* One question about the useage of pci_dev->resource[] @ 2012-06-20 8:45 Richard Yang 2012-06-26 1:57 ` Richard Yang 0 siblings, 1 reply; 4+ messages in thread From: Richard Yang @ 2012-06-20 8:45 UTC (permalink / raw) To: Linux PCI; +Cc: Gavin Shan, Ram Pai All, I want to confirm something for the pci_dev->resource[]. As in the definition in the pci.h, this resource array is divided into several parts. 0-5 for standard PCI resources 6 for ROM resource 7-10 for bridge resource( if no iov ) 1. For P2P bridge, 0-5 is left empty? 2. If so, in code pci_setup_device(), I think it set the wrong resource. It call pci_read_bases(dev, 2, PCI_ROM_ADDRESS1), for a p2p bridge. And in pci_read_bases(), BAR information is retrieved and set to pci_dev->resource[0|1]. 3. If pci_setup_device() just set first two resource, the child bus will point to empty resource. In pci_alloc_child_bus(), child->resource[0-3] will be point to bridge->resource[7-10], which is not set in pci_setup_device(). 4. Another question is, is there any convention for pci_bus->resource[]. [0] for io, [1] for mem, [2] for prefetch? -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: One question about the useage of pci_dev->resource[] 2012-06-20 8:45 One question about the useage of pci_dev->resource[] Richard Yang @ 2012-06-26 1:57 ` Richard Yang 2012-06-26 12:16 ` Bjorn Helgaas 0 siblings, 1 reply; 4+ messages in thread From: Richard Yang @ 2012-06-26 1:57 UTC (permalink / raw) To: Richard Yang; +Cc: Linux PCI, Gavin Shan, Ram Pai On Wed, Jun 20, 2012 at 04:45:15PM +0800, Richard Yang wrote: >All, > >I want to confirm something for the pci_dev->resource[]. > >As in the definition in the pci.h, this resource array is divided into >several parts. > 0-5 for standard PCI resources > 6 for ROM resource > 7-10 for bridge resource( if no iov ) > > >1. For P2P bridge, 0-5 is left empty? >2. If so, in code pci_setup_device(), I think it set the wrong resource. > It call pci_read_bases(dev, 2, PCI_ROM_ADDRESS1), for a p2p bridge. > And in pci_read_bases(), BAR information is retrieved and set to > pci_dev->resource[0|1]. >3. If pci_setup_device() just set first two resource, the child bus will > point to empty resource. > In pci_alloc_child_bus(), child->resource[0-3] will be point to > bridge->resource[7-10], which is not set in pci_setup_device(). >4. Another question is, is there any convention for pci_bus->resource[]. > [0] for io, [1] for mem, [2] for prefetch? All, I go through the code again and find pci_dev->resource[7-10] is used for io/mem base/limit, which is used by the bridge to determine whether it will forward one pci transaction. So pci_dev->[0-1] is used by the bridge's driver? If not exact, please correct me:) > >-- >Richard Yang >Help you, Help me -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: One question about the useage of pci_dev->resource[] 2012-06-26 1:57 ` Richard Yang @ 2012-06-26 12:16 ` Bjorn Helgaas 2012-06-27 2:22 ` Richard Yang 0 siblings, 1 reply; 4+ messages in thread From: Bjorn Helgaas @ 2012-06-26 12:16 UTC (permalink / raw) To: Richard Yang; +Cc: Linux PCI, Gavin Shan, Ram Pai On Mon, Jun 25, 2012 at 7:57 PM, Richard Yang <weiyang@linux.vnet.ibm.com> wrote: > On Wed, Jun 20, 2012 at 04:45:15PM +0800, Richard Yang wrote: >>All, >> >>I want to confirm something for the pci_dev->resource[]. >> >>As in the definition in the pci.h, this resource array is divided into >>several parts. >> 0-5 for standard PCI resources >> 6 for ROM resource >> 7-10 for bridge resource( if no iov ) >> >> >>1. For P2P bridge, 0-5 is left empty? >>2. If so, in code pci_setup_device(), I think it set the wrong resource. >> It call pci_read_bases(dev, 2, PCI_ROM_ADDRESS1), for a p2p bridge. >> And in pci_read_bases(), BAR information is retrieved and set to >> pci_dev->resource[0|1]. >>3. If pci_setup_device() just set first two resource, the child bus will >> point to empty resource. >> In pci_alloc_child_bus(), child->resource[0-3] will be point to >> bridge->resource[7-10], which is not set in pci_setup_device(). >>4. Another question is, is there any convention for pci_bus->resource[]. >> [0] for io, [1] for mem, [2] for prefetch? > All, > > I go through the code again and find pci_dev->resource[7-10] is used for > io/mem base/limit, which is used by the bridge to determine whether it > will forward one pci transaction. > > So pci_dev->[0-1] is used by the bridge's driver? Per the PCI-to-PCI Bridge spec v1.2, config space for type 1 devices (bridges) has two BARs in addition to the I/O, mem, and prefetchable mem windows. These two BARs are optional and can be used for device-specific configuration of the bridge itself. This is unrelated to forwarding transactions. See sec 3.2.5.1. The bridge consumes the address space described by the windows and forwards it to its secondary interface. It also consumes the address space described by those BARs, without forwarding it. Therefore, we have to read the BARs to make sure we don't allocate that space to anything else. There *could* be device-specific bridge drivers that actually do something with those BARs, but I'm not aware of any in Linux. Bjorn ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: One question about the useage of pci_dev->resource[] 2012-06-26 12:16 ` Bjorn Helgaas @ 2012-06-27 2:22 ` Richard Yang 0 siblings, 0 replies; 4+ messages in thread From: Richard Yang @ 2012-06-27 2:22 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Richard Yang, Linux PCI, Gavin Shan, Ram Pai On Tue, Jun 26, 2012 at 06:16:08AM -0600, Bjorn Helgaas wrote: >On Mon, Jun 25, 2012 at 7:57 PM, Richard Yang ><weiyang@linux.vnet.ibm.com> wrote: >> On Wed, Jun 20, 2012 at 04:45:15PM +0800, Richard Yang wrote: >>>All, >>> >>>I want to confirm something for the pci_dev->resource[]. >>> >>>As in the definition in the pci.h, this resource array is divided into >>>several parts. >>> 0-5 for standard PCI resources >>> 6 for ROM resource >>> 7-10 for bridge resource( if no iov ) >>> >>> >>>1. For P2P bridge, 0-5 is left empty? >>>2. If so, in code pci_setup_device(), I think it set the wrong resource. >>> It call pci_read_bases(dev, 2, PCI_ROM_ADDRESS1), for a p2p bridge. >>> And in pci_read_bases(), BAR information is retrieved and set to >>> pci_dev->resource[0|1]. >>>3. If pci_setup_device() just set first two resource, the child bus will >>> point to empty resource. >>> In pci_alloc_child_bus(), child->resource[0-3] will be point to >>> bridge->resource[7-10], which is not set in pci_setup_device(). >>>4. Another question is, is there any convention for pci_bus->resource[]. >>> [0] for io, [1] for mem, [2] for prefetch? >> All, >> >> I go through the code again and find pci_dev->resource[7-10] is used for >> io/mem base/limit, which is used by the bridge to determine whether it >> will forward one pci transaction. >> >> So pci_dev->[0-1] is used by the bridge's driver? > >Per the PCI-to-PCI Bridge spec v1.2, config space for type 1 devices >(bridges) has two BARs in addition to the I/O, mem, and prefetchable >mem windows. These two BARs are optional and can be used for >device-specific configuration of the bridge itself. This is unrelated >to forwarding transactions. See sec 3.2.5.1. > >The bridge consumes the address space described by the windows and >forwards it to its secondary interface. It also consumes the address >space described by those BARs, without forwarding it. Therefore, we >have to read the BARs to make sure we don't allocate that space to >anything else. > >There *could* be device-specific bridge drivers that actually do >something with those BARs, but I'm not aware of any in Linux. Thanks for your confirmation. :-) > >Bjorn -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-27 2:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-20 8:45 One question about the useage of pci_dev->resource[] Richard Yang 2012-06-26 1:57 ` Richard Yang 2012-06-26 12:16 ` Bjorn Helgaas 2012-06-27 2:22 ` Richard Yang
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).