From nobody Tue Feb 10 04:16:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633954097853622.2179746259893; Mon, 11 Oct 2021 05:08:17 -0700 (PDT) Received: from localhost ([::1]:60468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZu6K-00011Z-PM for importer@patchew.org; Mon, 11 Oct 2021 08:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZu4B-00068N-OY for qemu-devel@nongnu.org; Mon, 11 Oct 2021 08:06:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZu49-0004Q6-0E for qemu-devel@nongnu.org; Mon, 11 Oct 2021 08:06:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-sGERBD_vN-CjFOH1uACnPw-1; Mon, 11 Oct 2021 08:05:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B8FF100C660; Mon, 11 Oct 2021 12:05:55 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C39F5C25D; Mon, 11 Oct 2021 12:05:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AF0AF18009EA; Mon, 11 Oct 2021 14:05:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633953959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+RA1Fn/tAiTbDU7wgjQFXuoi2jwyyufHF2xCDIYUHSU=; b=afSQnDVQhMF5z3fvrzwh6G0JXs5NOFIJk+2HshJaLtP7bhTJ/xvH6AkF5f7z8t9yYKu7yT h9sxaMVe/oKHxJ33JIIX1QUPAggrBQE4kz3bj7rv3QI+xWZCXlQqSOALGeH88lv2dwds0j 7BTtaju8r08oo27KsnO3LUN2vwemHW4= X-MC-Unique: sGERBD_vN-CjFOH1uACnPw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 5/6] pcie: fast unplug when slot power is off Date: Mon, 11 Oct 2021 14:05:03 +0200 Message-Id: <20211011120504.254053-6-kraxel@redhat.com> In-Reply-To: <20211011120504.254053-1-kraxel@redhat.com> References: <20211011120504.254053-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633954099191100002 Content-Type: text/plain; charset="utf-8" In case the slot is powered off (and the power indicator turned off too) we can unplug right away, without round-trip to the guest. Also clear pending attention button press, there is nothing to care about any more. Signed-off-by: Gerd Hoffmann --- hw/pci/pcie.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 70fc11ba4c7d..f3ac04399969 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -561,6 +561,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *h= otplug_dev, return; } =20 + if (((sltctl & PCI_EXP_SLTCTL_PIC) =3D=3D PCI_EXP_SLTCTL_PWR_IND_OFF) = && + ((sltctl & PCI_EXP_SLTCTL_PCC) =3D=3D PCI_EXP_SLTCTL_PWR_OFF)) { + /* slot is powered off -> unplug without round-trip to the guest */ + pcie_cap_slot_do_unplug(hotplug_pdev); + hotplug_event_notify(hotplug_pdev); + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_ABP); + return; + } + pcie_cap_slot_push_attention_button(hotplug_pdev); } =20 --=20 2.31.1