linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Marc Zyngier <maz@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>, <linux-pci@vger.kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	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>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	<linux-hyperv@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 V2 05/10] PCI/MSI: Switch to MSI descriptor locking to guard()
Date: Thu, 13 Mar 2025 15:50:15 +0000	[thread overview]
Message-ID: <20250313155015.000037f5@huawei.com> (raw)
In-Reply-To: <20250313130321.695027112@linutronix.de>

On Thu, 13 Mar 2025 14:03:44 +0100 (CET)
Thomas Gleixner <tglx@linutronix.de> wrote:

> Convert the code to use the new guard(msi_descs_lock).
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> ---
> V2: Remove the gotos - Jonathan
Hi Thomas,


There is a bit of the original code that is carried forwards here
that superficially seemed overly complex.  However as far as I can tell
this is functionally the same as you intended.  So with that in mind
if my question isn't complete garbage, maybe a readability issue for
another day.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c



> +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;
> +
> +	guard(msi_descs_lock)(&dev->dev);
> +	int ret = __msix_setup_interrupts(dev, entries, nvec, masks);
> +	if (ret)
> +		pci_free_msi_irqs(dev);

It's not immediately obvious what this is undoing (i.e. where the alloc
is).  I think it is at least mostly the pci_msi_setup_msi_irqs in
__msix_setup_interrupts

Why not handle the error in __msix_setup_interrupts and make that function
side effect free.  Does require gotos but in a function that isn't
doing any cleanup magic so should be fine.

Mind you I'm not following the logic in msix_setup_interrupts()
before this series either. i.e. why doesn't msix_setup_msi_descs()
clean up after itself on failure (i.e. undo loop iterations that
weren't failures) as that at least superficially looks like it
would give more readable code.

So this is the same as current and as such the patch is fine I think.

>  	return ret;
>  }
>  



  reply	other threads:[~2025-03-13 15:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 13:03 [patch V2 00/10] genirq/msi: Spring cleaning Thomas Gleixner
2025-03-13 13:03 ` [patch V2 01/10] cleanup: Provide retain_ptr() Thomas Gleixner
2025-03-13 15:24   ` Jonathan Cameron
2025-03-14  9:37   ` Peter Zijlstra
2025-03-14 14:04   ` Frank Li
2025-03-13 13:03 ` [patch V2 02/10] genirq/msi: Use lock guards for MSI descriptor locking Thomas Gleixner
2025-03-13 15:26   ` Jonathan Cameron
2025-03-13 13:03 ` [patch V2 03/10] soc: ti: ti_sci_inta_msi: Switch MSI descriptor locking to guard() Thomas Gleixner
2025-03-13 13:03 ` [patch V2 04/10] NTB/msi: Switch MSI descriptor locking to lock guard() Thomas Gleixner
2025-03-13 13:03 ` [patch V2 05/10] PCI/MSI: Switch to MSI descriptor locking to guard() Thomas Gleixner
2025-03-13 15:50   ` Jonathan Cameron [this message]
2025-03-13 17:55     ` Thomas Gleixner
2025-03-14  9:42       ` Peter Zijlstra
2025-03-13 13:03 ` [patch V2 06/10] PCI: hv: Switch " Thomas Gleixner
2025-03-13 13:03 ` [patch V2 07/10] PCI/MSI: Provide a sane mechanism for TPH Thomas Gleixner
2025-03-13 13:03 ` [patch V2 08/10] PCI/TPH: Replace the broken MSI-X control word update Thomas Gleixner
2025-03-13 13:03 ` [patch V2 09/10] scsi: ufs: qcom: Remove the MSI descriptor abuse Thomas Gleixner
2025-03-28 10:00   ` Dan Carpenter
2025-03-28 14:05     ` Thomas Gleixner
2025-03-13 13:03 ` [patch V2 10/10] 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=20250313155015.000037f5@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=James.Bottomley@HansenPartnership.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;
as well as URLs for NNTP newsgroup(s).