provide "etc/system-states" on Q35 too
cover provide "etc/system-states" on Q35 too
S3 support in OVMF says hi.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
Cc: Amit Shah <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Cc: Leon Alrae <[email protected]>
Thanks
Laszlo
Laszlo Ersek (3):
hw/acpi: acpi_pm1_cnt_init(): take "disable_s3" and "disable_s4" hw/acpi: move "etc/system-states" fw_cfg file from PIIX4 to core hw/acpi: piix4_pm_init(): take fw_cfg object no more
include/hw/acpi/acpi.h | 3 ++- include/hw/i386/pc.h | 3 +-- hw/acpi/core.c | 15 ++++++++++++++- hw/acpi/ich9.c | 3 ++- hw/acpi/piix4.c | 13 ++----------- hw/i386/pc_piix.c | 19 +++++++++---------- hw/isa/vt82c686.c | 2 +- hw/mips/mips_malta.c | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 hw/acpi: acpi_pm1_cnt_init(): take "disable_s3" and "disable_s4"
This patch only modifies the function prototype and updates all chipset code that calls acpi_pm1_cnt_init() to pass in their own disable_s3 and disable_s4 settings. vt82c686 is assumed to be fixed "S3 and S4 enabled".
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
--- include/hw/acpi/acpi.h | 3 ++- hw/acpi/core.c | 3 ++- hw/acpi/ich9.c | 3 ++- hw/acpi/piix4.c | 2 +- hw/isa/vt82c686.c | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-)
include/hw/acpi/acpi.h +2 -1
@@ -160,7 +160,8 @@ void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci, MemoryRegion *parent);/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */ -void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent,uint8_t s4_val); +void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, +bool disable_s3,bool disable_s4,uint8_t s4_val);void acpi_pm1_cnt_update (ACPIREGS *ar,bool sci_enable,bool sci_disable);void acpi_pm1_cnt_reset (ACPIREGS *ar);
hw/acpi/core.c +2 -1
@@ -592,7 +592,8 @@ static const MemoryRegionOps acpi_pm_cnt_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent,uint8_t s4_val) +void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent, +bool disable_s3,bool disable_s4,uint8_t s4_val) { ar->pm1.cnt.s4_val = s4_val; ar->wakeup.notify = acpi_notify_wakeup;
hw/acpi/ich9.c +2 -1
@@ -219,7 +219,8 @@ 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->s4_val); +acpi_pm1_cnt_init (&pm->acpi_regs, &pm->io, pm->disable_s3, pm->disable_s4, + pm->s4_val);acpi_gpe_init (&pm->acpi_regs,ICH9_PMIO_GPE0_LEN ); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,
hw/acpi/piix4.c +1 -1
@@ -464,7 +464,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io, s->s4_val); +acpi_pm1_cnt_init (&s->ar, &s->io, s->disable_s3, s->disable_s4, s->s4_val);acpi_gpe_init (&s->ar,GPE_LEN ); s->powerdown_notifier.notify = piix4_pm_powerdown_req;
hw/isa/vt82c686.c +1 -1
@@ -356,7 +356,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)acpi_pm_tmr_init (&s->ar, pm_tmr_timer, &s->io);acpi_pm1_evt_init (&s->ar, pm_tmr_timer, &s->io); -acpi_pm1_cnt_init (&s->ar, &s->io,2 ); +acpi_pm1_cnt_init (&s->ar, &s->io, false, false,2 ); } I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
Signature · 1 line
1.8.3.1
PATCH 2/3 hw/acpi: move "etc/system-states" fw_cfg file from PIIX4 to core
In reply to Laszlo ErsekThe acpi_pm1_cnt_init() core function is responsible for setting up the register block that will ultimately react to S3 and S4 requests (see acpi_pm1_cnt_write()). It makes sense to advertise this configuration to the guest firmware via an easy to parse fw_cfg file (ACPI is too complex for firmware to parse), and indeed PIIX4 does that. However, since acpi_pm1_cnt_init() is not specific to PIIX4, neither should be the fw_cfg file.
This patch makes "etc/system-states" appear on all chipsets modified in the previous patch, not just PIIX4 (assuming they have fw_cfg at all).
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
--- hw/acpi/core.c | 12 ++++++++++++ hw/acpi/piix4.c | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-)
hw/acpi/core.c +12 -0
@@ -22,6 +22,7 @@#include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/acpi/acpi.h" +#include "hw/nvram/fw_cfg.h" #include "qemu/config-file.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h"
@@ -595,12 +596,23 @@ static const MemoryRegionOps acpi_pm_cnt_ops = {void acpi_pm1_cnt_init (ACPIREGS *ar,MemoryRegion *parent,bool disable_s3,bool disable_s4,uint8_t s4_val) { +FWCfgState *fw_cfg; + ar->pm1.cnt.s4_val = s4_val; ar->wakeup.notify = acpi_notify_wakeup;qemu_register_wakeup_notifier (&ar->wakeup);memory_region_init_io (&ar->pm1.cnt.io,memory_region_owner (parent), &acpi_pm_cnt_ops, ar,"acpi-cnt" ,2 );memory_region_add_subregion (parent,4 , &ar->pm1.cnt.io); + + fw_cfg =fw_cfg_find (); +if (fw_cfg) { +uint8_t suspend[6 ] = {128 ,0 ,0 ,129 ,128 ,128 }; + suspend[3 ] =1 | ((!disable_s3) <<7 ); + suspend[4 ] = s4_val | ((!disable_s4) <<7 ); + +fw_cfg_add_file (fw_cfg,"etc/system-states" ,g_memdup (suspend,6 ),6 ); + } }void acpi_pm1_cnt_reset (ACPIREGS *ar)
hw/acpi/piix4.c +0 -8
@@ -514,14 +514,6 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,qdev_init_nofail (dev); -if (fw_cfg) { -uint8_t suspend[6 ] = {128 ,0 ,0 ,129 ,128 ,128 }; - suspend[3 ] =1 | ((!s->disable_s3) <<7 ); - suspend[4 ] = s->s4_val | ((!s->disable_s4) <<7 ); - -fw_cfg_add_file (fw_cfg,"etc/system-states" ,g_memdup (suspend,6 ),6 ); - } -return s->smb.smbus; }
Signature · 1 line
1.8.3.1
PATCH 3/3 hw/acpi: piix4_pm_init(): take fw_cfg object no more
In reply to Laszlo ErsekThis PIIX4 init function has no more reason to receive a pointer to the FwCfg object. Remove the parameter from the prototype, and update callers.
As a result, the pc_init1() function no longer needs to save the return value of pc_memory_init() and xen_load_linux(), which makes it more similar to pc_memory_init().
The return type & value of pc_memory_init() and xen_load_linux() are not changed themselves; maybe we'll need their return values sometime later.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
--- include/hw/i386/pc.h | 3 +-- hw/acpi/piix4.c | 3 +-- hw/i386/pc_piix.c | 19 +++++++++---------- hw/mips/mips_malta.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-)
include/hw/i386/pc.h +1 -2
@@ -219,8 +219,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int kvm_enabled,FWCfgState *fw_cfg, -DeviceState **piix4_pm); +int kvm_enabled,DeviceState **piix4_pm);void piix4_smbus_register_device (SMBusDevice *dev,uint8_t addr);/* hpet.c */
hw/acpi/piix4.c +1 -2
@@ -492,8 +492,7 @@ Object *piix4_pm_find(void)I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int kvm_enabled,FWCfgState *fw_cfg, -DeviceState **piix4_pm) +int kvm_enabled,DeviceState **piix4_pm) {DeviceState *dev;PIIX4PMState *s;
hw/i386/pc_piix.c +9 -10
@@ -99,7 +99,6 @@ static void pc_init1(MachineState *machine,MemoryRegion *pci_memory;MemoryRegion *rom_memory;DeviceState *icc_bridge; -FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info;ram_addr_t lowmem;
@@ -180,16 +179,16 @@ static void pc_init1(MachineState *machine,/* allocate ram and load rom/bios */ if (!xen_enabled ()) { - fw_cfg =pc_memory_init (machine, system_memory, - below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); +pc_memory_init (machine, system_memory, + below_4g_mem_size, above_4g_mem_size, + rom_memory, &ram_memory, guest_info); }else if (machine->kernel_filename !=NULL ) {/* For xen HVM direct kernel boot, load linux here */ - fw_cfg =xen_load_linux (machine->kernel_filename, - machine->kernel_cmdline, - machine->initrd_filename, - below_4g_mem_size, - guest_info); +xen_load_linux (machine->kernel_filename, + machine->kernel_cmdline, + machine->initrd_filename, + below_4g_mem_size, + guest_info); } gsi_state =g_malloc0 (sizeof (*gsi_state));
@@ -288,7 +287,7 @@ static void pc_init1(MachineState *machine,/* TODO: Populate SPD eeprom data. */ smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , gsi[9 ], *smi_irq, -kvm_enabled (), fw_cfg, &piix4_pm); +kvm_enabled (), &piix4_pm);smbus_eeprom_init (smbus,8 ,NULL ,0 ); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
hw/mips/mips_malta.c +1 -1
@@ -1160,7 +1160,7 @@ void mips_malta_init(MachineState *machine)pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 );pci_create_simple (pci_bus, piix4_devfn +2 ,"piix4-usb-uhci" ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 , -isa_get_irq (NULL ,9 ),NULL ,0 ,NULL ,NULL ); +isa_get_irq (NULL ,9 ),NULL ,0 ,NULL );smbus_eeprom_init (smbus,8 , smbus_eeprom_buf, smbus_eeprom_size);g_free (smbus_eeprom_buf); pit =pit_init (isa_bus,0x40 ,0 ,NULL );
Signature · 1 line
1.8.3.1
Quoted 11 lines · Laszlo Ersek
S3 support in OVMF says hi.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
Cc: Amit Shah <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Cc: Leon Alrae <[email protected]>
Quoted 2 lines
Thanks
Laszlo
Looks good. I'll apply it to my smm branch, since I have a conflicting patch in there, but if mst wants to pick it up it would be great. It is an independent bug, and that tree is already becoming pretty large.
Paolo
Quoted 15 lines
Laszlo Ersek (3):
hw/acpi:acpi_pm1_cnt_init(): take "disable_s3" and "disable_s4" hw/acpi: move "etc/system-states"fw_cfgfile from PIIX4 to core hw/acpi:piix4_pm_init(): takefw_cfgobject no moreinclude/hw/acpi/acpi.h | 3 ++- include/hw/i386/pc.h | 3 +-- hw/acpi/core.c | 15 ++++++++++++++- hw/acpi/ich9.c | 3 ++- hw/acpi/piix4.c | 13 ++----------- hw/i386/pc_piix.c | 19 +++++++++---------- hw/isa/vt82c686.c | 2 +- hw/mips/mips_malta.c | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-)
Re: [Qemu-devel] [PATCH 3/3] hw/acpi: piix4_pm_init(): take fw_cfg object no more
In reply to Laszlo ErsekQuoted 6 lines · Laszlo Ersek
This PIIX4 init function has no more reason to receive a pointer to the FwCfg object. Remove the parameter from the prototype, and update callers.
As a result, the
pc_init1()function no longer needs to save the return value ofpc_memory_init()andxen_load_linux(), which makes it more similar topc_memory_init().
Argh, mis-paste. Whoever picks this up (assuming the patches are good enough), please replace the 2nd instance of pc_memory_init() with pc_q35_init().
Thanks!
Laszlo
Quoted 107 lines
The return type & value of
pc_memory_init()andxen_load_linux()are not changed themselves; maybe we'll need their return values sometime later.RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
Cc Amit Shah <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Richard Henderson <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Aurelien Jarno <[email protected]>Cc Leon Alrae <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>--- include/hw/i386/pc.h | 3 +-- hw/acpi/piix4.c | 3 +-- hw/i386/pc_piix.c | 19 +++++++++---------- hw/mips/mips_malta.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-)include/hw/i386/pc.h +1
-2@@ -219,8 +219,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int kvm_enabled,FWCfgState *fw_cfg, -DeviceState **piix4_pm); +int kvm_enabled,DeviceState **piix4_pm);void piix4_smbus_register_device (SMBusDevice *dev,uint8_t addr);/* hpet.c */ hw/acpi/piix4.c +1
-2@@ -492,8 +492,7 @@ Object *piix4_pm_find(void)I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int kvm_enabled,FWCfgState *fw_cfg, -DeviceState **piix4_pm) +int kvm_enabled,DeviceState **piix4_pm) {DeviceState *dev;PIIX4PMState *s;hw/i386/pc_piix.c +9
-10@@ -99,7 +99,6 @@ static void pc_init1(MachineState *machine,MemoryRegion *pci_memory;MemoryRegion *rom_memory;DeviceState *icc_bridge; -FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info;ram_addr_t lowmem;@@ -180,16 +179,16 @@ static void pc_init1(MachineState *machine,/* allocate ram and load rom/bios */ if (!xen_enabled ()) { - fw_cfg =pc_memory_init (machine, system_memory, - below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory, guest_info); +pc_memory_init (machine, system_memory, + below_4g_mem_size, above_4g_mem_size, + rom_memory, &ram_memory, guest_info); }else if (machine->kernel_filename !=NULL ) {/* For xen HVM direct kernel boot, load linux here */ - fw_cfg =xen_load_linux (machine->kernel_filename, - machine->kernel_cmdline, - machine->initrd_filename, - below_4g_mem_size, - guest_info); +xen_load_linux (machine->kernel_filename, + machine->kernel_cmdline, + machine->initrd_filename, + below_4g_mem_size, + guest_info); } gsi_state =g_malloc0 (sizeof (*gsi_state));@@ -288,7 +287,7 @@ static void pc_init1(MachineState *machine,/* TODO: Populate SPD eeprom data. */ smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , gsi[9 ], *smi_irq, -kvm_enabled (), fw_cfg, &piix4_pm); +kvm_enabled (), &piix4_pm);smbus_eeprom_init (smbus,8 ,NULL ,0 ); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,hw/mips/mips_malta.c +1
-1@@ -1160,7 +1160,7 @@ void mips_malta_init(MachineState *machine)pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 );pci_create_simple (pci_bus, piix4_devfn +2 ,"piix4-usb-uhci" ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 , -isa_get_irq (NULL ,9 ),NULL ,0 ,NULL ,NULL ); +isa_get_irq (NULL ,9 ),NULL ,0 ,NULL );smbus_eeprom_init (smbus,8 , smbus_eeprom_buf, smbus_eeprom_size);g_free (smbus_eeprom_buf); pit =pit_init (isa_bus,0x40 ,0 ,NULL );
Quoted 1 line · Laszlo Ersek
S3 support in OVMF says hi.
Nice.
Amit
Quoted 11 lines · Laszlo Ersek
S3 support in OVMF says hi.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696
Cc: Amit Shah <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Cc: Leon Alrae <[email protected]>
Quoted 2 lines
Thanks
Laszlo
Since Paolo wants to merge this.
Series:
Quoted 18 lines
Laszlo Ersek (3):
hw/acpi:acpi_pm1_cnt_init(): take "disable_s3" and "disable_s4" hw/acpi: move "etc/system-states"fw_cfgfile from PIIX4 to core hw/acpi:piix4_pm_init(): takefw_cfgobject no moreinclude/hw/acpi/acpi.h | 3 ++- include/hw/i386/pc.h | 3 +-- hw/acpi/core.c | 15 ++++++++++++++- hw/acpi/ich9.c | 3 ++- hw/acpi/piix4.c | 13 ++----------- hw/i386/pc_piix.c | 19 +++++++++---------- hw/isa/vt82c686.c | 2 +- hw/mips/mips_malta.c | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-)Signature · 1 line
1.8.3.1