mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Mario Limonciello" <mario.limonciello@amd.com>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: Oz Tiram <oz@shift-computing.de>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus
Date: Tue, 27 Oct 2026 10:11:31 +0530	[thread overview]
Message-ID: <bb135cd6-5e36-4330-9635-885bb26576e3@amd.com> (raw)
In-Reply-To: <20261026-vfct-regression-v3-1-fe9586ed6978@amd.com>



On 26-Oct-26 9:18 PM, Mario Limonciello wrote:
> Bridges that need bus reassignment are scanned in two passes. Save
> the firmware secondary bus number during the first pass, before the
> bridge is disabled, and carry it to the bus created in the second
> pass. Drivers can then match firmware records against the bus number
> from before PCI bus renumbering.
> 
> The initial number belongs to the bus, so consumers can use the
> pci_bus value directly without copying it into every pci_dev.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/pci/probe.c | 9 +++++++++
>   include/linux/pci.h | 2 ++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 27008e2ea5afc..9950a9dd1db1f 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1012,6 +1012,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
>   	bus->sysdata = bridge->sysdata;
>   	bus->ops = bridge->ops;
>   	bus->number = bus->busn_res.start = bridge->busnr;
> +	bus->number_initial = bus->number;
>   #ifdef CONFIG_PCI_DOMAINS_GENERIC
>   	if (bridge->domain_nr == PCI_DOMAIN_NR_NOT_SET)
>   		bus->domain_nr = pci_bus_find_domain_nr(bus, parent);
> @@ -1232,6 +1233,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
>   
>   	/* Set up the primary, secondary and subordinate bus numbers */
>   	child->number = child->busn_res.start = busnr;
> +	child->number_initial = busnr;
>   	child->primary = parent->busn_res.start;
>   	child->busn_res.end = 0xff;
>   
> @@ -1470,6 +1472,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
>   			child = pci_add_new_bus(bus, dev, secondary);
>   			if (!child)
>   				goto out;
> +			child->number_initial = secondary;
>   			child->primary = primary;
>   			pci_bus_insert_busn_res(child, secondary, subordinate);
>   			child->bridge_ctl = bctl;
> @@ -1491,6 +1494,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
>   		 * do in the second pass.
>   		 */
>   		if (!pass) {
> +			if (!dev->secondary_busnr)
> +				dev->secondary_busnr = secondary;
>   			if (pcibios_assign_all_busses() || broken)
>   
>   				/*
> @@ -1529,6 +1534,10 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
>   			pci_bus_insert_busn_res(child, next_busnr,
>   						bus->busn_res.end);
>   		}
> +		if (dev->secondary_busnr) {
> +			child->number_initial = dev->secondary_busnr;
> +			dev->secondary_busnr = 0;
> +		}
>   		max++;
>   		if (available_buses)
>   			available_buses--;
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 5ffcf5ce8c966..75a5fd2374acb 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -363,6 +363,7 @@ struct pci_dev {
>   	struct pci_slot	*slot;		/* Physical slot this device is in */
>   
>   	unsigned int	devfn;		/* Encoded device & function index */
> +	u8		secondary_busnr;	/* Original secondary bus number */

This doesn't make sense for end point devices. Is it possible to keep 
under bus itself?

Thanks,
Lijo

>   	unsigned short	vendor;
>   	unsigned short	device;
>   	unsigned short	subsystem_vendor;
> @@ -724,6 +725,7 @@ struct pci_bus {
>   	struct proc_dir_entry *procdir;	/* Directory entry in /proc/bus/pci */
>   
>   	unsigned char	number;		/* Bus number */
> +	unsigned char	number_initial;	/* Bus number before reassignment */
>   	unsigned char	primary;	/* Number of primary bridge */
>   	unsigned char	max_bus_speed;	/* enum pci_bus_speed */
>   	unsigned char	cur_bus_speed;	/* enum pci_bus_speed */
> 


  reply	other threads:[~2026-10-27  4:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 15:48 [PATCH v3 0/3] Fix amdgpu detection of pci=realloc Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 1/3] PCI: Preserve the initial bus number in pci_bus Mario Limonciello
2026-10-27  4:41   ` Lazar, Lijo [this message]
2026-10-26 15:48 ` [PATCH v3 2/3] drm/amdgpu: Match VFCT using initial PCI bus number Mario Limonciello
2026-10-26 15:51   ` Mario Limonciello
2026-10-26 15:48 ` [PATCH v3 3/3] drm/radeon: " Mario Limonciello
2026-10-26 15:51   ` Mario Limonciello

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=bb135cd6-5e36-4330-9635-885bb26576e3@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=oz@shift-computing.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

all inboxes | Powered by JetHome®