From: "Pali Rohár" <pali@kernel.org>
To: "Martin Mareš" <mj@ucw.cz>, "Bjorn Helgaas" <helgaas@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Matthew Wilcox" <willy@infradead.org>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH pciutils 3/4] libpci: Add support for filling bridge resources
Date: Fri, 31 Dec 2021 23:27:48 +0100 [thread overview]
Message-ID: <20211231222748.xriixk5etfya2xbn@pali> (raw)
In-Reply-To: <20211226222027.byugwn7c23ckwach@pali>
On Sunday 26 December 2021 23:20:27 Pali Rohár wrote:
> On Sunday 26 December 2021 23:13:11 Martin Mareš wrote:
> > Hi!
> >
> > > + else if (i < 7+6+4)
> > > + {
> > > + /*
> > > + * If kernel was compiled without CONFIG_PCI_IOV option then after
> > > + * the ROM line for configured bridge device (that which had set
> > > + * subordinary bus number to non-zero value) are four additional lines
> > > + * which describe resources behind bridge. For PCI-to-PCI bridges they
> > > + * are: IO, MEM, PREFMEM and empty. For CardBus bridges they are: IO0,
> > > + * IO1, MEM0 and MEM1. For unconfigured bridges and other devices
> > > + * there is no additional line after the ROM line. If kernel was
> > > + * compiled with CONFIG_PCI_IOV option then after the ROM line and
> > > + * before the first bridge resource line are six additional lines
> > > + * which describe IOV resources. Read all remaining lines in resource
> > > + * file and based on the number of remaining lines (0, 4, 6, 10) parse
> > > + * resources behind bridge.
> > > + */
> > > + lines[i-7].flags = flags;
> > > + lines[i-7].base_addr = start;
> > > + lines[i-7].size = size;
> > > + }
> > > + }
> > > + if (i == 7+4 || i == 7+6+4)
> >
> > This looks crazy: is there any other way how to tell what the bridge entries mean?
> > Checking the number of entries looks very brittle.
>
> I do not know any other way. Just for reference, here is a link to the
> function resource_show() and DEVICE_COUNT_RESOURCE enum:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci-sysfs.c?h=v5.15#n136
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/pci.h?h=v5.15#n94
I have also checked flags and there is no indication if resource is
assigned on bridge as BAR or is forwarded behind the bridge.
Bjorn, Krzysztof: any idea if something better than checking number of
entries in "resource" node can be used to determinate type of entry at
specified line in "resource" node?
next prev parent reply other threads:[~2021-12-31 22:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 15:54 [PATCH pciutils 1/4] lspci: Show 16/32/64 bit width for address ranges behind bridge Pali Rohár
2021-12-20 15:54 ` [PATCH pciutils 2/4] lspci: Simplify printing range in show_range() Pali Rohár
2021-12-20 15:54 ` [PATCH pciutils 3/4] libpci: Add support for filling bridge resources Pali Rohár
2021-12-26 22:13 ` Martin Mareš
2021-12-26 22:20 ` Pali Rohár
2021-12-31 22:27 ` Pali Rohár [this message]
2022-01-20 20:33 ` Bjorn Helgaas
2022-01-20 20:45 ` Pali Rohár
2022-01-20 21:02 ` Bjorn Helgaas
2022-01-20 21:19 ` Pali Rohár
2022-11-11 20:09 ` IORESOURCE_WINDOW for PCI-to-PCI bridges Pali Rohár
2022-11-11 21:05 ` Bjorn Helgaas
2022-11-11 21:48 ` Pali Rohár
2022-11-15 22:15 ` Bjorn Helgaas
2021-12-20 15:54 ` [PATCH pciutils 4/4] lspci: Use PCI_FILL_BRIDGE_BASES to detect if range behind bridge is disabled or unsupported Pali Rohár
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=20211231222748.xriixk5etfya2xbn@pali \
--to=pali@kernel.org \
--cc=helgaas@kernel.org \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=mj@ucw.cz \
--cc=willy@infradead.org \
/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).