diff mbox series

[v2,1/1] hw/i386/acpi-build: add OSHP method support for SHPC driver load

Message ID 20240625035224.13019-1-gaoshiyuan@baidu.com (mailing list archive)
State New
Headers show
Series [v2,1/1] hw/i386/acpi-build: add OSHP method support for SHPC driver load | expand

Commit Message

Shiyuan Gao June 25, 2024, 3:52 a.m. UTC
SHPC driver will be loaded fail in i440fx machine, the dmesg shows
that OS cannot get control of SHPC hotplug and hotplug device to
the PCI bridge will fail when we use SHPC Native type:

  [3.336059] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S28_)
  [3.337408] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
  [3.338710] shpchp 0000:00:03.0: Cannot get control of SHPC hotplug

Add OSHP method support for transfer control to the operating system,
after this SHPC driver will be loaded success and the hotplug device to
the PCI bridge will success when we use SHPC Native type.

  [1.703975] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S18_)
  [1.704934] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
  [1.705855] shpchp 0000:00:03.0: Gained control of SHPC hotplug (\_SB_.PCI0)
  [1.707054] shpchp 0000:00:03.0: HPC vendor_id 1b36 device_id 1 ss_vid 0 ss_did 0

Signed-off-by: Shiyuan Gao <gaoshiyuan@baidu.com>
---
v1 -> v2:
* add quote PCI firmware spec 3.0
* explain why an empty method is enough
---

 hw/i386/acpi-build.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Igor Mammedov June 27, 2024, 1:45 p.m. UTC | #1
On Tue, 25 Jun 2024 11:52:24 +0800
Shiyuan Gao <gaoshiyuan@baidu.com> wrote:

> SHPC driver will be loaded fail in i440fx machine, the dmesg shows
> that OS cannot get control of SHPC hotplug and hotplug device to
> the PCI bridge will fail when we use SHPC Native type:
> 
>   [3.336059] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S28_)
>   [3.337408] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
>   [3.338710] shpchp 0000:00:03.0: Cannot get control of SHPC hotplug
> 
> Add OSHP method support for transfer control to the operating system,
> after this SHPC driver will be loaded success and the hotplug device to
> the PCI bridge will success when we use SHPC Native type.
> 
>   [1.703975] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S18_)
>   [1.704934] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
>   [1.705855] shpchp 0000:00:03.0: Gained control of SHPC hotplug (\_SB_.PCI0)
>   [1.707054] shpchp 0000:00:03.0: HPC vendor_id 1b36 device_id 1 ss_vid 0 ss_did 0

please describe in commit message reproducer
(aka QEMU CLI and guest OS and if necessary other details)


> Signed-off-by: Shiyuan Gao <gaoshiyuan@baidu.com>
> ---
> v1 -> v2:
> * add quote PCI firmware spec 3.0
> * explain why an empty method is enough
> ---
> 
>  hw/i386/acpi-build.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index f4e366f64f..00f8abedf6 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1412,6 +1412,23 @@ static void build_acpi0017(Aml *table)
>      aml_append(table, scope);
>  }
>  
> +/*
> + * PCI Firmware Specification 3.0
> + * 4.8. The OSHP Control Method
> + */
> +static Aml *build_oshp_method(void)
> +{
> +    Aml *method;
> +
> +    /*
> +     * We don't use ACPI to control the SHPC, so just return
> +     * success is enough.
> +     */
> +    method = aml_method("OSHP", 0, AML_NOTSERIALIZED);
> +    aml_append(method, aml_return(aml_int(0x0)));
> +    return method;
> +}
> +
>  static void
>  build_dsdt(GArray *table_data, BIOSLinker *linker,
>             AcpiPmInfo *pm, AcpiMiscInfo *misc,
> @@ -1452,6 +1469,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
>          aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
>          aml_append(dev, aml_pci_edsm());
> +        aml_append(dev, build_oshp_method());

it's global and what will happen if we have ACPI PCI hotplug enabled
and guest calls this NOP method?

>          aml_append(sb_scope, dev);
>          aml_append(dsdt, sb_scope);
>  
> @@ -1586,6 +1604,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>                  aml_append(dev, build_q35_osc_method(true));
>              } else {
>                  aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
> +                aml_append(dev, build_oshp_method());
>              }
>  
>              if (numa_node != NUMA_NODE_UNASSIGNED) {
shiju.jose--- via June 28, 2024, 3:04 a.m. UTC | #2
> > that OS cannot get control of SHPC hotplug and hotplug device to
> > the PCI bridge will fail when we use SHPC Native type:
> >
> >   [3.336059] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S28_)
> >   [3.337408] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
> >   [3.338710] shpchp 0000:00:03.0: Cannot get control of SHPC hotplug
> >
> > Add OSHP method support for transfer control to the operating system,
> > after this SHPC driver will be loaded success and the hotplug device to
> > the PCI bridge will success when we use SHPC Native type.
> >
> >   [1.703975] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S18_)
> >   [1.704934] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
> >   [1.705855] shpchp 0000:00:03.0: Gained control of SHPC hotplug (\_SB_.PCI0)
> >   [1.707054] shpchp 0000:00:03.0: HPC vendor_id 1b36 device_id 1 ss_vid 0 ss_did 0
>
> please describe in commit message reproducer
> (aka QEMU CLI and guest OS and if necessary other details)

