From nobody Sat Apr 20 13:26:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1678857273; cv=none; d=zohomail.com; s=zohoarc; b=lv04EuW5EESUgTWO6W8OuvcN/YtYN72ric0XeIGThFW0z4I2z+6/xnupZTl98tsaqU1rsnZGN/KbY+hZxFQ9tyjxX0w0cPpkemrMq6NS00/vYnthGHVTBd4mneyShc0p7NKS2SN/eArpkuWxeWz4X7IuI7sGCSUWVhy7pa+BzMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678857273; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F9KsY+/Y90uQDNeE4eLqItY5YwC2xDwyG1hbbTr85xo=; b=aqbfV/ZOG0tXwebISTur67v5St/HYCLh9OxKkQuTTdtjEEJwZ2guKvMxmANqFSJIjcrAqpLMjz77u2kMTy3MD2sizWTbseF6cXUaNkwgmX5kFLIQSEZomf8XO4CORdXvwpjk+tqQBMl1jG+YtL7lVr97aLTi3lDsx7p5Ou/Zxt0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678857273129982.0818435818835; Tue, 14 Mar 2023 22:14:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.509892.786574 (Exim 4.92) (envelope-from ) id 1pcJSb-000626-6B; Wed, 15 Mar 2023 05:14:01 +0000 Received: by outflank-mailman (output) from mailman id 509892.786574; Wed, 15 Mar 2023 05:14:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcJSb-00061z-3C; Wed, 15 Mar 2023 05:14:01 +0000 Received: by outflank-mailman (input) for mailman id 509892; Wed, 15 Mar 2023 05:14:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcJSZ-00061o-UW for xen-devel@lists.xenproject.org; Wed, 15 Mar 2023 05:14:00 +0000 Received: from sonic317-22.consmr.mail.gq1.yahoo.com (sonic317-22.consmr.mail.gq1.yahoo.com [98.137.66.148]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2f016344-c2f0-11ed-b464-930f4c7d94ae; Wed, 15 Mar 2023 06:13:57 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.gq1.yahoo.com with HTTP; Wed, 15 Mar 2023 05:13:54 +0000 Received: by hermes--production-ne1-759c9b8c64-f7wvp (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 96a4225277b909cacfff2106b7580bc2; Wed, 15 Mar 2023 05:13:53 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2f016344-c2f0-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1678857234; bh=F9KsY+/Y90uQDNeE4eLqItY5YwC2xDwyG1hbbTr85xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=p9YN7VqyjmOukFXlxyruJtleNDUkqxs9Ql4dKEl/w3Xplp137dMgCEw4IuDDlmmSqK8emkSURKxPoEQtyqv0yOAaZF71IGcnOrjr4eAEcU4u4O2YuI9MFyHQ6wSTfDY0Y4Rt8zWYzl8T4vYmhifovZ6qZ4M9PUrwxnAYQe5a+ppWLspoOPebWEss3NTZP37t+7A8VIBR3gke7luGZoMmi5fqI8z2SgW5H9ILJR1eADiQbXfLfzAZUkmSBhaiaFMuWWE7GnjlA+b8nkcStgP8hk+9+NZLF+Ua9EUpJOSPPSMWIJVew9n5toBsgZogaTmTWCQFtyjeOVbq1hb7kmuIXg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1678857234; bh=r66pmpen/CDgyOZ0u5YeD2OIwCo+4rRYWxBwfRhi7/n=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=cDhoq4Wbjc/vkgk1EjUsQEAJ27X3kavm0dSdaHlun/2GuLeMizlDkvVz0Lc6gEEi+KtuwJ60j2K77Km/23gDgJlAVKTgcSF0rl8jqVvY+16ZeGgfy+ifvVl9CSV1E/87uIfGUx4Uqak7ZuevYvBmjYJx7T9L0HGsAZgPpLEQCoIzau/wXU0vqd8W9+iFUJfFtmhoSxOSZEkwb4NPa0jtd+jp0ucgORLIQIsEFnHHToahXR0CAnCELchpAFQda0+UXBc1HdmH3FGPD19+j+O3ohx7WxQXLTY+m+gFJusPAcnB4iVgiKD6EFTdPMfGckU9wJ0IiA2Xg7nUEfqCbJhyyw== X-YMail-OSG: lIWPx_cVM1lwlWKEVRdW7zVGbIDet8pd3jLPX208cXjeuk3Anj7SHy.6mEfwHuo To.XPZeLR2_bXM_LSlJTOp9SKqsfti2mKeB32WFPvTNm5jo8oI_hCA0tiXzglGu4wqHofq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ID: ed68d27d-d92f-4969-a28c-6b51268c4f58 From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Mark Cave-Ayland , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v3 1/2] pci: avoid accessing slot_reserved_mask directly outside of pci.c Date: Wed, 15 Mar 2023 01:13:41 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 4962 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1678857274608100001 Content-Type: text/plain; charset="utf-8" This patch provides accessor functions as replacements for direct access to slot_reserved_mask according to the comment at the top of include/hw/pci/pci_bus.h which advises that data structures for PCIBus should not be directly accessed but instead be accessed using accessor functions in pci.h. Three accessor functions can conveniently replace all direct accesses of slot_reserved_mask. With this patch, the new accessor functions are used in hw/sparc64/sun4u.c and hw/xen/xen_pt.c and pci_bus.h is removed from the included header files of the same two files. No functional change intended. Signed-off-by: Chuck Zmudzinski --- Changelog v3: This patch is unchanged since v2. v2: This is the first version of this patch, it did not exist in v1. hw/pci/pci.c | 15 +++++++++++++++ hw/sparc64/sun4u.c | 7 +++---- hw/xen/xen_pt.c | 7 +++---- include/hw/pci/pci.h | 3 +++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index def5000e7b..8a87ccc8b0 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1116,6 +1116,21 @@ static bool pci_bus_devfn_reserved(PCIBus *bus, int = devfn) return bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn)); } =20 +uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus) +{ + return bus->slot_reserved_mask; +} + +void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask) +{ + bus->slot_reserved_mask |=3D mask; +} + +void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask) +{ + bus->slot_reserved_mask &=3D ~mask; +} + /* -1 for devfn means auto assign */ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, const char *name, int devfn, diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index a25e951f9d..eae7589462 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -31,7 +31,6 @@ #include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" #include "hw/pci-host/sabre.h" @@ -608,9 +607,9 @@ static void sun4uv_init(MemoryRegion *address_space_mem, /* Only in-built Simba APBs can exist on the root bus, slot 0 on busA = is reserved (leaving no slots free after on-board devices) however slo= ts 0-3 are free on busB */ - pci_bus->slot_reserved_mask =3D 0xfffffffc; - pci_busA->slot_reserved_mask =3D 0xfffffff1; - pci_busB->slot_reserved_mask =3D 0xfffffff0; + pci_bus_set_slot_reserved_mask(pci_bus, 0xfffffffc); + pci_bus_set_slot_reserved_mask(pci_busA, 0xfffffff1); + pci_bus_set_slot_reserved_mask(pci_busB, 0xfffffff0); =20 ebus =3D pci_new_multifunction(PCI_DEVFN(1, 0), true, TYPE_EBUS); qdev_prop_set_uint64(DEVICE(ebus), "console-serial-base", diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 2d33d178ad..a540149639 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -57,7 +57,6 @@ #include =20 #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "xen_pt.h" @@ -951,7 +950,7 @@ void xen_igd_reserve_slot(PCIBus *pci_bus) } =20 XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n"); - pci_bus->slot_reserved_mask |=3D XEN_PCI_IGD_SLOT_MASK; + pci_bus_set_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); } =20 static void xen_igd_clear_slot(DeviceState *qdev, Error **errp) @@ -971,7 +970,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) return; } =20 - if (!(pci_bus->slot_reserved_mask & XEN_PCI_IGD_SLOT_MASK)) { + if (!(pci_bus_get_slot_reserved_mask(pci_bus) & XEN_PCI_IGD_SLOT_MASK)= ) { xpdc->pci_qdev_realize(qdev, errp); return; } @@ -982,7 +981,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) s->real_device.dev =3D=3D XEN_PCI_IGD_DEV && s->real_device.func =3D=3D XEN_PCI_IGD_FN && s->real_device.vendor_id =3D=3D PCI_VENDOR_ID_INTEL) { - pci_bus->slot_reserved_mask &=3D ~XEN_PCI_IGD_SLOT_MASK; + pci_bus_clear_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n"); } xpdc->pci_qdev_realize(qdev, errp); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index d5a40cd058..935b4b91b4 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -287,6 +287,9 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq); void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); +uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus); +void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask); +void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ static inline int pci_swizzle(int slot, int pin) { --=20 2.39.2 From nobody Sat Apr 20 13:26:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1678857274; cv=none; d=zohomail.com; s=zohoarc; b=fQfGmLjIzlDrqvkEUN8Wb3NTHUgawqnBgtyQBYMPnwD+R7yaf0sFqTkWO3RkzI76wTi6dtO+syjRaIVtPMOlpT8/8dBZJDdsPTqt2xvAnfF0slEhV9FrrVgsK9YgJPDLx9Gc1oM0PlX5EQ+2SgDHa1iLkYmabEHh+AHKk8NIoFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678857274; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q0XT1QQYOz5Utc07CCwIzZ4mh2OSgk2Itg/6nDFk02o=; b=cI8WFwpS0LEwau4P51S4+PS2+ST0x9oMafi0OHJf7fj9rja1RRG+2n+c8/743xP4ZMXmw/bU0PqwFGzCWjGieJq7atRfJOGrig2lm/UETWHyGdOg9zwcLmBmIOUYzCJasKNRskHK10Tlx91TTgKma12hu1hOgOmGFDFn24U3Sbc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16788572747252.0912385252354397; Tue, 14 Mar 2023 22:14:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.509894.786590 (Exim 4.92) (envelope-from ) id 1pcJSc-0006KV-Pq; Wed, 15 Mar 2023 05:14:02 +0000 Received: by outflank-mailman (output) from mailman id 509894.786590; Wed, 15 Mar 2023 05:14:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcJSc-0006KG-KC; Wed, 15 Mar 2023 05:14:02 +0000 Received: by outflank-mailman (input) for mailman id 509894; Wed, 15 Mar 2023 05:14:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcJSb-00061o-Jm for xen-devel@lists.xenproject.org; Wed, 15 Mar 2023 05:14:01 +0000 Received: from sonic316-8.consmr.mail.gq1.yahoo.com (sonic316-8.consmr.mail.gq1.yahoo.com [98.137.69.32]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2ffbba38-c2f0-11ed-b464-930f4c7d94ae; Wed, 15 Mar 2023 06:13:58 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.gq1.yahoo.com with HTTP; Wed, 15 Mar 2023 05:13:56 +0000 Received: by hermes--production-ne1-759c9b8c64-f7wvp (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 96a4225277b909cacfff2106b7580bc2; Wed, 15 Mar 2023 05:13:55 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2ffbba38-c2f0-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1678857236; bh=Q0XT1QQYOz5Utc07CCwIzZ4mh2OSgk2Itg/6nDFk02o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=DBLkXR5qItNdj7IB5Mocib0e7lnRUTJV4h8pFUhfzy/PGBJVbbravppO8dWn0xAf8LI4SKP8GMbU9tCHlOHtrG57N/QnydzQpTnI1IHzKXOU+owmYfxhIIN9l/tr5YhwJ05SDs22tlHcAPMHjD2QxlBfV/B9zM4KZR4p4OFKO2cZzH4WfJnI3gOQAIB7koeby5UDTUNCDfjLcx/kGX0SKkJqFPedZU4JHPbwzGbYKnbnxiMhx60sD/GisOW5g4/4ozrvNky/d4wyh+nVDrtSn4PoUWwF14077b0gKq3JEnHbR6l2v/Aj6rUIOcUx2OSgWbC+uI6FhaHbIoQf7fiajQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1678857236; bh=ShaupOz04ZK/Avyjra5SI9Y1u94kMyAAUosDFXRSnkh=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=r8SaCtP5TR1E7vT3HnwSi5f+K4DJkygL7N06d+BhNYnHVhbLHOGnn+Iep2Izw7CHCetm15K8K4nldqc00LltXz/hSgx7ybMW6kTfyu4LbV7T7QsbzSYOcjFGXX4n3kRjTbb+MVQXlL7qNLjmnl2Mb+3umG8k4re+0rqtWN2FSxMjolIQrJsbQAQItmzxVc0GNBafQtyBvPWKDBVatKAMOyJ26rz13r7O+H8ooJSiq+rITxMyo9+CCwbOj5gcmJCQhwy/Ldqr5IKRiqQuUOVHuocdCqfWrIbIVsnoQT4kQEzIQEluf7Fo8Hprh74l5ZNqx9ik7CkeKebVqlFCXyokqQ== X-YMail-OSG: tt9De90VM1nUtWI7MldM0UB64dhKT41tuhOByewHdnowbRAJvnWEBQImhJesqqP MhtLE9jTK.8jLBWTbNKtQ0IOnB5Nh_Ku3ANawmC2lVFtw4BvVmbMrQ6fmum5g3NfhLSVlOs3DHpa 1MaDpJdnCpdsMfg2bx6uc3F9zUOByVDxO6e9.DdY6lA0Z8yI9qBml2DX6wf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el@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Mark Cave-Ayland , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v3 2/2] pci: introduce slot_reserved_auto_mask and slot_reserved_manual_mask Date: Wed, 15 Mar 2023 01:13:42 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 10649 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1678857276324100003 Content-Type: text/plain; charset="utf-8" Commit 4f67543bb8c5 ("xen/pt: reserve PCI slot 2 for Intel igd-passthru") uses slot_reserved_mask to reserve slot 2 for the Intel igd for the xenfv machine when the guest is configured for igd-passthru. Prior to that commit, a single 32-bit mask was sufficient to meet the needs of the only machine that used the 32-bit slot_reserved_mask, the sun4u machine. However, the requirements of the xenfv machine with igd-passthru is somewhat different from the requirements of the sun4u machine. First, the sun4u machine reserves slots in such a way that no device can be assigned to a reserved slot, but the xenfv machine needs to reserve a single slot that is reserved for a particular device, the Intel igd. The necessary logic to ensure that the reserved slot is used by the Intel igd was recently added by the aforementioned commit. Second, it is useful to limit slot reservation in the case of the xenfv machine with the Intel igd to devices configured for automatic slot assignment so an administrator can assign a device to the reserved slot by manually specifying the reserved slot address on the command line, but the sun4u machine requires slot reservation for all devices, whether or not the device is configured for automatic slot assignment or configured manually by specifying a slot address on the command line. In other words, for the sun4u machine, the required behavior is that an attempt to assign a reserved slot to a device must always result in an error, but it is useful to allow manual assignment of a reserved slot to succeed for the xenfv machine with the Intel igd. The necessary logic to implement the desired behavior of reserving one or more slots only for the case of automatic slot allocation has not yet been implemented, and that is the purpose of this patch. The implementation is simple: the xenfv machine only sets slot_reserved_auto_mask and the sun4u machine sets both slot_reserved_manual_mask and slot_reserved_auto_mask. A single "set" accessor function allows xenfv and sun4u machines to set the value of the two masks appropriately for each use case. Since the xenfv machine needs to implement additional logic to detect the Intel igd and clear the bit in the mask to allow a particular device to use the reserved slot, there is a need for a "get" and "clear" accessor function for slot_reserved_auto_mask, but these accessor functions are not needed for slot_reserved_manual_mask because the sun4u machine has no need to get the value of the mask or clear bits in the mask. Link: https://lore.kernel.org/qemu-devel/20230106064838-mutt-send-email-mst= @kernel.org/ Signed-off-by: Chuck Zmudzinski --- Changelog v3: Change Subject of patch from "pci: allow slot_reserved_mask to be ignored with manual slot assignmen= t" To "pci: introduce slot_reserved_auto_mask and slot_reserved_manual_mask" =20 Substantially reword the commit message to clearly explain the reasons this patch is needed Apply changes in response to comments on v2: - slot_reserved_mask -> slot_reserved_auto_mask - remove enforce_slot_reserved_mask_manual - remove pci_bus_ignore_slot_reserved_mask_manual - add slot_reserved_manual_mask - pci_bus_devfn_reserved -> pci_bus_devfn_reserved_auto - change code in pci_bus_devfn_reserved_manual appropriately - pci_bus_set_slot_reserved_mask -> pci_bus_set_slot_reserved_masks - use renamed "set" function to set value of both masks for sun4= u and xenfv cases - pci_bus_get_slot_reserved_mask -> pci_bus_get_slot_reserved_auto_m= ask - pci_bus_clear_slot_reserved_mask -> pci_bus_clear_slot_reserved_au= to_mask v2: Change Subject of patch from "pci: add enforce_slot_reserved_mask_manual property" To "pci: allow slot_reserved_mask to be ignored with manual slot assignmen= t" Add pci_bus_ignore_slot_reserved_mask_manual function Call pci_bus_ignore_slot_reserved_mask_manual at appropriate place in hw/pci-host/i440fx.c hw/pci/pci.c | 29 ++++++++++++++++++----------- hw/sparc64/sun4u.c | 6 +++--- hw/xen/xen_pt.c | 6 +++--- include/hw/pci/pci.h | 6 +++--- include/hw/pci/pci_bus.h | 3 ++- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 8a87ccc8b0..58a530a651 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -500,7 +500,8 @@ static void pci_root_bus_internal_init(PCIBus *bus, Dev= iceState *parent, { assert(PCI_FUNC(devfn_min) =3D=3D 0); bus->devfn_min =3D devfn_min; - bus->slot_reserved_mask =3D 0x0; + bus->slot_reserved_auto_mask =3D 0x0; + bus->slot_reserved_manual_mask =3D 0x0; bus->address_space_mem =3D address_space_mem; bus->address_space_io =3D address_space_io; bus->flags |=3D PCI_BUS_IS_ROOT; @@ -1111,24 +1112,30 @@ static bool pci_bus_devfn_available(PCIBus *bus, in= t devfn) return !(bus->devices[devfn]); } =20 -static bool pci_bus_devfn_reserved(PCIBus *bus, int devfn) +static bool pci_bus_devfn_reserved_auto(PCIBus *bus, int devfn) { - return bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn)); + return bus->slot_reserved_auto_mask & (1UL << PCI_SLOT(devfn)); } =20 -uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus) +static bool pci_bus_devfn_reserved_manual(PCIBus *bus, int devfn) { - return bus->slot_reserved_mask; + return bus->slot_reserved_manual_mask & (1UL << PCI_SLOT(devfn)); } =20 -void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask) +void pci_bus_set_slot_reserved_masks(PCIBus *bus, uint32_t auto_mask, uint= 32_t manual_mask) { - bus->slot_reserved_mask |=3D mask; + bus->slot_reserved_auto_mask |=3D auto_mask; + bus->slot_reserved_manual_mask |=3D manual_mask; } =20 -void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask) +void pci_bus_clear_slot_reserved_auto_mask(PCIBus *bus, uint32_t mask) { - bus->slot_reserved_mask &=3D ~mask; + bus->slot_reserved_auto_mask &=3D ~mask; +} + +uint32_t pci_bus_get_slot_reserved_auto_mask(PCIBus *bus) +{ + return bus->slot_reserved_auto_mask; } =20 /* -1 for devfn means auto assign */ @@ -1156,7 +1163,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, for(devfn =3D bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn +=3D PCI_FUNC_MAX) { if (pci_bus_devfn_available(bus, devfn) && - !pci_bus_devfn_reserved(bus, devfn)) { + !pci_bus_devfn_reserved_auto(bus, devfn)) { goto found; } } @@ -1164,7 +1171,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, "or reserved", name); return NULL; found: ; - } else if (pci_bus_devfn_reserved(bus, devfn)) { + } else if (pci_bus_devfn_reserved_manual(bus, devfn)) { error_setg(errp, "PCI: slot %d function %d not available for %s," " reserved", PCI_SLOT(devfn), PCI_FUNC(devfn), name); diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index eae7589462..21ab12f6f7 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -607,9 +607,9 @@ static void sun4uv_init(MemoryRegion *address_space_mem, /* Only in-built Simba APBs can exist on the root bus, slot 0 on busA = is reserved (leaving no slots free after on-board devices) however slo= ts 0-3 are free on busB */ - pci_bus_set_slot_reserved_mask(pci_bus, 0xfffffffc); - pci_bus_set_slot_reserved_mask(pci_busA, 0xfffffff1); - pci_bus_set_slot_reserved_mask(pci_busB, 0xfffffff0); + pci_bus_set_slot_reserved_masks(pci_bus, 0xfffffffc, 0xfffffffc); + pci_bus_set_slot_reserved_masks(pci_busA, 0xfffffff1, 0xfffffff1); + pci_bus_set_slot_reserved_masks(pci_busB, 0xfffffff0, 0xfffffff0); =20 ebus =3D pci_new_multifunction(PCI_DEVFN(1, 0), true, TYPE_EBUS); qdev_prop_set_uint64(DEVICE(ebus), "console-serial-base", diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index a540149639..3d3290ec02 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -950,7 +950,7 @@ void xen_igd_reserve_slot(PCIBus *pci_bus) } =20 XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n"); - pci_bus_set_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); + pci_bus_set_slot_reserved_masks(pci_bus, XEN_PCI_IGD_SLOT_MASK, 0x0); } =20 static void xen_igd_clear_slot(DeviceState *qdev, Error **errp) @@ -970,7 +970,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) return; } =20 - if (!(pci_bus_get_slot_reserved_mask(pci_bus) & XEN_PCI_IGD_SLOT_MASK)= ) { + if (!(pci_bus_get_slot_reserved_auto_mask(pci_bus) & XEN_PCI_IGD_SLOT_= MASK)) { xpdc->pci_qdev_realize(qdev, errp); return; } @@ -981,7 +981,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) s->real_device.dev =3D=3D XEN_PCI_IGD_DEV && s->real_device.func =3D=3D XEN_PCI_IGD_FN && s->real_device.vendor_id =3D=3D PCI_VENDOR_ID_INTEL) { - pci_bus_clear_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); + pci_bus_clear_slot_reserved_auto_mask(pci_bus, XEN_PCI_IGD_SLOT_MA= SK); XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n"); } xpdc->pci_qdev_realize(qdev, errp); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 935b4b91b4..7e941e1c87 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -287,9 +287,9 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq); void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); -uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus); -void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask); -void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask); +uint32_t pci_bus_get_slot_reserved_auto_mask(PCIBus *bus); +void pci_bus_set_slot_reserved_masks(PCIBus *bus, uint32_t auto_mask, uint= 32_t manual_mask); +void pci_bus_clear_slot_reserved_auto_mask(PCIBus *bus, uint32_t mask); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ static inline int pci_swizzle(int slot, int pin) { diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 5653175957..3c2b3b8e32 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -36,7 +36,8 @@ struct PCIBus { PCIIOMMUFunc iommu_fn; void *iommu_opaque; uint8_t devfn_min; - uint32_t slot_reserved_mask; + uint32_t slot_reserved_auto_mask; + uint32_t slot_reserved_manual_mask; pci_set_irq_fn set_irq; pci_map_irq_fn map_irq; pci_route_irq_fn route_intx_to_irq; --=20 2.39.2