mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
PCI/MSI: Switch msix_capability_init() to guard(msi_desc_lock)
Split the lock protected functionality of msix_capability_init() out into a helper function and use guard(msi_desc_lock) to replace the lock/unlock pair. Simplify the error path in the helper function by utilizing a custom cleanup to get rid of the remaining gotos. No functional change intended. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/all/20250319105506.564105011@linutronix.de
This commit is contained in:
parent
f11cc2af8f
commit
891146645e
|
|
@ -660,35 +660,39 @@ static void msix_mask_all(void __iomem *base, int tsize)
|
|||
writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
|
||||
}
|
||||
|
||||
DEFINE_FREE(free_msi_irqs, struct pci_dev *, if (_T) pci_free_msi_irqs(_T));
|
||||
|
||||
static int __msix_setup_interrupts(struct pci_dev *__dev, struct msix_entry *entries,
|
||||
int nvec, struct irq_affinity_desc *masks)
|
||||
{
|
||||
struct pci_dev *dev __free(free_msi_irqs) = __dev;
|
||||
|
||||
int ret = msix_setup_msi_descs(dev, entries, nvec, masks);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Check if all MSI entries honor device restrictions */
|
||||
ret = msi_verify_entries(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
msix_update_entries(dev, entries);
|
||||
retain_and_null_ptr(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
|
||||
int nvec, struct irq_affinity *affd)
|
||||
{
|
||||
struct irq_affinity_desc *masks __free(kfree) =
|
||||
affd ? irq_create_affinity_masks(nvec, affd) : NULL;
|
||||
int ret;
|
||||
|
||||
msi_lock_descs(&dev->dev);
|
||||
ret = msix_setup_msi_descs(dev, entries, nvec, masks);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
|
||||
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
|
||||
/* Check if all MSI entries honor device restrictions */
|
||||
ret = msi_verify_entries(dev);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
|
||||
msix_update_entries(dev, entries);
|
||||
goto out_unlock;
|
||||
|
||||
out_free:
|
||||
pci_free_msi_irqs(dev);
|
||||
out_unlock:
|
||||
msi_unlock_descs(&dev->dev);
|
||||
return ret;
|
||||
guard(msi_descs_lock)(&dev->dev);
|
||||
return __msix_setup_interrupts(dev, entries, nvec, masks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user