From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
To: "kw@linux.com" <kw@linux.com>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"manivannan.sadhasivam@linaro.org"
<manivannan.sadhasivam@linaro.org>,
"lpieralisi@kernel.org" <lpieralisi@kernel.org>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"cassel@kernel.org" <cassel@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lukas@wunner.de" <lukas@wunner.de>
Subject: Re: [PATCH 1/2] PCI: Save and restore root port config space in pcibios_reset_secondary_bus()
Date: Sun, 25 May 2025 02:36:42 +0000 [thread overview]
Message-ID: <cfec2252044b208efef6ffd14a50f334528ceec3.camel@wdc.com> (raw)
In-Reply-To: <20250524185304.26698-2-manivannan.sadhasivam@linaro.org>
On Sun, 2025-05-25 at 00:23 +0530, Manivannan Sadhasivam wrote:
> host_bridge::reset_slot() is supposed to reset the PCI root
> port/slot. Once
> that happens, the config space content would be lost. This was
> reported by
> Niklas on the dw-rockchip based platform where the MPS setting of the
> root
> port was lost after the host_bridge::reset_slot() callback. Hence,
> save the
> config space before calling the host_bridge::reset_slot() callback
> and
> restore it afterwards.
>
> While at it, make sure that the callback is only called for root
> ports by
> checking if the bridge is behind the root bus.
>
> Fixes: d5c1e1c25b37 ("PCI/ERR: Add support for resetting the slots in
> a platform specific way")
> Reported-by: Niklas Cassel <cassel@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/aC9OrPAfpzB_A4K2@ryzen
> Suggested-by: Lukas Wunner <lukas@wunner.de>
> Signed-off-by: Manivannan Sadhasivam
> <manivannan.sadhasivam@linaro.org>
> ---
> drivers/pci/pci.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 4d396bbab4a8..6d6e9ce2bbcc 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4985,10 +4985,19 @@ void __weak
> pcibios_reset_secondary_bus(struct pci_dev *dev)
> struct pci_host_bridge *host = pci_find_host_bridge(dev-
> >bus);
> int ret;
>
> - if (host->reset_slot) {
> + if (pci_is_root_bus(dev->bus) && host->reset_slot) {
> + /*
> + * Save the config space of the root port before
> doing the
> + * reset, since the state could be lost. The device
> state
> + * should've been saved by the caller.
> + */
> + pci_save_state(dev);
> ret = host->reset_slot(host, dev);
> if (ret)
> pci_err(dev, "failed to reset slot: %d\n",
> ret);
> + else
> + /* Now restore it on success */
> + pci_restore_state(dev);
>
> return;
> }
Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
next prev parent reply other threads:[~2025-05-25 2:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-24 18:53 [PATCH 0/2] PCI: Slot reset fixes Manivannan Sadhasivam
2025-05-24 18:53 ` [PATCH 1/2] PCI: Save and restore root port config space in pcibios_reset_secondary_bus() Manivannan Sadhasivam
2025-05-24 20:54 ` Niklas Cassel
2025-05-25 2:36 ` Wilfred Mallawa [this message]
2025-05-25 7:22 ` Lukas Wunner
2025-05-25 7:58 ` Manivannan Sadhasivam
2025-05-26 6:54 ` Lukas Wunner
2025-05-26 11:16 ` Manivannan Sadhasivam
2025-05-24 18:53 ` [PATCH 2/2] PCI: Rename host_bridge::reset_slot() to host_bridge::reset_root_port() Manivannan Sadhasivam
2025-05-24 20:57 ` Niklas Cassel
2025-05-25 2:38 ` Wilfred Mallawa
2025-05-25 8:00 ` Manivannan Sadhasivam
2025-05-24 21:51 ` kernel test robot
2025-05-25 7:26 ` Lukas Wunner
2025-05-26 0:47 ` [PATCH 0/2] PCI: Slot reset fixes Wilfred Mallawa
2025-05-26 5:53 ` Manivannan Sadhasivam
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=cfec2252044b208efef6ffd14a50f334528ceec3.camel@wdc.com \
--to=wilfred.mallawa@wdc.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=lukas@wunner.de \
--cc=manivannan.sadhasivam@linaro.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