Skip to content

Commit 495c66a

Browse files
committed
genirq/msi: Convert to new functions
Use the new iterator functions and add locking where required. Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Nishanth Menon <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ef8dd01 commit 495c66a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

kernel/irq/msi.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,29 +320,34 @@ EXPORT_SYMBOL_GPL(msi_next_desc);
320320
unsigned int msi_get_virq(struct device *dev, unsigned int index)
321321
{
322322
struct msi_desc *desc;
323+
unsigned int ret = 0;
323324
bool pcimsi;
324325

325326
if (!dev->msi.data)
326327
return 0;
327328

328329
pcimsi = dev_is_pci(dev) ? to_pci_dev(dev)->msi_enabled : false;
329330

330-
for_each_msi_entry(desc, dev) {
331+
msi_lock_descs(dev);
332+
msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) {
331333
/* PCI-MSI has only one descriptor for multiple interrupts. */
332334
if (pcimsi) {
333-
if (desc->irq && index < desc->nvec_used)
334-
return desc->irq + index;
335+
if (index < desc->nvec_used)
336+
ret = desc->irq + index;
335337
break;
336338
}
337339

338340
/*
339341
* PCI-MSIX and platform MSI use a descriptor per
340342
* interrupt.
341343
*/
342-
if (desc->msi_index == index)
343-
return desc->irq;
344+
if (desc->msi_index == index) {
345+
ret = desc->irq;
346+
break;
347+
}
344348
}
345-
return 0;
349+
msi_unlock_descs(dev);
350+
return ret;
346351
}
347352
EXPORT_SYMBOL_GPL(msi_get_virq);
348353

@@ -373,7 +378,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev)
373378
int i;
374379

375380
/* Determine how many msi entries we have */
376-
for_each_msi_entry(entry, dev)
381+
msi_for_each_desc(entry, dev, MSI_DESC_ALL)
377382
num_msi += entry->nvec_used;
378383
if (!num_msi)
379384
return NULL;
@@ -383,7 +388,7 @@ static const struct attribute_group **msi_populate_sysfs(struct device *dev)
383388
if (!msi_attrs)
384389
return ERR_PTR(-ENOMEM);
385390

386-
for_each_msi_entry(entry, dev) {
391+
msi_for_each_desc(entry, dev, MSI_DESC_ALL) {
387392
for (i = 0; i < entry->nvec_used; i++) {
388393
msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
389394
if (!msi_dev_attr)
@@ -803,7 +808,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain,
803808
* Checking the first MSI descriptor is sufficient. MSIX supports
804809
* masking and MSI does so when the can_mask attribute is set.
805810
*/
806-
desc = first_msi_entry(dev);
811+
desc = msi_first_desc(dev, MSI_DESC_ALL);
807812
return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask;
808813
}
809814

0 commit comments

Comments
 (0)