From patchwork Tue Sep 15 15:38:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ani Sinha X-Patchwork-Id: 273687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8F17C43461 for ; Tue, 15 Sep 2020 15:40:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6A4CB206B2 for ; Tue, 15 Sep 2020 15:40:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=anisinha-ca.20150623.gappssmtp.com header.i=@anisinha-ca.20150623.gappssmtp.com header.b="Vz10bbju" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A4CB206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=anisinha.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kID46-0005wa-6h for qemu-devel@archiver.kernel.org; Tue, 15 Sep 2020 11:40:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kID2m-0004KT-DI for qemu-devel@nongnu.org; Tue, 15 Sep 2020 11:38:56 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:36122) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kID2k-0004a0-GV for qemu-devel@nongnu.org; Tue, 15 Sep 2020 11:38:56 -0400 Received: by mail-pg1-x535.google.com with SMTP id f2so2200015pgd.3 for ; Tue, 15 Sep 2020 08:38:53 -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=Q9e5WoPP1IxGkMk/UfsIYmbQR1ZYEM3M7sDwaoDUZm8=; b=Vz10bbjud8YgR9oMFDaxUOQ/0nPEWFeSmYkIEyKd4p09dU9w8/ePKj5PVVIfmuYJ6+ SJ/nVwQ/vzL1LX723eVc7dsPlFWFxjd68ciz+Bu7bjPYCekTQ0K09f+VvG76pEpDNHFn 1v90lOJdzNsESlJpySZuBGFo/h6mtil0M+sbESse5+JSpU3RDv5Pcxa+/19uvZ85t4kG 7zGA/ECV6NUNaizyH6aFG/XEvKcUzi2imUFI9N4ahqxUCEEl1oOwAHCh8B3yiXo7xfg8 7ERbDz8TITEFFlGwEGMsJnfPu/tVfswBAan6N8sJtf9mz63oQcVSqnQbQ/yRuchdqfq+ kyOg== 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=Q9e5WoPP1IxGkMk/UfsIYmbQR1ZYEM3M7sDwaoDUZm8=; b=jGRM7neUXD39iyWjTvnJ1vbtVVg4IepLLxZ4FlIhfLEi9EVQH/430f0Qr7FttO1eD/ 4s3qSnU5tkP5tImjymKe2iqf+KyYYMzSj9exIEOTKN3SUQFR2CGgqS0sayFdWyFZZywb cQ/JAF4CtFCFf5GKpGG5AtpRzOEjNb3m/jhTHkUF7GUdRDiieu9hVJKSiC6XO44EwoKV wISbddXUHiTsDW9+KO9qL5hPuGBQGQVWguGMz2CfZMkSk40kbIJT+erJjTa/xxsZVldi Ey5G532sTbhRgBV+tNkThPgPB0S0N9z+5WYVb1hslG80631qtg/rj2E/GE+G8dzeP+Sl kPIQ== X-Gm-Message-State: AOAM532U6EP2+CbeKLV7UUhD7dKSoX+qTEyDpeKkK57D+TyksMH96cao Xhg0PZ5XT8pYkzKnc/aPVTEv5GY7ppE3YgF5 X-Google-Smtp-Source: ABdhPJxRsc1kEqYIfyKAo/jTCuiOxC6Tq6BkhBk+crRfxppAw4lOlhZviEYhVIrgUR1gaZoEzwKq0Q== X-Received: by 2002:aa7:9491:0:b029:142:2501:396b with SMTP id z17-20020aa794910000b02901422501396bmr2410714pfk.48.1600184332445; Tue, 15 Sep 2020 08:38:52 -0700 (PDT) Received: from localhost.localdomain ([115.96.130.76]) by smtp.googlemail.com with ESMTPSA id 194sm13283547pfy.44.2020.09.15.08.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 08:38:51 -0700 (PDT) From: Ani Sinha To: qemu-devel@nongnu.org Subject: [PATCH v3 5/9] i440fx/acpi: do not add hotplug related amls for cold plugged bridges Date: Tue, 15 Sep 2020 21:08:14 +0530 Message-Id: <20200915153818.13020-6-ani@anisinha.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915153818.13020-1-ani@anisinha.ca> References: <20200915153818.13020-1-ani@anisinha.ca> Received-SPF: none client-ip=2607:f8b0:4864:20::535; envelope-from=ani@anisinha.ca; helo=mail-pg1-x535.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: Eduardo Habkost , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Paolo Bonzini , Ani Sinha , Igor Mammedov , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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() (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 --- 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;