Skip to content

Commit 68e3183

Browse files
committed
NTB/msi: Convert to msi_on_each_desc()
Replace the about to vanish iterators, make use of the filtering and take the descriptor lock around the iteration. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Logan Gunthorpe <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dc2b453 commit 68e3183

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/ntb/msi.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ int ntb_msi_setup_mws(struct ntb_dev *ntb)
108108
if (!ntb->msi)
109109
return -EINVAL;
110110

111-
desc = first_msi_entry(&ntb->pdev->dev);
111+
msi_lock_descs(&ntb->pdev->dev);
112+
desc = msi_first_desc(&ntb->pdev->dev, MSI_DESC_ASSOCIATED);
112113
addr = desc->msg.address_lo + ((uint64_t)desc->msg.address_hi << 32);
114+
msi_unlock_descs(&ntb->pdev->dev);
113115

114116
for (peer = 0; peer < ntb_peer_port_count(ntb); peer++) {
115117
peer_widx = ntb_peer_highest_mw_idx(ntb, peer);
@@ -281,13 +283,15 @@ int ntbm_msi_request_threaded_irq(struct ntb_dev *ntb, irq_handler_t handler,
281283
const char *name, void *dev_id,
282284
struct ntb_msi_desc *msi_desc)
283285
{
286+
struct device *dev = &ntb->pdev->dev;
284287
struct msi_desc *entry;
285288
int ret;
286289

287290
if (!ntb->msi)
288291
return -EINVAL;
289292

290-
for_each_pci_msi_entry(entry, ntb->pdev) {
293+
msi_lock_descs(dev);
294+
msi_for_each_desc(entry, dev, MSI_DESC_ASSOCIATED) {
291295
if (irq_has_action(entry->irq))
292296
continue;
293297

@@ -304,14 +308,17 @@ int ntbm_msi_request_threaded_irq(struct ntb_dev *ntb, irq_handler_t handler,
304308
ret = ntbm_msi_setup_callback(ntb, entry, msi_desc);
305309
if (ret) {
306310
devm_free_irq(&ntb->dev, entry->irq, dev_id);
307-
return ret;
311+
goto unlock;
308312
}
309313

310-
311-
return entry->irq;
314+
ret = entry->irq;
315+
goto unlock;
312316
}
317+
ret = -ENODEV;
313318

314-
return -ENODEV;
319+
unlock:
320+
msi_unlock_descs(dev);
321+
return ret;
315322
}
316323
EXPORT_SYMBOL(ntbm_msi_request_threaded_irq);
317324

0 commit comments

Comments
 (0)