From nobody Mon Nov 23 05:10:02 2026 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790589434; cv=none; d=zohomail.com; s=zohoarc; b=FEOuyFT93XvJPBwXeOeIa/Udk7XRi+DHeclTxCX8ZZaW9Xu8oVbsNW7X1R54CJZ3ZtUBbD6CyQuvzmZootjtJbIMkIY7Hy0yMRbiTKyOKUmeTHpDvYzVVHkqyta8HgipxiJ1Exqnrm4Volfc9XUf2oBYPMVOO0zty0BSHhe0miw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790589434; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4tVuCFNF/H30yzbtZqEPG9Njc0+ZOaYVy5PjtguTs70=; b=c1wn/HNYEVEL9kWRb/waBdfX7L/R0E9yC/0+sUojKGccWOfqKjUfOXGJLQ9PANm+dr//idP4fY2yi46yHhXkW2CphtnNUbaSGMIQwY2RkqvnkRPKjDq2eM5+vr6aWPSLT/vXvUgcxkOMWRBXU6o03VOefpGaDzFebJHnKvpg+Fk= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790589434659366.5320772660293; Mon, 28 Sep 2026 02:57:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xB86b-0000VG-4g; Mon, 28 Sep 2026 05:57:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xB86Y-0000T4-Pt for qemu-devel@nongnu.org; Mon, 28 Sep 2026 05:57:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xB86X-00009L-86 for qemu-devel@nongnu.org; Mon, 28 Sep 2026 05:57:02 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-pqnv6E6YONKDnLyjTcF4Xg-1; Mon, 28 Sep 2026 05:56:56 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8836419352EF; Mon, 28 Sep 2026 09:56:54 +0000 (UTC) Received: from berrange.csb (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ECE681956089; Mon, 28 Sep 2026 09:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790589420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4tVuCFNF/H30yzbtZqEPG9Njc0+ZOaYVy5PjtguTs70=; b=T8PCsyP6XBS0AgvOpxEUGaWOhk+2jhJn/SuABzRoXjz0Kvkc1XWwuIb8vtxSOjBzeX2dUw ghDjmZl3smxZ+tpFVtpOFCEWo6ZDr3nA/C+IRFTA+CJy2xzYuijV9WjRvs4lGiL2ZBdwI0 ysrn/dOB373SolIhBTz9zwOBB5/BB3I= X-MC-Unique: pqnv6E6YONKDnLyjTcF4Xg-1 X-Mimecast-MFC-AGG-ID: pqnv6E6YONKDnLyjTcF4Xg_1790589414 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: linux-cxl@vger.kernel.org, "Michael S. Tsirkin" , qemu-arm@nongnu.org, Junjie Cao , Peter Maydell , Anisa Su , Jonathan Cameron , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 1/2] hw/arm: remove pci-bridge/pci_expander_bridge.h from virt.c Date: Mon, 28 Sep 2026 10:56:45 +0100 Message-ID: <20260928095646.3555447-2-berrange@redhat.com> In-Reply-To: <20260928095646.3555447-1-berrange@redhat.com> References: <20260928095646.3555447-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 9 X-Spam_score: 0.9 X-Spam_bar: / X-Spam_report: (0.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1790589441258158500 This include is redundant as the function is declares is not referenced. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/virt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3eecf094bcc..a570832fc0e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -58,7 +58,6 @@ #include "qemu/module.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/gpex.h" -#include "hw/pci-bridge/pci_expander_bridge.h" #include "hw/virtio/virtio-pci.h" #include "hw/core/sysbus-fdt.h" #include "hw/core/platform-bus.h" --=20 2.55.0 From nobody Mon Nov 23 05:10:02 2026 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790589434; cv=none; d=zohomail.com; s=zohoarc; b=U+Ad5ICaqoBYb7rhmjDEoxaJPV2cKM60FsjFr6fBKhKRBndaSJ+DJ69E48iwWGP1oBxoqRyOyIUGOd/fDv0fpsnUuitjHWEHIswE/M8/8AJk8Eht0E3HnzcrcsUxjkJlo4pcjo69/QffXRgMC3YF8+KBiXAhLdw9SKwmn7raNcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790589434; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=exX1zsK/mhQx+Jvfd/Qj5mA7V/LpOI3/0XJa9RPhC8k=; b=no0vNkKbGhfEWmso7hzEMgHa0/aoo65aT8enh8YW+S9wtmcjYO/c6jobwUSH66AfIFqSN7iMHOdxJQPuO3D4HYJjaW/fCadKhdFhEqDCJ/lTzg2urjoXS4k1MhsQk6SCYwQY1eNbKr/Zv7CUNog98BJ0kxOo5dXfIQGEOuKImtU= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790589434642735.8419588241046; Mon, 28 Sep 2026 02:57:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xB86e-0000XX-TL; Mon, 28 Sep 2026 05:57:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xB86d-0000X6-Hv for qemu-devel@nongnu.org; Mon, 28 Sep 2026 05:57:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xB86a-00009w-Rm for qemu-devel@nongnu.org; Mon, 28 Sep 2026 05:57:07 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-Rw9tR4cwOF2kJJvfrcMRBw-1; Mon, 28 Sep 2026 05:56:58 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1E3C318512F9; Mon, 28 Sep 2026 09:56:57 +0000 (UTC) Received: from berrange.csb (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D99791956087; Mon, 28 Sep 2026 09:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790589424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exX1zsK/mhQx+Jvfd/Qj5mA7V/LpOI3/0XJa9RPhC8k=; b=IYR/afskP1OokQhj1KAjLmhX9j38eQ4DgIl5v1RdCBPQiulE6D3nY9ajdEVmstUGEG8xVC wajXRKmDanTwzGLM057RUwjyqvyvscdPb+2dbNy0hTeWBZAFcQUgj5Hjh6QoMEGjSoPECK tsipBG8Hs1vfLuJN14lYJ21aI4mkXF4= X-MC-Unique: Rw9tR4cwOF2kJJvfrcMRBw-1 X-Mimecast-MFC-AGG-ID: Rw9tR4cwOF2kJJvfrcMRBw_1790589417 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: linux-cxl@vger.kernel.org, "Michael S. Tsirkin" , qemu-arm@nongnu.org, Junjie Cao , Peter Maydell , Anisa Su , Jonathan Cameron , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 2/2] hw/pci-bridge: split CXL PXB into separate file Date: Mon, 28 Sep 2026 10:56:46 +0100 Message-ID: <20260928095646.3555447-3-berrange@redhat.com> In-Reply-To: <20260928095646.3555447-1-berrange@redhat.com> References: <20260928095646.3555447-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-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: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1790589435311158500 If CONFIG_CXL=3Dn is added to the Kconfig, the build fails to link the PXB device: /usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in fu= nction `pxb_cxl_realize': /home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:2= 02:(.text+0x330): undefined reference to `cxl_component_register_block_init' /usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in fu= nction `pxb_cxl_dev_reset': /home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:3= 09:(.text+0x768): undefined reference to `cxl_component_register_init_commo= n' We cannot use CONFIG_CXL in pci_expander_bridge.c because the identifier is poisoned. Instead the CXL pieces must be split off into a separate source file which can be conditionally built. With this change, the stubs file is no longer required, since the code referencing the stub was already protected by CONFIG_CXL. Fixes: 6e4e3ae936 (hw/cxl/component: Implement host bridge MMIO (8.2.5, tab= le 142)) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/cxl/cxl-host.c | 2 +- hw/pci-bridge/meson.build | 4 +- hw/pci-bridge/pci_expander_bridge.c | 194 +---------------- hw/pci-bridge/pci_expander_bridge_common.h | 29 +++ hw/pci-bridge/pci_expander_bridge_cxl.c | 201 ++++++++++++++++++ hw/pci-bridge/pci_expander_bridge_stubs.c | 14 -- ...der_bridge.h =3D> pci_expander_bridge_cxl.h} | 0 7 files changed, 242 insertions(+), 202 deletions(-) create mode 100644 hw/pci-bridge/pci_expander_bridge_common.h create mode 100644 hw/pci-bridge/pci_expander_bridge_cxl.c delete mode 100644 hw/pci-bridge/pci_expander_bridge_stubs.c rename include/hw/pci-bridge/{pci_expander_bridge.h =3D> pci_expander_brid= ge_cxl.h} (100%) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index e279ce5fe3a..cda4dfed50d 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -20,7 +20,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" #include "hw/pci/pcie_port.h" -#include "hw/pci-bridge/pci_expander_bridge.h" +#include "hw/pci-bridge/pci_expander_bridge_cxl.h" =20 static void cxl_fixed_memory_window_config(CXLFixedMemoryWindowOptions *ob= ject, int index, Error **errp) diff --git a/hw/pci-bridge/meson.build b/hw/pci-bridge/meson.build index 2e0eb0d2332..aaeef64caaa 100644 --- a/hw/pci-bridge/meson.build +++ b/hw/pci-bridge/meson.build @@ -4,8 +4,8 @@ pci_ss.add(when: 'CONFIG_I82801B11', if_true: files('i82801= b11.c')) pci_ss.add(when: 'CONFIG_IOH3420', if_true: files('ioh3420.c')) pci_ss.add(when: 'CONFIG_PCIE_PORT', if_true: files('pcie_root_port.c', 'g= en_pcie_root_port.c')) pci_ss.add(when: 'CONFIG_PCIE_PCI_BRIDGE', if_true: files('pcie_pci_bridge= .c')) -pci_ss.add(when: 'CONFIG_PXB', if_true: files('pci_expander_bridge.c'), - if_false: files('pci_expander_bridge_stubs.= c')) +pci_ss.add(when: 'CONFIG_PXB', if_true: files('pci_expander_bridge.c')) +pci_ss.add(when: 'CONFIG_CXL', if_true: files('pci_expander_bridge_cxl.c')) pci_ss.add(when: 'CONFIG_XIO3130', if_true: files('xio3130_upstream.c', 'x= io3130_downstream.c')) pci_ss.add(when: 'CONFIG_CXL', if_true: files('cxl_root_port.c', 'cxl_upst= ream.c', 'cxl_downstream.c')) =20 diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index 40ffbc4e082..2498df480bd 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -18,57 +18,29 @@ #include "hw/pci/pcie_port.h" #include "hw/core/qdev-properties.h" #include "hw/pci/pci_bridge.h" -#include "hw/pci-bridge/pci_expander_bridge.h" -#include "hw/cxl/cxl.h" #include "qemu/range.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "system/numa.h" #include "hw/core/boards.h" #include "qom/object.h" - -enum BusType { PCI, PCIE, CXL }; +#include "pci_expander_bridge_common.h" =20 #define TYPE_PXB_BUS "pxb-bus" -typedef struct PXBBus PXBBus; + DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS, TYPE_PXB_BUS) =20 DECLARE_INSTANCE_CHECKER(PXBBus, PXB_PCIE_BUS, TYPE_PXB_PCIE_BUS) =20 -DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS, - TYPE_PXB_CXL_BUS) - -struct PXBBus { - /*< private >*/ - PCIBus parent_obj; - /*< public >*/ - - char bus_path[8]; -}; - OBJECT_DECLARE_SIMPLE_TYPE(PXBPCIEDev, PXB_PCIE_DEV) =20 static GList *pxb_dev_list; =20 #define TYPE_PXB_HOST "pxb-host" =20 -CXLComponentState *cxl_get_hb_cstate(PCIHostState *hb) -{ - CXLHost *host =3D PXB_CXL_HOST(hb); - - return &host->cxl_cstate; -} - -bool cxl_get_hb_passthrough(PCIHostState *hb) -{ - CXLHost *host =3D PXB_CXL_HOST(hb); - - return host->passthrough; -} - -static int pxb_bus_num(PCIBus *bus) +int pxb_bus_num(PCIBus *bus) { PXBDev *pxb =3D PXB_DEV(bus->parent_dev); =20 @@ -96,7 +68,7 @@ static void prop_pxb_uid_get(Object *obj, Visitor *v, con= st char *name, visit_type_uint32(v, name, &uid, errp); } =20 -static void pxb_bus_class_init(ObjectClass *class, const void *data) +void pxb_bus_class_init(ObjectClass *class, const void *data) { PCIBusClass *pbc =3D PCI_BUS_CLASS(class); =20 @@ -123,20 +95,11 @@ static const TypeInfo pxb_pcie_bus_info =3D { .class_init =3D pxb_bus_class_init, }; =20 -static const TypeInfo pxb_cxl_bus_info =3D { - .name =3D TYPE_PXB_CXL_BUS, - .parent =3D TYPE_CXL_BUS, - .instance_size =3D sizeof(PXBBus), - .class_init =3D pxb_bus_class_init, -}; - static const char *pxb_host_root_bus_path(PCIHostState *host_bridge, PCIBus *rootbus) { - PXBBus *bus =3D pci_bus_is_cxl(rootbus) ? - PXB_CXL_BUS(rootbus) : - pci_bus_is_express(rootbus) ? PXB_PCIE_BUS(rootbus) : - PXB_BUS(rootbus); + PXBBus *bus =3D pci_bus_is_express(rootbus) ? + PXB_PCIE_BUS(rootbus) : PXB_BUS(rootbus); =20 snprintf(bus->bus_path, 8, "0000:%02x", pxb_bus_num(rootbus)); return bus->bus_path; @@ -192,64 +155,6 @@ static const TypeInfo pxb_host_info =3D { .class_init =3D pxb_host_class_init, }; =20 -static void pxb_cxl_realize(DeviceState *dev, Error **errp) -{ - SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); - CXLHost *cxl =3D PXB_CXL_HOST(dev); - CXLComponentState *cxl_cstate =3D &cxl->cxl_cstate; - struct MemoryRegion *mr =3D &cxl_cstate->crb.component_registers; - - cxl_component_register_block_init(OBJECT(dev), cxl_cstate, - TYPE_PXB_CXL_HOST); - sysbus_init_mmio(sbd, mr); -} - -/* - * Host bridge realization has no means of knowning state associated - * with a particular machine. As such, it is nececssary to delay - * final setup of the host bridge register space until later in the - * machine bring up. - */ -void pxb_cxl_hook_up_registers(CXLState *cxl_state, PCIBus *bus, Error **e= rrp) -{ - 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; - - offset =3D memory_region_size(mr) * cxl_state->next_mr_idx; - if (offset > memory_region_size(&cxl_state->host_mr)) { - error_setg(errp, "Insufficient space for pxb cxl host register spa= ce"); - return; - } - - memory_region_add_subregion(&cxl_state->host_mr, offset, mr); - cxl_state->next_mr_idx++; -} - -static void pxb_cxl_host_class_init(ObjectClass *class, const void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(class); - PCIHostBridgeClass *hc =3D PCI_HOST_BRIDGE_CLASS(class); - - hc->root_bus_path =3D pxb_host_root_bus_path; - dc->fw_name =3D "cxl"; - dc->realize =3D pxb_cxl_realize; - /* Reason: Internal part of the pxb/pxb-pcie device, not usable by its= elf */ - dc->user_creatable =3D false; -} - -/* - * This is a device to handle the MMIO for a CXL host bridge. It does noth= ing - * else. - */ -static const TypeInfo cxl_host_info =3D { - .name =3D TYPE_PXB_CXL_HOST, - .parent =3D TYPE_PCI_HOST_BRIDGE, - .instance_size =3D sizeof(CXLHost), - .class_init =3D pxb_cxl_host_class_init, -}; =20 /* * Registers the PXB bus as a child of pci host root bus. @@ -297,34 +202,6 @@ static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) return pin - PCI_SLOT(pxb->devfn); } =20 -static void pxb_cxl_dev_reset(DeviceState *dev) -{ - 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; - uint32_t *write_msk =3D cxl_cstate->crb.cache_mem_regs_write_mask; - int dsp_count =3D 0; - - cxl_component_register_init_common(reg_state, write_msk, CXL2_RC, fals= e); - /* - * The CXL specification allows for host bridges with no HDM decoders - * if they only have a single root port. - */ - 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 */ - if (dsp_count =3D=3D 1) { - cxl->passthrough =3D true; - /* Set Capability ID in header to NONE */ - ARRAY_FIELD_DP32(reg_state, CXL_HDM_CAPABILITY_HEADER, ID, 0); - } else { - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, TARGET_COU= NT, - 8); - } -} - static gint pxb_compare(gconstpointer a, gconstpointer b) { const PXBDev *pxb_a =3D a, *pxb_b =3D b; @@ -334,8 +211,8 @@ static gint pxb_compare(gconstpointer a, gconstpointer = b) 0; } =20 -static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, - Error **errp) +bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, + Error **errp) { PXBDev *pxb =3D PXB_DEV(dev); DeviceState *ds, *bds =3D NULL; @@ -417,7 +294,7 @@ static void pxb_dev_realize(PCIDevice *dev, Error **err= p) pxb_dev_realize_common(dev, PCI, errp); } =20 -static void pxb_dev_exitfn(PCIDevice *pci_dev) +void pxb_dev_exitfn(PCIDevice *pci_dev) { PXBDev *pxb =3D PXB_DEV(pci_dev); =20 @@ -496,67 +373,14 @@ static const TypeInfo pxb_pcie_dev_info =3D { }, }; =20 -static void pxb_cxl_dev_realize(PCIDevice *dev, Error **errp) -{ - /* A CXL PXB's parent bus is still PCIe */ - if (!pci_bus_is_express(pci_get_bus(dev))) { - error_setg(errp, "pxb-cxl devices cannot reside on a PCI bus"); - return; - } - - if (!pxb_dev_realize_common(dev, CXL, errp)) { - return; - } - pxb_cxl_dev_reset(DEVICE(dev)); -} - -static const Property pxb_cxl_dev_properties[] =3D { - DEFINE_PROP_BOOL("hdm_for_passthrough", PXBCXLDev, hdm_for_passthrough= , false), -}; - -static void pxb_cxl_dev_class_init(ObjectClass *klass, const void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); - - k->realize =3D pxb_cxl_dev_realize; - k->exit =3D pxb_dev_exitfn; - /* - * XXX: These types of bridges don't actually show up in the hierarchy= so - * vendor, device, class, etc. ids are intentionally left out. - */ - - dc->desc =3D "CXL Host Bridge"; - device_class_set_props(dc, pxb_cxl_dev_properties); - set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); - - /* Host bridges aren't hotpluggable. FIXME: spec reference */ - dc->hotpluggable =3D false; - device_class_set_legacy_reset(dc, pxb_cxl_dev_reset); -} - -static const TypeInfo pxb_cxl_dev_info =3D { - .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 - (const InterfaceInfo[]){ - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - {}, - }, -}; =20 static void pxb_register_types(void) { type_register_static(&pxb_bus_info); type_register_static(&pxb_pcie_bus_info); - type_register_static(&pxb_cxl_bus_info); type_register_static(&pxb_host_info); - type_register_static(&cxl_host_info); type_register_static(&pxb_dev_info); type_register_static(&pxb_pcie_dev_info); - type_register_static(&pxb_cxl_dev_info); } =20 type_init(pxb_register_types) diff --git a/hw/pci-bridge/pci_expander_bridge_common.h b/hw/pci-bridge/pci= _expander_bridge_common.h new file mode 100644 index 00000000000..fc5d1ac8691 --- /dev/null +++ b/hw/pci-bridge/pci_expander_bridge_common.h @@ -0,0 +1,29 @@ +/* + * PCI Expander Bridge Device Emulation Common Code + * + * Copyright (C) 2015 Red Hat Inc + * + * Authors: + * Marcel Apfelbaum + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +enum BusType { PCI, PCIE, CXL }; + +typedef struct PXBBus PXBBus; + +struct PXBBus { + /*< private >*/ + PCIBus parent_obj; + /*< public >*/ + + char bus_path[8]; +}; + +int pxb_bus_num(PCIBus *bus); +void pxb_bus_class_init(ObjectClass *class, const void *data); +bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, + Error **errp); +void pxb_dev_exitfn(PCIDevice *pci_dev); diff --git a/hw/pci-bridge/pci_expander_bridge_cxl.c b/hw/pci-bridge/pci_ex= pander_bridge_cxl.c new file mode 100644 index 00000000000..3294baeaf99 --- /dev/null +++ b/hw/pci-bridge/pci_expander_bridge_cxl.c @@ -0,0 +1,201 @@ +/* + * CXL PCI Expander Bridge Device Emulation + * + * Copyright (C) 2015 Red Hat Inc + * + * Authors: + * Marcel Apfelbaum + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" +#include "hw/pci/pci_bridge.h" +#include "hw/pci/pcie_port.h" +#include "hw/core/qdev-properties.h" +#include "hw/pci-bridge/pci_expander_bridge_cxl.h" +#include "qom/object.h" +#include "pci_expander_bridge_common.h" + +DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS, + TYPE_PXB_CXL_BUS) + +CXLComponentState *cxl_get_hb_cstate(PCIHostState *hb) +{ + CXLHost *host =3D PXB_CXL_HOST(hb); + + return &host->cxl_cstate; +} + +bool cxl_get_hb_passthrough(PCIHostState *hb) +{ + CXLHost *host =3D PXB_CXL_HOST(hb); + + return host->passthrough; +} + +static const char *pxb_cxl_host_root_bus_path(PCIHostState *host_bridge, + PCIBus *rootbus) +{ + PXBBus *bus =3D PXB_CXL_BUS(rootbus); + snprintf(bus->bus_path, 8, "0000:%02x", pxb_bus_num(rootbus)); + return bus->bus_path; +} + + +static const TypeInfo pxb_cxl_bus_info =3D { + .name =3D TYPE_PXB_CXL_BUS, + .parent =3D TYPE_CXL_BUS, + .instance_size =3D sizeof(PXBBus), + .class_init =3D pxb_bus_class_init, +}; + +static void pxb_cxl_realize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + CXLHost *cxl =3D PXB_CXL_HOST(dev); + CXLComponentState *cxl_cstate =3D &cxl->cxl_cstate; + struct MemoryRegion *mr =3D &cxl_cstate->crb.component_registers; + + cxl_component_register_block_init(OBJECT(dev), cxl_cstate, + TYPE_PXB_CXL_HOST); + sysbus_init_mmio(sbd, mr); +} + +/* + * Host bridge realization has no means of knowning state associated + * with a particular machine. As such, it is nececssary to delay + * final setup of the host bridge register space until later in the + * machine bring up. + */ +void pxb_cxl_hook_up_registers(CXLState *cxl_state, PCIBus *bus, Error **e= rrp) +{ + 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; + + offset =3D memory_region_size(mr) * cxl_state->next_mr_idx; + if (offset > memory_region_size(&cxl_state->host_mr)) { + error_setg(errp, "Insufficient space for pxb cxl host register spa= ce"); + return; + } + + memory_region_add_subregion(&cxl_state->host_mr, offset, mr); + cxl_state->next_mr_idx++; +} + +static void pxb_cxl_host_class_init(ObjectClass *class, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + PCIHostBridgeClass *hc =3D PCI_HOST_BRIDGE_CLASS(class); + + hc->root_bus_path =3D pxb_cxl_host_root_bus_path; + dc->fw_name =3D "cxl"; + dc->realize =3D pxb_cxl_realize; + /* Reason: Internal part of the pxb/pxb-pcie device, not usable by its= elf */ + dc->user_creatable =3D false; +} + +/* + * This is a device to handle the MMIO for a CXL host bridge. It does noth= ing + * else. + */ +static const TypeInfo cxl_host_info =3D { + .name =3D TYPE_PXB_CXL_HOST, + .parent =3D TYPE_PCI_HOST_BRIDGE, + .instance_size =3D sizeof(CXLHost), + .class_init =3D pxb_cxl_host_class_init, +}; + +static void pxb_cxl_dev_reset(DeviceState *dev) +{ + 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; + uint32_t *write_msk =3D cxl_cstate->crb.cache_mem_regs_write_mask; + int dsp_count =3D 0; + + cxl_component_register_init_common(reg_state, write_msk, CXL2_RC, fals= e); + /* + * The CXL specification allows for host bridges with no HDM decoders + * if they only have a single root port. + */ + 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 */ + if (dsp_count =3D=3D 1) { + cxl->passthrough =3D true; + /* Set Capability ID in header to NONE */ + ARRAY_FIELD_DP32(reg_state, CXL_HDM_CAPABILITY_HEADER, ID, 0); + } else { + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, TARGET_COU= NT, + 8); + } +} + +static void pxb_cxl_dev_realize(PCIDevice *dev, Error **errp) +{ + /* A CXL PXB's parent bus is still PCIe */ + if (!pci_bus_is_express(pci_get_bus(dev))) { + error_setg(errp, "pxb-cxl devices cannot reside on a PCI bus"); + return; + } + + if (!pxb_dev_realize_common(dev, CXL, errp)) { + return; + } + pxb_cxl_dev_reset(DEVICE(dev)); +} + +static const Property pxb_cxl_dev_properties[] =3D { + DEFINE_PROP_BOOL("hdm_for_passthrough", PXBCXLDev, hdm_for_passthrough= , false), +}; + +static void pxb_cxl_dev_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->realize =3D pxb_cxl_dev_realize; + k->exit =3D pxb_dev_exitfn; + /* + * XXX: These types of bridges don't actually show up in the hierarchy= so + * vendor, device, class, etc. ids are intentionally left out. + */ + + dc->desc =3D "CXL Host Bridge"; + device_class_set_props(dc, pxb_cxl_dev_properties); + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + + /* Host bridges aren't hotpluggable. FIXME: spec reference */ + dc->hotpluggable =3D false; + device_class_set_legacy_reset(dc, pxb_cxl_dev_reset); +} + +static const TypeInfo pxb_cxl_dev_info =3D { + .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 + (const InterfaceInfo[]){ + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + {}, + }, +}; + +static void pxb_cxl_register_types(void) +{ + type_register_static(&pxb_cxl_bus_info); + type_register_static(&cxl_host_info); + type_register_static(&pxb_cxl_dev_info); +} + +type_init(pxb_cxl_register_types) diff --git a/hw/pci-bridge/pci_expander_bridge_stubs.c b/hw/pci-bridge/pci_= expander_bridge_stubs.c deleted file mode 100644 index b35180311f6..00000000000 --- a/hw/pci-bridge/pci_expander_bridge_stubs.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-2.0-or-later - * - * Stubs for calls made from machines to handle the case where CONFIG_PXB - * is not enabled. - */ -#include "qemu/osdep.h" -#include "qapi/error.h" -#include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" -#include "hw/pci-bridge/pci_expander_bridge.h" -#include "hw/cxl/cxl.h" - -void pxb_cxl_hook_up_registers(CXLState *state, PCIBus *bus, Error **errp)= {}; diff --git a/include/hw/pci-bridge/pci_expander_bridge.h b/include/hw/pci-b= ridge/pci_expander_bridge_cxl.h similarity index 100% rename from include/hw/pci-bridge/pci_expander_bridge.h rename to include/hw/pci-bridge/pci_expander_bridge_cxl.h --=20 2.55.0