qemu-system-x86_64 -machine pc-q35-9.0
    ...
    -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

guest OS: centos7/ubuntu22.04

I will add it in the next version.

> > +/*
> > + * PCI Firmware Specification 3.0
> > + * 4.8. The OSHP Control Method
> > + */
> > +static Aml *build_oshp_method(void)
> > +{
> > +    Aml *method;
> > +
> > +    /*
> > +     * We don't use ACPI to control the SHPC, so just return
> > +     * success is enough.
> > +     */
> > +    method = aml_method("OSHP", 0, AML_NOTSERIALIZED);
> > +    aml_append(method, aml_return(aml_int(0x0)));
> > +    return method;
> > +}
> > +
> >  static void
> >  build_dsdt(GArray *table_data, BIOSLinker *linker,
> >             AcpiPmInfo *pm, AcpiMiscInfo *misc,
> > @@ -1452,6 +1469,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >          aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
> >          aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
> >          aml_append(dev, aml_pci_edsm());
> > +        aml_append(dev, build_oshp_method());
>
> it's global and what will happen if we have ACPI PCI hotplug enabled
> and guest calls this NOP method?

ths OS get the control of SHPC hotplug and SHPC driver load fail later.

[    6.170345] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S18_)
[    6.171962] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
[    6.173556] shpchp 0000:00:03.0: Gained control of SHPC hotplug (\_SB_.PCI0)
[    6.175144] shpchp 0000:00:03.0: HPC vendor_id 1b36 device_id 1 ss_vid 0 ss_did 0
[    6.196153] shpchp 0000:00:03.0: irq 24 for MSI/MSI-X
[    6.197211] shpchp 0000:00:03.0: pci_hp_register failed with error -16
[    6.198272] shpchp 0000:00:03.0: Slot initialization failed

this looks more suitable.

+    if (!pm->pcihp_bridge_en) {
+        aml_append(dev, build_i440fx_oshp_method());
+    }

>
> >          aml_append(sb_scope, dev);
> >          aml_append(dsdt, sb_scope);
> >
> > @@ -1586,6 +1604,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >                  aml_append(dev, build_q35_osc_method(true));
> >              } else {
> >                  aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
> > +                aml_append(dev, build_oshp_method());
> >              }
> >
> >              if (numa_node != NUMA_NODE_UNASSIGNED) {

Hot plug/unplug a device using SHPC will take more time than ACPI PCI hotplug, because
after pressing the button, it can be cancelled within 5 seconds in SHPC driver.

If I want to use ACPI PCI hotplug in the pxb bridge, what else need to be done?

thanks.
shiju.jose--- via June 28, 2024, 3:12 a.m. UTC | #3
> > > that OS cannot get control of SHPC hotplug and hotplug device to
> > > the PCI bridge will fail when we use SHPC Native type:
> > >
> > >   [3.336059] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S28_)
> > >   [3.337408] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
> > >   [3.338710] shpchp 0000:00:03.0: Cannot get control of SHPC hotplug
> > >
> > > Add OSHP method support for transfer control to the operating system,
> > > after this SHPC driver will be loaded success and the hotplug device to
> > > the PCI bridge will success when we use SHPC Native type.
> > >
> > >   [1.703975] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0.S18_)
> > >   [1.704934] shpchp 0000:00:03.0: Requesting control of SHPC hotplug via OSHP (\_SB_.PCI0)
> > >   [1.705855] shpchp 0000:00:03.0: Gained control of SHPC hotplug (\_SB_.PCI0)
> > >   [1.707054] shpchp 0000:00:03.0: HPC vendor_id 1b36 device_id 1 ss_vid 0 ss_did 0
> >
> > please describe in commit message reproducer
> > (aka QEMU CLI and guest OS and if necessary other details)
>
> qemu-system-x86_64 -machine pc-q35-9.0

sorry, it is -machine pc-i440fx-9.0

>     ...
>     -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
>
diff mbox series

Patch

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f4e366f64f..00f8abedf6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1412,6 +1412,23 @@  static void build_acpi0017(Aml *table)
     aml_append(table, scope);
 }
 
+/*
+ * PCI Firmware Specification 3.0
+ * 4.8. The OSHP Control Method
+ */
+static Aml *build_oshp_method(void)
+{
+    Aml *method;
+
+    /*
+     * We don't use ACPI to control the SHPC, so just return
+     * success is enough.
+     */
+    method = aml_method("OSHP", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_return(aml_int(0x0)));
+    return method;
+}
+
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker,
            AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1452,6 +1469,7 @@  build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
         aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
         aml_append(dev, aml_pci_edsm());
+        aml_append(dev, build_oshp_method());
         aml_append(sb_scope, dev);
         aml_append(dsdt, sb_scope);
 
@@ -1586,6 +1604,7 @@  build_dsdt(GArray *table_data, BIOSLinker *linker,
                 aml_append(dev, build_q35_osc_method(true));
             } else {
                 aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
+                aml_append(dev, build_oshp_method());
             }
 
             if (numa_node != NUMA_NODE_UNASSIGNED) {