From: Bjorn Helgaas <helgaas@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Marc Zyngier <maz@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Nishanth Menon <nm@ti.com>, Dhruva Gole <d-gole@ti.com>,
Tero Kristo <kristo@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
Logan Gunthorpe <logang@deltatee.com>,
Dave Jiang <dave.jiang@intel.com>, Jon Mason <jdmason@kudzu.us>,
Allen Hubbe <allenbh@gmail.com>,
ntb@lists.linux.dev, Michael Kelley <mhklinux@outlook.com>,
Wei Liu <wei.liu@kernel.org>, Bjorn Helgaas <bhelgaas@google.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org,
Wei Huang <wei.huang2@amd.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huwei.com>
Subject: Re: [patch V4 09/14] PCI/MSI: Switch msix_capability_init() to guard(msi_desc_lock)
Date: Wed, 19 Mar 2025 12:09:32 -0500 [thread overview]
Message-ID: <20250319170932.GA1046398@bhelgaas> (raw)
In-Reply-To: <20250319105506.564105011@linutronix.de>
On Wed, Mar 19, 2025 at 11:56:54AM +0100, Thomas Gleixner wrote:
> 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>
> ---
> V4: Split out from the previous combo patch
> ---
> drivers/pci/msi/msi.c | 36 ++++++++++++++++++++----------------
> 1 file changed, 20 insertions(+), 16 deletions(-)
>
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -663,35 +663,39 @@ static void msix_mask_all(void __iomem *
> writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
> }
>
> -static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries,
> - int nvec, struct irq_affinity *affd)
> +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 irq_affinity_desc *masks __free(kfree) =
> - affd ? irq_create_affinity_masks(nvec, affd) : NULL;
> - int ret;
> + struct pci_dev *dev __free(free_msi_irqs) = __dev;
>
> - msi_lock_descs(&dev->dev);
> - ret = msix_setup_msi_descs(dev, entries, nvec, masks);
> + int ret = msix_setup_msi_descs(dev, entries, nvec, masks);
> if (ret)
> - goto out_free;
> + return ret;
>
> ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
> if (ret)
> - goto out_free;
> + return ret;
>
> /* Check if all MSI entries honor device restrictions */
> ret = msi_verify_entries(dev);
> if (ret)
> - goto out_free;
> + return ret;
>
> + retain_ptr(dev);
> msix_update_entries(dev, entries);
> - goto out_unlock;
> + 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;
>
> -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);
> }
>
> /**
>
next prev parent reply other threads:[~2025-03-19 17:09 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 10:56 [patch V4 00/14] genirq/msi: Spring cleaning Thomas Gleixner
2025-03-19 10:56 ` [patch V4 01/14] cleanup: Provide retain_ptr() Thomas Gleixner
2025-03-19 20:15 ` James Bottomley
2025-03-19 10:56 ` [patch V4 02/14] genirq/msi: Use lock guards for MSI descriptor locking Thomas Gleixner
2025-03-19 10:56 ` [patch V4 03/14] soc: ti: ti_sci_inta_msi: Switch MSI descriptor locking to guard() Thomas Gleixner
2025-03-19 10:56 ` [patch V4 04/14] NTB/msi: Switch MSI descriptor locking to lock guard() Thomas Gleixner
2025-03-19 10:56 ` [patch V4 05/14] PCI/MSI: Use guard(msi_desc_lock) where applicable Thomas Gleixner
2025-03-19 17:08 ` Bjorn Helgaas
2025-03-19 10:56 ` [patch V4 06/14] PCI/MSI: Set pci_dev::msi_enabled late Thomas Gleixner
2025-03-19 17:08 ` Bjorn Helgaas
2025-03-19 10:56 ` [patch V4 07/14] PCI/MSI: Use __free() for affinity masks Thomas Gleixner
2025-03-19 17:09 ` Bjorn Helgaas
2025-03-19 10:56 ` [patch V4 08/14] PCI/MSI: Switch msi_capability_init() to guard(msi_desc_lock) Thomas Gleixner
2025-03-19 17:09 ` Bjorn Helgaas
2025-03-19 10:56 ` [patch V4 09/14] PCI/MSI: Switch msix_capability_init() " Thomas Gleixner
2025-03-19 17:09 ` Bjorn Helgaas [this message]
2025-04-08 12:04 ` commit 7b025f3f85ed causes NULL pointer dereference Bert Karwatzki
2025-04-08 15:09 ` Thomas Gleixner
2025-04-08 15:29 ` Thomas Gleixner
2025-04-08 16:20 ` Bert Karwatzki
2025-04-08 20:22 ` Klara Modin
2025-04-08 20:46 ` Thomas Gleixner
2025-04-09 11:44 ` Aithal, Srikanth
2025-04-09 11:49 ` Andy Shevchenko
2025-04-09 12:49 ` James Bottomley
2025-04-09 18:38 ` Thomas Gleixner
2025-04-09 15:22 ` Venkat Rao Bagalkote
2025-04-09 18:29 ` Borislav Petkov
2025-03-19 10:56 ` [patch V4 10/14] PCI: hv: Switch MSI descriptor locking to guard() Thomas Gleixner
2025-03-19 10:56 ` [patch V4 11/14] PCI/MSI: Provide a sane mechanism for TPH Thomas Gleixner
2025-06-17 23:22 ` Bjorn Helgaas
2025-06-17 23:25 ` Bjorn Helgaas
2025-03-19 10:56 ` [patch V4 12/14] PCI/TPH: Replace the broken MSI-X control word update Thomas Gleixner
2025-03-19 10:57 ` [patch V4 13/14] scsi: ufs: qcom: Remove the MSI descriptor abuse Thomas Gleixner
2025-03-19 20:40 ` James Bottomley
2025-03-19 10:57 ` [patch V4 14/14] genirq/msi: Rename msi_[un]lock_descs() Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250319170932.GA1046398@bhelgaas \
--to=helgaas@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Jonathan.Cameron@huwei.com \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=d-gole@ti.com \
--cc=dave.jiang@intel.com \
--cc=haiyangz@microsoft.com \
--cc=jdmason@kudzu.us \
--cc=kristo@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=maz@kernel.org \
--cc=mhklinux@outlook.com \
--cc=nm@ti.com \
--cc=ntb@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=ssantosh@kernel.org \
--cc=tglx@linutronix.de \
--cc=wei.huang2@amd.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox