* One chart on pci bridge and its bus and their children @ 2012-06-05 3:26 Richard Yang 2012-06-05 4:11 ` Ram Pai 0 siblings, 1 reply; 19+ messages in thread From: Richard Yang @ 2012-06-05 3:26 UTC (permalink / raw) To: linux-pci; +Cc: Ram Pai, Gavin Shan All, I draw a chart on the relationship of bridge/bus/devics. I am not sure it is exact, so please correct me if it is not correct. BTW, the pci_bus->self, pci_bus->bridge seem to point the same thing. So this is really necessary to do this? Bus 0(pci_bus) +--------------------+<----+ | | | +--------------------+ | | | Bridge(pci_dev) | +--------------------+<----|---+--------------+ |subordinate(pci_bus)|-+ | | | +--------------------+ | | | | | | | | | | | | | | | | Bus 1(pci_bus) | | | | +--->+-------------------+<-+ | | | | |parent(pci_bus) |------+ | | | +-------------------+ | | | |self(pci_dev) |----------+ | | |bridge(device) | | | +-------------------+ | | |devices(list_head) | | | +--------+----------+ | | | | | ----+--+---+---- | pci_dev | | | pci_dev | +---------------+<--|----------+ +--------->+-----------------+ | |bus(pci_bus) |---+ |bus(pci_bus) | | +---------------+ +-----------------+ | |dev.parent | |dev.parent |---+ +---------------+ +-----------------+ -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 3:26 One chart on pci bridge and its bus and their children Richard Yang @ 2012-06-05 4:11 ` Ram Pai 2012-06-05 4:37 ` Bjorn Helgaas 2012-06-05 5:33 ` Richard Yang 0 siblings, 2 replies; 19+ messages in thread From: Ram Pai @ 2012-06-05 4:11 UTC (permalink / raw) To: Richard Yang; +Cc: linux-pci, Ram Pai, Gavin Shan On Tue, Jun 05, 2012 at 11:26:27AM +0800, Richard Yang wrote: > > All, > > I draw a chart on the relationship of bridge/bus/devics. > > I am not sure it is exact, so please correct me if it is not correct. A clearer representation can be found at http://tldp.org/LDP/tlk/dd/pci.html in section 6.6.1 > > BTW, the pci_bus->self, pci_bus->bridge seem to point the same thing. > So this is really necessary to do this? pci_bus->self points to the pci_dev structure, and pci_bus->bridge points to the device structure. Both correspond to the same bridge. BTW: device structure is the basic structure to represent any device in the system, not necessarily pci device. > > Bus 0(pci_bus) > +--------------------+<----+ > | | | > +--------------------+ | > | > | > Bridge(pci_dev) | > +--------------------+<----|---+--------------+ > |subordinate(pci_bus)|-+ | | | > +--------------------+ | | | | > | | | | > | | | | > | | | | > Bus 1(pci_bus) | | | | > +--->+-------------------+<-+ | | | > | |parent(pci_bus) |------+ | | > | +-------------------+ | | > | |self(pci_dev) |----------+ | > | |bridge(device) | | > | +-------------------+ | > | |devices(list_head) | | > | +--------+----------+ | > | | | > | ----+--+---+---- | > pci_dev | | | pci_dev | > +---------------+<--|----------+ +--------->+-----------------+ | > |bus(pci_bus) |---+ |bus(pci_bus) | | > +---------------+ +-----------------+ | > |dev.parent | |dev.parent |---+ > +---------------+ +-----------------+ ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 4:11 ` Ram Pai @ 2012-06-05 4:37 ` Bjorn Helgaas 2012-06-05 5:18 ` Yinghai Lu 2012-06-05 5:33 ` Richard Yang 1 sibling, 1 reply; 19+ messages in thread From: Bjorn Helgaas @ 2012-06-05 4:37 UTC (permalink / raw) To: Ram Pai; +Cc: Richard Yang, linux-pci, Gavin Shan On Mon, Jun 4, 2012 at 9:11 PM, Ram Pai <linuxram@us.ibm.com> wrote: > On Tue, Jun 05, 2012 at 11:26:27AM +0800, Richard Yang wrote: >> BTW, the pci_bus->self, pci_bus->bridge seem to point the same thing. >> So this is really necessary to do this? > > pci_bus->self points to the pci_dev structure, and pci_bus->bridge > points to the device structure. Both correspond to the same bridge. BTW: device > structure is the basic structure to represent any device in the system, > not necessarily pci device. That's true, but I don't think it answers the question. If we have: pci_bus->bridge == pci_bus->self->dev why would we need both "self" and "bridge"? It would be interesting to try to remove "bridge" and replace uses of it with "self->dev". ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 4:37 ` Bjorn Helgaas @ 2012-06-05 5:18 ` Yinghai Lu 2012-06-05 5:20 ` Yinghai Lu 2012-06-05 6:02 ` Richard Yang 0 siblings, 2 replies; 19+ messages in thread From: Yinghai Lu @ 2012-06-05 5:18 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Ram Pai, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: > That's true, but I don't think it answers the question. If we have: > > pci_bus->bridge == pci_bus->self->dev > > why would we need both "self" and "bridge"? It would be interesting > to try to remove "bridge" and replace uses of it with "self->dev". then how about root bus? root bus ->self should be NULL. root bus ->bridge is to the hostbridge->dev. Yinghai ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 5:18 ` Yinghai Lu @ 2012-06-05 5:20 ` Yinghai Lu 2012-06-05 5:41 ` Richard Yang ` (2 more replies) 2012-06-05 6:02 ` Richard Yang 1 sibling, 3 replies; 19+ messages in thread From: Yinghai Lu @ 2012-06-05 5:20 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Ram Pai, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: > On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >> That's true, but I don't think it answers the question. If we have: >> >> pci_bus->bridge == pci_bus->self->dev >> >> why would we need both "self" and "bridge"? It would be interesting >> to try to remove "bridge" and replace uses of it with "self->dev". > > then how about root bus? > > root bus ->self should be NULL. > > root bus ->bridge is to the hostbridge->dev. also b->bridge = get_device(&bridge->dev); so there is one reference held by pci bus. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 5:20 ` Yinghai Lu @ 2012-06-05 5:41 ` Richard Yang 2012-06-05 6:35 ` Ram Pai 2012-06-05 21:52 ` Gavin Shan 2 siblings, 0 replies; 19+ messages in thread From: Richard Yang @ 2012-06-05 5:41 UTC (permalink / raw) To: Yinghai Lu; +Cc: Bjorn Helgaas, Ram Pai, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: >On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: >> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >>> That's true, but I don't think it answers the question. If we have: >>> >>> pci_bus->bridge == pci_bus->self->dev >>> >>> why would we need both "self" and "bridge"? It would be interesting >>> to try to remove "bridge" and replace uses of it with "self->dev". >> >> then how about root bus? >> >> root bus ->self should be NULL. >> >> root bus ->bridge is to the hostbridge->dev. > >also > >b->bridge = get_device(&bridge->dev); > >so there is one reference held by pci bus. Hmm... so can we just have b->bridge, and then convert bridge to self if necessary? -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 5:20 ` Yinghai Lu 2012-06-05 5:41 ` Richard Yang @ 2012-06-05 6:35 ` Ram Pai 2012-06-05 14:41 ` Jiang Liu 2012-06-05 19:38 ` Yinghai Lu 2012-06-05 21:52 ` Gavin Shan 2 siblings, 2 replies; 19+ messages in thread From: Ram Pai @ 2012-06-05 6:35 UTC (permalink / raw) To: Yinghai Lu; +Cc: Bjorn Helgaas, Ram Pai, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: > On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: > > On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: > >> That's true, but I don't think it answers the question. If we have: > >> > >> pci_bus->bridge == pci_bus->self->dev > >> > >> why would we need both "self" and "bridge"? It would be interesting > >> to try to remove "bridge" and replace uses of it with "self->dev". > > > > then how about root bus? > > > > root bus ->self should be NULL. > > > > root bus ->bridge is to the hostbridge->dev. Yinghai, is there a reason why this can't be fixed in pci_create_root_bus() by having bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ get_device(&bridge->dev); RP ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 6:35 ` Ram Pai @ 2012-06-05 14:41 ` Jiang Liu 2012-06-05 16:40 ` Ram Pai 2012-06-05 19:38 ` Yinghai Lu 1 sibling, 1 reply; 19+ messages in thread From: Jiang Liu @ 2012-06-05 14:41 UTC (permalink / raw) To: Ram Pai; +Cc: Yinghai Lu, Bjorn Helgaas, Richard Yang, linux-pci, Gavin Shan On 06/05/2012 02:35 PM, Ram Pai wrote: > On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: >> On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: >>> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >>>> That's true, but I don't think it answers the question. If we have: >>>> >>>> pci_bus->bridge == pci_bus->self->dev >>>> >>>> why would we need both "self" and "bridge"? It would be interesting >>>> to try to remove "bridge" and replace uses of it with "self->dev". >>> >>> then how about root bus? >>> >>> root bus ->self should be NULL. >>> >>> root bus ->bridge is to the hostbridge->dev. > > Yinghai, > > is there a reason why this can't be fixed in > pci_create_root_bus() by having > bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ Hi Ram, A host bridge has no associated pci_device because it's out of the PCI domain. PCI domain only covers the hierarchy starting from the host bridge, but doesn't include the host bridge itself. Thanks! > get_device(&bridge->dev); > > > RP > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pci" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 14:41 ` Jiang Liu @ 2012-06-05 16:40 ` Ram Pai 2012-06-06 1:58 ` Ram Pai 0 siblings, 1 reply; 19+ messages in thread From: Ram Pai @ 2012-06-05 16:40 UTC (permalink / raw) To: Jiang Liu Cc: Ram Pai, Yinghai Lu, Bjorn Helgaas, Richard Yang, linux-pci, Gavin Shan On Tue, Jun 05, 2012 at 10:41:39PM +0800, Jiang Liu wrote: > On 06/05/2012 02:35 PM, Ram Pai wrote: > > On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: > >> On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: > >>> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: > >>>> That's true, but I don't think it answers the question. If we have: > >>>> > >>>> pci_bus->bridge == pci_bus->self->dev > >>>> > >>>> why would we need both "self" and "bridge"? It would be interesting > >>>> to try to remove "bridge" and replace uses of it with "self->dev". > >>> > >>> then how about root bus? > >>> > >>> root bus ->self should be NULL. > >>> > >>> root bus ->bridge is to the hostbridge->dev. > > > > Yinghai, > > > > is there a reason why this can't be fixed in > > pci_create_root_bus() by having > > bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ > Hi Ram, > A host bridge has no associated pci_device because it's out of the > PCI domain. PCI domain only covers the hierarchy starting from the host bridge, > but doesn't include the host bridge itself. That makes it even easier to kill pci_bus->bridge. for non-root buses, we can access the bridge's device using bus->self->dev and for root bridges we can silently ignore the bridge's dev since we know that it does not exist; because pci_bus->self is null. No? RP ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 16:40 ` Ram Pai @ 2012-06-06 1:58 ` Ram Pai 0 siblings, 0 replies; 19+ messages in thread From: Ram Pai @ 2012-06-06 1:58 UTC (permalink / raw) To: Ram Pai Cc: Jiang Liu, Yinghai Lu, Bjorn Helgaas, Richard Yang, linux-pci, Gavin Shan On Wed, Jun 06, 2012 at 12:40:19AM +0800, Ram Pai wrote: > On Tue, Jun 05, 2012 at 10:41:39PM +0800, Jiang Liu wrote: > > On 06/05/2012 02:35 PM, Ram Pai wrote: > > > On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: > > >> On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: > > >>> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: > > >>>> That's true, but I don't think it answers the question. If we have: > > >>>> > > >>>> pci_bus->bridge == pci_bus->self->dev > > >>>> > > >>>> why would we need both "self" and "bridge"? It would be interesting > > >>>> to try to remove "bridge" and replace uses of it with "self->dev". > > >>> > > >>> then how about root bus? > > >>> > > >>> root bus ->self should be NULL. > > >>> > > >>> root bus ->bridge is to the hostbridge->dev. > > > > > > Yinghai, > > > > > > is there a reason why this can't be fixed in > > > pci_create_root_bus() by having > > > bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ > > Hi Ram, > > A host bridge has no associated pci_device because it's out of the > > PCI domain. PCI domain only covers the hierarchy starting from the host bridge, > > but doesn't include the host bridge itself. > > That makes it even easier to kill pci_bus->bridge. > > for non-root buses, we can access the bridge's device using > bus->self->dev and for root bridges we can silently ignore > the bridge's dev since we know that it does not exist; because > pci_bus->self is null. hmm..ok. I realize the struct device of the host bridge exists and needs to be accessed, even though it is not a pci_device. So killing bus->bridge is not trivial. RP ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 6:35 ` Ram Pai 2012-06-05 14:41 ` Jiang Liu @ 2012-06-05 19:38 ` Yinghai Lu 2012-06-06 5:28 ` Richard Yang 1 sibling, 1 reply; 19+ messages in thread From: Yinghai Lu @ 2012-06-05 19:38 UTC (permalink / raw) To: Ram Pai; +Cc: Bjorn Helgaas, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 4, 2012 at 11:35 PM, Ram Pai <linuxram@us.ibm.com> wrote: > On Mon, Jun 04, 2012 at 10:20:51PM -0700, Yinghai Lu wrote: >> On Mon, Jun 4, 2012 at 10:18 PM, Yinghai Lu <yinghai@kernel.org> wrote: >> > On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >> >> That's true, but I don't think it answers the question. If we have: >> >> >> >> pci_bus->bridge == pci_bus->self->dev >> >> >> >> why would we need both "self" and "bridge"? It would be interesting >> >> to try to remove "bridge" and replace uses of it with "self->dev". >> > >> > then how about root bus? >> > >> > root bus ->self should be NULL. >> > >> > root bus ->bridge is to the hostbridge->dev. > > Yinghai, > > is there a reason why this can't be fixed in > pci_create_root_bus() by having > bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ > get_device(&bridge->dev); self is pointer to pci_dev bridge. and for root bus, it is NULL. that mean no pci bridge device related. bridge is device, and have that assigned from host bridge dev, or pci bridge dev. also for virtfn of iov, new bus from there will not have self assigned too. for it even bridge is not assigned. so bridge is just generic way to save bridge (pci, host) device ... ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 19:38 ` Yinghai Lu @ 2012-06-06 5:28 ` Richard Yang 2012-06-06 7:58 ` Richard Yang 0 siblings, 1 reply; 19+ messages in thread From: Richard Yang @ 2012-06-06 5:28 UTC (permalink / raw) To: Yinghai Lu; +Cc: Ram Pai, Bjorn Helgaas, Richard Yang, linux-pci, Gavin Shan On Tue, Jun 05, 2012 at 12:38:52PM -0700, Yinghai Lu wrote: >> >> Yinghai, >> >> is there a reason why this can't be fixed in >> pci_create_root_bus() by having >> bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ >> get_device(&bridge->dev); > >self is pointer to pci_dev bridge. > >and for root bus, it is NULL. that mean no pci bridge device related. > >bridge is device, and have that assigned from host bridge dev, or pci >bridge dev. > >also for virtfn of iov, new bus from there will not have self assigned too. >for it even bridge is not assigned. > >so bridge is just generic way to save bridge (pci, host) device ... I did a summarize, we have three types of pci_bus. Can we identify the type by following method? +--------------------+--------------------------------------------------+ | bus type | identification | +--------------------+--------------------------------------------------+ | root_bus |parent is NULL, bridge point to host_bridge dev | +--------------------+--------------------------------------------------+ | general_bus |parent to parent bus, bridge point to the bridge | +--------------------+--------------------------------------------------+ | iov_bus |parent to parent bus, bridge point to NULL | +--------------------+--------------------------------------------------+ -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-06 5:28 ` Richard Yang @ 2012-06-06 7:58 ` Richard Yang 0 siblings, 0 replies; 19+ messages in thread From: Richard Yang @ 2012-06-06 7:58 UTC (permalink / raw) To: Richard Yang; +Cc: Yinghai Lu, Ram Pai, Bjorn Helgaas, linux-pci, Gavin Shan On Wed, Jun 06, 2012 at 01:28:35PM +0800, Richard Yang wrote: >On Tue, Jun 05, 2012 at 12:38:52PM -0700, Yinghai Lu wrote: >>> >>> Yinghai, >>> >>> is there a reason why this can't be fixed in >>> pci_create_root_bus() by having >>> bus->self = bridge; /* 'bridge' is the pci_device of the corresponding host bridge */ >>> get_device(&bridge->dev); >> >>self is pointer to pci_dev bridge. >> >>and for root bus, it is NULL. that mean no pci bridge device related. >> >>bridge is device, and have that assigned from host bridge dev, or pci >>bridge dev. >> >>also for virtfn of iov, new bus from there will not have self assigned too. >>for it even bridge is not assigned. >> >>so bridge is just generic way to save bridge (pci, host) device ... > I did a summarize, we have three types of pci_bus. Can we identify the type by following method? +--------------------+--------------------------------------------------+ | bus type | identification | +--------------------+--------------------------------------------------+ | root_bus |parent is NULL, bridge point to host_bridge dev | +--------------------+--------------------------------------------------+ | general_bus |parent to parent bus, bridge point to the bridge | +--------------------+--------------------------------------------------+ | iov_bus |parent to parent bus, bridge point to NULL | +--------------------+--------------------------------------------------+ Hmm... if we can determine which type a pci_bus is from this criteria. Sounds we don't need the self in pci_bus? -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 5:20 ` Yinghai Lu 2012-06-05 5:41 ` Richard Yang 2012-06-05 6:35 ` Ram Pai @ 2012-06-05 21:52 ` Gavin Shan 2 siblings, 0 replies; 19+ messages in thread From: Gavin Shan @ 2012-06-05 21:52 UTC (permalink / raw) To: Yinghai Lu; +Cc: Bjorn Helgaas, Ram Pai, Richard Yang, linux-pci Hi YingHai, >>> That's true, but I don't think it answers the question. If we have: >>> >>> pci_bus->bridge == pci_bus->self->dev >>> >>> why would we need both "self" and "bridge"? It would be interesting >>> to try to remove "bridge" and replace uses of it with "self->dev". >> >> then how about root bus? >> >> root bus ->self should be NULL. >> >> root bus ->bridge is to the hostbridge->dev. As I understood, the current implementation is to trace the PCI host bridge through the PCI root bus. The problem would be avoided if you change it for a little bit to trace the PCI host bridge through (PCI domain number), which will simplify the current implementation in 3.5.RC1 as well even though not much. For example: When looking for the PCI host bridge for the child bus, we only need get the PCI domain number, then get the corresponding PCI host bridge. We needn't go through the whole PCI bus tree from the bottom to the top until the PCI root bus. I'm not sure that will introduce performance improvement or not. > >also > >b->bridge = get_device(&bridge->dev); > >so there is one reference held by pci bus. > If we ignore the return value of get_device() here, that would be possible to merge "bridge"/"self" for child PCI bus. However, we still need differentiate the PCI root bus and child bus because the "bridge"/"self" of PCI root bus would be "NULL", but "bridge"/"self" (might be merged to "bridge") would point pci_dev of the P2P bridge. Thanks, Gavin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 5:18 ` Yinghai Lu 2012-06-05 5:20 ` Yinghai Lu @ 2012-06-05 6:02 ` Richard Yang 2012-06-05 14:32 ` Jiang Liu ` (2 more replies) 1 sibling, 3 replies; 19+ messages in thread From: Richard Yang @ 2012-06-05 6:02 UTC (permalink / raw) To: Yinghai Lu; +Cc: Bjorn Helgaas, Ram Pai, Richard Yang, linux-pci, Gavin Shan On Mon, Jun 04, 2012 at 10:18:46PM -0700, Yinghai Lu wrote: >On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >> That's true, but I don't think it answers the question. If we have: >> >> pci_bus->bridge == pci_bus->self->dev >> >> why would we need both "self" and "bridge"? It would be interesting >> to try to remove "bridge" and replace uses of it with "self->dev". > >then how about root bus? > >root bus ->self should be NULL. > >root bus ->bridge is to the hostbridge->dev. > >Yinghai Agree, root_pci_bus->self is NULL, and root_pci_bus->bridge point to a solo device structure, not in hostbridge. BTW, if the dev is the hostbrige->dev, why not pci_host_bridge contain a field "dev"? And, why root bus differs with other bus a lot? Both root bus and other bus use self/bridge point to the "PCI BRIDGE" device. I think we can determine whether this is a root bus by bus->parent? -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 6:02 ` Richard Yang @ 2012-06-05 14:32 ` Jiang Liu 2012-06-05 14:37 ` Jiang Liu 2012-06-05 19:41 ` Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: Jiang Liu @ 2012-06-05 14:32 UTC (permalink / raw) To: Richard Yang; +Cc: Yinghai Lu, Bjorn Helgaas, Ram Pai, linux-pci, Gavin Shan On 06/05/2012 02:02 PM, Richard Yang wrote: > On Mon, Jun 04, 2012 at 10:18:46PM -0700, Yinghai Lu wrote: >> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >>> That's true, but I don't think it answers the question. If we have: >>> >>> pci_bus->bridge == pci_bus->self->dev >>> >>> why would we need both "self" and "bridge"? It would be interesting >>> to try to remove "bridge" and replace uses of it with "self->dev". >> >> then how about root bus? >> >> root bus ->self should be NULL. >> >> root bus ->bridge is to the hostbridge->dev. >> >> Yinghai > > Agree, root_pci_bus->self is NULL, and root_pci_bus->bridge point to a > solo device structure, not in hostbridge. > > BTW, if the dev is the hostbrige->dev, why not pci_host_bridge contain a > field "dev"? > > And, why root bus differs with other bus a lot? > Both root bus and other bus use self/bridge point to the "PCI BRIDGE" > device. > I think we can determine whether this is a root bus by bus->parent? Hi Richard, There's fundamental difference between root bridge and pci bridge. A PCI bridge is a PCI to PCI bridge. It's presented as a PCI device on the primary bus and hosts the secondary bus. So the secondary bus is associated with the PCI device on the primary bus through pci_bus->self and pci_bus->device. A root bridge is a system bus to PCI bus bridge, which connects PCI domain to system bus domain. The primary side is the system bus and the secondary side is a PCI bus, so there's a PCI bus associated with a root bridge, but there's no PCI device for the root bridge because it's primary side is system bus, out of the PCI domain. pci_bus->bridge is a common abstraction of the device associated with a PCI bus, no matter it's a host bridge or P2P bridge. So we don't need to distinguish between host bridge and pci bridge when we want to hold a reference to the device associated with a PCI bus. Thanks! Gerry ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 6:02 ` Richard Yang 2012-06-05 14:32 ` Jiang Liu @ 2012-06-05 14:37 ` Jiang Liu 2012-06-05 19:41 ` Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: Jiang Liu @ 2012-06-05 14:37 UTC (permalink / raw) To: Richard Yang; +Cc: Yinghai Lu, Bjorn Helgaas, Ram Pai, linux-pci, Gavin Shan On 06/05/2012 02:02 PM, Richard Yang wrote: > On Mon, Jun 04, 2012 at 10:18:46PM -0700, Yinghai Lu wrote: >> On Mon, Jun 4, 2012 at 9:37 PM, Bjorn Helgaas <bhelgaas@google.com> wrote: >>> That's true, but I don't think it answers the question. If we have: >>> >>> pci_bus->bridge == pci_bus->self->dev >>> >>> why would we need both "self" and "bridge"? It would be interesting >>> to try to remove "bridge" and replace uses of it with "self->dev". >> >> then how about root bus? >> >> root bus ->self should be NULL. >> >> root bus ->bridge is to the hostbridge->dev. >> >> Yinghai > > Agree, root_pci_bus->self is NULL, and root_pci_bus->bridge point to a > solo device structure, not in hostbridge. > > BTW, if the dev is the hostbrige->dev, why not pci_host_bridge contain a > field "dev"? With latest code from Yinghai, the host bridge is defined as: struct pci_host_bridge { struct device dev; struct pci_bus *bus; /* root bus */ struct list_head windows; /* pci_host_bridge_windows */ void (*release_fn)(struct pci_host_bridge *); void *release_data; }; So I think it's already working in the way suggested by you. > > And, why root bus differs with other bus a lot? > Both root bus and other bus use self/bridge point to the "PCI BRIDGE" > device. > I think we can determine whether this is a root bus by bus->parent? > ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 6:02 ` Richard Yang 2012-06-05 14:32 ` Jiang Liu 2012-06-05 14:37 ` Jiang Liu @ 2012-06-05 19:41 ` Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: Yinghai Lu @ 2012-06-05 19:41 UTC (permalink / raw) To: Richard Yang; +Cc: Bjorn Helgaas, Ram Pai, linux-pci, Gavin Shan On Mon, Jun 4, 2012 at 11:02 PM, Richard Yang <weiyang@linux.vnet.ibm.com> wrote: > On Mon, Jun 04, 2012 at 10:18:46PM -0700, Yinghai Lu wrote: > > BTW, if the dev is the hostbrige->dev, why not pci_host_bridge contain a > field "dev"? we have that from 3.5-rc1 > > And, why root bus differs with other bus a lot? > Both root bus and other bus use self/bridge point to the "PCI BRIDGE" > device. > I think we can determine whether this is a root bus by bus->parent? self is for real pci dev bridge. bridge is the for pci_dev bridge generic device pointer. or host bridge device pointer. Yinghai ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: One chart on pci bridge and its bus and their children 2012-06-05 4:11 ` Ram Pai 2012-06-05 4:37 ` Bjorn Helgaas @ 2012-06-05 5:33 ` Richard Yang 1 sibling, 0 replies; 19+ messages in thread From: Richard Yang @ 2012-06-05 5:33 UTC (permalink / raw) To: Ram Pai; +Cc: Richard Yang, linux-pci, Gavin Shan On Tue, Jun 05, 2012 at 12:11:46PM +0800, Ram Pai wrote: >On Tue, Jun 05, 2012 at 11:26:27AM +0800, Richard Yang wrote: >> >> All, >> >> I draw a chart on the relationship of bridge/bus/devics. >> >> I am not sure it is exact, so please correct me if it is not correct. > >A clearer representation can be found at http://tldp.org/LDP/tlk/dd/pci.html >in section 6.6.1 Thanks, Ram. I found I missed one important field in pci_bus. > >> >> BTW, the pci_bus->self, pci_bus->bridge seem to point the same thing. >> So this is really necessary to do this? > >pci_bus->self points to the pci_dev structure, and pci_bus->bridge >points to the device structure. Both correspond to the same bridge. BTW: device >structure is the basic structure to represent any device in the system, >not necessarily pci device. > > >> >> Bus 0(pci_bus) >> +--------------------+<----+ >> | | | >> +--------------------+ | >> | >> | >> Bridge(pci_dev) | >> +--------------------+<----|---+--------------+ >> |subordinate(pci_bus)|-+ | | | >> +--------------------+ | | | | >> | | | | >> | | | | >> | | | | >> Bus 1(pci_bus) | | | | >> +--->+-------------------+<-+ | | | >> | |parent(pci_bus) |------+ | | >> | +-------------------+ | | >> | |self(pci_dev) |----------+ | >> | |bridge(device) | | >> | +-------------------+ | >> | |devices(list_head) | | >> | +--------+----------+ | >> | | | >> | ----+--+---+---- | >> pci_dev | | | pci_dev | >> +---------------+<--|----------+ +--------->+-----------------+ | >> |bus(pci_bus) |---+ |bus(pci_bus) | | >> +---------------+ +-----------------+ | >> |dev.parent | |dev.parent |---+ >> +---------------+ +-----------------+ -- Richard Yang Help you, Help me ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2012-06-06 7:58 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-05 3:26 One chart on pci bridge and its bus and their children Richard Yang 2012-06-05 4:11 ` Ram Pai 2012-06-05 4:37 ` Bjorn Helgaas 2012-06-05 5:18 ` Yinghai Lu 2012-06-05 5:20 ` Yinghai Lu 2012-06-05 5:41 ` Richard Yang 2012-06-05 6:35 ` Ram Pai 2012-06-05 14:41 ` Jiang Liu 2012-06-05 16:40 ` Ram Pai 2012-06-06 1:58 ` Ram Pai 2012-06-05 19:38 ` Yinghai Lu 2012-06-06 5:28 ` Richard Yang 2012-06-06 7:58 ` Richard Yang 2012-06-05 21:52 ` Gavin Shan 2012-06-05 6:02 ` Richard Yang 2012-06-05 14:32 ` Jiang Liu 2012-06-05 14:37 ` Jiang Liu 2012-06-05 19:41 ` Yinghai Lu 2012-06-05 5:33 ` 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).