From patchwork Thu Sep 17 15:00:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ani Sinha X-Patchwork-Id: 1366193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=anisinha.ca Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=anisinha-ca.20150623.gappssmtp.com header.i=@anisinha-ca.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=PbOC/y9W; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BsgPC6wRSz9sSC for ; Fri, 18 Sep 2020 01:09:51 +1000 (AEST) Received: from localhost ([::1]:60478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIvXg-0004mf-42 for incoming@patchwork.ozlabs.org; Thu, 17 Sep 2020 11:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIvPW-0001i6-CY for qemu-devel@nongnu.org; Thu, 17 Sep 2020 11:01:27 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:51886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIvPR-00010Z-Nw for qemu-devel@nongnu.org; Thu, 17 Sep 2020 11:01:21 -0400 Received: by mail-pj1-x1044.google.com with SMTP id a9so1430148pjg.1 for ; Thu, 17 Sep 2020 08:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ughGQhnpv0vI//S8mrXDQnorJKmr6CWqkbIT0eqOuAw=; b=PbOC/y9WV/NEGJ22+DSCW/3bSzeRHWJjjjiYEzBftJctfmq7db8Zgx5rBFjBzM3KC9 +NlUitMB8+rha9f6K07eU9gI+M0iWCp8uFlWhjzqdqpUkLnBe8AwqTIkvXwS0NW50eBz csAd5XQeK419LDm5/t1Z3kn8eQS/RUH65q391ibOm6pVor92pzskZ4hSmqBoFXM2GiMm xyGlNzmpchrY5Z1dG2fA3/mjJnuboOtjcIyx6yn3YXnZphR5/HclFkts7lxw+LW9J4tZ 5C1XzwA9nTaKH9cp5r2sQW+d80Gqn5INeaBGlI66QVwO90rxD89rgA0ge0aT4V1ro/xt azEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ughGQhnpv0vI//S8mrXDQnorJKmr6CWqkbIT0eqOuAw=; b=ZSSX3VqkbTclAfI10uV4J1vm0h2LpvgMA94g9nRNuTASNOHt5MoXuBemZL2sBKtdWl Ly3/h6ZxghvwjABfTS1VS/ysOisQtoF0LN/0aLY9kLbrJU0Ey9IRhw/Gjl11oPBpwzzE CW2iM93RCAXITj7D2b+hNwUVj9myWb5afKglS+DXBDe6N+i87pv/tAP6AmITwCcepMUz 2ngFsDhOWqTOrRtOQr6VFBTbBjMCxSUsmOOJfnbbNwGTrzxLgmNBtmu5R7uYe7mKZTgD 9K87MydwtZd1BSeX20/Xsi6zXdystSGTNvv/BftkVS8EkxCEMI3WzMzuPlCfBxguPbg8 Ghtg== X-Gm-Message-State: AOAM531yL/z17eU4tQPTSok7hqPAiL1H3n6kgl4NzPrjC7t6M195+E/q +KuZuQbhyPv16XcoCQ863hIFJbRqtFV4uoBz X-Google-Smtp-Source: ABdhPJx69rgc5ViBo/km+9y0X7nmM0qHRuFVW/rrshmyWwUJ2RQy2m6iNJfu4Qk5j0gqwoIaTJhbnQ== X-Received: by 2002:a17:90b:1111:: with SMTP id gi17mr9054857pjb.109.1600354875783; Thu, 17 Sep 2020 08:01:15 -0700 (PDT) Received: from localhost.localdomain ([115.96.151.231]) by smtp.googlemail.com with ESMTPSA id e10sm17674374pgb.45.2020.09.17.08.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 08:01:14 -0700 (PDT) From: Ani Sinha To: qemu-devel@nongnu.org Subject: [PATCH v8 05/12] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Date: Thu, 17 Sep 2020 20:30:37 +0530 Message-Id: <20200917150044.23159-6-ani@anisinha.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917150044.23159-1-ani@anisinha.ca> References: <20200917150044.23159-1-ani@anisinha.ca> Received-SPF: none client-ip=2607:f8b0:4864:20::1044; envelope-from=ani@anisinha.ca; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Eduardo Habkost , "Michael S. Tsirkin" , jusual@redhat.com, Paolo Bonzini , Ani Sinha , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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(). 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 ACPI code like _EJ0 etc for the pci slot where the bridge is cold plugged. In this fix, we identify a cold plugged bridge and for cold plugged bridges, we do not add the appropriate ACPI methods that are used by the OS to identify a hot-pluggable/unpluggable pci device. After this change, Windows does not detect the cold plugged pci bridge as ejectable. 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. Signed-off-by: Ani Sinha Suggested-by: Julia Suvorova Reviewed-by: Julia Suvorova Reviewed-by: Igor Mammedov --- 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;