From: Ira Weiny <ira.weiny@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org,
Dave Jiang <dave.jiang@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Ira Weiny <ira.weiny@intel.com>
Subject: [PATCH RFC 3/5] hw/cxl: Derive a CXL accelerator device from Type-3
Date: Wed, 17 May 2023 19:45:56 -0700 [thread overview]
Message-ID: <20230517-rfc-type2-dev-v1-3-6eb2e470981b@intel.com> (raw)
In-Reply-To: <20230517-rfc-type2-dev-v1-0-6eb2e470981b@intel.com>
It is desirable to have a test accelerator device to present various
accelerator features such as Back-Invalidate (BI) registers to OS
software for testing.
BI accelerator devices require memory that can be easily modeled as a
sub-class of Type-3 device.
Derive 'cxl-accel' from cxl-type3. Add documentation for such a device.
Follow on patches will add BI registers and other simulation of the
accelerator device.
Adding devices qemu can be done with the following example:
...
-device cxl-accel,bus=sw0p0,volatile-memdev=cxl-ac-mem5,id=cxl-dev5,sn=0xCAFE0005
...
Not-Yet-Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
The device ID and class code are completely made up by me. As discussed
in the last community call perhaps these could be declared in some more
official capacity?
---
docs/system/devices/cxl.rst | 11 +++++++++++
hw/mem/cxl_type3.c | 28 ++++++++++++++++++++++++++++
include/hw/cxl/cxl_device.h | 16 ++++++++++++++++
include/hw/pci/pci_ids.h | 1 +
4 files changed, 56 insertions(+)
diff --git a/docs/system/devices/cxl.rst b/docs/system/devices/cxl.rst
index 95900252c56a..5bc931be44b3 100644
--- a/docs/system/devices/cxl.rst
+++ b/docs/system/devices/cxl.rst
@@ -321,6 +321,17 @@ A very simple setup with just one directly attached CXL Type 3 Volatile Memory d
-device cxl-type3,bus=root_port13,volatile-memdev=vmem0,id=cxl-vmem0 \
-M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=4G
+A very simple setup with just one directly attached CXL Type 2 Volatile Memory
+Accelerator device::
+
+ qemu-system-x86_64 -M q35,cxl=on -m 4G,maxmem=8G,slots=8 -smp 4 \
+ ...
+ -object memory-backend-ram,id=vmem0,share=on,size=256M \
+ -device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1 \
+ -device cxl-rp,port=0,bus=cxl.1,id=root_port13,chassis=0,slot=2 \
+ -device cxl-accel,bus=root_port13,volatile-memdev=vmem0,id=cxl-accel0 \
+ -M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=4G
+
The same volatile setup may optionally include an LSA region::
qemu-system-aarch64 -M virt,gic-version=3,cxl=on -m 4g,maxmem=8G,slots=8 -cpu max \
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index 3e63dbd83551..c7eafd76d1ea 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -1691,3 +1691,31 @@ static void ct3d_registers(void)
}
type_init(ct3d_registers);
+
+static void cxl_accel_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
+
+ pc->class_id = PCI_CLASS_CXL_QEMU_ACCEL;
+ pc->vendor_id = PCI_VENDOR_ID_INTEL;
+ pc->device_id = 0xd94; /* LVF for now */
+ pc->revision = 1;
+
+ dc->desc = "CXL Accelerator Device (Type 2)";
+}
+
+static const TypeInfo cxl_accel_dev_info = {
+ .name = TYPE_CXL_ACCEL,
+ .parent = TYPE_CXL_TYPE3,
+ .class_size = sizeof(struct CXLAccelClass),
+ .class_init = cxl_accel_class_init,
+ .instance_size = sizeof(CXLAccelDev),
+};
+
+static void cxl_accel_dev_registers(void)
+{
+ type_register_static(&cxl_accel_dev_info);
+}
+
+type_init(cxl_accel_dev_registers);
diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
index cd7f28dba884..f7f6688ee6e2 100644
--- a/include/hw/cxl/cxl_device.h
+++ b/include/hw/cxl/cxl_device.h
@@ -432,6 +432,22 @@ struct CXLType3Class {
bool (*set_cacheline)(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t *data);
};
+/*
+ * Accel devices are a type3 device but with additional functionality.
+ */
+struct CXLAccelDev {
+ /* Private: Must be first */
+ CXLType3Dev parent_obj;
+};
+
+struct CXLAccelClass {
+ /* Private: Must be first */
+ CXLType3Class parent_class;
+};
+
+#define TYPE_CXL_ACCEL "cxl-accel"
+OBJECT_DECLARE_TYPE(CXLAccelDev, CXLAccelClass, CXL_ACCEL)
+
struct CSWMBCCIDev {
PCIDevice parent_obj;
CXLComponentState cxl_cstate;
diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
index e4386ebb2038..2dbf350ebba4 100644
--- a/include/hw/pci/pci_ids.h
+++ b/include/hw/pci/pci_ids.h
@@ -54,6 +54,7 @@
#define PCI_CLASS_MEMORY_RAM 0x0500
#define PCI_CLASS_MEMORY_FLASH 0x0501
#define PCI_CLASS_MEMORY_CXL 0x0502
+#define PCI_CLASS_CXL_QEMU_ACCEL 0x0503
#define PCI_CLASS_MEMORY_OTHER 0x0580
#define PCI_BASE_CLASS_BRIDGE 0x06
--
2.40.0
next prev parent reply other threads:[~2023-05-18 2:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-18 2:45 [PATCH RFC 0/5] hw/cxl: Type 2 Device RFC Ira Weiny
2023-05-18 2:45 ` [PATCH RFC 1/5] hw/cxl: Use define for build bug detection Ira Weiny
2023-05-18 9:54 ` Jonathan Cameron via
2023-05-18 20:19 ` Ira Weiny
2023-05-19 15:14 ` Jonathan Cameron via
2023-05-23 14:18 ` Ira Weiny
2023-05-18 2:45 ` [PATCH RFC 2/5] hw/cxl: Refactor component register initialization Ira Weiny
2023-05-18 2:45 ` Ira Weiny [this message]
2023-05-18 2:45 ` [PATCH RFC 4/5] hw/cxl/accel: Add Back-Invalidate decoder capbility structure Ira Weiny
2023-05-18 2:45 ` [PATCH RFC 5/5] hw/cxl: Add UIO HDM decoder register fields Ira Weiny
2024-10-17 16:57 ` [PATCH RFC 0/5] hw/cxl: Type 2 Device RFC Cédric Le Goater
2024-10-18 14:49 ` Zhi Wang
2024-10-18 15:25 ` Alejandro Lucero Palau
2024-10-18 16:19 ` Jonathan Cameron via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230517-rfc-type2-dev-v1-3-6eb2e470981b@intel.com \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).