Introduce a new flag for piix to disable root bus PCI hotplug
PATCH v2 1/1 Introduce a new flag for piix to disable root bus PCI hotplug
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug on the root bus. This flag can be used to prevent all PCI devices from getting hotplugged or unplugged from the root PCI bus.
--- hw/acpi/piix4.c | 3 +++ hw/i386/acpi-build.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
hw/acpi/piix4.c +3 -0
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_root_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;
@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_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 +16 -4
@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)
@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {
@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));
@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));
@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);
@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) {
Signature · 1 line
2.7.4
Igor etc, I just tested this patch using a Windows 2012 R2 image and it seems to be working. Any feedbacks on this patch?
Quoted 113 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug on the root bus. This flag can be used to prevent all PCI devices from getting hotplugged or unplugged from the root PCI bus.
Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/piix4.c | 3 +++ hw/i386/acpi-build.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)hw/acpi/piix4.c +3
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_root_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_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 +16
-5@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) { --2.7.4
Hi,
Quoted 25 lines · Ani Sinha
Igor etc, I just tested this patch using a Windows 2012 R2 image and it seems to be working. Any feedbacks on this patch?
Quoted 21 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug on the root bus. This flag can be used to prevent all PCI devices from getting hotplugged or unplugged from the root PCI bus.
Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/piix4.c | 3 +++ hw/i386/acpi-build.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 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_root_pci_hotplug;
Quoted 8 lines
hw/acpi/piix4.c static Property piix4_pm_properties[] = { · line 640
Quoted 8 lines
hw/acpi/piix4.c +2
-0uint8_t disable_s3;uint8_t disable_s4;@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_pci_hotplug, true),
From what I understood here, this file is already pretty twisted and Igor doesn't want more workarounds:
https://www.mail-archive.com/[email protected]/msg690564.html
¯\_(ツ)_/¯
Quoted 85 lines
Quoted 84 lines
hw/acpi/piix4.c +0
-0DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(),hw/i386/acpi-build.c +16
-5@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) { --2.7.4
This is not a workaround, this is a feature we need badly. We have discussed this at length. Igor suggested we have one additional global flag to disable all pci hotplug. But then that leads to strange case when pci hotplug on the bridges are enabled (we have a separate flag for that). Hence, I think we can simply add another flag to disable hotplug just for the pci root bus.
Quoted 274 lines · Philippe Mathieu-Daudé
Hi,
Quoted 11 lines · Ani Sinha
Igor etc, I just tested this patch using a Windows 2012 R2 image and
it seems to be working. Any feedbacks on this patch?
Quoted 3 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or
off PCI
Quoted 40 lines
Quoted 39 lines
device hotplug on the root bus. This flag can be used to prevent all PCI
devices from getting hotplugged or unplugged from the root PCI bus.
Signed-off-by Ani Sinha <[email protected]>---
hw/acpi/piix4.c | 3 +++hw/i386/acpi-build.c | 20 ++++++++++++++++----2 files changed, 19 insertions(+), 4 deletions(-)hw/acpi/piix4.c +0
-0index 26bac4f..94ec35a 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_root_pci_hotplug;uint8_t disable_s3;Quoted 7 lines
hw/acpi/piix4.c static Property piix4_pm_properties[] = { · line 639
Quoted 7 lines
uint8_t disable_s4;hw/acpi/piix4.c +0
-0@@ -635,6 +636,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,
Quoted 5 lines
hw/acpi/piix4.c static Property piix4_pm_properties[] = { · line 640
Quoted 5 lines
hw/acpi/piix4.c +2
-0use_acpi_hotplug_bridge, true), + DEFINE_PROP_BOOL("acpi-root-pci-hotplug", PIIX4PMState, + use_acpi_root_pci_hotplug, true),From what I understood here, this file is already pretty twisted
and Igor doesn't want more workarounds:
https://www.mail-archive.com/[email protected]/msg690564.html
¯\_(ツ)_/¯
Quoted 24 lines
Quoted 23 lines
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..a82e5c1 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_root_en;Quoted 7 lines
hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine,
Quoted 7 lines
uint8_t s4_val; AcpiFadtData fadt; uint16_t cpu_hp_io_base;hw/i386/acpi-build.c +0
-0@@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine,AcpiPmInfo *pm)
Quoted 3 lines
hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
Quoted 3 lines
hw/i386/acpi-build.c +0
-0pm->pcihp_bridge_en = object_property_get_bool(obj,"acpi-pci-hotplug-with-bridge-support",
Quoted 8 lines
Quoted 7 lines
hw/i386/acpi-build.c +3
-0NULL); + pm->pcihp_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); +Quoted 7 lines
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml
Quoted 7 lines
}
static void
acpi_get_misc_info(AcpiMiscInfo *info)hw/i386/acpi-build.c +0
-0@@ -337,12 +341,15 @@ static void build_append_pcihp_notify_entry(Aml*method, int slot)
Quoted 5 lines
hw/i386/acpi-build.c static void build_append_pcihp_notify_entry(Aml · line 345
Quoted 5 lines
hw/i386/acpi-build.c +0
-0} static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus*bus,
Quoted 16 lines
Quoted 15 lines
hw/i386/acpi-build.c +2
-1- bool pcihp_bridge_en) + bool pcihp_bridge_en, + bool pcihp_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i;Quoted 7 lines
hw/i386/acpi-build.c
Quoted 7 lines
hw/i386/acpi-build.c +2
-0+bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);Quoted 3 lines
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 3 lines
if (bsel) {hw/i386/acpi-build.c +0
-0@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,Quoted 12 lines
Quoted 11 lines
hw/i386/acpi-build.c +3
-0bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;Quoted 7 lines
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 7 lines
if (bsel) { /* add hotplug slots for non present devices */ dev = aml_device("S%.02X", PCI_DEVFN(slot, 0)); aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));hw/i386/acpi-build.c +0
-0@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,Quoted 10 lines
Quoted 9 lines
hw/i386/acpi-build.c +1
-1method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {Quoted 7 lines
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 7 lines
/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));hw/i386/acpi-build.c +0
-0@@ -439,7 +449,8 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,Quoted 7 lines
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml · line 445
Quoted 7 lines
hw/i386/acpi-build.c +0
-1*/ PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); - build_append_pci_bus_devices(dev, sec_bus,
pcihp_bridge_en);Quoted 7 lines
hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml
Quoted 7 lines
hw/i386/acpi-build.c +2
-0+build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en, + pcihp_root_en); }/* slot descriptor has been composed, add it into parent context */
Quoted 9 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1834
Quoted 9 lines
aml_append(parent_scope, dev);hw/i386/acpi-build.c +0
-0@@ -1818,7 +1829,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (bus) {Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */
Quoted 1 line
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1824
Quoted 1 line
hw/i386/acpi-build.c +0
-1- build_append_pci_bus_devices(scope, bus,
pm->pcihp_bridge_en);Quoted 1 line
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1835
Quoted 1 line
hw/i386/acpi-build.c +1
-0+ build_append_pci_bus_devices(scope, bus,
pm->pcihp_bridge_en,Quoted 15 lines
Quoted 13 lines
hw/i386/acpi-build.c +1
-0+ pm->pcihp_root_en);if (TPM_IS_TIS_ISA(tpm)) { if (misc->tpm_version == TPM_VERSION_2_0) {--
2.7.4
Quoted 6 lines · Ani Sinha
This is not a workaround, this is a feature we need badly. We have discussed this at length. Igor suggested we have one additional global flag to disable all pci hotplug. But then that leads to strange case when pci hotplug on the bridges are enabled (we have a separate flag for that). Hence, I think we can simply add another flag to disable hotplug just for the pci root bus.
Relevant thread: https://www.mail-archive.com/[email protected]/msg729072.html
Quoted 259 lines
Quoted 259 lines · Philippe Mathieu-Daudé
Hi,
Quoted 65 lines · Ani Sinha
Igor etc, I just tested this patch using a Windows 2012 R2 image and
it seems to be working. Any feedbacks on this patch?
Quoted 57 lines · Ani Sinha
We introduce a new global flag for PIIX with which we can turn on or off PCI
device hotplug on the root bus. This flag can be used to prevent all PCI
devices from getting hotplugged or unplugged from the root PCI bus.
Signed-off-by Ani Sinha <[email protected]>---
hw/acpi/piix4.c | 3 +++hw/i386/acpi-build.c | 20 ++++++++++++++++----2 files changed, 19 insertions(+), 4 deletions(-)hw/acpi/piix4.c +0
-0index 26bac4f..94ec35a 100644
---
a/hw/acpi/piix4.c+++
b/hw/acpi/piix4.chw/acpi/piix4.c +3
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_root_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_pci_hotplug, true),From what I understood here, this file is already pretty twisted
and Igor doesn't want more workarounds:
https://www.mail-archive.com/[email protected]/msg690564.html
¯\_(ツ)_/¯
Quoted 169 lines
Quoted 167 lines
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..a82e5c1 100644
---
a/hw/i386/acpi-build.c+++
b/hw/i386/acpi-build.chw/i386/acpi-build.c +16
-5@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) { --2.7.4
Quoted 3 lines · On Tue, 11 Aug 2020 18:42:08 +0530 Ani Sinha <[email protected]> wrote:
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug on the root bus. This flag can be used to prevent all PCI devices from getting hotplugged or unplugged from the root PCI bus.
somewhere in intial versions there were mentionig why we are doing it (i.e for Windows sake because ...)
I suggest to add it to commit message so reason for this won't be lost. Also giving example how to use option in commit message would be good.
with this changes:
Quoted 106 lines
Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/piix4.c | 3 +++ hw/i386/acpi-build.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)hw/acpi/piix4.c +3
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_root_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_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 +16
-4@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) {
Quoted 10 lines · Igor Mammedov
Quoted 3 lines · On Tue, 11 Aug 2020 18:42:08 +0530 Ani Sinha <[email protected]> wrote:
We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug on the root bus. This flag can be used to prevent all PCI devices from getting hotplugged or unplugged from the root PCI bus.
Tested-by Igor Mammedov <[email protected]>
Quoted 7 lines
somewhere in intial versions there were mentionig why we are doing it (i.e for Windows sake because ...)
I suggest to add it to commit message so reason for this won't be lost. Also giving example how to use option in commit message would be good.with this changes:
Reviewed-by Igor Mammedov <[email protected]>
Thanks Igor, I have sent a V4 with your suggestions to the commit message and some more
rework on the patch. The V4 has again been tested by me in the same setup. Looks good so far.
Quoted 110 lines
Quoted 109 lines
Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/piix4.c | 3 +++ hw/i386/acpi-build.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)hw/acpi/piix4.c +3
-0@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {AcpiPciHpState acpi_pci_hotplug;bool use_acpi_hotplug_bridge; +bool use_acpi_root_pci_hotplug;uint8_t disable_s3;uint8_t disable_s4;@@ -635,6 +636,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-root-pci-hotplug" , PIIX4PMState, + use_acpi_root_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 +16
-4@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {bool s3_disabled;bool s4_disabled;bool pcihp_bridge_en; +bool pcihp_root_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_root_en = +object_property_get_bool (obj,"acpi-root-pci-hotplug" ,NULL ); + }static void acpi_get_misc_info (AcpiMiscInfo *info)@@ -337,12 +341,15 @@ 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_root_en) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;PCIBus *sec;int i; +bool root_bus =pci_bus_is_root (bus); +bool root_pcihp_disabled = (root_bus && !pcihp_root_en); bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {@@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,bool bridge_in_acpi;if (!pdev) { +/* skip if pci hotplug for the root bus is disabled */ +if (root_pcihp_disabled) +continue ;if (bsel) {/* add hotplug slots for non present devices */ dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { + }else if (hotplug_enabled_dev && !root_pcihp_disabled) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));@@ -439,7 +449,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_root_en); }/* slot descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);@@ -1818,7 +1829,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_root_en);if (TPM_IS_TIS_ISA (tpm)) {if (misc->tpm_version ==TPM_VERSION_2_0 ) {