Message ID | 1447601946-31248-4-git-send-email-marcel@redhat.com |
---|---|
State | New |
Headers | show |
On Sun, Nov 15, 2015 at 05:39:05PM +0200, Marcel Apfelbaum wrote: > Look for pxb devices on both i386 machines. > > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> [...] > diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c > index c81507d..2fbbcd3 100644 > --- a/hw/pci-host/q35.c > +++ b/hw/pci-host/q35.c > @@ -511,6 +511,14 @@ static void mch_realize(PCIDevice *d, Error **errp) > } > } > > +PCIBus *find_q35(void) > +{ > + PCIHostState *s = OBJECT_CHECK(PCIHostState, > + object_resolve_path("/machine/q35", NULL), > + TYPE_PCI_HOST_BRIDGE); Why not use the PCI_HOST_BRIDGE macro? > + return s ? s->bus : NULL; > +} > + > uint64_t mch_mcfg_base(void) > { > bool ambiguous; > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h > index 4bbc0ff..95d7610 100644 > --- a/include/hw/i386/pc.h > +++ b/include/hw/i386/pc.h > @@ -242,6 +242,15 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type, > MemoryRegion *ram_memory); > > PCIBus *find_i440fx(void); > +PCIBus *find_q35(void); > + > +static inline PCIBus *find_pc(void) > +{ > + PCIBus *bus = find_i440fx(); > + > + return bus ? bus : find_q35(); Have you considered a /machine/pci link, or (in case you don't want to add something new to the QOM tree) a simple PCMachineState::pci_bus struct field?
On 11/16/2015 08:26 PM, Eduardo Habkost wrote: > On Sun, Nov 15, 2015 at 05:39:05PM +0200, Marcel Apfelbaum wrote: >> Look for pxb devices on both i386 machines. >> >> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> > [...] >> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c >> index c81507d..2fbbcd3 100644 >> --- a/hw/pci-host/q35.c >> +++ b/hw/pci-host/q35.c >> @@ -511,6 +511,14 @@ static void mch_realize(PCIDevice *d, Error **errp) >> } >> } >> >> +PCIBus *find_q35(void) >> +{ >> + PCIHostState *s = OBJECT_CHECK(PCIHostState, >> + object_resolve_path("/machine/q35", NULL), >> + TYPE_PCI_HOST_BRIDGE); > Hi Eduardo, Thanks for the review. > Why not use the PCI_HOST_BRIDGE macro? Do you mean ? PCIHostState *s = PCI_HOST_BRIDGE(object_resolve_path("/machine/q35", NULL)); I can use it, thanks -- I was doing the usual copy/paste of the i440fx counterpart :) > >> + return s ? s->bus : NULL; >> +} >> + >> uint64_t mch_mcfg_base(void) >> { >> bool ambiguous; >> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h >> index 4bbc0ff..95d7610 100644 >> --- a/include/hw/i386/pc.h >> +++ b/include/hw/i386/pc.h >> @@ -242,6 +242,15 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type, >> MemoryRegion *ram_memory); >> >> PCIBus *find_i440fx(void); >> +PCIBus *find_q35(void); >> + >> +static inline PCIBus *find_pc(void) >> +{ >> + PCIBus *bus = find_i440fx(); >> + >> + return bus ? bus : find_q35(); > > Have you considered a /machine/pci link, or (in case you don't > want to add something new to the QOM tree) a simple > PCMachineState::pci_bus struct field? This is a nice idea, I like the PC machine state, I'll look into it. Thanks, Marcel >
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 736b252..80e9d47 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -950,8 +950,7 @@ build_ssdt(GArray *table_data, GArray *linker, /* Reserve space for header */ acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - /* Extra PCI root buses are implemented only for i440fx */ - bus = find_i440fx(); + bus = find_pc(); if (bus) { QLIST_FOREACH(bus, &bus->child, sibling) { uint8_t bus_num = pci_bus_num(bus); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0cb8afd..c027782 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1174,7 +1174,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data) PcGuestInfoState *guest_info_state = container_of(notifier, PcGuestInfoState, machine_done); - PCIBus *bus = find_i440fx(); + PCIBus *bus = find_pc(); if (bus) { int extra_hosts = 0; diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index c81507d..2fbbcd3 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -511,6 +511,14 @@ static void mch_realize(PCIDevice *d, Error **errp) } } +PCIBus *find_q35(void) +{ + PCIHostState *s = OBJECT_CHECK(PCIHostState, + object_resolve_path("/machine/q35", NULL), + TYPE_PCI_HOST_BRIDGE); + return s ? s->bus : NULL; +} + uint64_t mch_mcfg_base(void) { bool ambiguous; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 4bbc0ff..95d7610 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -242,6 +242,15 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type, MemoryRegion *ram_memory); PCIBus *find_i440fx(void); +PCIBus *find_q35(void); + +static inline PCIBus *find_pc(void) +{ + PCIBus *bus = find_i440fx(); + + return bus ? bus : find_q35(); +} + /* piix4.c */ extern PCIDevice *piix4_dev; int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
Look for pxb devices on both i386 machines. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> --- hw/i386/acpi-build.c | 3 +-- hw/i386/pc.c | 2 +- hw/pci-host/q35.c | 8 ++++++++ include/hw/i386/pc.h | 9 +++++++++ 4 files changed, 19 insertions(+), 3 deletions(-)