From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] pci: only release that resource index is less than 3
Date: Mon, 26 Oct 2009 17:20:28 -0700 [thread overview]
Message-ID: <4AE63CCC.3050203@kernel.org> (raw)
In-Reply-To: <1256601476.25492.47.camel@dc7800.home>
Bjorn Helgaas wrote:
> On Mon, 2009-10-26 at 14:23 -0700, Yinghai Lu wrote:
>
>> ===================================================================
>> --- linux-2.6.orig/drivers/pci/setup-bus.c
>> +++ linux-2.6/drivers/pci/setup-bus.c
>> @@ -322,33 +322,54 @@ static void pci_bridge_check_ranges(stru
>> }
>> }
>>
>> -/* Helper function for sizing routines: find first available
>> - bus resource of a given type. Note: we intentionally skip
>> - the bus resources which have already been assigned (that is,
>> - have non-NULL parent resource). */
>> -static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type)
>> +void pci_bridge_release_not_used_res(struct pci_bus *bus)
>> {
>> int i;
>> struct resource *r;
>> unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
>> IORESOURCE_PREFETCH;
>>
>> - for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
>> + /* for pci bridges res only */
>> + for (i = 0; i < 3; i++) {
>
> I think the "i = 0; i < 3" part is to check the bridge apertures, i.e.,
> the I/O base/limit, the memory base/limit, and the prefetchable memory
> base/limit. Right? We need some way to indicate that more clearly than
> using a hard-coded "3".
yes. the 0x1c, 0x20, and 0x28
>
>> r = bus->resource[i];
>> - if (r == &ioport_resource || r == &iomem_resource)
>> - continue;
>> - if (r && (r->flags & type_mask) == type) {
>> + if (r && (r->flags & type_mask)) {
>> if (!r->parent)
>> - return r;
>> + continue;
>> /*
>> * if there is no child under that, we should release
>> * and use it. don't need to reset it, pbus_size_* will
>> * set it again
>> */
>> if (!r->child && !release_resource(r))
>
> We got this resource pointer out of a struct pci_bus, and we release it
> here. We must have previously done a request_resource(),
> allocate_resource(), or similar. Where does that happen? Are the
> requests and releases nested correctly?
>
> I would think that somewhere, we would be doing a request_resource() and
> assigning the resource to pci_bus->resource[x]. But there are very few
> assignments to the pci_bus resources:
> setup_resource (only for "pci=use_crs")
> pci_read_bridge_bases (just a copy from upstream bus resources)
> pci_alloc_child_bus (copy from upstream bridge resources)
> pci_create_bus (set to &ioport_resource or &iomem_resource)
>
> My guess is that this release_resource() releases something we copied
> from the bridge in pci_alloc_child_bus(). But that doesn't seem right,
> because we aren't changing the bridge programming here.
in arch/x86/pci/i386.c::
pcibios_resource_survey() ==> pcibios_allocate_bus_resources()
YH
next prev parent reply other threads:[~2009-10-27 0:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-24 9:25 [PATCH] pci: only release that resource index is less than 3 Yinghai Lu
2009-10-26 16:32 ` Bjorn Helgaas
2009-10-26 17:19 ` Jesse Barnes
2009-10-26 21:23 ` Yinghai Lu
2009-10-26 23:57 ` Bjorn Helgaas
2009-10-27 0:20 ` Yinghai Lu [this message]
2009-10-27 16:09 ` Bjorn Helgaas
2009-10-28 3:45 ` Yinghai Lu
2009-10-26 19:38 ` Yinghai Lu
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=4AE63CCC.3050203@kernel.org \
--to=yinghai@kernel.org \
--cc=bjorn.helgaas@hp.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@elte.hu \
/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