From nobody Fri May 17 13:31:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1662362836; cv=none; d=zohomail.com; s=zohoarc; b=ADDWuk6XmQTzCQYIGYONP1rL29o5EOCkJ8FnAxx1qLULb0bIj5Sqg39W+KosP3fbuXXI3MGmHCUP9j8b7rmsIrS0DvI47BkuOghg25grtstfukuASXAerJIxUL/kcpao15yNIZt6ngXrlPZWiYcVCNeX4vm9/zQ6lUIXNdfmTWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662362836; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=gs22vWON6RUgaJ4SjYt/9qKUGTgiN0Tv98etehxFICg=; b=YST0tj7+8It/O/KhKfEIVSnlwYjSfaGC8LK+nGAMkLV/XBJR9sLm01nnCfJ+L46PU3LzIDFZm+9ARCwXE09fpSKKSMxlPJqwYBnaNWxLBDM2Pa9nAr1PV+IM5CK+wiEdBGKBfEJZhHneJQBPH6iuTKubU6ZkachxQGN2ZACkWqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16623628360771006.6018412748509; Mon, 5 Sep 2022 00:27:16 -0700 (PDT) Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oV6Vm-0006nx-CB for importer@patchew.org; Mon, 05 Sep 2022 03:27:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oV6US-00067U-W1 for qemu-devel@nongnu.org; Mon, 05 Sep 2022 03:25:53 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:44682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oV6UQ-0003c9-8S for qemu-devel@nongnu.org; Mon, 05 Sep 2022 03:25:52 -0400 Received: by mail-pf1-x436.google.com with SMTP id q15so7829390pfn.11 for ; Mon, 05 Sep 2022 00:25:48 -0700 (PDT) Received: from anisinha-lenovo.ba.nuagenetworks.net ([115.96.134.171]) by smtp.googlemail.com with ESMTPSA id b8-20020a17090aa58800b0020063e7d63asm1406933pjq.30.2022.09.05.00.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=gs22vWON6RUgaJ4SjYt/9qKUGTgiN0Tv98etehxFICg=; b=IUYO7csCfeAARPHvWMjusnV530KKzVcQ32um2gCSnFWnGvV3VglU+RUdytPjDPgvl5 LIEpV0Po5becS7UWXh8TRaXPlc7ccXmZh9lix82YXYaGTKteLFNCyKHgITGfj7SB3IPU 9Z7vFv5INORj1DdNmuaynOwf9n5hd/6k/UCgpgDHqT1a7yUgooeUJZ2B2Wq+tkO192RF WYqjxUhd8MMMhXo3iOkDnbmpx6v1kTMfpIpOojS2qniDf2RON+hjt4Q0m1a53NVeqlbh xAbZIC9QlhUCkqQajSXQCTGKxS4S1OBA6zoAE5DJfYI4APzzPr8twBW7vrSbK2lbxJRb 3y2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=gs22vWON6RUgaJ4SjYt/9qKUGTgiN0Tv98etehxFICg=; b=KvNrO47vC1eNABB5+pGFi2WZOp7SM0euAS9QBdrKxFnu8t9bEmV0uPYKrmSaD8Q0Hp tBKQYTG57t5NNwYvyStjdKnRltcJk8JhqATK5/0uzK455Fo/k+0lURC6GMBAeWCjfiFO AYahUHJeqeb+bX7KTmaXT2hWLaSHKBzXG33zJhQQINr0h0Y2j9tUp1VDYdSMZWEzJoTr 6r0tG3j7+j65bBlIv1LY8c341ZulgpjLRzL+bXJ+OpWwLO/tLqTp+lgaWsLRDuxBUnqu QZJjDtwYFcgR7v82Ny6rhSSFkiBbtfrK8Nnx15zNIKpga9PFzD2fdF2nYK/phXHqHmp+ dK1w== X-Gm-Message-State: ACgBeo0CgFMHOoNqVxOjb0yUrwjBBnJNDR5z1c76AsUB8fR8pPrR0qbn kpFbrzqQw6XZndV5bL9ngj/STQ== X-Google-Smtp-Source: AA6agR50cfOZVepDZD4dETNB7i//E8KgvZt+lU+6DSrtSKV6ZKT3eWOzYjGPkm/7hdg3TkwzcgTebw== X-Received: by 2002:a63:e156:0:b0:42b:5541:80d4 with SMTP id h22-20020a63e156000000b0042b554180d4mr39724065pgk.183.1662362747604; Mon, 05 Sep 2022 00:25:47 -0700 (PDT) From: Ani Sinha To: "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum 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 Message-Id: <20220905072531.8059-1-ani@anisinha.ca> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::436; envelope-from=ani@anisinha.ca; helo=mail-pf1-x436.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @anisinha-ca.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1662362836769100001 Content-Type: text/plain; charset="utf-8" Possible fix for https://bugzilla.redhat.com/show_bug.cgi?id=3D2089545 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: Compat= ible ID Name (_ADR, Zero) // _ADR: Address Name (_UID, Zero) // _UID: Unique ID Method (_OSC, 4, NotSerialized) // _OSC: Operating System Cap= abilities { CreateDWordField (Arg3, Zero, CDW1) If ((Arg0 =3D=3D ToUUID ("33db4d5b-1ff7-401c-9657-7441c03d= d766") /* PCI Host Bridge Device */)) { CreateDWordField (Arg3, 0x04, CDW2) CreateDWordField (Arg3, 0x08, CDW3) Local0 =3D CDW3 /* \_SB_.PCI0._OSC.CDW3 */ - Local0 &=3D 0x1E + Local0 &=3D 0x1F + Local1 =3D (CDW3 & One) + If ((One =3D=3D Local1)) + { + CDW1 |=3D 0x12 + } + If ((Arg1 !=3D One)) { CDW1 |=3D 0x08 } If ((CDW3 !=3D Local0)) { CDW1 |=3D 0x10 } CDW3 =3D Local0 } Else { CDW1 |=3D 0x04 } ** Signed-off-by: Ani Sinha --- 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 =3D aml_name("CDW1"); Aml *a_ctrl =3D aml_local(0); + Aml *a_pcie_nhp_ctl =3D aml_local(1); =20 method =3D aml_method("_OSC", 4, AML_NOTSERIALIZED); aml_append(method, aml_create_dword_field(aml_arg(3), aml_int(0), "CDW= 1")); @@ -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)); =20 + /* + * 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 =3D 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 =3D 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)); --=20 2.34.1