public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Keith Busch <kbusch@meta.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
	Keith Busch <kbusch@kernel.org>,
	Alex Williamson <alex@shazbot.org>,
	Lukas Wunner <lukas@wunner.de>
Subject: Re: [PATCH] pci: make reset_subordinate hotplug safe
Date: Wed, 14 Jan 2026 13:18:28 -0600	[thread overview]
Message-ID: <20260114191828.GA830415@bhelgaas> (raw)
In-Reply-To: <20260114185821.704089-1-kbusch@meta.com>

[+cc Alex, Lukas]

On Wed, Jan 14, 2026 at 10:58:21AM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> Use the slot reset method when resetting the bridge if the bus contains
> hotplug slots. This fixes spurious hotplug events the secondary bus
> reset triggers by utilizing slot's specific reset callback that ignores
> link events.

What do these spurious events look like in dmesg?

> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> The new function introduced here is essentially the same as
> pci_bus_error_reset, except it uses the reset functions that save and
> restore the device. This is the same as before if not resetting a
> hotplug slot.
> 
>  drivers/pci/pci-sysfs.c |  3 +--
>  drivers/pci/pci.c       | 27 +++++++++++++++++++++++++++
>  drivers/pci/pci.h       |  2 +-
>  3 files changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 3881359440b1a..5c7c6f0c435f3 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -553,7 +553,6 @@ static ssize_t reset_subordinate_store(struct device *dev,
>  				const char *buf, size_t count)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
> -	struct pci_bus *bus = pdev->subordinate;
>  	unsigned long val;
>  
>  	if (!capable(CAP_SYS_ADMIN))
> @@ -563,7 +562,7 @@ static ssize_t reset_subordinate_store(struct device *dev,
>  		return -EINVAL;
>  
>  	if (val) {
> -		int ret = __pci_reset_bus(bus);
> +		int ret = pci_reset_bridge(pdev);
>  
>  		if (ret)
>  			return ret;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b14dd064006cc..ca426ff68c820 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5747,6 +5747,33 @@ int __pci_reset_bus(struct pci_bus *bus)
>  	return rc;
>  }
>  
> +int pci_reset_bridge(struct pci_dev *bridge)
> +{
> +	struct pci_bus *bus = bridge->subordinate;
> +	struct pci_slot *slot;
> +
> +	if (!bus)
> +		return -ENOTTY;
> +
> +	mutex_lock(&pci_slot_mutex);
> +	if (list_empty(&bus->slots))
> +		goto bus_reset;
> +
> +	list_for_each_entry(slot, &bus->slots, list)
> +		if (pci_probe_reset_slot(slot))
> +			goto bus_reset;
> +
> +	list_for_each_entry(slot, &bus->slots, list)
> +		if (__pci_reset_slot(slot))
> +			goto bus_reset;
> +
> +	mutex_unlock(&pci_slot_mutex);
> +	return 0;
> +bus_reset:
> +	mutex_unlock(&pci_slot_mutex);
> +	return __pci_reset_bus(bus);
> +}
> +
>  /**
>   * pci_reset_bus - Try to reset a PCI bus
>   * @pdev: top level PCI device to reset via slot/bus
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 36f8c0985430a..f216e7a37d726 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -197,7 +197,7 @@ bool pci_reset_supported(struct pci_dev *dev);
>  void pci_init_reset_methods(struct pci_dev *dev);
>  int pci_bridge_secondary_bus_reset(struct pci_dev *dev);
>  int pci_bus_error_reset(struct pci_dev *dev);
> -int __pci_reset_bus(struct pci_bus *bus);
> +int pci_reset_bridge(struct pci_dev *dev);
>  
>  struct pci_cap_saved_data {
>  	u16		cap_nr;
> -- 
> 2.47.3
> 

  reply	other threads:[~2026-01-14 19:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 18:58 [PATCH] pci: make reset_subordinate hotplug safe Keith Busch
2026-01-14 19:18 ` Bjorn Helgaas [this message]
2026-01-14 19:24   ` Keith Busch
2026-01-15 10:45 ` kernel test robot
2026-01-15 11:29 ` kernel test robot
2026-01-15 17:38 ` kernel test robot

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=20260114191828.GA830415@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=alex@shazbot.org \
    --cc=bhelgaas@google.com \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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