From: Bjorn Helgaas <helgaas@kernel.org>
To: Philipp Stanner <pstanner@redhat.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Damien Le Moal" <dlemoal@kernel.org>,
"Christoph Hellwig" <hch@infradead.org>
Subject: Re: [PATCH] PCI: Fix devres regression in pci_intx()
Date: Thu, 25 Jul 2024 16:00:16 -0500 [thread overview]
Message-ID: <20240725210016.GA859301@bhelgaas> (raw)
In-Reply-To: <20240725120729.59788-2-pstanner@redhat.com>
[+cc Christoph]
On Thu, Jul 25, 2024 at 02:07:30PM +0200, Philipp Stanner wrote:
> pci_intx() is a function that becomes managed if pcim_enable_device()
> has been called in advance. Commit 25216afc9db5 ("PCI: Add managed
> pcim_intx()") changed this behavior so that pci_intx() always leads to
> creation of a separate device resource for itself, whereas earlier, a
> shared resource was used for all PCI devres operations.
>
> Unfortunately, pci_intx() seems to be used in some drivers' remove()
> paths; in the managed case this causes a device resource to be created
> on driver detach.
>
> Fix the regression by only redirecting pci_intx() to its managed twin
> pcim_intx() if the pci_command changes.
>
> Fixes: 25216afc9db5 ("PCI: Add managed pcim_intx()")
> Reported-by: Damien Le Moal <dlemoal@kernel.org>
> Closes: https://lore.kernel.org/all/b8f4ba97-84fc-4b7e-ba1a-99de2d9f0118@kernel.org/
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Applied to for-linus for v6.11, thanks!
> ---
> Alright, I reproduced this with QEMU as Damien described and this here
> fixes the issue on my side. Feedback welcome. Thank you very much,
> Damien.
>
> It seems that this might yet again be the issue of drivers not being
> aware that pci_intx() might become managed, so they use it in their
> unwind path (rightfully so; there probably was no alternative back
> then).
>
> That will make the long term cleanup difficult. But I think this for now
> is the most elegant possible workaround.
> ---
> drivers/pci/pci.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e3a49f66982d..ffaaca0978cb 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4477,12 +4477,6 @@ void pci_intx(struct pci_dev *pdev, int enable)
> {
> u16 pci_command, new;
>
> - /* Preserve the "hybrid" behavior for backwards compatibility */
> - if (pci_is_managed(pdev)) {
> - WARN_ON_ONCE(pcim_intx(pdev, enable) != 0);
> - return;
> - }
> -
> pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
>
> if (enable)
> @@ -4490,8 +4484,15 @@ void pci_intx(struct pci_dev *pdev, int enable)
> else
> new = pci_command | PCI_COMMAND_INTX_DISABLE;
>
> - if (new != pci_command)
> + if (new != pci_command) {
> + /* Preserve the "hybrid" behavior for backwards compatibility */
> + if (pci_is_managed(pdev)) {
> + WARN_ON_ONCE(pcim_intx(pdev, enable) != 0);
> + return;
> + }
> +
> pci_write_config_word(pdev, PCI_COMMAND, new);
> + }
> }
> EXPORT_SYMBOL_GPL(pci_intx);
>
> --
> 2.45.2
>
next prev parent reply other threads:[~2024-07-25 21:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 12:07 [PATCH] PCI: Fix devres regression in pci_intx() Philipp Stanner
2024-07-25 14:26 ` Christoph Hellwig
2024-07-25 15:21 ` Philipp Stanner
2024-07-25 15:47 ` Christoph Hellwig
2024-07-25 21:00 ` Bjorn Helgaas [this message]
2024-07-26 0:19 ` Damien Le Moal
2024-07-26 18:43 ` pstanner
2024-07-26 18:59 ` Bjorn Helgaas
2024-07-29 11:29 ` Damien Le Moal
2024-07-29 15:45 ` Philipp Stanner
2024-09-03 15:44 ` Alex Williamson
2024-09-04 7:06 ` Philipp Stanner
2024-09-04 8:25 ` Damien Le Moal
2024-09-04 13:37 ` Philipp Stanner
2024-09-04 18:07 ` Alex Williamson
2024-09-04 20:24 ` Andy Shevchenko
2024-09-04 21:10 ` Alex Williamson
2024-09-05 0:33 ` Damien Le Moal
2024-09-05 1:56 ` Alex Williamson
2024-09-05 7:13 ` Philipp Stanner
2024-09-06 0:37 ` Damien Le Moal
2024-09-06 6:45 ` Philipp Stanner
2024-09-04 12:57 ` Alex Williamson
2024-09-04 13:29 ` Philipp Stanner
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=20240725210016.GA859301@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=dlemoal@kernel.org \
--cc=hch@infradead.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=pstanner@redhat.com \
/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