* [QEMU PATCH 0/1] CXL: Enable FMAPI Add for MHSLDs
@ 2025-09-27 0:18 anisa.su887
2025-09-27 0:18 ` [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD anisa.su887
0 siblings, 1 reply; 4+ messages in thread
From: anisa.su887 @ 2025-09-27 0:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Jonathan.Cameron, dave, linux-cxl, Anisa Su
From: Anisa Su <anisa.su@samsung.com>
This patch adds support for FMAPI Initiate Add command (5604h) for MHSLDs. It
is based on the following branch:
https://gitlab.com/jic23/qemu/-/tree/cxl-2025-07-03
This code was tested by starting 2 VMs, host_1, which initializes the MHSLD, and
host_2, with the following topologies, then sending the FMAPI command from both
hosts.
host_1 = "-device usb-ehci,id=ehci \
-object memory-backend-file,id=cxl-mem1,mem-path=/tmp/t3_cxl1.raw,size=4G \
-object memory-backend-file,id=cxl-lsa1,mem-path=/tmp/t3_lsa1.raw,size=1M \
-device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1,hdm_for_passthrough=true \
-device cxl-rp,port=0,bus=cxl.1,id=cxl_rp_port0,chassis=0,slot=2 \
-device cxl-mhsld,bus=cxl_rp_port0,num-dc-regions=2,volatile-dc-memdev=cxl-mem1,id=cxl-mhd0,sn=99,mhd-head=0,mhd-state_file=mhd_metadata,mhd-init=true \
-device usb-cxl-mctp,bus=ehci.0,id=usb0,target=cxl-mhd0\
-machine cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=1k"
host_2 = "-device usb-ehci,id=ehci \
-object memory-backend-file,id=cxl-mem1,mem-path=/tmp/t3_cxl1.raw,size=4G \
-object memory-backend-file,id=cxl-lsa1,mem-path=/tmp/t3_lsa1.raw,size=1M \
-device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1,hdm_for_passthrough=true \
-device cxl-rp,port=0,bus=cxl.1,id=cxl_rp_port0,chassis=0,slot=2 \
-device cxl-mhsld,bus=cxl_rp_port0,num-dc-regions=2,volatile-dc-memdev=cxl-mem1,id=cxl-mhd0,sn=99,mhd-head=1,mhd-state_file=mhd_metadata,mhd-init=false \
-device usb-cxl-mctp,bus=ehci.0,id=usb0,target=cxl-mhd0\
-machine cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=1k"
libcxlmi is cloned on both hosts and used to send the FMAPI add/release commands
from both host_1 and host_2 and the expected behavior is verified by printing
the response payload from the Get DC Region Lists command (5603h).
The following interactive program from libcxlmi is
used to do so: https://github.com/computexpresslink/libcxlmi/blob/main/examples/fmapi-mctp.c
Question:
Currently, the input payload to FMAPI Init Add contains an array of CXLDCExtentRaw
elements. The mshld_reserve_extents() function expects a pointer of type
CxlDynamicCapacityExtentList, so a loop is introduced to convert CXLDCExtentRaw[]
to CxlDynamicCapacityExtentList.
I am wondering why the typedefs for extents/extent list in qapi-types-cxl.h
are separate from the typedefs in cxl_device.h? Is there a nice way to avoid
introducing a loop here just to convert types here?
Anisa Su (1):
hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD
hw/cxl/cxl-mailbox-utils.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD
2025-09-27 0:18 [QEMU PATCH 0/1] CXL: Enable FMAPI Add for MHSLDs anisa.su887
@ 2025-09-27 0:18 ` anisa.su887
2025-10-28 16:21 ` Jonathan Cameron via
0 siblings, 1 reply; 4+ messages in thread
From: anisa.su887 @ 2025-09-27 0:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Jonathan.Cameron, dave, linux-cxl, Anisa Su
From: Anisa Su <anisa.su@samsung.com>
Call mhd_reserve_extents in FMAPI Init Add (5604h)to enable sending
FMAPI Add command to MHSLD.
Signed-off-by: Anisa Su <anisa.su@samsung.com>
---
hw/cxl/cxl-mailbox-utils.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index c5177dfd92..9ac60db4e1 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -24,6 +24,7 @@
#include "system/hostmem.h"
#include "qemu/range.h"
#include "qapi/qapi-types-cxl.h"
+#include "hw/cxl/mhsld/mhsld.h"
#define CXL_CAPACITY_MULTIPLIER (256 * MiB)
#define CXL_DC_EVENT_LOG_SIZE 8
@@ -4163,6 +4164,8 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
CXLDCExtentRaw extents[];
} QEMU_PACKED *in = (void *)payload_in;
CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
+ CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d);
+ CXLDCRegion *region = &ct3d->dc.regions[in->reg_num];
int i, rc;
switch (in->selection_policy) {
@@ -4201,6 +4204,28 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
return rc;
}
+ /* If this is an MHD, attempt to reserve the extents */
+ if (cvc->mhd_reserve_extents) {
+ g_autofree CxlDynamicCapacityExtentList *records =
+ g_malloc0(in->ext_count * sizeof(*records));
+ g_autofree CxlDynamicCapacityExtent *dc_exts =
+ g_malloc0(in->ext_count * sizeof(*dc_exts));
+
+ for (i = 0; i < in->ext_count; i++) {
+ CxlDynamicCapacityExtent *value = &dc_exts[i];
+ value->offset =
+ in->extents[i].start_dpa - region->base;
+ value->len = in->extents[i].len;
+
+ records[i].value = value;
+ records[i].next = &records[i + 1];
+ }
+ records[in->ext_count - 1].next = NULL;
+ if (!cvc->mhd_reserve_extents(&ct3d->parent_obj, records, in->reg_num)) {
+ return CXL_MBOX_INVALID_INPUT;
+ }
+ }
+
CXLDCExtentGroup *group = NULL;
for (i = 0; i < in->ext_count; i++) {
CXLDCExtentRaw *ext = &in->extents[i];
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD
2025-09-27 0:18 ` [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD anisa.su887
@ 2025-10-28 16:21 ` Jonathan Cameron via
2025-10-28 16:56 ` Anisa Su
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron via @ 2025-10-28 16:21 UTC (permalink / raw)
To: anisa.su887; +Cc: qemu-devel, dave, linux-cxl, Anisa Su
On Sat, 27 Sep 2025 00:18:07 +0000
anisa.su887@gmail.com wrote:
> From: Anisa Su <anisa.su@samsung.com>
>
> Call mhd_reserve_extents in FMAPI Init Add (5604h)to enable sending
> FMAPI Add command to MHSLD.
>
> Signed-off-by: Anisa Su <anisa.su@samsung.com>
Hi Anisa,
I've not been quick on this one partly because it sits on top of the MHSLD
work that I think needs a proper revisit to establish what is an up streamable
path, but I haven't had time to do that :(
Anyhow in meantime I'll take a look. I suppose nothing stops me carrying
this on top.
Just one minor comment inline.
> ---
> hw/cxl/cxl-mailbox-utils.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index c5177dfd92..9ac60db4e1 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -24,6 +24,7 @@
> #include "system/hostmem.h"
> #include "qemu/range.h"
> #include "qapi/qapi-types-cxl.h"
> +#include "hw/cxl/mhsld/mhsld.h"
>
> #define CXL_CAPACITY_MULTIPLIER (256 * MiB)
> #define CXL_DC_EVENT_LOG_SIZE 8
> @@ -4163,6 +4164,8 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
> CXLDCExtentRaw extents[];
> } QEMU_PACKED *in = (void *)payload_in;
> CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
> + CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d);
> + CXLDCRegion *region = &ct3d->dc.regions[in->reg_num];
> int i, rc;
>
> switch (in->selection_policy) {
> @@ -4201,6 +4204,28 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
> return rc;
> }
>
> + /* If this is an MHD, attempt to reserve the extents */
> + if (cvc->mhd_reserve_extents) {
> + g_autofree CxlDynamicCapacityExtentList *records =
> + g_malloc0(in->ext_count * sizeof(*records));
I think it makes sense to use g_malloc0_n for these
I changed this whilst applying it locally so it'll be there next time
I push out a tree.
Thanks,
Jonathan
> + g_autofree CxlDynamicCapacityExtent *dc_exts =
> + g_malloc0(in->ext_count * sizeof(*dc_exts));
> +
> + for (i = 0; i < in->ext_count; i++) {
> + CxlDynamicCapacityExtent *value = &dc_exts[i];
> + value->offset =
> + in->extents[i].start_dpa - region->base;
> + value->len = in->extents[i].len;
> +
> + records[i].value = value;
> + records[i].next = &records[i + 1];
> + }
> + records[in->ext_count - 1].next = NULL;
> + if (!cvc->mhd_reserve_extents(&ct3d->parent_obj, records, in->reg_num)) {
> + return CXL_MBOX_INVALID_INPUT;
> + }
> + }
> +
> CXLDCExtentGroup *group = NULL;
> for (i = 0; i < in->ext_count; i++) {
> CXLDCExtentRaw *ext = &in->extents[i];
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD
2025-10-28 16:21 ` Jonathan Cameron via
@ 2025-10-28 16:56 ` Anisa Su
0 siblings, 0 replies; 4+ messages in thread
From: Anisa Su @ 2025-10-28 16:56 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: anisa.su887, qemu-devel, dave, linux-cxl
> Tue, Oct 28, 2025 at 04:21:00PM +0000, Jonathan Cameron wrote:
> On Sat, 27 Sep 2025 00:18:07 +0000
> anisa.su887@gmail.com wrote:
>
> > From: Anisa Su <anisa.su@samsung.com>
> >
> > Call mhd_reserve_extents in FMAPI Init Add (5604h)to enable sending
> > FMAPI Add command to MHSLD.
> >
> > Signed-off-by: Anisa Su <anisa.su@samsung.com>
> Hi Anisa,
>
> I've not been quick on this one partly because it sits on top of the MHSLD
> work that I think needs a proper revisit to establish what is an up streamable
> path, but I haven't had time to do that :(
>
> Anyhow in meantime I'll take a look. I suppose nothing stops me carrying
> this on top.
>
> Just one minor comment inline.
> > ---
> > hw/cxl/cxl-mailbox-utils.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> > index c5177dfd92..9ac60db4e1 100644
> > --- a/hw/cxl/cxl-mailbox-utils.c
> > +++ b/hw/cxl/cxl-mailbox-utils.c
> > @@ -24,6 +24,7 @@
> > #include "system/hostmem.h"
> > #include "qemu/range.h"
> > #include "qapi/qapi-types-cxl.h"
> > +#include "hw/cxl/mhsld/mhsld.h"
> >
> > #define CXL_CAPACITY_MULTIPLIER (256 * MiB)
> > #define CXL_DC_EVENT_LOG_SIZE 8
> > @@ -4163,6 +4164,8 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
> > CXLDCExtentRaw extents[];
> > } QEMU_PACKED *in = (void *)payload_in;
> > CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
> > + CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d);
> > + CXLDCRegion *region = &ct3d->dc.regions[in->reg_num];
> > int i, rc;
> >
> > switch (in->selection_policy) {
> > @@ -4201,6 +4204,28 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd,
> > return rc;
> > }
> >
> > + /* If this is an MHD, attempt to reserve the extents */
> > + if (cvc->mhd_reserve_extents) {
> > + g_autofree CxlDynamicCapacityExtentList *records =
> > + g_malloc0(in->ext_count * sizeof(*records));
>
> I think it makes sense to use g_malloc0_n for these
>
> I changed this whilst applying it locally so it'll be there next time
> I push out a tree.
>
> Thanks,
>
> Jonathan
>
Gotcha, thanks Jonathan :D
- Anisa
>
> > + g_autofree CxlDynamicCapacityExtent *dc_exts =
> > + g_malloc0(in->ext_count * sizeof(*dc_exts));
> > +
> > + for (i = 0; i < in->ext_count; i++) {
> > + CxlDynamicCapacityExtent *value = &dc_exts[i];
> > + value->offset =
> > + in->extents[i].start_dpa - region->base;
> > + value->len = in->extents[i].len;
> > +
> > + records[i].value = value;
> > + records[i].next = &records[i + 1];
> > + }
> > + records[in->ext_count - 1].next = NULL;
> > + if (!cvc->mhd_reserve_extents(&ct3d->parent_obj, records, in->reg_num)) {
> > + return CXL_MBOX_INVALID_INPUT;
> > + }
> > + }
> > +
> > CXLDCExtentGroup *group = NULL;
> > for (i = 0; i < in->ext_count; i++) {
> > CXLDCExtentRaw *ext = &in->extents[i];
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-28 16:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-27 0:18 [QEMU PATCH 0/1] CXL: Enable FMAPI Add for MHSLDs anisa.su887
2025-09-27 0:18 ` [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD anisa.su887
2025-10-28 16:21 ` Jonathan Cameron via
2025-10-28 16:56 ` Anisa Su
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).