qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Zhi Wang <zhiw@nvidia.com>
Cc: <qemu-devel@nongnu.org>, <dan.j.williams@intel.com>,
	<dave.jiang@intel.com>, <ira.weiny@intel.com>,
	<fan.ni@samsung.com>, <alex.williamson@redhat.com>,
	<alucerop@amd.com>, <clg@redhat.com>, <acurrid@nvidia.com>,
	<cjia@nvidia.com>, <smitra@nvidia.com>, <ankita@nvidia.com>,
	<aniketa@nvidia.com>, <kwankhede@nvidia.com>,
	<targupta@nvidia.com>, <zhiwang@kernel.org>
Subject: Re: [PATCH 3/3] hw/cxl: introduce CXL type-2 device emulation
Date: Tue, 21 Jan 2025 16:16:10 +0000	[thread overview]
Message-ID: <20250121161610.000025af@huawei.com> (raw)
In-Reply-To: <20241212130422.69380-4-zhiw@nvidia.com>

On Thu, 12 Dec 2024 05:04:22 -0800
Zhi Wang <zhiw@nvidia.com> wrote:

> From: Zhi Wang <zhiwang@kernel.org>
> 
> Introduce a CXL type-2 device emulation that provides a minimum base for
> testing kernel CXL core type-2 support and CXL type-2 virtualization. It
> is also a good base for introducing the more emulated features.
> 
> Currently, it only supports:
> 
> - Emulating component registers with HDM decoders.
> - Volatile memory backend and emualtion of region access.
> 
> The emulation is aimed to not tightly coupled with the current CXL type-3
> emulation since many advanced CXL type-3 emulation features are not
> implemented in a CXL type-2 device.
> 
> Co-developed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Zhi Wang <zhiwang@kernel.org>

Hi Zhi,

A few passing comments.

Jonathan

> diff --git a/hw/mem/cxl_accel.c b/hw/mem/cxl_accel.c
> new file mode 100644
> index 0000000000..770072126d
> --- /dev/null
> +++ b/hw/mem/cxl_accel.c
> @@ -0,0 +1,319 @@

> +
> +static void update_dvsecs(CXLAccelDev *acceld)

Just to make them easier to search for and void clashes, good to prefix
all functions with cxlacc or something like that.

> +{

/...


> +static Property cxl_accel_props[] = {
> +    DEFINE_PROP_LINK("volatile-memdev", CXLAccelDev, hostvmem,
> +                     TYPE_MEMORY_BACKEND, HostMemoryBackend *),

Does backing a type 2 device with a memdev provide any advantages?
I'd have thought a device specific memory allocation would make more
sense, like we'd do for a memory BAR on a PCI device.  That might
complicate the cxl-host handling though so perhaps this is a good
way to go for now.


> +    DEFINE_PROP_END_OF_LIST(),

When you get time, rebase as these have gone away recently.
I aim to get a fresher staging tree out shortly.

> +};
> +
> +static void cxl_accel_class_init(ObjectClass *oc, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +    PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc);
> +
> +    pc->realize = cxl_accel_realize;
> +    pc->exit = cxl_accel_exit;
> +
> +    pc->class_id = PCI_CLASS_CXL_QEMU_ACCEL;
> +    pc->vendor_id = PCI_VENDOR_ID_INTEL;
> +    pc->device_id = 0xd94;

If you are posting these I hope you have those IDs reserved
(which seems unlikely ;)
We need to be absolutely sure we never hit an existing ID which generally
means you need to find whoever controls those allocations in your company
and get them to give you an ID for this.

> +    pc->revision = 1;
> +
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> +    dc->desc = "CXL Accelerator Device (Type 2)";
> +    device_class_set_legacy_reset(dc, cxl_accel_reset);
> +    device_class_set_props(dc, cxl_accel_props);
> +}

>  void cxl_event_init(CXLDeviceState *cxlds, int start_msg_num);
> diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
> index f1a53fea8d..08bc469316 100644
> --- a/include/hw/pci/pci_ids.h
> +++ b/include/hw/pci/pci_ids.h
> @@ -55,6 +55,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

Either this is a real device class (which seems unlikely given the name)
or you need to choose something else.  PCI maintains a big list of
class codes and currently 0x0502 is the highest one define in baseclass 05h
(memory controllers)

https://members.pcisig.com/wg/PCI-SIG/document/20113
(behind a pcisig login)

>  #define PCI_CLASS_MEMORY_OTHER           0x0580
>  
>  #define PCI_BASE_CLASS_BRIDGE            0x06



  parent reply	other threads:[~2025-01-21 16:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 13:04 [PATCH 0/3] Introduce CXL type-2 device emulation Zhi Wang
2024-12-12 13:04 ` [PATCH 1/3] hw/cxl: factor out cxl_host_addr_to_dpa() Zhi Wang
2025-01-21 15:52   ` Jonathan Cameron via
2024-12-12 13:04 ` [PATCH 2/3] hw/cxl: introduce cxl_component_update_dvsec() Zhi Wang
2025-01-21 15:57   ` Jonathan Cameron via
2024-12-12 13:04 ` [PATCH 3/3] hw/cxl: introduce CXL type-2 device emulation Zhi Wang
2024-12-12 17:02   ` Alejandro Lucero Palau
2024-12-12 18:33     ` Zhi Wang
2025-01-21 16:16   ` Jonathan Cameron via [this message]
2025-01-31 10:45     ` Zhi Wang
2025-01-31 11:52       ` Jonathan Cameron via
2024-12-12 16:49 ` [PATCH 0/3] Introduce " Alejandro Lucero Palau
2024-12-12 18:10   ` Zhi Wang
2025-01-21 15:34     ` Jonathan Cameron via
2025-01-31 10:37       ` Zhi Wang

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=20250121161610.000025af@huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=acurrid@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=alucerop@amd.com \
    --cc=aniketa@nvidia.com \
    --cc=ankita@nvidia.com \
    --cc=cjia@nvidia.com \
    --cc=clg@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=fan.ni@samsung.com \
    --cc=ira.weiny@intel.com \
    --cc=kwankhede@nvidia.com \
    --cc=smitra@nvidia.com \
    --cc=targupta@nvidia.com \
    --cc=zhiw@nvidia.com \
    --cc=zhiwang@kernel.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).