Introduce global piix flag to disable PCI hotplug
PATCH 1/1 Introduce global piix flag to disable PCI hotplug
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs.
--- hw/acpi/piix4.c | 8 ++++++-- hw/i386/acpi-build.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)
hw/acpi/piix4.c +6 -2
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;
@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); +if (s->use_acpi_pci_hotplug) +acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ),DEFINE_PROP_BOOL ("acpi-pci-hotplug-with-bridge-support" , PIIX4PMState, use_acpi_hotplug_bridge, true), +DEFINE_PROP_BOOL ("acpi-pci-hotplug" , PIIX4PMState, + use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +14 -6
@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_en;uint8_t s4_val;AcpiFadtData fadt;uint16_t cpu_hp_io_base;
@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->pcihp_bridge_en =object_property_get_bool (obj,"acpi-pci-hotplug-with-bridge-support" ,NULL ); + pm->pcihp_en = +object_property_get_bool (obj,"acpi-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)
@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) }static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus, -bool pcihp_bridge_en) +bool pcihp_bridge_en,bool pcihp_en) {Aml *dev, *notify_method =NULL , *method; -QObject *bsel; +QObject *bsel =NULL ;PCIBus *sec;int i; - bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); +if (pcihp_en) + bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));
@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,*/ PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); -build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); +build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en, + pcihp_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);
@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }/* Notify about child bus events in any case */ -if (pcihp_bridge_en) { +if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) {int32_t devfn = sec->parent_dev->devfn;
@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); +build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en, + pm->pcihp_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) {
Signature · 1 line
2.7.4
This is related to the discussion we had a few weeks ago:
https://www.mail-archive.com/[email protected]/msg705212.html
Igor, could you please comment if this will do. I have not tested it since I do not have a setup handy. Sending this out for a quick review.
thanks
ani
Quoted 120 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/piix4.c | 8 ++++++-- hw/i386/acpi-build.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +6
-2@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); +if (s->use_acpi_pci_hotplug) +acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ),DEFINE_PROP_BOOL ("acpi-pci-hotplug-with-bridge-support" , PIIX4PMState, use_acpi_hotplug_bridge, true), +DEFINE_PROP_BOOL ("acpi-pci-hotplug" , PIIX4PMState, + use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +14
-7@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_en;uint8_t s4_val;AcpiFadtData fadt;uint16_t cpu_hp_io_base;@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->pcihp_bridge_en =object_property_get_bool (obj,"acpi-pci-hotplug-with-bridge-support" ,NULL ); + pm->pcihp_en = +object_property_get_bool (obj,"acpi-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) }static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus, -bool pcihp_bridge_en) +bool pcihp_bridge_en,bool pcihp_en) {Aml *dev, *notify_method =NULL , *method; -QObject *bsel; +QObject *bsel =NULL ;PCIBus *sec;int i; - bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); +if (pcihp_en) + bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,*/ PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); -build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); +build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en, + pcihp_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }/* Notify about child bus events in any case */ -if (pcihp_bridge_en) { +if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) {int32_t devfn = sec->parent_dev->devfn;@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); +build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en, + pm->pcihp_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) { --2.7.4
Quoted 7 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>
Well we have a flag like this for pci bridges, right? So all that's left is an option to disable hotplug for the pci root, right?
Wouldn't that be better than disabling it globally?
Quoted 111 lines
--- hw/acpi/piix4.c | 8 ++++++-- hw/i386/acpi-build.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +6
-2@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); +if (s->use_acpi_pci_hotplug) +acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ),DEFINE_PROP_BOOL ("acpi-pci-hotplug-with-bridge-support" , PIIX4PMState, use_acpi_hotplug_bridge, true), +DEFINE_PROP_BOOL ("acpi-pci-hotplug" , PIIX4PMState, + use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +14
-6@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_en;uint8_t s4_val;AcpiFadtData fadt;uint16_t cpu_hp_io_base;@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->pcihp_bridge_en =object_property_get_bool (obj,"acpi-pci-hotplug-with-bridge-support" ,NULL ); + pm->pcihp_en = +object_property_get_bool (obj,"acpi-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) }static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus, -bool pcihp_bridge_en) +bool pcihp_bridge_en,bool pcihp_en) {Aml *dev, *notify_method =NULL , *method; -QObject *bsel; +QObject *bsel =NULL ;PCIBus *sec;int i; - bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); +if (pcihp_en) + bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,*/ PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); -build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); +build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en, + pcihp_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }/* Notify about child bus events in any case */ -if (pcihp_bridge_en) { +if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) {int32_t devfn = sec->parent_dev->devfn;@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); +build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en, + pm->pcihp_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) {Signature · 1 line
2.7.4
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right? So all that's left is an option to disable hotplug for the pci root, right?
Wouldn't that be better than disabling it globally?
The idea is to have just one option to disable all hotplug globally. But if you want to have two flags one for the bridges and one for the pci root, we can certainly look into it.
Quoted 127 lines
hw/acpi/piix4.c static void
Quoted 19 lines
--- hw/acpi/piix4.c | 8 ++++++-- hw/i386/acpi-build.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +1
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -595,8 +596,9 @@ static voidpiix4_acpi_system_hot_add_init(MemoryRegion *parent,
Quoted 12 lines
hw/acpi/piix4.c +3
-2"acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); +if (s->use_acpi_pci_hotplug) +acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",hw/acpi/piix4.c static Property piix4_pm_properties[] = { · line 638
Quoted 2 lines
hw/acpi/piix4.c +0
-0@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ), DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",PIIX4PMState,
hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine,
Quoted 19 lines
hw/acpi/piix4.c +2
-0use_acpi_hotplug_bridge, true), +DEFINE_PROP_BOOL ("acpi-pci-hotplug" , PIIX4PMState, + use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +1
-0@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_en;uint8_t s4_val;AcpiFadtData fadt;uint16_t cpu_hp_io_base;@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine,AcpiPmInfo *pm)
hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine, · line 247
Quoted 2 lines
hw/i386/acpi-build.c +0
-0pm->pcihp_bridge_en = object_property_get_bool(obj,"acpi-pci-hotplug-with-bridge-support",
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml
Quoted 8 lines
hw/i386/acpi-build.c +3
-0NULL); + pm->pcihp_en = +object_property_get_bool (obj,"acpi-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml*method, int slot)
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml *method, int slot)
Quoted 5 lines
hw/i386/acpi-build.c +1
-1}static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus, -bool pcihp_bridge_en) + bool pcihp_bridge_en, bool
pcihp_en)hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml *method, int slot)
Quoted 8 lines
hw/i386/acpi-build.c +1
-2{Aml *dev, *notify_method =NULL , *method; -QObject *bsel; +QObject *bsel =NULL ;PCIBus *sec;int i; - bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 7 lines
hw/i386/acpi-build.c +3
-0+if (pcihp_en) + bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
Quoted 8 lines
hw/i386/acpi-build.c +2
-1*/ PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); -build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); +build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en, + pcihp_en); }/* slot descriptor has been composed, add it into parent context */
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 2 lines
hw/i386/acpi-build.c +0
-0aml_append (parent_scope, dev);@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1827
Quoted 12 lines
hw/i386/acpi-build.c +1
-1}/* Notify about child bus events in any case */ -if (pcihp_bridge_en) { +if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) {int32_t devfn = sec->parent_dev->devfn;@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1821
Quoted 1 line
hw/i386/acpi-build.c +0
-1- build_append_pci_bus_devices(scope, bus,
pm->pcihp_bridge_en);hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1828
Quoted 1 line
hw/i386/acpi-build.c +1
-0+ build_append_pci_bus_devices(scope, bus,
pm->pcihp_bridge_en,Quoted 6 lines
hw/i386/acpi-build.c +1
-1+ pm->pcihp_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) { --2.7.4
Quoted 19 lines · Ani Sinha
On Mon, Aug 10, 2020 at 8:17 PM Michael S. Tsirkin <[email protected]> wrote:
On Mon, Aug 10, 2020 at 04:59:41PM +0530, Ani Sinha wrote:
> We introduce a new global flag for PIIX with which we can > turn on or off PCI device hotplug. This flag can be used > to prevent all PCI devices from getting hotplugged/unplugged > on the PCI bus. The new options disables all hotpluh HW > initialization code as well as the ACPI AMLs.
>
> Signed-off-by: Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right? So all that's left is an option to disable hotplug for the pci root, right?
Wouldn't that be better than disabling it globally?
Quoted 4 lines
The idea is to have just one option to disable all hotplug globally. But if you want to have two flags one for the bridges and one for the pci root, we can certainly look into it.
I can certainly see the attraction of a global flag.
However, with the interface we have for bridges right now, how are we going to resolve the conflict if hotplug is disabled globally but enabled for a given bridge?
A reasonable way would be to change the default value for bridges, have a user-specified value override it.
This patch doesn't do it, though.
Quoted 128 lines
hw/acpi/piix4.c static void piix4_acpi_system_hot_add_init
Quoted 20 lines
---
 hw/acpi/piix4.c   | 8 ++++++--
Âhw/i386/acpi-build.c| 20 ++++++++++++++------ Â 2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +0
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {Â
   AcpiPciHpStateacpi_pci_hotplug;
   booluse_acpi_hotplug_bridge;
+Â Â booluse_acpi_pci_hotplug;
Â
  Âuint8_tdisable_s3;
  Âuint8_tdisable_s4;hw/acpi/piix4.c +0
-0@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, >Â Â Â Â Â Â Â Â Â Â Â Â Â Â "acpi-gpe0", GPE_LEN); >Â Â Â memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); >Â > -Â Â acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, > -Â Â Â Â Â Â Â Â Â Â s->use_acpi_hotplug_bridge); > +Â Â if (s->use_acpi_pci_hotplug) > +Â Â Â Â acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, > +Â Â Â Â Â Â Â Â Â Â Â Â s->use_acpi_hotplug_bridge); >Â >Â Â Â s->cpu_hotplug_legacy = true; >Â Â Â object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy", > @@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = { >Â Â Â DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), >Â Â Â DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState, >Â Â Â Â Â Â Â Â Â Â Â Â use_acpi_hotplug_bridge, true), > +Â Â DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState, > +Â Â Â Â Â Â Â Â Â Â Â use_acpi_pci_hotplug, true), >Â Â Â DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState, >Â Â Â Â Â Â Â Â Â Â Â Â acpi_memory_hotplug.is_enabled, true), >Â Â Â DEFINE_PROP_END_OF_LIST(), > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index b7bcbbb..343b9b6 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -95,6 +95,7 @@ typedef struct AcpiPmInfo { >Â Â Â bool s3_disabled; >Â Â Â bool s4_disabled; >Â Â Â bool pcihp_bridge_en; > +Â Â bool pcihp_en; >Â Â Â uint8_t s4_val; >Â Â Â AcpiFadtData fadt; >Â Â Â uint16_t cpu_hp_io_base; > @@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) >Â Â Â pm->pcihp_bridge_en = >Â Â Â Â Â object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support", >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL); > +Â Â pm->pcihp_en = > +Â Â Â Â object_property_get_bool(obj, "acpi-pci-hotplug", NULL); > + >Â } >Â >Â static void acpi_get_misc_info(AcpiMiscInfo *info) > @@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) >Â } >Â >Â static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, > -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bool pcihp_bridge_en) > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bool pcihp_bridge_en, bool pcihp_en) >Â { >Â Â Â Aml *dev, *notify_method = NULL, *method; > -Â Â QObject *bsel; > +Â Â QObject *bsel = NULL; >Â Â Â PCIBus *sec; >Â Â Â int i; >Â > -Â Â bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL); > +Â Â if (pcihp_en) > +Â Â Â Â bsel = object_property_get_qobject(OBJECT(bus), > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ACPI_PCIHP_PROP_BSEL, NULL); >Â Â Â if (bsel) { >Â Â Â Â Â uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel)); >Â > @@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, >Â Â Â Â Â Â Â Â */ >Â Â Â Â Â Â Â PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); >Â > -Â Â Â Â Â Â build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en); > +Â Â Â Â Â Â build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en, > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pcihp_en); >Â Â Â Â Â } >Â Â Â Â Â /* slot descriptor has been composed, add it into parent context */ >Â Â Â Â Â aml_append(parent_scope, dev); > @@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, >Â Â Â } >Â >Â Â Â /* Notify about child bus events in any case */ > -Â Â if (pcihp_bridge_en) { > +Â Â if (pcihp_bridge_en && pcihp_en) { >Â Â Â Â Â QLIST_FOREACH(sec, &bus->child, sibling) { >Â Â Â Â Â Â Â int32_t devfn = sec->parent_dev->devfn; >Â > @@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, >Â Â Â Â Â if (bus) { >Â Â Â Â Â Â Â Aml *scope = aml_scope("PCI0"); >Â Â Â Â Â Â Â /* Scan all PCI buses. Generate tables to support hotplug. * / > -Â Â Â Â Â Â build_append_pci_bus_devices(scope, bus, pm-> pcihp_bridge_en); > +Â Â Â Â Â Â build_append_pci_bus_devices(scope, bus, pm-> pcihp_bridge_en, > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pm->pcihp_en); >Â >Â Â Â Â Â Â Â if (TPM_IS_TIS_ISA(tpm)) { >Â Â Â Â Â Â Â Â Â if (misc->tpm_version == TPM_VERSION_2_0) { > -- > 2.7.4
Ani
Quoted 27 lines · On Aug 10, 2020, 20:30 +0530, Michael S. Tsirkin <[email protected]>, wrote:
Quoted 19 lines · Ani Sinha
On Mon, Aug 10, 2020 at 8:17 PM Michael S. Tsirkin <[email protected]> wrote:
Quoted 7 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right? So all that's left is an option to disable hotplug for the pci root, right?
Wouldn't that be better than disabling it globally?Quoted 4 lines
The idea is to have just one option to disable all hotplug globally. But if you want to have two flags one for the bridges and one for the pci root, we can certainly look into it.
I can certainly see the attraction of a global flag.
Quoted 7 lines
However, with the interface we have for bridges right now, how are we going to resolve the conflict if hotplug is disabled globally but enabled for a given bridge?
A reasonable way would be to change the default value for bridges, have a user-specified value override it.
This patch doesn't do it, though.
I think the global option should override the bridge option. So if the global option disables hotplug, the bridge option should be a noop.
Quoted 133 lines
Quoted 132 lines
hw/acpi/piix4.c static void piix4_acpi_system_hot_add_init
Quoted 24 lines
---
hw/acpi/piix4.c | 8 ++++++--hw/i386/acpi-build.c| 20 ++++++++++++++------2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +1
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState { AcpiPciHpState acpi_pci_hotplug; bool use_acpi_hotplug_bridge; + bool use_acpi_pci_hotplug; uint8_t disable_s3; uint8_t disable_s4;@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
Quoted 12 lines
hw/acpi/piix4.c +3
-2"acpi-gpe0", GPE_LEN); memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); - acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); + if (s->use_acpi_pci_hotplug) + acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",hw/acpi/piix4.c static Property piix4_pm_properties[] = { · line 638
Quoted 2 lines
hw/acpi/piix4.c +0
-0@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = { DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",PIIX4PMState,
hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine,
Quoted 19 lines
hw/acpi/piix4.c +2
-0use_acpi_hotplug_bridge, true), + DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState, + use_acpi_pci_hotplug, true), DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +1
-0@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled; bool pcihp_bridge_en; + bool pcihp_en; uint8_t s4_val; AcpiFadtData fadt; uint16_t cpu_hp_io_base;@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine,AcpiPmInfo *pm)
Quoted 2 lines
pm->pcihp_bridge_en =
object_property_get_bool(obj,"acpi-pci-hotplug-with-bridge-support",
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml
Quoted 8 lines
NULL);
+ pm->pcihp_en =
+ object_property_get_bool(obj, "acpi-pci-hotplug", NULL); +
}static void
acpi_get_misc_info(AcpiMiscInfo *info)hw/i386/acpi-build.c +0
-0@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml*method, int slot)
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml *method, int slot)
Quoted 5 lines
hw/i386/acpi-build.c +1
-1} static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, - bool pcihp_bridge_en) + bool pcihp_bridge_en, bool
pcihp_en)hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml *method, int slot)
Quoted 8 lines
hw/i386/acpi-build.c +1
-2{ Aml *dev, *notify_method = NULL, *method; - QObject *bsel; + QObject *bsel = NULL; PCIBus *sec; int i; - bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 7 lines
hw/i386/acpi-build.c +3
-0+ if (pcihp_en) + bsel = object_property_get_qobject(OBJECT(bus), + ACPI_PCIHP_PROP_BSEL, NULL); if (bsel) { uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
Quoted 8 lines
hw/i386/acpi-build.c +2
-1*/ PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); - build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en); + build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en, + pcihp_en); } /* slot descriptor has been composed, add it into parent context*/
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 2 lines
hw/i386/acpi-build.c +0
-0aml_append(parent_scope, dev);@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1827
Quoted 12 lines
hw/i386/acpi-build.c +1
-1} /* Notify about child bus events in any case */ - if (pcihp_bridge_en) { + if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) { int32_t devfn = sec->parent_dev->devfn;@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, if (bus) { Aml *scope = aml_scope("PCI0"); /* Scan all PCI buses. Generate tables to support hotplug. */
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1821
Quoted 1 line
hw/i386/acpi-build.c +0
-1- build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en);hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1828
Quoted 1 line
hw/i386/acpi-build.c +1
-0+ build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en,Quoted 6 lines
hw/i386/acpi-build.c +1
-1+ pm->pcihp_en); if (TPM_IS_TIS_ISA(tpm)) { if (misc->tpm_version == TPM_VERSION_2_0) { --2.7.4
Quoted 71 lines · Ani Sinha
Ani
On Aug 10, 2020, 20:30 +0530, Michael S. Tsirkin <[email protected]>, wrote:On Mon, Aug 10, 2020 at 08:24:53PM +0530, Ani Sinha wrote:
On Mon, Aug 10, 2020 at 8:17 PM Michael S. Tsirkin <[email protected]> wrote:
On Mon, Aug 10, 2020 at 04:59:41PM +0530, Ani Sinha wrote:
We introduce a new global flag for PIIX with which we can
turn on or off PCI device hotplug. This flag can be used
to prevent all PCI devices from getting hotplugged/unplugged
on the PCI bus. The new options disables all hotpluh HW
initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right?
So all that's left is an option to disable hotplug
for the pci root, right?
Wouldn't that be better than disabling it globally?
The idea is to have just one option to disable all hotplug globally. But if you
want to have two flags one for the bridges and one for the pci root, we can
certainly look into it.
I can certainly see the attraction of a global flag.
However, with the interface we have for bridges right now, how are we
going to resolve the conflict if hotplug is disabled globally but
enabled for a given bridge?
A reasonable way would be to change the default value for bridges,
Quoted 8 lines
have a user-specified value override it.
This patch doesn't do it, though.
I think the global option should override the bridge option. So if the global option disables hotplug, the bridge option should be a noop.
Well just ignoring inconsistent user input does not sound great. Tends to create support problems.
Quoted 279 lines
---
hw/acpi/piix4.c | 8 ++++++--
hw/i386/acpi-build.c | 20 ++++++++++++++------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 26bac4f..8b13e86 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
AcpiPciHpState acpi_pci_hotplug;
bool use_acpi_hotplug_bridge;
+ bool use_acpi_pci_hotplug;
uint8_t disable_s3;
uint8_t disable_s4;
@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init
(MemoryRegion *parent,
"acpi-gpe0", GPE_LEN);
memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
- acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent,
- s->use_acpi_hotplug_bridge);
+ if (s->use_acpi_pci_hotplug)
+ acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus,
parent,
+ s->use_acpi_hotplug_bridge);
s->cpu_hotplug_legacy = true;
object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {
DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val,
2),
DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",
PIIX4PMState,
use_acpi_hotplug_bridge, true),
+ DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
+ use_acpi_pci_hotplug, true),
DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
acpi_memory_hotplug.is_enabled, true),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b7bcbbb..343b9b6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {
bool s3_disabled;
bool s4_disabled;
bool pcihp_bridge_en;
+ bool pcihp_en;
uint8_t s4_val;
AcpiFadtData fadt;
uint16_t cpu_hp_io_base;
@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState
*machine,
AcpiPmInfo *pm)
pm->pcihp_bridge_en =
object_property_get_bool(obj,
"acpi-pci-hotplug-with-bridge-support",
NULL);
+ pm->pcihp_en =
+ object_property_get_bool(obj, "acpi-pci-hotplug", NULL);
+
}
static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry
(Aml
*method, int slot)
}
static void build_append_pci_bus_devices(Aml *parent_scope,
PCIBus *bus,
- bool pcihp_bridge_en)
+ bool pcihp_bridge_en,
bool
pcihp_en)
{
Aml *dev, *notify_method = NULL, *method;
- QObject *bsel;
+ QObject *bsel = NULL;
PCIBus *sec;
int i;
- bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);
+ if (pcihp_en)
+ bsel = object_property_get_qobject(OBJECT(bus),
+ ACPI_PCIHP_PROP_BSEL,
NULL);
if (bsel) {
uint64_t bsel_val = qnum_get_uint(qobject_to(QNum,
bsel));
@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,
*/
PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE
(pdev));
- build_append_pci_bus_devices(dev, sec_bus,
pcihp_bridge_en);
+ build_append_pci_bus_devices(dev, sec_bus,
pcihp_bridge_en,
+ pcihp_en);
}
/* slot descriptor has been composed, add it into parent
context
*/
aml_append(parent_scope, dev);
@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,
}
/* Notify about child bus events in any case */
- if (pcihp_bridge_en) {
+ if (pcihp_bridge_en && pcihp_en) {
QLIST_FOREACH(sec, &bus->child, sibling) {
int32_t devfn = sec->parent_dev->devfn;
@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker
*linker,
if (bus) {
Aml *scope = aml_scope("PCI0");
/* Scan all PCI buses. Generate tables to support
hotplug. *
/
- build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en);
+ build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en,
+ pm->pcihp_en);
if (TPM_IS_TIS_ISA(tpm)) {
if (misc->tpm_version == TPM_VERSION_2_0) {
--
2.7.4Ani
Quoted 77 lines · On Aug 10, 2020, 20:49 +0530, Michael S. Tsirkin <[email protected]>, wrote:
Quoted 76 lines · Ani Sinha
Ani
On Aug 10, 2020, 20:30 +0530, Michael S. Tsirkin <[email protected]>, wrote:On Mon, Aug 10, 2020 at 08:24:53PM +0530, Ani Sinha wrote:
On Mon, Aug 10, 2020 at 8:17 PM Michael S. Tsirkin <[email protected]> wrote:
On Mon, Aug 10, 2020 at 04:59:41PM +0530, Ani Sinha wrote:
We introduce a new global flag for PIIX with which we can
turn on or off PCI device hotplug. This flag can be used
to prevent all PCI devices from getting hotplugged/unplugged
on the PCI bus. The new options disables all hotpluh HW
initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right?
So all that's left is an option to disable hotplug
for the pci root, right?
Wouldn't that be better than disabling it globally?
The idea is to have just one option to disable all hotplug globally. But if you
want to have two flags one for the bridges and one for the pci root, we can
certainly look into it.
I can certainly see the attraction of a global flag.
However, with the interface we have for bridges right now, how are we
going to resolve the conflict if hotplug is disabled globally but
enabled for a given bridge?
A reasonable way would be to change the default value for bridges,
have a user-specified value override it.
This patch doesn't do it, though.
Quoted 6 lines
Quoted 3 lines
I think the global option should override the bridge option. So if the global option disables hotplug, the bridge option should be a noop.
Well just ignoring inconsistent user input does not sound great. Tends to create support problems.
Then I suggest we take your original idea - have the new option just disable hotplug on the pci root bus.
This would be cleaner and would introduce less confusion. Also the patch should be simple.
Quoted 281 lines
Quoted 280 lines
---
hw/acpi/piix4.c| 8 ++++++--
hw/i386/acpi-build.c| 20 ++++++++++++++------2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +0
-0index 26bac4f..8b13e86 100644
---
a/hw/acpi/piix4.c+++
b/hw/acpi/piix4.chw/acpi/piix4.c +1
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_pci_hotplug;
uint8_tdisable_s3;
uint8_tdisable_s4;hw/acpi/piix4.c +2
-2@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,"acpi-gpe0" ,GPE_LEN );memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); +if (s->use_acpi_pci_hotplug) + acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus,parent,
+
s->use_acpi_hotplug_bridge);
s->cpu_hotplug_legacy= true;object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/acpi/piix4.c +0
-0@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ), DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",PIIX4PMState,
use_acpi_hotplug_bridge, true),+ DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
+
use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
acpi_memory_hotplug.is_enabled, true),
DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +0
-0index b7bcbbb..343b9b6 100644
---
a/hw/i386/acpi-build.c+++
b/hw/i386/acpi-build.chw/i386/acpi-build.c +1
-0@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_en;
uint8_ts4_val;AcpiFadtData fadt;
uint16_tcpu_hp_io_base;hw/i386/acpi-build.c +0
-0@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
pm->pcihp_bridge_en=object_property_get_bool(obj,
"acpi-pci-hotplug-with-bridge-support",
NULL);
+
pm->pcihp_en=+
object_property_get_bool(obj, "acpi-pci-hotplug", NULL);+
}
static void
acpi_get_misc_info(AcpiMiscInfo *info)hw/i386/acpi-build.c +0
-0@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml
*method, int slot)
}
static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,- bool
pcihp_bridge_en)+ bool
pcihp_bridge_en,
bool
pcihp_en){
Aml *dev,
*notify_method= NULL, *method;- QObject *bsel;
+ QObject *bsel = NULL;
PCIBus *sec;
int i;
- bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);+ if (
pcihp_en)+ bsel = object_property_get_qobject(OBJECT(bus),
+
ACPI_PCIHP_PROP_BSEL,
NULL);if (bsel) {
uint64_tbsel_val=qnum_get_uint(qobject_to(QNum, bsel));hw/i386/acpi-build.c +0
-0@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml*parent_scope, PCIBus *bus, */ PCIBus
*sec_bus=pci_bridge_get_sec_bus(PCI_BRIDGE (pdev));- build_append_pci_bus_devices(dev,
sec_bus,pcihp_bridge_en);+ build_append_pci_bus_devices(dev,
sec_bus,pcihp_bridge_en,+
pcihp_en);}
/* slot descriptor has been composed, add it into parent context
*/
aml_append(parent_scope, dev);hw/i386/acpi-build.c +0
-0@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }/* Notify about child bus events in any case */
- if (
pcihp_bridge_en) {+ if (
pcihp_bridge_en&&pcihp_en) {
QLIST_FOREACH(sec, &bus->child, sibling){
int32_tdevfn =sec->parent_dev->devfn;hw/i386/acpi-build.c +0
-0@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. *
/
- build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en);+ build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en,+
pm->pcihp_en);if (
TPM_IS_TIS_ISA(tpm)) {if (
misc->tpm_version==TPM_VERSION_2_0) {--
2.7.4
Quoted 117 lines · Ani Sinha
Ani
On Aug 10, 2020, 20:49 +0530, Michael S. Tsirkin <[email protected]>, wrote:On Mon, Aug 10, 2020 at 08:35:56PM +0530, Ani Sinha wrote:
Ani
On Aug 10, 2020, 20:30 +0530, Michael S. Tsirkin <[email protected]>, wrote:
On Mon, Aug 10, 2020 at 08:24:53PM +0530, Ani Sinha wrote:
On Mon, Aug 10, 2020 at 8:17 PM Michael S. Tsirkin <[email protected]>
wrote:
On Mon, Aug 10, 2020 at 04:59:41PM +0530, Ani Sinha wrote:
We introduce a new global flag for PIIX with which we can
turn on or off PCI device hotplug. This flag can be used
to prevent all PCI devices from getting hotplugged/unplugged
on the PCI bus. The new options disables all hotpluh HW
initialization code as well as the ACPI AMLs.
Signed-off-by Ani Sinha <[email protected]>Well we have a flag like this for pci bridges, right?
So all that's left is an option to disable hotplug
for the pci root, right?
Wouldn't that be better than disabling it globally?
The idea is to have just one option to disable all hotplug globally.
But if you
want to have two flags one for the bridges and one for the pci root, we
can
certainly look into it.
I can certainly see the attraction of a global flag.
However, with the interface we have for bridges right now, how are we
going to resolve the conflict if hotplug is disabled globally but
enabled for a given bridge?
A reasonable way would be to change the default value for bridges,
have a user-specified value override it.
This patch doesn't do it, though.
I think the global option should override the bridge option. So if the global
option disables hotplug, the bridge option should be a noop.
Quoted 8 lines
Well just ignoring inconsistent user input does not sound great.
Tends to create support problems.
Then I suggest we take your original idea - have the new option just disable hotplug on the pci root bus.
This would be cleaner and would introduce less confusion. Also the patch should be simple.
I have sent a patch to this effect.
Quoted 407 lines
---
hw/acpi/piix4.c| 8 ++++++--
hw/i386/acpi-build.c| 20 ++++++++++++++------2 files changed, 20 insertions(+), 8 deletions(-)hw/acpi/piix4.c +0
-0index 26bac4f..8b13e86 100644
---
a/hw/acpi/piix4.c+++
b/hw/acpi/piix4.chw/acpi/piix4.c +0
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool
use_acpi_hotplug_bridge;+ bool
use_acpi_pci_hotplug;
uint8_tdisable_s3;
uint8_tdisable_s4;hw/acpi/piix4.c +0
-0@@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,"acpi-gpe0" ,GPE_LEN );
memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);- acpi_pcihp_init(OBJECT(s),
&s->acpi_pci_hotplug, bus, parent,-
s->use_acpi_hotplug_bridge);+ if (
s->use_acpi_pci_hotplug)+ acpi_pcihp_init(OBJECT(s),
&s->acpi_pci_hotplug, bus,parent,
+
s->use_acpi_hotplug_bridge);
s->cpu_hotplug_legacy= true;object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/acpi/piix4.c +0
-0@@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val, 2),DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",
PIIX4PMState,
use_acpi_hotplug_bridge, true),+ DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
+
use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
acpi_memory_hotplug.is_enabled, true),
DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +0
-0index b7bcbbb..343b9b6 100644
---
a/hw/i386/acpi-build.c+++
b/hw/i386/acpi-build.chw/i386/acpi-build.c +0
-0@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool
pcihp_bridge_en;+ bool
pcihp_en;
uint8_ts4_val;AcpiFadtData fadt;
uint16_tcpu_hp_io_base;hw/i386/acpi-build.c +0
-0@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
pm->pcihp_bridge_en=object_property_get_bool(obj,
"acpi-pci-hotplug-with-bridge-support",
NULL);
+
pm->pcihp_en=+
object_property_get_bool(obj, "acpi-pci-hotplug", NULL);+
}
static void
acpi_get_misc_info(AcpiMiscInfo *info)hw/i386/acpi-build.c +0
-0@@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml
*method, int slot)
}
static void build_append_pci_bus_devices(Aml
*parent_scope,PCIBus *bus,
- bool
pcihp_bridge_en)+ bool
pcihp_bridge_en,bool
pcihp_en){
Aml *dev,
*notify_method= NULL, *method;- QObject *bsel;
+ QObject *bsel = NULL;
PCIBus *sec;
int i;
- bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);+ if (
pcihp_en)+ bsel = object_property_get_qobject(OBJECT(bus),
+
ACPI_PCIHP_PROP_BSEL,NULL);
if (bsel) {
uint64_tbsel_val= qnum_get_uint(qobject_to(QNum,bsel));
hw/i386/acpi-build.c +0
-0@@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml*parent_scope, PCIBus *bus, */ PCIBus
*sec_bus= pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
- build_append_pci_bus_devices(dev,
sec_bus,
pcihp_bridge_en);+ build_append_pci_bus_devices(dev,
sec_bus,
pcihp_bridge_en,+
pcihp_en);}
/* slot descriptor has been composed, add it into parent
context
*/
aml_append(parent_scope, dev);hw/i386/acpi-build.c +0
-0@@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }/* Notify about child bus events in any case */
- if (
pcihp_bridge_en) {+ if (
pcihp_bridge_en&&pcihp_en) {
QLIST_FOREACH(sec, &bus->child, sibling){
int32_tdevfn =sec->parent_dev->devfn;hw/i386/acpi-build.c +0
-0@@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, if (bus) {Aml *scope =
aml_scope("PCI0");/* Scan all PCI buses. Generate tables to support
hotplug. *
/
- build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en);+ build_append_pci_bus_devices(scope, bus, pm->
pcihp_bridge_en,+
pm->pcihp_en);if (
TPM_IS_TIS_ISA(tpm)) {if (
misc->tpm_version==TPM_VERSION_2_0) {--
2.7.4