Commit 495c66ac authored by Thomas Gleixner's avatar Thomas Gleixner

genirq/msi: Convert to new functions

Use the new iterator functions and add locking where required.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarMichael Kelley <mikelley@microsoft.com>
Tested-by: default avatarNishanth Menon <nm@ti.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20211206210749.063705667@linutronix.de
parent ef8dd015
...@@ -320,6 +320,7 @@ EXPORT_SYMBOL_GPL(msi_next_desc); ...@@ -320,6 +320,7 @@ EXPORT_SYMBOL_GPL(msi_next_desc);
unsigned int msi_get_virq(struct device *dev, unsigned int index) unsigned int msi_get_virq(struct device *dev, unsigned int index)
{ {
struct msi_desc *desc; struct msi_desc *desc;
unsigned int ret = 0;
bool pcimsi; bool pcimsi;
if (!dev->msi.data) if (!dev->msi.data)
...@@ -327,11 +328,12 @@ unsigned int msi_get_virq(struct device *dev, unsigned int index) ...@@ -327,11 +328,12 @@ unsigned int msi_get_virq(struct device *dev, unsigned int index)
pcimsi = dev_is_pci(dev) ? to_pci_dev(dev)->msi_enabled : false; pcimsi = dev_is_pci(dev) ? to_pci_dev(dev)->msi_enabled : false;
for_each_msi_entry(desc, dev) { msi_lock_descs(dev);
msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) {
/* PCI-MSI has only one descriptor for multiple interrupts. */ /* PCI-MSI has only one descriptor for multiple interrupts. */
if (pcimsi) { if (pcimsi) {
if (desc->irq && index < desc->nvec_used) if (index < desc->nvec_used)
return desc->irq + index; ret = desc->irq + index;
break; break;
} }
...@@ -339,10 +341,13 @@ unsigned int msi_get_virq(struct device *dev, unsigned int index) ...@@ -339,10 +341,13 @@ unsigned int msi_get_virq(struct device *dev, unsigned int index)
* PCI-MSIX and platform MSI use a descriptor per * PCI-MSIX and platform MSI use a descriptor per
* interrupt. * interrupt.
*/ */
if (desc->msi_index == index) if (desc->msi_index == index) {
return desc->irq; ret = desc->irq;
break;
}
} }
return 0; msi_unlock_descs(dev);
return ret;
} }
EXPORT_SYMBOL_GPL(msi_get_virq); EXPORT_SYMBOL_GPL(msi_get_virq);
...@@ -373,7 +378,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev) ...@@ -373,7 +378,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev)
int i; int i;
/* Determine how many msi entries we have */ /* Determine how many msi entries we have */
for_each_msi_entry(entry, dev) msi_for_each_desc(entry, dev, MSI_DESC_ALL)
num_msi += entry->nvec_used; num_msi += entry->nvec_used;
if (!num_msi) if (!num_msi)
return NULL; return NULL;
...@@ -383,7 +388,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev) ...@@ -383,7 +388,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev)
if (!msi_attrs) if (!msi_attrs)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for_each_msi_entry(entry, dev) { msi_for_each_desc(entry, dev, MSI_DESC_ALL) {
for (i = 0; i < entry->nvec_used; i++) { for (i = 0; i < entry->nvec_used; i++) {
msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
if (!msi_dev_attr) if (!msi_dev_attr)
...@@ -803,7 +808,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain, ...@@ -803,7 +808,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain,
* Checking the first MSI descriptor is sufficient. MSIX supports * Checking the first MSI descriptor is sufficient. MSIX supports
* masking and MSI does so when the can_mask attribute is set. * masking and MSI does so when the can_mask attribute is set.
*/ */
desc = first_msi_entry(dev); desc = msi_first_desc(dev, MSI_DESC_ALL);
return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask; return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment