Message ID | 1526801333-30613-3-git-send-email-whois.zihan.yang@gmail.com |
---|---|
State | New |
Headers | show |
Series | pci_expander_brdige: Put pxb host bridge into separate pci domain | expand |
On 05/20/2018 10:28 AM, Zihan Yang wrote: > QLIST will place the original q35 host bridge at the end of list because it is > added first. Replace it with QTAILQ to make q35 at the first of queue, which > makes it convinient and compatible when there are pxb hosts other than q35 hosts I have no objection here, we'll see later how the modification helps. Thanks, Marcek > Signed-off-by: Zihan Yang <whois.zihan.yang@gmail.com> > --- > hw/pci/pci.c | 9 +++++---- > include/hw/pci/pci_host.h | 2 +- > 2 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 80bc459..ddc27ba 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -196,7 +196,8 @@ static void pci_del_option_rom(PCIDevice *pdev); > static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET; > static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; > > -static QLIST_HEAD(, PCIHostState) pci_host_bridges; > +static QTAILQ_HEAD(, PCIHostState) pci_host_bridges = > + QTAILQ_HEAD_INITIALIZER(pci_host_bridges); > > int pci_bar(PCIDevice *d, int reg) > { > @@ -330,7 +331,7 @@ static void pci_host_bus_register(DeviceState *host) > { > PCIHostState *host_bridge = PCI_HOST_BRIDGE(host); > > - QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); > + QTAILQ_INSERT_TAIL(&pci_host_bridges, host_bridge, next); > } > > PCIBus *pci_device_root_bus(const PCIDevice *d) > @@ -1798,7 +1799,7 @@ PciInfoList *qmp_query_pci(Error **errp) > PciInfoList *info, *head = NULL, *cur_item = NULL; > PCIHostState *host_bridge; > > - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { > + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { > info = g_malloc0(sizeof(*info)); > info->value = qmp_query_pci_bus(host_bridge->bus, > pci_bus_num(host_bridge->bus)); > @@ -2493,7 +2494,7 @@ int pci_qdev_find_device(const char *id, PCIDevice **pdev) > PCIHostState *host_bridge; > int rc = -ENODEV; > > - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { > + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { > int tmp = pci_qdev_find_recursive(host_bridge->bus, id, pdev); > if (!tmp) { > rc = 0; > diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h > index ba31595..a5617cf 100644 > --- a/include/hw/pci/pci_host.h > +++ b/include/hw/pci/pci_host.h > @@ -47,7 +47,7 @@ struct PCIHostState { > uint32_t config_reg; > PCIBus *bus; > > - QLIST_ENTRY(PCIHostState) next; > + QTAILQ_ENTRY(PCIHostState) next; > }; > > typedef struct PCIHostBridgeClass {
> have no objection here, we'll see later how the modification helps.
The purpose is to place the q35 host at the start of queue. In the original
QLIST,
when a new pxb host is added, q35 host will be bumped to the end end list.
By replacing it with QTAILQ, we can always get q35 host bridges first, so
that
we can make sure q35 host stays in pci domain 0. If there is no pxb host,
the code needs not change because the 'next' field will be NULL.
I'm not sure whether it is necessary to let q35 host reside in pci domain 0,
but I think I'd better reserve the original when I don't know the potential
impact.
Thanks
Zihan
Hi Zihan, On 05/22/2018 08:59 AM, Zihan Yang wrote: > > have no objection here, we'll see later how the modification helps. > > The purpose is to place the q35 host at the start of queue. In the > original QLIST, > when a new pxb host is added, q35 host will be bumped to the end end list. > > By replacing it with QTAILQ, we can always get q35 host bridges first, > so that > we can make sure q35 host stays in pci domain 0. If there is no pxb host, > the code needs not change because the 'next' field will be NULL. > We can use the pxb list we keep, but I don't see an issue here. > I'm not sure whether it is necessary to let q35 host reside in pci > domain 0, > but I think I'd better reserve the original when I don't know the > potential impact. > Q35 should always reside in PCI domain 0. Thanks, Marcel > Thanks > Zihan >
diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 80bc459..ddc27ba 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -196,7 +196,8 @@ static void pci_del_option_rom(PCIDevice *pdev); static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET; static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; -static QLIST_HEAD(, PCIHostState) pci_host_bridges; +static QTAILQ_HEAD(, PCIHostState) pci_host_bridges = + QTAILQ_HEAD_INITIALIZER(pci_host_bridges); int pci_bar(PCIDevice *d, int reg) { @@ -330,7 +331,7 @@ static void pci_host_bus_register(DeviceState *host) { PCIHostState *host_bridge = PCI_HOST_BRIDGE(host); - QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); + QTAILQ_INSERT_TAIL(&pci_host_bridges, host_bridge, next); } PCIBus *pci_device_root_bus(const PCIDevice *d) @@ -1798,7 +1799,7 @@ PciInfoList *qmp_query_pci(Error **errp) PciInfoList *info, *head = NULL, *cur_item = NULL; PCIHostState *host_bridge; - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { info = g_malloc0(sizeof(*info)); info->value = qmp_query_pci_bus(host_bridge->bus, pci_bus_num(host_bridge->bus)); @@ -2493,7 +2494,7 @@ int pci_qdev_find_device(const char *id, PCIDevice **pdev) PCIHostState *host_bridge; int rc = -ENODEV; - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { int tmp = pci_qdev_find_recursive(host_bridge->bus, id, pdev); if (!tmp) { rc = 0; diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index ba31595..a5617cf 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -47,7 +47,7 @@ struct PCIHostState { uint32_t config_reg; PCIBus *bus; - QLIST_ENTRY(PCIHostState) next; + QTAILQ_ENTRY(PCIHostState) next; }; typedef struct PCIHostBridgeClass {
QLIST will place the original q35 host bridge at the end of list because it is added first. Replace it with QTAILQ to make q35 at the first of queue, which makes it convinient and compatible when there are pxb hosts other than q35 hosts Signed-off-by: Zihan Yang <whois.zihan.yang@gmail.com> --- hw/pci/pci.c | 9 +++++---- include/hw/pci/pci_host.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-)