All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off
@ 2020-09-11 18:07 Ani Sinha
  2020-09-11 18:07 ` [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha
                   ` (8 more replies)
  0 siblings, 9 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

A new binary acpi table tests/data/acpi/pc/DSDT.roothp is added in order to unit test
the feature flag that can disable/enable root pci bus hotplug on i440fx. This feature was
added with the commit:
3d7e78aa7777f0 ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")

This change documents the fact that this new file addition was made as a part of the
unit test change.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index dfb8523c8b..ac864fc982 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT.roothp",
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 11:57   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off Ani Sinha
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	Paolo Bonzini, Ani Sinha, Igor Mammedov

Ability to turn hotplug off on the pci root bus for i440fx was added in commit:
3d7e78aa7777f0 ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")

This change adds a unit test in order to test this feature.

This change has been tested against upstream qemu master branch on top of tag v5.1.0.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/qtest/bios-tables-test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 504b810af5..d8c7d57557 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -740,6 +740,20 @@ static void test_acpi_piix4_tcg_bridge(void)
     free_test_data(&data);
 }
 
+static void test_acpi_piix4_root_hotplug(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_PC;
+    data.variant = ".roothp";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+    test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
+                  "-device pci-bridge,chassis_nr=1", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg(void)
 {
     test_data data;
@@ -1144,6 +1158,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tcg_tpm_tis);
         qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
         qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
+        qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
         qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
  2020-09-11 18:07 ` [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 11:58   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Ani Sinha
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

A new binary ACPI table tests/data/acpi/pc/DSDT.roothp is added in order
to unit test hotplug on/off capability on the root pci bus for i440fx.
The diff between the table DSDT.bridge and DSDT.roothp is listed below:

@@ -1,30 +1,30 @@
 /*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20180105 (64-bit version)
  * Copyright (c) 2000 - 2018 Intel Corporation
  *
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of tests/data/acpi/pc/DSDT.bridge, Fri Sep 11 22:51:04 2020
+ * Disassembly of /tmp/aml-UGIHQ0, Fri Sep 11 22:51:04 2020
  *
  * Original Table Header:
  *     Signature        "DSDT"
- *     Length           0x00001A89 (6793)
+ *     Length           0x0000140A (5130)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0x09
+ *     Checksum         0xE6
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -831,61 +831,60 @@
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
                 IO (Decode16,
                     0x0510,             // Range Minimum
                     0x0510,             // Range Maximum
                     0x01,               // Alignment
                     0x0C,               // Length
                     )
             })
         }
     }

     Scope (\_SB)
     {
         Scope (PCI0)
         {
-            Name (BSEL, Zero)
             Device (S00)
             {
                 Name (_ADR, Zero)  // _ADR: Address
             }

             Device (S10)
             {
                 Name (_ADR, 0x00020000)  // _ADR: Address
                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }

             Device (S18)
             {
                 Name (_ADR, 0x00030000)  // _ADR: Address
-                Name (BSEL, One)
+                Name (BSEL, Zero)
                 Device (S00)
                 {
                     Name (_SUN, Zero)  // _SUN: Slot User Number
                     Name (_ADR, Zero)  // _ADR: Address
                     Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                     {
                         PCEJ (BSEL, _SUN)
                     }
                 }

                 Device (S08)
                 {
                     Name (_SUN, One)  // _SUN: Slot User Number
                     Name (_ADR, 0x00010000)  // _ADR: Address
                     Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                     {
@@ -1345,456 +1344,30 @@
                         Notify (SE8, Arg1)
                     }

                     If ((Arg0 & 0x40000000))
                     {
                         Notify (SF0, Arg1)
                     }

                     If ((Arg0 & 0x80000000))
                     {
                         Notify (SF8, Arg1)
                     }
                 }

                 Method (PCNT, 0, NotSerialized)
                 {
-                    BNUM = One
+                    BNUM = Zero
                     DVNT (PCIU, One)
                     DVNT (PCID, 0x03)
                 }
             }

-            Device (S20)
-            {
-                Name (_SUN, 0x04)  // _SUN: Slot User Number
-                Name (_ADR, 0x00040000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S28)
-            {
-                Name (_SUN, 0x05)  // _SUN: Slot User Number
-                Name (_ADR, 0x00050000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S30)
-            {
-                Name (_SUN, 0x06)  // _SUN: Slot User Number
-                Name (_ADR, 0x00060000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S38)
-            {
-                Name (_SUN, 0x07)  // _SUN: Slot User Number
-                Name (_ADR, 0x00070000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S40)
-            {
-                Name (_SUN, 0x08)  // _SUN: Slot User Number
-                Name (_ADR, 0x00080000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S48)
-            {
-                Name (_SUN, 0x09)  // _SUN: Slot User Number
-                Name (_ADR, 0x00090000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S50)
-            {
-                Name (_SUN, 0x0A)  // _SUN: Slot User Number
-                Name (_ADR, 0x000A0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S58)
-            {
-                Name (_SUN, 0x0B)  // _SUN: Slot User Number
-                Name (_ADR, 0x000B0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S60)
-            {
-                Name (_SUN, 0x0C)  // _SUN: Slot User Number
-                Name (_ADR, 0x000C0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S68)
-            {
-                Name (_SUN, 0x0D)  // _SUN: Slot User Number
-                Name (_ADR, 0x000D0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S70)
-            {
-                Name (_SUN, 0x0E)  // _SUN: Slot User Number
-                Name (_ADR, 0x000E0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S78)
-            {
-                Name (_SUN, 0x0F)  // _SUN: Slot User Number
-                Name (_ADR, 0x000F0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S80)
-            {
-                Name (_SUN, 0x10)  // _SUN: Slot User Number
-                Name (_ADR, 0x00100000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S88)
-            {
-                Name (_SUN, 0x11)  // _SUN: Slot User Number
-                Name (_ADR, 0x00110000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S90)
-            {
-                Name (_SUN, 0x12)  // _SUN: Slot User Number
-                Name (_ADR, 0x00120000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (S98)
-            {
-                Name (_SUN, 0x13)  // _SUN: Slot User Number
-                Name (_ADR, 0x00130000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SA0)
-            {
-                Name (_SUN, 0x14)  // _SUN: Slot User Number
-                Name (_ADR, 0x00140000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SA8)
-            {
-                Name (_SUN, 0x15)  // _SUN: Slot User Number
-                Name (_ADR, 0x00150000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SB0)
-            {
-                Name (_SUN, 0x16)  // _SUN: Slot User Number
-                Name (_ADR, 0x00160000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SB8)
-            {
-                Name (_SUN, 0x17)  // _SUN: Slot User Number
-                Name (_ADR, 0x00170000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SC0)
-            {
-                Name (_SUN, 0x18)  // _SUN: Slot User Number
-                Name (_ADR, 0x00180000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SC8)
-            {
-                Name (_SUN, 0x19)  // _SUN: Slot User Number
-                Name (_ADR, 0x00190000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SD0)
-            {
-                Name (_SUN, 0x1A)  // _SUN: Slot User Number
-                Name (_ADR, 0x001A0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SD8)
-            {
-                Name (_SUN, 0x1B)  // _SUN: Slot User Number
-                Name (_ADR, 0x001B0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SE0)
-            {
-                Name (_SUN, 0x1C)  // _SUN: Slot User Number
-                Name (_ADR, 0x001C0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SE8)
-            {
-                Name (_SUN, 0x1D)  // _SUN: Slot User Number
-                Name (_ADR, 0x001D0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SF0)
-            {
-                Name (_SUN, 0x1E)  // _SUN: Slot User Number
-                Name (_ADR, 0x001E0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Device (SF8)
-            {
-                Name (_SUN, 0x1F)  // _SUN: Slot User Number
-                Name (_ADR, 0x001F0000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
-            }
-
-            Method (DVNT, 2, NotSerialized)
-            {
-                If ((Arg0 & 0x10))
-                {
-                    Notify (S20, Arg1)
-                }
-
-                If ((Arg0 & 0x20))
-                {
-                    Notify (S28, Arg1)
-                }
-
-                If ((Arg0 & 0x40))
-                {
-                    Notify (S30, Arg1)
-                }
-
-                If ((Arg0 & 0x80))
-                {
-                    Notify (S38, Arg1)
-                }
-
-                If ((Arg0 & 0x0100))
-                {
-                    Notify (S40, Arg1)
-                }
-
-                If ((Arg0 & 0x0200))
-                {
-                    Notify (S48, Arg1)
-                }
-
-                If ((Arg0 & 0x0400))
-                {
-                    Notify (S50, Arg1)
-                }
-
-                If ((Arg0 & 0x0800))
-                {
-                    Notify (S58, Arg1)
-                }
-
-                If ((Arg0 & 0x1000))
-                {
-                    Notify (S60, Arg1)
-                }
-
-                If ((Arg0 & 0x2000))
-                {
-                    Notify (S68, Arg1)
-                }
-
-                If ((Arg0 & 0x4000))
-                {
-                    Notify (S70, Arg1)
-                }
-
-                If ((Arg0 & 0x8000))
-                {
-                    Notify (S78, Arg1)
-                }
-
-                If ((Arg0 & 0x00010000))
-                {
-                    Notify (S80, Arg1)
-                }
-
-                If ((Arg0 & 0x00020000))
-                {
-                    Notify (S88, Arg1)
-                }
-
-                If ((Arg0 & 0x00040000))
-                {
-                    Notify (S90, Arg1)
-                }
-
-                If ((Arg0 & 0x00080000))
-                {
-                    Notify (S98, Arg1)
-                }
-
-                If ((Arg0 & 0x00100000))
-                {
-                    Notify (SA0, Arg1)
-                }
-
-                If ((Arg0 & 0x00200000))
-                {
-                    Notify (SA8, Arg1)
-                }
-
-                If ((Arg0 & 0x00400000))
-                {
-                    Notify (SB0, Arg1)
-                }
-
-                If ((Arg0 & 0x00800000))
-                {
-                    Notify (SB8, Arg1)
-                }
-
-                If ((Arg0 & 0x01000000))
-                {
-                    Notify (SC0, Arg1)
-                }
-
-                If ((Arg0 & 0x02000000))
-                {
-                    Notify (SC8, Arg1)
-                }
-
-                If ((Arg0 & 0x04000000))
-                {
-                    Notify (SD0, Arg1)
-                }
-
-                If ((Arg0 & 0x08000000))
-                {
-                    Notify (SD8, Arg1)
-                }
-
-                If ((Arg0 & 0x10000000))
-                {
-                    Notify (SE0, Arg1)
-                }
-
-                If ((Arg0 & 0x20000000))
-                {
-                    Notify (SE8, Arg1)
-                }
-
-                If ((Arg0 & 0x40000000))
-                {
-                    Notify (SF0, Arg1)
-                }
-
-                If ((Arg0 & 0x80000000))
-                {
-                    Notify (SF8, Arg1)
-                }
-            }
-
             Method (PCNT, 0, NotSerialized)
             {
-                BNUM = Zero
-                DVNT (PCIU, One)
-                DVNT (PCID, 0x03)
                 ^S18.PCNT ()
             }
         }
     }
 }

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/data/acpi/pc/DSDT.roothp              | Bin 0 -> 5130 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 2 files changed, 1 deletion(-)
 create mode 100644 tests/data/acpi/pc/DSDT.roothp

diff --git a/tests/data/acpi/pc/DSDT.roothp b/tests/data/acpi/pc/DSDT.roothp
new file mode 100644
index 0000000000000000000000000000000000000000..886a5e6952f6f034bdd80d44d43de5975a1a4b0f
GIT binary patch
literal 5130
zcmb7IQEwZ^5uPQF@^O!pj?&q3tT-lQyJ?cbCMj8Q&=-++6iG{@&OFL(aYFAXDJT^L
z$iaz=C`wS80Tjn?f$E|UeP9eeTR)-w3Hb@>OMgI$#(D}nbH}A<iU%YFc-ooy?wgt2
z+1V8h%V=;7fc>Yish6#E;rFI)ppF3mjp?sik+#8Z8-<d?l!(Oa$BIA3M?uzpV-&VZ
z?C&l2Z?5~vS1xOMu=8Afw$t>!eB$l^fgbI6oYO#EbgY77cNR>&l98Qq#Yp78<5Ahk
z8+DMKt%?C^RSqykxoj320>ltRX1iTB8&yaEeD{+AlKogEdG0~6W~9x!;iR<{$7<xk
zBaQ2ks`;7ARkxe?=GcW}SLyeA(4GF~xCwu4Cg9)yi}j$#XJkjOTd5SEK8j<;NDdOf
z0jR&aMbS{WcIQgP$~%6n=$>IH=5j`laF<JJZT@yt010Jxme&ggf`b&J7(GTM++5}t
zOUwlq7%Q<o*u%ez5%gwvZd5n7hHuTxz4DgKV~d~?Dle}Y`f&a(;LK6*3;c44{Sf^j
z3Q~!^jJ}KlTU>>=C7(FEwqfSQJg*s**|Z8g#y5F}@e>~5H}N~m7kHn4$baNBT$Y_R
zqnMiK8dbpPCxU|A$!(a8tVmA^){earuF8`o_G$Ffs4OqG{TOokW_9>Z4AHot6W%$E
zo<>1lRQ-2u)*Je8LX<(KKD7rPFnJLeu2NY(Tc)<DTMeeb3oc`Ikf7u8ZKd&Hr0up<
zyoXgRzu;Iq3JH24Q@n?ULakb7iW(S5&<nM#YT9On4SgN7o2Fj87qPFC)bD#OGI|GW
zALw=aO;Yzjtzq>Q9Ce*j#b^e1%z6X7*+|><p!vKIf7aw}@3SV4z>atLu(<;~3cFqP
zco#u&thkNZx&eFL8^^n>n>ucCX{fef@7v^1$|ERsyvrj)O<|yk4mCRLd0!mta22rT
z;mIC=ci2RKPxcsidr#aZJZkn_`|*w2QHqwzmI|7g_4^qaA6a_j=&>YgbCvrztKIk^
zZ?|y2#Cu%PRx0=PdK>}uOlq1dUr#~YFO~y%N;)3HXQit=YhlhU8uv(TcQ!6ynplj%
z-bmoyqn$0|Tv@40eD3RMh(}{sWgNc>eh)yK@i%pkf}rrUlw(vZ_=3i~?Q3Re4*(+c
zx-ZW=R^4JxTR{}q2<jEm54;z~yki;uZ133-?^)k_7ULWBp4BFM&)S_T<*tu;=aFCF
zJ~!e%=ey61xzB~T&kfug<L<FL{p{?QM%*v??w7{gFNL^YvOAj+W^awVmjd^qgs1`I
zlE;H3$2yzx7h6+;Ii^riMXRfB_}k6y=zROE|C;sU&;_6Jiz}&{Tj}ygpLicW`cwMh
z`yYSw=;7}BAA`+wb7OtbRFa&R7@WWfOJI-1qVl`Q2~XIMual66v~Ct_Os~`|rq`<v
z7&e3q14-Ab2DX}60!4MJxRFMrk#D56gj1<iWDiJ*$-lGhcPWe|h%cGf%}OSd%}@lv
zQ5e%wdSmSmkuE=O!I7THWcIc46!x%u+`hhjTM}ms<w&tpCmL6yGY{PEmE&;(Mep$$
z*M9SyWn;bPYSkEJ^vfKvaVlh($gh>BbxW_wVQDb;d0sho8HVn`I4RC>w<MiQ$X^MZ
zu5ma{KJ(5+hG>tu->ysD@_8zMJttG~=y@)LBiH0at8snPY9zuEow#1-g2jxz{Rw$_
zJTk5&=m+CUoPvqb*<aqJs=_UXA1qL;EV)PZg*8~sH&P0hL8jXcTBjY%L!o4#wf}*(
zfaO~<i%v0<!v*rMJ5<WFs_LdhCVyiOsyed*+Ixu20!_s5augh&BMMWm`H{YYP<1WX
zD|9dgx0_YY|M4UV5xjcgr%w;OJe?*^6HG=uOGHWa63wTHp`65n58%IF%>x8>I#l|7
zI#lQr0pB8SIC8)L&z}OzzkYoB&e=PGj$r+M|1Sa_XrWDi=~kvoI0eD2ENRxvOdh8o
z=su($X*<C+NeS}u+s^kV-=8pvNbX5y*{lZ>`6>xc#e^1io(o>U3#Q?v=&fyZZ!I~q
zQxe0NalGuz$`W4m@Ct|09kNjH>Tk~`+wR<2`<=cP1aQAt-NItY5gKo=qY<kyHAan6
zt$e=iUwQJM(^}ab#mZ!YOEPBjwv`<SxGoXUkSA+E&mZK(V2K9U9{+4*?*?xo7;k_D
zY-Fgv5fEBiH4KCPPtax^YP@tGBZz|*yYp)+LoeePk8(sI1)Gd~D~Jh^bnFID3~drA
zLI<RS|55zFLZCUylvwdN3s|Kv)|_CC31}<~x+GZfAPZQhLZO27f`DEKgDwkJyyge2
zawt@=#sxGU2E8L#xq$Les9?pK3Ib5VpeuqkA)tv+s9;SBXfh1?u3()O(CJX9V8x4S
z5bI1B^sZo41yl`%3f7c>roy1_3D#KwoehNwR{Ym7h;=Runis6ND+8z&3Kgsu1@vMV
zv>;e73FxIzs9>EJ(D^W^E?6%M=;ctTV0}$MUkig8g7u1kUI~Q?)&&7w2!j>{>+1sg
zdMH$|UKP-*VbC?f`i6kM5egNo*97$1B&b%qYCNblB3<RM#o&m#?0z?K*uv8Rg}Vbm
zLIHbtV3A1>78M2Td4VNOg0QTjfPE{lv`HXK^01{~Pd>7+`3xlTv^=ztD{LVH8~M63
zw2?Dx1Opp+TN&EO9d74=jr_e!wwc40e+ZzA+fvAQ^r3ua#{=-l!VM<uc=tj1%&wA*
zTSeH@zI<k1B^ire*xSB*X7@A3@)dSG1&=I!#7<dbAr9@7w=rU;%(0|~_B6>O_EnUz
qIEMB%$!OQE(aj2fBcUHEXrb|V-eQA+!J``fG=la&-l7$y;r{_Geabxm

literal 0
HcmV?d00001

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index ac864fc982..dfb8523c8b 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT.roothp",
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
  2020-09-11 18:07 ` [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha
  2020-09-11 18:07 ` [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 12:21   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Ani Sinha
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

When ACPI hotplug for the root bus is disabled, the bsel property for that
bus is not set. Please see the following commit:

3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus").

As a result, when acpi_pcihp_find_hotplug_bus() is called
with bsel set to 0, it may return the root bus. This can cause devices attached to
the root bus to get hot-unplugged if the user issues the following set of commmands:

outl 0xae10 0
outl 0xae08 your_slot

Thanks to Julia for pointing this out here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg734548.html

In this patch, we fix the issue in this function by checking if the bus which is
returned by the function is actually hotpluggable. If not, we simply return NULL.
This avoids the scenario where we were returning a non-hotpluggable bus.

This patch is based off of tag v5.10

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 hw/acpi/pcihp.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 39b1f74442..32ae8b2c0a 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -147,6 +147,21 @@ static PCIBus *acpi_pcihp_find_hotplug_bus(AcpiPciHpState *s, int bsel)
     if (!bsel && !find.bus) {
         find.bus = s->root;
     }
+
+    /*
+     * Check if find.bus is actually hotpluggable. If bsel is set to
+     * NULL for example on the root bus in order to make it
+     * non-hotpluggable, find.bus will match the root bus when bsel
+     * is 0. See acpi_pcihp_test_hotplug_bus() above. Since the
+     * bus is not hotpluggable however, we should not select the bus.
+     * Instead, we should set find.bus to NULL in that case. In the check
+     * below, we generalize this case for all buses, not just the root bus.
+     * The callers of this function check for a null return value and
+     * handle them appropriately.
+     */
+    if (find.bus && !qbus_is_hotpluggable(BUS(find.bus))) {
+        find.bus = NULL;
+    }
     return find.bus;
 }
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (2 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 12:36   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 6/9] tests/acpi: list added acpi table binary file for pci bridge hotplug test Ani Sinha
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, jusual, Paolo Bonzini,
	Ani Sinha, Igor Mammedov, Richard Henderson

Cold plugged bridges are not hot unpluggable, even when their hotplug
property (acpi-pci-hotplug-with-bridge-support) is turned off. Please see
the function acpi_pcihp_pc_no_hotplug() (thanks Julia). However, with
the current implementaton, windows would try to hot-unplug a pci bridge when
it's hotplug switch is off. This is regardless of whether there are devices
attached to the bridge. This is because we add amls like _EJ0 etc for the
pci slot where the bridge is cold plugged. We have a demo video here:
https://youtu.be/pME2sjyQweo

In this fix, we identify a cold plugged bridge and for cold plugged bridges,
we do not add the appropriate amls and acpi methods that are used by the OS
to identify a hot-pluggable/unpluggable pci device. After this change, Windows
does not show an option to eject the PCI bridge. A demo video is here:
https://youtu.be/kbgej5B9Hgs

As a result of the patch, the following are the changes to the DSDT ACPI table:

@@ -858,38 +858,33 @@
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }

             Device (S18)
             {
-                Name (_SUN, 0x03)  // _SUN: Slot User Number
                 Name (_ADR, 0x00030000)  // _ADR: Address
-                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                {
-                    PCEJ (BSEL, _SUN)
-                }
             }

             Device (S20)
             {
                 Name (_SUN, 0x04)  // _SUN: Slot User Number
                 Name (_ADR, 0x00040000)  // _ADR: Address
                 Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                 {
                     PCEJ (BSEL, _SUN)
                 }
             }

             Device (S28)
             {
                 Name (_SUN, 0x05)  // _SUN: Slot User Number
                 Name (_ADR, 0x00050000)  // _ADR: Address
@@ -1148,37 +1143,32 @@
                     PCEJ (BSEL, _SUN)
                 }
             }

             Device (SF8)
             {
                 Name (_SUN, 0x1F)  // _SUN: Slot User Number
                 Name (_ADR, 0x001F0000)  // _ADR: Address
                 Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                 {
                     PCEJ (BSEL, _SUN)
                 }
             }

             Method (DVNT, 2, NotSerialized)
             {
-                If ((Arg0 & 0x08))
-                {
-                    Notify (S18, Arg1)
-                }
-
                 If ((Arg0 & 0x10))
                 {
                     Notify (S20, Arg1)
                 }

                 If ((Arg0 & 0x20))
                 {
                     Notify (S28, Arg1)
                 }

                 If ((Arg0 & 0x40))
                 {
                     Notify (S30, Arg1)
                 }

                 If ((Arg0 & 0x80))

While at it, I have also updated a stale comment.

This change is tested with a Windows 2012R2 guest image and Windows 2019 server
guest image running on Ubuntu 18.04 host. This change is based off of upstream
qemu master branch tag v5.1.0.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 hw/i386/acpi-build.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7a5a8b3521..e079b686f5 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -359,6 +359,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
         int slot = PCI_SLOT(i);
         bool hotplug_enabled_dev;
         bool bridge_in_acpi;
+        bool cold_plugged_bridge;
 
         if (!pdev) {
             if (bsel) { /* add hotplug slots for non present devices */
@@ -380,15 +381,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
         pc = PCI_DEVICE_GET_CLASS(pdev);
         dc = DEVICE_GET_CLASS(pdev);
 
-        /* When hotplug for bridges is enabled, bridges are
-         * described in ACPI separately (see build_pci_bus_end).
-         * In this case they aren't themselves hot-pluggable.
+        /*
+         * Cold plugged bridges aren't themselves hot-pluggable.
          * Hotplugged bridges *are* hot-pluggable.
          */
-        bridge_in_acpi = pc->is_bridge && pcihp_bridge_en &&
-            !DEVICE(pdev)->hotplugged;
+        cold_plugged_bridge = pc->is_bridge && !DEVICE(pdev)->hotplugged;
+        bridge_in_acpi =  cold_plugged_bridge && pcihp_bridge_en;
 
-        hotplug_enabled_dev = bsel && dc->hotpluggable && !bridge_in_acpi;
+        hotplug_enabled_dev = bsel && dc->hotpluggable && !cold_plugged_bridge;
 
         if (pc->class_id == PCI_CLASS_BRIDGE_ISA) {
             continue;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 6/9] tests/acpi: list added acpi table binary file for pci bridge hotplug test
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (3 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-11 18:07 ` [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag Ani Sinha
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

The file 'tests/data/acpi/pc/DSDT.hpbridge' is a newly added acpi table file for
testing the pci bridge option 'acpi-pci-hotplug-with-bridge-support' under i440fx.
This change documents this fact.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index dfb8523c8b..96a9237355 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT.hpbridge",
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (4 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 6/9] tests/acpi: list added acpi table binary file for pci bridge hotplug test Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 12:42   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag Ani Sinha
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	Paolo Bonzini, Ani Sinha, Igor Mammedov

This change adds a new unit test for the global flag
'acpi-pci-hotplug-with-bridge-support' which is available for cold plugged pci
bridges in i440fx. The flag can be used to turn off acpi based hotplug support
for all the slots of the pci bus.

Tested on the upstream qemu master branch.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/qtest/bios-tables-test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index d8c7d57557..7632cfe1be 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -754,6 +754,20 @@ static void test_acpi_piix4_root_hotplug(void)
     free_test_data(&data);
 }
 
+static void test_acpi_piix4_bridge_hotplug(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_PC;
+    data.variant = ".hpbridge";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+    test_acpi_one("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
+                  "-device pci-bridge,chassis_nr=1", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg(void)
 {
     test_data data;
@@ -1159,6 +1173,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
         qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
         qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
+        qtest_add_func("acpi/piix4/brhotplug", test_acpi_piix4_bridge_hotplug);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
         qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (5 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 12:43   ` Igor Mammedov
  2020-09-11 18:07 ` [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally Ani Sinha
  2020-09-14 11:45 ` [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Igor Mammedov
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ani Sinha, Igor Mammedov, jusual, Michael S. Tsirkin

This patch adds a binary blob corresponding to the DSDT acpi table. It is used
to unit test the flag 'acpi-pci-hotplug-with-bridge-support' used with pci
bridges.

This change also clears the file tests/qtest/bios-tables-test-allowed-diff.h
so that future changes which affect the table can be caught.

The following is the diff between files tests/data/acpi/pc/DSDT.bridge and
tests/data/acpi/pc/DSDT.hpbridge after disassembly :

@@ -1,30 +1,30 @@
 /*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20180105 (64-bit version)
  * Copyright (c) 2000 - 2018 Intel Corporation
  *
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of tests/data/acpi/pc/DSDT.bridge, Fri Sep 11 23:21:34 2020
+ * Disassembly of /tmp/aml-7UURQ0, Fri Sep 11 23:21:34 2020
  *
  * Original Table Header:
  *     Signature        "DSDT"
- *     Length           0x00001A89 (6793)
+ *     Length           0x0000131F (4895)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0x09
+ *     Checksum         0xF9
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -859,522 +859,32 @@
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }

             Device (S18)
             {
                 Name (_ADR, 0x00030000)  // _ADR: Address
-                Name (BSEL, One)
-                Device (S00)
-                {
-                    Name (_SUN, Zero)  // _SUN: Slot User Number
-                    Name (_ADR, Zero)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S08)
-                {
-                    Name (_SUN, One)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00010000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S10)
-                {
-                    Name (_SUN, 0x02)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00020000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S18)
-                {
-                    Name (_SUN, 0x03)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00030000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S20)
-                {
-                    Name (_SUN, 0x04)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00040000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S28)
-                {
-                    Name (_SUN, 0x05)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00050000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S30)
-                {
-                    Name (_SUN, 0x06)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00060000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S38)
-                {
-                    Name (_SUN, 0x07)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00070000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S40)
-                {
-                    Name (_SUN, 0x08)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00080000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S48)
-                {
-                    Name (_SUN, 0x09)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00090000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S50)
-                {
-                    Name (_SUN, 0x0A)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000A0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S58)
-                {
-                    Name (_SUN, 0x0B)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000B0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S60)
-                {
-                    Name (_SUN, 0x0C)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000C0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S68)
-                {
-                    Name (_SUN, 0x0D)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000D0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S70)
-                {
-                    Name (_SUN, 0x0E)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000E0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S78)
-                {
-                    Name (_SUN, 0x0F)  // _SUN: Slot User Number
-                    Name (_ADR, 0x000F0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S80)
-                {
-                    Name (_SUN, 0x10)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00100000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S88)
-                {
-                    Name (_SUN, 0x11)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00110000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S90)
-                {
-                    Name (_SUN, 0x12)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00120000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (S98)
-                {
-                    Name (_SUN, 0x13)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00130000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SA0)
-                {
-                    Name (_SUN, 0x14)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00140000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SA8)
-                {
-                    Name (_SUN, 0x15)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00150000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SB0)
-                {
-                    Name (_SUN, 0x16)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00160000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SB8)
-                {
-                    Name (_SUN, 0x17)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00170000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SC0)
-                {
-                    Name (_SUN, 0x18)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00180000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SC8)
-                {
-                    Name (_SUN, 0x19)  // _SUN: Slot User Number
-                    Name (_ADR, 0x00190000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SD0)
-                {
-                    Name (_SUN, 0x1A)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001A0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SD8)
-                {
-                    Name (_SUN, 0x1B)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001B0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SE0)
-                {
-                    Name (_SUN, 0x1C)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001C0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SE8)
-                {
-                    Name (_SUN, 0x1D)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001D0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SF0)
-                {
-                    Name (_SUN, 0x1E)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001E0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Device (SF8)
-                {
-                    Name (_SUN, 0x1F)  // _SUN: Slot User Number
-                    Name (_ADR, 0x001F0000)  // _ADR: Address
-                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-                    {
-                        PCEJ (BSEL, _SUN)
-                    }
-                }
-
-                Method (DVNT, 2, NotSerialized)
-                {
-                    If ((Arg0 & One))
-                    {
-                        Notify (S00, Arg1)
-                    }
-
-                    If ((Arg0 & 0x02))
-                    {
-                        Notify (S08, Arg1)
-                    }
-
-                    If ((Arg0 & 0x04))
-                    {
-                        Notify (S10, Arg1)
-                    }
-
-                    If ((Arg0 & 0x08))
-                    {
-                        Notify (S18, Arg1)
-                    }
-
-                    If ((Arg0 & 0x10))
-                    {
-                        Notify (S20, Arg1)
-                    }
-
-                    If ((Arg0 & 0x20))
-                    {
-                        Notify (S28, Arg1)
-                    }
-
-                    If ((Arg0 & 0x40))
-                    {
-                        Notify (S30, Arg1)
-                    }
-
-                    If ((Arg0 & 0x80))
-                    {
-                        Notify (S38, Arg1)
-                    }
-
-                    If ((Arg0 & 0x0100))
-                    {
-                        Notify (S40, Arg1)
-                    }
-
-                    If ((Arg0 & 0x0200))
-                    {
-                        Notify (S48, Arg1)
-                    }
-
-                    If ((Arg0 & 0x0400))
-                    {
-                        Notify (S50, Arg1)
-                    }
-
-                    If ((Arg0 & 0x0800))
-                    {
-                        Notify (S58, Arg1)
-                    }
-
-                    If ((Arg0 & 0x1000))
-                    {
-                        Notify (S60, Arg1)
-                    }
-
-                    If ((Arg0 & 0x2000))
-                    {
-                        Notify (S68, Arg1)
-                    }
-
-                    If ((Arg0 & 0x4000))
-                    {
-                        Notify (S70, Arg1)
-                    }
-
-                    If ((Arg0 & 0x8000))
-                    {
-                        Notify (S78, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00010000))
-                    {
-                        Notify (S80, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00020000))
-                    {
-                        Notify (S88, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00040000))
-                    {
-                        Notify (S90, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00080000))
-                    {
-                        Notify (S98, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00100000))
-                    {
-                        Notify (SA0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00200000))
-                    {
-                        Notify (SA8, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00400000))
-                    {
-                        Notify (SB0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x00800000))
-                    {
-                        Notify (SB8, Arg1)
-                    }
-
-                    If ((Arg0 & 0x01000000))
-                    {
-                        Notify (SC0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x02000000))
-                    {
-                        Notify (SC8, Arg1)
-                    }
-
-                    If ((Arg0 & 0x04000000))
-                    {
-                        Notify (SD0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x08000000))
-                    {
-                        Notify (SD8, Arg1)
-                    }
-
-                    If ((Arg0 & 0x10000000))
-                    {
-                        Notify (SE0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x20000000))
-                    {
-                        Notify (SE8, Arg1)
-                    }
-
-                    If ((Arg0 & 0x40000000))
-                    {
-                        Notify (SF0, Arg1)
-                    }
-
-                    If ((Arg0 & 0x80000000))
-                    {
-                        Notify (SF8, Arg1)
-                    }
-                }
-
-                Method (PCNT, 0, NotSerialized)
-                {
-                    BNUM = One
-                    DVNT (PCIU, One)
-                    DVNT (PCID, 0x03)
-                }
             }

             Device (S20)
             {
                 Name (_SUN, 0x04)  // _SUN: Slot User Number
                 Name (_ADR, 0x00040000)  // _ADR: Address
                 Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                 {
                     PCEJ (BSEL, _SUN)
                 }
             }

             Device (S28)
             {
                 Name (_SUN, 0x05)  // _SUN: Slot User Number
                 Name (_ADR, 0x00050000)  // _ADR: Address
@@ -1779,22 +1289,21 @@
                 If ((Arg0 & 0x40000000))
                 {
                     Notify (SF0, Arg1)
                 }

                 If ((Arg0 & 0x80000000))
                 {
                     Notify (SF8, Arg1)
                 }
             }

             Method (PCNT, 0, NotSerialized)
             {
                 BNUM = Zero
                 DVNT (PCIU, One)
                 DVNT (PCID, 0x03)
-                ^S18.PCNT ()
             }
         }
     }
 }

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/data/acpi/pc/DSDT.hpbridge            | Bin 0 -> 4895 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 2 files changed, 1 deletion(-)
 create mode 100644 tests/data/acpi/pc/DSDT.hpbridge

diff --git a/tests/data/acpi/pc/DSDT.hpbridge b/tests/data/acpi/pc/DSDT.hpbridge
new file mode 100644
index 0000000000000000000000000000000000000000..b0751398541bdf88ce405be9742aeba0b375dbc3
GIT binary patch
literal 4895
zcmb7IQE%Hu5}p+)hgwNCWixSVw~gQ=SF}AelAO9J?!^)*ONuR-5#`(+Xn>UM;^d-5
ziL?Rg8pSCp;HG&ibUEC^J*a`6<Dby`3H=GZztF=qzL)A|NUf~MBG3vj#hLl`o0;9&
z*_92;Xk1$WVE-#@>t!ol_>-v{sAB*?@AR!!<Xy1aMxo@ectmFQqqzT$kAkB8-YD#p
z*gsnC-(B~!uU*#kVDFjwbg$`s_1N750zKUGIHwnN#jy&G-B~vEN=9+Y6(f=VflG>$
zH|n4`I~4=esuEy|O4%$n1c)Js%yzqMHmZ;S_~Dm0$o3<Z<c0ginvpi^hLhIT9IKHB
zk2J1Fs^%9iSKVIX+pY^;H$E8jp*Q<&w+Vl1Cg9)yjrO6>=M+b;Td5SEJ&9q)NDeZ<
z5vad=hoYfy?aorg$~%6n=$>IH=Ix9g;Vzfe+Ttxq010JxZf_P01P3Wf7(GTM++5|C
zOUwlq7%Q;@IKc0f2zs+SH>%q^qfv7UFO5=obOlsG<&_OXAI;w-oH+`9nO`ljpQN88
zkW1`^^g;r*vJP*_K5=$q%gl>;-Y_cjX%%>sZ}SY}r#!-M;@>=9<^%o_|C!HmMR7Ka
zVrr3VQ~~3k2nu#5w`Df6B0V`+JN8nzDo>W!=hEkrqO7$27;^e{bu=c5Xk5@KW6q>A
z36vGpA9J(b&_@#zA7<)Pd*A_6R)FCum6h{lYMZ*%U~zcP6|4>tbX>ljG(L>9-L{H%
zv5J-F9BU^|f?miJ@1mhltJYau4Gbjch1yOvZL`9bz6sh*Q!n0)*w;xK47?T@y(4xA
zG~9lJ)O}EESbYUY-Q-j;n!z2j-T-et(sn&)J}bnYHhJ6oqRAt$=N&(2?g5uzzo&Nh
z5fsCU+p29EaL~Ka-Dka2x5?#^+Jb}ck|QaPpj3CCM@E{$P$P{rIvjXk9_?`zu;$_M
z0f2YhM1PMD7<dPd-6lM2_FenYjaw2$OJz$1&CL3}jDn9WJ#zF|RkVf5J)G5E?3lM(
zxL;y@9@o|?_w;%U0rgC3mdC%DftX(`NAQGnJc`dsFaETJIk)J&PinifbqUkNVhr|1
z0{0&6Yz61aN?qX#-^@Zxiei;<{EOq?5omM%rtVV^6rPrHjEV(c(mQYanmO77fC#<r
z%ZrXxx7d?b5Ct}ZdWG~u?}Z8PScbpadv?rw*7u&p_{P0wwdvlocBe|Y>l5C2<Ttp_
zjk(YH?sF6Fb0O|?L-)p{d+biXI{Vcz_p849)d}~jA?{c0&bEx%Ta)hPz`ZCTYQVVU
zv0%xu&Sw0@*5bh&Q>dt-)m69r?Phm$zI)z(&3bX<g3tKHmDJ6hborCdypJCKCH>%o
zPd|D1VE=<p!DhO-wK;4mNzO|QPT`a#u*YIi`Ca6cC+tVpNytN5H;Xl<S85j1>(%=V
z8$yPGtm{<+Tg^OyB;6`*r4ec58)+@!RB9E)15#r0Z}0kD3S$Z4OXhX6lF4K<6hUwl
zMzxgQ*!Xj#$Ga^!(KDIMp;n&39+r>U*LQEp;*6mjDR$~alWKJ4f!kZ^P8ukBkI%XG
z8y75Fn|)WSMk%A;=7>#FA;VODtvst+dQAySgSpT0@vh4-bPpy;afW*(`9ebeO5k)&
z!g2DMcOf!Fd(8cAQ|^^7Qu*sSor+5rxe$(A(-W=6^lht=2upP8dR+(>GxiRr<mK_m
zq?Vu`PAYK<rbcIfb%&}7w-|n~K(VrvKGhf2U^U-J#km3s-EPo2>tG&nN(NeoA8N~3
zz9qBh6f-$oApg2UrA(`;Zp&oyH}<fqGi#u|kJv2GM2s#+!SOk!F!h=r=}QPz*Mhx5
z2UBpnS?BzpkCPC=s~3I-^uWv0S>i0g6x6eXM5-5PK1+<`Bp!SK|M_|mAh6S+G8oXI
zLZ1lu7IDK-27~W^2`vBm`N`YoV*(w)27|$01w7C~o4)B*rpq`5!L2N5*33*Ery%G)
zq#tWL!8Iu!<mI=WA5VWgWipZ6mCdqQ4<_<u5}b-DE$ku}Jcs8@!%NYdyXf9pb>?Se
zhB4#&ZD(GQ@uG)UIF#Nc3k9$K;e4{~&N~}_)Hi|v?iH&$SS&e0<Lz}kVl}EpsZpx6
zk9Ykm&&J38S{1PSU>b2NlL@ZMD7<B5hXSrn1T<vJ8qoJ&a^hu`UhK}CmAw-TM6860
zH?15EwsvY9&k6jUfO;9Ud54-W-O0!!nSCgYC1_MYqhZih!HOqDz&aBO6|9#8^imk~
zwqV8kbHJ*ELIrC~Kx1LhcLggKP#y{uthiV~0P!&BnqW-`Xd)CUSd#*p41>NWSZ4)v
zHWVsY@dg;gIu{1LBUn`dRYReIH6@^_FzEY&bzVT{L!p8df0G5VE`&kzf)xurfNG&o
z!FpLhFNZ-3g7u1kUI~Q?)<pqb41?-|^{Rkg4TTEUR|NExFsLC|mjrYv6e?Jk1#~$K
zS`@6W3h1k$P{I0|fW8(6-4Lv=3+U^iP{DdlK(9@MYMV>O{aPc^OB}cG$JYrputQ%+
zlW=D!tfPQUD6q6iAWQPN701)}#KKN8lp-XJY%)sN4~8~{q>+uB;jSLq$lKb;M(%KL
z4sGP`J+jRmx3Hn&@o-|{9uqPi5GbG9@t8QVaJL9M-Vjhex2q&$-3xo#m(T6%Bx3~&
zd)t@K?S95si^7hl#EGSk*(qzRs*#=YHpc9fIo8L>o+f$BzK$}k^vK>O8SUCNx_{t*
S66ohVtr{L;J8bx3aOwYF+mJl~

literal 0
HcmV?d00001

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
index 96a9237355..dfb8523c8b 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT.hpbridge",
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (6 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag Ani Sinha
@ 2020-09-11 18:07 ` Ani Sinha
  2020-09-14 13:05   ` Igor Mammedov
  2020-09-14 11:45 ` [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Igor Mammedov
  8 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-11 18:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, jusual,
	Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Ani Sinha, Igor Mammedov,
	Aurelien Jarno, Richard Henderson

When acpi hotplug is turned off for both root pci bus as well as for pci
bridges, we should not generate the related amls for DSDT table or initialize
related hw ports or reserve hw resources. This change makes sure all those
operations are turned off in the case acpi pci hotplug is off globally.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 hw/acpi/piix4.c      |  6 ++++--
 hw/i386/acpi-build.c | 10 ++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index e6163bb6ce..b70b1f98af 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index e079b686f5..7e3cf3b57b 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_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)
@@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_piix4_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
-        build_piix4_pci_hotplug(dsdt);
+        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
+            build_piix4_pci_hotplug(dsdt);
+        }
         build_piix4_pci0_int(dsdt);
     } else {
         sb_scope = aml_scope("_SB");
@@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     crs_range_set_free(&crs_range_set);
 
     /* reserve PCIHP resources */
-    if (pm->pcihp_io_len) {
+    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
         dev = aml_device("PHPR");
         aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
         aml_append(dev,
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off
  2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
                   ` (7 preceding siblings ...)
  2020-09-11 18:07 ` [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally Ani Sinha
@ 2020-09-14 11:45 ` Igor Mammedov
  8 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 11:45 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Fri, 11 Sep 2020 23:37:47 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> A new binary acpi table tests/data/acpi/pc/DSDT.roothp is added in order to unit test
> the feature flag that can disable/enable root pci bus hotplug on i440fx. This feature was
> added with the commit:
> 3d7e78aa7777f0 ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")
> 
> This change documents the fact that this new file addition was made as a part of the
> unit test change.
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
since it's new test case. I'd squash it into 2/9

Reviewed-by: Igor Mammedov <imammedo@redhat.com>


> ---
>  tests/qtest/bios-tables-test-allowed-diff.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
> index dfb8523c8b..ac864fc982 100644
> --- a/tests/qtest/bios-tables-test-allowed-diff.h
> +++ b/tests/qtest/bios-tables-test-allowed-diff.h
> @@ -1 +1,2 @@
>  /* List of comma-separated changed AML files to ignore */
> +"tests/data/acpi/pc/DSDT.roothp",



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus
  2020-09-11 18:07 ` [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha
@ 2020-09-14 11:57   ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 11:57 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	qemu-devel, Paolo Bonzini

On Fri, 11 Sep 2020 23:37:48 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> Ability to turn hotplug off on the pci root bus for i440fx was added in commit:
> 3d7e78aa7777f0 ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")
> 
> This change adds a unit test in order to test this feature.
> 
> This change has been tested against upstream qemu master branch on top of tag v5.1.0.

isn't this seriest a rebase on top of master?
should comment be amended?

> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
 
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  tests/qtest/bios-tables-test.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> index 504b810af5..d8c7d57557 100644
> --- a/tests/qtest/bios-tables-test.c
> +++ b/tests/qtest/bios-tables-test.c
> @@ -740,6 +740,20 @@ static void test_acpi_piix4_tcg_bridge(void)
>      free_test_data(&data);
>  }
>  
> +static void test_acpi_piix4_root_hotplug(void)
> +{
> +    test_data data;
> +
> +    memset(&data, 0, sizeof(data));
> +    data.machine = MACHINE_PC;
> +    data.variant = ".roothp";
> +    data.required_struct_types = base_required_struct_types;
> +    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
> +    test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
> +                  "-device pci-bridge,chassis_nr=1", &data);
> +    free_test_data(&data);
> +}
> +
>  static void test_acpi_q35_tcg(void)
>  {
>      test_data data;
> @@ -1144,6 +1158,7 @@ int main(int argc, char *argv[])
>          qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tcg_tpm_tis);
>          qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
>          qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
> +        qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
>          qtest_add_func("acpi/q35", test_acpi_q35_tcg);
>          qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
>          qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off
  2020-09-11 18:07 ` [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off Ani Sinha
@ 2020-09-14 11:58   ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 11:58 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Fri, 11 Sep 2020 23:37:49 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> A new binary ACPI table tests/data/acpi/pc/DSDT.roothp is added in order
> to unit test hotplug on/off capability on the root pci bus for i440fx.
> The diff between the table DSDT.bridge and DSDT.roothp is listed below:

Acked-by: Igor Mammedov <imammedo@redhat.com>

> @@ -1,30 +1,30 @@
>  /*
>   * Intel ACPI Component Architecture
>   * AML/ASL+ Disassembler version 20180105 (64-bit version)
>   * Copyright (c) 2000 - 2018 Intel Corporation
>   *
>   * Disassembling to symbolic ASL+ operators
>   *
> - * Disassembly of tests/data/acpi/pc/DSDT.bridge, Fri Sep 11 22:51:04 2020
> + * Disassembly of /tmp/aml-UGIHQ0, Fri Sep 11 22:51:04 2020
>   *
>   * Original Table Header:
>   *     Signature        "DSDT"
> - *     Length           0x00001A89 (6793)
> + *     Length           0x0000140A (5130)
>   *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
> - *     Checksum         0x09
> + *     Checksum         0xE6
>   *     OEM ID           "BOCHS "
>   *     OEM Table ID     "BXPCDSDT"
>   *     OEM Revision     0x00000001 (1)
>   *     Compiler ID      "BXPC"
>   *     Compiler Version 0x00000001 (1)
>   */
>  DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
>  {
>      Scope (\)
>      {
>          OperationRegion (DBG, SystemIO, 0x0402, One)
>          Field (DBG, ByteAcc, NoLock, Preserve)
>          {
>              DBGB,   8
>          }
> 
> @@ -831,61 +831,60 @@
>              Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
>              {
>                  IO (Decode16,
>                      0x0510,             // Range Minimum
>                      0x0510,             // Range Maximum
>                      0x01,               // Alignment
>                      0x0C,               // Length
>                      )
>              })
>          }
>      }
> 
>      Scope (\_SB)
>      {
>          Scope (PCI0)
>          {
> -            Name (BSEL, Zero)
>              Device (S00)
>              {
>                  Name (_ADR, Zero)  // _ADR: Address
>              }
> 
>              Device (S10)
>              {
>                  Name (_ADR, 0x00020000)  // _ADR: Address
>                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                  {
>                      Return (Zero)
>                  }
>              }
> 
>              Device (S18)
>              {
>                  Name (_ADR, 0x00030000)  // _ADR: Address
> -                Name (BSEL, One)
> +                Name (BSEL, Zero)
>                  Device (S00)
>                  {
>                      Name (_SUN, Zero)  // _SUN: Slot User Number
>                      Name (_ADR, Zero)  // _ADR: Address
>                      Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
>                      {
>                          PCEJ (BSEL, _SUN)
>                      }
>                  }
> 
>                  Device (S08)
>                  {
>                      Name (_SUN, One)  // _SUN: Slot User Number
>                      Name (_ADR, 0x00010000)  // _ADR: Address
>                      Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
>                      {
> @@ -1345,456 +1344,30 @@
>                          Notify (SE8, Arg1)
>                      }
> 
>                      If ((Arg0 & 0x40000000))
>                      {
>                          Notify (SF0, Arg1)
>                      }
> 
>                      If ((Arg0 & 0x80000000))
>                      {
>                          Notify (SF8, Arg1)
>                      }
>                  }
> 
>                  Method (PCNT, 0, NotSerialized)
>                  {
> -                    BNUM = One
> +                    BNUM = Zero
>                      DVNT (PCIU, One)
>                      DVNT (PCID, 0x03)
>                  }
>              }
> 
> -            Device (S20)
> -            {
> -                Name (_SUN, 0x04)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00040000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S28)
> -            {
> -                Name (_SUN, 0x05)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00050000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S30)
> -            {
> -                Name (_SUN, 0x06)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00060000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S38)
> -            {
> -                Name (_SUN, 0x07)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00070000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S40)
> -            {
> -                Name (_SUN, 0x08)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00080000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S48)
> -            {
> -                Name (_SUN, 0x09)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00090000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S50)
> -            {
> -                Name (_SUN, 0x0A)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000A0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S58)
> -            {
> -                Name (_SUN, 0x0B)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000B0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S60)
> -            {
> -                Name (_SUN, 0x0C)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000C0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S68)
> -            {
> -                Name (_SUN, 0x0D)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000D0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S70)
> -            {
> -                Name (_SUN, 0x0E)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000E0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S78)
> -            {
> -                Name (_SUN, 0x0F)  // _SUN: Slot User Number
> -                Name (_ADR, 0x000F0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S80)
> -            {
> -                Name (_SUN, 0x10)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00100000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S88)
> -            {
> -                Name (_SUN, 0x11)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00110000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S90)
> -            {
> -                Name (_SUN, 0x12)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00120000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (S98)
> -            {
> -                Name (_SUN, 0x13)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00130000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SA0)
> -            {
> -                Name (_SUN, 0x14)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00140000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SA8)
> -            {
> -                Name (_SUN, 0x15)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00150000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SB0)
> -            {
> -                Name (_SUN, 0x16)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00160000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SB8)
> -            {
> -                Name (_SUN, 0x17)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00170000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SC0)
> -            {
> -                Name (_SUN, 0x18)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00180000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SC8)
> -            {
> -                Name (_SUN, 0x19)  // _SUN: Slot User Number
> -                Name (_ADR, 0x00190000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SD0)
> -            {
> -                Name (_SUN, 0x1A)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001A0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SD8)
> -            {
> -                Name (_SUN, 0x1B)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001B0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SE0)
> -            {
> -                Name (_SUN, 0x1C)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001C0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SE8)
> -            {
> -                Name (_SUN, 0x1D)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001D0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SF0)
> -            {
> -                Name (_SUN, 0x1E)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001E0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Device (SF8)
> -            {
> -                Name (_SUN, 0x1F)  // _SUN: Slot User Number
> -                Name (_ADR, 0x001F0000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
> -            }
> -
> -            Method (DVNT, 2, NotSerialized)
> -            {
> -                If ((Arg0 & 0x10))
> -                {
> -                    Notify (S20, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x20))
> -                {
> -                    Notify (S28, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x40))
> -                {
> -                    Notify (S30, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x80))
> -                {
> -                    Notify (S38, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x0100))
> -                {
> -                    Notify (S40, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x0200))
> -                {
> -                    Notify (S48, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x0400))
> -                {
> -                    Notify (S50, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x0800))
> -                {
> -                    Notify (S58, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x1000))
> -                {
> -                    Notify (S60, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x2000))
> -                {
> -                    Notify (S68, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x4000))
> -                {
> -                    Notify (S70, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x8000))
> -                {
> -                    Notify (S78, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00010000))
> -                {
> -                    Notify (S80, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00020000))
> -                {
> -                    Notify (S88, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00040000))
> -                {
> -                    Notify (S90, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00080000))
> -                {
> -                    Notify (S98, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00100000))
> -                {
> -                    Notify (SA0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00200000))
> -                {
> -                    Notify (SA8, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00400000))
> -                {
> -                    Notify (SB0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x00800000))
> -                {
> -                    Notify (SB8, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x01000000))
> -                {
> -                    Notify (SC0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x02000000))
> -                {
> -                    Notify (SC8, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x04000000))
> -                {
> -                    Notify (SD0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x08000000))
> -                {
> -                    Notify (SD8, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x10000000))
> -                {
> -                    Notify (SE0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x20000000))
> -                {
> -                    Notify (SE8, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x40000000))
> -                {
> -                    Notify (SF0, Arg1)
> -                }
> -
> -                If ((Arg0 & 0x80000000))
> -                {
> -                    Notify (SF8, Arg1)
> -                }
> -            }
> -
>              Method (PCNT, 0, NotSerialized)
>              {
> -                BNUM = Zero
> -                DVNT (PCIU, One)
> -                DVNT (PCID, 0x03)
>                  ^S18.PCNT ()
>              }
>          }
>      }
>  }
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  tests/data/acpi/pc/DSDT.roothp              | Bin 0 -> 5130 bytes
>  tests/qtest/bios-tables-test-allowed-diff.h |   1 -
>  2 files changed, 1 deletion(-)
>  create mode 100644 tests/data/acpi/pc/DSDT.roothp
> 
> diff --git a/tests/data/acpi/pc/DSDT.roothp b/tests/data/acpi/pc/DSDT.roothp
> new file mode 100644
> index 0000000000000000000000000000000000000000..886a5e6952f6f034bdd80d44d43de5975a1a4b0f
> GIT binary patch
> literal 5130
> zcmb7IQEwZ^5uPQF@^O!pj?&q3tT-lQyJ?cbCMj8Q&=-++6iG{@&OFL(aYFAXDJT^L
> z$iaz=C`wS80Tjn?f$E|UeP9eeTR)-w3Hb@>OMgI$#(D}nbH}A<iU%YFc-ooy?wgt2
> z+1V8h%V=;7fc>Yish6#E;rFI)ppF3mjp?sik+#8Z8-<d?l!(Oa$BIA3M?uzpV-&VZ  
> z?C&l2Z?5~vS1xOMu=8Afw$t>!eB$l^fgbI6oYO#EbgY77cNR>&l98Qq#Yp78<5Ahk  
> z8+DMKt%?C^RSqykxoj320>ltRX1iTB8&yaEeD{+AlKogEdG0~6W~9x!;iR<{$7<xk  
> zBaQ2ks`;7ARkxe?=GcW}SLyeA(4GF~xCwu4Cg9)yi}j$#XJkjOTd5SEK8j<;NDdOf
> z0jR&aMbS{WcIQgP$~%6n=$>IH=5j`laF<JJZT@yt010Jxme&ggf`b&J7(GTM++5}t  
> zOUwlq7%Q<o*u%ez5%gwvZd5n7hHuTxz4DgKV~d~?Dle}Y`f&a(;LK6*3;c44{Sf^j
> z3Q~!^jJ}KlTU>>=C7(FEwqfSQJg*s**|Z8g#y5F}@e>~5H}N~m7kHn4$baNBT$Y_R  
> zqnMiK8dbpPCxU|A$!(a8tVmA^){earuF8`o_G$Ffs4OqG{TOokW_9>Z4AHot6W%$E  
> zo<>1lRQ-2u)*Je8LX<(KKD7rPFnJLeu2NY(Tc)<DTMeeb3oc`Ikf7u8ZKd&Hr0up<
> zyoXgRzu;Iq3JH24Q@n?ULakb7iW(S5&<nM#YT9On4SgN7o2Fj87qPFC)bD#OGI|GW
> zALw=aO;Yzjtzq>Q9Ce*j#b^e1%z6X7*+|><p!vKIf7aw}@3SV4z>atLu(<;~3cFqP
> zco#u&thkNZx&eFL8^^n>n>ucCX{fef@7v^1$|ERsyvrj)O<|yk4mCRLd0!mta22rT  
> z;mIC=ci2RKPxcsidr#aZJZkn_`|*w2QHqwzmI|7g_4^qaA6a_j=&>YgbCvrztKIk^
> zZ?|y2#Cu%PRx0=PdK>}uOlq1dUr#~YFO~y%N;)3HXQit=YhlhU8uv(TcQ!6ynplj%  
> z-bmoyqn$0|Tv@40eD3RMh(}{sWgNc>eh)yK@i%pkf}rrUlw(vZ_=3i~?Q3Re4*(+c
> zx-ZW=R^4JxTR{}q2<jEm54;z~yki;uZ133-?^)k_7ULWBp4BFM&)S_T<*tu;=aFCF
> zJ~!e%=ey61xzB~T&kfug<L<FL{p{?QM%*v??w7{gFNL^YvOAj+W^awVmjd^qgs1`I
> zlE;H3$2yzx7h6+;Ii^riMXRfB_}k6y=zROE|C;sU&;_6Jiz}&{Tj}ygpLicW`cwMh
> z`yYSw=;7}BAA`+wb7OtbRFa&R7@WWfOJI-1qVl`Q2~XIMual66v~Ct_Os~`|rq`<v
> z7&e3q14-Ab2DX}60!4MJxRFMrk#D56gj1<iWDiJ*$-lGhcPWe|h%cGf%}OSd%}@lv
> zQ5e%wdSmSmkuE=O!I7THWcIc46!x%u+`hhjTM}ms<w&tpCmL6yGY{PEmE&;(Mep$$
> z*M9SyWn;bPYSkEJ^vfKvaVlh($gh>BbxW_wVQDb;d0sho8HVn`I4RC>w<MiQ$X^MZ  
> zu5ma{KJ(5+hG>tu->ysD@_8zMJttG~=y@)LBiH0at8snPY9zuEow#1-g2jxz{Rw$_  
> zJTk5&=m+CUoPvqb*<aqJs=_UXA1qL;EV)PZg*8~sH&P0hL8jXcTBjY%L!o4#wf}*(
> zfaO~<i%v0<!v*rMJ5<WFs_LdhCVyiOsyed*+Ixu20!_s5augh&BMMWm`H{YYP<1WX
> zD|9dgx0_YY|M4UV5xjcgr%w;OJe?*^6HG=uOGHWa63wTHp`65n58%IF%>x8>I#l|7  
> zI#lQr0pB8SIC8)L&z}OzzkYoB&e=PGj$r+M|1Sa_XrWDi=~kvoI0eD2ENRxvOdh8o
> z=su($X*<C+NeS}u+s^kV-=8pvNbX5y*{lZ>`6>xc#e^1io(o>U3#Q?v=&fyZZ!I~q
> zQxe0NalGuz$`W4m@Ct|09kNjH>Tk~`+wR<2`<=cP1aQAt-NItY5gKo=qY<kyHAan6  
> zt$e=iUwQJM(^}ab#mZ!YOEPBjwv`<SxGoXUkSA+E&mZK(V2K9U9{+4*?*?xo7;k_D
> zY-Fgv5fEBiH4KCPPtax^YP@tGBZz|*yYp)+LoeePk8(sI1)Gd~D~Jh^bnFID3~drA
> zLI<RS|55zFLZCUylvwdN3s|Kv)|_CC31}<~x+GZfAPZQhLZO27f`DEKgDwkJyyge2
> zawt@=#sxGU2E8L#xq$Les9?pK3Ib5VpeuqkA)tv+s9;SBXfh1?u3()O(CJX9V8x4S
> z5bI1B^sZo41yl`%3f7c>roy1_3D#KwoehNwR{Ym7h;=Runis6ND+8z&3Kgsu1@vMV  
> zv>;e73FxIzs9>EJ(D^W^E?6%M=;ctTV0}$MUkig8g7u1kUI~Q?)&&7w2!j>{>+1sg  
> zdMH$|UKP-*VbC?f`i6kM5egNo*97$1B&b%qYCNblB3<RM#o&m#?0z?K*uv8Rg}Vbm
> zLIHbtV3A1>78M2Td4VNOg0QTjfPE{lv`HXK^01{~Pd>7+`3xlTv^=ztD{LVH8~M63  
> zw2?Dx1Opp+TN&EO9d74=jr_e!wwc40e+ZzA+fvAQ^r3ua#{=-l!VM<uc=tj1%&wA*
> zTSeH@zI<k1B^ire*xSB*X7@A3@)dSG1&=I!#7<dbAr9@7w=rU;%(0|~_B6>O_EnUz
> qIEMB%$!OQE(aj2fBcUHEXrb|V-eQA+!J``fG=la&-l7$y;r{_Geabxm
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
> index ac864fc982..dfb8523c8b 100644
> --- a/tests/qtest/bios-tables-test-allowed-diff.h
> +++ b/tests/qtest/bios-tables-test-allowed-diff.h
> @@ -1,2 +1 @@
>  /* List of comma-separated changed AML files to ignore */
> -"tests/data/acpi/pc/DSDT.roothp",



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus
  2020-09-11 18:07 ` [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Ani Sinha
@ 2020-09-14 12:21   ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 12:21 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Fri, 11 Sep 2020 23:37:50 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> When ACPI hotplug for the root bus is disabled, the bsel property for that
> bus is not set. Please see the following commit:
> 
> 3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus").
> 
> As a result, when acpi_pcihp_find_hotplug_bus() is called
> with bsel set to 0, it may return the root bus. This can cause devices attached to
> the root bus to get hot-unplugged if the user issues the following set of commmands:
> 
> outl 0xae10 0
> outl 0xae08 your_slot
> 
> Thanks to Julia for pointing this out here:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg734548.html
> 
> In this patch, we fix the issue in this function by checking if the bus which is
> returned by the function is actually hotpluggable. If not, we simply return NULL.
> This avoids the scenario where we were returning a non-hotpluggable bus.
> 

> This patch is based off of tag v5.10
I'd put this type of comment below --- or in cover letter
so it won't be committed into git history
 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/acpi/pcihp.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 39b1f74442..32ae8b2c0a 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -147,6 +147,21 @@ static PCIBus *acpi_pcihp_find_hotplug_bus(AcpiPciHpState *s, int bsel)
>      if (!bsel && !find.bus) {
>          find.bus = s->root;
>      }
> +
> +    /*
> +     * Check if find.bus is actually hotpluggable. If bsel is set to
> +     * NULL for example on the root bus in order to make it
> +     * non-hotpluggable, find.bus will match the root bus when bsel
> +     * is 0. See acpi_pcihp_test_hotplug_bus() above. Since the
> +     * bus is not hotpluggable however, we should not select the bus.
> +     * Instead, we should set find.bus to NULL in that case. In the check
> +     * below, we generalize this case for all buses, not just the root bus.
> +     * The callers of this function check for a null return value and
> +     * handle them appropriately.
> +     */
> +    if (find.bus && !qbus_is_hotpluggable(BUS(find.bus))) {
> +        find.bus = NULL;
> +    }
>      return find.bus;
>  }
>  



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges
  2020-09-11 18:07 ` [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Ani Sinha
@ 2020-09-14 12:36   ` Igor Mammedov
  2020-09-14 12:39     ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 12:36 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, jusual, qemu-devel,
	Paolo Bonzini, Richard Henderson

On Fri, 11 Sep 2020 23:37:51 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> Cold plugged bridges are not hot unpluggable, even when their hotplug
> property (acpi-pci-hotplug-with-bridge-support) is turned off. Please see
> the function acpi_pcihp_pc_no_hotplug() (thanks Julia). However, with
> the current implementaton, windows would try to hot-unplug a pci bridge when
> it's hotplug switch is off. This is regardless of whether there are devices
> attached to the bridge. This is because we add amls like _EJ0 etc for the
> pci slot where the bridge is cold plugged. We have a demo video here:
> https://youtu.be/pME2sjyQweo
> 
> In this fix, we identify a cold plugged bridge and for cold plugged bridges,
> we do not add the appropriate amls and acpi methods that are used by the OS
> to identify a hot-pluggable/unpluggable pci device. After this change, Windows
> does not show an option to eject the PCI bridge. A demo video is here:
> https://youtu.be/kbgej5B9Hgs
> 
> As a result of the patch, the following are the changes to the DSDT ACPI table:
> 
> @@ -858,38 +858,33 @@
>                      Return (Zero)
>                  }
> 
>                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                  {
>                      Return (Zero)
>                  }
>              }
> 
>              Device (S18)
>              {
> -                Name (_SUN, 0x03)  // _SUN: Slot User Number
>                  Name (_ADR, 0x00030000)  // _ADR: Address
> -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                {
> -                    PCEJ (BSEL, _SUN)
> -                }
>              }
> 
>              Device (S20)
>              {
>                  Name (_SUN, 0x04)  // _SUN: Slot User Number
>                  Name (_ADR, 0x00040000)  // _ADR: Address
>                  Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
>                  {
>                      PCEJ (BSEL, _SUN)
>                  }
>              }
> 
>              Device (S28)
>              {
>                  Name (_SUN, 0x05)  // _SUN: Slot User Number
>                  Name (_ADR, 0x00050000)  // _ADR: Address
> @@ -1148,37 +1143,32 @@
>                      PCEJ (BSEL, _SUN)
>                  }
>              }
> 
>              Device (SF8)
>              {
>                  Name (_SUN, 0x1F)  // _SUN: Slot User Number
>                  Name (_ADR, 0x001F0000)  // _ADR: Address
>                  Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
>                  {
>                      PCEJ (BSEL, _SUN)
>                  }
>              }
> 
>              Method (DVNT, 2, NotSerialized)
>              {
> -                If ((Arg0 & 0x08))
> -                {
> -                    Notify (S18, Arg1)
> -                }
> -
>                  If ((Arg0 & 0x10))
>                  {
>                      Notify (S20, Arg1)
>                  }
> 
>                  If ((Arg0 & 0x20))
>                  {
>                      Notify (S28, Arg1)
>                  }
> 
>                  If ((Arg0 & 0x40))
>                  {
>                      Notify (S30, Arg1)
>                  }
> 
>                  If ((Arg0 & 0x80))
> 
> While at it, I have also updated a stale comment.
> 
> This change is tested with a Windows 2012R2 guest image and Windows 2019 server
> guest image running on Ubuntu 18.04 host. This change is based off of upstream
> qemu master branch tag v5.1.0.
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/i386/acpi-build.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 7a5a8b3521..e079b686f5 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -359,6 +359,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>          int slot = PCI_SLOT(i);
>          bool hotplug_enabled_dev;
>          bool bridge_in_acpi;
> +        bool cold_plugged_bridge;
>  
>          if (!pdev) {
>              if (bsel) { /* add hotplug slots for non present devices */
> @@ -380,15 +381,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>          pc = PCI_DEVICE_GET_CLASS(pdev);
>          dc = DEVICE_GET_CLASS(pdev);
>  
> -        /* When hotplug for bridges is enabled, bridges are
> -         * described in ACPI separately (see build_pci_bus_end).
> -         * In this case they aren't themselves hot-pluggable.
> +        /*
> +         * Cold plugged bridges aren't themselves hot-pluggable.
>           * Hotplugged bridges *are* hot-pluggable.
>           */
> -        bridge_in_acpi = pc->is_bridge && pcihp_bridge_en &&
> -            !DEVICE(pdev)->hotplugged;
> +        cold_plugged_bridge = pc->is_bridge && !DEVICE(pdev)->hotplugged;
> +        bridge_in_acpi =  cold_plugged_bridge && pcihp_bridge_en;
>  
> -        hotplug_enabled_dev = bsel && dc->hotpluggable && !bridge_in_acpi;
> +        hotplug_enabled_dev = bsel && dc->hotpluggable && !cold_plugged_bridge;
>  
>          if (pc->class_id == PCI_CLASS_BRIDGE_ISA) {
>              continue;



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges
  2020-09-14 12:36   ` Igor Mammedov
@ 2020-09-14 12:39     ` Ani Sinha
  0 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 12:39 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Paolo Bonzini, Richard Henderson

On Mon, Sep 14, 2020 at 6:07 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Fri, 11 Sep 2020 23:37:51 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > Cold plugged bridges are not hot unpluggable, even when their hotplug
> > property (acpi-pci-hotplug-with-bridge-support) is turned off. Please see
> > the function acpi_pcihp_pc_no_hotplug() (thanks Julia). However, with
> > the current implementaton, windows would try to hot-unplug a pci bridge when
> > it's hotplug switch is off. This is regardless of whether there are devices
> > attached to the bridge. This is because we add amls like _EJ0 etc for the
> > pci slot where the bridge is cold plugged. We have a demo video here:
> > https://youtu.be/pME2sjyQweo
> >
> > In this fix, we identify a cold plugged bridge and for cold plugged bridges,
> > we do not add the appropriate amls and acpi methods that are used by the OS
> > to identify a hot-pluggable/unpluggable pci device. After this change, Windows
> > does not show an option to eject the PCI bridge. A demo video is here:
> > https://youtu.be/kbgej5B9Hgs
> >
> > As a result of the patch, the following are the changes to the DSDT ACPI table:
> >
> > @@ -858,38 +858,33 @@
> >                      Return (Zero)
> >                  }
> >
> >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> >                  {
> >                      Return (Zero)
> >                  }
> >
> >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> >                  {
> >                      Return (Zero)
> >                  }
> >              }
> >
> >              Device (S18)
> >              {
> > -                Name (_SUN, 0x03)  // _SUN: Slot User Number
> >                  Name (_ADR, 0x00030000)  // _ADR: Address
> > -                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> > -                {
> > -                    PCEJ (BSEL, _SUN)
> > -                }
> >              }
> >
> >              Device (S20)
> >              {
> >                  Name (_SUN, 0x04)  // _SUN: Slot User Number
> >                  Name (_ADR, 0x00040000)  // _ADR: Address
> >                  Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> >                  {
> >                      PCEJ (BSEL, _SUN)
> >                  }
> >              }
> >
> >              Device (S28)
> >              {
> >                  Name (_SUN, 0x05)  // _SUN: Slot User Number
> >                  Name (_ADR, 0x00050000)  // _ADR: Address
> > @@ -1148,37 +1143,32 @@
> >                      PCEJ (BSEL, _SUN)
> >                  }
> >              }
> >
> >              Device (SF8)
> >              {
> >                  Name (_SUN, 0x1F)  // _SUN: Slot User Number
> >                  Name (_ADR, 0x001F0000)  // _ADR: Address
> >                  Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> >                  {
> >                      PCEJ (BSEL, _SUN)
> >                  }
> >              }
> >
> >              Method (DVNT, 2, NotSerialized)
> >              {
> > -                If ((Arg0 & 0x08))
> > -                {
> > -                    Notify (S18, Arg1)
> > -                }
> > -
> >                  If ((Arg0 & 0x10))
> >                  {
> >                      Notify (S20, Arg1)
> >                  }
> >
> >                  If ((Arg0 & 0x20))
> >                  {
> >                      Notify (S28, Arg1)
> >                  }
> >
> >                  If ((Arg0 & 0x40))
> >                  {
> >                      Notify (S30, Arg1)
> >                  }
> >
> >                  If ((Arg0 & 0x80))
> >
> > While at it, I have also updated a stale comment.
> >
> > This change is tested with a Windows 2012R2 guest image and Windows 2019 server
> > guest image running on Ubuntu 18.04 host. This change is based off of upstream
> > qemu master branch tag v5.1.0.
> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Julia Suvorova <jusual@redhat.com>

From the previous thread.

>
> > ---
> >  hw/i386/acpi-build.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 7a5a8b3521..e079b686f5 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -359,6 +359,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> >          int slot = PCI_SLOT(i);
> >          bool hotplug_enabled_dev;
> >          bool bridge_in_acpi;
> > +        bool cold_plugged_bridge;
> >
> >          if (!pdev) {
> >              if (bsel) { /* add hotplug slots for non present devices */
> > @@ -380,15 +381,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> >          pc = PCI_DEVICE_GET_CLASS(pdev);
> >          dc = DEVICE_GET_CLASS(pdev);
> >
> > -        /* When hotplug for bridges is enabled, bridges are
> > -         * described in ACPI separately (see build_pci_bus_end).
> > -         * In this case they aren't themselves hot-pluggable.
> > +        /*
> > +         * Cold plugged bridges aren't themselves hot-pluggable.
> >           * Hotplugged bridges *are* hot-pluggable.
> >           */
> > -        bridge_in_acpi = pc->is_bridge && pcihp_bridge_en &&
> > -            !DEVICE(pdev)->hotplugged;
> > +        cold_plugged_bridge = pc->is_bridge && !DEVICE(pdev)->hotplugged;
> > +        bridge_in_acpi =  cold_plugged_bridge && pcihp_bridge_en;
> >
> > -        hotplug_enabled_dev = bsel && dc->hotpluggable && !bridge_in_acpi;
> > +        hotplug_enabled_dev = bsel && dc->hotpluggable && !cold_plugged_bridge;
> >
> >          if (pc->class_id == PCI_CLASS_BRIDGE_ISA) {
> >              continue;
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag
  2020-09-11 18:07 ` [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag Ani Sinha
@ 2020-09-14 12:42   ` Igor Mammedov
  2020-09-14 13:07     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 12:42 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	qemu-devel, Paolo Bonzini

On Fri, 11 Sep 2020 23:37:53 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> This change adds a new unit test for the global flag
> 'acpi-pci-hotplug-with-bridge-support' which is available for cold plugged pci
> bridges in i440fx. The flag can be used to turn off acpi based hotplug support
> for all the slots of the pci bus.
not true or not clear,
should be 
 "turn off acpi based hotplug support on all PCI bridges"

> Tested on the upstream qemu master branch.
Doesn't belong to commit message

> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  tests/qtest/bios-tables-test.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> index d8c7d57557..7632cfe1be 100644
> --- a/tests/qtest/bios-tables-test.c
> +++ b/tests/qtest/bios-tables-test.c
> @@ -754,6 +754,20 @@ static void test_acpi_piix4_root_hotplug(void)
>      free_test_data(&data);
>  }
>  
> +static void test_acpi_piix4_bridge_hotplug(void)
> +{
> +    test_data data;
> +
> +    memset(&data, 0, sizeof(data));
> +    data.machine = MACHINE_PC;
> +    data.variant = ".hpbridge";
> +    data.required_struct_types = base_required_struct_types;
> +    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
> +    test_acpi_one("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
> +                  "-device pci-bridge,chassis_nr=1", &data);
> +    free_test_data(&data);
> +}
> +
>  static void test_acpi_q35_tcg(void)
>  {
>      test_data data;
> @@ -1159,6 +1173,7 @@ int main(int argc, char *argv[])
>          qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
>          qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
>          qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
> +        qtest_add_func("acpi/piix4/brhotplug", test_acpi_piix4_bridge_hotplug);
>          qtest_add_func("acpi/q35", test_acpi_q35_tcg);
>          qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
>          qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag
  2020-09-11 18:07 ` [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag Ani Sinha
@ 2020-09-14 12:43   ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 12:43 UTC (permalink / raw)
  To: Ani Sinha; +Cc: jusual, qemu-devel, Michael S. Tsirkin

On Fri, 11 Sep 2020 23:37:54 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> This patch adds a binary blob corresponding to the DSDT acpi table. It is used
> to unit test the flag 'acpi-pci-hotplug-with-bridge-support' used with pci
> bridges.
> 
> This change also clears the file tests/qtest/bios-tables-test-allowed-diff.h
> so that future changes which affect the table can be caught.
> 
> The following is the diff between files tests/data/acpi/pc/DSDT.bridge and
> tests/data/acpi/pc/DSDT.hpbridge after disassembly :

Acked-by: Igor Mammedov <imammedo@redhat.com>

> 
> @@ -1,30 +1,30 @@
>  /*
>   * Intel ACPI Component Architecture
>   * AML/ASL+ Disassembler version 20180105 (64-bit version)
>   * Copyright (c) 2000 - 2018 Intel Corporation
>   *
>   * Disassembling to symbolic ASL+ operators
>   *
> - * Disassembly of tests/data/acpi/pc/DSDT.bridge, Fri Sep 11 23:21:34 2020
> + * Disassembly of /tmp/aml-7UURQ0, Fri Sep 11 23:21:34 2020
>   *
>   * Original Table Header:
>   *     Signature        "DSDT"
> - *     Length           0x00001A89 (6793)
> + *     Length           0x0000131F (4895)
>   *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
> - *     Checksum         0x09
> + *     Checksum         0xF9
>   *     OEM ID           "BOCHS "
>   *     OEM Table ID     "BXPCDSDT"
>   *     OEM Revision     0x00000001 (1)
>   *     Compiler ID      "BXPC"
>   *     Compiler Version 0x00000001 (1)
>   */
>  DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
>  {
>      Scope (\)
>      {
>          OperationRegion (DBG, SystemIO, 0x0402, One)
>          Field (DBG, ByteAcc, NoLock, Preserve)
>          {
>              DBGB,   8
>          }
> 
> @@ -859,522 +859,32 @@
>                  }
> 
>                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                  {
>                      Return (Zero)
>                  }
>              }
> 
>              Device (S18)
>              {
>                  Name (_ADR, 0x00030000)  // _ADR: Address
> -                Name (BSEL, One)
> -                Device (S00)
> -                {
> -                    Name (_SUN, Zero)  // _SUN: Slot User Number
> -                    Name (_ADR, Zero)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S08)
> -                {
> -                    Name (_SUN, One)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00010000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S10)
> -                {
> -                    Name (_SUN, 0x02)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00020000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S18)
> -                {
> -                    Name (_SUN, 0x03)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00030000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S20)
> -                {
> -                    Name (_SUN, 0x04)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00040000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S28)
> -                {
> -                    Name (_SUN, 0x05)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00050000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S30)
> -                {
> -                    Name (_SUN, 0x06)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00060000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S38)
> -                {
> -                    Name (_SUN, 0x07)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00070000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S40)
> -                {
> -                    Name (_SUN, 0x08)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00080000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S48)
> -                {
> -                    Name (_SUN, 0x09)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00090000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S50)
> -                {
> -                    Name (_SUN, 0x0A)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000A0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S58)
> -                {
> -                    Name (_SUN, 0x0B)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000B0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S60)
> -                {
> -                    Name (_SUN, 0x0C)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000C0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S68)
> -                {
> -                    Name (_SUN, 0x0D)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000D0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S70)
> -                {
> -                    Name (_SUN, 0x0E)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000E0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S78)
> -                {
> -                    Name (_SUN, 0x0F)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x000F0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S80)
> -                {
> -                    Name (_SUN, 0x10)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00100000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S88)
> -                {
> -                    Name (_SUN, 0x11)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00110000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S90)
> -                {
> -                    Name (_SUN, 0x12)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00120000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (S98)
> -                {
> -                    Name (_SUN, 0x13)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00130000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SA0)
> -                {
> -                    Name (_SUN, 0x14)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00140000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SA8)
> -                {
> -                    Name (_SUN, 0x15)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00150000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SB0)
> -                {
> -                    Name (_SUN, 0x16)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00160000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SB8)
> -                {
> -                    Name (_SUN, 0x17)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00170000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SC0)
> -                {
> -                    Name (_SUN, 0x18)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00180000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SC8)
> -                {
> -                    Name (_SUN, 0x19)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x00190000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SD0)
> -                {
> -                    Name (_SUN, 0x1A)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001A0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SD8)
> -                {
> -                    Name (_SUN, 0x1B)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001B0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SE0)
> -                {
> -                    Name (_SUN, 0x1C)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001C0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SE8)
> -                {
> -                    Name (_SUN, 0x1D)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001D0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SF0)
> -                {
> -                    Name (_SUN, 0x1E)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001E0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Device (SF8)
> -                {
> -                    Name (_SUN, 0x1F)  // _SUN: Slot User Number
> -                    Name (_ADR, 0x001F0000)  // _ADR: Address
> -                    Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -                    {
> -                        PCEJ (BSEL, _SUN)
> -                    }
> -                }
> -
> -                Method (DVNT, 2, NotSerialized)
> -                {
> -                    If ((Arg0 & One))
> -                    {
> -                        Notify (S00, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x02))
> -                    {
> -                        Notify (S08, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x04))
> -                    {
> -                        Notify (S10, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x08))
> -                    {
> -                        Notify (S18, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x10))
> -                    {
> -                        Notify (S20, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x20))
> -                    {
> -                        Notify (S28, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x40))
> -                    {
> -                        Notify (S30, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x80))
> -                    {
> -                        Notify (S38, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x0100))
> -                    {
> -                        Notify (S40, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x0200))
> -                    {
> -                        Notify (S48, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x0400))
> -                    {
> -                        Notify (S50, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x0800))
> -                    {
> -                        Notify (S58, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x1000))
> -                    {
> -                        Notify (S60, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x2000))
> -                    {
> -                        Notify (S68, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x4000))
> -                    {
> -                        Notify (S70, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x8000))
> -                    {
> -                        Notify (S78, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00010000))
> -                    {
> -                        Notify (S80, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00020000))
> -                    {
> -                        Notify (S88, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00040000))
> -                    {
> -                        Notify (S90, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00080000))
> -                    {
> -                        Notify (S98, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00100000))
> -                    {
> -                        Notify (SA0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00200000))
> -                    {
> -                        Notify (SA8, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00400000))
> -                    {
> -                        Notify (SB0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x00800000))
> -                    {
> -                        Notify (SB8, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x01000000))
> -                    {
> -                        Notify (SC0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x02000000))
> -                    {
> -                        Notify (SC8, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x04000000))
> -                    {
> -                        Notify (SD0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x08000000))
> -                    {
> -                        Notify (SD8, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x10000000))
> -                    {
> -                        Notify (SE0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x20000000))
> -                    {
> -                        Notify (SE8, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x40000000))
> -                    {
> -                        Notify (SF0, Arg1)
> -                    }
> -
> -                    If ((Arg0 & 0x80000000))
> -                    {
> -                        Notify (SF8, Arg1)
> -                    }
> -                }
> -
> -                Method (PCNT, 0, NotSerialized)
> -                {
> -                    BNUM = One
> -                    DVNT (PCIU, One)
> -                    DVNT (PCID, 0x03)
> -                }
>              }
> 
>              Device (S20)
>              {
>                  Name (_SUN, 0x04)  // _SUN: Slot User Number
>                  Name (_ADR, 0x00040000)  // _ADR: Address
>                  Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
>                  {
>                      PCEJ (BSEL, _SUN)
>                  }
>              }
> 
>              Device (S28)
>              {
>                  Name (_SUN, 0x05)  // _SUN: Slot User Number
>                  Name (_ADR, 0x00050000)  // _ADR: Address
> @@ -1779,22 +1289,21 @@
>                  If ((Arg0 & 0x40000000))
>                  {
>                      Notify (SF0, Arg1)
>                  }
> 
>                  If ((Arg0 & 0x80000000))
>                  {
>                      Notify (SF8, Arg1)
>                  }
>              }
> 
>              Method (PCNT, 0, NotSerialized)
>              {
>                  BNUM = Zero
>                  DVNT (PCIU, One)
>                  DVNT (PCID, 0x03)
> -                ^S18.PCNT ()
>              }
>          }
>      }
>  }
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  tests/data/acpi/pc/DSDT.hpbridge            | Bin 0 -> 4895 bytes
>  tests/qtest/bios-tables-test-allowed-diff.h |   1 -
>  2 files changed, 1 deletion(-)
>  create mode 100644 tests/data/acpi/pc/DSDT.hpbridge
> 
> diff --git a/tests/data/acpi/pc/DSDT.hpbridge b/tests/data/acpi/pc/DSDT.hpbridge
> new file mode 100644
> index 0000000000000000000000000000000000000000..b0751398541bdf88ce405be9742aeba0b375dbc3
> GIT binary patch
> literal 4895
> zcmb7IQE%Hu5}p+)hgwNCWixSVw~gQ=SF}AelAO9J?!^)*ONuR-5#`(+Xn>UM;^d-5
> ziL?Rg8pSCp;HG&ibUEC^J*a`6<Dby`3H=GZztF=qzL)A|NUf~MBG3vj#hLl`o0;9&
> z*_92;Xk1$WVE-#@>t!ol_>-v{sAB*?@AR!!<Xy1aMxo@ectmFQqqzT$kAkB8-YD#p
> z*gsnC-(B~!uU*#kVDFjwbg$`s_1N750zKUGIHwnN#jy&G-B~vEN=9+Y6(f=VflG>$
> zH|n4`I~4=esuEy|O4%$n1c)Js%yzqMHmZ;S_~Dm0$o3<Z<c0ginvpi^hLhIT9IKHB
> zk2J1Fs^%9iSKVIX+pY^;H$E8jp*Q<&w+Vl1Cg9)yjrO6>=M+b;Td5SEJ&9q)NDeZ<
> z5vad=hoYfy?aorg$~%6n=$>IH=Ix9g;Vzfe+Ttxq010JxZf_P01P3Wf7(GTM++5|C
> zOUwlq7%Q;@IKc0f2zs+SH>%q^qfv7UFO5=obOlsG<&_OXAI;w-oH+`9nO`ljpQN88
> zkW1`^^g;r*vJP*_K5=$q%gl>;-Y_cjX%%>sZ}SY}r#!-M;@>=9<^%o_|C!HmMR7Ka  
> zVrr3VQ~~3k2nu#5w`Df6B0V`+JN8nzDo>W!=hEkrqO7$27;^e{bu=c5Xk5@KW6q>A  
> z36vGpA9J(b&_@#zA7<)Pd*A_6R)FCum6h{lYMZ*%U~zcP6|4>tbX>ljG(L>9-L{H%
> zv5J-F9BU^|f?miJ@1mhltJYau4Gbjch1yOvZL`9bz6sh*Q!n0)*w;xK47?T@y(4xA
> zG~9lJ)O}EESbYUY-Q-j;n!z2j-T-et(sn&)J}bnYHhJ6oqRAt$=N&(2?g5uzzo&Nh
> z5fsCU+p29EaL~Ka-Dka2x5?#^+Jb}ck|QaPpj3CCM@E{$P$P{rIvjXk9_?`zu;$_M
> z0f2YhM1PMD7<dPd-6lM2_FenYjaw2$OJz$1&CL3}jDn9WJ#zF|RkVf5J)G5E?3lM(
> zxL;y@9@o|?_w;%U0rgC3mdC%DftX(`NAQGnJc`dsFaETJIk)J&PinifbqUkNVhr|1
> z0{0&6Yz61aN?qX#-^@Zxiei;<{EOq?5omM%rtVV^6rPrHjEV(c(mQYanmO77fC#<r
> z%ZrXxx7d?b5Ct}ZdWG~u?}Z8PScbpadv?rw*7u&p_{P0wwdvlocBe|Y>l5C2<Ttp_  
> zjk(YH?sF6Fb0O|?L-)p{d+biXI{Vcz_p849)d}~jA?{c0&bEx%Ta)hPz`ZCTYQVVU
> zv0%xu&Sw0@*5bh&Q>dt-)m69r?Phm$zI)z(&3bX<g3tKHmDJ6hborCdypJCKCH>%o  
> zPd|D1VE=<p!DhO-wK;4mNzO|QPT`a#u*YIi`Ca6cC+tVpNytN5H;Xl<S85j1>(%=V
> z8$yPGtm{<+Tg^OyB;6`*r4ec58)+@!RB9E)15#r0Z}0kD3S$Z4OXhX6lF4K<6hUwl
> zMzxgQ*!Xj#$Ga^!(KDIMp;n&39+r>U*LQEp;*6mjDR$~alWKJ4f!kZ^P8ukBkI%XG
> z8y75Fn|)WSMk%A;=7>#FA;VODtvst+dQAySgSpT0@vh4-bPpy;afW*(`9ebeO5k)&  
> z!g2DMcOf!Fd(8cAQ|^^7Qu*sSor+5rxe$(A(-W=6^lht=2upP8dR+(>GxiRr<mK_m
> zq?Vu`PAYK<rbcIfb%&}7w-|n~K(VrvKGhf2U^U-J#km3s-EPo2>tG&nN(NeoA8N~3
> zz9qBh6f-$oApg2UrA(`;Zp&oyH}<fqGi#u|kJv2GM2s#+!SOk!F!h=r=}QPz*Mhx5
> z2UBpnS?BzpkCPC=s~3I-^uWv0S>i0g6x6eXM5-5PK1+<`Bp!SK|M_|mAh6S+G8oXI
> zLZ1lu7IDK-27~W^2`vBm`N`YoV*(w)27|$01w7C~o4)B*rpq`5!L2N5*33*Ery%G)
> zq#tWL!8Iu!<mI=WA5VWgWipZ6mCdqQ4<_<u5}b-DE$ku}Jcs8@!%NYdyXf9pb>?Se
> zhB4#&ZD(GQ@uG)UIF#Nc3k9$K;e4{~&N~}_)Hi|v?iH&$SS&e0<Lz}kVl}EpsZpx6
> zk9Ykm&&J38S{1PSU>b2NlL@ZMD7<B5hXSrn1T<vJ8qoJ&a^hu`UhK}CmAw-TM6860  
> zH?15EwsvY9&k6jUfO;9Ud54-W-O0!!nSCgYC1_MYqhZih!HOqDz&aBO6|9#8^imk~
> zwqV8kbHJ*ELIrC~Kx1LhcLggKP#y{uthiV~0P!&BnqW-`Xd)CUSd#*p41>NWSZ4)v
> zHWVsY@dg;gIu{1LBUn`dRYReIH6@^_FzEY&bzVT{L!p8df0G5VE`&kzf)xurfNG&o
> z!FpLhFNZ-3g7u1kUI~Q?)<pqb41?-|^{Rkg4TTEUR|NExFsLC|mjrYv6e?Jk1#~$K
> zS`@6W3h1k$P{I0|fW8(6-4Lv=3+U^iP{DdlK(9@MYMV>O{aPc^OB}cG$JYrputQ%+
> zlW=D!tfPQUD6q6iAWQPN701)}#KKN8lp-XJY%)sN4~8~{q>+uB;jSLq$lKb;M(%KL
> z4sGP`J+jRmx3Hn&@o-|{9uqPi5GbG9@t8QVaJL9M-Vjhex2q&$-3xo#m(T6%Bx3~&
> zd)t@K?S95si^7hl#EGSk*(qzRs*#=YHpc9fIo8L>o+f$BzK$}k^vK>O8SUCNx_{t*  
> S66ohVtr{L;J8bx3aOwYF+mJl~
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
> index 96a9237355..dfb8523c8b 100644
> --- a/tests/qtest/bios-tables-test-allowed-diff.h
> +++ b/tests/qtest/bios-tables-test-allowed-diff.h
> @@ -1,2 +1 @@
>  /* List of comma-separated changed AML files to ignore */
> -"tests/data/acpi/pc/DSDT.hpbridge",



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-11 18:07 ` [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally Ani Sinha
@ 2020-09-14 13:05   ` Igor Mammedov
  2020-09-14 13:10     ` Ani Sinha
  2020-09-14 13:39     ` Ani Sinha
  0 siblings, 2 replies; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 13:05 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, jusual, qemu-devel,
	Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Fri, 11 Sep 2020 23:37:55 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> When acpi hotplug is turned off for both root pci bus as well as for pci
> bridges, we should not generate the related amls for DSDT table or initialize
> related hw ports or reserve hw resources. This change makes sure all those
> operations are turned off in the case acpi pci hotplug is off globally.

it still leaves around pure PCI hotplug ACPI code:
 
            Method (PCNT, 0, NotSerialized)                                      
            {                                                                    
            } 
> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  hw/acpi/piix4.c      |  6 ++++--
>  hw/i386/acpi-build.c | 10 ++++++++--
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index e6163bb6ce..b70b1f98af 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e079b686f5..7e3cf3b57b 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_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)
> @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_hpet_aml(dsdt);
>          build_piix4_isa_bridge(dsdt);
>          build_isa_devices_aml(dsdt);
> -        build_piix4_pci_hotplug(dsdt);
> +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> +            build_piix4_pci_hotplug(dsdt);
> +        }
>          build_piix4_pci0_int(dsdt);
>      } else {
>          sb_scope = aml_scope("_SB");
> @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>      crs_range_set_free(&crs_range_set);
>  
>      /* reserve PCIHP resources */
> -    if (pm->pcihp_io_len) {
> +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
>          dev = aml_device("PHPR");
>          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
>          aml_append(dev,



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag
  2020-09-14 12:42   ` Igor Mammedov
@ 2020-09-14 13:07     ` Igor Mammedov
  2020-09-14 13:42       ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 13:07 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	qemu-devel, Paolo Bonzini

On Mon, 14 Sep 2020 14:42:20 +0200
Igor Mammedov <imammedo@redhat.com> wrote:

> On Fri, 11 Sep 2020 23:37:53 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
> 
> > This change adds a new unit test for the global flag
> > 'acpi-pci-hotplug-with-bridge-support' which is available for cold plugged pci
> > bridges in i440fx. The flag can be used to turn off acpi based hotplug support
> > for all the slots of the pci bus.  
> not true or not clear,
> should be 
>  "turn off acpi based hotplug support on all PCI bridges"
> 
> > Tested on the upstream qemu master branch.  
> Doesn't belong to commit message

with above fixed:

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> > 
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  tests/qtest/bios-tables-test.c | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> > index d8c7d57557..7632cfe1be 100644
> > --- a/tests/qtest/bios-tables-test.c
> > +++ b/tests/qtest/bios-tables-test.c
> > @@ -754,6 +754,20 @@ static void test_acpi_piix4_root_hotplug(void)
> >      free_test_data(&data);
> >  }
> >  
> > +static void test_acpi_piix4_bridge_hotplug(void)
> > +{
> > +    test_data data;
> > +
> > +    memset(&data, 0, sizeof(data));
> > +    data.machine = MACHINE_PC;
> > +    data.variant = ".hpbridge";
> > +    data.required_struct_types = base_required_struct_types;
> > +    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
> > +    test_acpi_one("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
> > +                  "-device pci-bridge,chassis_nr=1", &data);
> > +    free_test_data(&data);
> > +}
> > +
> >  static void test_acpi_q35_tcg(void)
> >  {
> >      test_data data;
> > @@ -1159,6 +1173,7 @@ int main(int argc, char *argv[])
> >          qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
> >          qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
> >          qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
> > +        qtest_add_func("acpi/piix4/brhotplug", test_acpi_piix4_bridge_hotplug);
> >          qtest_add_func("acpi/q35", test_acpi_q35_tcg);
> >          qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
> >          qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);  
> 
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 13:05   ` Igor Mammedov
@ 2020-09-14 13:10     ` Ani Sinha
  2020-09-14 13:28       ` Ani Sinha
  2020-09-14 13:39     ` Ani Sinha
  1 sibling, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 13:10 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Fri, 11 Sep 2020 23:37:55 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > When acpi hotplug is turned off for both root pci bus as well as for pci
> > bridges, we should not generate the related amls for DSDT table or initialize
> > related hw ports or reserve hw resources. This change makes sure all those
> > operations are turned off in the case acpi pci hotplug is off globally.
>
> it still leaves around pure PCI hotplug ACPI code:
>
>             Method (PCNT, 0, NotSerialized)
>             {
>             }

How do you suggest we fix this?

> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  hw/acpi/piix4.c      |  6 ++++--
> >  hw/i386/acpi-build.c | 10 ++++++++--
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > index e6163bb6ce..b70b1f98af 100644
> > --- a/hw/acpi/piix4.c
> > +++ b/hw/acpi/piix4.c
> > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index e079b686f5..7e3cf3b57b 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_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)
> > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >          build_hpet_aml(dsdt);
> >          build_piix4_isa_bridge(dsdt);
> >          build_isa_devices_aml(dsdt);
> > -        build_piix4_pci_hotplug(dsdt);
> > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > +            build_piix4_pci_hotplug(dsdt);
> > +        }
> >          build_piix4_pci0_int(dsdt);
> >      } else {
> >          sb_scope = aml_scope("_SB");
> > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >      crs_range_set_free(&crs_range_set);
> >
> >      /* reserve PCIHP resources */
> > -    if (pm->pcihp_io_len) {
> > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> >          dev = aml_device("PHPR");
> >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> >          aml_append(dev,
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 13:10     ` Ani Sinha
@ 2020-09-14 13:28       ` Ani Sinha
  2020-09-14 14:09         ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 13:28 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Fri, 11 Sep 2020 23:37:55 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >
> > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > bridges, we should not generate the related amls for DSDT table or initialize
> > > related hw ports or reserve hw resources. This change makes sure all those
> > > operations are turned off in the case acpi pci hotplug is off globally.
> >
> > it still leaves around pure PCI hotplug ACPI code:
> >
> >             Method (PCNT, 0, NotSerialized)
> >             {
> >             }
>
> How do you suggest we fix this?

One way to fix this would be to do this:

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7e3cf3b57b..2bd0c37143 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
*parent_scope, PCIBus *bus,
             aml_append(method, aml_name("^S%.02X.PCNT", devfn));
         }
     }
-    aml_append(parent_scope, method);
+    if (bsel)
+        aml_append(parent_scope, method);
     qobject_unref(bsel);
 }

This means that if the hotplug on the root bus is disabled, we also
disable PCNT. This will also need the unit test update as the unit
test
will fail with :

@@ -3113,24 +3113,20 @@
                 Name (_ADR, 0x00010000)  // _ADR: Address
                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }
-
-            Method (PCNT, 0, NotSerialized)
-            {
-            }
         }
     }
 }

Let's fix this as a separate patch.

>
> > >
> > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > ---
> > >  hw/acpi/piix4.c      |  6 ++++--
> > >  hw/i386/acpi-build.c | 10 ++++++++--
> > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > index e6163bb6ce..b70b1f98af 100644
> > > --- a/hw/acpi/piix4.c
> > > +++ b/hw/acpi/piix4.c
> > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index e079b686f5..7e3cf3b57b 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_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)
> > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > >          build_hpet_aml(dsdt);
> > >          build_piix4_isa_bridge(dsdt);
> > >          build_isa_devices_aml(dsdt);
> > > -        build_piix4_pci_hotplug(dsdt);
> > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > +            build_piix4_pci_hotplug(dsdt);
> > > +        }
> > >          build_piix4_pci0_int(dsdt);
> > >      } else {
> > >          sb_scope = aml_scope("_SB");
> > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > >      crs_range_set_free(&crs_range_set);
> > >
> > >      /* reserve PCIHP resources */
> > > -    if (pm->pcihp_io_len) {
> > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > >          dev = aml_device("PHPR");
> > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > >          aml_append(dev,
> >


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 13:05   ` Igor Mammedov
  2020-09-14 13:10     ` Ani Sinha
@ 2020-09-14 13:39     ` Ani Sinha
  1 sibling, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 13:39 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Fri, 11 Sep 2020 23:37:55 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > When acpi hotplug is turned off for both root pci bus as well as for pci
> > bridges, we should not generate the related amls for DSDT table or initialize
> > related hw ports or reserve hw resources. This change makes sure all those
> > operations are turned off in the case acpi pci hotplug is off globally.
>
> it still leaves around pure PCI hotplug ACPI code:
>
>             Method (PCNT, 0, NotSerialized)
>             {
>             }

How about this comment?
" Add unconditionally for root since DSDT expects it."

Can this method then be removed when bsel is absent for the root bus?

> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  hw/acpi/piix4.c      |  6 ++++--
> >  hw/i386/acpi-build.c | 10 ++++++++--
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > index e6163bb6ce..b70b1f98af 100644
> > --- a/hw/acpi/piix4.c
> > +++ b/hw/acpi/piix4.c
> > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index e079b686f5..7e3cf3b57b 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_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)
> > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >          build_hpet_aml(dsdt);
> >          build_piix4_isa_bridge(dsdt);
> >          build_isa_devices_aml(dsdt);
> > -        build_piix4_pci_hotplug(dsdt);
> > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > +            build_piix4_pci_hotplug(dsdt);
> > +        }
> >          build_piix4_pci0_int(dsdt);
> >      } else {
> >          sb_scope = aml_scope("_SB");
> > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >      crs_range_set_free(&crs_range_set);
> >
> >      /* reserve PCIHP resources */
> > -    if (pm->pcihp_io_len) {
> > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> >          dev = aml_device("PHPR");
> >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> >          aml_append(dev,
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag
  2020-09-14 13:07     ` Igor Mammedov
@ 2020-09-14 13:42       ` Ani Sinha
  0 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 13:42 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Paolo Bonzini

On Mon, Sep 14, 2020 at 6:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Mon, 14 Sep 2020 14:42:20 +0200
> Igor Mammedov <imammedo@redhat.com> wrote:
>
> > On Fri, 11 Sep 2020 23:37:53 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >
> > > This change adds a new unit test for the global flag
> > > 'acpi-pci-hotplug-with-bridge-support' which is available for cold plugged pci
> > > bridges in i440fx. The flag can be used to turn off acpi based hotplug support
> > > for all the slots of the pci bus.
> > not true or not clear,
> > should be
> >  "turn off acpi based hotplug support on all PCI bridges"
> >
> > > Tested on the upstream qemu master branch.
> > Doesn't belong to commit message
>
> with above fixed:
>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>

I sent a v2

>
> > >
> > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > ---
> > >  tests/qtest/bios-tables-test.c | 15 +++++++++++++++
> > >  1 file changed, 15 insertions(+)
> > >
> > > diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> > > index d8c7d57557..7632cfe1be 100644
> > > --- a/tests/qtest/bios-tables-test.c
> > > +++ b/tests/qtest/bios-tables-test.c
> > > @@ -754,6 +754,20 @@ static void test_acpi_piix4_root_hotplug(void)
> > >      free_test_data(&data);
> > >  }
> > >
> > > +static void test_acpi_piix4_bridge_hotplug(void)
> > > +{
> > > +    test_data data;
> > > +
> > > +    memset(&data, 0, sizeof(data));
> > > +    data.machine = MACHINE_PC;
> > > +    data.variant = ".hpbridge";
> > > +    data.required_struct_types = base_required_struct_types;
> > > +    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
> > > +    test_acpi_one("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
> > > +                  "-device pci-bridge,chassis_nr=1", &data);
> > > +    free_test_data(&data);
> > > +}
> > > +
> > >  static void test_acpi_q35_tcg(void)
> > >  {
> > >      test_data data;
> > > @@ -1159,6 +1173,7 @@ int main(int argc, char *argv[])
> > >          qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
> > >          qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
> > >          qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
> > > +        qtest_add_func("acpi/piix4/brhotplug", test_acpi_piix4_bridge_hotplug);
> > >          qtest_add_func("acpi/q35", test_acpi_q35_tcg);
> > >          qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
> > >          qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
> >
> >
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 13:28       ` Ani Sinha
@ 2020-09-14 14:09         ` Igor Mammedov
  2020-09-14 14:50           ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-14 14:09 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, 14 Sep 2020 18:58:19 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> >
> > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > >
> > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > Ani Sinha <ani@anisinha.ca> wrote:
> > >  
> > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > operations are turned off in the case acpi pci hotplug is off globally.  
> > >
> > > it still leaves around pure PCI hotplug ACPI code:
> > >
> > >             Method (PCNT, 0, NotSerialized)
> > >             {
> > >             }  
> >
> > How do you suggest we fix this?  
> 
> One way to fix this would be to do this:
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 7e3cf3b57b..2bd0c37143 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
>              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
>          }
>      }
> -    aml_append(parent_scope, method);
> +    if (bsel)
> +        aml_append(parent_scope, method);
>      qobject_unref(bsel);
>  }
> 
> This means that if the hotplug on the root bus is disabled, we also
> disable PCNT. This will also need the unit test update as the unit
Does bridge hot-plug still work if we disable it only on root bus?

> test
> will fail with :
> 
> @@ -3113,24 +3113,20 @@
>                  Name (_ADR, 0x00010000)  // _ADR: Address
>                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                  {
>                      Return (Zero)
>                  }
> 
>                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                  {
>                      Return (Zero)
>                  }
>              }
> -
> -            Method (PCNT, 0, NotSerialized)
> -            {
> -            }
>          }
>      }
>  }
> 
> Let's fix this as a separate patch.

I'd rather fix up this patch, so it would do what it claims.

> >  
> > > >
> > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > ---
> > > >  hw/acpi/piix4.c      |  6 ++++--
> > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > index e6163bb6ce..b70b1f98af 100644
> > > > --- a/hw/acpi/piix4.c
> > > > +++ b/hw/acpi/piix4.c
> > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > >          build_hpet_aml(dsdt);
> > > >          build_piix4_isa_bridge(dsdt);
> > > >          build_isa_devices_aml(dsdt);
> > > > -        build_piix4_pci_hotplug(dsdt);
> > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > +            build_piix4_pci_hotplug(dsdt);
> > > > +        }
> > > >          build_piix4_pci0_int(dsdt);
> > > >      } else {
> > > >          sb_scope = aml_scope("_SB");
> > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > >      crs_range_set_free(&crs_range_set);
> > > >
> > > >      /* reserve PCIHP resources */
> > > > -    if (pm->pcihp_io_len) {
> > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > >          dev = aml_device("PHPR");
> > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > >          aml_append(dev,  
> > >  
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 14:09         ` Igor Mammedov
@ 2020-09-14 14:50           ` Ani Sinha
  2020-09-14 15:21             ` Ani Sinha
  2020-09-15 11:51             ` Igor Mammedov
  0 siblings, 2 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 14:50 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Mon, 14 Sep 2020 18:58:19 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > >
> > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >
> > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > >
> > > > it still leaves around pure PCI hotplug ACPI code:
> > > >
> > > >             Method (PCNT, 0, NotSerialized)
> > > >             {
> > > >             }
> > >
> > > How do you suggest we fix this?
> >
> > One way to fix this would be to do this:
> >
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 7e3cf3b57b..2bd0c37143 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > *parent_scope, PCIBus *bus,
> >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> >          }
> >      }
> > -    aml_append(parent_scope, method);
> > +    if (bsel)
> > +        aml_append(parent_scope, method);
> >      qobject_unref(bsel);
> >  }
> >
> > This means that if the hotplug on the root bus is disabled, we also
> > disable PCNT. This will also need the unit test update as the unit
> Does bridge hot-plug still work if we disable it only on root bus?

Just did a quick test. Windows seems to eject devices on the bridge
even when the root bus hot plug is off.

>
> > test
> > will fail with :
> >
> > @@ -3113,24 +3113,20 @@
> >                  Name (_ADR, 0x00010000)  // _ADR: Address
> >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> >                  {
> >                      Return (Zero)
> >                  }
> >
> >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> >                  {
> >                      Return (Zero)
> >                  }
> >
> >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> >                  {
> >                      Return (Zero)
> >                  }
> >              }
> > -
> > -            Method (PCNT, 0, NotSerialized)
> > -            {
> > -            }
> >          }
> >      }
> >  }
> >
> > Let's fix this as a separate patch.
>
> I'd rather fix up this patch, so it would do what it claims.
>
> > >
> > > > >
> > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > ---
> > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > --- a/hw/acpi/piix4.c
> > > > > +++ b/hw/acpi/piix4.c
> > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > >          build_hpet_aml(dsdt);
> > > > >          build_piix4_isa_bridge(dsdt);
> > > > >          build_isa_devices_aml(dsdt);
> > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > +        }
> > > > >          build_piix4_pci0_int(dsdt);
> > > > >      } else {
> > > > >          sb_scope = aml_scope("_SB");
> > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > >      crs_range_set_free(&crs_range_set);
> > > > >
> > > > >      /* reserve PCIHP resources */
> > > > > -    if (pm->pcihp_io_len) {
> > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > >          dev = aml_device("PHPR");
> > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > >          aml_append(dev,
> > > >
> >
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 14:50           ` Ani Sinha
@ 2020-09-14 15:21             ` Ani Sinha
  2020-09-14 15:41               ` Ani Sinha
  2020-09-15 11:51             ` Igor Mammedov
  1 sibling, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 15:21 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 8:20 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 14 Sep 2020 18:58:19 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >
> > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > >
> > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > >
> > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > >
> > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > >
> > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > >
> > > > >             Method (PCNT, 0, NotSerialized)
> > > > >             {
> > > > >             }
> > > >
> > > > How do you suggest we fix this?
> > >
> > > One way to fix this would be to do this:
> > >
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index 7e3cf3b57b..2bd0c37143 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > *parent_scope, PCIBus *bus,
> > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > >          }
> > >      }
> > > -    aml_append(parent_scope, method);
> > > +    if (bsel)
> > > +        aml_append(parent_scope, method);
> > >      qobject_unref(bsel);
> > >  }
> > >
> > > This means that if the hotplug on the root bus is disabled, we also
> > > disable PCNT. This will also need the unit test update as the unit
> > Does bridge hot-plug still work if we disable it only on root bus?
>
> Just did a quick test. Windows seems to eject devices on the bridge
> even when the root bus hot plug is off.

OK I am really confused! With the above change, the unit tests are
failing because of differences in tests/data/acpi/q35/DSDT !! Why is
q35 affected?

>
> >
> > > test
> > > will fail with :
> > >
> > > @@ -3113,24 +3113,20 @@
> > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >
> > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >
> > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >              }
> > > -
> > > -            Method (PCNT, 0, NotSerialized)
> > > -            {
> > > -            }
> > >          }
> > >      }
> > >  }
> > >
> > > Let's fix this as a separate patch.
> >
> > I'd rather fix up this patch, so it would do what it claims.
> >
> > > >
> > > > > >
> > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > ---
> > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > >
> > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > --- a/hw/acpi/piix4.c
> > > > > > +++ b/hw/acpi/piix4.c
> > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > >          build_hpet_aml(dsdt);
> > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > >          build_isa_devices_aml(dsdt);
> > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > +        }
> > > > > >          build_piix4_pci0_int(dsdt);
> > > > > >      } else {
> > > > > >          sb_scope = aml_scope("_SB");
> > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > >      crs_range_set_free(&crs_range_set);
> > > > > >
> > > > > >      /* reserve PCIHP resources */
> > > > > > -    if (pm->pcihp_io_len) {
> > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > >          dev = aml_device("PHPR");
> > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > >          aml_append(dev,
> > > > >
> > >
> >


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 15:21             ` Ani Sinha
@ 2020-09-14 15:41               ` Ani Sinha
  2020-09-15  7:02                 ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 15:41 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 8:51 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Mon, Sep 14, 2020 at 8:20 PM Ani Sinha <ani@anisinha.ca> wrote:
> >
> > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > >
> > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > >
> > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > >
> > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >
> > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > >
> > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > >
> > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > >             {
> > > > > >             }
> > > > >
> > > > > How do you suggest we fix this?
> > > >
> > > > One way to fix this would be to do this:
> > > >
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > --- a/hw/i386/acpi-build.c
> > > > +++ b/hw/i386/acpi-build.c
> > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > *parent_scope, PCIBus *bus,
> > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > >          }
> > > >      }
> > > > -    aml_append(parent_scope, method);
> > > > +    if (bsel)
> > > > +        aml_append(parent_scope, method);
> > > >      qobject_unref(bsel);
> > > >  }
> > > >
> > > > This means that if the hotplug on the root bus is disabled, we also
> > > > disable PCNT. This will also need the unit test update as the unit
> > > Does bridge hot-plug still work if we disable it only on root bus?
> >
> > Just did a quick test. Windows seems to eject devices on the bridge
> > even when the root bus hot plug is off.
>
> OK I am really confused! With the above change, the unit tests are
> failing because of differences in tests/data/acpi/q35/DSDT !! Why is
> q35 affected?

Following is the list of golden master tables which need to be
refreshed in order to make the change:

> > > > -    aml_append(parent_scope, method);
> > > > +    if (bsel)
> > > > +        aml_append(parent_scope, method);
> > > >      qobject_unref(bsel);

"tests/data/acpi/pc/DSDT.roothp",
"tests/data/acpi/q35/DSDT",
"tests/data/acpi/q35/DSDT.tis",
"tests/data/acpi/q35/DSDT.bridge",
"tests/data/acpi/q35/DSDT.mmio64",
"tests/data/acpi/q35/DSDT.ipmibt",
"tests/data/acpi/q35/DSDT.cphp",
"tests/data/acpi/q35/DSDT.memhp",
"tests/data/acpi/q35/DSDT.numamem",
"tests/data/acpi/q35/DSDT.dimmpxm",
"tests/data/acpi/q35/DSDT.acpihmat",

I am not sure if this is the right thing to do. The diff in every case is:

@@ -3413,24 +3413,20 @@
                 Name (_ADR, 0x00010000)  // _ADR: Address
                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                 {
                     Return (Zero)
                 }

                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                 {
                     Return (Zero)
                 }
             }
-
-            Method (PCNT, 0, NotSerialized)
-            {
-            }
         }
     }
 }

@Igor Mammedov  Please advice.

>
> >
> > >
> > > > test
> > > > will fail with :
> > > >
> > > > @@ -3113,24 +3113,20 @@
> > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >
> > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >
> > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >              }
> > > > -
> > > > -            Method (PCNT, 0, NotSerialized)
> > > > -            {
> > > > -            }
> > > >          }
> > > >      }
> > > >  }
> > > >
> > > > Let's fix this as a separate patch.
> > >
> > > I'd rather fix up this patch, so it would do what it claims.
> > >
> > > > >
> > > > > > >
> > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > ---
> > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > >
> > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > >          build_hpet_aml(dsdt);
> > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > +        }
> > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > >      } else {
> > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > >
> > > > > > >      /* reserve PCIHP resources */
> > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > >          dev = aml_device("PHPR");
> > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > >          aml_append(dev,
> > > > > >
> > > >
> > >


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 15:41               ` Ani Sinha
@ 2020-09-15  7:02                 ` Ani Sinha
  0 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-15  7:02 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, Sep 14, 2020 at 9:11 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Mon, Sep 14, 2020 at 8:51 PM Ani Sinha <ani@anisinha.ca> wrote:
> >
> > On Mon, Sep 14, 2020 at 8:20 PM Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > >
> > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >
> > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >
> > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > >
> > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > >
> > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > > >
> > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > >
> > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > >             {
> > > > > > >             }
> > > > > >
> > > > > > How do you suggest we fix this?
> > > > >
> > > > > One way to fix this would be to do this:
> > > > >
> > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > --- a/hw/i386/acpi-build.c
> > > > > +++ b/hw/i386/acpi-build.c
> > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > *parent_scope, PCIBus *bus,
> > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > >          }
> > > > >      }
> > > > > -    aml_append(parent_scope, method);
> > > > > +    if (bsel)
> > > > > +        aml_append(parent_scope, method);
> > > > >      qobject_unref(bsel);
> > > > >  }
> > > > >
> > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > disable PCNT. This will also need the unit test update as the unit
> > > > Does bridge hot-plug still work if we disable it only on root bus?
> > >
> > > Just did a quick test. Windows seems to eject devices on the bridge
> > > even when the root bus hot plug is off.
> >
> > OK I am really confused! With the above change, the unit tests are
> > failing because of differences in tests/data/acpi/q35/DSDT !! Why is
> > q35 affected?
>
> Following is the list of golden master tables which need to be
> refreshed in order to make the change:
>
> > > > > -    aml_append(parent_scope, method);
> > > > > +    if (bsel)
> > > > > +        aml_append(parent_scope, method);
> > > > >      qobject_unref(bsel);
>
> "tests/data/acpi/pc/DSDT.roothp",
> "tests/data/acpi/q35/DSDT",
> "tests/data/acpi/q35/DSDT.tis",
> "tests/data/acpi/q35/DSDT.bridge",
> "tests/data/acpi/q35/DSDT.mmio64",
> "tests/data/acpi/q35/DSDT.ipmibt",
> "tests/data/acpi/q35/DSDT.cphp",
> "tests/data/acpi/q35/DSDT.memhp",
> "tests/data/acpi/q35/DSDT.numamem",
> "tests/data/acpi/q35/DSDT.dimmpxm",
> "tests/data/acpi/q35/DSDT.acpihmat",
>
> I am not sure if this is the right thing to do. The diff in every case is:
>
> @@ -3413,24 +3413,20 @@
>                  Name (_ADR, 0x00010000)  // _ADR: Address
>                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
>                  {
>                      Return (Zero)
>                  }
>
>                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                  {
>                      Return (Zero)
>                  }
>
>                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                  {
>                      Return (Zero)
>                  }
>              }
> -
> -            Method (PCNT, 0, NotSerialized)
> -            {
> -            }
>          }
>      }
>  }
>
> @Igor Mammedov  Please advice.

I could be wrong but it seems bsel is not set for pci buses for q35.

>
> >
> > >
> > > >
> > > > > test
> > > > > will fail with :
> > > > >
> > > > > @@ -3113,24 +3113,20 @@
> > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >
> > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >
> > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >              }
> > > > > -
> > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > -            {
> > > > > -            }
> > > > >          }
> > > > >      }
> > > > >  }
> > > > >
> > > > > Let's fix this as a separate patch.
> > > >
> > > > I'd rather fix up this patch, so it would do what it claims.
> > > >
> > > > > >
> > > > > > > >
> > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > ---
> > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > >
> > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > +        }
> > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > >      } else {
> > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > >
> > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > >          dev = aml_device("PHPR");
> > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > >          aml_append(dev,
> > > > > > >
> > > > >
> > > >


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-14 14:50           ` Ani Sinha
  2020-09-14 15:21             ` Ani Sinha
@ 2020-09-15 11:51             ` Igor Mammedov
  2020-09-15 12:10               ` Ani Sinha
  1 sibling, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-15 11:51 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Mon, 14 Sep 2020 20:20:21 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 14 Sep 2020 18:58:19 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >  
> > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:  
> > > >
> > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > > >
> > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > >  
> > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > operations are turned off in the case acpi pci hotplug is off globally.  
> > > > >
> > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > >
> > > > >             Method (PCNT, 0, NotSerialized)
> > > > >             {
> > > > >             }  
> > > >
> > > > How do you suggest we fix this?  
> > >
> > > One way to fix this would be to do this:
> > >
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index 7e3cf3b57b..2bd0c37143 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > *parent_scope, PCIBus *bus,
> > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > >          }
> > >      }
> > > -    aml_append(parent_scope, method);
> > > +    if (bsel)
> > > +        aml_append(parent_scope, method);

and this also introduces mem leak


> > >      qobject_unref(bsel);
> > >  }
> > >
> > > This means that if the hotplug on the root bus is disabled, we also
> > > disable PCNT. This will also need the unit test update as the unit  
> > Does bridge hot-plug still work if we disable it only on root bus?  
> 
> Just did a quick test. Windows seems to eject devices on the bridge
> even when the root bus hot plug is off.

well I'm not sure it works using ACPI hotplug,

with
-global PIIX4_PM.acpi-root-pci-hotplug=off 
-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on

DSDT ins't what I'd expect when bridge hp is on:

    Scope (\_SB)
    {
        Scope (PCI0)
        {
            Device (S00)
            {
                Name (_ADR, Zero)  // _ADR: Address
            }

            Device (S08)
            {
                Name (_ADR, 0x00010000)  // _ADR: Address
                Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                {
                    Return (Zero)
                }

                Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
                {
                    Return (Zero)
                }

                Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
                {
                    Return (Zero)
                }
            }
        }
    }


> 
> >  
> > > test
> > > will fail with :
> > >
> > > @@ -3113,24 +3113,20 @@
> > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >
> > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >
> > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > >                  {
> > >                      Return (Zero)
> > >                  }
> > >              }
> > > -
> > > -            Method (PCNT, 0, NotSerialized)
> > > -            {
> > > -            }
> > >          }
> > >      }
> > >  }
> > >
> > > Let's fix this as a separate patch.  
> >
> > I'd rather fix up this patch, so it would do what it claims.
> >  
> > > >  
> > > > > >
> > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > ---
> > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > >
> > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > --- a/hw/acpi/piix4.c
> > > > > > +++ b/hw/acpi/piix4.c
> > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > >          build_hpet_aml(dsdt);
> > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > >          build_isa_devices_aml(dsdt);
> > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > +        }
> > > > > >          build_piix4_pci0_int(dsdt);
> > > > > >      } else {
> > > > > >          sb_scope = aml_scope("_SB");
> > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > >      crs_range_set_free(&crs_range_set);
> > > > > >
> > > > > >      /* reserve PCIHP resources */
> > > > > > -    if (pm->pcihp_io_len) {
> > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > >          dev = aml_device("PHPR");
> > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > >          aml_append(dev,  
> > > > >  
> > >  
> >  
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 11:51             ` Igor Mammedov
@ 2020-09-15 12:10               ` Ani Sinha
  2020-09-15 12:48                 ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-15 12:10 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Mon, 14 Sep 2020 20:20:21 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > >
> > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > >
> > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > >
> > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >
> > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > >
> > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > >
> > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > >             {
> > > > > >             }
> > > > >
> > > > > How do you suggest we fix this?
> > > >
> > > > One way to fix this would be to do this:
> > > >
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > --- a/hw/i386/acpi-build.c
> > > > +++ b/hw/i386/acpi-build.c
> > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > *parent_scope, PCIBus *bus,
> > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > >          }
> > > >      }
> > > > -    aml_append(parent_scope, method);
> > > > +    if (bsel)
> > > > +        aml_append(parent_scope, method);
>
> and this also introduces mem leak
>
>
> > > >      qobject_unref(bsel);
> > > >  }
> > > >
> > > > This means that if the hotplug on the root bus is disabled, we also
> > > > disable PCNT. This will also need the unit test update as the unit
> > > Does bridge hot-plug still work if we disable it only on root bus?
> >
> > Just did a quick test. Windows seems to eject devices on the bridge
> > even when the root bus hot plug is off.
>
> well I'm not sure it works using ACPI hotplug,
>
> with
> -global PIIX4_PM.acpi-root-pci-hotplug=off
> -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
>
> DSDT ins't what I'd expect when bridge hp is on:
>
>     Scope (\_SB)
>     {
>         Scope (PCI0)
>         {
>             Device (S00)
>             {
>                 Name (_ADR, Zero)  // _ADR: Address
>             }
>
>             Device (S08)

I think you should look for AMLs for Device (S18) because the bridge
goes into slot 3.

>             {
>                 Name (_ADR, 0x00010000)  // _ADR: Address
>                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
>                 {
>                     Return (Zero)
>                 }
>
>                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
>                 {
>                     Return (Zero)
>                 }
>
>                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
>                 {
>                     Return (Zero)
>                 }
>             }
>         }
>     }
>
>
> >
> > >
> > > > test
> > > > will fail with :
> > > >
> > > > @@ -3113,24 +3113,20 @@
> > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >
> > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >
> > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > >                  {
> > > >                      Return (Zero)
> > > >                  }
> > > >              }
> > > > -
> > > > -            Method (PCNT, 0, NotSerialized)
> > > > -            {
> > > > -            }
> > > >          }
> > > >      }
> > > >  }
> > > >
> > > > Let's fix this as a separate patch.
> > >
> > > I'd rather fix up this patch, so it would do what it claims.
> > >
> > > > >
> > > > > > >
> > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > ---
> > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > >
> > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > >          build_hpet_aml(dsdt);
> > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > +        }
> > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > >      } else {
> > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > >
> > > > > > >      /* reserve PCIHP resources */
> > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > >          dev = aml_device("PHPR");
> > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > >          aml_append(dev,
> > > > > >
> > > >
> > >
> >
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 12:10               ` Ani Sinha
@ 2020-09-15 12:48                 ` Igor Mammedov
  2020-09-15 12:55                   ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-15 12:48 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, 15 Sep 2020 17:40:25 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 14 Sep 2020 20:20:21 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >  
> > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > >
> > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >  
> > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:  
> > > > > >
> > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > > > > >
> > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > >  
> > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.  
> > > > > > >
> > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > >
> > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > >             {
> > > > > > >             }  
> > > > > >
> > > > > > How do you suggest we fix this?  
> > > > >
> > > > > One way to fix this would be to do this:
> > > > >
> > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > --- a/hw/i386/acpi-build.c
> > > > > +++ b/hw/i386/acpi-build.c
> > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > *parent_scope, PCIBus *bus,
> > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > >          }
> > > > >      }
> > > > > -    aml_append(parent_scope, method);
> > > > > +    if (bsel)
> > > > > +        aml_append(parent_scope, method);  
> >
> > and this also introduces mem leak
> >
> >  
> > > > >      qobject_unref(bsel);
> > > > >  }
> > > > >
> > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > disable PCNT. This will also need the unit test update as the unit  
> > > > Does bridge hot-plug still work if we disable it only on root bus?  
> > >
> > > Just did a quick test. Windows seems to eject devices on the bridge
> > > even when the root bus hot plug is off.  
> >
> > well I'm not sure it works using ACPI hotplug,
> >
> > with
> > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> >
> > DSDT ins't what I'd expect when bridge hp is on:
> >
> >     Scope (\_SB)
> >     {
> >         Scope (PCI0)
> >         {
> >             Device (S00)
> >             {
> >                 Name (_ADR, Zero)  // _ADR: Address
> >             }
> >
> >             Device (S08)  
> 
> I think you should look for AMLs for Device (S18) because the bridge
> goes into slot 3.

as you see, there weren't any here. so maybe something else gone wrong
in earlier patches

> 
> >             {
> >                 Name (_ADR, 0x00010000)  // _ADR: Address
> >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> >                 {
> >                     Return (Zero)
> >                 }
> >
> >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> >                 {
> >                     Return (Zero)
> >                 }
> >
> >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> >                 {
> >                     Return (Zero)
> >                 }
> >             }
> >         }
> >     }
> >
> >  
> > >  
> > > >  
> > > > > test
> > > > > will fail with :
> > > > >
> > > > > @@ -3113,24 +3113,20 @@
> > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >
> > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >
> > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > >                  {
> > > > >                      Return (Zero)
> > > > >                  }
> > > > >              }
> > > > > -
> > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > -            {
> > > > > -            }
> > > > >          }
> > > > >      }
> > > > >  }
> > > > >
> > > > > Let's fix this as a separate patch.  
> > > >
> > > > I'd rather fix up this patch, so it would do what it claims.
> > > >  
> > > > > >  
> > > > > > > >
> > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > ---
> > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > >
> > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > +        }
> > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > >      } else {
> > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > >
> > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > >          dev = aml_device("PHPR");
> > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > >          aml_append(dev,  
> > > > > > >  
> > > > >  
> > > >  
> > >  
> >  
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 12:48                 ` Igor Mammedov
@ 2020-09-15 12:55                   ` Ani Sinha
  2020-09-15 13:35                     ` Ani Sinha
  2020-09-15 13:42                     ` Igor Mammedov
  0 siblings, 2 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-15 12:55 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, Sep 15, 2020 at 6:19 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Tue, 15 Sep 2020 17:40:25 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > >
> > > On Mon, 14 Sep 2020 20:20:21 +0530
> > > Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > >
> > > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > >
> > > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > >
> > > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > > >
> > > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > >
> > > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > > > >
> > > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > > >
> > > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > > >             {
> > > > > > > >             }
> > > > > > >
> > > > > > > How do you suggest we fix this?
> > > > > >
> > > > > > One way to fix this would be to do this:
> > > > > >
> > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > > --- a/hw/i386/acpi-build.c
> > > > > > +++ b/hw/i386/acpi-build.c
> > > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > > *parent_scope, PCIBus *bus,
> > > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > > >          }
> > > > > >      }
> > > > > > -    aml_append(parent_scope, method);
> > > > > > +    if (bsel)
> > > > > > +        aml_append(parent_scope, method);
> > >
> > > and this also introduces mem leak
> > >
> > >
> > > > > >      qobject_unref(bsel);
> > > > > >  }
> > > > > >
> > > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > > disable PCNT. This will also need the unit test update as the unit
> > > > > Does bridge hot-plug still work if we disable it only on root bus?
> > > >
> > > > Just did a quick test. Windows seems to eject devices on the bridge
> > > > even when the root bus hot plug is off.
> > >
> > > well I'm not sure it works using ACPI hotplug,
> > >
> > > with
> > > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> > >
> > > DSDT ins't what I'd expect when bridge hp is on:
> > >
> > >     Scope (\_SB)
> > >     {
> > >         Scope (PCI0)
> > >         {
> > >             Device (S00)
> > >             {
> > >                 Name (_ADR, Zero)  // _ADR: Address
> > >             }
> > >
> > >             Device (S08)
> >
> > I think you should look for AMLs for Device (S18) because the bridge
> > goes into slot 3.
>
> as you see, there weren't any here. so maybe something else gone wrong
> in earlier patches

Can you send the full command line you are passing? You need to attach
a bridge, then the function will recurse into it.

>
> >
> > >             {
> > >                 Name (_ADR, 0x00010000)  // _ADR: Address
> > >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > >                 {
> > >                     Return (Zero)
> > >                 }
> > >
> > >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > >                 {
> > >                     Return (Zero)
> > >                 }
> > >
> > >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > >                 {
> > >                     Return (Zero)
> > >                 }
> > >             }
> > >         }
> > >     }
> > >
> > >
> > > >
> > > > >
> > > > > > test
> > > > > > will fail with :
> > > > > >
> > > > > > @@ -3113,24 +3113,20 @@
> > > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > >                  {
> > > > > >                      Return (Zero)
> > > > > >                  }
> > > > > >
> > > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > >                  {
> > > > > >                      Return (Zero)
> > > > > >                  }
> > > > > >
> > > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > >                  {
> > > > > >                      Return (Zero)
> > > > > >                  }
> > > > > >              }
> > > > > > -
> > > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > > -            {
> > > > > > -            }
> > > > > >          }
> > > > > >      }
> > > > > >  }
> > > > > >
> > > > > > Let's fix this as a separate patch.
> > > > >
> > > > > I'd rather fix up this patch, so it would do what it claims.
> > > > >
> > > > > > >
> > > > > > > > >
> > > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > > ---
> > > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > > >
> > > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > > +        }
> > > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > > >      } else {
> > > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > > >
> > > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > > >          dev = aml_device("PHPR");
> > > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > > >          aml_append(dev,
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 12:55                   ` Ani Sinha
@ 2020-09-15 13:35                     ` Ani Sinha
  2020-09-15 13:42                     ` Igor Mammedov
  1 sibling, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-15 13:35 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, Sep 15, 2020 at 6:25 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Tue, Sep 15, 2020 at 6:19 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Tue, 15 Sep 2020 17:40:25 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >
> > > On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > >
> > > > On Mon, 14 Sep 2020 20:20:21 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >
> > > > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > >
> > > > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >
> > > > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > >
> > > > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > > > >
> > > > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > >
> > > > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > > > > >
> > > > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > > > >
> > > > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > > > >             {
> > > > > > > > >             }
> > > > > > > >
> > > > > > > > How do you suggest we fix this?
> > > > > > >
> > > > > > > One way to fix this would be to do this:
> > > > > > >
> > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > > > --- a/hw/i386/acpi-build.c
> > > > > > > +++ b/hw/i386/acpi-build.c
> > > > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > > > *parent_scope, PCIBus *bus,
> > > > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > > > >          }
> > > > > > >      }
> > > > > > > -    aml_append(parent_scope, method);
> > > > > > > +    if (bsel)
> > > > > > > +        aml_append(parent_scope, method);
> > > >
> > > > and this also introduces mem leak
> > > >
> > > >
> > > > > > >      qobject_unref(bsel);
> > > > > > >  }
> > > > > > >
> > > > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > > > disable PCNT. This will also need the unit test update as the unit
> > > > > > Does bridge hot-plug still work if we disable it only on root bus?
> > > > >
> > > > > Just did a quick test. Windows seems to eject devices on the bridge
> > > > > even when the root bus hot plug is off.
> > > >
> > > > well I'm not sure it works using ACPI hotplug,
> > > >
> > > > with
> > > > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > > > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> > > >
> > > > DSDT ins't what I'd expect when bridge hp is on:
> > > >
> > > >     Scope (\_SB)
> > > >     {
> > > >         Scope (PCI0)
> > > >         {
> > > >             Device (S00)
> > > >             {
> > > >                 Name (_ADR, Zero)  // _ADR: Address
> > > >             }
> > > >
> > > >             Device (S08)
> > >
> > > I think you should look for AMLs for Device (S18) because the bridge
> > > goes into slot 3.
> >
> > as you see, there weren't any here. so maybe something else gone wrong
> > in earlier patches
>
> Can you send the full command line you are passing? You need to attach
> a bridge, then the function will recurse into it.
Just to be clear, the AMLs will be added for every slot on the bridge.
So you need to attach a bridge to see them.

>
> >
> > >
> > > >             {
> > > >                 Name (_ADR, 0x00010000)  // _ADR: Address
> > > >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >
> > > >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >
> > > >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >             }
> > > >         }
> > > >     }
> > > >
> > > >
> > > > >
> > > > > >
> > > > > > > test
> > > > > > > will fail with :
> > > > > > >
> > > > > > > @@ -3113,24 +3113,20 @@
> > > > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >
> > > > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >
> > > > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >              }
> > > > > > > -
> > > > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > > > -            {
> > > > > > > -            }
> > > > > > >          }
> > > > > > >      }
> > > > > > >  }
> > > > > > >
> > > > > > > Let's fix this as a separate patch.
> > > > > >
> > > > > > I'd rather fix up this patch, so it would do what it claims.
> > > > > >
> > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > > > ---
> > > > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > > > >
> > > > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > +        }
> > > > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > > > >      } else {
> > > > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > > > >
> > > > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > > > >          dev = aml_device("PHPR");
> > > > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > > > >          aml_append(dev,
> > > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 12:55                   ` Ani Sinha
  2020-09-15 13:35                     ` Ani Sinha
@ 2020-09-15 13:42                     ` Igor Mammedov
  2020-09-15 14:03                       ` Ani Sinha
  1 sibling, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2020-09-15 13:42 UTC (permalink / raw)
  To: Ani Sinha
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, 15 Sep 2020 18:25:55 +0530
Ani Sinha <ani@anisinha.ca> wrote:

> On Tue, Sep 15, 2020 at 6:19 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Tue, 15 Sep 2020 17:40:25 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >  
> > > On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > >
> > > > On Mon, 14 Sep 2020 20:20:21 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >  
> > > > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > > > >
> > > > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >  
> > > > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:  
> > > > > > > >
> > > > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:  
> > > > > > > > >
> > > > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > >  
> > > > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.  
> > > > > > > > >
> > > > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > > > >
> > > > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > > > >             {
> > > > > > > > >             }  
> > > > > > > >
> > > > > > > > How do you suggest we fix this?  
> > > > > > >
> > > > > > > One way to fix this would be to do this:
> > > > > > >
> > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > > > --- a/hw/i386/acpi-build.c
> > > > > > > +++ b/hw/i386/acpi-build.c
> > > > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > > > *parent_scope, PCIBus *bus,
> > > > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > > > >          }
> > > > > > >      }
> > > > > > > -    aml_append(parent_scope, method);
> > > > > > > +    if (bsel)
> > > > > > > +        aml_append(parent_scope, method);  
> > > >
> > > > and this also introduces mem leak
> > > >
> > > >  
> > > > > > >      qobject_unref(bsel);
> > > > > > >  }
> > > > > > >
> > > > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > > > disable PCNT. This will also need the unit test update as the unit  
> > > > > > Does bridge hot-plug still work if we disable it only on root bus?  
> > > > >
> > > > > Just did a quick test. Windows seems to eject devices on the bridge
> > > > > even when the root bus hot plug is off.  
> > > >
> > > > well I'm not sure it works using ACPI hotplug,
> > > >
> > > > with
> > > > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > > > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> > > >
> > > > DSDT ins't what I'd expect when bridge hp is on:
> > > >
> > > >     Scope (\_SB)
> > > >     {
> > > >         Scope (PCI0)
> > > >         {
> > > >             Device (S00)
> > > >             {
> > > >                 Name (_ADR, Zero)  // _ADR: Address
> > > >             }
> > > >
> > > >             Device (S08)  
> > >
> > > I think you should look for AMLs for Device (S18) because the bridge
> > > goes into slot 3.  
> >
> > as you see, there weren't any here. so maybe something else gone wrong
> > in earlier patches  
> 
> Can you send the full command line you are passing? You need to attach
> a bridge, then the function will recurse into it.

all your 9 pathes with this on top:

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7e3cf3b57b..8339a3538a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             aml_append(method, aml_name("^S%.02X.PCNT", devfn));
         }
     }
-    aml_append(parent_scope, method);
+    if (bsel)
+       aml_append(parent_scope, method);
     qobject_unref(bsel);
 }
 
diff --git a/slirp b/slirp
--- a/slirp
+++ b/slirp
@@ -1 +1 @@
-Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275
+Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275-dirty
diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 7632cfe1be..fb56c1eeb0 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -750,7 +750,7 @@ static void test_acpi_piix4_root_hotplug(void)
     data.required_struct_types = base_required_struct_types;
     data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
     test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
-                  "-device pci-bridge,chassis_nr=1", &data);
+                  "-device pci-bridge,chassis_nr=1 -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on", &data);
     free_test_data(&data);
 }
 

and run test with:

make -j32 && make tests/qtest/bios-tables-test && V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/qtest/bios-tables-test

> 
> >  
> > >  
> > > >             {
> > > >                 Name (_ADR, 0x00010000)  // _ADR: Address
> > > >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >
> > > >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >
> > > >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > >                 {
> > > >                     Return (Zero)
> > > >                 }
> > > >             }
> > > >         }
> > > >     }
> > > >
> > > >  
> > > > >  
> > > > > >  
> > > > > > > test
> > > > > > > will fail with :
> > > > > > >
> > > > > > > @@ -3113,24 +3113,20 @@
> > > > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >
> > > > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >
> > > > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > > >                  {
> > > > > > >                      Return (Zero)
> > > > > > >                  }
> > > > > > >              }
> > > > > > > -
> > > > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > > > -            {
> > > > > > > -            }
> > > > > > >          }
> > > > > > >      }
> > > > > > >  }
> > > > > > >
> > > > > > > Let's fix this as a separate patch.  
> > > > > >
> > > > > > I'd rather fix up this patch, so it would do what it claims.
> > > > > >  
> > > > > > > >  
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > > > ---
> > > > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > > > >
> > > > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > +        }
> > > > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > > > >      } else {
> > > > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > > > >
> > > > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > > > >          dev = aml_device("PHPR");
> > > > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > > > >          aml_append(dev,  
> > > > > > > > >  
> > > > > > >  
> > > > > >  
> > > > >  
> > > >  
> > >  
> >  
> 



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 13:42                     ` Igor Mammedov
@ 2020-09-15 14:03                       ` Ani Sinha
  2020-09-15 14:45                         ` Ani Sinha
  0 siblings, 1 reply; 37+ messages in thread
From: Ani Sinha @ 2020-09-15 14:03 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, Sep 15, 2020 at 7:12 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Tue, 15 Sep 2020 18:25:55 +0530
> Ani Sinha <ani@anisinha.ca> wrote:
>
> > On Tue, Sep 15, 2020 at 6:19 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > >
> > > On Tue, 15 Sep 2020 17:40:25 +0530
> > > Ani Sinha <ani@anisinha.ca> wrote:
> > >
> > > > On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > >
> > > > > On Mon, 14 Sep 2020 20:20:21 +0530
> > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > >
> > > > > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > >
> > > > > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > >
> > > > > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > >
> > > > > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > > > > >
> > > > > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > > >
> > > > > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > > > > > >
> > > > > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > > > > >
> > > > > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > > > > >             {
> > > > > > > > > >             }
> > > > > > > > >
> > > > > > > > > How do you suggest we fix this?
> > > > > > > >
> > > > > > > > One way to fix this would be to do this:
> > > > > > > >
> > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > > > > --- a/hw/i386/acpi-build.c
> > > > > > > > +++ b/hw/i386/acpi-build.c
> > > > > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > > > > *parent_scope, PCIBus *bus,
> > > > > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > > > > >          }
> > > > > > > >      }
> > > > > > > > -    aml_append(parent_scope, method);
> > > > > > > > +    if (bsel)
> > > > > > > > +        aml_append(parent_scope, method);
> > > > >
> > > > > and this also introduces mem leak
> > > > >
> > > > >
> > > > > > > >      qobject_unref(bsel);
> > > > > > > >  }
> > > > > > > >
> > > > > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > > > > disable PCNT. This will also need the unit test update as the unit
> > > > > > > Does bridge hot-plug still work if we disable it only on root bus?
> > > > > >
> > > > > > Just did a quick test. Windows seems to eject devices on the bridge
> > > > > > even when the root bus hot plug is off.
> > > > >
> > > > > well I'm not sure it works using ACPI hotplug,
> > > > >
> > > > > with
> > > > > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > > > > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> > > > >
> > > > > DSDT ins't what I'd expect when bridge hp is on:
> > > > >
> > > > >     Scope (\_SB)
> > > > >     {
> > > > >         Scope (PCI0)
> > > > >         {
> > > > >             Device (S00)
> > > > >             {
> > > > >                 Name (_ADR, Zero)  // _ADR: Address
> > > > >             }
> > > > >
> > > > >             Device (S08)
> > > >
> > > > I think you should look for AMLs for Device (S18) because the bridge
> > > > goes into slot 3.
> > >
> > > as you see, there weren't any here. so maybe something else gone wrong
> > > in earlier patches
> >
> > Can you send the full command line you are passing? You need to attach
> > a bridge, then the function will recurse into it.
>
> all your 9 pathes with this on top:
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 7e3cf3b57b..8339a3538a 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
>          }
>      }
> -    aml_append(parent_scope, method);
> +    if (bsel)
> +       aml_append(parent_scope, method);
>      qobject_unref(bsel);
>  }
>
> diff --git a/slirp b/slirp
> --- a/slirp
> +++ b/slirp
> @@ -1 +1 @@
> -Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275
> +Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275-dirty
> diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> index 7632cfe1be..fb56c1eeb0 100644
> --- a/tests/qtest/bios-tables-test.c
> +++ b/tests/qtest/bios-tables-test.c
> @@ -750,7 +750,7 @@ static void test_acpi_piix4_root_hotplug(void)
>      data.required_struct_types = base_required_struct_types;
>      data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
>      test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
> -                  "-device pci-bridge,chassis_nr=1", &data);
> +                  "-device pci-bridge,chassis_nr=1 -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on", &data);

That's a noop since by default its ON.

I ran the test and it passed. The disassembly of
tests/data/acpi/pc/DSDT.roothp is here:

https://pastebin.ubuntu.com/p/52VS6HRPx8/

Seems OK to me. The table for the bridge slots starts from line 871.

>      free_test_data(&data);
>  }
>
>
> and run test with:
>
> make -j32 && make tests/qtest/bios-tables-test && V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/qtest/bios-tables-test
>
> >
> > >
> > > >
> > > > >             {
> > > > >                 Name (_ADR, 0x00010000)  // _ADR: Address
> > > > >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > >                 {
> > > > >                     Return (Zero)
> > > > >                 }
> > > > >
> > > > >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > >                 {
> > > > >                     Return (Zero)
> > > > >                 }
> > > > >
> > > > >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > >                 {
> > > > >                     Return (Zero)
> > > > >                 }
> > > > >             }
> > > > >         }
> > > > >     }
> > > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > > > test
> > > > > > > > will fail with :
> > > > > > > >
> > > > > > > > @@ -3113,24 +3113,20 @@
> > > > > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > > > >                  {
> > > > > > > >                      Return (Zero)
> > > > > > > >                  }
> > > > > > > >
> > > > > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > > > >                  {
> > > > > > > >                      Return (Zero)
> > > > > > > >                  }
> > > > > > > >
> > > > > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > > > >                  {
> > > > > > > >                      Return (Zero)
> > > > > > > >                  }
> > > > > > > >              }
> > > > > > > > -
> > > > > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > > > > -            {
> > > > > > > > -            }
> > > > > > > >          }
> > > > > > > >      }
> > > > > > > >  }
> > > > > > > >
> > > > > > > > Let's fix this as a separate patch.
> > > > > > >
> > > > > > > I'd rather fix up this patch, so it would do what it claims.
> > > > > > >
> > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > > > > ---
> > > > > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > > > > >
> > > > > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > > +        }
> > > > > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > > > > >      } else {
> > > > > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > > > > >
> > > > > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > > > > >          dev = aml_device("PHPR");
> > > > > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > > > > >          aml_append(dev,
> > > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally
  2020-09-15 14:03                       ` Ani Sinha
@ 2020-09-15 14:45                         ` Ani Sinha
  0 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-15 14:45 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, Michael S. Tsirkin, Julia Suvorova,
	QEMU Developers, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Paolo Bonzini, Aurelien Jarno,
	Richard Henderson

On Tue, Sep 15, 2020 at 7:33 PM Ani Sinha <ani@anisinha.ca> wrote:
>
> On Tue, Sep 15, 2020 at 7:12 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Tue, 15 Sep 2020 18:25:55 +0530
> > Ani Sinha <ani@anisinha.ca> wrote:
> >
> > > On Tue, Sep 15, 2020 at 6:19 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > >
> > > > On Tue, 15 Sep 2020 17:40:25 +0530
> > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > >
> > > > > On Tue, Sep 15, 2020 at 5:21 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > >
> > > > > > On Mon, 14 Sep 2020 20:20:21 +0530
> > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > >
> > > > > > > On Mon, Sep 14, 2020 at 7:39 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > > >
> > > > > > > > On Mon, 14 Sep 2020 18:58:19 +0530
> > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > >
> > > > > > > > > On Mon, Sep 14, 2020 at 6:40 PM Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > > >
> > > > > > > > > > On Mon, Sep 14, 2020 at 6:36 PM Igor Mammedov <imammedo@redhat.com> wrote:
> > > > > > > > > > >
> > > > > > > > > > > On Fri, 11 Sep 2020 23:37:55 +0530
> > > > > > > > > > > Ani Sinha <ani@anisinha.ca> wrote:
> > > > > > > > > > >
> > > > > > > > > > > > When acpi hotplug is turned off for both root pci bus as well as for pci
> > > > > > > > > > > > bridges, we should not generate the related amls for DSDT table or initialize
> > > > > > > > > > > > related hw ports or reserve hw resources. This change makes sure all those
> > > > > > > > > > > > operations are turned off in the case acpi pci hotplug is off globally.
> > > > > > > > > > >
> > > > > > > > > > > it still leaves around pure PCI hotplug ACPI code:
> > > > > > > > > > >
> > > > > > > > > > >             Method (PCNT, 0, NotSerialized)
> > > > > > > > > > >             {
> > > > > > > > > > >             }
> > > > > > > > > >
> > > > > > > > > > How do you suggest we fix this?
> > > > > > > > >
> > > > > > > > > One way to fix this would be to do this:
> > > > > > > > >
> > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > index 7e3cf3b57b..2bd0c37143 100644
> > > > > > > > > --- a/hw/i386/acpi-build.c
> > > > > > > > > +++ b/hw/i386/acpi-build.c
> > > > > > > > > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml
> > > > > > > > > *parent_scope, PCIBus *bus,
> > > > > > > > >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> > > > > > > > >          }
> > > > > > > > >      }
> > > > > > > > > -    aml_append(parent_scope, method);
> > > > > > > > > +    if (bsel)
> > > > > > > > > +        aml_append(parent_scope, method);
> > > > > >
> > > > > > and this also introduces mem leak
> > > > > >
> > > > > >
> > > > > > > > >      qobject_unref(bsel);
> > > > > > > > >  }
> > > > > > > > >
> > > > > > > > > This means that if the hotplug on the root bus is disabled, we also
> > > > > > > > > disable PCNT. This will also need the unit test update as the unit
> > > > > > > > Does bridge hot-plug still work if we disable it only on root bus?
> > > > > > >
> > > > > > > Just did a quick test. Windows seems to eject devices on the bridge
> > > > > > > even when the root bus hot plug is off.
> > > > > >
> > > > > > well I'm not sure it works using ACPI hotplug,
> > > > > >
> > > > > > with
> > > > > > -global PIIX4_PM.acpi-root-pci-hotplug=off
> > > > > > -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
> > > > > >
> > > > > > DSDT ins't what I'd expect when bridge hp is on:
> > > > > >
> > > > > >     Scope (\_SB)
> > > > > >     {
> > > > > >         Scope (PCI0)
> > > > > >         {
> > > > > >             Device (S00)
> > > > > >             {
> > > > > >                 Name (_ADR, Zero)  // _ADR: Address
> > > > > >             }
> > > > > >
> > > > > >             Device (S08)
> > > > >
> > > > > I think you should look for AMLs for Device (S18) because the bridge
> > > > > goes into slot 3.
> > > >
> > > > as you see, there weren't any here. so maybe something else gone wrong
> > > > in earlier patches
> > >
> > > Can you send the full command line you are passing? You need to attach
> > > a bridge, then the function will recurse into it.
> >
> > all your 9 pathes with this on top:
> >
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 7e3cf3b57b..8339a3538a 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -483,7 +483,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> >              aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> >          }
> >      }
> > -    aml_append(parent_scope, method);
> > +    if (bsel)
> > +       aml_append(parent_scope, method);
> >      qobject_unref(bsel);
> >  }
> >
> > diff --git a/slirp b/slirp
> > --- a/slirp
> > +++ b/slirp
> > @@ -1 +1 @@
> > -Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275
> > +Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275-dirty
> > diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> > index 7632cfe1be..fb56c1eeb0 100644
> > --- a/tests/qtest/bios-tables-test.c
> > +++ b/tests/qtest/bios-tables-test.c
> > @@ -750,7 +750,7 @@ static void test_acpi_piix4_root_hotplug(void)
> >      data.required_struct_types = base_required_struct_types;
> >      data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
> >      test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
> > -                  "-device pci-bridge,chassis_nr=1", &data);
> > +                  "-device pci-bridge,chassis_nr=1 -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on", &data);
>
> That's a noop since by default its ON.
>
> I ran the test and it passed. The disassembly of
> tests/data/acpi/pc/DSDT.roothp is here:
>
> https://pastebin.ubuntu.com/p/52VS6HRPx8/
>
> Seems OK to me. The table for the bridge slots starts from line 871.

I just sent v2 for the entire patch set. I have updated patch #7 and
patch #9. Can you try again with the updated patch #9? I think it's OK
now. Maybe the previous patch had an issue.

>
> >      free_test_data(&data);
> >  }
> >
> >
> > and run test with:
> >
> > make -j32 && make tests/qtest/bios-tables-test && V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/qtest/bios-tables-test
> >
> > >
> > > >
> > > > >
> > > > > >             {
> > > > > >                 Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > >                 Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > >                 {
> > > > > >                     Return (Zero)
> > > > > >                 }
> > > > > >
> > > > > >                 Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > >                 {
> > > > > >                     Return (Zero)
> > > > > >                 }
> > > > > >
> > > > > >                 Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > >                 {
> > > > > >                     Return (Zero)
> > > > > >                 }
> > > > > >             }
> > > > > >         }
> > > > > >     }
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > > test
> > > > > > > > > will fail with :
> > > > > > > > >
> > > > > > > > > @@ -3113,24 +3113,20 @@
> > > > > > > > >                  Name (_ADR, 0x00010000)  // _ADR: Address
> > > > > > > > >                  Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
> > > > > > > > >                  {
> > > > > > > > >                      Return (Zero)
> > > > > > > > >                  }
> > > > > > > > >
> > > > > > > > >                  Method (_S2D, 0, NotSerialized)  // _S2D: S2 Device State
> > > > > > > > >                  {
> > > > > > > > >                      Return (Zero)
> > > > > > > > >                  }
> > > > > > > > >
> > > > > > > > >                  Method (_S3D, 0, NotSerialized)  // _S3D: S3 Device State
> > > > > > > > >                  {
> > > > > > > > >                      Return (Zero)
> > > > > > > > >                  }
> > > > > > > > >              }
> > > > > > > > > -
> > > > > > > > > -            Method (PCNT, 0, NotSerialized)
> > > > > > > > > -            {
> > > > > > > > > -            }
> > > > > > > > >          }
> > > > > > > > >      }
> > > > > > > > >  }
> > > > > > > > >
> > > > > > > > > Let's fix this as a separate patch.
> > > > > > > >
> > > > > > > > I'd rather fix up this patch, so it would do what it claims.
> > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > > > > > > > > > > ---
> > > > > > > > > > > >  hw/acpi/piix4.c      |  6 ++++--
> > > > > > > > > > > >  hw/i386/acpi-build.c | 10 ++++++++--
> > > > > > > > > > > >  2 files changed, 12 insertions(+), 4 deletions(-)
> > > > > > > > > > > >
> > > > > > > > > > > > diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> > > > > > > > > > > > index e6163bb6ce..b70b1f98af 100644
> > > > > > > > > > > > --- a/hw/acpi/piix4.c
> > > > > > > > > > > > +++ b/hw/acpi/piix4.c
> > > > > > > > > > > > @@ -596,8 +596,10 @@ 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_hotplug_bridge || s->use_acpi_root_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",
> > > > > > > > > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > > > > > > > > index e079b686f5..7e3cf3b57b 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_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)
> > > > > > > > > > > > @@ -1504,7 +1508,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > > > >          build_hpet_aml(dsdt);
> > > > > > > > > > > >          build_piix4_isa_bridge(dsdt);
> > > > > > > > > > > >          build_isa_devices_aml(dsdt);
> > > > > > > > > > > > -        build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > > > +        if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> > > > > > > > > > > > +            build_piix4_pci_hotplug(dsdt);
> > > > > > > > > > > > +        }
> > > > > > > > > > > >          build_piix4_pci0_int(dsdt);
> > > > > > > > > > > >      } else {
> > > > > > > > > > > >          sb_scope = aml_scope("_SB");
> > > > > > > > > > > > @@ -1698,7 +1704,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> > > > > > > > > > > >      crs_range_set_free(&crs_range_set);
> > > > > > > > > > > >
> > > > > > > > > > > >      /* reserve PCIHP resources */
> > > > > > > > > > > > -    if (pm->pcihp_io_len) {
> > > > > > > > > > > > +    if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
> > > > > > > > > > > >          dev = aml_device("PHPR");
> > > > > > > > > > > >          aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> > > > > > > > > > > >          aml_append(dev,
> > > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus
@ 2020-09-14 12:18 Ani Sinha
  0 siblings, 0 replies; 37+ messages in thread
From: Ani Sinha @ 2020-09-14 12:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, jusual,
	Paolo Bonzini, Ani Sinha, Igor Mammedov

Ability to turn hotplug off on the pci root bus for i440fx was added in commit:
3d7e78aa7777f0 ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")

This change adds a unit test in order to test this feature.

This change has been tested against upstream qemu master branch tip.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/qtest/bios-tables-test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

changelog:
v1: initial patch
v2:  updated comment to reflect that the patch was tested against qemu master branch tip.

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 504b810af5..d8c7d57557 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -740,6 +740,20 @@ static void test_acpi_piix4_tcg_bridge(void)
     free_test_data(&data);
 }
 
+static void test_acpi_piix4_root_hotplug(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_PC;
+    data.variant = ".roothp";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+    test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
+                  "-device pci-bridge,chassis_nr=1", &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_q35_tcg(void)
 {
     test_data data;
@@ -1144,6 +1158,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tcg_tpm_tis);
         qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
         qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
+        qtest_add_func("acpi/piix4/hotplug", test_acpi_piix4_root_hotplug);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
         qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-09-15 14:52 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 18:07 [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Ani Sinha
2020-09-11 18:07 ` [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha
2020-09-14 11:57   ` Igor Mammedov
2020-09-11 18:07 ` [PATCH 3/9] tests/acpi: add a new ACPI table in order to test root pci hotplug on/off Ani Sinha
2020-09-14 11:58   ` Igor Mammedov
2020-09-11 18:07 ` [PATCH 4/9] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Ani Sinha
2020-09-14 12:21   ` Igor Mammedov
2020-09-11 18:07 ` [PATCH 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Ani Sinha
2020-09-14 12:36   ` Igor Mammedov
2020-09-14 12:39     ` Ani Sinha
2020-09-11 18:07 ` [PATCH 6/9] tests/acpi: list added acpi table binary file for pci bridge hotplug test Ani Sinha
2020-09-11 18:07 ` [PATCH 7/9] tests/acpi: unit test for 'acpi-pci-hotplug-with-bridge-support' bridge flag Ani Sinha
2020-09-14 12:42   ` Igor Mammedov
2020-09-14 13:07     ` Igor Mammedov
2020-09-14 13:42       ` Ani Sinha
2020-09-11 18:07 ` [PATCH 8/9] tests/acpi: add newly added acpi DSDT table blob for pci bridge hotplug flag Ani Sinha
2020-09-14 12:43   ` Igor Mammedov
2020-09-11 18:07 ` [PATCH 9/9] piix4: don't reserve hw resources when hotplug is off globally Ani Sinha
2020-09-14 13:05   ` Igor Mammedov
2020-09-14 13:10     ` Ani Sinha
2020-09-14 13:28       ` Ani Sinha
2020-09-14 14:09         ` Igor Mammedov
2020-09-14 14:50           ` Ani Sinha
2020-09-14 15:21             ` Ani Sinha
2020-09-14 15:41               ` Ani Sinha
2020-09-15  7:02                 ` Ani Sinha
2020-09-15 11:51             ` Igor Mammedov
2020-09-15 12:10               ` Ani Sinha
2020-09-15 12:48                 ` Igor Mammedov
2020-09-15 12:55                   ` Ani Sinha
2020-09-15 13:35                     ` Ani Sinha
2020-09-15 13:42                     ` Igor Mammedov
2020-09-15 14:03                       ` Ani Sinha
2020-09-15 14:45                         ` Ani Sinha
2020-09-14 13:39     ` Ani Sinha
2020-09-14 11:45 ` [PATCH 1/9] tests/acpi: document addition of table DSDT.roothp for unit testing root pci hotplug on/off Igor Mammedov
2020-09-14 12:18 [PATCH 2/9] tests/acpi: add a new unit test to test hotplug off/on feature on the root pci bus Ani Sinha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.