Re: [PATCH v6 1/4] PCI: Consider alignment of hot-added bridges when distributing available resources

Bjorn Helgaas
2019-06-17T18:22:17Z

On Mon, Jun 17, 2019 at 12:35:13PM +0300, mika.westerberg@linux.intel.com wrote:
> On Wed, May 22, 2019 at 02:30:44PM +0000, Nicholas Johnson wrote:
> > Rewrite pci_bus_distribute_available_resources to better handle bridges
> > with different resource alignment requirements. Pass more details
> > arguments recursively to track the resource start and end addresses
> > relative to the initial hotplug bridge. This is especially useful for
> > Thunderbolt with native PCI enumeration, enabling external graphics
> > cards and other devices with bridge alignment higher than 0x100000
>
> Instead of 0x100000 you could say 1MB here.

And of course, 1MB is the minimum bridge window alignment. I *guess*
this is actually talking about endpoints with BARs larger than 1MB,
which have to be aligned on their size. This doesn't actually impose
any requirement on the bridge window alignment, as long as the bridge
window contains the endpoint BARs.

> > bytes.

> > for_each_pci_bridge(dev, bus) {
> > - const struct resource *res;
> > + struct resource *res;
> > + resource_size_t used_size;
>
> Here order these in "reverse christmas tree" like:
>
> resource_size_t used_size;
> struct resource *res;

I actually don't enforce "reverse christmas tree", and when I write
code, I order the declarations in order of their use in the code
below, as Nicholas has done. But either way is fine.

Bjorn