From nobody Sun Nov 24 11:28:24 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=1723529793; cv=none; d=zohomail.com; s=zohoarc; b=SohxMJ3CH0yRZaSY4xOcqDQwp6swmb1fycObaVNi/8CQO0Kw3Z9I0cycrxmVdF2pPbLORGKmMXXXE+d+HDU9qBoWsTUp/auqg5UcQGm841iyrhO9A+9w9lSy1Jpo0S4xsac5ug8+PYtZ4xrG/PyC4Pe+YCVzeypvNZky6K9yuKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529793; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=62kKfr9dHJM0SZ5J/90nbLNcm1EIlbr8aKdENcXAj+8=; b=dG7ZlihV3XC3Ppf4okCvQ/iuzhnSk9vlgXwrXszReSkq0YkjfMTD7+zVA3k0WelRv+Ioc7iQf8RY416XqoT5s+Ry+Z+5MbY0XQ5IqrQD5NFAEafElsGtqE41hFNcqkS8R5bIA4rK44MeTXW1vNrn+EJRpLcmMDQOr52cLTcXpbE= 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 1723529793990208.25575591190614; Mon, 12 Aug 2024 23:16:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdko7-0005eV-8n; Tue, 13 Aug 2024 02:14:59 -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 1sdko5-0005ZJ-NE for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:14:57 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdko4-0003IB-0Q for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:14:57 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-710cad5778fso4144220b3a.3 for ; Mon, 12 Aug 2024 23:14:55 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7c697a0442bsm690147a12.48.2024.08.12.23.14.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529695; x=1724134495; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=62kKfr9dHJM0SZ5J/90nbLNcm1EIlbr8aKdENcXAj+8=; b=llivHXW1lMZA+st4rLx12zZX8dyOkh0KodCvvwl744vkQBm1+UH/iOhUPpMVOZwgEp zM5B5ji2geWnuYLvbYTuYdyaJJXJ7AXDp59YakHdwM0uwYuezlH+9o4hotgo3MO9h6xT xRVoi2OFSDdRSbgYnhozXAN7BIWi+DxFYw2cnJtrI2aQcVXL769g+vUPEpcj0h40OngK hkXS+6YUfsI/5jRcePyhGeA1idxBCTRjGMGYbjBG8TfhjYYyiltRew0iZJdRUe9k/mMZ ZM79dmn2W1ULXpKhNg1qPpKUBcNvOFZnFoDRR5SBrFj17zpMXvEsxJBsKepnarpYGWuL of+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529695; x=1724134495; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62kKfr9dHJM0SZ5J/90nbLNcm1EIlbr8aKdENcXAj+8=; b=KYTiqfzaoFOofcxnEzQk6uyQpI9fTOpH+zVGtU2+9cPlPGbP+0VF7xgGMpLSRwFs9v pqo63ND1kKfR37z7t1fOw611nkHfjaP7BaxUQhOx62m/nZinPAluQ+n6Ovd/Zxy62B01 jUJDwpXiCsUdO+smFXcSFNCOCT/T5pJQCSpvfabShbELC/8KLFtb7GpXTz+9CeWhMfDs vIN0zSDGR2igRq3qvaG6qrxPtOqH1YDEJ0/M0sZR/3EiLxA13gpWHTNtfNLBvCFYfQ8X s1vYJesLvsmmDvKQCLDSQ75TSjhFfX2sdjhpLg7Xbnf2TzE/vjxIlocB2ApV3dwkICvX gKOQ== X-Gm-Message-State: AOJu0YyVw1XPzv+vrrtceWe0cYQWXQYC32xXyEtdmdoVLRVOuAqf9oy4 gTnLeX/UK/M1rCYcvGiMrD0FKnNBTwSjxXw/MvtC+/lsgLSZjMJnW3wao+Xvd8w= X-Google-Smtp-Source: AGHT+IHM8n82WGP9Z7Pbm+OW5wAg/UJMvjfW8RHXeR9vJ29KjUWpW8QT4tQrSVmb2c/AKGdowGIXNA== X-Received: by 2002:a05:6a20:c78f:b0:1c4:c3a1:f479 with SMTP id adf61e73a8af0-1c8d758ac82mr3516134637.39.1723529694602; Mon, 12 Aug 2024 23:14:54 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:44 +0900 Subject: [PATCH for-9.2 v14 01/11] hw/pci: Rename has_power to enabled MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-1-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529794868116600 The renamed state will not only represent powering state of PFs, but also represent SR-IOV VF enablement in the future. Signed-off-by: Akihiko Odaki --- include/hw/pci/pci.h | 7 ++++++- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 14 +++++++------- hw/pci/pci_host.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eb26cac81098..fe04b4fafd04 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -678,6 +678,11 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) } =20 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); -void pci_set_power(PCIDevice *pci_dev, bool state); +void pci_set_enabled(PCIDevice *pci_dev, bool state); + +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + pci_set_enabled(pci_dev, state); +} =20 #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 15694f248948..f38fb3111954 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -57,7 +57,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; - bool has_power; + bool enabled; =20 /* PCI config space */ uint8_t *config; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fab86d056721..b532888e8f6c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1525,7 +1525,7 @@ static void pci_update_mappings(PCIDevice *d) continue; =20 new_addr =3D pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->enabled) { new_addr =3D PCI_BAR_UNMAPPED; } =20 @@ -1613,7 +1613,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + & PCI_COMMAND_MASTER) && d->enabled); } =20 msi_write_config(d, addr, val_in, l); @@ -2884,18 +2884,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int = vector) return msg; } =20 -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power =3D=3D state) { + if (d->enabled =3D=3D state) { return; } =20 - d->has_power =3D state; + d->enabled =3D state; pci_update_mappings(d); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); - if (!d->has_power) { + & PCI_COMMAND_MASTER) && d->enabled); + if (!d->enabled) { pci_device_reset(d); } } diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfe6fe618401..0d82727cc9dd 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -86,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 || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return; } =20 @@ -111,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 || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return ~0x0; } =20 --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529800; cv=none; d=zohomail.com; s=zohoarc; b=cO6EQ3LTM7qg6OioKd4fz5eAugr8dHprVo988kKskFkxkLp2N5r0ztKMSo0To5kEotN2UTd6ZjermqnU1omAi8ZoLqN48JOMr1FD9Gg2BSyFFiv/gcmpn2xGp+teuNquIdLM4y1wpgibvyaNeSxajEjtsLXipRziyM6Q6kwY9l8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529800; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hZYRJCaOR7D2p7YWgr7dJo7l/TPHeAaK6dBF5pYEnfc=; b=FRsnFXkUiC7XYa47STtwmkNzKqfATB6So46Z2kFqRivwVCjcJie95xrPGNVGNjoKFQA7NG90g2HyOlfsC4BlcuvFkpsTn9db6RlZ95GVDS4x/NlD0HfkEiWRUi4FQoHoAqQ6/yNrbhRPfRPFJsipbC89bEkzbRG6q/Lh8V0I7ko= 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 172352980047091.66229452134564; Mon, 12 Aug 2024 23:16:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoG-0005vN-CT; Tue, 13 Aug 2024 02:15:08 -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 1sdkoB-0005qj-Ao for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:03 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdko9-0003Ic-Oj for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:03 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-7093705c708so5010576a34.1 for ; Mon, 12 Aug 2024 23:15:00 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-710e58a921fsm4973357b3a.67.2024.08.12.23.14.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529699; x=1724134499; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hZYRJCaOR7D2p7YWgr7dJo7l/TPHeAaK6dBF5pYEnfc=; b=yjrL0zD0mzLmWFiejHwyp/81hOKlKwW9e9uiwSeZ158rrEyR7V+XzgRhKmfvBF6Rlc 4Xk51KhFBp4RPHCX9NNu1/mdLXx+qEDrNefvvVdXljuaUIJxzUVZQBbBLG1kIxOGFP2G t5ZTsblFYtTzMMcrCpS1rO61nQZP5LeO7YYkKR66jezXSc/Q5hU4t7pLkRXrQR0qv8vz SlIfSyaauWz/cay2DYEfK4g9cgqD3CyWUocDhLw1OX9cKtqF7eTA8NLo8Qs0sBlqf+co bWVyxFuVvT+SzCrczYMxLJ564UfeDCHR4vSZcFOj4wg+to1LL+Watpenfyrzy/WoNty3 Wa5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529699; x=1724134499; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZYRJCaOR7D2p7YWgr7dJo7l/TPHeAaK6dBF5pYEnfc=; b=XMsViIPZ1YBoopjZ6kpTS5O/plNE29Vb8N+WYM0Ixzi57XnNIbRiAkuuqryYZAvSFu /iDSZ88jqXHrRnERGHmWSFyxbNkUd9vpCo7yNnyGXzlOwjtaSwQKIMQfIngddkyVbL2V RLbKoqYu7foccasM8uhuEL3FbX/qImV1OW5CidF51hxQvAY6CsVikQUHKY9nGEVOaqb4 +41TaIqTfIfQBfzn0s+SyyHvdbQotvapSvWKUFkM+MWCQ5YaX2PI0H/3tl8/QkVbXwAT DtBoZUYj7LW65clb0Z91Y6fB2NnPklLI1QN9y1YNb8U9cPdlk4qv3m55Mirrqg63yRZA G+SA== X-Gm-Message-State: AOJu0YyzOdkmwMnyqnANJ4pazXACZ/VZ/zHNz5F82CqtOL86dBIWEVjG ZywxZJyPg6/dP2x76fGhjxe9iea7+0sSmlsj2sh/Ngp4V9+3F45WleY4837gZYM= X-Google-Smtp-Source: AGHT+IFWNoShctOMKaHWZFBnGz3sCacmY9Wa2W+OkJeM1AkLIV3Fsj1Eg9ZCyvYs4gWoubRKR1zByg== X-Received: by 2002:a05:6830:610b:b0:704:3fef:f045 with SMTP id 46e09a7af769-70c9394f4e5mr3263451a34.29.1723529699268; Mon, 12 Aug 2024 23:14:59 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:45 +0900 Subject: [PATCH for-9.2 v14 02/11] hw/ppc/spapr_pci: Do not create DT for disabled PCI device MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-2-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::32a; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32a.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529800892116600 Disabled means it is a disabled SR-IOV VF or it is powered off, and hidden from the guest. Signed-off-by: Akihiko Odaki --- hw/ppc/spapr_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7cf9904c3546..f63182a03c41 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1296,6 +1296,10 @@ static void spapr_dt_pci_device_cb(PCIBus *bus, PCID= evice *pdev, return; } =20 + if (!pdev->enabled) { + return; + } + err =3D spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->offset); if (err < 0) { p->err =3D err; --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529811; cv=none; d=zohomail.com; s=zohoarc; b=cgugT1PFMAw0cmK4v6fHnM9YXeBgAEqGysMPz0v++UoZGwg22le54PyfUyT3DSoQBdm/efJNhT/yuh0C5d5jY+0qt1ZA5UMRtQW2WgtJGTlepNgvqA7/NKAU6wzj0OyqWUsyyoExJa1vFWhQ2XsXPJfrZ29IckukEeWqJQmpyCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529811; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1EH/aHXKf0I4GydXqDhlyHJMWgC5ukj8mIGCdjS/Jn4=; b=QN83w7f/Z7cdBkrf5H9pNZalaH+Ws6u8HYEJpwMcajnpkSgZBWYxuT34mhTwTWDf1YvoJVJKPls9PRAXyS665Y2L/AEhqEIBWiEx1ohdJcdpQB3B5XJT7BHC4hkhlF5sLzluWiPEymuhRCzp8kcTvINfBg/fSspOVxuTjSt62hY= 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 1723529811612354.94291147293814; Mon, 12 Aug 2024 23:16:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoS-0006FU-59; Tue, 13 Aug 2024 02:15:20 -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 1sdkoJ-000603-8o for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:12 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoF-0003U6-CR for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:09 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-70d2b921cd1so4726639b3a.1 for ; Mon, 12 Aug 2024 23:15:05 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7c697a728e4sm563722a12.90.2024.08.12.23.15.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529704; x=1724134504; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1EH/aHXKf0I4GydXqDhlyHJMWgC5ukj8mIGCdjS/Jn4=; b=ttHNRHLZOn0ObwdS/CeoMHqzfcMX8tzDw9Zzaj4CO3esSgOWtLRKddn2z0+7b4sjJ2 BCnOrZlXO6E/kVmGmKvJzuK9xJsegUniA5JrUS2wl8MdM6rA8VSuFDlZKbJrfODi1Pwc EqqDzHvpPbOtRAccVDP95YnXEANzW88F8d16akVu/w9T+UFvW0HLOjhSyzen4QPtahO7 KyUjWBfJ/KpgEKvNZyrfpjV98pexYbjPnLZJyGguzdAfW+bWT6+RQlRhrH95cxRqz9tm EHboyx8cxFTJTARekSoNLbceX4PS7ZQaquE6zFWwwFaIktLbutatd8fZrkJS8K/a0Ws4 Gxyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529704; x=1724134504; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1EH/aHXKf0I4GydXqDhlyHJMWgC5ukj8mIGCdjS/Jn4=; b=uVpqf9QWnW1nVPVnQgPujAVCSilU0SAUsBMz2qnxRMs7Osmr3gjhwzsnAojthZkOsr 4S+DbNofFkylEBnO1kQXenbyAGZyyCmc/wj865i9DQYJPWWTXmsdEk4rI31hTzNHb0co wx0Hc9lLAwSf4aVfstcPWv8P2Y4CAtEIxNUqGdERUZS08/YjYUTpH3RtbN0xodlS6lpA SSmd0qk0yNF26WWC5HtbPy5lgfBkGlop2+GeA9AENxLOsCFVkUU+lEnPeZWhK2ZSHjK/ n8/A9xtGFvOyAVIPO1FuFzFsLcMRHftWfIHEeL7hhDzzwxV74KrAngdXLw/4qPES31TS 2a/w== X-Gm-Message-State: AOJu0YzrqUxeomm+4LS9F8GrUa3XKD/Yal/ByufqDZIa9se2wCyD6uym o95vfNvJ5Z00QwsgD3VM6F8XNe1jo9IP8j0aBiLDpJGKLfPHiJhN+jtXWBeDmN2G3GT+7ilrjf4 lcSk= X-Google-Smtp-Source: AGHT+IHyG35zjlW0rjlLac7KZOGQNnvrgF/m2A/gapkBI2LgTPhlG5QgAAqfG2IrOa19zwDnQTBDjg== X-Received: by 2002:a05:6a00:a8d:b0:70d:2892:402b with SMTP id d2e1a72fcca58-7125512f30cmr3443206b3a.7.1723529704149; Mon, 12 Aug 2024 23:15:04 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:46 +0900 Subject: [PATCH for-9.2 v14 03/11] hw/ppc/spapr_pci: Do not reject VFs created after a PF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-3-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529812804116600 A PF may automatically create VFs and the PF may be function 0. Signed-off-by: Akihiko Odaki --- hw/ppc/spapr_pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f63182a03c41..ed4454bbf79e 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1573,7 +1573,9 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_h= andler, * hotplug, we do not allow functions to be hotplugged to a * slot that already has function 0 present */ - if (plugged_dev->hotplugged && bus->devices[PCI_DEVFN(slotnr, 0)] && + if (plugged_dev->hotplugged && + !pci_is_vf(pdev) && + bus->devices[PCI_DEVFN(slotnr, 0)] && PCI_FUNC(pdev->devfn) !=3D 0) { error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " additional functions can no longer be exposed to gues= t.", --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529812; cv=none; d=zohomail.com; s=zohoarc; b=DyQx+S/hiAIRC8UcJpDAaMVRVIJtq8mjjthF9q3RpOVU4cEURTfoEcsPWzy3nsWTa6tfKtZzgT1PFy3vhxnZPyHJ1OAIuJaxmeaYX6U/Ez+mNVFCeoP0wxV+MMREMkY2H8iL7qF5FOszxgHPvPBvRio/6C4iTAOYqgQWyk54Jgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529812; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KhvSqXAEdDDWpyZ2TnpIXArJspefwxxfrLfBQ6hR8X0=; b=NRS242tTmkVECVQ+HsYAA5tSh4NVfYb+GtBhrwzOZzymdwggapZ10pwVsyS6mTRNVTm5Z7IvGRN3Zd2Q5MdtVlzqN9rcmUdtKx3smW6EJCDCInGreDrp+vLSWwFJoTsg89W7gDlEs8EPjq3AAIwMas206pDLYUfwKOeZZUzJq+A= 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 1723529812596199.78761090614717; Mon, 12 Aug 2024 23:16:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoS-0006LV-L3; Tue, 13 Aug 2024 02:15:21 -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 1sdkoM-000686-6B for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:16 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoJ-0003Uj-BW for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:13 -0400 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3db157cb959so3552959b6e.0 for ; Mon, 12 Aug 2024 23:15:10 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-711e3b21bf3sm2499312b3a.85.2024.08.12.23.15.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529709; x=1724134509; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KhvSqXAEdDDWpyZ2TnpIXArJspefwxxfrLfBQ6hR8X0=; b=kooshb32Tyd7CCsKJPzPXVZ5F/M0055Ab1mcRGnLBr1GF1x/xko8XQLtfaeKwvRyr+ LVYpN/GF0Or/FJgxORj47jj3G2dFLKEh5H6AojSLkjwCuW+CSdhPR7a8rXiCWOw1yzaH mr+DVIbmrjSivHFSWhLh1ezeVSkB0169cYAUfXrj4zKCW0ntC4E++4QYvqyv5aAXMThA 0SF/OKIgZmYwfRi2emFQnhKPoTOn2FIpnaaE6k0qbilfhcpDuTX9kF7+oANlkDN2OrQ+ gVZVz5qYUcQITOD3AUY1664o5kMMKNdWUYZZQiltl7eSSMVhkzFuI23pAFCVbjFPO3KX 1CHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529709; x=1724134509; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KhvSqXAEdDDWpyZ2TnpIXArJspefwxxfrLfBQ6hR8X0=; b=FXx9Ejm+wQZqCPMirAxwJA5yI8p5ZMSpCP3iJ1r+ZO+L1+OPclvcZttH7zpLpsCF52 3tEaHYXAMDe0erY3Scy7XrijPPrIwNZ8nKNWNRcRa9Bs0ZFV/LMkBvybe44WA4Xn1hrU D5oSeKTNXhGqdUEGjjkIl75ZHznpGZIK7DEEVDgk4JJ5L+/1H7D+wNcnf8YEHbUY4LrH 7zyZIgf/xQdxl2hqqII0a06lJnQhyx+CefRLraxNnsCnEY8MnQNcIWfRMXSvF+WDqAcm IkWkOIABfmmLcZ093W6IwPCAu8T7BrIn+LRYQWf01EErNx1fHBeu6mfchQc6A7SygUnk u6Tw== X-Gm-Message-State: AOJu0YwNzG4f/0bFbsqMDtCTRSwNyEdnb7kGborRU52ijZz+t0P9XWGW 04Ic8zYIK6uscO5FND7wv7QKpiq401RfeJpttZCOYweVuyPU8e7zbEIfiKe4DDo= X-Google-Smtp-Source: AGHT+IHtIty8dKgBr/1waQO6p9mgcPghJoGbZxHu/gzzfRvLwUAb6l/96T0V3KeILkFm6YzceIwtTw== X-Received: by 2002:a05:6870:e314:b0:254:affe:5a05 with SMTP id 586e51a60fabf-26fcb6ca3ecmr2971068fac.21.1723529709419; Mon, 12 Aug 2024 23:15:09 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:47 +0900 Subject: [PATCH for-9.2 v14 04/11] s390x/pci: Check for multifunction after device realization MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-4-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::235; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x235.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529812821116600 The SR-IOV PFs set the multifunction bits during device realization so check them after that. This forbids adding SR-IOV devices to s390x. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 3e57d5faca18..00b2c1f6157b 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -971,14 +971,7 @@ static void s390_pcihost_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, "this device"); } =20 - if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - PCIDevice *pdev =3D PCI_DEVICE(dev); - - if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { - error_setg(errp, "multifunction not supported in s390"); - return; - } - } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { S390PCIBusDevice *pbdev =3D S390_PCI_DEVICE(dev); =20 if (!s390_pci_alloc_idx(s, pbdev)) { @@ -1069,6 +1062,11 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { pdev =3D PCI_DEVICE(dev); =20 + if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { + error_setg(errp, "multifunction not supported in s390"); + return; + } + if (!dev->id) { /* In the case the PCI device does not define an id */ /* we generate one based on the PCI address */ --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529779; cv=none; d=zohomail.com; s=zohoarc; b=g9vRHhWpPD0IBoRgq3Nuzth1XZbdSIlH8Hqn3+rCBiR/h8KiAbyl5ZZyhoIQkBBt9sctN5QdqfV6zh8r/G+XRYlxxeotMcrc/IFPcZpE6GTfS6lPP84Mr9fsBD7Cuo6XcDSFycM7vPV77Cgh3OTT5rJ9YC0wU5uhySApakZTRwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529779; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BRjBowTwtb659ZbVk9eSUPoUW4j3xXhVBm+o7M+tERI=; b=VUPkHh0D6mI4QpzVu2fhAbAdyxTLfBto63S84MsuKHsEcG6h4HS8U+1wv0JMSKYaYkNNPj68o+7tLed1/DW3aJhba1fDcCk48/wZ+MYoFkk3ZQ5jLVX2uUAGo9EO5vKpCxwcjWN6flNfm6viCsjQWDJFZRXfWz3nyCb5H47Zj1Y= 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 1723529779645340.25595985671; Mon, 12 Aug 2024 23:16:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoU-0006Rg-4d; Tue, 13 Aug 2024 02:15:22 -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 1sdkoQ-0006Di-6u for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:18 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoO-0003Vg-FQ for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:17 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-260dde65a68so3246466fac.2 for ; Mon, 12 Aug 2024 23:15:15 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-710e58ab867sm4936542b3a.66.2024.08.12.23.15.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529714; x=1724134514; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BRjBowTwtb659ZbVk9eSUPoUW4j3xXhVBm+o7M+tERI=; b=hdIUXXDZyiHiIbUjWw56Xt62rfpBq4/UDuFfTpI3rhrjbcb6nbvtMUCmz1GQmnORxx Aar207w/tqP3YbA6ZRAJ81RJTCN++Qet4T9/nf56fMSyQ26SOE65ptTeSxVo38FVh3YO PU6G4HYtNvrHOpGUKohJorSAJIPnt1ksWpJ2XoWI9/n82TR5+zdQTXkLkE1/aHz7AEFm ypqDBZb5DJLZlaYOnKAHbC/6WxZHckfNBZ3NQRnPf4RZ8mpE452+fxP350bQTFxAncw/ 15Iixu0I3A1bAB/4KWGFVERxDF9ni74qP91Cs0uJFo8e26W/ehLf2o3KMUEsAKjrnF9+ EiNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529714; x=1724134514; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BRjBowTwtb659ZbVk9eSUPoUW4j3xXhVBm+o7M+tERI=; b=M0o7EV+3kc5uxGsexJIQjeBgWVqd6/uojRFsWUBLeB62o3KqDeCmFw8FOuOoqn4VzA xWrI9cgPaumTD1FOXsI74EVi7LiDOKtQZzBakJiMy9Or8DqbONBY/ky+8F+0RuHCUcqQ RQFntsG4q+v7+sc6T0MVGjC+m708Nx0XZT3/ifkmTz5eIi1wTDYXy9KkHFjYDhaD6b89 +1mnOt4gCEay62Y/IhQR++jrQb67Eg9SqOqcUXPrAUlDbA45AMe3AsTCCg2uX/76Nl+Y BPwlfjJSUN6M6ydefsuU/xqp++CjpKFKdp22sVoUyY7jeSoc91D/tnZHydRrjzdMd+kA OSfQ== X-Gm-Message-State: AOJu0YxQ6t1Ge+KSooe8eOFsX5V9SRr4evVf2B+MhLmUb5v7vznUGkYA 3gLmsPQmN0mJShwvx2aGmgmcfd0/TInLUYPt1zqvEyWBN1zYUQiKgq9erUx96UA= X-Google-Smtp-Source: AGHT+IHOKqSvUzcvpAAX53JKKQ5Lobb7OfAb9SecdPPb5R5R3Zm3Ascdd7OrHm3VFyfH/cP7Dz/JVQ== X-Received: by 2002:a05:6870:b52a:b0:254:a811:6c75 with SMTP id 586e51a60fabf-26fcb64b94cmr2794485fac.7.1723529714162; Mon, 12 Aug 2024 23:15:14 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:48 +0900 Subject: [PATCH for-9.2 v14 05/11] pcie_sriov: Do not manually unrealize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-5-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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=2001:4860:4864:20::31; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x31.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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529780873116600 A device gets automatically unrealized when being unparented. Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index e9b23221d713..499becd5273f 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -204,11 +204,7 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - Error *err =3D NULL; PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)= ) { - error_reportf_err(err, "Failed to unplug: "); - } object_unparent(OBJECT(vf)); object_unref(OBJECT(vf)); } --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529784; cv=none; d=zohomail.com; s=zohoarc; b=TxRNt+4YSTbafuEeK9Xag75yX7ljoyaXPMsPxUmplmsTuEIHnbNeBjFJkCDpqc/WropYSeF0WxxJA87th5kIqBFq3S5d9RFL7yopxNBXMbGv2suGLhEdksumL8J3AZMrf9UpzUPnG39Xr0dFvOfuw+kZt6tBsa3aROWICJUqDxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529784; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ANdtsuA/TGl02EfU5lGEDU+SzPTDlHokeLE9rDoObAs=; b=mWOem3Q6v5muc+DbCs1vIUWVLBjLCFr9hKMrCN0cfO7Q7730zD4gxaZIgJwQDDtJCHW1zE6z8ivhTtlzbYHtUwKBJ01qjzBBO3OY7xSwdClIYkJ988p8eSR5irg8eijLaCHtJbsRYCPFLTC29aXY1Dh1pQ0TPtjjPGn6vWG87Ak= 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 1723529784924209.6568368365829; Mon, 12 Aug 2024 23:16:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoi-0006xT-6v; Tue, 13 Aug 2024 02:15:38 -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 1sdkoe-0006w4-K9 for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:32 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoS-0003Wb-Fn for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:31 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70cec4aa1e4so3707622b3a.1 for ; Mon, 12 Aug 2024 23:15:20 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-711841effe9sm2559062b3a.31.2024.08.12.23.15.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529719; x=1724134519; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ANdtsuA/TGl02EfU5lGEDU+SzPTDlHokeLE9rDoObAs=; b=MWU4s9zrPg+0gJGXIHlvMKyrMlRrntZxs0/y/2AAusV8PxglTQUkAiytZB1GQYJNB/ 8Oz2Mo6/77evDH4pZOSR7JdHBHOl7D4gHE2Iahdmjd0NO4dBWCeWdKmfmmZMeUqj0N36 ELxlK+FP9AZQbaiY+QhZVJc2A2+xQYadizrdmzfq46krxweNq9htJWm1SrhGMBv2Osrq 8x4rCuEKU2uHJK1gHVDMEa01hSTNDO/TK6FcNNl9pXwO1TrSL3uVv1r0ri/Se9lPNsf2 tntaVyM+02A3Fk8/xTwrG6TqfF00N2LIrEN0LFg+Q5TBBqGkRa7IkVflN+pwW4dh/o27 OwAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529719; x=1724134519; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ANdtsuA/TGl02EfU5lGEDU+SzPTDlHokeLE9rDoObAs=; b=cM0KCNjUdHP9ieAOqRxw4yTptoVubs2PTVBHzXziWd9UFhgYJ9XOG39SbU6SH4lhgI NM7cLrgGIyFzem+HdUCmx56Zd1oE6X/D8Eaz2HtanMUvxUzKCbiCzmMAAJZJL/1kLV5R osp/Ju2ZZG0zyzKjEP70fRSTVNE00koFex1Xd29SvFqrEkzgJauHfqgODskcdE9QUpn5 s0c8LRJOqDuBoWxR/2AOGkz+er7uMYcJRgi1PnvSaDq49LiPePlzGBoVmDbZol339U+0 e2PdcZO+kAmIOOJ4NHO2nV+ESNrsWPjGhmeS+No6/l8TfuIPKJsU7Wj+CQ/Dq1Mds0iX VNvQ== X-Gm-Message-State: AOJu0Yy+RqEoKYhGvU6rUqu3kvBDKffD5mrqUl5gtfH4zMuWJvG0ZMPs TdXa5UW4BxUUiAS/9e03q5upWxvkMnvzDsJYnv7asKlQK6q0RowNpEUCqZb+Aa8= X-Google-Smtp-Source: AGHT+IG9PhobkRPk1zmtFP323fZxq1QL0negM4rQ5O871fzXAc6dm6ZY/3+pmYZa3lD6u48CE20EeA== X-Received: by 2002:a05:6a00:17a7:b0:710:4d4b:1af with SMTP id d2e1a72fcca58-71255142d7dmr3359112b3a.7.1723529718815; Mon, 12 Aug 2024 23:15:18 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:49 +0900 Subject: [PATCH for-9.2 v14 06/11] pcie_sriov: Reuse SR-IOV VF device instances MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-6-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529786796116600 Disable SR-IOV VF devices by reusing code to power down PCI devices instead of removing them when the guest requests to disable VFs. This allows to realize devices and report VF realization errors at PF realization time. Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 8 ++-- include/hw/pci/pci.h | 5 --- include/hw/pci/pci_device.h | 15 +++++++ include/hw/pci/pcie_sriov.h | 6 +-- hw/net/igb.c | 13 ++++-- hw/nvme/ctrl.c | 24 +++++++---- hw/pci/pci.c | 2 +- hw/pci/pcie_sriov.c | 102 +++++++++++++++++++---------------------= ---- 8 files changed, 95 insertions(+), 80 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index a47aad0bfab0..ab2142807f79 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -52,9 +52,11 @@ setting up a BAR for a VF. ... =20 /* Add and initialize the SR/IOV capability */ - pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", - vf_devid, initial_vfs, total_vfs, - fun_offset, stride); + if (!pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", + vf_devid, initial_vfs, total_vfs, + fun_offset, stride, errp)) { + return; + } =20 /* Set up individual VF BARs (parameters as for normal BARs) */ pcie_sriov_pf_init_vf_bar( ... ) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index fe04b4fafd04..14a869eeaa71 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -680,9 +680,4 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); void pci_set_enabled(PCIDevice *pci_dev, bool state); =20 -static inline void pci_set_power(PCIDevice *pci_dev, bool state) -{ - pci_set_enabled(pci_dev, state); -} - #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index f38fb3111954..1ff3ce94e25b 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -212,6 +212,21 @@ static inline uint16_t pci_get_bdf(PCIDevice *dev) return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn); } =20 +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + /* + * Don't change the enabled state of VFs when powering on/off the devi= ce. + * + * When powering on, VFs must not be enabled immediately but they must + * wait until the guest configures SR-IOV. + * When powering off, their corresponding PFs will be reset and disable + * VFs. + */ + if (!pci_is_vf(pci_dev)) { + pci_set_enabled(pci_dev, state); + } +} + uint16_t pci_requester_id(PCIDevice *dev); =20 /* DMA access functions */ diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 450cbef6c201..70649236c18a 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -18,7 +18,6 @@ typedef struct PCIESriovPF { uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ - const char *vfname; /* Reference to the device type used for the VFs */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; =20 @@ -27,10 +26,11 @@ typedef struct PCIESriovVF { uint16_t vf_number; /* Logical VF number of this function */ } PCIESriovVF; =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride); + uint16_t vf_offset, uint16_t vf_stride, + Error **errp); void pcie_sriov_pf_exit(PCIDevice *dev); =20 /* Set up a VF bar in the SR/IOV bar area */ diff --git a/hw/net/igb.c b/hw/net/igb.c index b92bba402e0d..b6ca2f1b8aee 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -446,9 +446,16 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error = **errp) =20 pcie_ari_init(pci_dev, 0x150); =20 - pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF, - IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, - IGB_VF_OFFSET, IGB_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, + TYPE_IGBVF, IGB_82576_VF_DEV_ID, + IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, + IGB_VF_OFFSET, IGB_VF_STRIDE, + errp)) { + pcie_cap_exit(pci_dev); + igb_cleanup_msix(s); + msi_uninit(pci_dev); + return; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, IGBVF_MMIO_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c6d4f61a47f9..e86ea2e7ce57 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8271,7 +8271,8 @@ out: return pow2ceil(bar_size); } =20 -static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et) +static bool nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et, + Error **errp) { uint16_t vf_dev_id =3D n->params.use_intel_id ? PCI_DEVICE_ID_INTEL_NVME : PCI_DEVICE_ID_REDHAT_N= VME; @@ -8280,12 +8281,17 @@ static void nvme_init_sriov(NvmeCtrl *n, PCIDevice = *pci_dev, uint16_t offset) le16_to_cpu(cap->vifrsm), NULL, NULL); =20 - pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, - n->params.sriov_max_vfs, n->params.sriov_max_vfs, - NVME_VF_OFFSET, NVME_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, + n->params.sriov_max_vfs, n->params.sriov_max_v= fs, + NVME_VF_OFFSET, NVME_VF_STRIDE, + errp)) { + return false; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, bar_size); + + return true; } =20 static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) @@ -8410,6 +8416,12 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) return false; } =20 + if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs && + !nvme_init_sriov(n, pci_dev, 0x120, errp)) { + msix_uninit(pci_dev, &n->bar0, &n->bar0); + return false; + } + nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); =20 pcie_cap_deverr_init(pci_dev); @@ -8439,10 +8451,6 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) nvme_init_pmr(n, pci_dev); } =20 - if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs) { - nvme_init_sriov(n, pci_dev, 0x120); - } - return true; } =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b532888e8f6c..5c0050e1786a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2895,7 +2895,7 @@ void pci_set_enabled(PCIDevice *d, bool state) memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_MASTER) && d->enabled); - if (!d->enabled) { + if (d->qdev.realized) { pci_device_reset(d); } } diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 499becd5273f..4bffe6c97f66 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,15 +20,25 @@ #include "qapi/error.h" #include "trace.h" =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, - const char *name, uint16_t vf_num); -static void unregister_vfs(PCIDevice *dev); +static void unparent_vfs(PCIDevice *dev, uint16_t total_vfs) +{ + for (uint16_t i =3D 0; i < total_vfs; i++) { + PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; + object_unparent(OBJECT(vf)); + object_unref(OBJECT(vf)); + } + g_free(dev->exp.sriov_pf.vf); + dev->exp.sriov_pf.vf =3D NULL; +} =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride) + uint16_t vf_offset, uint16_t vf_stride, + Error **errp) { + BusState *bus =3D qdev_get_parent_bus(&dev->qdev); + int32_t devfn =3D dev->devfn + vf_offset; uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 @@ -36,7 +46,6 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; dev->exp.sriov_pf.num_vfs =3D 0; - dev->exp.sriov_pf.vfname =3D g_strdup(vfname); dev->exp.sriov_pf.vf =3D NULL; =20 pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -69,13 +78,35 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, 0x553); =20 qdev_prop_set_bit(&dev->qdev, "multifunction", true); + + dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, total_vfs); + + for (uint16_t i =3D 0; i < total_vfs; i++) { + PCIDevice *vf =3D pci_new(devfn, vfname); + vf->exp.sriov_vf.pf =3D dev; + vf->exp.sriov_vf.vf_number =3D i; + + if (!qdev_realize(&vf->qdev, bus, errp)) { + unparent_vfs(dev, i); + return false; + } + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(vf->config, 0xffff); + pci_config_set_device_id(vf->config, 0xffff); + + dev->exp.sriov_pf.vf[i] =3D vf; + devfn +=3D vf_stride; + } + + return true; } =20 void pcie_sriov_pf_exit(PCIDevice *dev) { - unregister_vfs(dev); - g_free((char *)dev->exp.sriov_pf.vfname); - dev->exp.sriov_pf.vfname =3D NULL; + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + + unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); } =20 void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, @@ -141,38 +172,11 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int r= egion_num, } } =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, - uint16_t vf_num) -{ - PCIDevice *dev =3D pci_new(devfn, name); - dev->exp.sriov_vf.pf =3D pf; - dev->exp.sriov_vf.vf_number =3D vf_num; - PCIBus *bus =3D pci_get_bus(pf); - Error *local_err =3D NULL; - - qdev_realize(&dev->qdev, &bus->qbus, &local_err); - if (local_err) { - error_report_err(local_err); - return NULL; - } - - /* set vid/did according to sr/iov spec - they are not used */ - pci_config_set_vendor_id(dev->config, 0xffff); - pci_config_set_device_id(dev->config, 0xffff); - - return dev; -} - static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; uint16_t i; uint16_t sriov_cap =3D dev->exp.sriov_cap; - uint16_t vf_offset =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_OFFSET); - uint16_t vf_stride =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_STRIDE); - int32_t devfn =3D dev->devfn + vf_offset; =20 assert(sriov_cap > 0); num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); @@ -180,18 +184,10 @@ static void register_vfs(PCIDevice *dev) return; } =20 - dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, num_vfs); - trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - dev->exp.sriov_pf.vf[i] =3D register_vf(dev, devfn, - dev->exp.sriov_pf.vfname, i); - if (!dev->exp.sriov_pf.vf[i]) { - num_vfs =3D i; - break; - } - devfn +=3D vf_stride; + pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } dev->exp.sriov_pf.num_vfs =3D num_vfs; } @@ -204,12 +200,8 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - object_unparent(OBJECT(vf)); - object_unref(OBJECT(vf)); + pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - g_free(dev->exp.sriov_pf.vf); - dev->exp.sriov_pf.vf =3D NULL; dev->exp.sriov_pf.num_vfs =3D 0; } =20 @@ -231,14 +223,10 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t= address, PCI_FUNC(dev->devfn), off, val, len); =20 if (range_covers_byte(off, len, PCI_SRIOV_CTRL)) { - if (dev->exp.sriov_pf.num_vfs) { - if (!(val & PCI_SRIOV_CTRL_VFE)) { - unregister_vfs(dev); - } + if (val & PCI_SRIOV_CTRL_VFE) { + register_vfs(dev); } else { - if (val & PCI_SRIOV_CTRL_VFE) { - register_vfs(dev); - } + unregister_vfs(dev); } } } --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529845; cv=none; d=zohomail.com; s=zohoarc; b=Sic4zByPvkdm+wQLljsuOH9gLQpeTo1r95fEkKlOjwPxZrqVec9kGudQ+wfiseqsj6RaGoiHvO0V9WHDSwkvvRIdFx011WT0YgwqtIHazKDGeEbkOuwQOCYwu+wYf9OcDYJllUicy7kERhvn4jI/9rm79KAZ3CXG0gOXmROel1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529845; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5CGZuhv54KbzzZfkN6AoDeKXUOhgbsQVkrQ/COnk478=; b=AtPrT9/bJ6fitfrSckYcr6jAMZzjRrprM6C16/m3Za/bdMQgiW/e7/+yOJqt20xu318dr3Vcg/QsjaCFivg7XNGZKkO4qUxK/XqQ4A+3gXcWl23zvbbCdrlYtButXvzWOui87JyDWTdxwKYVmFnmWDGePsauMhsw0wRNVCQMfNA= 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 1723529845208222.9181312360073; Mon, 12 Aug 2024 23:17:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkpr-0003SC-EB; Tue, 13 Aug 2024 02:16:47 -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 1sdkor-0007cY-FF for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:45 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoa-0003XE-Hj for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:45 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70d2ae44790so3596271b3a.2 for ; Mon, 12 Aug 2024 23:15:24 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-201cd1b471dsm6185785ad.201.2024.08.12.23.15.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529723; x=1724134523; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5CGZuhv54KbzzZfkN6AoDeKXUOhgbsQVkrQ/COnk478=; b=jNctXkflen3KJzNEIdGGZQi1sGji+vUR/IuEMgTbqYi0mZUJHkBVlFXpvmdXNOgWmQ 4g2n18piVzW5KEI71cwbX556HIqPInluhphNRiaxs5WajIpa19NrHO52ay9vbuJ0MjHi Z3z3uFlcWxGihGKbd50LmK6LS+eualc2tXQ9avPprho9UK38U10FxXqd6EYP36p5xYRr ZxMLIZk/K9iNkakNgxKUG/BUS0JG776FKAoJTVdN7hwJM9mRCKaOb+Lqa+msDwBw8CCk aR0vrQ2iAS39LtR/gvwQLclKsO4avSrNnoo0L9oFQwJJyGETwyoz2PL9XRDA1wg+Tvir AVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529723; x=1724134523; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5CGZuhv54KbzzZfkN6AoDeKXUOhgbsQVkrQ/COnk478=; b=sPI7P7B0SgLN0GGzsVqju3wAgKTGxbP3d19oVluE5WRZReod+0d/q5JRRkuPZvP/Og znceI9jOt8dm8euEj7kS2tpw6YFbgC+ocgKxZ5tmW3vCoMkWdr2l4dsdyurMFQAKAbIH EOShE6nwvGbcq52Qu5FC1REtzpxhpOdX8upyN7Dl5AEiSbE1S6feUTYDm38GyBr+TgLi WTPTpPtyIoV9Vzf8pklvghPYjKbGvheKE2402a++8wPEcvckapOhLL6kByTOwkphdJGf soPgRTl3NANLPzM3/lciDbjot8HemfdSCHHgb/08R0zdsO/ZFUQICBnXgTjG4t6/Jo8f 8hRg== X-Gm-Message-State: AOJu0YyGw6zmrcfkg1Y0bPg2Y2Qo8q+bk9hRqoKG710X1UlKd1U4pwlj mN5T7+OD816S9OjrUh3JXztdh8CquKJ1Fnl7VJ9HmRvl3RLb9ht13Auw+hv4q28= X-Google-Smtp-Source: AGHT+IE0pglnaj4j0HQIzVbtnwwhhgN9n/g1yTCaRoXDEbqyXEb6JbVpBkmDRQSoT4/83tX46rGD5A== X-Received: by 2002:a05:6a20:6f08:b0:1be:ffe4:b2a2 with SMTP id adf61e73a8af0-1c8d745a6cbmr3275098637.7.1723529723349; Mon, 12 Aug 2024 23:15:23 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:50 +0900 Subject: [PATCH for-9.2 v14 07/11] pcie_sriov: Release VFs failed to realize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-7-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::42c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42c.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529847167116600 Release VFs failed to realize just as we do in unregister_vfs(). Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization = (SR/IOV)") Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 4bffe6c97f66..ac8c4013bc88 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -87,6 +87,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, vf->exp.sriov_vf.vf_number =3D i; =20 if (!qdev_realize(&vf->qdev, bus, errp)) { + object_unparent(OBJECT(vf)); + object_unref(vf); unparent_vfs(dev, i); return false; } --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529833; cv=none; d=zohomail.com; s=zohoarc; b=Q5YXagrey4/ouzKVSPkIOPw69iL4XoLlCXO4IU13mkCpKProGOpCLwqZ0pGtZtQKL5ApH3zE+hvvCsbUyoiD3vcfBL1i2V/Vc4AuxvOltAw0LKijUh1lspKTppOHbGct3r5GGxhNA/Rvkzqbu8WYsZNRR8omKG686p62zdY79Xs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529833; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NpdrESgH8yB+yjouz5MNrbZmq6Tv3XFM1h6NjURYvQI=; b=kEp/9D6J5ZzctQjfrGvxAgQw4uRUhl1tiLq5offiorw62cDooelTGBRw6dHoprqgxofAgxbp0/OvksXCy7aSs3HbT9jZG2iTcG0xlMjZE8eSLjofEidannqf8GkJH+0TlXGLCYPXHoJmm8f6+mnZg1NEzMo4T+vhTaIBlw4kI6Q= 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 1723529833983692.4823669563388; Mon, 12 Aug 2024 23:17:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkoo-0007JK-Hx; Tue, 13 Aug 2024 02:15:42 -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 1sdkoh-0006xk-6B for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:36 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoe-0003XX-HF for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:34 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-26827ec5235so2590333fac.2 for ; Mon, 12 Aug 2024 23:15:29 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-710f7e1b345sm3388105b3a.151.2024.08.12.23.15.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529728; x=1724134528; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NpdrESgH8yB+yjouz5MNrbZmq6Tv3XFM1h6NjURYvQI=; b=bUvO/KIzpbNWA6ulV/npHSJZWqYRs9hdUNu2by5pLaEo/H4vk+ww6mOpZd10ZOh86E H+ldgpbe9YwMKIfyONovCPA9dlHPrVmvhUjM4FMx9VBnQ3BPfRmwIiBOlER15KUXcngW Pb4kR8o4rdrDDsN27sxs/mGJ23osZAuF4kchq9ZJSMD7zBEM38DHXBia+JOAu8MDyilx tXLLRb+OETkGwNBHTqDVwMf/kSI5FUoepNjnl63mwUYes5/BhQYUP98Uw/VTaqjYzJx6 iKDyOrvolXI1ZuvNUx8L/01C2hz/AHRTzOXz4Yfc6WehbAqZaU6ZEyAZpasr7UVvdE9k 2Xcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529728; x=1724134528; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NpdrESgH8yB+yjouz5MNrbZmq6Tv3XFM1h6NjURYvQI=; b=XUBNiFYhRmz81fXVSRq+Wb1YwEpvFr+tItzoRaUaNT584VPBUWv+Nm5tKqS5ZxJWdt k6Jvy7DcLDQ5qohkkw2d43kM65F/knZ8XIfRPEsTJaAvFgYRWWdV9SL9899bn0GTS0xn fYhYuOMfexJ51yFLBbUGTI8zxT+Otnp+75Es/bdF7DhsQspg6qNYxWlr3+ZX1ZNlcrfh mKK2SkY0I5lzbm5aQdqpihGvj59tK6WBRiTdCYX/FlAvqLTgiAztNLsq+VHpDZOSwSjD 22Rysg6fwgHnpnbPtmi/fZ6hb7veygolEfuuhGpaZmtOkKQD1PazVep5X9D8E6Db6wEd 1fyQ== X-Gm-Message-State: AOJu0YxU/5kV2qhCrrhHppmuP8pQB/YE4jFEHELMAj7JX2EmTeEX3CsP igOA0TRMsJj8pU1VOyp5ma18EuA7JQz+XZIUVoGwlpcO8Kbg4Lc6e0J6SC9nZ7/eOQ6+hZO9p3+ mgVk= X-Google-Smtp-Source: AGHT+IH7OgfrjLg33+ehBWxMQOzyU1inGG049EMf2dzjk52EuLwBNSNeFCBaTd/rA3NHc89s5TGYPA== X-Received: by 2002:a05:6870:a68c:b0:268:79c1:31d2 with SMTP id 586e51a60fabf-26fcb361b89mr2976810fac.0.1723529727996; Mon, 12 Aug 2024 23:15:27 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:51 +0900 Subject: [PATCH for-9.2 v14 08/11] pcie_sriov: Remove num_vfs from PCIESriovPF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-8-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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=2001:4860:4864:20::33; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x33.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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529835121116600 num_vfs is not migrated so use PCI_SRIOV_CTRL_VFE and PCI_SRIOV_NUM_VF instead. Signed-off-by: Akihiko Odaki --- include/hw/pci/pcie_sriov.h | 1 - hw/pci/pcie_sriov.c | 38 +++++++++++++++++++++++++++----------- hw/pci/trace-events | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 70649236c18a..5148c5b77dd1 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -16,7 +16,6 @@ #include "hw/pci/pci.h" =20 typedef struct PCIESriovPF { - uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index ac8c4013bc88..91e817617238 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -45,7 +45,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; - dev->exp.sriov_pf.num_vfs =3D 0; dev->exp.sriov_pf.vf =3D NULL; =20 pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -182,29 +181,28 @@ static void register_vfs(PCIDevice *dev) =20 assert(sriov_cap > 0); num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); - if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_V= F)) { - return; - } =20 trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } - dev->exp.sriov_pf.num_vfs =3D num_vfs; + + pci_set_word(dev->wmask + sriov_cap + PCI_SRIOV_NUM_VF, 0); } =20 static void unregister_vfs(PCIDevice *dev) { - uint16_t num_vfs =3D dev->exp.sriov_pf.num_vfs; + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; uint16_t i; =20 trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn), num_vfs); - for (i =3D 0; i < num_vfs; i++) { + PCI_FUNC(dev->devfn)); + for (i =3D 0; i < pci_get_word(cfg + PCI_SRIOV_TOTAL_VF); i++) { pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - dev->exp.sriov_pf.num_vfs =3D 0; + + pci_set_word(dev->wmask + dev->exp.sriov_cap + PCI_SRIOV_NUM_VF, 0xfff= f); } =20 void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, @@ -230,6 +228,17 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t = address, } else { unregister_vfs(dev); } + } else if (range_covers_byte(off, len, PCI_SRIOV_NUM_VF)) { + uint8_t *cfg =3D dev->config + sriov_cap; + uint8_t *wmask =3D dev->wmask + sriov_cap; + uint16_t num_vfs =3D pci_get_word(cfg + PCI_SRIOV_NUM_VF); + uint16_t val =3D PCI_SRIOV_CTRL_MSE | PCI_SRIOV_CTRL_ARI; + + if (num_vfs <=3D pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)) { + val |=3D PCI_SRIOV_CTRL_VFE; + } + + pci_set_word(wmask + PCI_SRIOV_CTRL, val); } } =20 @@ -246,6 +255,8 @@ void pcie_sriov_pf_reset(PCIDevice *dev) unregister_vfs(dev); =20 pci_set_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF, 0); + pci_set_word(dev->wmask + sriov_cap + PCI_SRIOV_CTRL, + PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE | PCI_SRIOV_CTRL_= ARI); =20 /* * Default is to use 4K pages, software can modify it @@ -292,7 +303,7 @@ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) { assert(!pci_is_vf(dev)); - if (n < dev->exp.sriov_pf.num_vfs) { + if (n < pcie_sriov_num_vfs(dev)) { return dev->exp.sriov_pf.vf[n]; } return NULL; @@ -300,5 +311,10 @@ PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, = int n) =20 uint16_t pcie_sriov_num_vfs(PCIDevice *dev) { - return dev->exp.sriov_pf.num_vfs; + uint16_t sriov_cap =3D dev->exp.sriov_cap; + uint8_t *cfg =3D dev->config + sriov_cap; + + return sriov_cap && + (pci_get_word(cfg + PCI_SRIOV_CTRL) & PCI_SRIOV_CTRL_VFE) ? + pci_get_word(cfg + PCI_SRIOV_NUM_VF) : 0; } diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 19643aa8c6b0..e98f575a9d19 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -14,7 +14,7 @@ msix_write_config(char *name, bool enabled, bool masked) = "dev %s enabled %d mask =20 # hw/pci/pcie_sriov.c sriov_register_vfs(const char *name, int slot, int function, int num_vfs) = "%s %02x:%x: creating %d vf devs" -sriov_unregister_vfs(const char *name, int slot, int function, int num_vfs= ) "%s %02x:%x: Unregistering %d vf devs" +sriov_unregister_vfs(const char *name, int slot, int function) "%s %02x:%x= : Unregistering vf devs" sriov_config_write(const char *name, int slot, int fun, uint32_t offset, u= int32_t val, uint32_t len) "%s %02x:%x: sriov offset 0x%x val 0x%x len %d" =20 # pcie.c --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529818; cv=none; d=zohomail.com; s=zohoarc; b=Ji01BZLMJMWX4oNqMAgS44kSgvf3mkREgVr/3pfEVoIsCKOaPKxC0AE90XQMcqbXUnWJZOhHbGvqdSYE3O1+aDKbNA231xSR5RybSTNN8vBkpOKNHG2ahg4k2tjqe11UoYsqm/gIWGcGHirRbaew/MlHrJhFo+FnXd+D2gowKJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529818; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ou7ZJrgBuVzv4pqn/hJ30lFJuCggSMTVtSP3YbwS9Xw=; b=ZzYPKS3ORfcUPN2QVhA+aG+uER3yvSXKZ+6dv2ApF35bJEjKJ6lueilMId6lJU5aStGwsypPi+0W1kVcPBqmIKwJNwDn2P7n50qG/zBS0u6Ed7NhVe7h8afB06zWnn7Yhw/fjlT1zqMqmP/e3AmHpjTneyV3YwGW3JgE5Km7M7Y= 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 1723529818736868.2895014022622; Mon, 12 Aug 2024 23:16:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkpR-0000eH-0O; Tue, 13 Aug 2024 02:16:26 -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 1sdkok-00073Q-CR for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:38 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkog-0003Y5-6y for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:36 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70eae5896bcso4612133b3a.2 for ; Mon, 12 Aug 2024 23:15:33 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-710e5ab56c4sm4927787b3a.203.2024.08.12.23.15.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529733; x=1724134533; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ou7ZJrgBuVzv4pqn/hJ30lFJuCggSMTVtSP3YbwS9Xw=; b=pA2xrd6YH+EbEtUyaA4Az0Nq7TW5sFkqg7qT8TFAYOE2TrJZz8Dp2l8TQieS2jwIRz cnMBEIBUS+yAYgsep18fIoRUF4mFFxyjAAz17klgz8VcRXgZhwPG6SoBf/BIYiajbTZg q1UohPXi2HMR8p4lKwq99J0TrtDFgChbXoKvyOLJaJ2YlydKOuzjFX+JEj6MKNi8GUjr 5FhxWJ0XhogBKeOPSmdSdbAtNuUsqemXge0RPjuCU2KbMiS2LCpxB3MRNqC816eGpsbd /jL99KsqvR7PVXKBLQXPRdDhhw5ODJxKBIAQLtGHfL05PPP8lQH8Wh9wx1zWcZZ3f3/D KfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529733; x=1724134533; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ou7ZJrgBuVzv4pqn/hJ30lFJuCggSMTVtSP3YbwS9Xw=; b=P09L3bVHlpXaMj6MLZbfE86x0II08VvRU9ifCtqVLKLN2BVbY5UP7sxffHarqinPt7 2pFTUTWYiyUSzhpCAXrv7+7UvF5YRgogUVvEatoXXvlmXHjuHWd9HGKz2SZMPGsNYW4S Sc3rzvJzOhMAQC0KMhYEExefUVxQj6KJ04zF3OIE0Zd1f+jO2mePvOuRQgZK0rD3iIuD pYaTrZLRk5f1YkVVrKjSGi4MvwzgtBEdgStUvQw3ae3+7xBqV52HvIVBA6dq8YlrulSg ybz91QXY1WorZ9tugXBuDRrc1JnPArn36vOFaLeeWhzD4wjsSFX0LiqH69mw2RM1nHC/ yR7g== X-Gm-Message-State: AOJu0YyptfNfLgKSRzSw8VXCLfo3LJKuWgrpsBz02IF7kOTxf1bvV27l lE2Zp4YY1PBY21/rguNV7AH/HjrQJptvIyW7zrllMEoM0Hyol+2lOP4o2QsslkupxHbOg9EX1uD kxQE= X-Google-Smtp-Source: AGHT+IHx/EpnZ0Lhs8UXd9p2r9G8bwJJMpiaX3jMO/FdaIfyIK1/wBxLDR2GRrxDkV3GvAdxSEIUMA== X-Received: by 2002:aa7:8891:0:b0:710:4cf5:c570 with SMTP id d2e1a72fcca58-71254f5f826mr3640638b3a.0.1723529732626; Mon, 12 Aug 2024 23:15:32 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:52 +0900 Subject: [PATCH for-9.2 v14 09/11] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-9-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.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=unavailable 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529820857116600 pcie_sriov doesn't have code to restore its state after migration, but igb, which uses pcie_sriov, naively claimed its migration capability. Add code to register VFs after migration and fix igb migration. Fixes: 3a977deebe6b ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 7 +++++++ hw/pci/pcie_sriov.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 5148c5b77dd1..c5d2d318d330 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_= t opt_sup_pgsize); void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, uint32_t val, int len); =20 +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5c0050e1786a..4c7be5295110 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int ver= sion_id) return !pci_is_express((PCIDevice *)opaque); } =20 +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device =3D { .name =3D "PCIDevice", .version_id =3D 2, .minimum_version_id =3D 1, + .post_load =3D pci_post_load, .fields =3D (const VMStateField[]) { VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice), VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 91e817617238..1eae9f0a0acf 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -242,6 +242,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t = address, } } =20 +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + =20 /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev) --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529819; cv=none; d=zohomail.com; s=zohoarc; b=nhuwkkDn6aOp+oa15QgIaNTgWGvnKqaVyDRi9wZ7Gfg+TfRqKkREzEnw7c2+3RUs2yV70H6hovAp8m/cVevl55qrAjWACHqlWgUIT7hYWJl5NGvXrVwTdUKRS8aoaeJvv1zOkgCSunnhxnUnc41iK21lcbS0e9wpnTgRlF/08O0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529819; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=e5cIklUW8jd6tKZfpSBrRyaDJV5WcF0ttv7u1/dlPJxaUnnvwIAjF20BWocYJOiEFrrC6PGa3p5fNeq2xMJj3j1JKgWljcJAbdHtWmBIT0WCv1gpV/xswZIxii+BG+YYPHliCqtiitGmfhKBIw3mbBaCJD5DwfiU11OmSqRbRP4= 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 1723529819740282.41313961669164; Mon, 12 Aug 2024 23:16:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkos-0007g8-EP; Tue, 13 Aug 2024 02:15:48 -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 1sdkon-0007JI-SS for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:42 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkol-0003aB-Qz for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:41 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so3298989a12.1 for ; Mon, 12 Aug 2024 23:15:39 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d1fd01a448sm6262703a91.49.2024.08.12.23.15.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529738; x=1724134538; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=JNhj31OMU2Q8FTRRWBCwRX5s0ML0f5TF/At5rmvB1FlHD58tFTz9vueHZV4jAhD/Di +265OUliBOuTJc4AVmYlSUn8TkiIBOylUFZa5ymGu9nAXrgco6AGwkkEaoTdsigbgtAN Lup4OXmXmuWTHNxwEP0MYwVjL1lL4kwHAIT8YUt3flPdBoELu1ETP7qk1YmBlhIyE0wv yayfdpoUi1bUP4ZVhZquaFD8htpAAvg9ZfHD+q26IHYio0YnUioDbbDG7y9oBhiBQGRl xO9YulUcsHUcPYuxkn20vFOXFXoRwG0lfR2CYl1VK/pnxOhoolfqdbUMuT1GRByKVVvR j3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529738; x=1724134538; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=RIPUhb/bZprDzt+OBM9c7OI+pOo9r3rwKKtMtev+NL02MxFNCd10JqiTW8pdZjQx0f LRDt5ZGdAIkKj7QswJ5vvahtZTaiSY9HDBs30TAiikHdcB6m5JW7eEhpXKoeQtrwFwb3 rU0nW9geBC95kL27gGl0BeBETUoBXLFrnStmYSrXHbBG7K9Bah7Mo6O6/3GPGJtm7UC+ tMwQylTwburkW7DoRjI+a12/NFbsw8UGy1CC9ak4kHLxYTctx9fsdQ0NSM9bm/MQEDTF nC4ftNK6JknCHYIwm6tGpkHUk0MclHMrXVpfjycUTLKNgwgZ+/DOPaZ644K3I/nTXLjn l/eQ== X-Gm-Message-State: AOJu0YzrtPFHJfTjZPVOmOLQrWt4YNJ/0QBO4TM9RT3LXMCnJTE0eChi hVeeN3rWZNml6LneFbf/1AH8y+nYXhdcodskLQ8cGWR2INhOE6uIh9nVA74e1ok= X-Google-Smtp-Source: AGHT+IFph3uB81Z1nge6y0CzHfO4q1huFVg5pC9dVwXpB4kQeZgvWpHeCxg+8/LcZzEePVujQHi5JQ== X-Received: by 2002:a05:6a20:2d0e:b0:1c4:8293:76d0 with SMTP id adf61e73a8af0-1c8d7444e36mr3399329637.4.1723529738011; Mon, 12 Aug 2024 23:15:38 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:53 +0900 Subject: [PATCH for-9.2 v14 10/11] hw/pci: Use -1 as the default value for rombar MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-10-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::531; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x531.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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529820898116600 vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1 by checking dev->opts, bypassing the QOM property infrastructure. Use -1 as the default value for rombar to tell if the user explicitly set it to 1. The property is also converted from unsigned to signed. -1 is signed so it is safe to give it a new meaning. The values in [2 ^ 31, 2 ^ 32) become invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster --- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 2 +- hw/vfio/pci.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 1ff3ce94e25b..8fa845beee5e 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -148,7 +148,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + int32_t rom_bar; =20 /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4c7be5295110..d2eaf0c51dde 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -71,7 +71,7 @@ static Property pci_props[] =3D { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2407720c3530..dc53837eac73 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size =3D cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset =3D vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev =3D DEVICE(vdev); char *name; int fd =3D vdev->vbasedev.fd; =20 @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } =20 if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar > 0) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " positive value for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues", --=20 2.46.0 From nobody Sun Nov 24 11:28:24 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=1723529833; cv=none; d=zohomail.com; s=zohoarc; b=Kg2T7hs/Xw237xqR34UZkWEaVRt6aJBD+X1oW7rFqeeK7ZtsjOBrP3b0opxy3N0ygTQUoFXE9QqyiqzRMCoxLAlXNqmVL2agDhLvH+emhWysnXQaCNRiOVQvQBr75PrN/Y+kpzrktJjBrjpxqvE97opilEAH8tTV0C4RYLLrQ/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529833; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fEpDPUaFL8zPvYOx/0hsO+TqHl11ExTE7h8t0M0WvV0=; b=eKm8t672u2o/51c1VRM6qCZEws7I53g6Hr+gv+X3CF3E6oF1hpQDJwb5vse5+DpnY+E/KckT1/fvJAjJqtHLs9uMvo1ma13PsP1jdOtJOgKqEl8dY2QsoguiT+ZtfWqH6DSIry23T0xrTTi0tDn990X5AlATnHuCUF3qU81JJRw= 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 172352983338113.131226737890984; Mon, 12 Aug 2024 23:17:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkpi-0002h9-R0; Tue, 13 Aug 2024 02:16:40 -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 1sdkov-00082n-OF for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:51 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkoq-0003ay-8a for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:48 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70ea2f25bfaso3653156b3a.1 for ; Mon, 12 Aug 2024 23:15:43 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7c697a55b4bsm682700a12.73.2024.08.12.23.15.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529743; x=1724134543; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fEpDPUaFL8zPvYOx/0hsO+TqHl11ExTE7h8t0M0WvV0=; b=u42ITD3gX5ESXjMYKzYmGq7CM56NyeS/B1r0YJPsKfUwqgT0getD8fZF1ERt9SiWoZ vFYoZIn74fJzD12FWUREPIlaELdtLXF9h5de7V50Hk/6K6b6btpBU+jAEzkSkh71EcU+ wL9z4Pgrn2BbzbB22B8KXyjFMvmLPTgTSiWHt/q+u33QBB0lUZhmeZ5TeqtJxsbxVugj awPq1IFeD17Oi5S6/yU4ZGl5/lh+CUJZ0S/PsPnY0j++eWsuyS2AOmtPxzWmmmLAAfvl r9PketN4b6poHc+v/LahReY/2Wkd3RlYs1t/dq8gFEbi2S9lrIK+omdw0y0jB8B/qbMh u0KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529743; x=1724134543; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fEpDPUaFL8zPvYOx/0hsO+TqHl11ExTE7h8t0M0WvV0=; b=bukDvPyLNdBJ5CdyomKzyA7oHZoL88dOhJhb20lQKa5qMsY8vDDFHTpWc5EXcBhCtR GEtzzhV3r0n+/ihDFhPQIRD+Ud5/HXYgfRdaJKCeXWJM2M/Ilqql0jw10fpbsiZEasEV 28ekCfyoBekcYvOiHX5ahbmeYHBNlgeD4pzBbYAU7/2gMTGXfUkIrVvPLRNeQeLYNOyM htRf6ygLN1s01kr6ld0p6M0Nt/t9X23Xy0gKhkY8IxS/mAar6NdXN3d7L0FZ3KRpRZkS CH3HM1eSZpJHGZ1/eNuaFr5FAL5fHIjfGbkJcx8lixRORkRbx2SExQzt5ALrAzEILqsX pZ1g== X-Gm-Message-State: AOJu0YyPOgD7Xdf8v60aZv3/vwKdQz44iq4QFNthYIbXOXytKaSRD8Ww wE393u+H3P53XHwEcXP/gFFXt0GxTGpLVEc/0YtUBZGNCyUL1Y0BHfWfOHHTkIo= X-Google-Smtp-Source: AGHT+IFIH3gjlPRuJ6nubMBXzagqt2IaxRLewnMy5VopTTtGPknA5PSV8gjmxP0UnQ+uLQPGroLLVA== X-Received: by 2002:a05:6a00:a8d:b0:70d:37f4:2c73 with SMTP id d2e1a72fcca58-7125510f688mr3025016b3a.10.1723529742776; Mon, 12 Aug 2024 23:15:42 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:54 +0900 Subject: [PATCH for-9.2 v14 11/11] hw/qdev: Remove opts member MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-11-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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::431; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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=no 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529835136116600 It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster --- include/hw/qdev-core.h | 4 ---- hw/core/qdev.c | 1 - system/qdev-monitor.c | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 77bfcbdf732a..a3757e6769f8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -237,10 +237,6 @@ struct DeviceState { * @pending_deleted_expires_ms: optional timeout for deletion events */ int64_t pending_deleted_expires_ms; - /** - * @opts: QDict of options for the device - */ - QDict *opts; /** * @hotplugged: was device added after PHASE_MACHINE_READY? */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f3a996f57dee..2fc84699d432 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -706,7 +706,6 @@ static void device_finalize(Object *obj) dev->canonical_path =3D NULL; } =20 - qobject_unref(dev->opts); g_free(dev->id); } =20 diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 6af6ef7d667f..3551989d5153 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -624,6 +624,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *op= ts, char *id; DeviceState *dev =3D NULL; BusState *bus =3D NULL; + QDict *properties; =20 driver =3D qdict_get_try_str(opts, "driver"); if (!driver) { @@ -705,13 +706,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *= opts, } =20 /* set properties */ - dev->opts =3D qdict_clone_shallow(opts); - qdict_del(dev->opts, "driver"); - qdict_del(dev->opts, "bus"); - qdict_del(dev->opts, "id"); + properties =3D qdict_clone_shallow(opts); + qdict_del(properties, "driver"); + qdict_del(properties, "bus"); + qdict_del(properties, "id"); =20 - object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_js= on, + object_set_properties_from_keyval(&dev->parent_obj, properties, from_j= son, errp); + qobject_unref(properties); if (*errp) { goto err_del_dev; } --=20 2.46.0