From nobody Sun Nov 24 12:25:56 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=1722852152; cv=none; d=zohomail.com; s=zohoarc; b=a29S4HvNUVPC+VtEt2a0OtiBdA3S7LopQgMc0EUH2BWmDLM4wIg4DuR6FmK799cknZS3yrIDilbkB8X2I3ZiM2fuBUG2qs/2CxqeGY0/6fhb0P/43XWe2Ljhrq/m3ALkPcXvz4fw5643EwT5E43rvRC2gbn5lVZaRrWep4Cjots= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852152; 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=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=nTtbZC6Yebb0731l6CSK3y3TQNKNQtlJ9n8bZSo3G/FG4y0vPfLA1MBbryf1t4oO0u2ahytTn0ePQZfhY+KoK6yci2Z9AePf29afl8yBhWNx7OdEKpF47liGs2ETHniSLXVrCjhktzRg1fwwI8R9nc6wU5xO+sKF+rmmGvBl4XQ= 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 1722852152709156.5318471162808; Mon, 5 Aug 2024 03:02:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauV1-0002wr-K8; Mon, 05 Aug 2024 05:59:31 -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 1sauV0-0002st-GI for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:30 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauUy-0001DO-SI for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:30 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7b0c9bbddb4so4779575a12.3 for ; Mon, 05 Aug 2024 02:59:28 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2cffb0c4682sm6553710a91.28.2024.08.05.02.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851967; x=1723456767; 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=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=LtdanKyaCA1Q16fC/xKAHqqM4fDWmr3XMLDol9I5LnM2QW6+Kw3EGRPOKUXmiwEBcs TEkO8VAn2lapgJfpo87Vly5EFAnq1qivj0B4fPpNyQv2wuvaBY0xKLjZZWzDarmclZvs 5/S8SI7pF22m064rLZ+6B0/MHL+NNTiKO0J5btXLYp3ywIXqkO1nXKSOiYn1BwJO402Y n+uEdeEVv4nEyRaTndT1u1iGRsWc/jogIuJS/YZIUdegKIwomQAfUePyh896HhBNeL36 NLMqfpCqoZo6WA0hCa28zoWzajcHYa6jYV1QHxw+qkAYZVh/Kwmisg+BIhzz7YIkKhM1 dESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851967; x=1723456767; 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=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=WX7qmbNURfkaZL3YDtIoAp/LLUVG/pZDYKLDa6l5pK8B6a6Z6HP48j0o6CVecuxCwC 4467QusTsVyfoLQ5CL8VTnEzRjPa28U+usGL0xv65vnxmbyGyP/oS7fNSYUJHPFH2d7R IqMS9wR2A2T7xqpqWVWhd5ZLkcsOn/TdwbblgOvLiAV7hTasDhDznDURxdrdMuABA1qA v91IslleoVcyv4NwX+ra9HCzpg10r7+kqmMe4twne2Lfi8/LsZj4yl2kCZGy3t8mPI+8 JrffeSpqStGaGmN9NHS1S4ISPahojcqvsQzulF2EiHBB6U6M53cN3TIjENCbA60fOKQB hQZg== X-Gm-Message-State: AOJu0YxRKaPz4bx+TI5uN1Oi00Xq7I64zfXh6BCSlPY303IR9cW6bepw quEXVFfM5F6dJIE2oI0pfymDXHew4Rub0Ux+asePT/KMxAq5rTvkcFjmj/at+90= X-Google-Smtp-Source: AGHT+IHdnu5ZOKLBGuvVw7c7mRd5SA7aE/PXVzDPlyWMXFEpysfV5eI1Jb+RDBrfS67Et9PC930FAA== X-Received: by 2002:a05:6a20:6a13:b0:1c2:8af6:31d3 with SMTP id adf61e73a8af0-1c699550d06mr11919545637.10.1722851967499; Mon, 05 Aug 2024 02:59:27 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:58:58 +0900 Subject: [PATCH for-9.2 v13 01/12] 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: <20240805-reuse-v13-1-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::530; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x530.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 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: 1722852154893116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852065; cv=none; d=zohomail.com; s=zohoarc; b=DLEyKDZn/OLJyBhIl9nLgV5qHZPOHxgNhTnDfUkMP38kDx7AU5DUtn22frjB9CU5NzzOBy9cGu44ibZ+6vkDS09ZJeYaSWDn6y/SgDz199Pofa6GFczD0S/BiyoGU0TdVacCoSh5eBhsrWFL/zBlCDIARIxvuI3W4bXUJKq5AJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852065; 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=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=F9o6u34Ox4IY/y1BKERL/2dQeTGrt4M7AgH0hOV9p4ceuYkUZCYKgBG3yi6JIjWsu8/jCICf++NLj+na13+mUQ0v7IWMK00V0MDYHXw28qi8HPoubvN/8+wfF0w7FO48guBc0CRpBNeQsAB9lGbn085NclMzJ6jTGM2wWh9Wwo4= 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 1722852065414788.6184286946166; Mon, 5 Aug 2024 03:01:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauV8-0003CA-48; Mon, 05 Aug 2024 05:59: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 1sauV6-000393-7O for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:36 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauV4-0001Dx-NV for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:35 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fdd6d81812so88694925ad.1 for ; Mon, 05 Aug 2024 02:59:34 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58f2a22bsm64017635ad.10.2024.08.05.02.59.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851972; x=1723456772; 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=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=0LiCMSTInLESWSlSIdiPdlxn+T5sMai059YBDeSU3GxOTMTWM0IvouAoQSIOruLncD 9Ckz9PLuCfspEEAZqZyfWfzgiGQypvdFtsvbKP2nVMkXwrKsQBopXun9o104ZuJtD+kJ 54A0weQ2FRxDThZioyskOJT/m1Yfj9Nvm20ZAISX5Y/mxuRnUkb3m0EKH+CjTepM46Xx B4GpSG/kAzNNOQC7nnRywb1HbSgHB283znJFiTkffXB42e87QrIx5P5yibMBqaWYR+Xi qCT+qMczw8gXAyZ5nkiDVk28hCIxO+5hoIv0su1wc5lY0bpXOvB/2lLqtSmlvVIBJmI3 NMyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851972; x=1723456772; 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=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=qxrHu2FtWp+R0LgZQB+waVALNSnabZSKhTrwVeNnC8qBA4XXS0XsQeoZP6/yZISZEv DUVbBjRbTEEckLgAV7z4KtHl+G5jlrmZWW1Pms8/WAVBSglChGaDh9zsfhZKGouJtFVv DRT1EBiPFvGPRKv+bwmD5PCCYfinta9JBoWzJxPaX/6ViN9WtOt7iB8N87C97JtGvPn1 NHZ8Y3wJoCn8NMNErTzDkVRQTnd6A21TPKXTKVZqaiAPRTTX1PtrM728E1t+uWB3S9Gb MNyUBpyBkSpYMSS5fFujEkRS+ySvu0e6+SpDyLg7XiV7jJ7LITc2t8zD4V33j7gv/92v Fh7w== X-Gm-Message-State: AOJu0YyK49DpY8iiRRLIGHuMOr/ig2HhOGZsf8r0Hqz5AjZbbOzKzUB2 deTSxlrVIfFKNP1Nw/073SroOKa6UuIunL54Mh52h9/WdinbMgNMxqORwFu4p30= X-Google-Smtp-Source: AGHT+IFMxas0IGE1uLO9bondQe0+egYNs5JjKDwQHB5wZvCvKWAConiEj0Dg51LGeNdwFeHDXmPr4g== X-Received: by 2002:a17:902:c94d:b0:1ff:4a11:5f72 with SMTP id d9443c01a7336-1ff57271b1amr145075095ad.23.1722851972213; Mon, 05 Aug 2024 02:59:32 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:58:59 +0900 Subject: [PATCH for-9.2 v13 02/12] 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: <20240805-reuse-v13-2-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.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 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: 1722852066613116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852017; cv=none; d=zohomail.com; s=zohoarc; b=VRK2AbnEzi8PQawKpoesZ2v3BrPlfkiwyb3EOVwB3nJvkVDs+UH1ss6I+dhYz0vGsjOHcQuCMaKdGHlTn9kPCauL/BmCAyd0TofffywnHj+CiKrUAo7eJIeh5c1VS6XGCXXGM6UgY0d3BUefqvB7yZUaD7DH25mgfxESxBcFdyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852017; 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=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=EV/uAGCwDRvRmLr73E45aOLi9ilv5UjLBOwsRakq+0ZKBPcsxX+Q9cin3nR35uJjkRbzgC/12cBCKUW0EHO6d+Fd2/cKu2rkg+gka30tIK6p/OXoESzkHDGBfHdgT463D2K6rZGxqpx1AV9XA7rEiavQlTycKSHNj7MlyhiMxcA= 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 1722852017587949.6452570861968; Mon, 5 Aug 2024 03:00:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVB-0003Qt-Nm; Mon, 05 Aug 2024 05:59:41 -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 1sauVA-0003Nh-L9 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:40 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauV9-0001EN-4v for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:40 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fd9e6189d5so80731135ad.3 for ; Mon, 05 Aug 2024 02:59:38 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff59060045sm63441995ad.147.2024.08.05.02.59.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851977; x=1723456777; 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=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=OkpL3jk5uiZ9KfXMdqIbRtr/+gILbs9EEciFP85LGJuRJ5r4CM3XivHkZ+zvfzCccH LjXKnZYDQaajgmjcdNED1WmzykDH2WBsHWG1Qg/NZ+JrDxPimIdqqvuXcabvSpVDAXe+ OuMmjtfsRHAy34Tc001Df6bf/girtpCra5aNIZLyTLvrYqLP5joroSHl/mVfMliiwoan t8gn564508MuRDOxbzPiGMNzff2yQqf8ieLJCZSoRRjVToyW7Kpuw84Z96xUnbMXs1WI Lvd9JJnH9FRNey4wvyD7DzSSIczCUUgg3osns3cUXX/du1oFrNmXmT0RgS7lEMkGgJd5 iXVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851977; x=1723456777; 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=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=OfmuCxralnZg3NAh6/7M5Wzag/8LbVljIjqAKvRSFyg8oCltYnASlA2OwN+K0bxZdA /+6R4EuYA53lOckl2IOMo3dyLeaS8/vqJ0xvoXkxe8QMcE6zVWx+PbshYS+Hj/dhZr/i jGeGkPcAXQtSarMgWkD5TZEfQGT39GnrRrkfjPEsWpFYGTMixr45dA0oL0FT0wF0nZga SwOX/uA1nIOv7UzdVPlw/QZ5NPf/AdyAf49nmpTlg1phRtzi134DVLD3Bieeb85PgoMg hspqKg7tR1SvgM/a02DJ1M++2bYq4sWY/Z5kBRfxqSjge7PUno4nvSTb3wqpiUSOMtfS gH+g== X-Gm-Message-State: AOJu0YyQjO0POU/Bp9C9qdWW8yqya5gM/Exn4+NPo/IdseLNwHKC2wVU QJKhsa/uHnXnOPjC2tn1CGSnY8UeM4A9FYpxKbbWVyj6S4ZFlg6oOojI7lX2SHw= X-Google-Smtp-Source: AGHT+IHKZfmNrs9COenNr9rHpHrlTA+tCgC1dQuZckaluzhRuF+QMSJPpMwl5bOYcMVAk+KgZNu5Zw== X-Received: by 2002:a17:902:d507:b0:1fd:6a00:582e with SMTP id d9443c01a7336-1ff572cdd9amr99225215ad.30.1722851977617; Mon, 05 Aug 2024 02:59:37 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:00 +0900 Subject: [PATCH for-9.2 v13 03/12] 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: <20240805-reuse-v13-3-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.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 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: 1722852019333116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852099; cv=none; d=zohomail.com; s=zohoarc; b=NIX4+uGLks3/BxRhljiEwwpNFflPg2BTLy3WjfONGe4bbN5piFkqy1UVSJpwyMaLbBYDWFdxbK6VSf+VMlUj416dXTi+EcKBkYW3LNt1/VsPgkzR+9A99Zutcq52QuoZEHQJrjPniwdrFr1yBafPizOKUAL9lSufY6ScwAVnuP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852099; 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=LuOaJH+QrihGyemQSgnz7T1Hq666W5wLKaLdXVtBW7s=; b=FGStgrP9xOvNMaeKfRbg62E94PFQOkLHQnUCJ3/xrJvnJLKGbcX9ZdMkCxMyYAHimn3wyT2B6g52GRIWoVQ69NkaTzkZwRopcqo2nzSacQ02XEICi+Jj3dDTnBbhXJj7QhJmZYNFBd3UHwhIACUf4KmHsI369Fi8ygmpwfvx5W8= 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 1722852099775977.4049848480746; Mon, 5 Aug 2024 03:01:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVI-0003fx-Mf; Mon, 05 Aug 2024 05:59: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 1sauVF-0003cR-9b for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:45 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVD-0001GY-OO for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:44 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fec34f94abso80505715ad.2 for ; Mon, 05 Aug 2024 02:59:43 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58a66284sm63775605ad.0.2024.08.05.02.59.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851982; x=1723456782; 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=LuOaJH+QrihGyemQSgnz7T1Hq666W5wLKaLdXVtBW7s=; b=Byf5RirmOslpgKoSN4Q/rT000nyKOjgr+UvITW5WvxouVLpjET4voW0Dxlep0nuA+H BxymreOQb2LgVi2gJ5rzfiJGxR549b3FAYf+1LphbULX9bSJOFKqLlM7o3tL1fNfTBOI 6C4eNS4bj39HydVAPLUY+kcYomclQI465sO2aBEhxM9iear3AM1oO0s+y+3wwWPaVV1Z 1/N8NFQC1zQ6yFCNHEYroOdYBFYsqMdRIlSIQcdDtHDxbi9TOGs7CMHm8wRczUhoJLPL Ro41QRoNyR93lopY0a5Ve1XUr291c2C7aBMfQFhCoNZHwQNCufvV7fQtzXRF0gaJd8LH 4lyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851982; x=1723456782; 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=LuOaJH+QrihGyemQSgnz7T1Hq666W5wLKaLdXVtBW7s=; b=VQi/n0yHTUuCxKBx58nlZX7M6zRYOXJoAlszEFHb754ex8go6c/CPg6F0eKP4V+KiX e/VPbY3SNZx8/zx5qPqVNsG9omAT1h87CB9FcprgnjODiX7zxtCvIb5qfWeEniJfV2TR MltUlw1oQsiv6pwNiafs16tV54LdnjTSBpN7NyO5K27hXk11jkOISf79dykrwKDXVSTn QK4rW437ngm1TaE3TRd3juCTvmnFHICR2bb4QQoTxFgY93lxSoMPNwitLmo4xXsdla5w 72fmm49SDC9nbnmIYToZ5kyx4k7YP6xRlwfVW8KLz4A8Mw7uOS2OXTWndjRULNoAXbhb Twdg== X-Gm-Message-State: AOJu0YxRgrbO7hkyzW8RO1tTbW+vgeXs4IZYdcxR3RJAeQN39ST8TnQx XaQ8mg9dZnvHnxWV15AUyIp2z+EHw1XRy157FzNcBuNsWqJWUEaSeEfL900TdOQ= X-Google-Smtp-Source: AGHT+IFj7TbHtdBmFoX9Qo4BTVQbRdxt0oFv0r2d8KTdoCAp1Qx0OJVrdhJc4nk9BSDZd2w45bDmqA== X-Received: by 2002:a17:902:d4c5:b0:1ff:1bd:7e61 with SMTP id d9443c01a7336-1ff57258aa1mr123317335ad.14.1722851982425; Mon, 05 Aug 2024 02:59:42 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:01 +0900 Subject: [PATCH for-9.2 v13 04/12] 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: <20240805-reuse-v13-4-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::633; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x633.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 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: 1722852100616116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852104; cv=none; d=zohomail.com; s=zohoarc; b=hMk9OZs9q0S3DsH5dkwVeDhGXHdYMpu8yUUuXC75mFmALkLBjsW8mJKQp4YQQ25XUVvL/7R4j661aHjiHooENpbrM7kB89ySED+1qrOYrZfizJBqgrBiyUI7fGwQHmz7wxABMmalE+7nTGsz9/8BB/Nnzz6ODH4yTvf4XRAiGEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852104; 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=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=FDoMAKd1RwdEtFoe3g7Vk79foTMT7sH6BlBuBew2LAPuqij7KfXC1HuPvOohiLh0dK7vsNZubJ+mI52E5jS9ht9HQ6cATA57BVnbsPt5oh9FQ0cnW5+mr9OgsR36spj1nsyfg+gfRhv+9yos+Wta2lpKP5x3rEV8hxMCWDXpD5w= 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 1722852104137482.34098991278313; Mon, 5 Aug 2024 03:01:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVM-0003s5-Nl; Mon, 05 Aug 2024 05:59:52 -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 1sauVL-0003qA-Se for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:51 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVJ-0001IP-Uv for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:51 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-7163489149eso7335091a12.1 for ; Mon, 05 Aug 2024 02:59:48 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2cffb091391sm6585975a91.18.2024.08.05.02.59.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851988; x=1723456788; 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=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=PR4hW9QPK0dzYJTjZYV6le8ybfVCM3qyW8m39wXtU7hPSXWjd6YkhIlDwofzromvf8 qolASZeGsKiSgfadai9jdIO6kADT4QNbGGJW6YA8muA2KacyjefEVJo7yE4WGS+8V2Dc fRXKSFz4PJDLtHlzN5CKlEi+R32KWCfqX8crJEvFJTFaLnXGGRGoK/ngS60WGPQRoTMg vhHADDjLKMuzMeyI2GubbPGtq/o8L72mGPoZoC0sprHth9RFhkGEEvSgo9GLjxx537mt 75MY3l6mwh6EIb/Ue3UQSkAxOp98MJoUhwhwUbvUg1Lrqat2jhJcJ/0CFvdbZwWwtnKm 6igw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851988; x=1723456788; 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=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=FzLyH4tG79OuP3QPjWyROEtq9V+rhLX1XCZt+OcbJY3QQ4po9P4Va90/BhioFgQ3cj 4rNUZFgXWQ/Zl5tRwHQgwP3lb4RgimmVjdsrS1nNBFyylYUbO0tPThQgf+DPlTF9z8qO PtnSsTCOTEWjxOaE6bCePSWwcdAquPRW629cZvu+8s7B3KBldyNtE5RDtvy+ka0x+srI dxnrvMXBqRbWvkxH/p1xb+YluWjX+jmoGUPzx+hhmo6JGdAECY54owpPn3kQP04im+xR lZUiahdtAi/j6GSRPVOqc0lmVWDcG7IRUVP4wbOt651ByU0rFIgXcLMWWiuoklBAZSYQ 8YYQ== X-Gm-Message-State: AOJu0Yz9H9WRgIY1ex+1u025DEDZ8gXole+C54WE/3JuPS+CPxEwA/GX tSjOFgKbFhh99aeVdz4r+4nN9VHMG51z0/++pHeJ2/v3lNH1ZS3kjMm/Z1RZBJE= X-Google-Smtp-Source: AGHT+IGGBZglPco7tYVVxnP+o2Oc+ABIwTtZHlRnXSY1Jbw+66g391+XRrGjB6ZfjoDLSCMYNYDCOw== X-Received: by 2002:a17:90b:489:b0:2c9:6a2d:b116 with SMTP id 98e67ed59e1d1-2cff940e469mr13438243a91.7.1722851987778; Mon, 05 Aug 2024 02:59:47 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:02 +0900 Subject: [PATCH for-9.2 v13 05/12] pcie_sriov: Do not manually unrealize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240805-reuse-v13-5-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::536; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x536.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 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: 1722852104764116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852068; cv=none; d=zohomail.com; s=zohoarc; b=L9SKR/5Qur/MVtz+zPpCs9UFeNfG74lZ14l3C5/wtcJTmOndVOsu5pVGfI/htNxE0fUJ30lEEqx/eXcW63jhnujT9JlCv2kveaTfgLvnDRLxi+kKDerOlWAEhO+2fZRZyne9Gkq/nqByCTEv/9Rh5LCpfN3qvKEzay6Ydi4/T+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852068; 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=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=m8MZC5pKKF8JTKmfq/I/NtwDZSJ2+dMgkJmMVf6jW0OlaKg6QENRjDMLov7BWiDGnGPyjH+6j8sTDLzNhQLscwtga/wm1yt0VoWodKA57V9Ji5LlIjoYl4iLmGRahJN3kGbXOZtc9V8oHcqM6OwseKnnCnVzKhiOR8/LJEHTrMc= 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 1722852068506366.2064669469348; Mon, 5 Aug 2024 03:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVW-0004T4-Qj; Mon, 05 Aug 2024 06:00:04 -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 1sauVS-0004If-6b for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:58 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVQ-0001JW-9V for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:57 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-81f9339e534so373128739f.3 for ; Mon, 05 Aug 2024 02:59:54 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7b7654beb1csm5032397a12.93.2024.08.05.02.59.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851993; x=1723456793; 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=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=SMIG/CIMiKM974g58xRSe43eqeRlVbsniE7ghtqn5OsTvf4nOI+/6HQOmFV9Cp4jp1 EvAWsOdx0FMMu99Ti3qZwgb+wkEQJyTE/fSHVxEwczc00YS5lLJeavlkotlM2bq/YH9u eTsgya9+LqE78+n4CpCIIokX42wGeHBhWuGQlsCXITVZMic1rMdIEIFztGy4P9HrYF8s IkQUkBeTWzn0shzpFls8jcuAPwRyHwyqy6MbFHpXIzLxtnrui3drdt9sE5CMH1GGbYHq mcl868AGhrEhkXaJmMAquRv1n4PkZ3hN9KpbCQwRi3RIuha/NHdIXI/4HO73weZ1j1GR XfNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851993; x=1723456793; 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=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=w5HG99+rkknTz7m7gKWFrQNuyBWXYxxFiQo5c1NFWVnBKdQVbqimDZxFKHrIn+h6IT Xpq2ak2CS8HHnU/RIQ1NyAShjhhZgw5vVw/oAC85t3XiCM6Qe6+xBh3l7n/N7zXQuf0f i7Zgp+zA+MtOeGPt7QBZoTxEphK18TuCosKrcX2W2Z8BMteOjByPSlx9KW1taxrz8smO vpHRDdpNmDPd+YcX++Vj4LK26qjTJFOq3P1LAFKPnLxx/NjjxylDJ1cIZyQlakNWG5N5 +mD+7HPyo2qYM1ksa/CFR3lvKiFRAHs8fHtWVRW6/HghNpa0sSb3I/Zd8K/vzuiCM3Ir Vumw== X-Gm-Message-State: AOJu0YwkeiJiYmrArW2hgT7ecGsluUiVvPviwShde9wknexE3amOtWha wxI/dOWk4EcE8S0QnApZ2pgRgEdXHDngsCV6KdWxIeAx/1i2WChAsxM/AsuTVzU= X-Google-Smtp-Source: AGHT+IHJQJwxpNwbyeKQxUULqRWZLmJMntIkxMMsdsjsW9d1dTXefku8yTOXw8nkbH0uV85wNpE2SQ== X-Received: by 2002:a92:d683:0:b0:374:ac3a:e32c with SMTP id e9e14a558f8ab-39b1fb8885cmr125829365ab.16.1722851993214; Mon, 05 Aug 2024 02:59:53 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:03 +0900 Subject: [PATCH for-9.2 v13 06/12] pcie_sriov: Ensure VF function number does not overflow MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240805-reuse-v13-6-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::d29; envelope-from=akihiko.odaki@daynix.com; helo=mail-io1-xd29.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 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: 1722852070893116600 pci_new() aborts when creating a VF with a function number equals to or is greater than PCI_DEVFN_MAX. Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 8 +++++--- include/hw/pci/pcie_sriov.h | 5 +++-- hw/net/igb.c | 13 ++++++++++--- hw/nvme/ctrl.c | 24 ++++++++++++++++-------- hw/pci/pcie_sriov.c | 19 +++++++++++++++++-- 5 files changed, 51 insertions(+), 18 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/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 450cbef6c201..aa704e8f9d9f 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -27,10 +27,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/pcie_sriov.c b/hw/pci/pcie_sriov.c index 499becd5273f..f0bde0d3fc79 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -24,14 +24,27 @@ static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, uint16_t vf_num); static void unregister_vfs(PCIDevice *dev); =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) { uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 + if (total_vfs) { + uint16_t ari_cap =3D pcie_find_capability(dev, PCI_EXT_CAP_ID_ARI); + uint16_t first_vf_devfn =3D dev->devfn + vf_offset; + uint16_t last_vf_devfn =3D first_vf_devfn + vf_stride * (total_vfs= - 1); + + if ((!ari_cap && PCI_SLOT(dev->devfn) !=3D PCI_SLOT(last_vf_devfn)= ) || + last_vf_devfn >=3D PCI_DEVFN_MAX) { + error_setg(errp, "VF function number overflows"); + return false; + } + } + pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; @@ -69,6 +82,8 @@ 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); + + return true; } =20 void pcie_sriov_pf_exit(PCIDevice *dev) --=20 2.45.2 From nobody Sun Nov 24 12:25:56 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=1722852042; cv=none; d=zohomail.com; s=zohoarc; b=mrKCOuhsBLDKxDZS/E8IdqGKWOIOn4U391Cl1EMQxfZsB3zOBpx0i/EhnP05mTrDDAY/MQ5c4m/um5bd97Yg0P9EKuGDSuA5Zr0aeNmmXwo83V36ODxz2EQZoLGFOYxy2DV0I9w+UrOrIurPN/QnJx9f6lQWVG6N8bmyLt1Ineg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852042; 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=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=XslcGcVVum5ib8LCHJ32StgGewKedB0SWA2TXTXPqi+nCOcOOGG47DhvHA2WmGz3sKVo6IgeJgh10ih3iBacL8oHy1PU9bAdq/9Ah7cSEFHedDtZwwS8U0sXXnUaPirUxfIUbjQ9+BOff2DQmlxQbyGDiPRROJcCmW2Tpp0kA64= 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 1722852042798611.3775671313593; Mon, 5 Aug 2024 03:00:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVk-0005M4-0f; Mon, 05 Aug 2024 06:00:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sauVX-0004aZ-2v for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:04 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVT-0001Kb-Tn for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:02 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1fdd6d81812so88698845ad.1 for ; Mon, 05 Aug 2024 02:59:59 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff592b659asm63324985ad.301.2024.08.05.02.59.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851998; x=1723456798; 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=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=0zM5uSV4UcD1kisMMfVnn+8CGl/3NpRSkM5oTVTpgFGfGaLDbJXffPpmK0XueIgwxd Z+T9yODVugw+ow99jya8BaRZjuX4XgoNK2A2eLlG3zNWlAKnqZJInVqCTWdkgeQPD6ox 0yItd4GUPmu1TpYx7LUFdpEZi3R75zs9g34iOC7X3akRm1sF4AfN1Dp3gbQF0IsvtCg/ I2gnCHumEL3p0FsJT0a+MElYC56ML0CLSHJNzgNfIa0PTzvJH2zs+5SzMkJjASR+no47 SEPvaYv4DUF1qn/TnUj4J85rYH6BzbeUkpZEDoEpykT1PweinIdb+bAs2wvOClTjbtjU 1a/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851998; x=1723456798; 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=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=tVWx2V67sT/G2hTAGlvyGODuVoj6snl9YCdKAjD4Ew0zctCzGir2QGq9VOVI/iRkcG IZZQfPWq51/0ojuBL/WcpT3RWWvp9k4vMvOB38kJ2YHqH/M8hxC5laJnRGbJzIWfIeRv GWDzFdimNl99XQPIE6NbdlSQdavT7h9N/c7kkkke8wcTqRQGJI0m6Y6O98DgGF1xVGge Hv7qw4zOQDFO1imz1P9P2KCDyFxIxNLTVx5EezbMV7HZlsXYMRXBq55cLa6iz391FhFW mMV+w94ja+1Wz6ceBtfC4yYeeq1kXweIx2t55TdYK22Elklx42AGpe6Ie0Zz5gju8aMU +tkA== X-Gm-Message-State: AOJu0YwUtymJdBYqDoTa8KLmGF3j+EqxitwwlQE3yh3jSpCAgCjyYOqV UvBk/pQFrHsSYbGGZj7J2qYG7w26qSt1rVStMM2h4vfky4S5S57j/MLPWB0mOgg= X-Google-Smtp-Source: AGHT+IEdrY4tmwSJLnppzxJxCR1V9/zs9P6WXpoazYRW0RnI7QsMyv6Q7OYs1N1poyfOmdNO10z++Q== X-Received: by 2002:a17:903:1cd:b0:1fd:69e0:a8e5 with SMTP id d9443c01a7336-1ff5737e5f3mr144105925ad.41.1722851998103; Mon, 05 Aug 2024 02:59:58 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:04 +0900 Subject: [PATCH for-9.2 v13 07/12] 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: <20240805-reuse-v13-7-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.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 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: 1722852044475116600 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 --- include/hw/pci/pci.h | 5 --- include/hw/pci/pci_device.h | 15 +++++++ include/hw/pci/pcie_sriov.h | 1 - hw/pci/pci.c | 2 +- hw/pci/pcie_sriov.c | 95 +++++++++++++++++++----------------------= ---- 5 files changed, 56 insertions(+), 62 deletions(-) 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 aa704e8f9d9f..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 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 f0bde0d3fc79..faadb0d2ea85 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,9 +20,16 @@ #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 bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, @@ -30,6 +37,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, 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 @@ -49,7 +58,6 @@ bool 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); @@ -83,14 +91,34 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, =20 qdev_prop_set_bit(&dev->qdev, "multifunction", true); =20 + 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, @@ -156,38 +184,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); @@ -195,18 +196,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; } @@ -219,12 +212,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 @@ -246,14 +235,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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852043; cv=none; d=zohomail.com; s=zohoarc; b=nccbyz8g6aq7HDGPJTSYVQb9EHGvxXNB7+NvtHJZNUTFLR+aNXM2cxHXduW2DfGZ6sOWq3rcVAmLVi/fTKcxtHpa1ctaxkwVQ1C60CTKCDaK9ra3bsOjIHjzTXUviIetHeoRW4U0ADou8WI9Qb6iriHQTb2vMnCsuanLL/pY5hQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852043; 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=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=ICA3/9ZgTRmv7USz8n3gDv3Z9m5gt7GssbMboMJY9sYlUoLNtofx2437VHRD6xACzKg3BgNcIQcfr+lfoiAYNDD7ycwB91U4yiedEMFGF8Lb3I78kfJpxMtx/M0LmJxwkl7PVgyzdLOEbfKKZD4o/VndyWf8f3weHSTbq9M7Jn4= 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 17228520431901012.5876849081986; Mon, 5 Aug 2024 03:00:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVr-0005rF-QI; Mon, 05 Aug 2024 06:00:24 -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 1sauVc-0004sV-Bi for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:11 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVZ-0001On-UK for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:07 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-260f863109cso6152922fac.1 for ; Mon, 05 Aug 2024 03:00:04 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-7106ec05b77sm5042993b3a.21.2024.08.05.03.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 03:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722852003; x=1723456803; 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=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=osg9wNLIbceYUs8hCxmz+jq+/9UpZqtpngDUnZTlPZfAbkB8BrlUZD0o4Ik1u82Nus 7WQrwNn10iP3D6g6lEJjc0yEHBLZQfPO2IkTP0aLcidsdebcrB5Or0bWE2i99+VZ5Neg yVIcwWDEalGXQVOmBWe9vG67lQpc02BQDfhyd1hOlIOkd6XKLKhtGeKK/7y0iUHcPTSh CZVfkE/4sGeiTFIvhRyde3SM/5K1W963M6xB2ydMf8LXDWZo8OqwUiRgPKD0SoyCxx/k 0Kk79qgzkVIf/uV9jVs6HRUhker9//TcasqK/2pjHNEYenL+Rkv/qCfUwityBfOEno1M ei4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722852003; x=1723456803; 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=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=V9jH99z3ANKHKu+2J9fEiQw4PqHxckMXVEeOZ64DNJTM2FiIzl3V7urRYgy3Y+oIsv EV+mh4qgKYLjpukZFdS2iINF1lHS1JH4hJZnaDGBjztFyWoNSkIk2/be2q8RbK4zniay JwTrifVxvCtUg0fIBiKno6kjStsUk9xP4dmZcdlK69LEHTwbZhMC5cxJLWP3hUf8Z8DJ OF+39s5MQH4huLtezUR/WYlMd2NfYshs8ShyzOEaOXKvLRWyRFEwKAvIrLdUWPeQwqB8 b7Hvrnxy5ok4Es/fHneYiITLMu3vdgR3BINuTH/CA9zXSbKYH4i9FcysrBF5Xur+IPK8 zyQg== X-Gm-Message-State: AOJu0YxAtf82dPKCCaVcW9Ap1wiaBI8k2NXM4eQc/027bUIhdV7eL4FJ TgVNxMeUq4IZ026wAfGIgFvszxWpm/VsnThEzHTaivt8wUJMIIOdQLqmEBpkPMg= X-Google-Smtp-Source: AGHT+IHLtKvZEzD1nLCuHl/V85Fxnr6q24DjY6nxZiVJdLSG34SQwfHeOmhPd/XpM4MDrAOD/vVp8w== X-Received: by 2002:a05:6870:2193:b0:260:f801:61b2 with SMTP id 586e51a60fabf-26891f240famr13333670fac.43.1722852003533; Mon, 05 Aug 2024 03:00:03 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:05 +0900 Subject: [PATCH for-9.2 v13 08/12] 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: <20240805-reuse-v13-8-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::2c; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x2c.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 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: 1722852044447116600 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 faadb0d2ea85..9bd7f8acc3f4 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -99,6 +99,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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852154; cv=none; d=zohomail.com; s=zohoarc; b=m0Dd+o4J5uAOAAga7e6iqj6ERGbAU6Q/k6+GxG3qKo8duCCPH0r6GnYf9QdPxChXvt57nKc3Vh5hBWpFnndXXqJ7KuR6SPgGT39B51AxQliDg8z442wfKTLPAiVbdr+QCQs3KZKq1oUUtU4zx9loEUex0gP9JM/OpiF9mRP7AnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852154; 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=kAQHWcA1moNmn1CRikPYEp0/XnxLUG4mHd1R0B97aos=; b=mgQDJBOIW1lURuAZlLrNv+0Nqlmfkx87JETCLQ+8sNeEXCJYAiLmfDAhE1kVg4IT2oT8NSl3j0V31kwhFPMnCF1hofgil9MYUlLE8jD1qieav+SugDqav3XR14FXYX5nm1jxDUBgafGTR0TJpzexRIs5wKpuVJYYMP6J2XQm3ak= 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 1722852154149125.17249123256636; Mon, 5 Aug 2024 03:02:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVx-0006QC-5z; Mon, 05 Aug 2024 06:00:29 -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 1sauVm-0005eC-Oa for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:22 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVh-0001cD-B3 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:18 -0400 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2cb4c584029so6814349a91.3 for ; Mon, 05 Aug 2024 03:00:10 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2cffb0981c3sm6556083a91.24.2024.08.05.03.00.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 03:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722852008; x=1723456808; 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=kAQHWcA1moNmn1CRikPYEp0/XnxLUG4mHd1R0B97aos=; b=Cr07dXb7rKuCam75k/rFjH1C6lRS0a2LaoE0M3rUKcaN33UXPKusvK2t2MIc1RD7bF /f4vCohvw0dd7isas6B56YVZUD7mLMrMb+NcUR0KhPWsP+qBAWlqz/1pVuslati4zMR+ 44Zdnlm1l2nxR47opj56ZhaQvcOKUwQ1r7Fd7FlwcoxsSEevgzLYMz5E/gGez9hxcL1a w7UQ4v1lE1EbTfa73hLWY5fx68E5CG+qV3cS1j1JMCI8xvBpfTLolK7hzKSdazv/9p5s WR4b5WyjCy/CInkf0CINxfdbeYK+OXdNo+wFs7VRHpPLEVAhiMC20pMGaGqypLfKxHZ5 EkfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722852008; x=1723456808; 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=kAQHWcA1moNmn1CRikPYEp0/XnxLUG4mHd1R0B97aos=; b=I8OFyJlpz6W+mT4yevjNuRY9GFixCngXnGwA2XxCYid8BFQ3HDElWkuuyBRoOA4Rql Suc3uCiW6HB7+zbak2e5fdnPJCkSsFdv1pTnoL9H6pTlhci2zaE6n0hmO5Dze0KlhvdJ 7/gYkfLg1tyWMUdyExm1teGnLkIqiGRlC1yBSJHQuNw1B4YEWAuQpKMX0bBOcC/thfeJ 4k514tg8Ycjx3B/x8pJV12Mwi7YPkWg+OiW6U7hYcDVmxJmKdz9Z6r/gzt2TL1FlAECb lKzUV79DTtP1dXUlvVncco7Fp3jDYAkaIfxUU0u8kcPgmmDblHsOy5BAz2txqRNaPc6E H01A== X-Gm-Message-State: AOJu0Yy+Qdy7cXXnHvXEZbZ3tF1ABgYbjUT2xTtgFhLuE0dguyEjJq8w 6SUBxNJ44hH6waJ+ROityxYbjCyLQDcNjQYyg1glaxIFp3YYHJJx8J95g6Zg3Rg= X-Google-Smtp-Source: AGHT+IFgk5iGnqzFnyZvmfnASEBCwYhJ6GoEOTPVYYflJqK2bfUUNazL5imKJK4namqGTAVPFGzZ/A== X-Received: by 2002:a17:90a:8c91:b0:2c8:7330:68b3 with SMTP id 98e67ed59e1d1-2cff956e5b6mr10387072a91.39.1722852008475; Mon, 05 Aug 2024 03:00:08 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:06 +0900 Subject: [PATCH for-9.2 v13 09/12] 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: <20240805-reuse-v13-9-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::102b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102b.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 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: 1722852154886116600 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 9bd7f8acc3f4..91b6ed46959d 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -57,7 +57,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); @@ -194,29 +193,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, @@ -242,6 +240,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 @@ -258,6 +267,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 @@ -304,7 +315,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; @@ -312,5 +323,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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852108; cv=none; d=zohomail.com; s=zohoarc; b=jiBQ8uygZAXkvKTCWOdOvkQUq7n11QY8GTZEDsASmBnxkoaUGqwjbWoMVg42QqI/zhm5/htBT4iM3h0PDI0QQbF2hsJQhnRXtmBUs1CpgGgpMSdJk0fmdj9KWlOrJ0RdLEo5plqKY9zwdFjwJEzNLv/z251HYDN23+8iX3ZQF2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852108; 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=To+Ctud3IiVbBDGeLTlPr7QPErynCEwbUoWpPwlxWjU=; b=RsHz3jyAVJSc6ieCDPuiH7VGNsd9HCRZO8x3qvD20c8Bz3NMU3DGZ4y9I0vwoF5TiNa3jhpri9sMbJwkdDnjVFofjgHa37pl7P1C2zPIv61dZffihGP8C9LRUJRgChmKf/JWIzvKA1VEuO36eC9o70GCqZsDsXltuylXqQLMxuI= 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 1722852108929410.45278286547114; Mon, 5 Aug 2024 03:01:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVt-00061u-0q; Mon, 05 Aug 2024 06:00:25 -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 1sauVm-0005eG-OU for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:22 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVj-0001ea-LF for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:18 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1fd6ed7688cso83416275ad.3 for ; Mon, 05 Aug 2024 03:00:14 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58f29e02sm63801855ad.18.2024.08.05.03.00.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 03:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722852013; x=1723456813; 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=To+Ctud3IiVbBDGeLTlPr7QPErynCEwbUoWpPwlxWjU=; b=MfQD87xb0ZFC0m7vw/cqclGfSfBd2//K5mleQ+C92ux1AMrZEsEJOA05wWeMiJKsph FO4u/NeS8xIf0V205yLhe5JqeQG/dcZ/PqrKS0u4Hi7izPb+j3KfOnCWlQFMKiwASqu9 W84NxXtxu6en6sgOsiU6+Eta+MKpwVmRA4Qxr5j/EJDAbQ1aLwArR6f2N+MHSXTc4hET QVS8Xz5HT8BaDeRKw9Bt5W1KaLJNTvSQ2jUohdRXTE4NMQCh8Kowm9VEEf0Qnhfjkw2m MwZTdg5AJlFFL1/KYE5tfJYERPlgT2EWnYJ/Vi5gsbNIHZe3U16qS0H7mCqO4jiiLCt6 A0sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722852013; x=1723456813; 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=To+Ctud3IiVbBDGeLTlPr7QPErynCEwbUoWpPwlxWjU=; b=J11nGFeUQ7Wkk3Ijp5seUP4MKEzWZzzmcn54hMjHxwoRooyAb9dMi7f7wJLRlpN5RI FdPLaJwjCQw/q8HhezOWs6WlUcUBV5DXvlZVEl5w45v2KdF8KxCQK+J3B0aa+qKxVQJ5 mFHLiP5YgtsXVoQ7pQrLsV9vZ2ru4OvomYYHYfwiHb+pViuNJnyTBnqe43QSHmeJpFO2 VnNpF0EENpWIt58iusbYYDljxCi9KBB4Ei6s4oXdAH5iDolUYN2OmdVciwMsyvgkmk84 FG1NDzqsI4g0cFF3gPOIIMewQS9ialxCQ2wb7ZhDEc1/G2LtTTZLgFw+CXgHCmOopP25 fNBw== X-Gm-Message-State: AOJu0Yz2KTVQbWVWar0t4vLF1E0ria1WXF1FqGbdIJorcNqkE5zm7Y4w KfBcW89WkknLRhGgYYtaN9gSeZwqGQ1rTQRTPHiZIFsW3V1nmGSjzWIGFqXGlJM= X-Google-Smtp-Source: AGHT+IEWO+amb9QWF5YS5JTUjbvkpwD+WkE3hYlSaIg5RY2zqq4XYUN+my/OSAQKlUXAUQIMaKItNA== X-Received: by 2002:a17:902:c402:b0:1fd:d4c2:a2ef with SMTP id d9443c01a7336-1ff572910d9mr124199815ad.21.1722852013232; Mon, 05 Aug 2024 03:00:13 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:07 +0900 Subject: [PATCH for-9.2 v13 10/12] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240805-reuse-v13-10-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.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 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: 1722852110658116600 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 91b6ed46959d..663c1d0cab00 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -254,6 +254,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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852163; cv=none; d=zohomail.com; s=zohoarc; b=bPBXr6QUzZXeqwEM/ITE5IBUgxnC4WJysSo7Ctw0Rphr1hyCR3KTQ1701tTeNopMyRcuZHBn2br+AD4BWfxxO617bMwc28xKV2xjPqKiLyeumf2ok+1g0nyur6A2Af5AAeqrP1ypzhci9WUDRq6mUyVYYV6yFpGuXEHIjm+QP/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852163; 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=lBXEbnUwG06ejAJ51POyij7f50iVZK6QzSm218/g7Co=; b=QkK2vbtncBJZocUbTjxE3//Pmh2+frlbmlYY1AXlGdCOvHdQvJCMs3hUdB+T3JXDXHz1Apcd6FeAN7QnjAaeVwoHd2gOvRxWGK/X4s8HvcyTmqW3k6sKXAr0R4i3Wy9sBsI+hUX8UijF2HxZ9MazTjhWe8ChV76jEPSbtnTtaTQ= 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 1722852163446349.3471967684418; Mon, 5 Aug 2024 03:02:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVv-0006Ju-WC; Mon, 05 Aug 2024 06:00:28 -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 1sauVs-0005zk-B4 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:24 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVo-0001ir-QH for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:23 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fc66fc35f2so37802985ad.0 for ; Mon, 05 Aug 2024 03:00:19 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff592b65c5sm63514045ad.292.2024.08.05.03.00.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 03:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722852018; x=1723456818; 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=lBXEbnUwG06ejAJ51POyij7f50iVZK6QzSm218/g7Co=; b=sTP36BKw472o1hA71PRlWUvYC4lP9x5s5aEF+RRIfamertKHF2B00paHakz6oT1wE1 Gfv3EZtCcFtZhhKvIcrTnvzgezRCTpEdPvgv4d3h9fXyCD0LxO0rUmziucOqY4PtO7pZ lDqzoVzjyhqd1gnxpmeGjTvFCX+DeKtw6HYOnVndXS6Zh/eXU4TrFx3Icg1fB4aouU6a 4q/IUecuf05I8gEW8RnJsFvgIUdGe7FBdtNsKJ98sc/8tveLV+UW6OvnZemKqI3NUqoI ZEcvSVTkaPzmpfuDvUWnfgcAOKNWEF7DhhhZtFZYFIJC/YK7c6vebB0KvjDIieI+VPpr 8n5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722852018; x=1723456818; 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=lBXEbnUwG06ejAJ51POyij7f50iVZK6QzSm218/g7Co=; b=GCqz2BKYDyvdpVFokkIYKipfUhm0t8EnlDXSCJFWAy0QJppqcoe3G2H880oGb2HDS8 T/sxNtF4YeQk/E9uewjBaftBHA29+ZywKprfRhPCIW7ubg4UOgYDpJBZ2qK9gK/3582k yX0bQaFZAq7G3nJbteX114H7pbXmq0Wb+cfukPuvBP3qasNHL8EMW9o7ax2GJiIElwTW +cJSfoqqmgKEgpgzyBim9B9mtmFSBRRaMPUpKTHwfwOmJb6wuH3fylXQwhW67lSjM2ql uW6MPxw6+0yjgZi4/qrG2FpicHn8yaia8PsT5NitvTmUlSdhK5dO0Vie+Gd1GQukjX3+ YqMA== X-Gm-Message-State: AOJu0Yzj6n2sTeyBQGgPm5gAAg9RAuxIHLwPICR+1pwdPJSzZvgOyLPL owr5CYkXmiRCgo1ugJYSH+jfmycNVdKhUk1pN3030fMpQy4KzWtyxsKO/GI6NIA= X-Google-Smtp-Source: AGHT+IHPXa/Rg/ALOak3fZSE3MclZ5eCkZE6jecQbCexzt8a0b+oTVmdMY8P+DQ95OvTz8OztD4lAQ== X-Received: by 2002:a17:902:d4c1:b0:1f7:3a70:9e71 with SMTP id d9443c01a7336-1ff57bae470mr184561885ad.13.1722852018551; Mon, 05 Aug 2024 03:00:18 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:08 +0900 Subject: [PATCH for-9.2 v13 11/12] 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: <20240805-reuse-v13-11-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.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 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: 1722852164963116600 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.45.2 From nobody Sun Nov 24 12:25:56 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=1722852155; cv=none; d=zohomail.com; s=zohoarc; b=A6SEP1p+Gbw4N81ZgQQgJYdm3LmmEt+we47KiEpIXplcZk//QwqgX1LVMgYNNUG/0dDQXwTUvqAVVZd0KDKoZBUJT78msSXTM4/VDm4v+Ot/m+/JptJ8UHzEJtIy+YpKKtpHWqKkxshlopyvrtlSgCLQ5B+SOmM3+SXuMTNe+e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852155; 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=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=QaVFSp2Qz01y/yKNLOBIub2cdfWYsbVGV0PVu2SyDqJI1HTnEMapzIcASixsZNSFob4XkjlvF3vmwWP8Pwy4jW9foCuOOgL7jZrCrrudRbovNLWzd0B9/ATqvs4ePouppZzM6/diU2Xoz5iZhboz3xLy1Rf7pEabDxwijG0fQeg= 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 172285215534368.93512015617455; Mon, 5 Aug 2024 03:02:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauVy-0006as-4i; Mon, 05 Aug 2024 06:00:30 -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 1sauVw-0006Lb-6P for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:28 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauVu-0001lV-C8 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 06:00:27 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc4fccdd78so74937365ad.2 for ; Mon, 05 Aug 2024 03:00:24 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff59054759sm63612925ad.150.2024.08.05.03.00.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 03:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722852023; x=1723456823; 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=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=MH8RfdcXi9UcYIY6oPRifvyyDV1LffA4fO4MlT9PAs9egxi2ED5stDGZogFA2tRWfC obEPihhxJ4w/as6oXSSAT5BLQPsfn+q8F3zHDyBawmxvyBYRKYrWcvHDl+GRqcWWhe+6 aSND6wEwjGzL0RZb/Zq6AaRun76fJtRJsX2t/S1HaieFvrYqGsfad0ElH37bYlRpPUyA 71ohMeDuwxrZ7u7RhMJjp3g1nSGfcFjczYzeUiDtIp5O/tRdSFcQ+eEuJl7iQLc/aKFU S0FxoWIld5FpIXnJmyvY7XzEZF88qETPjiJU3qj8HwTABSMnmmFxizwZ9CxRR5M0ys4R D+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722852023; x=1723456823; 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=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=FCF2WkgqVBdFmVB3u1QWqnV45/N3c+679ZR0nlja/G280mJgG9nodN8pejZb8/w42K sWQ9p602CCrfGAwnDpuIc5+j9LunyZckDxIvYdAbEmaZLgCwkinMX9QTK9pO9dVVv+Mb YLhG7FiBEn5HXgfdg/kRryTwIN6/z/yI+ccmuGKcVaD6+US0zEbgWzb+ytB3BYy2Lx9M Rhz2Y5d+c28ryZkz/K0aZbRXg1QoghT+lGfcI2S6f3YBHT506lhuHAkfzh9gj3PbOaFJ N28z8ZYlIt8K+8Uc5QXEO3TEXtoq0nfCDjxGpaVkCPzrmfqW9sOZWk9mZG2/jgzwVaxG CHxA== X-Gm-Message-State: AOJu0YxT53RUqRYYn8QyJ+CG0pzapVbQ5o3CVR0TFa44FYRceh2kvx6f L+ZvZypec4BHRb5sVzJnZPqG0sUfNvJ7/lr3LCpDNOP3fRKSw4P9RJQfXZyrgu0= X-Google-Smtp-Source: AGHT+IHXNDNl+zIg6sWNQhhjGql9lmad94AXBbi9U9FyunlQUbMbplTv1kqey8OfMX5KGHjln9qceQ== X-Received: by 2002:a17:902:e88e:b0:1fb:35c7:8ea4 with SMTP id d9443c01a7336-1ff5727c893mr109091875ad.2.1722852023467; Mon, 05 Aug 2024 03:00:23 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:59:09 +0900 Subject: [PATCH for-9.2 v13 12/12] hw/qdev: Remove opts member MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240805-reuse-v13-12-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.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 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: 1722852156988116600 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.45.2