qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: anisa.su887@gmail.com
To: qemu-devel@nongnu.org
Cc: Jonathan.Cameron@huawei.com, dave@stgolabs.net,
	linux-cxl@vger.kernel.org, Anisa Su <anisa.su@samsung.com>
Subject: [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD
Date: Sat, 27 Sep 2025 00:18:07 +0000	[thread overview]
Message-ID: <20250927002125.860668-2-anisa.su887@gmail.com> (raw)
In-Reply-To: <20250927002125.860668-1-anisa.su887@gmail.com>

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



  reply	other threads:[~2025-09-27  0:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-27  0:18 [QEMU PATCH 0/1] CXL: Enable FMAPI Add for MHSLDs anisa.su887
2025-09-27  0:18 ` anisa.su887 [this message]
2025-10-28 16:21   ` [QEMU PATCH 1/1] hw/cxl/cxl-mailbox-utils: Enable FMAPI Initiate Add for MHSLD Jonathan Cameron via
2025-10-28 16:56     ` Anisa Su

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=20250927002125.860668-2-anisa.su887@gmail.com \
    --to=anisa.su887@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=anisa.su@samsung.com \
    --cc=dave@stgolabs.net \
    --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).