Re: [patch V4 05/14] PCI/MSI: Use guard(msi_desc_lock) where applicable

Bjorn Helgaas
2025-03-19T17:08:18Z

On Wed, Mar 19, 2025 at 11:56:47AM +0100, Thomas Gleixner wrote:
> Convert the trivial cases of msi_desc_lock/unlock() pairs.
>
> No functional change.
>
> 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/api.c | 6 ++----
> drivers/pci/msi/msi.c | 12 ++++++------
> 2 files changed, 8 insertions(+), 10 deletions(-)
>
> --- a/drivers/pci/msi/api.c
> +++ b/drivers/pci/msi/api.c
> @@ -53,10 +53,9 @@ void pci_disable_msi(struct pci_dev *dev
> if (!pci_msi_enabled() || !dev || !dev->msi_enabled)
> return;
>
> - msi_lock_descs(&dev->dev);
> + guard(msi_descs_lock)(&dev->dev);
> pci_msi_shutdown(dev);
> pci_free_msi_irqs(dev);
> - msi_unlock_descs(&dev->dev);
> }
> EXPORT_SYMBOL(pci_disable_msi);
>
> @@ -196,10 +195,9 @@ void pci_disable_msix(struct pci_dev *de
> if (!pci_msi_enabled() || !dev || !dev->msix_enabled)
> return;
>
> - msi_lock_descs(&dev->dev);
> + guard(msi_descs_lock)(&dev->dev);
> pci_msix_shutdown(dev);
> pci_free_msi_irqs(dev);
> - msi_unlock_descs(&dev->dev);
> }
> EXPORT_SYMBOL(pci_disable_msix);
>
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -871,13 +871,13 @@ void __pci_restore_msix_state(struct pci
>
> write_msg = arch_restore_msi_irqs(dev);
>
> - msi_lock_descs(&dev->dev);
> - msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
> - if (write_msg)
> - __pci_write_msi_msg(entry, &entry->msg);
> - pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl);
> + scoped_guard (msi_descs_lock, &dev->dev) {
> + msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
> + if (write_msg)
> + __pci_write_msi_msg(entry, &entry->msg);
> + pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl);
> + }
> }
> - msi_unlock_descs(&dev->dev);
>
> pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
> }
>