From nobody Mon May 13 14:29:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1682000931; cv=none; d=zohomail.com; s=zohoarc; b=Zo4AYLEqG2jh8zG7AfunzK54un7ROik05Pjpsb2J2MeyzRrUEJXd4HSgVJl+5GvxfNyxO8ys1iFvL6Oo5WLY50mv25tLOiCNiSNOElmBOOcXAfLpXgpo1uZBM49948XoUXDAkOdMFNlreO6UR/iDLtcn09Hc/kpwna4eHL9LHvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682000931; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LFhwmFotzPpn9OaOvkFUMGztAUM87mRAeZ4b9S6yz5E=; b=d6yKLmFO07AZ6VqamTOIwosXdn033jAmg8x0XigRdsAijOGSVnIIjUVvIgX9Szig5onnSvUV1rdJTrCU6rPl8Fklzmm1EKu/vrpP8+InfWLKvWTzCEwavF9TnjYX5yPIyuzoBLUv/o0eYNidTqVFFXLLFXhpkp2+q+H6tljoLZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682000931140105.30804653655014; Thu, 20 Apr 2023 07:28:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppVGq-0001iT-67; Thu, 20 Apr 2023 10:28:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppVGo-0001bU-Ix for qemu-devel@nongnu.org; Thu, 20 Apr 2023 10:28:22 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppVGn-0007zm-2S for qemu-devel@nongnu.org; Thu, 20 Apr 2023 10:28:22 -0400 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Q2Kgs2C6Mz6J776; Thu, 20 Apr 2023 22:25:29 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 20 Apr 2023 15:28:17 +0100 To: , Peter Maydell CC: "Michael S . Tsirkin" , Fan Ni , Subject: [PATCH 1/2] hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset() Date: Thu, 20 Apr 2023 15:27:49 +0100 Message-ID: <20230420142750.6950-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230420142750.6950-1-Jonathan.Cameron@huawei.com> References: <20230420142750.6950-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1682000932507100001 Content-Type: text/plain; charset="utf-8" Reproduce issue with configure --enable-qom-cast-debug ... qemu-system-x86_64 -display none -machine q35,cxl=3Don -device pxb-cxl,bus= =3Dpcie.0 hw/pci-bridge/pci_expander_bridge.c:54:PXB_DEV: Object 0x5570e0b1ada0 is = not an instance of type pxb Aborted The type conversion results in the right state structure, but PXB_DEV is not a parent of PXB_CXL_DEV hence the error. Rather than directly cleaning up the inheritance, this is the minimal fix which will be followed by the cleanup. Fixes: 154070eaf6 ("hw/pxb-cxl: Support passthrough HDM Decoders unless ove= rridden") Reported-by: Peter Maydell Signed-off-by: Jonathan Cameron Reviewed-by: Thomas Huth --- hw/pci-bridge/pci_expander_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index ead33f0c05..a78327b5f2 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -311,7 +311,7 @@ static void pxb_cxl_dev_reset(DeviceState *dev) * The CXL specification allows for host bridges with no HDM decoders * if they only have a single root port. */ - if (!PXB_DEV(dev)->hdm_for_passthrough) { + if (!PXB_CXL_DEV(dev)->hdm_for_passthrough) { dsp_count =3D pcie_count_ds_ports(hb->bus); } /* Initial reset will have 0 dsp so wait until > 0 */ --=20 2.37.2 From nobody Mon May 13 14:29:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1682000964; cv=none; d=zohomail.com; s=zohoarc; b=e1sEv+qHReKFUgmJK1z0Cg2o+Udo6UrmwcDQBjLq3sQhxNvX+E98/xFJR9mhQ9EOeeR8RpOS0OHHuHJidW9WoEvlmuxymH9LsJ5hEgzBpzWeFtp92+YQ/VFVhnIZJAJY8wUOEXA4rUBUl9dcgBKLJ7K2RoLLwmvt4saJiKw312U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682000964; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=H/clgPWVPaZuubXiFnDQ6bhUnBZ+mYUffWlEjfybUwc=; b=g/DIwcnHay8PMEEjNIQ+Z1M+KSCH3Hq4iajSzSP20OImGUX9B0VKCwpsKFjPRbSEBKonK6TBvi6a57meCGsSoDppm8/jRVWdwSNyot8XGve5i8eejo7+v9Rs5mD286rtP796yIt4WDl0viB3aratGYNkg/F/FyL3257mGvlB10c= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682000964888127.73866653552648; Thu, 20 Apr 2023 07:29:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppVHd-0002vk-Dp; Thu, 20 Apr 2023 10:29:13 -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 1ppVHJ-0002lu-Nn for qemu-devel@nongnu.org; Thu, 20 Apr 2023 10:28:57 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppVHG-0008Ao-OD for qemu-devel@nongnu.org; Thu, 20 Apr 2023 10:28:52 -0400 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Q2KkM3hQmz67Xxc; Thu, 20 Apr 2023 22:27:39 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 20 Apr 2023 15:28:48 +0100 To: , Peter Maydell CC: "Michael S . Tsirkin" , Fan Ni , Subject: [PATCH 2/2] hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV Date: Thu, 20 Apr 2023 15:27:50 +0100 Message-ID: <20230420142750.6950-3-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230420142750.6950-1-Jonathan.Cameron@huawei.com> References: <20230420142750.6950-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1682000966068100001 Content-Type: text/plain; charset="utf-8" Previously, PXB_CXL_DEVICE, PXB_PCIE_DEVICE and PXB_DEVICE all have PCI_DEVICE as their direct parent but share a common state struct PXBDev. convert_to_pxb() is used to get the PXBDev instance from which ever of these types it is called on. This patch switches to an explicit heirarchy based on shared functionality. To allow use of OBJECT_DECLARE_SIMPLE_TYPE() whilst minimizing code changes, all types are renamed to have the postfix _DEV rather than _DEVICE. The new heirarchy has PXB_CXL_DEV with parent PXB_PCIE_DEV which in turn has parent PXB_DEV which continues to have parent PCI_DEVICE. This allows simple use of PXB_DEV() etc rather than a custom function + removal of duplicated properties and moving the CXL specific elements out of struct PXBDev. Signed-off-by: Jonathan Cameron Reviewed-by: Thomas Huth --- hw/acpi/cxl.c | 11 +++--- hw/cxl/cxl-host.c | 4 +- hw/pci-bridge/pci_expander_bridge.c | 59 ++++++++++------------------- include/hw/cxl/cxl.h | 4 +- include/hw/pci/pci_bridge.h | 28 ++++++++++---- 5 files changed, 49 insertions(+), 57 deletions(-) diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c index 2bf8c07993..92b46bc932 100644 --- a/hw/acpi/cxl.c +++ b/hw/acpi/cxl.c @@ -30,9 +30,10 @@ #include "qapi/error.h" #include "qemu/uuid.h" =20 -static void cedt_build_chbs(GArray *table_data, PXBDev *cxl) +static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl) { - SysBusDevice *sbd =3D SYS_BUS_DEVICE(cxl->cxl.cxl_host_bridge); + PXBDev *pxb =3D PXB_DEV(cxl); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(cxl->cxl_host_bridge); struct MemoryRegion *mr =3D sbd->mmio[0].memory; =20 /* Type */ @@ -45,7 +46,7 @@ static void cedt_build_chbs(GArray *table_data, PXBDev *c= xl) build_append_int_noprefix(table_data, 32, 2); =20 /* UID - currently equal to bus number */ - build_append_int_noprefix(table_data, cxl->bus_nr, 4); + build_append_int_noprefix(table_data, pxb->bus_nr, 4); =20 /* Version */ build_append_int_noprefix(table_data, 1, 4); @@ -112,7 +113,7 @@ static void cedt_build_cfmws(GArray *table_data, CXLSta= te *cxls) /* Host Bridge List (list of UIDs - currently bus_nr) */ for (i =3D 0; i < fw->num_targets; i++) { g_assert(fw->target_hbs[i]); - build_append_int_noprefix(table_data, fw->target_hbs[i]->bus_n= r, 4); + build_append_int_noprefix(table_data, PXB_DEV(fw->target_hbs[i= ])->bus_nr, 4); } } } @@ -121,7 +122,7 @@ static int cxl_foreach_pxb_hb(Object *obj, void *opaque) { Aml *cedt =3D opaque; =20 - if (object_dynamic_cast(obj, TYPE_PXB_CXL_DEVICE)) { + if (object_dynamic_cast(obj, TYPE_PXB_CXL_DEV)) { cedt_build_chbs(cedt->buf, PXB_CXL_DEV(obj)); } =20 diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index 6e923ceeaf..034c7805b3 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -84,7 +84,7 @@ void cxl_fmws_link_targets(CXLState *cxl_state, Error **e= rrp) bool ambig; =20 o =3D object_resolve_path_type(fw->targets[i], - TYPE_PXB_CXL_DEVICE, + TYPE_PXB_CXL_DEV, &ambig); if (!o) { error_setg(errp, "Could not resolve CXLFM target %s", @@ -141,7 +141,7 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow = *fw, hwaddr addr) addr +=3D fw->base; =20 rb_index =3D (addr / cxl_decode_ig(fw->enc_int_gran)) % fw->num_target= s; - hb =3D PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl.cxl_host_bridge); + hb =3D PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl_host_bridge); if (!hb || !hb->bus || !pci_bus_is_cxl(hb->bus)) { return NULL; } diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index a78327b5f2..613857b601 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -50,24 +50,8 @@ struct PXBBus { char bus_path[8]; }; =20 -#define TYPE_PXB_DEVICE "pxb" -DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV, - TYPE_PXB_DEVICE) - -#define TYPE_PXB_PCIE_DEVICE "pxb-pcie" -DECLARE_INSTANCE_CHECKER(PXBDev, PXB_PCIE_DEV, - TYPE_PXB_PCIE_DEVICE) - -static PXBDev *convert_to_pxb(PCIDevice *dev) -{ - /* A CXL PXB's parent bus is PCIe, so the normal check won't work */ - if (object_dynamic_cast(OBJECT(dev), TYPE_PXB_CXL_DEVICE)) { - return PXB_CXL_DEV(dev); - } - - return pci_bus_is_express(pci_get_bus(dev)) - ? PXB_PCIE_DEV(dev) : PXB_DEV(dev); -} +#define TYPE_PXB_PCIE_DEV "pxb-pcie" +OBJECT_DECLARE_SIMPLE_TYPE(PXBPCIEDev, PXB_PCIE_DEV) =20 static GList *pxb_dev_list; =20 @@ -89,14 +73,14 @@ bool cxl_get_hb_passthrough(PCIHostState *hb) =20 static int pxb_bus_num(PCIBus *bus) { - PXBDev *pxb =3D convert_to_pxb(bus->parent_dev); + PXBDev *pxb =3D PXB_DEV(bus->parent_dev); =20 return pxb->bus_nr; } =20 static uint16_t pxb_bus_numa_node(PCIBus *bus) { - PXBDev *pxb =3D convert_to_pxb(bus->parent_dev); + PXBDev *pxb =3D PXB_DEV(bus->parent_dev); =20 return pxb->numa_node; } @@ -154,7 +138,7 @@ static char *pxb_host_ofw_unit_address(const SysBusDevi= ce *dev) =20 pxb_host =3D PCI_HOST_BRIDGE(dev); pxb_bus =3D pxb_host->bus; - pxb_dev =3D convert_to_pxb(pxb_bus->parent_dev); + pxb_dev =3D PXB_DEV(pxb_bus->parent_dev); position =3D g_list_index(pxb_dev_list, pxb_dev); assert(position >=3D 0); =20 @@ -212,8 +196,8 @@ static void pxb_cxl_realize(DeviceState *dev, Error **e= rrp) */ void pxb_cxl_hook_up_registers(CXLState *cxl_state, PCIBus *bus, Error **e= rrp) { - PXBDev *pxb =3D PXB_CXL_DEV(pci_bridge_get_device(bus)); - CXLHost *cxl =3D pxb->cxl.cxl_host_bridge; + PXBCXLDev *pxb =3D PXB_CXL_DEV(pci_bridge_get_device(bus)); + CXLHost *cxl =3D pxb->cxl_host_bridge; CXLComponentState *cxl_cstate =3D &cxl->cxl_cstate; struct MemoryRegion *mr =3D &cxl_cstate->crb.component_registers; hwaddr offset; @@ -299,7 +283,7 @@ static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) =20 static void pxb_cxl_dev_reset(DeviceState *dev) { - CXLHost *cxl =3D PXB_CXL_DEV(dev)->cxl.cxl_host_bridge; + CXLHost *cxl =3D PXB_CXL_DEV(dev)->cxl_host_bridge; CXLComponentState *cxl_cstate =3D &cxl->cxl_cstate; PCIHostState *hb =3D PCI_HOST_BRIDGE(cxl); uint32_t *reg_state =3D cxl_cstate->crb.cache_mem_registers; @@ -337,7 +321,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer = b) static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type, Error **errp) { - PXBDev *pxb =3D convert_to_pxb(dev); + PXBDev *pxb =3D PXB_DEV(dev); DeviceState *ds, *bds =3D NULL; PCIBus *bus; const char *dev_name =3D NULL; @@ -365,7 +349,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, enum= BusType type, } else if (type =3D=3D CXL) { bus =3D pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_CXL= _BUS); bus->flags |=3D PCI_BUS_CXL; - PXB_CXL_DEV(dev)->cxl.cxl_host_bridge =3D PXB_CXL_HOST(ds); + PXB_CXL_DEV(dev)->cxl_host_bridge =3D PXB_CXL_HOST(ds); } else { bus =3D pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_P= XB_BUS); bds =3D qdev_new("pci-bridge"); @@ -418,7 +402,7 @@ static void pxb_dev_realize(PCIDevice *dev, Error **err= p) =20 static void pxb_dev_exitfn(PCIDevice *pci_dev) { - PXBDev *pxb =3D convert_to_pxb(pci_dev); + PXBDev *pxb =3D PXB_DEV(pci_dev); =20 pxb_dev_list =3D g_list_remove(pxb_dev_list, pxb); } @@ -449,7 +433,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void= *data) } =20 static const TypeInfo pxb_dev_info =3D { - .name =3D TYPE_PXB_DEVICE, + .name =3D TYPE_PXB_DEV, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(PXBDev), .class_init =3D pxb_dev_class_init, @@ -481,15 +465,14 @@ static void pxb_pcie_dev_class_init(ObjectClass *klas= s, void *data) k->class_id =3D PCI_CLASS_BRIDGE_HOST; =20 dc->desc =3D "PCI Express Expander Bridge"; - device_class_set_props(dc, pxb_dev_properties); dc->hotpluggable =3D false; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } =20 static const TypeInfo pxb_pcie_dev_info =3D { - .name =3D TYPE_PXB_PCIE_DEVICE, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(PXBDev), + .name =3D TYPE_PXB_PCIE_DEV, + .parent =3D TYPE_PXB_DEV, + .instance_size =3D sizeof(PXBPCIEDev), .class_init =3D pxb_pcie_dev_class_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, @@ -510,11 +493,7 @@ static void pxb_cxl_dev_realize(PCIDevice *dev, Error = **errp) } =20 static Property pxb_cxl_dev_properties[] =3D { - /* Note: 0 is not a legal PXB bus number. */ - DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0), - DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNE= D), - DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false), - DEFINE_PROP_BOOL("hdm_for_passthrough", PXBDev, hdm_for_passthrough, f= alse), + DEFINE_PROP_BOOL("hdm_for_passthrough", PXBCXLDev, hdm_for_passthrough= , false), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -540,9 +519,9 @@ static void pxb_cxl_dev_class_init(ObjectClass *klass, = void *data) } =20 static const TypeInfo pxb_cxl_dev_info =3D { - .name =3D TYPE_PXB_CXL_DEVICE, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(PXBDev), + .name =3D TYPE_PXB_CXL_DEV, + .parent =3D TYPE_PXB_PCIE_DEV, + .instance_size =3D sizeof(PXBCXLDev), .class_init =3D pxb_cxl_dev_class_init, .interfaces =3D (InterfaceInfo[]){ diff --git a/include/hw/cxl/cxl.h b/include/hw/cxl/cxl.h index b2cffbb364..c453983e83 100644 --- a/include/hw/cxl/cxl.h +++ b/include/hw/cxl/cxl.h @@ -23,12 +23,12 @@ =20 #define CXL_WINDOW_MAX 10 =20 -typedef struct PXBDev PXBDev; +typedef struct PXBCXLDev PXBCXLDev; =20 typedef struct CXLFixedWindow { uint64_t size; char **targets; - PXBDev *target_hbs[8]; + PXBCXLDev *target_hbs[8]; uint8_t num_targets; uint8_t enc_int_ways; uint8_t enc_int_gran; diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index 1677176b2a..01670e9e65 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -84,7 +84,7 @@ struct PCIBridge { #define PCI_BRIDGE_DEV_PROP_SHPC "shpc" typedef struct CXLHost CXLHost; =20 -struct PXBDev { +typedef struct PXBDev { /*< private >*/ PCIDevice parent_obj; /*< public >*/ @@ -92,15 +92,27 @@ struct PXBDev { uint8_t bus_nr; uint16_t numa_node; bool bypass_iommu; +} PXBDev; + +typedef struct PXBPCIEDev { + /*< private >*/ + PXBDev parent_obj; +} PXBPCIEDev; + +#define TYPE_PXB_DEV "pxb" +OBJECT_DECLARE_SIMPLE_TYPE(PXBDev, PXB_DEV) + +typedef struct PXBCXLDev { + /*< private >*/ + PXBPCIEDev parent_obj; + /*< public >*/ + bool hdm_for_passthrough; - struct cxl_dev { - CXLHost *cxl_host_bridge; /* Pointer to a CXLHost */ - } cxl; -}; + CXLHost *cxl_host_bridge; /* Pointer to a CXLHost */ +} PXBCXLDev; =20 -#define TYPE_PXB_CXL_DEVICE "pxb-cxl" -DECLARE_INSTANCE_CHECKER(PXBDev, PXB_CXL_DEV, - TYPE_PXB_CXL_DEVICE) +#define TYPE_PXB_CXL_DEV "pxb-cxl" +OBJECT_DECLARE_SIMPLE_TYPE(PXBCXLDev, PXB_CXL_DEV) =20 int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset, uint16_t svid, uint16_t ssid, --=20 2.37.2