public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: <dan.j.williams@intel.com>
To: Keith Busch <kbusch@meta.com>, <linux-pci@vger.kernel.org>,
	<helgaas@kernel.org>
Cc: <alex@shazbot.org>, <lukas@wunner.de>, <dan.j.williams@intel.com>,
	<guojinhui.liam@bytedance.com>, <ilpo.jarvinen@linux.intel.com>,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCHv3 2/4] pci: allow all bus devices to use the same slot
Date: Tue, 10 Feb 2026 12:00:56 -0800	[thread overview]
Message-ID: <698b8e7894eb4_2e5710078@dwillia2-mobl4.notmuch> (raw)
In-Reply-To: <20260205212533.1512153-3-kbusch@meta.com>

Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> A pcie hot plug slot applies to the entire subordinate bus. Thus, pciehp
> only allocates a single hotplug slot for the bridge to that bus. The pci
> slot, though, would only match to functions on device 0, meaning any
> other device beyond that are not matched to any slot even though they
> all share the same slot.
> 
> Allow a slot to be created to claim all devices on a bus, not just a
> matching device. This is done by introducing a sential value, named

s/sential/sentinel/

> PCI_SLOT_ALL_DEVICES, which then has the pci slot match to any device on
> the bus. This fixes walking the slot's device list for ports that don't
> have device specific slots.
> 
> Since 0xff already has special meaning, the chose sentinal value for

s/sentinal/sentinel/

> this new feature is 0xfe. This will not clash with any actual slot
> number since they are limited to 5 bits.

Can you say a bit more about why other hotplug controller drivers can
continue to get away with a single device number as a hotplug slot
target?  For example, would you expect that the ACPI hotplug driver is
broken if an ARI device is added?

It looks like the goal of this sentinel is to turn all
pci_try_reset_slot() into pci_try_reset_bus() only for the native PCIe
hotplug controller, or did I miss a detail?

> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>  drivers/pci/hotplug/pciehp_core.c |  3 ++-
>  drivers/pci/slot.c                | 22 ++++++++++++++++++----
>  include/linux/pci.h               |  8 +++++++-
>  3 files changed, 27 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
> index f59baa9129709..d80346d567049 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -79,7 +79,8 @@ static int init_slot(struct controller *ctrl)
>  	snprintf(name, SLOT_NAME_SIZE, "%u", PSN(ctrl));
>  
>  	retval = pci_hp_initialize(&ctrl->hotplug_slot,
> -				   ctrl->pcie->port->subordinate, 0, name);
> +				   ctrl->pcie->port->subordinate,
> +				   PCI_SLOT_ALL_DEVICES, name);
>  	if (retval) {
>  		ctrl_err(ctrl, "pci_hp_initialize failed: error %d\n", retval);
>  		kfree(ops);
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 50fb3eb595fe6..647f6d2cceef6 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -41,6 +41,10 @@ static ssize_t address_read_file(struct pci_slot *slot, char *buf)
>  		return sysfs_emit(buf, "%04x:%02x\n",
>  				  pci_domain_nr(slot->bus),
>  				  slot->bus->number);
> +	if (slot->number == PCI_SLOT_ALL_DEVICES)
> +		return sysfs_emit(buf, "%04x:%02x:00\n",
> +				  pci_domain_nr(slot->bus),
> +				  slot->bus->number);

Why not treat the PCI_SLOT_ALL_DEVICES case the same as the 0xff case?

>  
>  	return sysfs_emit(buf, "%04x:%02x:%02x\n",
>  			  pci_domain_nr(slot->bus),
> @@ -73,7 +77,8 @@ static void pci_slot_release(struct kobject *kobj)
>  
>  	down_read(&pci_bus_sem);
>  	list_for_each_entry(dev, &slot->bus->devices, bus_list)
> -		if (PCI_SLOT(dev->devfn) == slot->number)
> +		if (slot->number == PCI_SLOT_ALL_DEVICES ||
> +		    PCI_SLOT(dev->devfn) == slot->number)

Maybe add a pci_slot_matches() helper for this pattern?

  reply	other threads:[~2026-02-10 20:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 21:25 [PATCHv3 0/4] pci slot reset handling fixes Keith Busch
2026-02-05 21:25 ` [PATCHv3 1/4] pci: rename __pci_bus_reset and __pci_slot_reset Keith Busch
2026-02-06 17:22   ` Keith Busch
2026-02-10 20:44   ` dan.j.williams
2026-02-05 21:25 ` [PATCHv3 2/4] pci: allow all bus devices to use the same slot Keith Busch
2026-02-10 20:00   ` dan.j.williams [this message]
2026-02-10 20:28     ` Keith Busch
2026-02-10 20:51       ` dan.j.williams
2026-02-05 21:25 ` [PATCHv3 3/4] pci: remove slot specific lock/unlock and save/restore Keith Busch
2026-02-10 22:03   ` dan.j.williams
2026-02-10 23:25     ` Keith Busch
2026-02-10 23:48       ` dan.j.williams
2026-02-10 23:46   ` Alex Williamson
2026-02-11  0:12     ` Keith Busch
2026-02-11 15:22       ` Alex Williamson
2026-02-11 15:54         ` Keith Busch
2026-02-05 21:25 ` [PATCHv3 4/4] pci: make reset_subordinate hotplug safe Keith Busch
2026-02-10 22:14   ` dan.j.williams

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=698b8e7894eb4_2e5710078@dwillia2-mobl4.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=alex@shazbot.org \
    --cc=guojinhui.liam@bytedance.com \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.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