linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Ross Lagerwall <ross.lagerwall@citrix.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Release coalesced resource
Date: Fri, 9 Jun 2023 16:45:30 -0500	[thread overview]
Message-ID: <20230609214530.GA1262596@bhelgaas> (raw)
In-Reply-To: <20230525153248.712779-1-ross.lagerwall@citrix.com>

On Thu, May 25, 2023 at 04:32:48PM +0100, Ross Lagerwall wrote:
> When contiguous windows are coalesced, the resource is invalidated and
> consequently not added to the bus. However, it remains in the resource
> hierarchy:
> 
> ...
>   ef2fff00-ef2fffff : 0000:00:13.2
>     ef2fff00-ef2fffff : ehci_hcd
> 00000000-00000000 : PCI Bus 0000:00
> f0000000-f3ffffff : PCI MMCONFIG 0000 [bus 00-3f]
>   f0000000-f3ffffff : Reserved
> ...
> 
> In some cases (e.g. the Xen scratch region), this causes future calls to
> allocate_resource() to choose an inappropriate location which the caller
> cannot handle. Fix by releasing the resource and removing from the
> hierarchy.
> 
> Fixes: 7c3855c423b1 ("PCI: Coalesce host bridge contiguous apertures")
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Applied to pci/resource for v6.5 with the commit log updated as below,
thanks!

Please let me know if I missed something, which is quite possible
because I don't know how to make the example in the commit log above
fit with the example in [1]:

  fec00000-fec7ffff : PCI Bus 0000:00
    fec00000-fec003ff : IOAPIC 0
  fec80000-fecbffff : PCI Bus 0000:00
    fec80000-fec803ff : IOAPIC 1
    fec90000-fec93fff : pnp 00:06

But maybe that's just because they're from different systems or
something.

Bjorn

[1] https://lore.kernel.org/r/DM6PR03MB53722DA6DF0E5D4E43C40753F051A@DM6PR03MB5372.namprd03.prod.outlook.com

    PCI: Release resource invalidated by coalescing
    
    When contiguous windows are coalesced by pci_register_host_bridge(), the
    second resource is expanded to include the first, and the first is
    invalidated and consequently not added to the bus. However, it remains in
    the resource hierarchy.  For example, these windows:
    
      fec00000-fec7ffff : PCI Bus 0000:00
      fec80000-fecbffff : PCI Bus 0000:00
    
    are coalesced into this, where the first resource remains in the tree with
    start/end zeroed out:
    
      00000000-00000000 : PCI Bus 0000:00
      fec00000-fecbffff : PCI Bus 0000:00
    
    In some cases (e.g. the Xen scratch region), this causes future calls to
    allocate_resource() to choose an inappropriate location which the caller
    cannot handle.
    
    Fix by releasing the zeroed-out resource and removing it from the resource
    hierarchy.
    
    [bhelgaas: commit log]
    Fixes: 7c3855c423b1 ("PCI: Coalesce host bridge contiguous apertures")
    Link: https://lore.kernel.org/r/20230525153248.712779-1-ross.lagerwall@citrix.com
    Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org	# v5.16+

> ---
>  drivers/pci/probe.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 0b2826c4a832..00ed20ac0dd6 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -997,8 +997,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
>  	resource_list_for_each_entry_safe(window, n, &resources) {
>  		offset = window->offset;
>  		res = window->res;
> -		if (!res->flags && !res->start && !res->end)
> +		if (!res->flags && !res->start && !res->end) {
> +			release_resource(res);
>  			continue;
> +		}
>  
>  		list_move_tail(&window->node, &bridge->windows);
>  
> -- 
> 2.31.1
> 

      parent reply	other threads:[~2023-06-09 21:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 15:32 [PATCH] PCI: Release coalesced resource Ross Lagerwall
2023-06-05  8:44 ` Ross Lagerwall
2023-06-06 22:36 ` Bjorn Helgaas
2023-06-09 15:39   ` Ross Lagerwall
2023-06-09 21:45 ` Bjorn Helgaas [this message]

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=20230609214530.GA1262596@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=ross.lagerwall@citrix.com \
    /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;
as well as URLs for NNTP newsgroup(s).