qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ani Sinha <ani@anisinha.ca>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>, Ani Sinha <ani@anisinha.ca>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Eduardo Habkost <eduardo@habkost.net>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: qemu-devel@nongnu.org, kkostiuk@redhat.com, yvugenfi@redhat.com,
	yiwei@redhat.com, ybendito@redhat.com, jusual@redhat.com
Subject: [RFC PATCH] hw/acpi: do not let OSPM set pcie native hotplug when acpi hotplug is enabled
Date: Mon,  5 Sep 2022 12:55:31 +0530	[thread overview]
Message-ID: <20220905072531.8059-1-ani@anisinha.ca> (raw)

Possible fix for https://bugzilla.redhat.com/show_bug.cgi?id=2089545

Change in AML:

@@ -47,33 +47,39 @@
     Scope (_SB)
     {
         Device (PCI0)
         {
             Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */)  // _HID: Hardware ID
             Name (_CID, EisaId ("PNP0A03") /* PCI Bus */)  // _CID: Compatible ID
             Name (_ADR, Zero)  // _ADR: Address
             Name (_UID, Zero)  // _UID: Unique ID
             Method (_OSC, 4, NotSerialized)  // _OSC: Operating System Capabilities
             {
                 CreateDWordField (Arg3, Zero, CDW1)
                 If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */))
                 {
                     CreateDWordField (Arg3, 0x04, CDW2)
                     CreateDWordField (Arg3, 0x08, CDW3)
                     Local0 = CDW3 /* \_SB_.PCI0._OSC.CDW3 */
-                    Local0 &= 0x1E
+                    Local0 &= 0x1F
+                    Local1 = (CDW3 & One)
+                    If ((One == Local1))
+                    {
+                        CDW1 |= 0x12
+                    }
+
                     If ((Arg1 != One))
                     {
                         CDW1 |= 0x08
                     }

                     If ((CDW3 != Local0))
                     {
                         CDW1 |= 0x10
                     }

                     CDW3 = Local0
                 }
                 Else
                 {
                     CDW1 |= 0x04
                 }
**

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

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 0355bd3dda..3dc9379f27 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1348,10 +1348,12 @@ static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
 {
     Aml *if_ctx;
     Aml *if_ctx2;
+    Aml *if_ctx3;
     Aml *else_ctx;
     Aml *method;
     Aml *a_cwd1 = aml_name("CDW1");
     Aml *a_ctrl = aml_local(0);
+    Aml *a_pcie_nhp_ctl = aml_local(1);
 
     method = aml_method("_OSC", 4, AML_NOTSERIALIZED);
     aml_append(method, aml_create_dword_field(aml_arg(3), aml_int(0), "CDW1"));
@@ -1366,11 +1368,26 @@ static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
     /*
      * Always allow native PME, AER (no dependencies)
      * Allow SHPC (PCI bridges can have SHPC controller)
-     * Disable PCIe Native Hot-plug if ACPI PCI Hot-plug is enabled.
      */
-    aml_append(if_ctx, aml_and(a_ctrl,
-        aml_int(0x1E | (enable_native_pcie_hotplug ? 0x1 : 0x0)), a_ctrl));
+    aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl));
 
+    /*
+     * if ACPI PCI Hot-plug is enabled, do not let OSPM set OSC PCIE
+     * Native hotplug ctrl bit.
+     */
+    if (!enable_native_pcie_hotplug) {
+        /* check if the ACPI native hotplug bit is set by the OS in DWORD3 */
+        aml_append(if_ctx, aml_and(aml_name("CDW3"),
+                                   aml_int(0x01), a_pcie_nhp_ctl));
+        if_ctx3 = aml_if(aml_equal(aml_int(1), a_pcie_nhp_ctl));
+        /*
+         * ACPI spec 5.1, section 6.2.11
+         * bit 1 in first DWORD - _OSC failure
+         * bit 4 in first DWORD - capabilities masked
+         */
+        aml_append(if_ctx3, aml_or(a_cwd1, aml_int(0x12), a_cwd1));
+        aml_append(if_ctx, if_ctx3);
+    }
     if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1))));
     /* Unknown revision */
     aml_append(if_ctx2, aml_or(a_cwd1, aml_int(0x08), a_cwd1));
-- 
2.34.1



             reply	other threads:[~2022-09-05  7:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  7:25 Ani Sinha [this message]
2022-09-05 10:53 ` [RFC PATCH] hw/acpi: do not let OSPM set pcie native hotplug when acpi hotplug is enabled Michael S. Tsirkin
2022-09-05 12:57   ` Ani Sinha
2022-09-05 15:52 ` Igor Mammedov
2022-09-05 16:50   ` Ani Sinha
2022-09-05 16:55     ` Ani Sinha
2022-09-06  7:39       ` Igor Mammedov
2022-09-06  7:45         ` Ani Sinha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220905072531.8059-1-ani@anisinha.ca \
    --to=ani@anisinha.ca \
    --cc=eduardo@habkost.net \
    --cc=imammedo@redhat.com \
    --cc=jusual@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=ybendito@redhat.com \
    --cc=yiwei@redhat.com \
    --cc=yvugenfi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).