From nobody Sat May 18 08:14:06 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=1690535428; cv=none; d=zohomail.com; s=zohoarc; b=V2DPd3C7sg3C7RmuNO6Rs556uUjilt/RplMEDDFqO0k4g2gOecjUiWJJYF0XItT9o1xrSvzu92AsIPnWikzZ1/b/QuMAWoSjPWRXki+Hs07boRl3vHHYpO7858JPuxSnrDk6A7q9FfbqKVQTCyhEm5rqs3g3SszH9GX6cOZwyZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690535428; 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=QQgYaOdHzCl++J9NMsdAiruYMkZ9LY8h7wiUCud6BpE=; b=mcAqAS2bR5AuTv1Ih4UOPL8A64SQVyWp3xowPEWprctn+VlI1dD6yxv0VLtFMmv7ut3CEhq1F7ga0NiQYNx8Bo4KIRvnMg9uVcLdgtFV4C7e7t1iBI9EPHFq7ReLVlXtbYKqj7rShZaROPR8bL4VtH165lXFVWgLgZh9qNUchKE= 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 169053542810175.40172737705916; Fri, 28 Jul 2023 02:10:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPJ2C-0001GP-8P; Fri, 28 Jul 2023 04:41:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qPJ2A-0001GH-Ea for qemu-devel@nongnu.org; Fri, 28 Jul 2023 04:41:14 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qPJ28-0002Ro-Ib for qemu-devel@nongnu.org; Fri, 28 Jul 2023 04:41:14 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-98e39784a85so666453166b.1 for ; Fri, 28 Jul 2023 01:41:06 -0700 (PDT) Received: from localhost.localdomain ([2a06:c701:46e6:7e00:c5bb:d943:dc1b:8245]) by smtp.gmail.com with ESMTPSA id kq6-20020a170906abc600b009828e26e519sm1769066ejb.122.2023.07.28.01.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 01:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690533664; x=1691138464; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QQgYaOdHzCl++J9NMsdAiruYMkZ9LY8h7wiUCud6BpE=; b=ggK5hes4DBL4Dt8RgZRvAk2z08PSPRK+P9sG4fc7DXVlTyOris5rdkcXQydIAwMgJ9 x9biRFENlIAhP4wtNylc8vBeXBUOeK0MHX/iYsz2y5Fz8mf5ekppplYam+wzBXV5Fk6Y h0nK8ZHJJx+HD2otRAJ2uZQi8SA5T11HVa3GxDIjeJIXgSyDEzY4CeZbWnr449jFcoMb JpcjJ8hudW/J/p9U1EC4MlwfraGB/k2n/8oVDtCMHCdgTBVbGX7vlUGhf5CGUi5SGSt0 RMgXOJx4QjaY6h48xqiV5o6u/0ekEKRo0h+7/MbaayBrtOPphzJb0UlqfzsmcoJ/02Na Vfeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690533664; x=1691138464; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QQgYaOdHzCl++J9NMsdAiruYMkZ9LY8h7wiUCud6BpE=; b=JHQg/uIJ6epo9gAEPxc6BOk1nED//N8q0PiHpia9PWwb+R8+OBlEJ1MyDaiaNTA6un +tHpXuFiK5m2TQxcY7jrEdBCl1MhCpdKaf0L+q2mnHPWwsQMzFJ85rH+y31qaHYI86yI jLABbzCaMgMMfr0WbXJi0ZnT0wkOUb9Uuoc6FgVWJ4iP46QYS+9fTL5LEHpUt/XCs5qF ijiSrhMPWRIVgkmIxbE4R3EEZA4jY59RaGcgkiCuFba1t94UkM/3WR3cev9vhcXeI6Ov QUD6cAU+BuJm9b3YYQpi/rlHbsjccZS060Q9sCfBZ4JXeParqPVSfIOrVDkOEDwxQG7l FvJw== X-Gm-Message-State: ABy/qLaJMAUfadv0f6B1Ks57TnQgoyRmcnGVj/sZ3BLxOSLN9f/cvZ9L bFn35LPpwWfzYyOVGhgob25P5p6vUAbbcerbv8o= X-Google-Smtp-Source: APBJJlGO6n3c108Bi7Iz8zgYtsJflqQ2lABs6QW9sQYttdzKKvrVVZ5lBCtwcbNfztMVwsL/HcjVeg== X-Received: by 2002:a17:907:7625:b0:989:450:e565 with SMTP id jy5-20020a170907762500b009890450e565mr1802821ejc.23.1690533664408; Fri, 28 Jul 2023 01:41:04 -0700 (PDT) From: Yuri Benditovich To: "Michael S. Tsirkin" , Marcel Apfelbaum , qemu-devel@nongnu.org (open list:All patches CC here) Cc: yan@daynix.com Subject: [PATCH] pci: do not respond config requests after PCI device eject Date: Fri, 28 Jul 2023 11:40:49 +0300 Message-Id: <20230728084049.191454-1-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.34.3 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=2a00:1450:4864:20::62f; envelope-from=yuri.benditovich@daynix.com; helo=mail-ej1-x62f.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690535430140100003 Content-Type: text/plain; charset="utf-8" Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2224964 In migration with VF failover, Windows guest and ACPI hot unplug we do not need to satisfy config requests, otherwise the guest immediately detects the device and brings up its driver. Many network VF's are stuck on the guest PCI bus after the migration. Signed-off-by: Yuri Benditovich --- hw/pci/pci_host.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 7af8afdcbe..a18aa0a8d4 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -62,6 +62,17 @@ static void pci_adjust_config_limit(PCIBus *bus, uint32_= t *limit) } } =20 +static bool is_pci_dev_ejected(PCIDevice *pci_dev) +{ + /* + * device unplug was requested and the guest acked it, + * so we stop responding config accesses even if the + * device is not deleted (failover flow) + */ + return pci_dev && pci_dev->partially_hotplugged && + !pci_dev->qdev.pending_deleted_event; +} + void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr, uint32_t limit, uint32_t val, uint32_t l= en) { @@ -75,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power) { + !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { return; } =20 @@ -100,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power) { + !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { return ~0x0; } =20 --=20 2.34.3