PC and ICH9 cleanups
v2 cover PC and ICH9 cleanups
This series contains some cleanups I came across when working on the PC machines. It consists of reducing the usage of global variables and eliminating some redundancies.
The ICH9 cleanups include further QOM'ification, making it more self-contained, and reducing its x86/pc dependencies.
Testing done:
* make check
' make check-avocado
* `qemu-system-x86_64 -M q35 -m 2G -cdrom \
manjaro-kde-21.3.2-220704-linux515.iso`
* qemu-system-x86_64 -M pc -m 2G -cdrom manjaro-kde-21.3.2-220704-linux515.iso
v2:
* Factor out 'hw/i386/pc_q35: Reuse machine parameter' from 'hw/i386/pc_q35:
Resolve redundant q35_host variable' (Zoltan)
* Lower type of phb to Object in 'hw/i386/pc_q35: Resolve redundant q35_host variable' (Zoltan)
* Add ICH9 cleanups
Bernhard Beschow (20):
hw/pci-host/i440fx: Inline sysbus_add_io() hw/pci-host/q35: Inline sysbus_add_io()
hw/i386/pc_q35: Reuse machine parameter
hw/i386/pc_q35: Resolve redundant q35_host variable hw/i386/pc_{q35,piix}: Reuse MachineClass::desc as SMB product name hw/i386/pc_{q35,piix}: Minimize usage of get_system_memory() hw/i386/pc: Initialize ram_memory variable directly hw/i386/ich9: Rename Q35_MASK to ICH9_MASK hw/isa/lpc_ich9: Unexport PIRQ functions hw/isa/lpc_ich9: Eliminate ICH9LPCState::isa_bus hw/isa/lpc_ich9: Reuse memory and io address space of PCI bus hw/i2c/smbus_ich9: Move ich9_smb_set_irq() in front of
ich9_smbus_realize()
hw/i2c/smbus_ich9: Inline ich9_smb_init() and remove it hw/i386/pc_q35: Allow for setting properties before realizing
TYPE_ICH9_LPC_DEVICE
hw/isa/lpc_ich9: Connect pm stuff to lpc internally hw/isa/lpc_ich9: Remove redundant ich9_lpc_reset() invocation hw/i386/ich9: Remove redundant GSI_NUM_PINS
hw: Move ioapic*.h to intc/
hw/i386/ich9: Clean up includes
hw: Move ich9.h to southbridge/
MAINTAINERS | 2 +
include/hw/acpi/ich9.h | 6 +-
include/hw/i386/pc.h | 1 -
include/hw/i386/x86.h | 3 +-
include/hw/{i386 => intc}/ioapic.h | 6 +-
include/hw/{i386 => intc}/ioapic_internal.h | 8 +--
include/hw/{i386 => southbridge}/ich9.h | 35 ++++------
hw/acpi/ich9.c | 10 +--
hw/acpi/ich9_tco.c | 2 +-
hw/i2c/smbus_ich9.c | 39 +++++------
hw/i386/acpi-build.c | 3 +-
hw/i386/kvm/ioapic.c | 3 +-
hw/i386/pc.c | 8 +--
hw/i386/pc_piix.c | 8 +--
hw/i386/pc_q35.c | 73 ++++++++++-----------
hw/intc/apic.c | 2 +-
hw/intc/ioapic.c | 4 +-
hw/intc/ioapic_common.c | 4 +-
hw/isa/lpc_ich9.c | 40 +++++------
hw/pci-bridge/i82801b11.c | 2 +-
hw/pci-host/i440fx.c | 5 +-
hw/pci-host/q35.c | 6 +-
target/i386/whpx/whpx-all.c | 2 +-
tests/qtest/tco-test.c | 2 +-
24 files changed, 127 insertions(+), 147 deletions(-)
rename include/hw/{i386 => intc}/ioapic.h (93%)
rename include/hw/{i386 => intc}/ioapic_internal.h (96%)
rename include/hw/{i386 => southbridge}/ich9.h (91%)Signature · 1 line
2.39.1
PATCH v2 1/20 hw/pci-host/i440fx: Inline sysbus_add_io()
sysbus_add_io() just wraps memory_region_add_subregion() while also obscuring where the memory is attached. So use memory_region_add_subregion() directly and attach it to the existing memory region s->bus->address_space_io which is set as an alias to get_system_io() by the pc machine.
--- hw/pci-host/i440fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/pci-host/i440fx.c +3 -2
@@ -27,6 +27,7 @@#include "qemu/range.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci-host/i440fx.h" #include "hw/qdev-properties.h"
@@ -217,10 +218,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)PCIHostState *s =PCI_HOST_BRIDGE (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev); -sysbus_add_io (sbd,0xcf8 , &s->conf_mem); +memory_region_add_subregion (s->bus->address_space_io,0xcf8 , &s->conf_mem);sysbus_init_ioports (sbd,0xcf8 ,4 ); -sysbus_add_io (sbd,0xcfc , &s->data_mem); +memory_region_add_subregion (s->bus->address_space_io,0xcfc , &s->data_mem);sysbus_init_ioports (sbd,0xcfc ,4 );/* register i440fx 0xcf8 port as coalesced pio */
Signature · 1 line
2.39.1
Re: [PATCH v2 01/20] hw/pci-host/i440fx: Inline sysbus_add_io()
Quoted 10 lines · Bernhard Beschow
sysbus_add_io()just wrapsmemory_region_add_subregion()while also obscuring where the memory is attached. So usememory_region_add_subregion()directly and attach it to the existing memory regions->bus->address_space_iowhich is set as an alias toget_system_io()by the pc machine.Signed-off-by Bernhard Beschow <[email protected]>--- hw/pci-host/i440fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
PATCH v2 2/20 hw/pci-host/q35: Inline sysbus_add_io()
In reply to Bernhard Beschowsysbus_add_io() just wraps memory_region_add_subregion() while also obscuring where the memory is attached. So use memory_region_add_subregion() directly and attach it to the existing memory region s->mch.address_space_io which is set as an alias to get_system_io() by the q35 machine.
--- hw/pci-host/q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/pci-host/q35.c +4 -2
@@ -50,10 +50,12 @@ static void q35_host_realize(DeviceState *dev, Error **errp)Q35PCIHost *s =Q35_HOST_DEVICE (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev); -sysbus_add_io (sbd,MCH_HOST_BRIDGE_CONFIG_ADDR , &pci->conf_mem); +memory_region_add_subregion (s->mch.address_space_io, +MCH_HOST_BRIDGE_CONFIG_ADDR , &pci->conf_mem);sysbus_init_ioports (sbd,MCH_HOST_BRIDGE_CONFIG_ADDR ,4 ); -sysbus_add_io (sbd,MCH_HOST_BRIDGE_CONFIG_DATA , &pci->data_mem); +memory_region_add_subregion (s->mch.address_space_io, +MCH_HOST_BRIDGE_CONFIG_DATA , &pci->data_mem);sysbus_init_ioports (sbd,MCH_HOST_BRIDGE_CONFIG_DATA ,4 );/* register q35 0xcf8 port as coalesced pio */
Signature · 1 line
2.39.1
Re: [PATCH v2 02/20] hw/pci-host/q35: Inline sysbus_add_io()
Quoted 20 lines · Bernhard Beschow
sysbus_add_io()just wrapsmemory_region_add_subregion()while also obscuring where the memory is attached. So usememory_region_add_subregion()directly and attach it to the existing memory regions->mch.address_space_iowhich is set as an alias toget_system_io()by the q35 machine.Signed-off-by Bernhard Beschow <[email protected]>--- hw/pci-host/q35.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)hw/pci-host/q35.c +0
-1@@ -50,10 +50,12 @@ static void q35_host_realize(DeviceState *dev, Error **errp)Q35PCIHost *s =Q35_HOST_DEVICE (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev); -sysbus_add_io (sbd,MCH_HOST_BRIDGE_CONFIG_ADDR , &pci->conf_mem);
hw/pci-host/q35.c static void q35_host_realize(DeviceState *dev, Error **errp) · line 61
Quoted 10 lines
hw/pci-host/q35.c +4
-1+memory_region_add_subregion (s->mch.address_space_io, +MCH_HOST_BRIDGE_CONFIG_ADDR , &pci->conf_mem);sysbus_init_ioports (sbd,MCH_HOST_BRIDGE_CONFIG_ADDR ,4 ); -sysbus_add_io (sbd,MCH_HOST_BRIDGE_CONFIG_DATA , &pci->data_mem); +memory_region_add_subregion (s->mch.address_space_io, +MCH_HOST_BRIDGE_CONFIG_DATA , &pci->data_mem);sysbus_init_ioports (sbd,MCH_HOST_BRIDGE_CONFIG_DATA ,4 );/* register q35 0xcf8 port as coalesced pio */
PATCH v2 3/20 hw/i386/pc_q35: Reuse machine parameter
In reply to Bernhard Beschow--- hw/i386/pc_q35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_q35.c +1 -1
@@ -218,7 +218,7 @@ static void pc_q35_init(MachineState *machine)pc_memory_init (pcms,get_system_memory (), rom_memory, &ram_memory, pci_hole64_size); -object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host)); +object_property_add_child (OBJECT (machine),"q35" ,OBJECT (q35_host));object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory),NULL ); object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_PCI_MEM,
Signature · 1 line
2.39.1
Re: [PATCH v2 03/20] hw/i386/pc_q35: Reuse machine parameter
Quoted 10 lines · Bernhard Beschow
Signed-off-by Bernhard Beschow <[email protected]>--- hw/i386/pc_q35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/pc_q35.c +0
-0
hw/i386/pc_q35.c static void pc_q35_init(MachineState *machine) · line 224
Quoted 8 lines
hw/i386/pc_q35.c +1
-1@@ -218,7 +218,7 @@ static void pc_q35_init(MachineState *machine)pc_memory_init (pcms,get_system_memory (), rom_memory, &ram_memory, pci_hole64_size); -object_property_add_child (qdev_get_machine (),"q35" ,OBJECT (q35_host)); +object_property_add_child (OBJECT (machine),"q35" ,OBJECT (q35_host));object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory),NULL ); object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_PCI_MEM,
PATCH v2 4/20 hw/i386/pc_q35: Resolve redundant q35_host variable
In reply to Bernhard BeschowThe variable is redundant to "phb" and is never used by its real type.
--- hw/i386/pc_q35.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
hw/i386/pc_q35.c +12 -14
@@ -118,8 +118,7 @@ static void pc_q35_init(MachineState *machine)PCMachineState *pcms =PC_MACHINE (machine);PCMachineClass *pcmc =PC_MACHINE_GET_CLASS (pcms);X86MachineState *x86ms =X86_MACHINE (machine); -Q35PCIHost *q35_host; -PCIHostState *phb; +Object *phb;PCIBus *host_bus;PCIDevice *lpc;DeviceState *lpc_dev;
@@ -206,10 +205,10 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - q35_host =Q35_HOST_DEVICE (qdev_new (TYPE_Q35_HOST_DEVICE )); + phb =OBJECT (qdev_new (TYPE_Q35_HOST_DEVICE ));if (pcmc->pci_enabled) { - pci_hole64_size =object_property_get_uint (OBJECT (q35_host), + pci_hole64_size =object_property_get_uint (phb,PCI_HOST_PROP_PCI_HOLE64_SIZE , &error_abort); }
@@ -218,23 +217,22 @@ static void pc_q35_init(MachineState *machine)pc_memory_init (pcms,get_system_memory (), rom_memory, &ram_memory, pci_hole64_size); -object_property_add_child (OBJECT (machine),"q35" ,OBJECT (q35_host)); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_RAM_MEM , +object_property_add_child (OBJECT (machine),"q35" , phb); +object_property_set_link (phb,MCH_HOST_PROP_RAM_MEM ,OBJECT (ram_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_PCI_MEM , +object_property_set_link (phb,MCH_HOST_PROP_PCI_MEM ,OBJECT (pci_memory),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_SYSTEM_MEM , +object_property_set_link (phb,MCH_HOST_PROP_SYSTEM_MEM ,OBJECT (get_system_memory ()),NULL ); -object_property_set_link (OBJECT (q35_host),MCH_HOST_PROP_IO_MEM , +object_property_set_link (phb,MCH_HOST_PROP_IO_MEM ,OBJECT (system_io),NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_BELOW_4G_MEM_SIZE , +object_property_set_int (phb,PCI_HOST_BELOW_4G_MEM_SIZE , x86ms->below_4g_mem_size,NULL ); -object_property_set_int (OBJECT (q35_host),PCI_HOST_ABOVE_4G_MEM_SIZE , +object_property_set_int (phb,PCI_HOST_ABOVE_4G_MEM_SIZE , x86ms->above_4g_mem_size,NULL );/* pci */ -sysbus_realize_and_unref (SYS_BUS_DEVICE (q35_host), &error_fatal); - phb =PCI_HOST_BRIDGE (q35_host); - host_bus = phb->bus; +sysbus_realize_and_unref (SYS_BUS_DEVICE (phb), &error_fatal); + host_bus =PCI_BUS (qdev_get_child_bus (DEVICE (phb),"pcie.0" ));/* create ISA bus */ lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true,
Signature · 1 line
2.39.1
Re: [PATCH v2 04/20] hw/i386/pc_q35: Resolve redundant q35_host variable
Quoted 6 lines · Bernhard Beschow
The variable is redundant to "phb" and is never used by its real type.
Signed-off-by Bernhard Beschow <[email protected]>--- hw/i386/pc_q35.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
PATCH v2 5/20 hw/i386/pc_{q35, piix}: Reuse MachineClass::desc as SMB product name
In reply to Bernhard BeschowNo need to repeat the descriptions.
--- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +1 -1
@@ -197,7 +197,7 @@ static void pc_init1(MachineState *machine,if (pcmc->smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine);/* These values are guest ABI, do not change */ -smbios_set_defaults ("QEMU" ,"Standard PC (i440FX + PIIX, 1996)" , +smbios_set_defaults ("QEMU" , mc->desc, mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, pcms->smbios_entry_point_type);
hw/i386/pc_q35.c +1 -1
@@ -198,7 +198,7 @@ static void pc_q35_init(MachineState *machine)if (pcmc->smbios_defaults) {/* These values are guest ABI, do not change */ -smbios_set_defaults ("QEMU" ,"Standard PC (Q35 + ICH9, 2009)" , +smbios_set_defaults ("QEMU" , mc->desc, mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, pcms->smbios_entry_point_type);
Signature · 1 line
2.39.1
Re: [PATCH v2 05/20] hw/i386/pc_{q35, piix}: Reuse MachineClass::desc as SMB product name
Quoted 8 lines · Bernhard Beschow
No need to repeat the descriptions.
Signed-off-by Bernhard Beschow <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH v2 6/20 hw/i386/pc_{q35, piix}: Minimize usage of get_system_memory()
In reply to Bernhard Beschow--- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +1 -1
@@ -241,7 +241,7 @@ static void pc_init1(MachineState *machine, isa_bus =ISA_BUS (qdev_get_child_bus (DEVICE (piix3),"isa.0" )); }else { pci_bus =NULL ; - isa_bus =isa_bus_new (NULL ,get_system_memory (), system_io, + isa_bus =isa_bus_new (NULL , system_memory, system_io, &error_abort);i8257_dma_init (isa_bus,0 ); pcms->hpet_enabled = false;
hw/i386/pc_q35.c +4 -3
@@ -124,6 +124,7 @@ static void pc_q35_init(MachineState *machine)DeviceState *lpc_dev;BusState *idebus[MAX_SATA_PORTS ];ISADevice *rtc_state; +MemoryRegion *system_memory =get_system_memory ();MemoryRegion *system_io =get_system_io ();MemoryRegion *pci_memory;MemoryRegion *rom_memory;
@@ -191,7 +192,7 @@ static void pc_q35_init(MachineState *machine) rom_memory = pci_memory; }else { pci_memory =NULL ; - rom_memory =get_system_memory (); + rom_memory = system_memory; }pc_guest_info_init (pcms);
@@ -214,7 +215,7 @@ static void pc_q35_init(MachineState *machine) }/* allocate ram and load rom/bios */ -pc_memory_init (pcms,get_system_memory (), rom_memory, &ram_memory, +pc_memory_init (pcms, system_memory, rom_memory, &ram_memory, pci_hole64_size);object_property_add_child (OBJECT (machine),"q35" , phb);
@@ -223,7 +224,7 @@ static void pc_q35_init(MachineState *machine)object_property_set_link (phb,MCH_HOST_PROP_PCI_MEM ,OBJECT (pci_memory),NULL );object_property_set_link (phb,MCH_HOST_PROP_SYSTEM_MEM , -OBJECT (get_system_memory ()),NULL ); +OBJECT (system_memory),NULL );object_property_set_link (phb,MCH_HOST_PROP_IO_MEM ,OBJECT (system_io),NULL ); object_property_set_int(phb, PCI_HOST_BELOW_4G_MEM_SIZE,
Signature · 1 line
2.39.1
Re: [PATCH v2 06/20] hw/i386/pc_{q35,piix}: Minimize usage of get_system_memory()
Quoted 5 lines · Bernhard Beschow
Signed-off-by Bernhard Beschow <[email protected]>--- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
PATCH v2 7/20 hw/i386/pc: Initialize ram_memory variable directly
In reply to Bernhard BeschowGoing through pc_memory_init() seems quite complicated for a simple assignment.
--- include/hw/i386/pc.h | 1 - hw/i386/pc.c | 2 -- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 5 ++--- 4 files changed, 4 insertions(+), 8 deletions(-)
include/hw/i386/pc.h +0 -1
@@ -163,7 +163,6 @@ void xen_load_linux(PCMachineState *pcms);void pc_memory_init (PCMachineState *pcms,MemoryRegion *system_memory,MemoryRegion *rom_memory, -MemoryRegion **ram_memory,uint64_t pci_hole64_size);uint64_t pc_pci_hole64_start (void );DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus);
hw/i386/pc.c +0 -2
@@ -936,7 +936,6 @@ static hwaddr pc_max_used_gpa(PCMachineState *pcms, uint64_t pci_hole64_size)void pc_memory_init (PCMachineState *pcms,MemoryRegion *system_memory,MemoryRegion *rom_memory, -MemoryRegion **ram_memory,uint64_t pci_hole64_size) {int linux_boot, i;
@@ -994,7 +993,6 @@ void pc_memory_init(PCMachineState *pcms,* Split single memory region and use aliases to address portions of it, * done for backwards compatibility with older qemus. */ - *ram_memory = machine->ram; ram_below_4g =g_malloc (sizeof (*ram_below_4g));memory_region_init_alias (ram_below_4g,NULL ,"ram-below-4g" , machine->ram,0 , x86ms->below_4g_mem_size);
hw/i386/pc_piix.c +2 -2
@@ -143,6 +143,7 @@ static void pc_init1(MachineState *machine,if (xen_enabled ()) {xen_hvm_init_pc (pcms, &ram_memory); }else { + ram_memory = machine->ram;if (!pcms->max_ram_below_4g) { pcms->max_ram_below_4g =0xe0000000 ;/* default: 3.5G */ }
@@ -205,8 +206,7 @@ static void pc_init1(MachineState *machine,/* allocate ram and load rom/bios */ if (!xen_enabled ()) { -pc_memory_init (pcms, system_memory, - rom_memory, &ram_memory, hole64_size); +pc_memory_init (pcms, system_memory, rom_memory, hole64_size); }else {pc_system_flash_cleanup_unused (pcms);if (machine->kernel_filename !=NULL ) {
hw/i386/pc_q35.c +2 -3
@@ -128,7 +128,7 @@ static void pc_q35_init(MachineState *machine)MemoryRegion *system_io =get_system_io ();MemoryRegion *pci_memory;MemoryRegion *rom_memory; -MemoryRegion *ram_memory; +MemoryRegion *ram_memory = machine->ram;GSIState *gsi_state;ISABus *isa_bus;int i;
@@ -215,8 +215,7 @@ static void pc_q35_init(MachineState *machine) }/* allocate ram and load rom/bios */ -pc_memory_init (pcms, system_memory, rom_memory, &ram_memory, - pci_hole64_size); +pc_memory_init (pcms, system_memory, rom_memory, pci_hole64_size);object_property_add_child (OBJECT (machine),"q35" , phb); object_property_set_link(phb, MCH_HOST_PROP_RAM_MEM,
Signature · 1 line
2.39.1
PATCH v2 8/20 hw/i386/ich9: Rename Q35_MASK to ICH9_MASK
In reply to Bernhard BeschowThe Q35_MASK macro is already defined by TYPE_Q35_HOST_DEVICE, so let TYPE_ICH9_LPC_DEVICE have its own one to prevent potential name clash.
--- include/hw/i386/ich9.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
include/hw/i386/ich9.h +5 -5
@@ -75,7 +75,7 @@ struct ICH9LPCState {qemu_irq gsi[GSI_NUM_PINS ]; }; -#define Q35_MASK (bit, ms_bit, ls_bit) \ +#define ICH9_MASK (bit, ms_bit, ls_bit) \ ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))/* ICH9: Chipset Configuration Registers */
@@ -137,13 +137,13 @@ struct ICH9LPCState {#define ICH9_LPC_NB_PIRQS 8/* PCI A-H */ #define ICH9_LPC_PMBASE 0x40 -#define ICH9_LPC_PMBASE_BASE_ADDRESS_MASK Q35_MASK(32, 15, 7) +#define ICH9_LPC_PMBASE_BASE_ADDRESS_MASK ICH9_MASK(32, 15, 7)#define ICH9_LPC_PMBASE_RTE 0x1#define ICH9_LPC_PMBASE_DEFAULT 0x1#define ICH9_LPC_ACPI_CTRL 0x44#define ICH9_LPC_ACPI_CTRL_ACPI_EN 0x80 -#define ICH9_LPC_ACPI_CTRL_SCI_IRQ_SEL_MASK Q35_MASK(8, 2, 0) +#define ICH9_LPC_ACPI_CTRL_SCI_IRQ_SEL_MASK ICH9_MASK(8, 2, 0)#define ICH9_LPC_ACPI_CTRL_9 0x0#define ICH9_LPC_ACPI_CTRL_10 0x1#define ICH9_LPC_ACPI_CTRL_11 0x2
@@ -162,7 +162,7 @@ struct ICH9LPCState {#define ICH9_LPC_PIRQH_ROUT 0x6b#define ICH9_LPC_PIRQ_ROUT_IRQEN 0x80 -#define ICH9_LPC_PIRQ_ROUT_MASK Q35_MASK(8, 3, 0) +#define ICH9_LPC_PIRQ_ROUT_MASK ICH9_MASK(8, 3, 0)#define ICH9_LPC_PIRQ_ROUT_DEFAULT 0x80#define ICH9_LPC_GEN_PMCON_1 0xa0
@@ -172,7 +172,7 @@ struct ICH9LPCState {#define ICH9_LPC_GEN_PMCON_LOCK 0xa6#define ICH9_LPC_RCBA 0xf0 -#define ICH9_LPC_RCBA_BA_MASK Q35_MASK(32, 31, 14) +#define ICH9_LPC_RCBA_BA_MASK ICH9_MASK(32, 31, 14)#define ICH9_LPC_RCBA_EN 0x1#define ICH9_LPC_RCBA_DEFAULT 0x0
Signature · 1 line
2.39.1
Re: [PATCH v2 08/20] hw/i386/ich9: Rename Q35_MASK to ICH9_MASK
Quoted 2 lines · Bernhard Beschow
The
Q35_MASKmacro is already defined byTYPE_Q35_HOST_DEVICE, so letTYPE_ICH9_LPC_DEVICEhave its own one to prevent potential name clash.
Ouch, good catch!
Quoted 4 lines
Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/i386/ich9.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
PATCH v2 9/20 hw/isa/lpc_ich9: Unexport PIRQ functions
In reply to Bernhard BeschowNo need to rely on the board to wire up the ICH9 PCI IRQs. All functions access private state of the LPC device which suggests that it should wire up the IRQs.
--- include/hw/i386/ich9.h | 3 --- hw/i386/pc_q35.c | 3 --- hw/isa/lpc_ich9.c | 11 ++++++++--- 3 files changed, 8 insertions(+), 9 deletions(-)
include/hw/i386/ich9.h +0 -3
@@ -9,9 +9,6 @@#include "hw/acpi/ich9.h" #include "qom/object.h" -void ich9_lpc_set_irq (void *opaque,int irq_num,int level); -int ich9_lpc_map_irq (PCIDevice *pci_dev,int intx); -PCIINTxRoute ich9_route_intx_pin_to_irq (void *opaque,int pirq_pin);void ich9_lpc_pm_init (PCIDevice *pci_lpc,bool smm_enabled);I2CBus *ich9_smb_init (PCIBus *bus,int devfn,uint32_t smb_io_base);
hw/i386/pc_q35.c +0 -3
@@ -267,9 +267,6 @@ static void pc_q35_init(MachineState *machine)for (i =0 ; i <GSI_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } -pci_bus_irqs (host_bus, ich9_lpc_set_irq, ich9_lpc,ICH9_LPC_NB_PIRQS ); -pci_bus_map_irqs (host_bus, ich9_lpc_map_irq); -pci_bus_set_route_irq_fn (host_bus, ich9_route_intx_pin_to_irq); isa_bus = ich9_lpc->isa_bus;if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) {
hw/isa/lpc_ich9.c +8 -3
@@ -259,7 +259,7 @@ static void ich9_lpc_update_apic(ICH9LPCState *lpc, int gsi)qemu_set_irq (lpc->gsi[gsi], level); } -void ich9_lpc_set_irq (void *opaque,int pirq,int level) +static void ich9_lpc_set_irq (void *opaque,int pirq,int level) {ICH9LPCState *lpc = opaque;int pic_irq, pic_dis;
@@ -275,7 +275,7 @@ void ich9_lpc_set_irq(void *opaque, int pirq, int level)/* return the pirq number (PIRQ[A-H]:0-7) corresponding to * a given device irq pin. */ -int ich9_lpc_map_irq (PCIDevice *pci_dev,int intx) +static int ich9_lpc_map_irq (PCIDevice *pci_dev,int intx) {BusState *bus =qdev_get_parent_bus (&pci_dev->qdev);PCIBus *pci_bus =PCI_BUS (bus);
@@ -286,7 +286,7 @@ int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx)return lpc->irr[PCI_SLOT (pci_dev->devfn)][intx]; } -PCIINTxRoute ich9_route_intx_pin_to_irq (void *opaque,int pirq_pin) +static PCIINTxRoute ich9_route_intx_pin_to_irq (void *opaque,int pirq_pin) {ICH9LPCState *lpc = opaque;PCIINTxRoute route;
@@ -680,6 +680,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp) {ICH9LPCState *lpc =ICH9_LPC_DEVICE (d);DeviceState *dev =DEVICE (d); +PCIBus *pci_bus =pci_get_bus (d);ISABus *isa_bus; if ((lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)) &&
@@ -728,6 +729,10 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)isa_bus_irqs (isa_bus, lpc->gsi);i8257_dma_init (isa_bus,0 ); + +pci_bus_irqs (pci_bus, ich9_lpc_set_irq, d,ICH9_LPC_NB_PIRQS ); +pci_bus_map_irqs (pci_bus, ich9_lpc_map_irq); +pci_bus_set_route_irq_fn (pci_bus, ich9_route_intx_pin_to_irq); }static bool ich9_rst_cnt_needed (void *opaque)
Signature · 1 line
2.39.1
PATCH v2 10/20 hw/isa/lpc_ich9: Eliminate ICH9LPCState::isa_bus
In reply to Bernhard BeschowBy using qdev_get_child_bus() we can eliminate ICH9LPCState::isa_bus and spare the ich9_lpc variable in pc_q35, too.
--- include/hw/i386/ich9.h | 3 --- hw/i386/pc_q35.c | 4 +--- hw/isa/lpc_ich9.c | 5 +---- 3 files changed, 2 insertions(+), 10 deletions(-)
include/hw/i386/ich9.h +0 -3
@@ -1,7 +1,6 @@#ifndef HW_ICH9_H #define HW_ICH9_H -#include "hw/isa/isa.h" #include "hw/sysbus.h" #include "hw/i386/pc.h" #include "hw/isa/apm.h"
@@ -64,8 +63,6 @@ struct ICH9LPCState {* triggers feature lockdown */ uint64_t smi_negotiated_features;/* guest-invisible, host endian */ -/* isa bus */ -ISABus *isa_bus;MemoryRegion rcrb_mem;/* root complex register block */ Notifier machine_ready;
hw/i386/pc_q35.c +1 -3
@@ -132,7 +132,6 @@ static void pc_q35_init(MachineState *machine)GSIState *gsi_state;ISABus *isa_bus;int i; -ICH9LPCState *ich9_lpc;PCIDevice *ahci;ram_addr_t lowmem;DriveInfo *hd[MAX_SATA_PORTS ];
@@ -262,12 +261,11 @@ static void pc_q35_init(MachineState *machine)/* irq lines */ gsi_state =pc_gsi_create (&x86ms->gsi, pcmc->pci_enabled); - ich9_lpc =ICH9_LPC_DEVICE (lpc); lpc_dev =DEVICE (lpc);for (i =0 ; i <GSI_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } - isa_bus = ich9_lpc->isa_bus; + isa_bus =ISA_BUS (qdev_get_child_bus (lpc_dev,"isa.0" ));if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) {pc_i8259_create (isa_bus, gsi_state->i8259_irq);
hw/isa/lpc_ich9.c +1 -4
@@ -710,8 +710,6 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)memory_region_init_io (&lpc->rcrb_mem,OBJECT (d), &rcrb_mmio_ops, lpc,"lpc-rcrb-mmio" ,ICH9_CC_SIZE ); - lpc->isa_bus = isa_bus; -ich9_cc_init (lpc);apm_init (d, &lpc->apm, ich9_apm_ctrl_changed, lpc);
@@ -819,8 +817,7 @@ static void build_ich9_isa_aml(AcpiDevAmlIf *adev, Aml *scope) {Aml *field;BusChild *kid; -ICH9LPCState *s =ICH9_LPC_DEVICE (adev); -BusState *bus =BUS (s->isa_bus); +BusState *bus =qdev_get_child_bus (DEVICE (adev),"isa.0" );Aml *sb_scope =aml_scope ("\\_SB" );/* ICH9 PCI to ISA irq remapping */
Signature · 1 line
2.39.1
Re: [PATCH v2 10/20] hw/isa/lpc_ich9: Eliminate ICH9LPCState::isa_bus
Quoted 9 lines · Bernhard Beschow
By using
qdev_get_child_bus()we can eliminateICH9LPCState::isa_busand spare theich9_lpcvariable inpc_q35, too.Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/i386/ich9.h | 3 --- hw/i386/pc_q35.c | 4 +--- hw/isa/lpc_ich9.c | 5 +---- 3 files changed, 2 insertions(+), 10 deletions(-)
PATCH v2 11/20 hw/isa/lpc_ich9: Reuse memory and io address space of PCI bus
In reply to Bernhard BeschowIn pc_q35.c the PCI host bridge's io and memory space is initialized with get_system_memory() and get_system_io() respectively. Therefore, using pci_address_space() and pci_address_space_io() is equivalent. All in all this makes the LPC function respect whatever memory spaces the PCI bus was set up with.
--- hw/isa/lpc_ich9.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/isa/lpc_ich9.c +3 -3
@@ -506,10 +506,10 @@ static void ich9_lpc_rcba_update(ICH9LPCState *lpc, uint32_t rcba_old)uint32_t rcba =pci_get_long (lpc->d.config +ICH9_LPC_RCBA );if (rcba_old &ICH9_LPC_RCBA_EN ) { -memory_region_del_subregion (get_system_memory (), &lpc->rcrb_mem); +memory_region_del_subregion (pci_address_space (&lpc->d), &lpc->rcrb_mem); }if (rcba &ICH9_LPC_RCBA_EN ) { -memory_region_add_subregion_overlap (get_system_memory (), +memory_region_add_subregion_overlap (pci_address_space (&lpc->d), rcba &ICH9_LPC_RCBA_BA_MASK , &lpc->rcrb_mem,1 ); }
@@ -695,7 +695,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)return ; } - isa_bus =isa_bus_new (DEVICE (d),get_system_memory (),get_system_io (), + isa_bus =isa_bus_new (dev,pci_address_space (d),pci_address_space_io (d), errp);if (!isa_bus) {return ;
Signature · 1 line
2.39.1
Re: [PATCH v2 11/20] hw/isa/lpc_ich9: Reuse memory and io address space of PCI bus
Am 31. Januar 2023 11:53:17 UTC schrieb Bernhard Beschow <[email protected]>:
Quoted 3 lines
In
pc_q35.cthe PCI host bridge's io and memory space is initialized withget_system_memory()andget_system_io()respectively. Therefore, usingpci_address_space()andpci_address_space_io()is equivalent.
Self-NACK: pci_address_space() != get_system_memory().
Please ignore this patch. This patch can be omitted from the series w/o any syntactic or semantic conflicts. I'll omit it in v3.
Quoted 35 lines
All
in all this makes the LPC function respect whatever memory spaces the PCI bus was set up with.Signed-off-by Bernhard Beschow <[email protected]>---
hw/isa/lpc_ich9.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)hw/isa/lpc_ich9.c +3
-3@@ -506,10 +506,10 @@ static void ich9_lpc_rcba_update(ICH9LPCState *lpc, uint32_t rcba_old)uint32_t rcba =pci_get_long (lpc->d.config +ICH9_LPC_RCBA );if (rcba_old &ICH9_LPC_RCBA_EN ) { -memory_region_del_subregion (get_system_memory (), &lpc->rcrb_mem); +memory_region_del_subregion (pci_address_space (&lpc->d), &lpc->rcrb_mem); }if (rcba &ICH9_LPC_RCBA_EN ) { -memory_region_add_subregion_overlap (get_system_memory (), +memory_region_add_subregion_overlap (pci_address_space (&lpc->d), rcba &ICH9_LPC_RCBA_BA_MASK , &lpc->rcrb_mem,1 ); }@@ -695,7 +695,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)return ; } - isa_bus =isa_bus_new (DEVICE (d),get_system_memory (),get_system_io (), + isa_bus =isa_bus_new (dev,pci_address_space (d),pci_address_space_io (d), errp);if (!isa_bus) {return ;
PATCH v2 12/20 hw/i2c/smbus_ich9: Move ich9_smb_set_irq() in front of ich9_smbus_realize()
In reply to Bernhard BeschowThis is a preparation for the next commit to make it cleaner.
--- hw/i2c/smbus_ich9.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/i2c/smbus_ich9.c +12 -12
@@ -80,6 +80,18 @@ static void ich9_smbus_write_config(PCIDevice *d, uint32_t address, } } +static void ich9_smb_set_irq (PMSMBus *pmsmb,bool enabled) +{ +ICH9SMBState *s = pmsmb->opaque; + +if (enabled == s->irq_enabled) { +return ; + } + + s->irq_enabled = enabled; +pci_set_irq (&s->dev, enabled); +} +static void ich9_smbus_realize (PCIDevice *d,Error **errp) {ICH9SMBState *s =ICH9_SMB_DEVICE (d);
@@ -128,18 +140,6 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data) adevc->build_dev_aml = build_ich9_smb_aml; } -static void ich9_smb_set_irq (PMSMBus *pmsmb,bool enabled) -{ -ICH9SMBState *s = pmsmb->opaque; - -if (enabled == s->irq_enabled) { -return ; - } - - s->irq_enabled = enabled; -pci_set_irq (&s->dev, enabled); -} -I2CBus *ich9_smb_init (PCIBus *bus,int devfn,uint32_t smb_io_base) { PCIDevice *d =
Signature · 1 line
2.39.1
PATCH v2 13/20 hw/i2c/smbus_ich9: Inline ich9_smb_init() and remove it
In reply to Bernhard Beschowich9_smb_init() is a legacy init function, so modernize the code.
Note that the smb_io_base parameter was unused.
--- include/hw/i386/ich9.h | 1 - hw/i2c/smbus_ich9.c | 13 +++---------- hw/i386/pc_q35.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 14 deletions(-)
include/hw/i386/ich9.h +0 -1
@@ -9,7 +9,6 @@#include "qom/object.h" void ich9_lpc_pm_init (PCIDevice *pci_lpc,bool smm_enabled); -I2CBus *ich9_smb_init (PCIBus *bus,int devfn,uint32_t smb_io_base);void ich9_generate_smi (void );
hw/i2c/smbus_ich9.c +3 -10
@@ -105,6 +105,9 @@ static void ich9_smbus_realize(PCIDevice *d, Error **errp)pm_smbus_init (&d->qdev, &s->smb, false);pci_register_bar (d,ICH9_SMB_SMB_BASE_BAR ,PCI_BASE_ADDRESS_SPACE_IO , &s->smb.io); + + s->smb.set_irq = ich9_smb_set_irq; + s->smb.opaque = s; }static void build_ich9_smb_aml (AcpiDevAmlIf *adev,Aml *scope)
@@ -140,16 +143,6 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data) adevc->build_dev_aml = build_ich9_smb_aml; } -I2CBus *ich9_smb_init (PCIBus *bus,int devfn,uint32_t smb_io_base) -{ -PCIDevice *d = -pci_create_simple_multifunction (bus, devfn, true,TYPE_ICH9_SMB_DEVICE ); -ICH9SMBState *s =ICH9_SMB_DEVICE (d); - s->smb.set_irq = ich9_smb_set_irq; - s->smb.opaque = s; -return s->smb.smbus; -} -static const TypeInfo ich9_smb_info = { .name =TYPE_ICH9_SMB_DEVICE , .parent =TYPE_PCI_DEVICE ,
hw/i386/pc_q35.c +8 -3
@@ -312,10 +312,15 @@ static void pc_q35_init(MachineState *machine) }if (pcms->smbus_enabled) { +PCIDevice *smb; +/* TODO: Populate SPD eeprom data. */ - pcms->smbus =ich9_smb_init (host_bus, -PCI_DEVFN (ICH9_SMB_DEV ,ICH9_SMB_FUNC ), -0xb100 ); + smb =pci_create_simple_multifunction (host_bus, +PCI_DEVFN (ICH9_SMB_DEV , +ICH9_SMB_FUNC ), + true,TYPE_ICH9_SMB_DEVICE ); + pcms->smbus =I2C_BUS (qdev_get_child_bus (DEVICE (smb),"i2c" )); +smbus_eeprom_init (pcms->smbus,8 ,NULL ,0 ); }
Signature · 1 line
2.39.1
PATCH v2 14/20 hw/i386/pc_q35: Allow for setting properties before realizing TYPE_ICH9_LPC_DEVICE
In reply to Bernhard BeschowThis is a preparation to make the next patch cleaner.
--- hw/i386/pc_q35.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_q35.c +4 -3
@@ -232,10 +232,11 @@ static void pc_q35_init(MachineState *machine)/* pci */ sysbus_realize_and_unref (SYS_BUS_DEVICE (phb), &error_fatal); host_bus =PCI_BUS (qdev_get_child_bus (DEVICE (phb),"pcie.0" )); +/* create ISA bus */ - lpc =pci_create_simple_multifunction (host_bus,PCI_DEVFN (ICH9_LPC_DEV , -ICH9_LPC_FUNC ), true, -TYPE_ICH9_LPC_DEVICE ); + lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ), true, +TYPE_ICH9_LPC_DEVICE ); +pci_realize_and_unref (lpc, host_bus, &error_fatal); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER,
Signature · 1 line
2.39.1
PATCH v2 15/20 hw/isa/lpc_ich9: Connect pm stuff to lpc internally
In reply to Bernhard BeschowMake TYPE_ICH9_LPC_DEVICE more self-contained by moving the call to ich9_lpc_pm_init() from board code to its realize function. In order to propagate x86_machine_is_smm_enabled(), introduce an "smm-enabled" property like we have in piix4.
--- include/hw/acpi/ich9.h | 6 ++---- include/hw/i386/ich9.h | 2 -- hw/acpi/ich9.c | 8 ++------ hw/i386/pc_q35.c | 5 ++--- hw/isa/lpc_ich9.c | 8 +++++--- 5 files changed, 11 insertions(+), 18 deletions(-)
include/hw/acpi/ich9.h +2 -4
@@ -64,7 +64,7 @@ typedef struct ICH9LPCPMRegs {uint8_t disable_s3;uint8_t disable_s4;uint8_t s4_val; -uint8_t smm_enabled; +bool smm_enabled;bool smm_compat;bool enable_tco;TCOIORegs tco_regs;
@@ -72,9 +72,7 @@ typedef struct ICH9LPCPMRegs {#define ACPI_PM_PROP_TCO_ENABLED "enable_tco" -void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm, -bool smm_enabled, -qemu_irq sci_irq); +void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm,qemu_irq sci_irq);void ich9_pm_iospace_update (ICH9LPCPMRegs *pm,uint32_t pm_io_base);extern const VMStateDescription vmstate_ich9_pm;
include/hw/i386/ich9.h +0 -2
@@ -8,8 +8,6 @@#include "hw/acpi/ich9.h" #include "qom/object.h" -void ich9_lpc_pm_init (PCIDevice *pci_lpc,bool smm_enabled); -void ich9_generate_smi (void );#define ICH9_CC_SIZE (16 * 1024)/* 16KB. Chipset configuration registers */
hw/acpi/ich9.c +2 -6
@@ -291,9 +291,7 @@ static void pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&pm->acpi_regs); } -void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm, -bool smm_enabled, -qemu_irq sci_irq) +void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm,qemu_irq sci_irq) {memory_region_init (&pm->io,OBJECT (lpc_pci),"ich9-pm" ,ICH9_PMIO_SIZE );memory_region_set_enabled (&pm->io, false);
@@ -303,7 +301,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,acpi_pm_tmr_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_evt_init (&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);acpi_pm1_cnt_init (&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4, - pm->s4_val, !pm->smm_compat && !smm_enabled); + pm->s4_val, !pm->smm_compat && !pm->smm_enabled);acpi_gpe_init (&pm->acpi_regs,ICH9_PMIO_GPE0_LEN ); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,
@@ -314,8 +312,6 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, "acpi-smi", 8);memory_region_add_subregion (&pm->io,ICH9_PMIO_SMI_EN , &pm->io_smi); - pm->smm_enabled = smm_enabled; -if (pm->enable_tco) {acpi_pm_tco_init (&pm->tco_regs, &pm->io); }
hw/i386/pc_q35.c +2 -3
@@ -236,6 +236,8 @@ static void pc_q35_init(MachineState *machine)/* create ISA bus */ lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ), true,TYPE_ICH9_LPC_DEVICE ); +qdev_prop_set_bit (DEVICE (lpc),"smm-enabled" , +x86_machine_is_smm_enabled (x86ms));pci_realize_and_unref (lpc, host_bus, &error_fatal); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
@@ -289,9 +291,6 @@ static void pc_q35_init(MachineState *machine)pc_basic_device_init (pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,0xff0104 ); -/* connect pm stuff to lpc */ -ich9_lpc_pm_init (lpc,x86_machine_is_smm_enabled (x86ms)); -if (pcms->sata_enabled) {/* ahci and SATA device, for q35 1 ahci controller is built-in */ ahci = pci_create_simple_multifunction(host_bus,
hw/isa/lpc_ich9.c +5 -3
@@ -407,14 +407,13 @@ static void smi_features_ok_callback(void *opaque) lpc->smi_features_ok =1 ; } -void ich9_lpc_pm_init (PCIDevice *lpc_pci,bool smm_enabled) +static void ich9_lpc_pm_init (ICH9LPCState *lpc) { -ICH9LPCState *lpc =ICH9_LPC_DEVICE (lpc_pci);qemu_irq sci_irq;FWCfgState *fw_cfg =fw_cfg_find (); sci_irq =qemu_allocate_irq (ich9_set_sci, lpc,0 ); -ich9_pm_init (lpc_pci, &lpc->pm, smm_enabled, sci_irq); +ich9_pm_init (PCI_DEVICE (lpc), &lpc->pm, sci_irq);if (lpc->smi_host_features && fw_cfg) {uint64_t host_features_le;
@@ -731,6 +730,8 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)pci_bus_irqs (pci_bus, ich9_lpc_set_irq, d,ICH9_LPC_NB_PIRQS );pci_bus_map_irqs (pci_bus, ich9_lpc_map_irq);pci_bus_set_route_irq_fn (pci_bus, ich9_route_intx_pin_to_irq); + +ich9_lpc_pm_init (lpc); }static bool ich9_rst_cnt_needed (void *opaque)
@@ -797,6 +798,7 @@ static const VMStateDescription vmstate_ich9_lpc = {static Property ich9_lpc_properties[] = {DEFINE_PROP_BOOL ("noreboot" , ICH9LPCState, pin_strap.spkr_hi, false),DEFINE_PROP_BOOL ("smm-compat" , ICH9LPCState, pm.smm_compat, false), +DEFINE_PROP_BOOL ("smm-enabled" , ICH9LPCState, pm.smm_enabled, false),DEFINE_PROP_BIT64 ("x-smi-broadcast" , ICH9LPCState, smi_host_features,ICH9_LPC_SMI_F_BROADCAST_BIT , true), DEFINE_PROP_BIT64("x-smi-cpu-hotplug", ICH9LPCState, smi_host_features,
Signature · 1 line
2.39.1
PATCH v2 16/20 hw/isa/lpc_ich9: Remove redundant ich9_lpc_reset() invocation
In reply to Bernhard Beschowich9_lpc_reset() is the dc->reset callback which is called automatically. No need to call it explicitly during k->realize.
--- hw/isa/lpc_ich9.c | 4 ---- 1 file changed, 4 deletions(-)
hw/isa/lpc_ich9.c +0 -4
@@ -57,8 +57,6 @@/*****************************************************************************/ /* ICH9 LPC PCI to ISA bridge */ -static void ich9_lpc_reset (DeviceState *qdev); -/* chipset configuration register * to access chipset configuration registers, pci_[sg]et_{byte, word, long} * are used.
@@ -439,8 +437,6 @@ static void ich9_lpc_pm_init(ICH9LPCState *lpc)sizeof lpc->smi_features_ok, true); } - -ich9_lpc_reset (DEVICE (lpc)); }/* APM */
Signature · 1 line
2.39.1
PATCH v2 17/20 hw/i386/ich9: Remove redundant GSI_NUM_PINS
In reply to Bernhard BeschowMost code uses IOAPIC_NUM_PINS. The only place where GSI_NUM_PINS defines the size of an array is ICH9LPCState::gsi which needs to match IOAPIC_NUM_PINS. Remove GSI_NUM_PINS for consistency.
--- include/hw/i386/ich9.h | 2 +- include/hw/i386/x86.h | 1 - hw/i386/pc.c | 6 +++--- hw/i386/pc_q35.c | 3 ++- hw/isa/lpc_ich9.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
include/hw/i386/ich9.h +1 -1
@@ -63,7 +63,7 @@ struct ICH9LPCState {MemoryRegion rcrb_mem;/* root complex register block */ Notifier machine_ready; -qemu_irq gsi[GSI_NUM_PINS ]; +qemu_irq gsi[IOAPIC_NUM_PINS ]; };#define ICH9_MASK (bit, ms_bit, ls_bit) \
include/hw/i386/x86.h +0 -1
@@ -134,7 +134,6 @@ bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);/* Global System Interrupts */ -#define GSI_NUM_PINS IOAPIC_NUM_PINS#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) typedef struct GSIState {
hw/i386/pc.c +3 -3
@@ -28,7 +28,7 @@#include "hw/i386/pc.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" -#include "hw/i386/apic.h" +#include "hw/i386/ioapic.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/vmport.h"
@@ -406,7 +406,7 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled)if (kvm_ioapic_in_kernel ()) {kvm_pc_setup_irq_routing (pci_enabled); } - *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS ); + *irqs =qemu_allocate_irqs (gsi_handler, s,IOAPIC_NUM_PINS );return s; }
@@ -1295,7 +1295,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,sysbus_realize_and_unref (SYS_BUS_DEVICE (hpet), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (hpet),0 ,HPET_BASE ); -for (i =0 ; i <GSI_NUM_PINS ; i++) { +for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {sysbus_connect_irq (SYS_BUS_DEVICE (hpet), i, gsi[i]); } pit_isa_irq =-1 ;
hw/i386/pc_q35.c +2 -1
@@ -43,6 +43,7 @@#include "hw/i386/ich9.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/i386/ioapic.h" #include "hw/display/ramfb.h" #include "hw/firmware/smbios.h" #include "hw/ide/pci.h"
@@ -265,7 +266,7 @@ static void pc_q35_init(MachineState *machine) gsi_state =pc_gsi_create (&x86ms->gsi, pcmc->pci_enabled); lpc_dev =DEVICE (lpc); -for (i =0 ; i <GSI_NUM_PINS ; i++) { +for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } isa_bus =ISA_BUS (qdev_get_child_bus (lpc_dev,"isa.0" ));
hw/isa/lpc_ich9.c +1 -1
@@ -717,7 +717,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)ICH9_RST_CNT_IOPORT , &lpc->rst_cnt_mem, 1); -qdev_init_gpio_out_named (dev, lpc->gsi,ICH9_GPIO_GSI ,GSI_NUM_PINS ); +qdev_init_gpio_out_named (dev, lpc->gsi,ICH9_GPIO_GSI ,IOAPIC_NUM_PINS );isa_bus_irqs (isa_bus, lpc->gsi);
Signature · 1 line
2.39.1
PATCH v2 18/20 hw: Move ioapic*.h to intc/
In reply to Bernhard BeschowThe ioapic sources reside in hw/intc already. Move the headers there as well.
---
MAINTAINERS | 1 +
include/hw/i386/x86.h | 2 +-
include/hw/{i386 => intc}/ioapic.h | 6 +++---
include/hw/{i386 => intc}/ioapic_internal.h | 8 ++++----
hw/i386/kvm/ioapic.c | 3 +--
hw/i386/pc.c | 2 +-
hw/i386/pc_q35.c | 2 +-
hw/intc/apic.c | 2 +-
hw/intc/ioapic.c | 4 ++--
hw/intc/ioapic_common.c | 4 ++--
target/i386/whpx/whpx-all.c | 2 +-
11 files changed, 18 insertions(+), 18 deletions(-)
rename include/hw/{i386 => intc}/ioapic.h (93%)
rename include/hw/{i386 => intc}/ioapic_internal.h (96%)MAINTAINERS +1 -0
@@ -1703,6 +1703,7 @@ F: include/hw/char/parallel.h F: include/hw/dma/i8257.h F: include/hw/i2c/pm_smbus.h F: include/hw/input/i8042.h +F: include/hw/intc/ioapic* F: include/hw/isa/i8259_internal.h F: include/hw/isa/superio.h F: include/hw/timer/hpet.h
include/hw/i386/x86.h +1 -1
@@ -23,8 +23,8 @@#include "hw/i386/topology.h" #include "hw/boards.h" #include "hw/nmi.h" +#include "hw/intc/ioapic.h" #include "hw/isa/isa.h" -#include "hw/i386/ioapic.h" #include "qom/object.h" struct X86MachineClass {
include/hw/intc/ioapic.h renamed from include/hw/i386/ioapic.h +3 -3
@@ -17,8 +17,8 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef HW_IOAPIC_H -#define HW_IOAPIC_H +#ifndef HW_INTC_IOAPIC_H +#define HW_INTC_IOAPIC_H #define IOAPIC_NUM_PINS 24#define IO_APIC_DEFAULT_ADDRESS 0xfec00000
@@ -30,4 +30,4 @@void ioapic_eoi_broadcast (int vector); -#endif /* HW_IOAPIC_H */ +#endif /* HW_INTC_IOAPIC_H */
include/hw/intc/ioapic_internal.h renamed from include/hw/i386/ioapic_internal.h +4 -4
@@ -19,11 +19,11 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef QEMU_IOAPIC_INTERNAL_H -#define QEMU_IOAPIC_INTERNAL_H +#ifndef HW_INTC_IOAPIC_INTERNAL_H +#define HW_INTC_IOAPIC_INTERNAL_H #include "exec/memory.h" -#include "hw/i386/ioapic.h" +#include "hw/intc/ioapic.h" #include "hw/sysbus.h" #include "qemu/notify.h" #include "qom/object.h"
@@ -115,4 +115,4 @@ void ioapic_reset_common(DeviceState *dev);void ioapic_stat_update_irq (IOAPICCommonState *s,int irq,int level); -#endif /* QEMU_IOAPIC_INTERNAL_H */ +#endif /* HW_INTC_IOAPIC_INTERNAL_H */
hw/i386/kvm/ioapic.c +1 -2
@@ -12,9 +12,8 @@#include "qemu/osdep.h" #include "monitor/monitor.h" -#include "hw/i386/x86.h" #include "hw/qdev-properties.h" -#include "hw/i386/ioapic_internal.h" +#include "hw/intc/ioapic_internal.h" #include "hw/intc/kvm_irqcount.h" #include "sysemu/kvm.h"
hw/i386/pc.c +1 -1
@@ -28,7 +28,6 @@#include "hw/i386/pc.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" -#include "hw/i386/ioapic.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/vmport.h"
@@ -47,6 +46,7 @@#include "multiboot.h" #include "hw/rtc/mc146818rtc.h" #include "hw/intc/i8259.h" +#include "hw/intc/ioapic.h" #include "hw/timer/i8254.h" #include "hw/input/i8042.h" #include "hw/irq.h"
hw/i386/pc_q35.c +1 -1
@@ -43,11 +43,11 @@#include "hw/i386/ich9.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" -#include "hw/i386/ioapic.h" #include "hw/display/ramfb.h" #include "hw/firmware/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" +#include "hw/intc/ioapic.h" #include "hw/usb.h" #include "hw/usb/hcd-uhci.h" #include "qapi/error.h"
hw/intc/apic.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/thread.h" #include "hw/i386/apic_internal.h" #include "hw/i386/apic.h" -#include "hw/i386/ioapic.h" +#include "hw/intc/ioapic.h" #include "hw/intc/i8259.h" #include "hw/intc/kvm_irqcount.h" #include "hw/pci/msi.h"
hw/intc/ioapic.c +2 -2
@@ -24,10 +24,10 @@#include "qapi/error.h" #include "monitor/monitor.h" #include "hw/i386/apic.h" -#include "hw/i386/ioapic.h" -#include "hw/i386/ioapic_internal.h" #include "hw/i386/x86.h" #include "hw/intc/i8259.h" +#include "hw/intc/ioapic.h" +#include "hw/intc/ioapic_internal.h" #include "hw/pci/msi.h" #include "hw/qdev-properties.h" #include "sysemu/kvm.h"
hw/intc/ioapic_common.c +2 -2
@@ -24,9 +24,9 @@#include "qemu/module.h" #include "migration/vmstate.h" #include "monitor/monitor.h" -#include "hw/i386/ioapic.h" -#include "hw/i386/ioapic_internal.h" #include "hw/intc/intc.h" +#include "hw/intc/ioapic.h" +#include "hw/intc/ioapic_internal.h" #include "hw/sysbus.h" /* ioapic_no count start from 0 to MAX_IOAPICS,
target/i386/whpx/whpx-all.c +1 -1
@@ -19,7 +19,7 @@#include "sysemu/runstate.h" #include "qemu/main-loop.h" #include "hw/boards.h" -#include "hw/i386/ioapic.h" +#include "hw/intc/ioapic.h" #include "hw/i386/apic_internal.h" #include "qemu/error-report.h" #include "qapi/error.h"
Signature · 1 line
2.39.1
PATCH v2 19/20 hw/i386/ich9: Clean up includes
In reply to Bernhard Beschow--- include/hw/i386/ich9.h | 8 +++++--- hw/i386/acpi-build.c | 1 + hw/isa/lpc_ich9.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)
include/hw/i386/ich9.h +5 -3
@@ -1,11 +1,13 @@#ifndef HW_ICH9_H #define HW_ICH9_H -#include "hw/sysbus.h" -#include "hw/i386/pc.h" #include "hw/isa/apm.h" -#include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" +#include "hw/intc/ioapic.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_device.h" +#include "exec/memory.h" +#include "qemu/notify.h" #include "qom/object.h" void ich9_generate_smi (void );
hw/i386/acpi-build.c +1 -0
@@ -59,6 +59,7 @@#include "hw/acpi/pcihp.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/ich9.h" +#include "hw/i386/pc.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/i440fx.h" #include "hw/pci-host/q35.h"
hw/isa/lpc_ich9.c +1 -1
@@ -40,8 +40,8 @@#include "hw/irq.h" #include "hw/isa/apm.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bridge.h" #include "hw/i386/ich9.h" +#include "hw/i386/pc.h" #include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" #include "hw/pci/pci_bus.h"
Signature · 1 line
2.39.1
Re: [PATCH v2 19/20] hw/i386/ich9: Clean up includes
On Tue, 31 Jan 2023 12:53:25 +0100
Bernhard Beschow <[email protected]> wrote:
this lacks commit description explaining below movements
Quoted 54 lines
Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/i386/ich9.h | 8 +++++--- hw/i386/acpi-build.c | 1 + hw/isa/lpc_ich9.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)include/hw/i386/ich9.h +5
-3@@ -1,11 +1,13 @@#ifndef HW_ICH9_H #define HW_ICH9_H -#include "hw/sysbus.h" -#include "hw/i386/pc.h" #include "hw/isa/apm.h" -#include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" +#include "hw/intc/ioapic.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_device.h" +#include "exec/memory.h" +#include "qemu/notify.h" #include "qom/object.h" void ich9_generate_smi (void );hw/i386/acpi-build.c +1
-0@@ -59,6 +59,7 @@#include "hw/acpi/pcihp.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/ich9.h" +#include "hw/i386/pc.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/i440fx.h" #include "hw/pci-host/q35.h" hw/isa/lpc_ich9.c +1
-1@@ -40,8 +40,8 @@#include "hw/irq.h" #include "hw/isa/apm.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bridge.h" #include "hw/i386/ich9.h" +#include "hw/i386/pc.h" #include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" #include "hw/pci/pci_bus.h"
PATCH v2 20/20 hw: Move ich9.h to southbridge/
In reply to Bernhard BeschowICH9 is a south bridge which doesn't necessarily depend on x86, so move it into the southbridge folder, analoguous to PIIX.
---
MAINTAINERS | 1 +
include/hw/{i386 => southbridge}/ich9.h | 6 +++---
hw/acpi/ich9.c | 2 +-
hw/acpi/ich9_tco.c | 2 +-
hw/i2c/smbus_ich9.c | 2 +-
hw/i386/acpi-build.c | 2 +-
hw/i386/pc_q35.c | 2 +-
hw/isa/lpc_ich9.c | 2 +-
hw/pci-bridge/i82801b11.c | 2 +-
tests/qtest/tco-test.c | 2 +-
10 files changed, 12 insertions(+), 11 deletions(-)
rename include/hw/{i386 => southbridge}/ich9.h (99%)MAINTAINERS +1 -0
@@ -1670,6 +1670,7 @@ F: hw/i2c/smbus_ich9.c F: hw/acpi/piix4.c F: hw/acpi/ich9*.c F: include/hw/acpi/ich9*.h +F: include/hw/southbridge/ich9.h F: include/hw/southbridge/piix.h F: hw/misc/sga.c F: hw/isa/apm.c
include/hw/southbridge/ich9.h renamed from include/hw/i386/ich9.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef HW_ICH9_H -#define HW_ICH9_H +#ifndef HW_SOUTHBRIDGE_ICH9_H +#define HW_SOUTHBRIDGE_ICH9_H #include "hw/isa/apm.h" #include "hw/acpi/ich9.h"
@@ -242,4 +242,4 @@ struct ICH9LPCState {#define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT 1#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT 2 -#endif /* HW_ICH9_H */ +#endif /* HW_SOUTHBRIDGE_ICH9_H */
hw/acpi/ich9.c +1 -1
@@ -36,7 +36,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ich9_tco.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h"
hw/acpi/ich9_tco.c +1 -1
@@ -9,7 +9,7 @@#include "qemu/osdep.h" #include "sysemu/watchdog.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" #include "migration/vmstate.h" #include "hw/acpi/ich9_tco.h"
hw/i2c/smbus_ich9.c +1 -1
@@ -27,7 +27,7 @@#include "migration/vmstate.h" #include "qemu/module.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" #include "qom/object.h" #include "hw/acpi/acpi_aml_interface.h"
hw/i386/acpi-build.c +1 -1
@@ -55,10 +55,10 @@#include "hw/hyperv/vmbus-bridge.h" /* Supported chipsets: */ +#include "hw/southbridge/ich9.h" #include "hw/southbridge/piix.h" #include "hw/acpi/pcihp.h" #include "hw/i386/fw_cfg.h" -#include "hw/i386/ich9.h" #include "hw/i386/pc.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/i440fx.h"
hw/i386/pc_q35.c +1 -1
@@ -40,7 +40,6 @@#include "hw/qdev-properties.h" #include "hw/i386/x86.h" #include "hw/i386/pc.h" -#include "hw/i386/ich9.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" #include "hw/display/ramfb.h"
@@ -48,6 +47,7 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/intc/ioapic.h" +#include "hw/southbridge/ich9.h" #include "hw/usb.h" #include "hw/usb/hcd-uhci.h" #include "qapi/error.h"
hw/isa/lpc_ich9.c +1 -1
@@ -40,7 +40,7 @@#include "hw/irq.h" #include "hw/isa/apm.h" #include "hw/pci/pci.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" #include "hw/i386/pc.h" #include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h"
hw/pci-bridge/i82801b11.c +1 -1
@@ -45,7 +45,7 @@#include "hw/pci/pci_bridge.h" #include "migration/vmstate.h" #include "qemu/module.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" /*****************************************************************************/ /* ICH9 DMI-to-PCI bridge */
tests/qtest/tco-test.c +1 -1
@@ -14,7 +14,7 @@#include "libqos/pci-pc.h" #include "qapi/qmp/qdict.h" #include "hw/pci/pci_regs.h" -#include "hw/i386/ich9.h" +#include "hw/southbridge/ich9.h" #include "hw/acpi/ich9.h" #include "hw/acpi/ich9_tco.h"
Signature · 1 line
2.39.1