From: Richard Cheng <icheng@nvidia.com>
To: dave@stgolabs.net, jonathan.cameron@huawei.com,
dave.jiang@intel.com, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
newtonl@nvidia.com, kristinc@nvidia.com, kaihengf@nvidia.com,
kobak@nvidia.com, vaslot@nvidia.com, smadhavan@nvidia.com,
Richard Cheng <icheng@nvidia.com>
Subject: [PATCH v3 1/2] cxl/hdm: Allow zero sized HDM decoders
Date: Sun, 7 Jun 2026 13:38:36 +0800 [thread overview]
Message-ID: <20260607053837.4389-2-icheng@nvidia.com> (raw)
In-Reply-To: <20260607053837.4389-1-icheng@nvidia.com>
CXL r3.2 8.2.4.20.12 and 14.13.10 permit committing on HDM decoder with
size 0. BIOS commits and locks such decoders to burn slots for a Type 3
device in a TSP-established TCB. init_hdm_decoder() rejected them with
-ENXIO and aborted port enumeration, so "cxl list" showed nothing.
Enumerate the decoder with its HW LOCK state instead. Skip the DPA
reservation it does not need, but advance port->hdm_end so a following
committed decoder still passes the in-order check in
__cxl_dpa_reserve(). commit_end can now point at a decoder with no DPA
resource, so poison_by_decoder() must still scan the unmapped DPA tail.
Signed-off-by: Vishal Aslot <vaslot@nvidia.com>
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
Changelog:
v2->v3:
- Advance port->hdm_end for the committed zero-size decoder so a
following committed decoder still passes the in-order check in
__cxl_dpa_reserve() .
- commit_end may now reference a zero-size decoder with no DPA
resource, so poison_by_decoder() falls through to run
cxl_get_poison_unmapped() and scan the unmapped DPA tail.
v1->v2:
- Add zero-size committed decoders to the topology instead of
skipping them. Drop v1's -ENOSPC sentinel and the matching
"continue" in devm_cxl_enumerate_decoders(); fall through so
add_hdm_decoder() registers the decoder.
- Set port->commit_end unconditionally for any committed decoder,
not only non-zero-size ones, so subsequent decoders satisfy the
out-of-order check.
- Add an explicit early-return before devm_cxl_dpa_reserve() in the
endpoint-decoder path. __cxl_dpa_reserve() rejects zero-size
decoders.
- Spell out TSP and TCB and cite spec sections in commit message.
- Reorder series, implementation first.
---
drivers/cxl/core/hdm.c | 25 +++++++++++++++++------
drivers/cxl/core/region.c | 42 +++++++++++++++++++--------------------
2 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index 0c80b76a5f9b..b5fe2b053bc2 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -1031,13 +1031,17 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
return -ENXIO;
}
- if (size == 0) {
- dev_warn(&port->dev,
- "decoder%d.%d: Committed with zero size\n",
- port->id, cxld->id);
- return -ENXIO;
- }
port->commit_end = cxld->id;
+
+ /*
+ * CXL r3.2 8.2.4.20.12 permits committing an HDM decoder with
+ * size 0. Enumerate it into the topology with its HW-reported
+ * LOCK state instead of aborting the port.
+ */
+ if (size == 0)
+ dev_dbg(&port->dev,
+ "decoder%d.%d: Committed with zero size\n",
+ port->id, cxld->id);
} else {
if (cxled) {
struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
@@ -1096,6 +1100,15 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
if (!committed)
return 0;
+ /*
+ * A committed zero-size decoder reserves no DPA, but still advance
+ * the port's DPA watermark.
+ */
+ if (size == 0) {
+ port->hdm_end = cxld->id;
+ return 0;
+ }
+
dpa_size = div_u64_rem(size, cxld->interleave_ways, &remainder);
if (remainder) {
dev_err(&port->dev,
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index e50dc716d4e8..a353d8e7489d 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2907,38 +2907,38 @@ static int poison_by_decoder(struct device *dev, void *arg)
return rc;
cxled = to_cxl_endpoint_decoder(dev);
- if (!cxled->dpa_res)
- return rc;
- cxlmd = cxled_to_memdev(cxled);
- cxlds = cxlmd->cxlds;
- mode = cxlds->part[cxled->part].mode;
+ if (cxled->dpa_res) {
+ cxlmd = cxled_to_memdev(cxled);
+ cxlds = cxlmd->cxlds;
+ mode = cxlds->part[cxled->part].mode;
+
+ if (cxled->skip) {
+ offset = cxled->dpa_res->start - cxled->skip;
+ length = cxled->skip;
+ rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
+ rc = 0;
+ if (rc)
+ return rc;
+ }
- if (cxled->skip) {
- offset = cxled->dpa_res->start - cxled->skip;
- length = cxled->skip;
- rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ offset = cxled->dpa_res->start;
+ length = cxled->dpa_res->end - offset + 1;
+ rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region);
if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
rc = 0;
if (rc)
return rc;
- }
- offset = cxled->dpa_res->start;
- length = cxled->dpa_res->end - offset + 1;
- rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region);
- if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
- rc = 0;
- if (rc)
- return rc;
-
- /* Iterate until commit_end is reached */
- if (cxled->cxld.id == ctx->port->commit_end) {
ctx->offset = cxled->dpa_res->end + 1;
ctx->part = cxled->part;
- return 1;
}
+ /* Iterate until commit_end is reached */
+ if (cxled->cxld.id == ctx->port->commit_end)
+ return 1;
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-06-07 5:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-07 5:38 [PATCH v3 0/2] Support zero-sized HDM decoders Richard Cheng
2026-06-07 5:38 ` Richard Cheng [this message]
2026-06-07 5:51 ` [PATCH v3 1/2] cxl/hdm: Allow zero sized " sashiko-bot
2026-06-07 8:16 ` Richard Cheng
2026-06-07 5:38 ` [PATCH v3 2/2] tools/testing/cxl: Enable zero sized decoder under hb0 Richard Cheng
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=20260607053837.4389-2-icheng@nvidia.com \
--to=icheng@nvidia.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=kaihengf@nvidia.com \
--cc=kobak@nvidia.com \
--cc=kristinc@nvidia.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=newtonl@nvidia.com \
--cc=smadhavan@nvidia.com \
--cc=vaslot@nvidia.com \
--cc=vishal.l.verma@intel.com \
/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