public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] PCI: Fix premature removal from realloc_head list
@ 2026-03-13  8:45 Ilpo Järvinen
  2026-03-13 14:52 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2026-03-13  8:45 UTC (permalink / raw)
  To: Bjorn Helgaas, Ilpo Järvinen, linux-pci, linux-kernel; +Cc: Peter Nisbet

reassign_resources_sorted() checks for two things:

a) Resource assignment failures for mandatory resources by checking if
   the resource remains unassigned, which are known to always repeat,
   and does not attempt to assign them again.

b) That resource is not among the ones being processed/assigned at this
   stage, leading to skip processing such resources in
   reassign_resources_sorted() as well (resource assignment progresses
   one PCI hierarchy level at a time).

The problem here is that a) is checked before b) but b) also implies
the resources is not being assigned yet, making also a) true. As a)
only skips resource assignment but still removes the resource from
realloc_head, the later stages that would need to process the
information in realloc_head cannot obtain the optional size information
anymore. This leads to considering only non-optional part for bridge
windows deeper in the PCI hierarchy.

This problem has been observed during rescan (add_size is not
considered while attempting assignment for 0000:e2:00.0 indicating the
corresponding entry was removed from realloc_head while processing
resource assignments for 0000:e1):

pci_bus 0000:e1: scanning bus
...
pci 0000:e3:01.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref] to [bus e4] add_size 60c000000 add_align 800000000
pci 0000:e3:01.0: bridge window [mem 0x00100000-0x000fffff] to [bus e4] add_size 200000 add_align 200000
pci 0000:e3:02.0: disabling bridge window [mem 0x00000000-0x000fffff 64bit pref] to [bus e5] (unused)
pci 0000:e2:00.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref] to [bus e3-e5] add_size 60c000000 add_align 800000000
pci 0000:e2:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus e3-e5] add_size 200000 add_align 200000
pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: can't assign; no space
pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: failed to assign
pcieport 0000:e1:02.0: bridge window [io  0x1000-0x2fff]: resource restored
pcieport 0000:e1:02.0: bridge window [io  0x1000-0x2fff]: resource restored
pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: can't assign; no space
pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: failed to assign
pci 0000:e2:00.0: bridge window [mem 0x28f000000000-0x28f800ffffff 64bit pref]: assigned

Fixes: 96336ec70264 ("PCI: Perform reset_resource() and build fail list in sync")
Reported-by: Peter Nisbet <peter.nisbet@intel.com>
Tested-by: Peter Nisbet <peter.nisbet@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---

There's no publically available report on this, thus no Link/Closes tags.

 drivers/pci/setup-bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 61f769aaa2f6..b0b00f10e31c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -434,6 +434,10 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
 		dev = add_res->dev;
 		idx = pci_resource_num(dev, res);
 
+		/* Skip this resource if not found in head list */
+		if (!res_to_dev_res(head, res))
+			continue;
+
 		/*
 		 * Skip resource that failed the earlier assignment and is
 		 * not optional as it would just fail again.
@@ -442,10 +446,6 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
 		    !pci_resource_is_optional(dev, idx))
 			goto out;
 
-		/* Skip this resource if not found in head list */
-		if (!res_to_dev_res(head, res))
-			continue;
-
 		res_name = pci_resource_name(dev, idx);
 		add_size = add_res->add_size;
 		align = add_res->min_align;

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] PCI: Fix premature removal from realloc_head list
  2026-03-13  8:45 [PATCH 1/1] PCI: Fix premature removal from realloc_head list Ilpo Järvinen
@ 2026-03-13 14:52 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2026-03-13 14:52 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: Bjorn Helgaas, linux-pci, linux-kernel, Peter Nisbet

On Fri, Mar 13, 2026 at 10:45:50AM +0200, Ilpo Järvinen wrote:
> reassign_resources_sorted() checks for two things:
> 
> a) Resource assignment failures for mandatory resources by checking if
>    the resource remains unassigned, which are known to always repeat,
>    and does not attempt to assign them again.
> 
> b) That resource is not among the ones being processed/assigned at this
>    stage, leading to skip processing such resources in
>    reassign_resources_sorted() as well (resource assignment progresses
>    one PCI hierarchy level at a time).
> 
> The problem here is that a) is checked before b) but b) also implies
> the resources is not being assigned yet, making also a) true. As a)
> only skips resource assignment but still removes the resource from
> realloc_head, the later stages that would need to process the
> information in realloc_head cannot obtain the optional size information
> anymore. This leads to considering only non-optional part for bridge
> windows deeper in the PCI hierarchy.
> 
> This problem has been observed during rescan (add_size is not
> considered while attempting assignment for 0000:e2:00.0 indicating the
> corresponding entry was removed from realloc_head while processing
> resource assignments for 0000:e1):
> 
> pci_bus 0000:e1: scanning bus
> ...
> pci 0000:e3:01.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref] to [bus e4] add_size 60c000000 add_align 800000000
> pci 0000:e3:01.0: bridge window [mem 0x00100000-0x000fffff] to [bus e4] add_size 200000 add_align 200000
> pci 0000:e3:02.0: disabling bridge window [mem 0x00000000-0x000fffff 64bit pref] to [bus e5] (unused)
> pci 0000:e2:00.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref] to [bus e3-e5] add_size 60c000000 add_align 800000000
> pci 0000:e2:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus e3-e5] add_size 200000 add_align 200000
> pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: can't assign; no space
> pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: failed to assign
> pcieport 0000:e1:02.0: bridge window [io  0x1000-0x2fff]: resource restored
> pcieport 0000:e1:02.0: bridge window [io  0x1000-0x2fff]: resource restored
> pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: can't assign; no space
> pcieport 0000:e1:02.0: bridge window [io  size 0x2000]: failed to assign
> pci 0000:e2:00.0: bridge window [mem 0x28f000000000-0x28f800ffffff 64bit pref]: assigned
> 
> Fixes: 96336ec70264 ("PCI: Perform reset_resource() and build fail list in sync")
> Reported-by: Peter Nisbet <peter.nisbet@intel.com>
> Tested-by: Peter Nisbet <peter.nisbet@intel.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Applied to pci/resource for v7.1, thanks, Ilpo!

> ---
> 
> There's no publically available report on this, thus no Link/Closes tags.
> 
>  drivers/pci/setup-bus.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 61f769aaa2f6..b0b00f10e31c 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -434,6 +434,10 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
>  		dev = add_res->dev;
>  		idx = pci_resource_num(dev, res);
>  
> +		/* Skip this resource if not found in head list */
> +		if (!res_to_dev_res(head, res))
> +			continue;
> +
>  		/*
>  		 * Skip resource that failed the earlier assignment and is
>  		 * not optional as it would just fail again.
> @@ -442,10 +446,6 @@ static void reassign_resources_sorted(struct list_head *realloc_head,
>  		    !pci_resource_is_optional(dev, idx))
>  			goto out;
>  
> -		/* Skip this resource if not found in head list */
> -		if (!res_to_dev_res(head, res))
> -			continue;
> -
>  		res_name = pci_resource_name(dev, idx);
>  		add_size = add_res->add_size;
>  		align = add_res->min_align;
> 
> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
> -- 
> 2.39.5
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-13 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  8:45 [PATCH 1/1] PCI: Fix premature removal from realloc_head list Ilpo Järvinen
2026-03-13 14:52 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox