From nobody Tue Oct 22 22:29:45 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=1729586283; cv=none; d=zohomail.com; s=zohoarc; b=Tra5i2I53+nTAEA6/keI9xkvfupkkzJ80HWXGU9LoZHjS0H26FxbMYsHEoTlYyFIRA+dQtqnv3/RxoZDYb1QiNM4dY6YcR9nkA3akIoBwpsh+Iy2kmLoYRF4jZbbnvEWa/i8XbUJqjV0dTh3AjL0+Kgy2qblFBL1AyMLm3JUApA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586283; 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=Fw3oQA7+IEOjChncnUMV1961OLXeMOoul99vLyfGf7Q=; b=lSCDlKnX/ODHg0BWzZwiaTE3J7HuOrMqgWbmU9kgLqB1JfUk9OeRufUXtbS0f80f/fz5HHnyLBSP+MwPfhEn/9/e2F+dQ9rgstNE5npR9P1NyTld2MMHWGDpHhorR9/11eYQPNib0js/wxhdffhUOnyJ9nub/IcxH4LtcHMg27U= 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 1729586283874385.51318074841527; Tue, 22 Oct 2024 01:38:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOF-0001O8-Nc; Tue, 22 Oct 2024 04:37:19 -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 1t3AO5-0001Li-Q5 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:10 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AO3-0001RR-Ci for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:09 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7ea7ad1e01fso3583668a12.0 for ; Tue, 22 Oct 2024 01:37:07 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71ec141b799sm4191782b3a.192.2024.10.22.01.37.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586226; x=1730191026; 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=Fw3oQA7+IEOjChncnUMV1961OLXeMOoul99vLyfGf7Q=; b=jfpx2CBTxyFCPYwBDX8FgyBFwCEakMeBVhCGneyXbAZ00a3UfqM16vFP8uGRjFgipj qm2rV9vA27rB2rFRYqmcl37gJvudljG4+5JsMTGvDVwfmK9Ig//pbl0OcqJshr6ma+Ed /JjVVaarv5XWO0PWnfqB2MIYC6xjUvdXEYBuzTtszyPXNe/lgPZ7y7cz6LAYy1Wto4Xy 1WinUyNzmORwDpgBVQdHm0RHzZ18y3+yjo81jeiBcUqb6pktQhZZNtc6jpuadUvCz+x/ OuotoZqKUBYK0TwR3gNHDZgHssc7tYmiBLTWl14RcEsRHTs23VWNP7XYq/9RAfOd9H54 IIhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586226; x=1730191026; 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=Fw3oQA7+IEOjChncnUMV1961OLXeMOoul99vLyfGf7Q=; b=h5Q8K4M9qdUTEI7Ysj9i4gCbm6iFh2TGoiL4fOHdUrzbuu+VDupwcbou82rI3tvuhF /BlOIgJvTMXjmKgjZhZxBK53r42ybFfANwIz8mSqiApZwDcjQil7c0lNpi2fYy1yolTn S4z/fu9fE1piisNSLiXRJSD7K+DL8x/NI0Yfr4KuGj+pQmOR4ZjSl87ygQpgkF+ZuMIm rLC2QVhVG1zT/Jjlh0/xiad22keiTArSFNIU3eypC06AXQ/AV0RJSscqfyONrQNthlk0 0aZIlgD6DDx0wKDKJSZ9rOVro357j/UHeYebdCaTiYdWHYphQbfpPZxfAhWlOpZsZ1dg 0Q/A== X-Gm-Message-State: AOJu0YzNgLj+bYvCYGU2WQX7LzPBfUb4YHcXAD1uvDjjq3XgXz+a9gEl d4XTh9rFTZ2l8PeDfeOd0Wt8ej+JJOlRx7mG/tG1wqulSs6wS1SYK/zwOEZCC4Q= X-Google-Smtp-Source: AGHT+IHHDLBoOC7WiWvMBKOAtm0/pnpL/hUil7P+gHM84Funoh9qSdo0Y93DSFItUquvHH8HioX4pg== X-Received: by 2002:a05:6a20:4c1f:b0:1d9:13da:db15 with SMTP id adf61e73a8af0-1d96c41aafamr3462268637.24.1729586224673; Tue, 22 Oct 2024 01:37:04 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:38 +0900 Subject: [PATCH v17 01/14] 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: <20241022-reuse-v17-1-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::535; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x535.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: 1729586285899116600 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 91df40f98973..cbc42349d561 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 87da35ca9ba6..eff408b4e9f4 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1530,7 +1530,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 @@ -1618,7 +1618,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); @@ -2893,18 +2893,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586285; cv=none; d=zohomail.com; s=zohoarc; b=HzXyHS02Ek3LCPMAgVO1AFhGvH10E7SR3pad31a0GkQqHlOOXFuEktYntEiVdrzArNhp8by7i4qRHznDlfOA1MOUT6E0aLeYs+g2yOvf+Z4jZrlkH8DzomJLyFRGDstxiitByXkBYfRC540tgAOlmUxfrISmr+YhyB5xV2m3F1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586285; 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=X+r+qLBzRY4WeVgJO0/0ofS90QVM4PjiCp2hM8/EckU=; b=c/BGubYeDPRB/ZGZY/K8wJr1jop/gsn+BUbNmqthEhVtYjwpMPBZhuL8df3ANAG01PDPpWipvmIi0Pw4n7gRyuffo6sjVgTV1JCaMDgcsw6x82QqReaxLE7Z/LKvKe6O/pXgN4JcIvhgeQH+5O8dndz8ZA8iDsFZ3M3zrtUQTq4= 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 1729586285542958.5904597695927; Tue, 22 Oct 2024 01:38:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOL-0001S0-9r; Tue, 22 Oct 2024 04:37: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 1t3AO8-0001M8-UU for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:13 -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 1t3AO7-0001SE-ED for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:12 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-20cb89a4e4cso37418315ad.3 for ; Tue, 22 Oct 2024 01:37:11 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-20e7f0c167bsm37922855ad.140.2024.10.22.01.37.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586230; x=1730191030; 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=X+r+qLBzRY4WeVgJO0/0ofS90QVM4PjiCp2hM8/EckU=; b=YKrJK4RfbyhQvD1y1gdvcqFeGsSxlw8mSbtkQTUtjLnqlONYivIh3woQP6RJuQOZxW hY8aQyy4SJkXIXHk1g4NohUYnFAwaf9obnjLhvDaN0EQ0gD4wop7BMoQ6coLEH3rzivx zJcENTyCAh3V4L5hCCJLOzF8+O1i24KqMtFaVr9womuQMoQCogWgXMAm0Tyd8Lj21Ben GLUzG+FpAWDhqZIcCtRMiiMoV7MYWK80Exk8Xo5o1Qge+Lr5iUm/7vD1smnDI0xTB00+ 8dNV5ZkfrNmnbeMqSXAsUezNxgPkR47oUdWKFoC/6QiU7wsisc527QM1Wb4YZggHSnQL AR2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586230; x=1730191030; 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=X+r+qLBzRY4WeVgJO0/0ofS90QVM4PjiCp2hM8/EckU=; b=JAdoUZOeYucPm1uID4BW+ILmjBuM9IXvw1EeS5l2KP4MIVnlAM0HL/hIwtgwuhS5eI TPEYOVvTTr38ejIQKHraAkLye/NFlZlcng3LHRzQKgXQxW4smhZbg1AvYRuGzTSdAVDe CLKlWqF2HqmHj44AbnkmLAMVTPgQFfrTDc3nZBy5MbRSKlo2wAtDzgK3cLbMoA18bLyM 15Rr78WdDq5fjIXbNy7Q02xa9g9f8v3b9693ttx9HsoUYTxqPJSCbBYTM5IdFQwp93SJ Bx+a5QRYDeEEmovAWGCMJEVStSlv+iz/cXUNZpwgbio0NXuSLZT1muRcHWhDDgJhtnGG aZQA== X-Gm-Message-State: AOJu0Yx9wTyVsRDZ4A1sPaWndJwrWaSy6+a+dr6M18ujpLmBvnxAj9QE jMWSE5FJOv4Dvhys6I0wn/jVqyMIoMR2slfmlYP9EI87tX8e20eXMkc6TPuZrlU= X-Google-Smtp-Source: AGHT+IHwJc4hOqFWQqrrCs5FrHlLFf4sst4QG4WF2cQD8nvZFtmn3nvJxbcq16mfXKkzTnRsvmarHQ== X-Received: by 2002:a17:902:f60a:b0:20c:9821:69b9 with SMTP id d9443c01a7336-20e5a71edd6mr189646905ad.5.1729586230094; Tue, 22 Oct 2024 01:37:10 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:39 +0900 Subject: [PATCH v17 02/14] 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: <20241022-reuse-v17-2-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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: 1729586287734116600 Disabled means it is a disabled SR-IOV VF and hidden from the guest. Do not create DT when starting the system and also keep the disabled PCI device not linked to DRC, which generates DT in case of hotplug. Signed-off-by: Akihiko Odaki --- hw/ppc/spapr_pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5c0024bef9c4..679a22fe4e79 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1291,8 +1291,7 @@ static void spapr_dt_pci_device_cb(PCIBus *bus, PCIDe= vice *pdev, PciWalkFdt *p =3D opaque; int err; =20 - if (p->err) { - /* Something's already broken, don't keep going */ + if (p->err || !pdev->enabled) { return; } =20 @@ -1592,10 +1591,10 @@ static void spapr_pci_plug(HotplugHandler *plug_han= dler, uint32_t slotnr =3D PCI_SLOT(pdev->devfn); =20 /* - * If DR is disabled we don't need to do anything in the case of - * hotplug or coldplug callbacks. + * If DR or the PCI device is disabled we don't need to do anything + * in the case of hotplug or coldplug callbacks. */ - if (!phb->dr_enabled) { + if (!phb->dr_enabled || !pdev->enabled) { return; } =20 @@ -1680,6 +1679,11 @@ static void spapr_pci_unplug_request(HotplugHandler = *plug_handler, } =20 g_assert(drc); + + if (!drc->dev) { + return; + } + g_assert(drc->dev =3D=3D plugged_dev); =20 if (!spapr_drc_unplug_requested(drc)) { --=20 2.47.0 From nobody Tue Oct 22 22:29:45 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=1729586264; cv=none; d=zohomail.com; s=zohoarc; b=dTfH3U3p8PvQpj7YHSIgCRHZ39Xo5dm0zLi3HGPHaEON1dOASLUs0DL0wED3RvrRfFaX9/ztjZAiAJKY7ayGvDT3aflF/EtFf0O/NpuCeLqYG6zgqu7EmxHZdRZhSu6i4/qhjVDNl+R4cpV71VhIUxNSZ7CF33m6dRRkGCpSMr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586264; 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=gEfac4mtNaZvgozcAQ25/IZsgf8tGhGnh3wtGi7jnbk=; b=V+s6AQriF7s6Y3rpmBmOPWPOwhdssOSQMhnmSMkWrfZcfsVegBGuz3VAZDrCPa03ZqtNyDhs5+jgISdYGb/KipqsyViEw0aTaYKJCSoPMduM7AJprCRMm8HM0D4db0ZdZMQnfiPeQFpNwmPvuZe92Tin++6xcOPmPxZ+97+Uz60= 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 1729586264560863.0738464537543; Tue, 22 Oct 2024 01:37:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AON-0001f4-Bo; Tue, 22 Oct 2024 04:37:27 -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 1t3AOE-0001Qx-PQ for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:19 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOD-0001Tw-9i for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:18 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-208cf673b8dso51982655ad.3 for ; Tue, 22 Oct 2024 01:37:17 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-20e7eee6521sm37907505ad.31.2024.10.22.01.37.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586236; x=1730191036; 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=gEfac4mtNaZvgozcAQ25/IZsgf8tGhGnh3wtGi7jnbk=; b=OWeTonHIYC1nsFR2DqFSlaO2eHWqvEqWtWeSoiJKnMvoP8FEljZmocUNCMbqkJWwzj dUaQnBjMX4flP/kXNbPzyTIcMhjFbvlTi3LpR9evBNCBfDxVfYP00FDyIzWDiaPvBSeK Y27ox8plVOvWH1AjMB2Hqy05DqaG/QskOEmOKuyH0UwJCzM3RbKUpRz2oepOfDtQzBNr WOPnHrUI2VNDzeAo2BqLkCBWK45Ngshtbr0HZUoIIuEgwFqTfDINRT7DaM4IAvYVkd8q ZctZvZmXi0c3Cdbgw4j+coBc/tPWed7JYlH36CmY5Fkg6lfeJA8Yc5D9vdcdlNCRocLl /JjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586236; x=1730191036; 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=gEfac4mtNaZvgozcAQ25/IZsgf8tGhGnh3wtGi7jnbk=; b=ciZimC4YcLvnCxCCmO2cELaAPNNI6wXQueiN1TNwJgZ0SX31EEa40GvRrlzi25n3EV 9/+E5j/zAuhXiBZBjjSFs7FVTRuUhxK1dwhWKs2ePbmk1HCOo4CbmT1bXQfaJBYAPt9O va5tiXc/JGEsnkneK2TrN1Se5aAPewFB6/sgo8eJ/MFYAo4nv8HwT8dOoGe45IDoROgF dnbHVR/01V/mqUJaqzHjHvGJ24gJMy+yYrb0gTWV/qY6mv0x4WPtLnYUU8BaG+8dhBSa mkRsctALPSZM6wjq5p1CRyJ5rmDx9p9SPoA2cAjHSmAllNUVnVdVXTahB5Hdbk2+lUjO 5h9w== X-Gm-Message-State: AOJu0YwkICqMAzbe9s8Uj0Z2dQvCtVTRtIMlzXUVwla7sNuP00UenWlH ld4yOiRsqTmBWMEEulTUNZ0XHxPGJ7WJQ3rBnlA9k/FALZ9cHz70u9zWt9Pj/bc= X-Google-Smtp-Source: AGHT+IFkSzclRvDLqPCDqmZav5HPKvqBmiSCMjA3sf+b6RG7E/oldAIFAE4b8UMU5ebuTOJNCPRaZw== X-Received: by 2002:a17:902:f644:b0:20c:d1ec:aeb with SMTP id d9443c01a7336-20e5a76124cmr201175595ad.21.1729586236094; Tue, 22 Oct 2024 01:37:16 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:40 +0900 Subject: [PATCH v17 03/14] 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: <20241022-reuse-v17-3-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.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: 1729586265955116600 A PF may automatically create VFs and the PF may be function 0. Signed-off-by: Akihiko Odaki Reviewed-by: Shivaprasad G Bhat Tested-by: Shivaprasad G Bhat --- 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 679a22fe4e79..31ffe8ba4340 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1568,7 +1568,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586312; cv=none; d=zohomail.com; s=zohoarc; b=SOQNr/IbijWmP6Xwax+yepLBWKwWuQ4zzAkz0XOdghVT3hIbG2lB0JQGlXgBw/LvMJOvS31s3xQloeOBGnh8IBzdo9Ftq5hbZk/fft4ynKDFPiwfvgs6Lpink34VG3qN+ayngjsysugCr3RgnGj8Dj+SHnCDdW6uMmd+Ie1ubxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586312; 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=s2ddjXKYpOMCpQhobDNCoLol3H9ldQZTsQ8bEMFv7Pc=; b=YKqA+AC/wPDYHnsTGhVCMkRMiwufFmEP81+u2j4g4KVGTKXNjQQJp7cH7QU+DB/4BG/yXI2OES/0rzVTpBskt9VpOOmQA1mpEercWtc0afu27nooIdEbwbam3OFSTut6E690DTchR7mhy/j0iAkA12YxLutFFZWmOOcTHC5pcUA= 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 1729586312770112.811603806211; Tue, 22 Oct 2024 01:38:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOO-0001i4-4e; Tue, 22 Oct 2024 04:37: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 1t3AOM-0001a1-3r for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:26 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOK-0001Vm-Hf for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:25 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-718119fc061so2106593a34.2 for ; Tue, 22 Oct 2024 01:37:23 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7eaeabd9c0esm4592104a12.79.2024.10.22.01.37.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586242; x=1730191042; 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=s2ddjXKYpOMCpQhobDNCoLol3H9ldQZTsQ8bEMFv7Pc=; b=IEAZjWfqDvLC4KDips9sAT9oLHtbOl/RDKVVg698yVuuU03QD93hIEyR1C/SBFoJ4x C/yqNMxi0gm7VJby8c9D6nT6GAEblYUojdF0HJCOzX/Dz5XCI0wl1WKXQkwXwXWT9t8t krPD0qfFIyvZL9k/z+8hglIlWmVQcUnvsIix/33Amkri+/4YFDs+ED368rZF9DYJKS8f BqIF8nvdGlDbxZ/SI2sdg26+liYOjUVIH3cuy2ZG3AfzmxWObdnqJGZzQwSvMlJjdU9M 6L1nVjYQuTjhGY7J2IF6C0h5NNrmw3K+IwYnyR9ZbhBweOeRgkV3awN5db/ZAFZ0Yu0M vdjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586242; x=1730191042; 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=s2ddjXKYpOMCpQhobDNCoLol3H9ldQZTsQ8bEMFv7Pc=; b=VaGz/1zvWW+3LRCUxD5Vf/I2jz5dqcJYg8A7E83bhn4JADVZgcEe3UebqxqpEm0x2p MCe1irCylET8od9uTqfe0dCJWTq+1piRYbfCM9PsD6zOXqzma+LdXBXp1mtE62OW9jwz Q0BEWG1EDXM5Y5CpCDKmYPtqvF/MyIQjq1fgf/8FkwrWkJulY+gMM8YUEEZrwfZR0n84 +X0kOgAx78eIueJO7HgD8FoDg1E4oI3hm0Uo6+Hr9hhK9l3ubOT+OITDSYoNhFYRs1dk 53ftNn6rX0GWwtS9JzsSfxMSNmsefyIbAPicAWiWcxcrB7z4Vp2whyXYgvJqu1T0HPdC KnQw== X-Gm-Message-State: AOJu0Yx6oZ0bb/1X3ClpTGLSGOxtytEPpWjlohv2vnF21JasDritLq/z iPoKbGSTM9fKh2e3R02+TY8ONLXtvK+n3gZj4HSmLjUnY1hv7tC+Xw+cSlu92cg= X-Google-Smtp-Source: AGHT+IH35ts0/l0USCjFN6lwgA8BBJiwMJt4kRQTFjbSLwMYFlnC24azPznLSEhbX2QwhEqZTMAIWw== X-Received: by 2002:a05:6870:440e:b0:277:f51d:3ed3 with SMTP id 586e51a60fabf-2892c2def2emr11876088fac.16.1729586242433; Tue, 22 Oct 2024 01:37:22 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:41 +0900 Subject: [PATCH v17 04/14] s390x/pci: Avoid creating zpci for VFs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-4-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::32c; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32c.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: 1729586313974116600 VFs are automatically created by PF, and creating zpci for them will result in unexpected usage of fids. Currently QEMU does not support multifunction for s390x so we don't need zpci for VFs anyway. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 40b2567aa706..f06df757a34b 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1080,6 +1080,16 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, =20 pbdev =3D s390_pci_find_dev_by_target(s, dev->id); if (!pbdev) { + /* + * VFs are automatically created by PF, and creating zpci for = them + * will result in unexpected usage of fids. Currently QEMU doe= s not + * support multifunction for s390x so we don't need zpci for V= Fs + * anyway. + */ + if (pci_is_vf(pdev)) { + return; + } + pbdev =3D s390_pci_device_new(s, dev->id, errp); if (!pbdev) { return; @@ -1167,7 +1177,10 @@ static void s390_pcihost_unplug(HotplugHandler *hotp= lug_dev, DeviceState *dev, int32_t devfn; =20 pbdev =3D s390_pci_find_dev_by_pci(s, PCI_DEVICE(dev)); - g_assert(pbdev); + if (!pbdev) { + g_assert(pci_is_vf(pci_dev)); + return; + } =20 s390_pci_generate_plug_event(HP_EVENT_STANDBY_TO_RESERVED, pbdev->fh, pbdev->fid); @@ -1206,7 +1219,11 @@ static void s390_pcihost_unplug_request(HotplugHandl= er *hotplug_dev, * we've checked the PCI device already (to prevent endless recurs= ion). */ pbdev =3D s390_pci_find_dev_by_pci(s, PCI_DEVICE(dev)); - g_assert(pbdev); + if (!pbdev) { + g_assert(pci_is_vf(PCI_DEVICE(dev))); + return; + } + pbdev->pci_unplug_request_processed =3D true; qdev_unplug(DEVICE(pbdev), errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { --=20 2.47.0 From nobody Tue Oct 22 22:29:45 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=1729586321; cv=none; d=zohomail.com; s=zohoarc; b=GJlWPuaDAaLKCFO8MEqQhChwMKKkKbqfJvvDa3L3g/8bD3DP0Ai2HLbm6+rwGWPl+bud0rKN2CcMXwFbAEjOiZUEjlLElmlaw7foKSP4E6zsKRuJ2ZDR9z0zVGrvLxmPFKOMkKb2GGstprnt2D5IyfQuz6u4tr0Fq7PVoU3mmRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586321; 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=iZa4SHG6kqnCw7wEadUMiCSvFMQvdZ0uEhNofSMSARA=; b=NuxN56hgAoI9Si/7jkvI7Nf00hhsLRWs+v+pMIzVPGMcf/l1UpAn5Zgi9xkHaksSqO4iTzW+MkPixV+ZJiWXlkrNCKTP8nyNsRxj+ZlEePKmfan4rBUKxq5Zn7HNPuDbGYtkuv/UBT5q9jiTAy5CJGzYxKkLkDTngLbdhDixt2o= 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 1729586321597803.5590546457997; Tue, 22 Oct 2024 01:38:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOS-00025b-SU; Tue, 22 Oct 2024 04:37:33 -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 1t3AOR-0001yJ-13 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:31 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOP-0001W7-1W for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:30 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-20c7edf2872so47121705ad.1 for ; Tue, 22 Oct 2024 01:37:28 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-20e7f0f355csm37922865ad.265.2024.10.22.01.37.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586248; x=1730191048; 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=iZa4SHG6kqnCw7wEadUMiCSvFMQvdZ0uEhNofSMSARA=; b=abL/NvgcioC1W6g2ZnwCY34qAxuXMboxMt0Icw3u4WM7QKaav7RoyzIpqsspPGutvE T30IH0kztIg6Lo3iPjxYZ1JQzqoES1IYUJ2gSFUKkblnIzOzVAVESUUc9GbW1Qv9A0Kw BsWVnfOIwG6wvzcMkb0mQXmzHCHdycFzSTDnnyAc3QxY27bLdtOGDadNGxKwgU/Ghwdh xtDsCdjVFRVXcHF3xYgpZ7fJ0dRPybmT6t4AESj8TtAI1Flf4kSp6eOQMGCxIMmSR5kr peaNd2fdBBggdZr971TShBtxFK8p22RWbeFO+X4qLvDRLT6KRMCUIyZRVYH9J4ljUYok QoTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586248; x=1730191048; 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=iZa4SHG6kqnCw7wEadUMiCSvFMQvdZ0uEhNofSMSARA=; b=j348RSBX+fN7KSvAdXf8Fgzl4Sbehl5sUPx759ckzsS+2HHCMZ9Ms5fs7aWB0D1Tgs J3/QvWkl9TQk6NZVDvpSjm8C23bS10EB6JLXULvH2+0Vve7CFwZky6q08/5nx0lG+doi yTo7hzlW6pjORUmyP6W2tMdhespB0B74RHrGPV+c6mKZTuSpcom25s8pqMYyq9MOwKCN CqRW6AhaoYy8MEewSJlC2fyW1pnhAZ3W4hJ8ueI1Zr0vIT/5MsaJsQEKAulxlmUSdLeC HXFiz0f+RHT1zjpmuDS/8yju2XaX2oGdRO8jOftNYd90VrRTzfLxj3t1Uzf+CIZo9dbw fn5g== X-Gm-Message-State: AOJu0YwMfkvdA3NqDZI4plZYuCNKVdCXGe1mEErhZMxxhuo+N6vq32Y4 aCohU44P0y8gVglefOAE7xsJPgMkx0dEJS19LUTjPGidMIz/AnuD5/ipWLcPDow= X-Google-Smtp-Source: AGHT+IHAKEJdaylFNjSGyAqXmH6/r6eXyKVTHr2NBnmuU/GejIfw3Rk1twxlWVe7YvJGz6HcayrLtg== X-Received: by 2002:a17:902:da83:b0:207:1845:bc48 with SMTP id d9443c01a7336-20e9712be45mr27705475ad.30.1729586247807; Tue, 22 Oct 2024 01:37:27 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:42 +0900 Subject: [PATCH v17 05/14] s390x/pci: Allow plugging SR-IOV devices MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-5-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.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: 1729586321906116600 The guest cannot use VFs due to the lack of multifunction support but can use PFs. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f06df757a34b..0c8866f8298d 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -974,7 +974,14 @@ static void s390_pcihost_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { PCIDevice *pdev =3D PCI_DEVICE(dev); =20 - if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { + /* + * Multifunction is not supported due to the lack of CLP. However, + * do not check for multifunction capability for SR-IOV devices be= cause + * SR-IOV devices automatically add the multifunction capability w= hether + * the user intends to use the functions other than the PF. + */ + if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION && + !pdev->exp.sriov_cap) { error_setg(errp, "multifunction not supported in s390"); return; } --=20 2.47.0 From nobody Tue Oct 22 22:29:45 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=1729586311; cv=none; d=zohomail.com; s=zohoarc; b=hgtaByVhdJWqVJOVKh1L19MvvcEKX7tCj0Xw7MwtMZTNHryXN027Mtn9g9QMZeqFxCgaeUSsHNDPVBBigljqmX1SUs4OfqRNS3GRPjOYV62/APUyTdWOcFOVgpbylOhI2wrMH+EHv1j6RjryJro/0toIg3VKZWptnc4Q1rj2cqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586311; 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=pQrvciCkOy/A/+YwEeHddo6lMPRDDT6kedSZ2jSFXsU=; b=dwazEnUSYdFAWW/wg/r5/uQP3t9Z6dNPNO5gdJoOOXyN04Ue22U0lpFBz7YrU9GOPbmQMCZIkKBorWICMpmg6yYKJjFI0qVe40W/pTVG/pEgM5rIQwR2LOVvyKEfQggbT4pUtCZ1zXo2qXs0gBZ6caOtAdbZtH2ntggmjxw56lo= 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 1729586311447287.1935696370083; Tue, 22 Oct 2024 01:38:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOY-0002QB-EY; Tue, 22 Oct 2024 04:37: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 1t3AOX-0002MK-1E for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:37 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOV-0001WT-F5 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:36 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-71e3fce4a60so3580772b3a.0 for ; Tue, 22 Oct 2024 01:37:35 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71ec13d754fsm4202596b3a.107.2024.10.22.01.37.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586254; x=1730191054; 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=pQrvciCkOy/A/+YwEeHddo6lMPRDDT6kedSZ2jSFXsU=; b=xqSXI0DPIBNS0p69XFgBGJTdaE2Rxm0oNJ21vS+AZfTea1akXEqiVsc2lyW5psvMRq 9jHh0PyIgZ1oK+Ha6RkAMtJY8f81NVY5IQWjVVdAnTH2KM7gDMOmOA/UwvrRUuxk02Bj wvOA7na+YKT06RhEnwHp48o4MQeGdY6IbGDtOy7Ut8sIYwh8H4t70fuAfwI3Wb9pH8bM Q5ZGUZ2XTw0X5lsGlc0yiM3Y1hmaDk1HqUpx6qnN5CTbDB4t64mgO/455/w80h0U57MJ 7uJZkDcKkng7xn2pexto2qvR5i1v/S2crpFUlo9lP3TRkworFjoDfF8Sb88UItCfdQNg Pf4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586254; x=1730191054; 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=pQrvciCkOy/A/+YwEeHddo6lMPRDDT6kedSZ2jSFXsU=; b=EVh26zxgjtxM50cGml3ZTIpkghSJPMR/jp2XMo65Dlf0LevmmfEXHh07OfU58mLxKV tjQ5U/aLN+PsTN/CcwkrfkPYH2Sb/WlxWmJ+LpRtWaaAQImjfmLdQweU0PQCwElplcxZ ZoaXesntcBBTtysJMAVrZ8MumllCPIMk2lpQGqQNkkmLvAYNB72OwvqXlQfmHlKHsmHb IRsodlgs0sj6+1bxZuQfkhPtOaEhgWAMEPXwZff7KQtcUZuUfw9/tYwxBD/dfnV48UI3 VTrQRcmF8PuDl3JkxRPkjdgGTlv25Dp/J2OuEGJV2NCZZzQVGzxinysPu9cm80/SUTNn jU2Q== X-Gm-Message-State: AOJu0Yy/C/aMU3KCs9LJ+ruYLdZniXyRAgmfZCWoFJAm2Ui1y+4V4Bwv 7yOUFq97tLC+EpN3zQSx0+sD4i/3eDEWqrlZDMNcS/l5eB4THJkxwBjkJ1SUgiA= X-Google-Smtp-Source: AGHT+IGpVTD1gdTeN+CdtmR6/XTR1DqijmSuZ5/IxSVrEsMDuoevd62Zquycx/1nf0YPhpUUBhs1tQ== X-Received: by 2002:a05:6a00:928a:b0:71e:722b:ae1d with SMTP id d2e1a72fcca58-71ea3399b49mr19666465b3a.25.1729586253856; Tue, 22 Oct 2024 01:37:33 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:43 +0900 Subject: [PATCH v17 06/14] 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: <20241022-reuse-v17-6-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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: 1729586311947116600 The SR-IOV PFs set the multifunction bit during device realization so check them after that. There is no functional change because we explicitly ignore the multifunction bit for SR-IOV devices. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 0c8866f8298d..6ad47f4fbebe 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -971,21 +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); - - /* - * Multifunction is not supported due to the lack of CLP. However, - * do not check for multifunction capability for SR-IOV devices be= cause - * SR-IOV devices automatically add the multifunction capability w= hether - * the user intends to use the functions other than the PF. - */ - if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION && - !pdev->exp.sriov_cap) { - 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)) { @@ -1076,6 +1062,18 @@ 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 + /* + * Multifunction is not supported due to the lack of CLP. However, + * do not check for multifunction capability for SR-IOV devices be= cause + * SR-IOV devices automatically add the multifunction capability w= hether + * the user intends to use the functions other than the PF. + */ + if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION && + !pdev->exp.sriov_cap) { + 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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586323; cv=none; d=zohomail.com; s=zohoarc; b=FOe6LV+X9Fyl7egNBjByH4mXiK64BhTRipKcwinICzQjLTu/v2NtaWO3x1sDGoakx+Wahw8PW8bVCBx/OlwhfrF5MZ6RAd92FAbrP7YqFr6+Safx8vmlR8ozIV2ZQY8D42dhV2T5g/V1BAZG3d4xH32N3ZvIcWAHSbOvUfehmko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586323; 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=yHyVTHJya0M4L8kbxrtNFAlxGXTEO3Xl+9QYB8h5VeY=; b=EdvIvoQ6OboU4vLfW7sER5E+Im4+ZTP46YOnQG/isW1YECJuXUp7YJ85htaA/AePNNkkw5o3jbj3xjtuNheWbFJJJ6UePqDXUTL+PIM6qDMbhLe5/UCjB0RlPM/rsvj3qTUNCQ27eE+u8bIRozWBN0KrvR5Gh7444atQsFycV2g= 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 1729586323794984.2259947434777; Tue, 22 Oct 2024 01:38:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOd-0002Tr-11; Tue, 22 Oct 2024 04:37:43 -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 1t3AOc-0002TT-9s for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:42 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOa-0001X2-Ul for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:42 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-71e61b47c6cso4112360b3a.2 for ; Tue, 22 Oct 2024 01:37:40 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71ec13eaae6sm4315332b3a.144.2024.10.22.01.37.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586259; x=1730191059; 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=yHyVTHJya0M4L8kbxrtNFAlxGXTEO3Xl+9QYB8h5VeY=; b=1LFpOX9bD4ribv3V0tVKb/yiEN0tkKDPKahYz5gPTtwaMplcBmlVNXDQ12/PARE7Me CTO7T+cd5EhkrYCH95+gp43C0qiq8KXDLZaDWs+6iijJtwGzheQyosJkf4PiZOVOOEqN kG2OTjZ0vKt5DUkp9htLW8ka9AMPE5VOytQZMNga6eaTWwLFwiL5aKhAmGuLA6Etp760 CnMoAFhtiwRKTjTbGkdNpUeY1JyKbwFPFhbDAl3gACA/0TzSpiR2jg9q06pdJbEUkiSq j0cOZeepMaF/RXOtKLc9phJnH/BoUrnhZ0Cpi/NlK55JMXqbIYfkFV6o6AL5FJV7TUSo s5Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586259; x=1730191059; 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=yHyVTHJya0M4L8kbxrtNFAlxGXTEO3Xl+9QYB8h5VeY=; b=ECpA+HoQv/crkCgjtK4XM6EoQojYNEanOpNh0ZzRBgGc73jN03/Xv5Hn2b6ADchRSi q2IZvxIibbEKkTPhc3s8z78HZl38G2JE1oNJbl4pZlJIV8CA9jHFfRIqZf+i/LteFg9s c+FphhMdGH7141lvhl0UCzN65ugdSnTEz+X3ZEFk24GmyPztW/XSQ90CeCtO8lrSOiy5 W8LsTOl6zDSM/4FF1A19s809dDzHpDBNAFFrk31GkHpYaC5lCyxafob9aarA3khDXbJl Ug1Pns0evynoUXJVOfCHqDsJYPukjUdZ30woepiCPy/nVbEisthEGVKsA7mE+B9c/JEZ YpqA== X-Gm-Message-State: AOJu0YwUKP/I0WR4XqkS/9/GpTz3epoC9dxRdx7ZaV/R2xBHEFzhPW0e VpWG1ZjS/zD4VG6YfxItX92uDL2zhjbl5w+7SCL/Ud8onITYwjqgRG9ZgxIyc4M= X-Google-Smtp-Source: AGHT+IHGF7xk4LfbQ6kp9ZzpDbUhpcOLaWlTw9YQ0T/ksEX8PSmTk0IPcOCU4N+CNGpQi3KckZTobQ== X-Received: by 2002:a05:6a00:640c:b0:71e:b4ee:960d with SMTP id d2e1a72fcca58-71eb4ee9b46mr11209211b3a.10.1729586259413; Tue, 22 Oct 2024 01:37:39 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:44 +0900 Subject: [PATCH v17 07/14] pcie_sriov: Do not manually unrealize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-7-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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: 1729586325912116600 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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586373; cv=none; d=zohomail.com; s=zohoarc; b=jf74kvUEobYyTlQAVv4R3yt4ec699hgHHm18IUNWQbXnHctSrdpn3wHX0MbfP1ol3BTm4oi3ZJ4x2Godn6qbwCZsJSiTtUSTySfV8DcaTyEnQVdZv79V6OXqf+yS6mRZtVcWVkGE5mBZFUM4mzHt3BbNvbla462MBeImivnadUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586373; 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=2JI+eUDp/ApCC9/Nrtx5nPOkPrflNzQuywK+Yt7TPhA=; b=R3THsyfyXYvXVdfFiKxcGbyyz0vHYgHOL4b4pPGf8ydVZKy0QuZrjlHO48Z6XFWtVxlIKosxcCopy71Wcl88nJzrtCJg2G9l0ZFnako/aIZebnopj8chhGbqIKn2qwRfM0LJ9JPNeJMH0C8hXSQXEuXHOalO38VuEvA2yOJzeuo= 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 1729586373927853.2412918108703; Tue, 22 Oct 2024 01:39:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOk-0002jN-QL; Tue, 22 Oct 2024 04:37:50 -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 1t3AOi-0002gU-88 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:48 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOg-0001YD-Km for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:48 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-71e49ef3bb9so3774581b3a.1 for ; Tue, 22 Oct 2024 01:37:46 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71ec13d7568sm4202552b3a.139.2024.10.22.01.37.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586265; x=1730191065; 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=2JI+eUDp/ApCC9/Nrtx5nPOkPrflNzQuywK+Yt7TPhA=; b=KnANWmsnuNUB9XwtoxjUfLCvPHu+EpicOzuR9zYASYyxlP6IZCFOobOmm81yhh9oU6 ZlfI7S5O3RqJOBVljq+AcnWB1tar7LpkpRIr04yoMC6nYg2I6dcHjb5QzqfhG1bYQeNB KcXxmEQ1wlY80KhVscmWNLB/iAbFezkTfNHTEECXlMiuyiT/o7vRRrSO4uYsrJN6qnE2 qKe1t0w/iDAyHMjFkVZ+7kY40rRRDT5eZwIHqyULErg6Lo/zusSKff5W3UfQghxk70qJ K5bCMjIKCNW5OqCkan0bbGc3xhjBdyHuIelmCB6+HkG42Ot/PgiINJvgmpXSBLmdgfWR rGZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586265; x=1730191065; 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=2JI+eUDp/ApCC9/Nrtx5nPOkPrflNzQuywK+Yt7TPhA=; b=lHcz2ViuF3dKUsiIl9l1p47Z0K9aVZm0eqHVhCx3qsYYAgUnZ0xvA19wqg4KU0Hcl9 P+F2F9pmNaY/AebfzLHIRvfvtBLk4ofReqX880dR9JpOiyLv2yyJfZ6P9oU8bDinjj9/ X5ecfkqv77dVg9VrEq/EVaDkUQe49DV2VMwFmpuhewMruLFEj8yCdU7EYBHfWC3t8d4H YLWeb2ftRsqNvQtguwnylMz/s8PmA6rKZ9o3kgnLk0LdvfSXYaxQ8rWBja5v1g7m3wce M52rBU9txgKRzLDa6WFJ/OvuQfd/AIEFP7MWFLAeeZe0mQbt9ctlQaZnZ5Su+qgoGtq/ x0RQ== X-Gm-Message-State: AOJu0Yx89Pmxnso6xDFZ7xrfHDiohqXFGBkGKvNzl+KqjPkxcFa0PkPo m5DlqDrlvGmcWLPXFS5U699M0N5hzUF6qHmTJ9jUrvz1CmFJ7EqfLdWmtDTe4tM= X-Google-Smtp-Source: AGHT+IHaFRqmB6HKcMeqkBAW/rXDa1sM7zEsYIKMAI+XAvCuvaKS5iva0prlteplCVWLjPdQd8ws0A== X-Received: by 2002:a05:6a00:76b5:b0:71e:735f:692a with SMTP id d2e1a72fcca58-71edc1c6090mr3472764b3a.14.1729586265323; Tue, 22 Oct 2024 01:37:45 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:45 +0900 Subject: [PATCH v17 08/14] pcie_sriov: Ensure VF addr does not overflow MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-8-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.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: 1729586374165116600 pci_new() aborts when creating a VF with addr >=3D PCI_DEVFN_MAX. Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 8 +++++--- include/hw/pci/pcie_sriov.h | 5 +++-- hw/net/igb.c | 10 +++++++--- hw/nvme/ctrl.c | 22 ++++++++++++++-------- hw/pci/pcie_sriov.c | 14 ++++++++++++-- 5 files changed, 41 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..dbbf20682ca1 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -446,9 +446,13 @@ 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_ST= RIDE, + errp)) { + igb_cleanup_msix(s); + 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 f4e89203c1a6..bd7f1d7bc8d6 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8440,7 +8440,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; @@ -8449,12 +8450,16 @@ 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) @@ -8579,6 +8584,11 @@ 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)) { + return false; + } + nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); =20 pcie_cap_deverr_init(pci_dev); @@ -8608,10 +8618,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..91c64c988eb4 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -24,14 +24,22 @@ 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) { + int32_t devfn =3D dev->devfn + vf_offset; uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 + if (total_vfs && + (uint32_t)devfn + (uint32_t)(total_vfs - 1) * vf_stride >=3D PCI_D= EVFN_MAX) { + error_setg(errp, "VF addr 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 +77,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586391; cv=none; d=zohomail.com; s=zohoarc; b=YkMGrZQwx9Z4CZE6Dsh5s9FHVgeneA2B3XUrTFrrfKiGeWYgW6xHXNjJUOdfpvwcTaxHYHb9QvuCRqaADnmExF0K54RFbtYMu0XwX1we/KNI+d+adCeqDdLk7NluyfZ2leJ/gWtulhAerFH03AlWs9KyQEjgtMco2vM7DLQFc10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586391; 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=Pk1g4gV2BzUyvws2WL8XxncsfS565/ZULISdZhPPeLs=; b=k2Nn5XI952ECdMWqr53VhS2Z9Df/cwQxF26ggO3aPlwywy+KkOQoOETE4Tc5buDgvt1+HM6zPvxiVG2LagVyHD4nj1RUDET6pIFk6nIl+zfHYLWIwLwG3h3AmBqh5ZC+QPSLTCPrG5iGjY+EiQvHuRfzsWLdiaeQeORQfJGiDT0= 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 172958639180869.68378100575126; Tue, 22 Oct 2024 01:39:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOs-0003BJ-5M; Tue, 22 Oct 2024 04:37:58 -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 1t3AOq-00035g-9V for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:56 -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 1t3AOm-0001Yr-Vi for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:55 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20c7edf2872so47123665ad.1 for ; Tue, 22 Oct 2024 01:37:52 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2e5ad25cb15sm5455522a91.11.2024.10.22.01.37.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586271; x=1730191071; 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=Pk1g4gV2BzUyvws2WL8XxncsfS565/ZULISdZhPPeLs=; b=e65kYhIao382HvwxS36NgDZmY2E2kBQwQpVQwE+ZMMfaxoQBxcFnDhKOrrlXLvfioa FQSnsikjtGGPXsIuZ9TuN/onAQ9GMbJwoEmNamxCokt1zOXZaLQUp2BAq2deikMIpctp 4RUJ69CFKdmZZIo3PQEdZ8a6b4t3duus9JHhbBTFc2+mF/Pdn2ilRl+m7kLieNSNeZ2x KXbp/a0bvoljh8bz4Abvf/bF9iqyWSoeDvZZ5etecyqJn88zEOegRxzWy/oeaR48jy5l BH3Qw6cK5R53AWaFH74dPBWDJOZFKk/KpUN49SUcsaWAnrV0fmCMOBiVI5zWz0dQcRd6 jYLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586271; x=1730191071; 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=Pk1g4gV2BzUyvws2WL8XxncsfS565/ZULISdZhPPeLs=; b=XZqoQdLpOX+4liS8ifmeqj5+wg8pAXvW7175bK5qYpDDth/IHRNzDwYDsIQc7kLJpa TxBAsN4YbdzqCz2Ho//GkC/Ye8fC+S5Ce3ffjl7Nb2a6aOnHTMaV32jjcJNSFM9kMyOe Lh0MNPs1sncZh5r37vjtd2rXo5hpI2fHb9cBvi+HpFPrqiEmHJ/jhoSt34rZJys/gWd5 N0He3QEKnbeyztOeTjYjbb2jpJ3mA82jZQQB1hPxQF2gyoiB3YpvZqF2oCcd/L/bhgWL y3VrrbQMvyO81uaR159jJ+EctEk9eJSWwCKqXDkUguAT7TfyDtxIn6Zkuj0dC9busH8V y1bg== X-Gm-Message-State: AOJu0YzpEgkfOc4nvGk7emPI+gRpNyrdmF/BF6v2rWVIImSv2ADH/Ecl DDjg+2jBz6p2So7H0FaLzTD90Kh+CCOEAE7s5ZrgSS5LgtPmGej1EfWnGMjEH00= X-Google-Smtp-Source: AGHT+IGGG9p7JOgKjjZVi6hB9iLFvbHRLwzW/C1/BLfv1i8v69bQKWSohk9g+YPypVWGgpn0fPULpQ== X-Received: by 2002:a17:90b:3883:b0:2e2:c225:4729 with SMTP id 98e67ed59e1d1-2e5db95655bmr3584348a91.8.1729586271313; Tue, 22 Oct 2024 01:37:51 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:46 +0900 Subject: [PATCH v17 09/14] 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: <20241022-reuse-v17-9-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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: 1729586392388116600 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 | 94 +++++++++++++++++++----------------------= ---- 5 files changed, 55 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 cbc42349d561..5dcabb94d679 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -215,6 +215,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 eff408b4e9f4..7ea751fb869d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2904,7 +2904,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 91c64c988eb4..f1993bc553c0 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,7 @@ 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; @@ -44,7 +52,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); @@ -78,14 +85,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, @@ -151,38 +178,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); @@ -190,18 +190,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; } @@ -214,12 +206,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 @@ -241,14 +229,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586322; cv=none; d=zohomail.com; s=zohoarc; b=i2BMezTWRA7pF6YtvWoZyFXrrjKYts5MTsNjEZGjwKw7H8LPRZRJKnMf9ajQN0AF8m84vGdCafyd16BaTl3vqankgLHUT+Fku1/hURtFTyn30PAx8eF0LF6OJFHUKAa/ZT7pWgjQq6VQrAvoFS3pEzOHBmqIQbQ/gKVz9+sakzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586322; 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=4Xt78vSTJ1r8zdGahl9S5mey0b+UCyoAUmEmAWGjCqs=; b=At8uzLSpQlla+6DBN6naUgLN1xtNrAESGyRqXgxcNnUjL01F0dvXYgEzy4nRRGrNa4sut8Ally2RhgfkWySRZMi7/Dowi2L58mdE6NiSeuiPuU6rJtyh6Hy/cozhUSQjixERjwcM2QKni80qab2LDyE1mgcL3IMh5t+KrHmuui8= 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 1729586322463697.8939985591207; Tue, 22 Oct 2024 01:38:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOw-0003NN-Gr; Tue, 22 Oct 2024 04:38:02 -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 1t3AOu-0003H7-2S for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:00 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOs-0001ZG-FD for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:59 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso3423587a12.1 for ; Tue, 22 Oct 2024 01:37:58 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7eaeabb83easm4531944a12.72.2024.10.22.01.37.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586277; x=1730191077; 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=4Xt78vSTJ1r8zdGahl9S5mey0b+UCyoAUmEmAWGjCqs=; b=x8QYgZwZRxGN8cZ1QMUfPOeKAsZv96mGPbnyivYWSq+F6Waj0UJdypMZeP6rzp4FGG 1boJtUTlvPcV0UVNFM/5lcYWRbeApuELI5sT+Jcw1zHCVCuPpjc0/StrzyeKIaHDW5oV qT1VFmMp6MC1gFOHoIv+UH/lKScHfr97QY/Wz+weuSWWfq8eQ6pPnH0Ak+tFC74Xktn0 eAM+82H7GFTBoLn5F9/cmYwyNZvivMPV0kXaaecTsvFg01o5M6M6l+dwFxpNaaSX4kVB 1a7OwuKq8TNeClImYgJMPeS0ggtDWYJauUzo31unuBpUwePXbjKzv0KkL1wcAm9V1yVs QLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586277; x=1730191077; 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=4Xt78vSTJ1r8zdGahl9S5mey0b+UCyoAUmEmAWGjCqs=; b=TgjyTkbi4/K7C9iCTPViJ44elBX+/49JjPGBamyPsXVZwYhzyspz/GHD6OvocRgMTM wZkOfTIQSHS749Xb7Kqr7JTUHBMN35tp3Kqo2BOwXIubbTBJB918FLE+hVQViO/L6aab U+ukmQCp8aCGQWQn1WRVRfthb9nNlyx9L90I061PE/4WqrJrgyt5THbKA/aYXk1QugEb 3JQe/ysyLYG5lnAnskv2jLiay6EQCoO+yZMovWPTlqp1Fvy3gx3r8QLnTvF/sWtOEid+ MHEN4p3YimPWrjnjvUg+YCu+OpZzprlROQMQ2yzEhjY2ziCc4kZHFjtDSMFJqzleIisk PMoQ== X-Gm-Message-State: AOJu0Yw2c6Wtigp1wj3Oposw5ixYBvt73ZfiF4ZlomKb1/1fOkzlD6t9 5n3sMfivPBUT9hzIUb3sOYx3/ZqaJqRZQGd6C9sOq2v0ttyQDF0gUDA2lcwrzuY= X-Google-Smtp-Source: AGHT+IGctnbezCTGJqbvKnxKBdZzunDvWd8LXUp3Qrw4lkysCgqoEBL061YZtk6dtLBP6Ny9Lsd5Jw== X-Received: by 2002:a05:6a21:6d99:b0:1cf:3f39:c469 with SMTP id adf61e73a8af0-1d96c25c2b9mr4130494637.2.1729586277177; Tue, 22 Oct 2024 01:37:57 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:47 +0900 Subject: [PATCH v17 10/14] 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: <20241022-reuse-v17-10-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::52f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52f.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: 1729586324002116600 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 f1993bc553c0..db087bb9330c 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -93,6 +93,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586303; cv=none; d=zohomail.com; s=zohoarc; b=Ac8fV4nKg1j5rBrSZOvIfYpWlkI7Bc9E0JWPhXqxsyFGLX0aYfXke7rr6ihs3tBX0Z1yZtYVg8F4Iu3jnbAW9iNqyamBAyQDvkb5sa1S4/qtGkxjfK8MkMNouBpQU81xuGx90sh5HcULGFns151Xy3ZyGDoJDa9kgVaraCkjvmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586303; 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=pNee5FE0+70OZlVEsoP8yUDph/emHBLuZjC/iOT6fd4=; b=UxsXpuoD1ilH54qsdRhYozngeyMQ8PJDhcSdJ9nZFCO2JCagWsdasNyWS0Vumo52o5BWZsF0a/sP+/6OewTMNseSDYWTeuBOzFv9stfzfADf37KBoSBf2SFULGybEu/ynbFi0QtVInSMcWF7B97pB/orKcEMPDVboHXjIyg9XCs= 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 1729586303487676.0149995060907; Tue, 22 Oct 2024 01:38:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AP4-0003oq-Nb; Tue, 22 Oct 2024 04:38:10 -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 1t3AP1-0003fp-GM for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:07 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOy-0001Zc-QS for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:06 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-20c9978a221so61084465ad.1 for ; Tue, 22 Oct 2024 01:38:04 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-20e7f0bd376sm37901015ad.132.2024.10.22.01.37.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586283; x=1730191083; 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=pNee5FE0+70OZlVEsoP8yUDph/emHBLuZjC/iOT6fd4=; b=Jr4n/xALT1966AWNjS9Avpn1mvs6VF3KvXqOdCWKKN3+tVlFzmbH7PnwX3QvXDFbg1 +j5KguEDYyhaubyglokyuCJXqYFd3R5UW1Bq2BKNT25WxJGhtsKtSTDPonyuqMP4Eh2d PG1HOkgiPQzbjtsoMtD+uLgSXhsa2g9PcCtUv0TXaX16L0fQGbg6/DAT2v8ahHcmqQLA HgMhy0aN5xvnyNphbcl1Sms5uI5D6sxJ0sewj4HTW8lofFJd1BoGXCC4Y3AtFTprEyyp eRQJpmnnJMpFAVs0cZjrxa9ku021g000T14Ry38T2FcIUM8cpscK8A6sFHYY6xNwaCF2 gjJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586283; x=1730191083; 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=pNee5FE0+70OZlVEsoP8yUDph/emHBLuZjC/iOT6fd4=; b=kSgGfOvqSRyc1CFhClKLZowMN1jmRcMsbS+igXsN95YC3AxX4GVGY/6nRSU3dw1PKr 33jUjTaADyaowb7gzN97U2qr7gth6Y+7/DD5HxxJJHjWs3IhbyL868a59VVrx+bOAu6P /D0d32Dqus7XbhPBeFNEevtnC0PUdih44yNpY7hsqius0O19x6wqC99mNFIEyNFcGsB8 nVd1yjxB+NVzNCSYRdK23p1asELLFKTtwcULnWZiP4VKUOAcMBHi6uea1JM4M6lQ0qOE aq3yewTBZru5jl4Ee6IxhsUNm4eheQiMgWL+L9sbADklVbleS4QnZieav4t/hQPZ8R4N M1iQ== X-Gm-Message-State: AOJu0Yz6LYaXlVsgaQEACLOzokuYLiw7m9lRE5ea90yUKSfz197qLlGU N+0ngc6PotJzxB0tYTsixY6mMugDyrMhxf1oHYGCn1sqUNflg7bfzLy/nfrhAjk= X-Google-Smtp-Source: AGHT+IGwHi3EIjPtd09Jwmy03p4e/DG3nfc1sQ55yE8ESjPH7G5jzBXB4T7UtxFofO7CS51dDXGLHw== X-Received: by 2002:a17:902:ce06:b0:20c:f27f:fbf with SMTP id d9443c01a7336-20e5a78dff2mr235089615ad.25.1729586283518; Tue, 22 Oct 2024 01:38:03 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:48 +0900 Subject: [PATCH v17 11/14] 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: <20241022-reuse-v17-11-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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: 1729586304009116600 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 db087bb9330c..69609c112e31 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -51,7 +51,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); @@ -188,29 +187,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, @@ -236,6 +234,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 wmask_val =3D PCI_SRIOV_CTRL_MSE | PCI_SRIOV_CTRL_ARI; + + if (num_vfs <=3D pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)) { + wmask_val |=3D PCI_SRIOV_CTRL_VFE; + } + + pci_set_word(wmask + PCI_SRIOV_CTRL, wmask_val); } } =20 @@ -252,6 +261,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 @@ -298,7 +309,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; @@ -306,5 +317,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586383; cv=none; d=zohomail.com; s=zohoarc; b=UsDDYf2BUYpyzgsz1g8y1l+he96uQhjwVSbcXV/tS9Lz+QeYJ+MefdnOVjfw4usedOqhIXjS4TJXfO974fJ6ypEBxHTJCkLrgXLrpvxP1MVVgENkguaR6ZYlZrtaFt9GRHBgDjkpwQ97fiAo1dVvLcWqMQAmA/RfTDxbd8zAqEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586383; 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=MV0l046maJwkqtz/pbKbRih2e1ce6szoak1X0m0d4Rs=; b=WqsQj3ZL0xWnEDpYZCTfaFjL+ZCavy/QszhJMItIKxdjf2mkULhoCfRaFM2EWwf9zNLoeNNlquastpCAy7EXFESSF9Ncl5oqv3D8sueegINwF6oO3CRt5BbypJslkSFvzlLC5rauB4wPpAJTq/jzcfsYQ9MI40DwhZ7eNMBQvPA= 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 1729586383983643.1459854945913; Tue, 22 Oct 2024 01:39:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3APK-00040u-L9; Tue, 22 Oct 2024 04:38: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 1t3AP6-0003sy-OC for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:13 -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 1t3AP4-0001aT-TM for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:12 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-20cd76c513cso44606365ad.3 for ; Tue, 22 Oct 2024 01:38:10 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2e5ad4ee3b0sm5462860a91.42.2024.10.22.01.38.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586289; x=1730191089; 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=MV0l046maJwkqtz/pbKbRih2e1ce6szoak1X0m0d4Rs=; b=3WN47AxWfKQGogoUbaHNsvh/HcYjJ4FGaf0yVfnWo+moKO5oHJVY5KitXpV76ld5fy RDRtwtW3EoGv4LDqvNRqF4g8Favr+u7X80h+O+Ag+RAEg3h9uUterE7u75CTvTnn3ykz MOim05mfJ6/MbkUT04u8npDhvgQ/OIZDegvViqO9VsVppxTepmVwyaqmDIT4EEPqGlpq LMrWPfgZ4pvpWu7Dfc+FubGGd7A/uelPaBDzr62u+IAy80l7lq9M4dOwlQAuJlP9zP24 SM83PBTSLeNDk/HfyO9hmEvIUojgc3khqoDnuRTsENqHfRuOLII/W3pEGQ7wBDdpQl8S ZR1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586289; x=1730191089; 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=MV0l046maJwkqtz/pbKbRih2e1ce6szoak1X0m0d4Rs=; b=Mn3vDagspJU0lEVq4SlIZHikuf4gKSi/x2VdN20qoqQ1ZB6whgAgM08rb2gxpSWB+q ZW9skwas0AUaA1XMcO4zGqoBfcrgbSa73zwG936IKQ2kzg+QT3/a+dcY68TcvaVJPJfE QJ3fvYD8COM9M6hOnPs3oOWxuUwipaxN7MpsTkof8EJWLzsj8fG/CCpV4IcuY43NwZ/E K17JdNZwUbHs2+a0mO2GlZScW4e7ZO+Ks0XmNB269g0WRnrAujSxLX8g8WV97inJ0fL3 ni8Jtr3Drp5gZV/we4i6gqmXqiIBxPjOIq3dla6EAhu32qIKE1qnQHQw8vxJI7UIGfNy B4nQ== X-Gm-Message-State: AOJu0YyzAxH9RN5rDbNdazsKJckriTYpF5zAvON3OjAoSNCeiuTzQWHf I5Mec6hkyzOVCyyAFvQPngqgoB0yIU3rDHGLTMuH2NXHMmpSK4wQxFlnOY5ob5w= X-Google-Smtp-Source: AGHT+IEqL46JraT+D71kkk1lHx7Z9c3l5O+1D6oqfCRmVWHI+tKOniiPLNdh1+Uz7Hi4mg7ml1kv0A== X-Received: by 2002:a05:6a20:289c:b0:1d9:6c07:6481 with SMTP id adf61e73a8af0-1d96c07650bmr2861055637.42.1729586289495; Tue, 22 Oct 2024 01:38:09 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:49 +0900 Subject: [PATCH v17 12/14] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-12-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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: 1729586384417116600 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 7ea751fb869d..8120d7c4c5a3 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -735,10 +735,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 69609c112e31..1eb4358256de 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -248,6 +248,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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586393; cv=none; d=zohomail.com; s=zohoarc; b=PXSf0lwK4uJ51x8j9aQBBcFmP6AWtBy9cNl+XNY+9QCm4dsUwO+nCH7PtNafFMJu/G87EYwfBW9Kz3mdrWZ5FXOqOwPIm4G+1533+SuJc294Ux9v75+/lM5IISYdqyQTjmyOblvefYo1u1EMFa7xWG1hORuO9AUDaZBCcLh6WX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586393; 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=gER0tR9dEh3Z2GZldoLikvaiG5ouEBTAsFs/3NvKbxU=; b=lg6QakdDh2XlrYvOfeJSs3sPNOGaEm5cKf8BbmaZBtA7gS9672ny4WshCaLlmbuR7UvszNObMlk67pRKKqmM0/8dapFsm504b81CyaI18EeaYmmJ7haa4zsbFBdBfGC+2te97aYjyx4R1fkm3gL97br/eW8n808JKTBS9gnLpIs= 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 172958639316522.206077829096103; Tue, 22 Oct 2024 01:39:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3APX-0004fX-2H; Tue, 22 Oct 2024 04:38:39 -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 1t3APD-00041b-7r for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:22 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3APA-0001bI-N7 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:18 -0400 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3e602994635so2145589b6e.0 for ; Tue, 22 Oct 2024 01:38:16 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7eaeaafbd49sm4438387a12.11.2024.10.22.01.38.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586295; x=1730191095; 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=gER0tR9dEh3Z2GZldoLikvaiG5ouEBTAsFs/3NvKbxU=; b=o1eOlVIasoJBBTJjByOH1qNwIimOlIwLAopdP3hqaoqILm9P7/paHpy9LfrSeXovEl C8gCvg4kncknOU39NMydgflM7oXAY20AwZw+u2b6ZJH+CJl+046PhXRhTGWXQOu30TSf 4zOenXgIKojYoguiRn1LA7dxd2hYL5e3aQSBZcIjzhabBXEBdxBBZO0bjdjtULIYy6jB gvlPaTPqac3CtH2YMrgZ1MsMcXSNzbrzbyD2hPwlXT0r7o53YlWbIM8wN4Xff9l99sa1 3pt/cPQadTz9W0LgRwaQ9mOb1wzfhlipzrHmBmPLSjf3aShnF1yIlGkE6Q7TZwOdHwVL nRpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586295; x=1730191095; 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=gER0tR9dEh3Z2GZldoLikvaiG5ouEBTAsFs/3NvKbxU=; b=GGuwb8bVMmeLSRbXE543nxMfNxQw+8aFtZAaKL4SuU8Ka8f/K1g3Z6pEurBL17nIkD nAj9PGGSTECs7XhiQ4rLnHiW5ymbSGNGLwGoAkwHTsQGiceTJtmqUTfNU4+Zi8iBpmSL LDd9c5Q8DsEPq2lTHL2ADyxzxlSKEnCQI+/zDLweb6p+dEejYRYkAyqo0Zyaqhh6ULcA X6l6aJuU9GN+S4+/mpjQ6zmWI9GRIM/arxg4dek7gsBWHXQnOmEc4Y6HINxG2avym5wK 8DLU24HAQV72MYkLiP4ieCY7AlzsnDztJPCiDdvfOsrLIZLNv33w90qCizbG4OTVYuJc fhkA== X-Gm-Message-State: AOJu0Yyf9Oj3u3RDbqNDyw+Ug6znZZ+do0ls8x38AqilSbuMRadWl4W+ m4/G8PDG1hkSlsUTwYavZdPSUgUOB9mrMe5Vau5/Vtmg4Pmrycz8R68EnWqEOF4= X-Google-Smtp-Source: AGHT+IHHPKPrzyv+Zt2GIvbs5UnZiVbjvU19Vj/bBurbLiUl1FEajLJ+dELHKowkucwzKcQNJ0Julg== X-Received: by 2002:a05:6808:3998:b0:3e2:a1f3:efa4 with SMTP id 5614622812f47-3e61cfe7364mr2460650b6e.1.1729586295261; Tue, 22 Oct 2024 01:38:15 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:50 +0900 Subject: [PATCH v17 13/14] 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: <20241022-reuse-v17-13-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::229; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x229.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: 1729586394552116600 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 5dcabb94d679..c9d4a347cdfe 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 8120d7c4c5a3..f31a6ae804f2 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 14bcc725c301..76a150fa2a2b 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.47.0 From nobody Tue Oct 22 22:29:45 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=1729586323; cv=none; d=zohomail.com; s=zohoarc; b=RQ79QSLKE1JfxDk/3a7WzdL2y6pbX715SrQ+aZLtyRSN8qav8cisMkzi5bsEtmkgNF2TcqEBBUzWa3uZno4WbmhkEBzRS/W36J3vtnI4zQ5DWMyuSvEcdfTSCsss9758slhlXv0PXJe9ACvtJRjCyXrcHffVwR2IlYKj6LokuOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729586323; 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=4rGP96u26ll2Tu0ZxjSlXHm20u22lSeeBTzuzXY1oKo=; b=dVCYQO8Sdh1e7qmpoWNvc8XAwSS3NZGKyxkndzvuoCdEWIjoVGlkymZ7AacTMj8OIhfj2wQ56Z2A3xqNqzbgwtPTWlZxqk/6hZzaxEWzXjoeJgehE1yYyXPE7yE0SUEKLg06p/2vu5FEf6LpYmt/a3gvWIitxODxf73LQhpN/tg= 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 1729586323721568.0840818835414; Tue, 22 Oct 2024 01:38:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3APU-0004Sw-Ox; Tue, 22 Oct 2024 04:38:36 -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 1t3API-00045I-83 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:27 -0400 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3APG-0001c0-OH for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:38:24 -0400 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3e5f9712991so2647196b6e.2 for ; Tue, 22 Oct 2024 01:38:21 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7eaeaafbd13sm4528382a12.9.2024.10.22.01.38.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586301; x=1730191101; 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=4rGP96u26ll2Tu0ZxjSlXHm20u22lSeeBTzuzXY1oKo=; b=ZDc5JyYkSLG//TFzY7dnflx0+lNBqTwoujNKb62IrZzAYzIeouWe8/5gnMWcFJkouD AhwRffJTmdcYw9IIH+feQHmDWWE7SsjpaBEftCci6VET84WHX8eGijxeDRRyJHesQVFS bDirlYTS0vCM2nHBMyChn+Qoa91ecXXz9/cMq6oDFfO/tEDQa5lY7Z5+4Z4INLNarghd z7hicQzSPk3tX0SSEWJk65m5jtbpwFpD/TKCWMJKjPunhDNq1RKo24EikOiE3aOjW5zw NMKlcbIBnk4HB56synj/J8/DpSxrcxNxqMJosiLCYRa75ac2BsE7IDrTxgDo1/iuBRL/ Z1RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586301; x=1730191101; 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=4rGP96u26ll2Tu0ZxjSlXHm20u22lSeeBTzuzXY1oKo=; b=cUcsMZH31iyLLKkr6B/43WfWgr4HfpGd1HryqQpQoT/poSBJQz48HSzdXk04MVtfRg G4bB9uHub7LfwmQxk65vptPJMSqaa2sN0xVcONzfMxLh/QBm8F2lNjOXeUDyKD9ZuYnd pk55fENEZ/fUZj5p+nxWXtCZ8oWmom/0qo0qg5hUcoXutDSfct7MxIwXrV+j1W2qxuw4 lstNvYZ+MTqyFpIVPcdhg5U9BcV2S+2ISDennTKwKUTF6EjvfinRLnFRS7j42OhrGE5z Kt0/imO3UnoPhsSCaZQML5KoTqpX/g0ejVUdpV85BAHCQqBvISWBSZ8JKbilDJ50sit1 RWjA== X-Gm-Message-State: AOJu0YzztNPTZX/+adTNIGvr15IVMPlVDJr20xl79f/DH/Z92C3w5dPG 0MEE8ecGHGv9hipwJE/swaAiJysECtuaFFHqxRQYfxGnZ3T2G85ubmY0qOTQIEs= X-Google-Smtp-Source: AGHT+IE1wJVd4xQUi5/i1XSepyLX2A6kseE/BbP6k7B4UMTIKxHjqCG9Q8QnwC5R53p+LRMLc808KQ== X-Received: by 2002:a05:6808:1a22:b0:3e0:4db9:8c44 with SMTP id 5614622812f47-3e602cbe098mr13514369b6e.27.1729586301088; Tue, 22 Oct 2024 01:38:21 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:51 +0900 Subject: [PATCH v17 14/14] hw/qdev: Remove opts member MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-reuse-v17-14-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@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 , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat 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::22c; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22c.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: 1729586324025116600 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 aa97c34a4be7..e8254f1cf302 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 db36f54d914a..5f47caf983a2 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 44994ea0e160..9d5ffa3baaab 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -630,6 +630,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) { @@ -711,13 +712,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.47.0