From nobody Sun Nov 24 14:26:12 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=1722575987; cv=none; d=zohomail.com; s=zohoarc; b=BD9sYwSDPeqq1ie6YNyiFD+LCrV2/DXvhS0uXD3SSJRtk3W90A4DzWAeQKE8sI0Phy/H9aT3zTFbOEsh9wG7d1LYB3yIaGh87aSD5Q/yGIFGmuUn3ZDJKoSISCoXQizYsHca2CwCLsJHBinLPYbpy089R+aG1dXvaMX1ywNS+Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722575987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=mHmyaZxCBDaQyi5lNfsBGeKAuxtHnKNKqZvCixF1TEfv8C59HetPt8UX1HP6AOW2ZCGkIf+m+N3XVBf24L4G81xQCS8zfsn3p9rBTh314X9B6GaA5xd0FXNzQ16vmMPKdlK8O3lxmRPwJC/3vv46iLrtOTdW3pLYNiNTkKqYT00= 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 1722575987174736.2291529309616; Thu, 1 Aug 2024 22:19:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkgl-0005Gj-Vu; Fri, 02 Aug 2024 01:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZkgi-0005A8-CH for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:48 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkgg-0006uq-GD for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:47 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3db19caec60so5547433b6e.1 for ; Thu, 01 Aug 2024 22:18:46 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7b764fb50a0sm522426a12.67.2024.08.01.22.18.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575925; x=1723180725; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=V9GAFpNV+4pMlP/ycZJTaYMeP/5e7RgzwJ9fwLJjrNUVfsbkXQ6C36rhiruigtjtld S0bpRXabcdRj6bRKtf4RfVo3Q2NxMO+r4GpS8sQAcLn5Cel5cUzOYfDsNbzmPTZZdkp0 dt7Hj6CUDMRaQzPfI8zHrTu+dvrymzZb/i0pfLJE191eLMlcNN6h2ASnecDhQGU9+KHC QWp6Y85HqWJIQzv1hEBB8w2csWBxyvCpIUpahCONWiXMuWsOq6/1L8JFLrthsAaaEgA0 a2WPbG0fdRDrdAJxFOeYYXSJDi6viiYUzTJCIbzP11TH1NABzhKQGMZoe4cj8cNz0td5 S4kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575925; x=1723180725; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=tmpOjPu8E5151rZGreeFQEgWzcwrGX2bl2IaNIRKf9sK4BAbuPSiDMEdOuOlzXMIbI KQpM7KwMiUf9/SEsR+Sn1JnufudlAlHOKeoFB2DmjpWoiyey+5CyZI38SHXFvQ4czBMM mAnXO33YpdVOwlinb3FxraiD4jykJMU3dcexSwBAzbTILO026HZpRwEVfwfP33+RIHFl j7sdOV9WwF4JC+UdsBX7IoCyv5kJ/ajH3m9AegA8NHkoS2CIj0aB3Nug5Zx/i6qZMDqB OOehkyzOc4abqFc/m9zRelTRFYQNzdQDsYNC0Fsp9p1hiYdBPirtKC1YhleIuXc6EkaH 8hKQ== X-Gm-Message-State: AOJu0YzW8K8usdLSJh8Yiqis28Pww3/BQ0VuDuwVZKiLuCNyOeF1CU8M d6SPgbLyZzF4Uc9MWZkCBezS++M4D5VAHCHnMWBL8jFTA/QraFgzR1LkxBd+FvQ= X-Google-Smtp-Source: AGHT+IHDciSCUmTYqytf7CZGW+ayt8ynWrxq4B1J5LfO19vwLlWRaFG61Hs4kR8FOLi4fVb749TVAg== X-Received: by 2002:a05:6808:2223:b0:3db:1558:7582 with SMTP id 5614622812f47-3db5580a2c7mr2773271b6e.15.1722575925455; Thu, 01 Aug 2024 22:18:45 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:51 +0900 Subject: [PATCH for-9.2 v11 01/11] hw/pci: Rename has_power to enabled MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-1-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::22b; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22b.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: 1722575987731116600 The renamed state will not only represent powering state of PFs, but also represent SR-IOV VF enablement in the future. Signed-off-by: Akihiko Odaki --- include/hw/pci/pci.h | 7 ++++++- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 14 +++++++------- hw/pci/pci_host.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eb26cac81098..fe04b4fafd04 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -678,6 +678,11 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) } =20 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); -void pci_set_power(PCIDevice *pci_dev, bool state); +void pci_set_enabled(PCIDevice *pci_dev, bool state); + +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + pci_set_enabled(pci_dev, state); +} =20 #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 15694f248948..f38fb3111954 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -57,7 +57,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; - bool has_power; + bool enabled; =20 /* PCI config space */ uint8_t *config; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fab86d056721..b532888e8f6c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1525,7 +1525,7 @@ static void pci_update_mappings(PCIDevice *d) continue; =20 new_addr =3D pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->enabled) { new_addr =3D PCI_BAR_UNMAPPED; } =20 @@ -1613,7 +1613,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + & PCI_COMMAND_MASTER) && d->enabled); } =20 msi_write_config(d, addr, val_in, l); @@ -2884,18 +2884,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int = vector) return msg; } =20 -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power =3D=3D state) { + if (d->enabled =3D=3D state) { return; } =20 - d->has_power =3D state; + d->enabled =3D state; pci_update_mappings(d); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); - if (!d->has_power) { + & PCI_COMMAND_MASTER) && d->enabled); + if (!d->enabled) { pci_device_reset(d); } } diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfe6fe618401..0d82727cc9dd 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -86,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return; } =20 @@ -111,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return ~0x0; } =20 --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576017; cv=none; d=zohomail.com; s=zohoarc; b=S3XC7aA1kNOmrmI8QakuttGzvE+jl6Vtp4oxiscWMUK5Uxk5RQF7Kz8qODAF1P9WnEMqBoGdYX5RSJrM1X+X76gqc3bAldSLAY1ApXBC+chyNnrBUim+vqHkEfrfhmh8yQAST6WQS6K8CWxdJXfOkpFzMqhnclfukRgqCplq68A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576017; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=g290Zd4uE3bSfCONNYpuRmBPHC8snIaGJ9qtpjxQu9cH+4Xkf7Qm/PeoY2DNEje6b1orLViV4bMJkrEyeYXvsdqC0jpxzuJVZE/glpFAY4MVj6VDxYHT1tc6x51ZVffTJ6Szz4cDi9ec4ir5iZ7bF+bP4l8e8zpVqdUZBY5Elqo= 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 1722576017539510.81675432923305; Thu, 1 Aug 2024 22:20:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkgp-0005TR-2i; Fri, 02 Aug 2024 01:18:55 -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 1sZkgm-0005KR-UM for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:53 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkgl-0006vV-FZ for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:52 -0400 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-70944dc8dc6so4147370a34.3 for ; Thu, 01 Aug 2024 22:18:51 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7b762e9c066sm521572a12.13.2024.08.01.22.18.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575930; x=1723180730; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=IN6lBtTPdbakMdBdAXr/NWwtyvTBOJuDSN0OjzgP8qSgAGHHgAie194JcX2AA/INXb k9+60PMM8IRsVaRt7qFSQRTBRylEEVITLe2pilYuhL8Kga71+PSKOvoYqG4sbuR1Ifvk KOIO9NACxq4enDaUk2gA24mqO3V2awvSwgutsn8u8bbCJr50BMCg4LTPLKlrlPBZn3Sy V7l5XBz8LGSXBc2sfJiNWVfaEum8doTqc1e7VZPCLoc/hqYy+KIO/vXpQ4W37TdQ0WoK GeRe3h9CaBA5uN0eylMUPyYrtjQi4FApgy1NFTkUFyV4G7G7G1ZB1HeAJXgCrXjMqVAh 8yNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575930; x=1723180730; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h49lGewxT9hFA+tlJrf36flRr26IrZVQVpZMqnu2U/A=; b=stAScgTKMD3idTG4gPDFplRPwCKuQODYGQlTZT/+4iPcTGm9uumTrxjTKVnIZnr+oh c7Ti7tlj0zjsDXQjdlwIEh4xikdc/2kC6QX/qDfiidarEP4pvd/4SFeAMLwe9RmJB/vT KXGkRP4FJIZEkEGEpD8brmUIFMxARlg3FeihcPflxpnzYEHu2s97EgOBQ/EB60EbYuzu V26k5gu+kaOa32/YZHC2PM+DrqOg+ABSIfOIpJk1uuAZQ7RTaQ3XSH1iolZ6BHI0sJZ+ Plv8PhROqGUPuwMrthvemllCmTgiLCY/FzzwLfwfJxa0ITkQ1fSocIo7anYVD8IqHuWB 3lFw== X-Gm-Message-State: AOJu0YxjbwREzBZct3fbRRSHvvgpjhbg43X3PFeSeCK/WSamZ9OKvD/q uIZhcRWo/2D9Biy1QL12/3xNpAYvMIU2Y/dGtELx1mGgk1CqJTMt8XojJ0A7EoI= X-Google-Smtp-Source: AGHT+IHDKDu8T0vVGl7yILcL8J/CQYzCUuX7OIAMkJVfgHOBbvbmbmP0cBIqfSyEpGuaOZTuWy89fQ== X-Received: by 2002:a05:6358:591e:b0:1af:3e47:4e3a with SMTP id e5c5f4694b2df-1af3e474f99mr186378255d.24.1722575930173; Thu, 01 Aug 2024 22:18:50 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:52 +0900 Subject: [PATCH for-9.2 v11 02/11] hw/ppc/spapr_pci: Do not create DT for disabled PCI device MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-2-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::336; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x336.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: 1722576019678116600 Disabled means it is a disabled SR-IOV VF or it is powered off, and hidden from the guest. Signed-off-by: Akihiko Odaki --- hw/ppc/spapr_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7cf9904c3546..f63182a03c41 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1296,6 +1296,10 @@ static void spapr_dt_pci_device_cb(PCIBus *bus, PCID= evice *pdev, return; } =20 + if (!pdev->enabled) { + return; + } + err =3D spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->offset); if (err < 0) { p->err =3D err; --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576034; cv=none; d=zohomail.com; s=zohoarc; b=JMrvYlZagkKTZ6OOBni1GAUXGCmBjvhWCypq9wKrMrlExSbjoOeoJ3VY8Xm63Aa7xgZxgqoa2SneLlUjCsrXL6k+tQ62TDUGm5SyWF2jODGVM5cKVQktY/JWWuoonBf84ozID6aI/4RiycaRT/zqa/xLpw8SaiqxbEqlLJLEsk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576034; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=UeUt60I5cbQp0W6nC16PQhg5QFJNd3lZb4qWaHPqr/cOzd2WMFtanK5BSbQH34qMdft1p2Q81ZC7jmS4FZWHceIK6YWo/ELUD4TayThvoBJMuZxUcIM1C8/i2Sgf16lmU+X5pz6agwpfIVQRBME3GyZPTNrekvc6PsakBwAx7Gg= 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 1722576034404947.4827440639609; Thu, 1 Aug 2024 22:20:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkgt-0005jz-4j; Fri, 02 Aug 2024 01:18:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZkgs-0005g3-4z for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:58 -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 1sZkgq-0006vx-L0 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:18:57 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fc566ac769so56953685ad.1 for ; Thu, 01 Aug 2024 22:18:55 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff5905ff25sm7926605ad.128.2024.08.01.22.18.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575935; x=1723180735; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=bdbBoHleMsw318Xq1ZLf8JTg4nDWUu7y5JX1wGKSgfQNYtW5DBHCwCFnxsYqV3DG58 pn7DlB/pAoKhqX+hOJ3PzsYt34KZXEsb474o3ULOXT8Ve47e4flNgUqb7KJ9MqwbBEwx FtrT1f22DeDhshmW5+RumbHJq4l5lT1LgLD40SgEjTcV0Mp5a4uGWLTjDp43CtWZWvGq 71vxDADeyix8NozQt6I0OLyZSpQtUa7kC03Pr+UQAdccgcd4PUuaLJ3Qw5DPgPMFOqQh qmpYPOvmsVWnCy9A9BhaGHznBt1IxIZZFL0NN34q8C/2DtwnbEK8vjr2EuIG5V0DDLBb Rn2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575935; x=1723180735; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LvYGkO0/34C91V8NXfef8guAibLAhiHYP0GgJQZDQZY=; b=QLA2B3cPoedlSGagKZFDo4RT8VjM59xIFGUcSlJE14Xcnn+lGf9hKjB9v2A3+WAHu6 nf7HnCZ6NtNe9qKuVdyxhJesIh34fHHi7sKZHjNmwKgPeaAIAG9qfCiFuEQWSWFC65Nl fqHOXlO9MMFYj5Rmelq0STmK6tPwwBsIULimvflFGrgAqnZzOzj/xJGt2bHiqI+W50fJ Tp94khhpBgUIKOw3y8RTMO0uEgWoELmURr+sSq72NSdJJ/8lm/iBCg2qe6e04Dz+iLau dz8ENuSEXcvs2VTFKnT81TorpIncwvy4eXbESmCoV7mESRQZupWgW5ogPCy0DZxvPsuT htXw== X-Gm-Message-State: AOJu0YwnK070D0Zm8OozxrslFjjszY4QzgIBqpN4wQzEJSsXAbI9kG0P /V7u9FZ31/QnzXGMOPXftJuPRAMYkedZwRN2PcAp8pMZ1DdzDnPMKN7w6F7EcfU= X-Google-Smtp-Source: AGHT+IFxNjyye6sX5p67ga/P1Kbtxl/HsZiznMyPqaaHc4q+TQnBbLbDhLHp/orJKV/cNkdL/TiZMQ== X-Received: by 2002:a17:902:d4c2:b0:1fb:93e6:94a3 with SMTP id d9443c01a7336-1ff57291d2fmr33708975ad.18.1722575934999; Thu, 01 Aug 2024 22:18:54 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:53 +0900 Subject: [PATCH for-9.2 v11 03/11] hw/ppc/spapr_pci: Do not reject VFs created after a PF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-3-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::633; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1722576035679116600 A PF may automatically create VFs and the PF may be function 0. Signed-off-by: Akihiko Odaki --- hw/ppc/spapr_pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f63182a03c41..ed4454bbf79e 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1573,7 +1573,9 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_h= andler, * hotplug, we do not allow functions to be hotplugged to a * slot that already has function 0 present */ - if (plugged_dev->hotplugged && bus->devices[PCI_DEVFN(slotnr, 0)] && + if (plugged_dev->hotplugged && + !pci_is_vf(pdev) && + bus->devices[PCI_DEVFN(slotnr, 0)] && PCI_FUNC(pdev->devfn) !=3D 0) { error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " additional functions can no longer be exposed to gues= t.", --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576030; cv=none; d=zohomail.com; s=zohoarc; b=Ce3+X9rUtUozpqcXBSJf243R04RxjGCk71cQxCooIjz4n78Ef7HB1hd5S19VN8PPj7RF+v8ulqnkDKTKVGBK7dezEmmwx0tAsfSJujUrJONYrPi1v0rMmAaJJXSbcuJ5/1+pNuwC91C47xhfKp1ZQfLBqqZzPdBNqPL7Zu0CD2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576030; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=TXekYIL3qgTFLubQFEv9uWQB9k9Jma21rTVF4/mrxRsblDgy7Ib39FnBlLtkJ31RnybCvMDrf6YPMeiuS652IaiQ1GI7n73FySNzH6Fkj10yuS9StK0Op9KYfyHieCFnCI/LGE86O/oj/DXdZ+fOH33mtN8fXI3pMSzX/SP+UZc= 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 1722576030797624.7330381935227; Thu, 1 Aug 2024 22:20:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkh8-00066M-3q; Fri, 02 Aug 2024 01:19:14 -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 1sZkgw-0005wb-Bz for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:04 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkgu-0006wK-Rn for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:02 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2cb5e0b020eso5920548a91.2 for ; Thu, 01 Aug 2024 22:19:00 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2cfdc42f9c7sm4305133a91.22.2024.08.01.22.18.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575939; x=1723180739; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=mDuILuDnZruFwPlWR9DU9g86U5pLZnkPjetohw8ryuCQFC3msiiCM1ddjIbA6iYSya uj3l4YV5kvlxLILdF/Kj6ST/diIfjbCXgOY1dEwQG404vlpl/Rt2to4mg/JDb7Q8EOf4 k/D3nSURxX5ldEdSWunD4WvtIWSlee6Qa+kZ21kkHFzCWUGTqYZoImfD6+7dlbZwl5zX 9BDOjclOG4a10DEOpGx2zNDqK5jE06YxRoeJzbnipTdPdBK7yPQ8Al/OJ8Npq1pK+7A/ Jh1kLNlFVKbKfzXsKys4KyzvhqA9au8Jk4BFWCB3nb+177lzrI+jkQu0Ibu9RIw3LPcD 6tCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575939; x=1723180739; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ja+2Rln8Aybt08irPb0En7wqcDpJy8xF+oHU5uY2BGc=; b=ffkPZFa9jbDrbhDmSepO0cmjoZO961MEd/tK5UEf1KyMRQ+vj3YZ4zfrGWKxq2+ZV+ K9D5UHKKo6+Nut5968ThBKKEPA8S+CSVbXejST3nXgYis27mgqO/5PsarlUCPlMsHfCh rTNr8ZglokvCN7rl1xia7Y2AiCy7KE4U6XUldbM1g/rMexuLS0hVbt2XDSkw3A0GPP6n yBP9BbBcvhzInhH+qARnoYqc2uRSyyRRT7NY+wv3zXlabrR9kMPWDmYdnhYKq15Kzhwm 5qvZkAcZXVQAKN3tbA4BS5mQEL5Y24DddudkUlUQhhB8TUK0NUynMB688s9dmKL872He ySFg== X-Gm-Message-State: AOJu0YzfgF+vqv2ZtOQ9dJMEfX4RpGLbA8lB0XeZ0hd9L9rgAJg6o0SB 1I4sC7WHWi8cRJk5RBb1Nn8GRT4vA8BHmcptMT3ShHmKh/8mX8F2Dl45MaeVCUo= X-Google-Smtp-Source: AGHT+IH9VAaArrXXja+1b8NQQHdLVygPxRE6N5AVhwzoVHVnk/cAEDuw5oambCMSR/YRjOfZQL+99g== X-Received: by 2002:a17:90b:33ca:b0:2ca:d1dc:47e2 with SMTP id 98e67ed59e1d1-2cff9559d93mr3094073a91.33.1722575939610; Thu, 01 Aug 2024 22:18:59 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:54 +0900 Subject: [PATCH for-9.2 v11 04/11] pcie_sriov: Do not manually unrealize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-4-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.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: 1722576031677116600 A device gets automatically unrealized when being unparented. Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index e9b23221d713..499becd5273f 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -204,11 +204,7 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - Error *err =3D NULL; PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)= ) { - error_reportf_err(err, "Failed to unplug: "); - } object_unparent(OBJECT(vf)); object_unref(OBJECT(vf)); } --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576030; cv=none; d=zohomail.com; s=zohoarc; b=OWUswbtxPxJARHdLSYVWLfvOhJtkHaUmJ2mJP0RMnLjkn0vHpFvLJNaUTfRVXx0TEc29Df4bLREkt7F1OgSi+h7V6soyEiQoj1DhPJc0cfqiEmjvIWPgrCknZsSe/2hGK3Yf8ouHRNvSojLGLPsxMsl+/ohDF/Tksr4qIscmzec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576030; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=nKXj5X/BczgRa2yN4SAw1wnoHnlntVvyi0KzzTQ+mC+u+P0uHwhEH6DTm1SQB3dwWQRfhqj9Vqm7obLywqSmJF4BDdYsnbAhmXzXMJkEVE1umNVZX5RNFrK91DgBcf6IPA2qBMnydmAqXcAX5oHgEl5/KU/woUurmW6y2jDWvEg= 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 1722576030727369.2076598061592; Thu, 1 Aug 2024 22:20:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhE-0006N2-1E; Fri, 02 Aug 2024 01:19:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZkh1-00062I-AU for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:07 -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 1sZkgz-0006x0-GJ for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:07 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fc66fc35f2so21050375ad.0 for ; Thu, 01 Aug 2024 22:19:05 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff592b3fa6sm7882055ad.304.2024.08.01.22.19.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575944; x=1723180744; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=2hLqfTkMfHk9wpSYQZPELJCKw2bQN3+RfPyDyZ/3NRgwi72VtQ/NPIILNyyNvVaJlF 5yK16J9+KggfeLDDHsWYfK8ma/aq/ldSQT/lhOc9qCDZwTVu1EoyBMTkHnLjY+WMPl4X zU3Oq0zi3BXNCSIc/Xp/q0W4QrbMzJ+mo7NVMbVYq+yACp7f3CDZdGUTKXszrdEMWtzT PLPwsJZZLd4Eik4cRvPC/grI5xpGnyen0cMFmBdo5574juJZhEzG/f3N9SqkSRKllmpJ Ozo3t30aTXmFtXp3JL1IuV3uvZyxpNxzdJAvnSknYEc9eg1mwWQIt0sM03Lbb0RQi3lL VfVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575944; x=1723180744; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jSFqxrJ6ZrVEUioZYkidDSjHzn1N+FgpqRFAmRsnAyg=; b=F5VEG05hKISCRtMLAYy2/7Exa0F9KxxIKyTXo7rVp/l5DVkdUtOS/jZcEDRFDAldYg MlhYNoTvN5C98ZcnYD/0Uao8lGvkrjPd13XVvx3d+e2ssz5fZQIEZcflPpyjt+1kEWng VRzKEXWdQkYXS/NYm5Iq4gNf/u6nCeB/LU/M+eVM+7ZKCo4z12np27s7DKESpHhMjjz9 45rWy1L9kZItXE48jlm+JYJ3aMfGyknmeZbL0VyEOMhbIrTx+QWKiSK81zLUy+xo4wBK nl3orALn4uaA3lqyaxelSsptXI+rvMeJWfhVaWB4Q/oe6XtP8RTwau2EwWFTOz8mqfsn g0Lw== X-Gm-Message-State: AOJu0Yyb6HdG1L2vgH71uBo1Ir7WOea2nCTyZsKrT4rG8rFrULedqkD0 wTyDBWNLNocUZKaDpfQiEXMKgvzz8ugUk0pHZ+hqf/EgnZDRukyAESep3oLIVJ0= X-Google-Smtp-Source: AGHT+IGNcfKW4ycWCfK1QqvjMu+IN6fvbb3OdW0kpoM8ZpmpTo7a3EfVi2XPD8LLh+ziFlY5tefuMw== X-Received: by 2002:a17:902:e74f:b0:1fd:9648:2d66 with SMTP id d9443c01a7336-1ff57bc62d8mr30313825ad.17.1722575944174; Thu, 01 Aug 2024 22:19:04 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:55 +0900 Subject: [PATCH for-9.2 v11 05/11] pcie_sriov: Ensure VF function number does not overflow MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-5-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::633; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722576031685116600 pci_new() aborts when creating a VF with a function number equals to or is greater than PCI_DEVFN_MAX. Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 8 +++++--- include/hw/pci/pcie_sriov.h | 5 +++-- hw/net/igb.c | 13 ++++++++++--- hw/nvme/ctrl.c | 24 ++++++++++++++++-------- hw/pci/pcie_sriov.c | 19 +++++++++++++++++-- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index a47aad0bfab0..ab2142807f79 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -52,9 +52,11 @@ setting up a BAR for a VF. ... =20 /* Add and initialize the SR/IOV capability */ - pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", - vf_devid, initial_vfs, total_vfs, - fun_offset, stride); + if (!pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", + vf_devid, initial_vfs, total_vfs, + fun_offset, stride, errp)) { + return; + } =20 /* Set up individual VF BARs (parameters as for normal BARs) */ pcie_sriov_pf_init_vf_bar( ... ) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 450cbef6c201..aa704e8f9d9f 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -27,10 +27,11 @@ typedef struct PCIESriovVF { uint16_t vf_number; /* Logical VF number of this function */ } PCIESriovVF; =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride); + uint16_t vf_offset, uint16_t vf_stride, + Error **errp); void pcie_sriov_pf_exit(PCIDevice *dev); =20 /* Set up a VF bar in the SR/IOV bar area */ diff --git a/hw/net/igb.c b/hw/net/igb.c index b92bba402e0d..b6ca2f1b8aee 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -446,9 +446,16 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error = **errp) =20 pcie_ari_init(pci_dev, 0x150); =20 - pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF, - IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, - IGB_VF_OFFSET, IGB_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, + TYPE_IGBVF, IGB_82576_VF_DEV_ID, + IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, + IGB_VF_OFFSET, IGB_VF_STRIDE, + errp)) { + pcie_cap_exit(pci_dev); + igb_cleanup_msix(s); + msi_uninit(pci_dev); + return; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, IGBVF_MMIO_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c6d4f61a47f9..e86ea2e7ce57 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8271,7 +8271,8 @@ out: return pow2ceil(bar_size); } =20 -static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et) +static bool nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et, + Error **errp) { uint16_t vf_dev_id =3D n->params.use_intel_id ? PCI_DEVICE_ID_INTEL_NVME : PCI_DEVICE_ID_REDHAT_N= VME; @@ -8280,12 +8281,17 @@ static void nvme_init_sriov(NvmeCtrl *n, PCIDevice = *pci_dev, uint16_t offset) le16_to_cpu(cap->vifrsm), NULL, NULL); =20 - pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, - n->params.sriov_max_vfs, n->params.sriov_max_vfs, - NVME_VF_OFFSET, NVME_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, + n->params.sriov_max_vfs, n->params.sriov_max_v= fs, + NVME_VF_OFFSET, NVME_VF_STRIDE, + errp)) { + return false; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, bar_size); + + return true; } =20 static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) @@ -8410,6 +8416,12 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) return false; } =20 + if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs && + !nvme_init_sriov(n, pci_dev, 0x120, errp)) { + msix_uninit(pci_dev, &n->bar0, &n->bar0); + return false; + } + nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); =20 pcie_cap_deverr_init(pci_dev); @@ -8439,10 +8451,6 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) nvme_init_pmr(n, pci_dev); } =20 - if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs) { - nvme_init_sriov(n, pci_dev, 0x120); - } - return true; } =20 diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 499becd5273f..f0bde0d3fc79 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -24,14 +24,27 @@ static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, uint16_t vf_num); static void unregister_vfs(PCIDevice *dev); =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride) + uint16_t vf_offset, uint16_t vf_stride, + Error **errp) { uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 + if (total_vfs) { + uint16_t ari_cap =3D pcie_find_capability(dev, PCI_EXT_CAP_ID_ARI); + uint16_t first_vf_devfn =3D dev->devfn + vf_offset; + uint16_t last_vf_devfn =3D first_vf_devfn + vf_stride * (total_vfs= - 1); + + if ((!ari_cap && PCI_SLOT(dev->devfn) !=3D PCI_SLOT(last_vf_devfn)= ) || + last_vf_devfn >=3D PCI_DEVFN_MAX) { + error_setg(errp, "VF function number overflows"); + return false; + } + } + pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; @@ -69,6 +82,8 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, 0x553); =20 qdev_prop_set_bit(&dev->qdev, "multifunction", true); + + return true; } =20 void pcie_sriov_pf_exit(PCIDevice *dev) --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576028; cv=none; d=zohomail.com; s=zohoarc; b=FQSxu5vh0hriI5wnsu43KlYkBhJ/0SBy68RwfGA2kGv5LnVLME/nA6dXfZeg3sOZUmMfpgKf49yE1ep6Zv63BzoPw1Bm92JzbHKOaN25IzgSw8yjeZA9AvfIOhqe6dZIwjBk/MHoQUPPDYHCOQojMbTBXf5onBXFXyXRxuAkbIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576028; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=FmRz4YFCHkCd/E+DSOTNB8+PPrphH+XnC9pzPKfLFbEuv/adXjMNmyt9MtDH4E5V9/qx3alJc3hWH0W3mlHbvnPSpZv8h0yrvvzatQUBhx0/UxJL9dVhN7w3p5Zx2wYWYbfRFJZuoh9KdDG+1UQ3XluF4KupZCcu1fkm6g+Zmgs= 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 1722576028395820.5318744034832; Thu, 1 Aug 2024 22:20:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhC-0006IC-Qx; Fri, 02 Aug 2024 01:19: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 1sZkh6-00066B-6d for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:14 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkh4-0006xL-82 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:11 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fd90c2fc68so61385695ad.1 for ; Thu, 01 Aug 2024 22:19:09 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff592b3fb1sm7918075ad.288.2024.08.01.22.19.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575949; x=1723180749; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=VXSgx06kk6PJpTNpDHEMX+hfoLp1H00pGO/Ecj1/G0hgqR2vLpqGjMC7uTEyXX+Pn7 ZYvzuVQThG+LpCK2kv5vW5qj57rDQQPlDSCu3sPUYAf/JijzOZWAi0DEiGt6iGz8cln7 xBP9zGWpMT09smJUwJcosfWpL5z0SsmOVnHHRNj4he0a6gkgLZ8iIb0168oBfEhDHWJJ h0yn6RAPwLXIMZh6FcM0C0nudygb37BzVTEUdUfXiMP3E4T5UQkv1SoQ6dATC/JWWx2J aimp9b1Mkamm5jx03AgxUIv08oXWuiKym7SqDOfTqdKcb+Th5pEKzz0UPfq5Un0G2x/Z 8H5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575949; x=1723180749; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=652Y8SFJE8RzVcm9zxKWZeyRoZ2qrpQB0WcZowAyd0Q=; b=FQnU/RsqP3cJE9UuOXQqbC+1WwJYdkRHjtKWIIAmtUK/1syYtbD/gwTTeuTyw8DfVw usFKQZhBqZJaOh4LKwACdnTSxE6K+sTjSaci8QgOmTleiXpxOk71MaSCf1+LSWGWkaku wKz0nTmzT6hFafMcoT7o4dlzCNDbZ8MlG0J/DhJ8c4RfSMRCIOZT6gY4diDHVSU3r5cd 0SRxxhzY0MA0kmOBK2R4rzfJ/5KzJO9ErKk+IFXD5g21seZzdY6fRlvIitQ1jn+jQwO7 vgMs6uIo5wR9Y6pGntTaTzFzIsXCWX3dIT/xOsg3d2RC1EpnbwCDQtPv1Es5iSR2r2Wk vpTA== X-Gm-Message-State: AOJu0YyIDbr06L+HRS7k2y+Ln+/A5WshFSJLiMiEFoS1Y5nkN7BaCinu L/gvDKMVuEPlb1clq9TjjnVji05Lju+kt95BRN0EikrAOIGPN9M//s/3AaOwNto= X-Google-Smtp-Source: AGHT+IGHw1iF64UWlPAXmAxItlJnpzCb9n7A7mZhlAXfgL2m4wdq/xWCMOOp2tvf7S4CJKiArayN1A== X-Received: by 2002:a17:902:ec8c:b0:1fb:3e52:8b5d with SMTP id d9443c01a7336-1ff5723e600mr28284215ad.1.1722575948800; Thu, 01 Aug 2024 22:19:08 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:56 +0900 Subject: [PATCH for-9.2 v11 06/11] pcie_sriov: Reuse SR-IOV VF device instances MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-6-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722576029707116600 Disable SR-IOV VF devices by reusing code to power down PCI devices instead of removing them when the guest requests to disable VFs. This allows to realize devices and report VF realization errors at PF realization time. Signed-off-by: Akihiko Odaki --- include/hw/pci/pci.h | 5 --- include/hw/pci/pci_device.h | 15 +++++++ include/hw/pci/pcie_sriov.h | 1 - hw/pci/pci.c | 2 +- hw/pci/pcie_sriov.c | 95 +++++++++++++++++++----------------------= ---- 5 files changed, 56 insertions(+), 62 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index fe04b4fafd04..14a869eeaa71 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -680,9 +680,4 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); void pci_set_enabled(PCIDevice *pci_dev, bool state); =20 -static inline void pci_set_power(PCIDevice *pci_dev, bool state) -{ - pci_set_enabled(pci_dev, state); -} - #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index f38fb3111954..1ff3ce94e25b 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -212,6 +212,21 @@ static inline uint16_t pci_get_bdf(PCIDevice *dev) return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn); } =20 +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + /* + * Don't change the enabled state of VFs when powering on/off the devi= ce. + * + * When powering on, VFs must not be enabled immediately but they must + * wait until the guest configures SR-IOV. + * When powering off, their corresponding PFs will be reset and disable + * VFs. + */ + if (!pci_is_vf(pci_dev)) { + pci_set_enabled(pci_dev, state); + } +} + uint16_t pci_requester_id(PCIDevice *dev); =20 /* DMA access functions */ diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index aa704e8f9d9f..70649236c18a 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -18,7 +18,6 @@ typedef struct PCIESriovPF { uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ - const char *vfname; /* Reference to the device type used for the VFs */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b532888e8f6c..5c0050e1786a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2895,7 +2895,7 @@ void pci_set_enabled(PCIDevice *d, bool state) memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_MASTER) && d->enabled); - if (!d->enabled) { + if (d->qdev.realized) { pci_device_reset(d); } } diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index f0bde0d3fc79..faadb0d2ea85 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,9 +20,16 @@ #include "qapi/error.h" #include "trace.h" =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, - const char *name, uint16_t vf_num); -static void unregister_vfs(PCIDevice *dev); +static void unparent_vfs(PCIDevice *dev, uint16_t total_vfs) +{ + for (uint16_t i =3D 0; i < total_vfs; i++) { + PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; + object_unparent(OBJECT(vf)); + object_unref(OBJECT(vf)); + } + g_free(dev->exp.sriov_pf.vf); + dev->exp.sriov_pf.vf =3D NULL; +} =20 bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, @@ -30,6 +37,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, uint16_t vf_offset, uint16_t vf_stride, Error **errp) { + BusState *bus =3D qdev_get_parent_bus(&dev->qdev); + int32_t devfn =3D dev->devfn + vf_offset; uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 @@ -49,7 +58,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; dev->exp.sriov_pf.num_vfs =3D 0; - dev->exp.sriov_pf.vfname =3D g_strdup(vfname); dev->exp.sriov_pf.vf =3D NULL; =20 pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -83,14 +91,34 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, =20 qdev_prop_set_bit(&dev->qdev, "multifunction", true); =20 + dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, total_vfs); + + for (uint16_t i =3D 0; i < total_vfs; i++) { + PCIDevice *vf =3D pci_new(devfn, vfname); + vf->exp.sriov_vf.pf =3D dev; + vf->exp.sriov_vf.vf_number =3D i; + + if (!qdev_realize(&vf->qdev, bus, errp)) { + unparent_vfs(dev, i); + return false; + } + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(vf->config, 0xffff); + pci_config_set_device_id(vf->config, 0xffff); + + dev->exp.sriov_pf.vf[i] =3D vf; + devfn +=3D vf_stride; + } + return true; } =20 void pcie_sriov_pf_exit(PCIDevice *dev) { - unregister_vfs(dev); - g_free((char *)dev->exp.sriov_pf.vfname); - dev->exp.sriov_pf.vfname =3D NULL; + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + + unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); } =20 void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, @@ -156,38 +184,11 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int r= egion_num, } } =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, - uint16_t vf_num) -{ - PCIDevice *dev =3D pci_new(devfn, name); - dev->exp.sriov_vf.pf =3D pf; - dev->exp.sriov_vf.vf_number =3D vf_num; - PCIBus *bus =3D pci_get_bus(pf); - Error *local_err =3D NULL; - - qdev_realize(&dev->qdev, &bus->qbus, &local_err); - if (local_err) { - error_report_err(local_err); - return NULL; - } - - /* set vid/did according to sr/iov spec - they are not used */ - pci_config_set_vendor_id(dev->config, 0xffff); - pci_config_set_device_id(dev->config, 0xffff); - - return dev; -} - static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; uint16_t i; uint16_t sriov_cap =3D dev->exp.sriov_cap; - uint16_t vf_offset =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_OFFSET); - uint16_t vf_stride =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_STRIDE); - int32_t devfn =3D dev->devfn + vf_offset; =20 assert(sriov_cap > 0); num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); @@ -195,18 +196,10 @@ static void register_vfs(PCIDevice *dev) return; } =20 - dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, num_vfs); - trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - dev->exp.sriov_pf.vf[i] =3D register_vf(dev, devfn, - dev->exp.sriov_pf.vfname, i); - if (!dev->exp.sriov_pf.vf[i]) { - num_vfs =3D i; - break; - } - devfn +=3D vf_stride; + pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } dev->exp.sriov_pf.num_vfs =3D num_vfs; } @@ -219,12 +212,8 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - object_unparent(OBJECT(vf)); - object_unref(OBJECT(vf)); + pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - g_free(dev->exp.sriov_pf.vf); - dev->exp.sriov_pf.vf =3D NULL; dev->exp.sriov_pf.num_vfs =3D 0; } =20 @@ -246,14 +235,10 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t= address, PCI_FUNC(dev->devfn), off, val, len); =20 if (range_covers_byte(off, len, PCI_SRIOV_CTRL)) { - if (dev->exp.sriov_pf.num_vfs) { - if (!(val & PCI_SRIOV_CTRL_VFE)) { - unregister_vfs(dev); - } + if (val & PCI_SRIOV_CTRL_VFE) { + register_vfs(dev); } else { - if (val & PCI_SRIOV_CTRL_VFE) { - register_vfs(dev); - } + unregister_vfs(dev); } } } --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722575989; cv=none; d=zohomail.com; s=zohoarc; b=Se1FNUl+/4Jn9L2cO9LVaWnGOBN+CNyoy+wNJJwGy/Hi9ie9t0mYTuxyGLqaKMK1MYZC7Gt6JAEoisbbDWYbTYYM/DE2Dc7PCfPacBRjSSsS/2clRU+9ZOiZFxXfH6gRBTG4WeSlereFtTHQN+eF1K/GIgcjeAr0S2WEi7dFATg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722575989; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=RivuUljtMPV8ZchTaQzP2P8zqWir3D7ix3ow8Fwv2u4sL2dckQNQ5EjFai8Zpq+S/g7qTsLSyMs19taCLlgIN/lepSHU+Ccoj3Dea5DylIe5nbbgFZLB66tELDfC4CE4pTRZg0Y0AvLo2XnhtQ/T3tJMKjUQ5VR4ceRUAnDbL0k= 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 1722575989630990.0502492703826; Thu, 1 Aug 2024 22:19:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhG-0006Vn-Un; Fri, 02 Aug 2024 01:19:23 -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 1sZkhC-0006Hy-7u for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:18 -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 1sZkh9-0006xj-UY for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:17 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7a92098ec97so5273325a12.2 for ; Thu, 01 Aug 2024 22:19:14 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58f29ef4sm8109515ad.14.2024.08.01.22.19.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575953; x=1723180753; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=v9GJmYtbxCWefaWC2L7/8wddF/dp/0rodPDMzRG3tGNOLp8YwTrHnJmhdI7JKV2OhU +wG0gUIlUhFG7OOtUBb5M8Vv4nBfXuwFSS33Au7mjtzar1admAROG9jVD/bZUPO2u4hR 0OjNVxTcdQJuLE8iiaveb+NjkKI3kvu3CYYjYGul3uxjhiYtRiXauXMs/3W+SegXjgDi sAh8QXzHl9w6apc2UIQfWvfEDRGFcHgzsMF5Kz2icyvZIb42Z4gydqfkJ6RnL0+qCSvQ 1t3EZ8eL/q3xvWjcckoL8HOUlWpgLc1Uq5HQSMFQiwIKVXjGTOT19Jj9F6lkG/o90eaV uGoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575953; x=1723180753; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4tfsLBSp5P9Enjc3prc0IqWrh95La08LAkdzlIXsS/A=; b=nqExW538ugAr4NQp0MdUWMRri10pwqVTsLgrQVtZvUj6TglEzjqWslGJdL/NXBeOWL Wz/Wz2kLiK6d2yoeoA8D6ErmL6I+nGP0yresdTBj2CjeWPpofl3uy6mBvBvLnswZJADN ijzzrBrObpS2hf2wnob1+9ywOpCLP2EAwpGlCXTDI4sfOJrm413nLk1ZpVb7aNajGBAv qUjzO5d59v+nlhaYy5zrM6TraPRnP9BIbHBckjZL1KUXHCNrh/GmUCgMW8iDv/srCdax iH4TNGc4BfuvdSfcRmDRwEeg+D9rVhSM1lFUj+AhJ6hJ60BYS1PscMcbmN5aQIEKfWM6 yyNQ== X-Gm-Message-State: AOJu0YzcBAObbKvmmdjk40T1qeaKW9xdt4TsP2vY6M4ozULSqEsl7RvQ B5pgSDDOwtXad0e4OCDIWOJD3fQU3n+ohAKntN1zKqx9v4V3zTn/RFWtVLwfzi8= X-Google-Smtp-Source: AGHT+IEgLbjkcKK1pXPBOTyntKiNaAfmf0I/+XpSSlls+hhdaM4j5NVopqOjklZcs7xNQWmUN/Krsg== X-Received: by 2002:a05:6a21:a4c1:b0:1c4:dae8:c72f with SMTP id adf61e73a8af0-1c699559d86mr2726399637.19.1722575953539; Thu, 01 Aug 2024 22:19:13 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:57 +0900 Subject: [PATCH for-9.2 v11 07/11] pcie_sriov: Release VFs failed to realize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-7-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::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: 1722575991765116600 Release VFs failed to realize just as we do in unregister_vfs(). Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization = (SR/IOV)") Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index faadb0d2ea85..9bd7f8acc3f4 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -99,6 +99,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, vf->exp.sriov_vf.vf_number =3D i; =20 if (!qdev_realize(&vf->qdev, bus, errp)) { + object_unparent(OBJECT(vf)); + object_unref(vf); unparent_vfs(dev, i); return false; } --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722575999; cv=none; d=zohomail.com; s=zohoarc; b=N/VwqwItL0wzodN0TBwFQevTlvJXQ5QbIOjmy6k+iQmfSdLQaJPuHfV1mdNdIh0bUSQivCh6XjfPHd0QnuQTi6aYNcIjrw1RQS2HW2jBNgdmmcH6oDheCVVvwLebje+kaFBCfcHGPSvO9Lg6OW20hd3obgw9KXFqmK4ZmKuqQbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722575999; 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=aluMVAZ460okBBrhiNZK+G3gMubw4xx6sc5IE7bE8wg=; b=afeYOMLEfIRj1U9n/gOKDAU4r30By5p5R8k8072OlDDnpXptpC885fT/pNUyAh+sqUbiL15tWyLggU03zM2YlpfBoS9cafHR4AVdG+7hqkejNyuGvxZV0NHciC1Td8pd9E713hC9tmc4tclaexvI/PI/Uf1bDS6V6RbHw2vnKqU= 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 1722575999240441.65124964950667; Thu, 1 Aug 2024 22:19:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhJ-0006mV-W3; Fri, 02 Aug 2024 01:19:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZkhF-0006UB-Nj for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:21 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkhE-0006yW-3V for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:21 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ff3d5c6e9eso31242405ad.1 for ; Thu, 01 Aug 2024 22:19:19 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff5905fed6sm8026915ad.166.2024.08.01.22.19.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575959; x=1723180759; 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=aluMVAZ460okBBrhiNZK+G3gMubw4xx6sc5IE7bE8wg=; b=nNS3B5xxwX2q8J6epkq5ovHNWAxpFY2HVGTror/OfTaFUTJ2aRZOfjFZJXBzwvPhbk 8Y4duy5PEY4B8U3R+K5gZ6vQAZmOdut2wBZWLHD4yCYZn0OnBoAMdT3RMdZqs4faIlZ4 WMTsoKohRUNg+nmNVgpD55LE4CJ3pUlWR9RNaZ/CGfBtpH1A2tGim58PaYtFHz3tITE9 n3CLtZoylJ2wyWXuVWS/phjbYAW/e3Yqb8ZcAlIpOzuZTH0IFtCpyM258xPp9pDChH1T ZLyb26phgi+GxEIKk0hdvIDSwDp/6nBzyme69LoysxRjZqjQCO+/K4K6JHvm0J7PDEt/ I3KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575959; x=1723180759; 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=aluMVAZ460okBBrhiNZK+G3gMubw4xx6sc5IE7bE8wg=; b=T9r1t8JupyCnJE/Sm+Lj+JRWOTl1Eh0Dyp/+usD212gvnxoZtPVWPdB/0BLJzbtcbm cYke60JmoRYICt82ZkC6Maf05MsrJguij602E5/3H6sJSoYinu2t+kCUPwZO1VBzuTCR G2kbvT9gQ8X8enlqMG5g1to6P+G8WjJXVweWQHRrhZFurBk3Mv4X/OVipadKHT1GaKWd aIs5qim+URV+m7U+yEBOijZ1Ji/hLF6dkxkpj2nIHGqnhuZhJg6Aw8a2E6pWD+LDIpY8 VuaaKUcUxKcBf9L3kggRbFxl9QnBoBhG+xytt+HQ6VPEY3T88I0wgExtBIBzgaFYfcco G8CQ== X-Gm-Message-State: AOJu0YyJHa4WMAyJlxFGs4CCpxnycdd/3oJIxiLsFwB2Lekohx4ac7WX 8jW4CKGZ5XbnIfwbI8STF81KiZxO5BRrti0QMluwFTb0x914Od3RNAUFPYu5YRY= X-Google-Smtp-Source: AGHT+IHnroXEck36nOqaJBtXM54qQjGI0SfIKvhkC+ja7DByaoTbPItDVLfOki7Y2WR1IlKSw/cnBA== X-Received: by 2002:a17:903:686:b0:1fd:9c2d:2f1b with SMTP id d9443c01a7336-1ff574caff8mr24387615ad.52.1722575958843; Thu, 01 Aug 2024 22:19:18 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:58 +0900 Subject: [PATCH for-9.2 v11 08/11] pcie_sriov: Remove num_vfs from PCIESriovPF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-8-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.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: 1722575999584116600 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 | 28 ++++++++++++++++++++-------- hw/pci/trace-events | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 70649236c18a..5148c5b77dd1 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -16,7 +16,6 @@ #include "hw/pci/pci.h" =20 typedef struct PCIESriovPF { - uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 9bd7f8acc3f4..fae6acea4acb 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -57,7 +57,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; - dev->exp.sriov_pf.num_vfs =3D 0; dev->exp.sriov_pf.vf =3D NULL; =20 pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -186,6 +185,12 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int re= gion_num, } } =20 +static void clear_ctrl_vfe(PCIDevice *dev) +{ + uint8_t *ctrl =3D dev->config + dev->exp.sriov_cap + PCI_SRIOV_CTRL; + pci_set_word(ctrl, pci_get_word(ctrl) & ~PCI_SRIOV_CTRL_VFE); +} + static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; @@ -195,6 +200,7 @@ static void register_vfs(PCIDevice *dev) 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)) { + clear_ctrl_vfe(dev); return; } =20 @@ -203,20 +209,18 @@ static void register_vfs(PCIDevice *dev) 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; } =20 static void unregister_vfs(PCIDevice *dev) { - uint16_t num_vfs =3D dev->exp.sriov_pf.num_vfs; uint16_t i; + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; =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; } =20 void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, @@ -242,6 +246,9 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t a= ddress, } else { unregister_vfs(dev); } + } else if (range_covers_byte(off, len, PCI_SRIOV_NUM_VF)) { + clear_ctrl_vfe(dev); + unregister_vfs(dev); } } =20 @@ -304,7 +311,7 @@ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) { assert(!pci_is_vf(dev)); - if (n < dev->exp.sriov_pf.num_vfs) { + if (n < pcie_sriov_num_vfs(dev)) { return dev->exp.sriov_pf.vf[n]; } return NULL; @@ -312,5 +319,10 @@ PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, = int n) =20 uint16_t pcie_sriov_num_vfs(PCIDevice *dev) { - return dev->exp.sriov_pf.num_vfs; + uint16_t sriov_cap =3D dev->exp.sriov_cap; + uint8_t *cfg =3D dev->config + sriov_cap; + + return sriov_cap && + (pci_get_word(cfg + PCI_SRIOV_CTRL) & PCI_SRIOV_CTRL_VFE) ? + pci_get_word(cfg + PCI_SRIOV_NUM_VF) : 0; } diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 19643aa8c6b0..e98f575a9d19 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -14,7 +14,7 @@ msix_write_config(char *name, bool enabled, bool masked) = "dev %s enabled %d mask =20 # hw/pci/pcie_sriov.c sriov_register_vfs(const char *name, int slot, int function, int num_vfs) = "%s %02x:%x: creating %d vf devs" -sriov_unregister_vfs(const char *name, int slot, int function, int num_vfs= ) "%s %02x:%x: Unregistering %d vf devs" +sriov_unregister_vfs(const char *name, int slot, int function) "%s %02x:%x= : Unregistering vf devs" sriov_config_write(const char *name, int slot, int fun, uint32_t offset, u= int32_t val, uint32_t len) "%s %02x:%x: sriov offset 0x%x val 0x%x len %d" =20 # pcie.c --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576019; cv=none; d=zohomail.com; s=zohoarc; b=kSpAOxRG6qcf511TWIXV+YrbkdpFo131NHVChtFESzUZHnUER1NcQ+w0W8kaY/eDpMoQXdCtg+o2ZxmHASKNLyvXFgj3NsS/J1BHw8yabPAxKDClo6Iu/8IELlkjLg0AUjkCxS3HxLqBFuy2bQAH2GkpY33oqpz8cyfMbVpQvJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576019; 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=QvhT8BOO7ycm9PXUc+0g8ECZRNCUjwgD+8aN9b1a3cI=; b=ZfJr/kRWgCAs1CaMIa4C9SWSTztvelzFBMFVeZh7xXkl4kX8cOSYsHB58cb41oqf0+0pXcd0AbqVz8T51JKZ3Sp0umMNhF9Vrc/+mx/LdxY1Ow5gtuDH5FpUeHYam8VeEfFbMDLCeTduUwHZipbWl4oK2VKX8/6nEq2tOGfzHB0= 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 1722576019832345.9139461757103; Thu, 1 Aug 2024 22:20:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhL-0006vy-RE; Fri, 02 Aug 2024 01:19: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 1sZkhK-0006qV-O6 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:26 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkhJ-0006zH-5p for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:26 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fd90c2fc68so61387515ad.1 for ; Thu, 01 Aug 2024 22:19:24 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff625da1d5sm527955ad.218.2024.08.01.22.19.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575964; x=1723180764; 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=QvhT8BOO7ycm9PXUc+0g8ECZRNCUjwgD+8aN9b1a3cI=; b=C66AhT+HuiTGGvtth1hraTv8ag+EQldzAelktYLkr7NoZaR7xV3X8RshLpf3o0IGt0 0aiO56hjCovt/EILeAxdd30gdZ28O/ZLuafFyXdwyVeVm3gJS0a0BdkIcDALMUufHzCc uCkKhVmXGD4iju2v3m6FWeCBvTWu0I1LLAsFXbMAvuXXc7w9oh1dWSvqy/Axn8KT9Wri PhdAYI5vAw66N14LTtERTTn0ZMAd5j0htWgNK375HYzc/o5PSOlK4b4FhK3sOLFMG7o8 CNPTGtQ0yWJbk9EyVwJdoLSzfXflPURoarcT00qPI75DIgYaudK8SrJucoFE0C7XFN74 VM4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575964; x=1723180764; 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=QvhT8BOO7ycm9PXUc+0g8ECZRNCUjwgD+8aN9b1a3cI=; b=XzFXiWxFDWrbUIGafaXGXvSdYt77hzIGCoPc+m3e3nQw2zA/zZR6/ae2BWtkmSY+iP cbtdxabUgRvO46kQydxCmT782DrHCUlloou02EATJCaJ9RubV+h14tgzlgITx/awZjVk EJ11Oakm9oL6Sm3ElHuimj7BqhC6co48wYvg3vdto5pCB0z/hxJyJybzsGDYRRDpY005 hpmqbtkxpr0xkFEqwikiLdSQr8kKsjsB7pz2BCyAQvYhQ6TWCdy/eV1fvqmXxt5OT0uo q7AML0Jo3LIQ/E83ERGkJpnj/6j0rmJRSbo17Rw5XepqjkJh77ItaH0ouQqA44AuAUA2 yRVA== X-Gm-Message-State: AOJu0YxOca+cXuaRBabafcDdeH6F9Q9R264DEYu1uLBiNPSnkb2IoZOu llb7G+/gqWjb1/hjhSlETr+K2UhtCl/8laDKlUEOGAcUhsvHUWSNTifLLFP6jwM= X-Google-Smtp-Source: AGHT+IGfatLAPXN+tl/yGTckKb1+Qt6L/Z89kMZ1QxC828hwl8mwfpNTAw3d9tTQ+xRihz/TG/iepg== X-Received: by 2002:a17:902:f551:b0:1fb:389b:1054 with SMTP id d9443c01a7336-1ff5745b7e6mr29754905ad.52.1722575964002; Thu, 01 Aug 2024 22:19:24 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:59 +0900 Subject: [PATCH for-9.2 v11 09/11] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-9-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.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: 1722576021679116600 pcie_sriov doesn't have code to restore its state after migration, but igb, which uses pcie_sriov, naively claimed its migration capability. Add code to register VFs after migration and fix igb migration. Fixes: 3a977deebe6b ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 7 +++++++ hw/pci/pcie_sriov.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 5148c5b77dd1..c5d2d318d330 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_= t opt_sup_pgsize); void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, uint32_t val, int len); =20 +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5c0050e1786a..4c7be5295110 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int ver= sion_id) return !pci_is_express((PCIDevice *)opaque); } =20 +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device =3D { .name =3D "PCIDevice", .version_id =3D 2, .minimum_version_id =3D 1, + .post_load =3D pci_post_load, .fields =3D (const VMStateField[]) { VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice), VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index fae6acea4acb..56523ab4e833 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -252,6 +252,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t = address, } } =20 +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + =20 /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev) --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576042; cv=none; d=zohomail.com; s=zohoarc; b=kgOpqnAxYizF27au8dw09sm80yXm7+mxQJPWOMMCKoVoBHoULqaBpS1MY679K08TlUJOQj/5QVF+oC6Ks5Ues7PyPGSV3EGXWUX/QVd/AZ3LnDwqn+CpMyREiBLK7pyGFZ1AYm/6N2UOuRuEvnkRGP6V+7GVfdFhRp9Vn9crNBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576042; 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=+i3x/GdHilVxxuP70OvKDjvZUNatxzQ32Tx86w/1Hns=; b=XpVOMdYSaY8Ke3YK7+JLlobawhD7/oXuNhh/HOyhGKN02QJxgE2I1gmnYa6wcDYRn32vbE0WIoIssoHAtn2esAn7yAhXjU3Uj2bb0shgHrLwUBGg9UjFY6NjcCskPGae+sEHYUcsiGkyT0Kvmtv7NrmiD44q3SS2YlGpqQh33YU= 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 1722576042397583.1829021396563; Thu, 1 Aug 2024 22:20:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhS-0007Vg-K1; Fri, 02 Aug 2024 01:19:34 -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 1sZkhQ-0007KF-4A for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:32 -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 1sZkhO-000702-Ez for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:31 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc566ac769so56957045ad.1 for ; Thu, 01 Aug 2024 22:19:30 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58f5714asm8129145ad.85.2024.08.01.22.19.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575969; x=1723180769; 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=+i3x/GdHilVxxuP70OvKDjvZUNatxzQ32Tx86w/1Hns=; b=aPk+CRZy6BkQZ/H6Ho0z/3Qx9odW5jiPw5XGHGsiZx5Z5cvsb/V9IwrjJCuBNKCuaq pa5URqYM06vwdenQzfzgBe7pyu9zV9LdcrAwT4BlOEajtTg8LYa8ZqmCoxUwt8ka9pKb SUSUmkoV1Mh2MkMhXJliZh78P9hMi8mlXmjXaJhLMhyJCTthvdGn21OP55vVvRts1eWV JBJwxJJC/bdD0UEeAQmk+jV8eY2uvJczOoopQZSd/DsC6HLdqh9GVna2Upw63AVfergr 0LlNisSik/HQr1RDYe+8xLbSOpVx9GDrudmYZxH2dx1XJJBxs4dOEa9c5Aai3Lz7Ofem Hy7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575969; x=1723180769; 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=+i3x/GdHilVxxuP70OvKDjvZUNatxzQ32Tx86w/1Hns=; b=ef/vDUDIGsgnfTQZN2yrzgjcru9Nl5wdNBePaliieFlhUcLyU189EujrsbLIKSGS29 xxKqhgn09gFsGza546yNE64m4iyImvX6O40uyM2x5rsst3AwKoOZBiM2j6SIY917KVy3 q7PXmFiEVNtROvILJ1lXSPAzg6lbLPjFVgse94sGzUoHaAT35VzLL3ag62yc5VMHSqiT kg5ILdfgoOOZEVJAuhNkcWQH9hcyYfwNkUmPXK/vmhWwDLJScXgA+D1mOI3ea3XozBiw zuAbj6qGR3AQARaWZqA5CEsd1E9Joa53Xi1VVzHt/ZG0XCJSaFenCcEcK2IYuq+HjLRT IngQ== X-Gm-Message-State: AOJu0YwdsgpXtZuljbN+QaRZqvYJ1Ai4AnYf+cUKDjfKq4NSmenKKRES uav7HpGyd3JjpKM9gdrOILgOubZX9c6B+TvPxuCh5OPjzWS6lutMyvLDBxFD9Dc= X-Google-Smtp-Source: AGHT+IHFklOY1ndd84v8L9jdyUXComkgpEIr0jwG8rI/UHTP4iWaIrO8bceen1mtvc3C7Z7ZGSf0Gw== X-Received: by 2002:a17:902:fa07:b0:1fd:5ed7:19e4 with SMTP id d9443c01a7336-1ff574cf70dmr21303235ad.60.1722575969113; Thu, 01 Aug 2024 22:19:29 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:18:00 +0900 Subject: [PATCH for-9.2 v11 10/11] hw/pci: Use -1 as the default value for rombar MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-10-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1722576043751116600 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) will be invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster --- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 2 +- hw/vfio/pci.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 1ff3ce94e25b..8fa845beee5e 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -148,7 +148,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + int32_t rom_bar; =20 /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4c7be5295110..d2eaf0c51dde 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -71,7 +71,7 @@ static Property pci_props[] =3D { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2407720c3530..dc53837eac73 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size =3D cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset =3D vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev =3D DEVICE(vdev); char *name; int fd =3D vdev->vbasedev.fd; =20 @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } =20 if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar > 0) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " positive value for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues", --=20 2.45.2 From nobody Sun Nov 24 14:26:12 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=1722576051; cv=none; d=zohomail.com; s=zohoarc; b=FHyHPkr7S3kbYgbdFVbTj3bqGBCAbYSe6Ze62VdiHFfCIsOjhv/ariIP+fiGjMnkuOe0o0U+8nftn1CFT1VpfOHxZKOvXf3nfhxofAziI1FEnK4QTExH5968WvJg9wBA2RwN9F9jIMImq1urXwmevm3sHq/tiiWh1eVnZ89Aok8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722576051; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=KHXf1+6elO3bdN2b2GXQ1ar5Fbf0ZfcPaSbqTxv8XK5rrYBmmde4zlKda7gAl8YHXsZ7Y58IahUChXYW6UhGfLNvfZtMq+gWmN5n03aMDRga6KC0Ew6QCwQlLVF44tf7VpdghhgWqupSlbipVU/2Ti9o3vX4w24kYbBz5ihDHzg= 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 1722576051420568.705238171483; Thu, 1 Aug 2024 22:20:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhX-0007u4-SG; Fri, 02 Aug 2024 01:19: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 1sZkhV-0007kg-Lj for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:37 -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 1sZkhT-00070Z-Jt for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:37 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1fd65aaac27so20889545ad.1 for ; Thu, 01 Aug 2024 22:19:35 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff58f62e7asm8094375ad.115.2024.08.01.22.19.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575974; x=1723180774; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=XtZ1g8JqBzX0FYFoyj4Nz6/zHzalerpjrEbyC1aOwTZLhYU2zK5WtTK45CC4+GjdwP fUg8uDhhz2Z5tfozJ/ydXRtXPfn0dfugV24IjQVWVGmhuuSXmp31vwDRApolu7HgGXMM tFqCttFgXQXOFnRD8dbQwu7hUW7dpI+cP/NNHfZ9ZZPj+7QsCbEx1b2VmUUFhi727ao+ UChIIQKMM+WJOTfGUG4w6HGzHwMDwUOWDUyONuDg/4F+7uxlhN1seSi3wl8HxzAzoSU7 s5FOj2pU/N+0kjGDM8a7qM9v/I7f/zYOX/J//kvX8y3dN+mOY24CHpj+fa6ldkPVOema 9shw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575974; x=1723180774; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0RYDgLdr7HQ010CTBqvRUSBgNA/oE/wNQ3ZQWiob4V0=; b=DvWVhw9MbNrd1uhYFwDB/XusnnYdTGY247PdHuvdksCmSJMYY6zf1A3Ja3pwiLfwWp ixXkRL68r9S2/gYFauVnBmjH8mgaKtJQQlG377VSEi90zdbcWnL8xiRVBxnRM604rolL EiIxPCuXa+YhGqpkULpnxbcDurbmrTBLpcyJtwTDqWdlfwvcfa+D7Iq560K7hI4xDinF y+7gpruW9pknP6avqItb+pJdXRgj34USfX956uGaARMIDjeWS/LaBZxsJJmTCUMqSL+f rMewbTZSFscJmqEQvIVUqLMZ7HqJNppHg7lz+JYPUMvQykJnxJxvSBXSJHOTpskCH/U6 EPKg== X-Gm-Message-State: AOJu0YzkC5mygTqge2utVZhIaAuOXqQ0teBoyshdFdp+C4uBOlTYEFog BwJCzR98ykNuWTexsFLH/3mbL/RAYt/dMvq3nfbBdnw1YdHl3QI9f5yDRZMhBMU= X-Google-Smtp-Source: AGHT+IEDYHPvHBQL+TTvTJTSvHIjVBsC1UHTTOyjd66+dQwL02gyRtvLyK4DiPHH7qZRais7zdk0wg== X-Received: by 2002:a17:902:e5cb:b0:1fb:6ea1:6e with SMTP id d9443c01a7336-1ff5240bc5fmr50314765ad.9.1722575973716; Thu, 01 Aug 2024 22:19:33 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:18:01 +0900 Subject: [PATCH for-9.2 v11 11/11] hw/qdev: Remove opts member MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240802-reuse-v11-11-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722576051788116600 It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster --- include/hw/qdev-core.h | 4 ---- hw/core/qdev.c | 1 - system/qdev-monitor.c | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 77bfcbdf732a..a3757e6769f8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -237,10 +237,6 @@ struct DeviceState { * @pending_deleted_expires_ms: optional timeout for deletion events */ int64_t pending_deleted_expires_ms; - /** - * @opts: QDict of options for the device - */ - QDict *opts; /** * @hotplugged: was device added after PHASE_MACHINE_READY? */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f3a996f57dee..2fc84699d432 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -706,7 +706,6 @@ static void device_finalize(Object *obj) dev->canonical_path =3D NULL; } =20 - qobject_unref(dev->opts); g_free(dev->id); } =20 diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 6af6ef7d667f..3551989d5153 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -624,6 +624,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *op= ts, char *id; DeviceState *dev =3D NULL; BusState *bus =3D NULL; + QDict *properties; =20 driver =3D qdict_get_try_str(opts, "driver"); if (!driver) { @@ -705,13 +706,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *= opts, } =20 /* set properties */ - dev->opts =3D qdict_clone_shallow(opts); - qdict_del(dev->opts, "driver"); - qdict_del(dev->opts, "bus"); - qdict_del(dev->opts, "id"); + properties =3D qdict_clone_shallow(opts); + qdict_del(properties, "driver"); + qdict_del(properties, "bus"); + qdict_del(properties, "id"); =20 - object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_js= on, + object_set_properties_from_keyval(&dev->parent_obj, properties, from_j= son, errp); + qobject_unref(properties); if (*errp) { goto err_del_dev; } --=20 2.45.2