From: Alison Schofield <alison.schofield@intel.com>
To: Anisa Su <anisa.su887@gmail.com>
Cc: <linux-cxl@vger.kernel.org>, <nvdimm@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, Dave Jiang <dave.jiang@intel.com>,
"Jonathan Cameron" <jic23@kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Ira Weiny <iweiny@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Fan Ni <nifan.cxl@gmail.com>, Li Ming <ming.li@zohomail.com>,
Benjamin Cheatham <benjamin.cheatham@amd.com>,
Gregory Price <gourry@gourry.net>,
Richard Cheng <icheng@nvidia.com>,
Anisa Su <anisa.su@samsung.com>
Subject: Re: [PATCH v1 12/14] cxl/region: Read existing extents on region creation
Date: Mon, 30 Nov 2026 14:07:35 -0800 [thread overview]
Message-ID: <aw3zpwoNIvKDl9K_@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261104230445.66625-13-anisa.su@samsung.com>
On Thu, Nov 05, 2026 at 08:02:36AM +0900, Anisa Su wrote:
> From: Ira Weiny <iweiny@kernel.org>
>
> Dynamic capacity device extents may be left in an accepted state on a
> device due to an unexpected host crash. In this case it is expected
> that the creation of a new region on top of a DC partition can read
> those extents and surface them for continued use.
>
> Once all endpoint decoders are part of a region and the region is being
> created, a read of the device's extent list can reveal these
> previously accepted extents.
The subject and this paragraph say the read happens at region creation,
while a later paragraph says it is "not at region creation" but at the
cxl_dax_region probe, which also runs again on every dax_cxl bind.
Could the subject and this paragraph match that (which is the correct
statement because dax_cxl driver probes later and async)
>
> CXL r4.0 Section 8.2.10.9.9.2 specifies the mailbox call Get Dynamic
> Capacity Extent List for this purpose. The call returns all the extents
> for all dynamic capacity partitions, so only the extents inside the
> region's decoder DPA range are accepted. The rest belong to other
> regions, or to partitions Linux does not map, so are not tracked on the
> current region. If the fabric manager is adding extents to any DCD
> partition, the extent list for the recovered region may change; the
> generation number changing between queries is detected and the read is
> retried.
>
> The dax_region device probes asynchronously, so the extent list is
> read from the cxl_dax_region probe, not at region creation. Onlining
> a recovered group attaches its devres teardown to the dax_region
> device, and devres present before a probe starts makes the driver
> core refuse to bind ("Resources present before probing").
>
> The same asynchrony means the region can detach its decoder before or
> while the probe runs, and the scan needs that decoder throughout: its
> DPA range filters the extent list, and every recovered extent is
> resolved through it back to the region. So cxl_dax_region_alloc()
> records the decoder in cxlr_dax->cxled with a reference, which keeps
> it valid until the dax_region is released. A detach mid-scan then
> just makes the remaining extents resolve to no region, and the group
> is released back to the device.
wrt a detach mid-scan...I don't think that is true if the decoder is
attached to another region while the scan runs. The extents then
resolve to that region instead.
snip
> diff --git a/drivers/cxl/core/extent.c b/drivers/cxl/core/extent.c
snip
> @@ -230,7 +230,7 @@ static int cxl_validate_extent(struct cxl_memdev_state *mds,
> struct cxl_extent *extent,
> struct cxl_endpoint_decoder **out_cxled,
> struct cxl_dax_region **out_cxlr_dax,
> - struct range *out_ext_range)
> + struct range *out_ext_range, bool existing)
> {
> u64 start_dpa = le64_to_cpu(extent->start_dpa);
> struct cxl_memdev *cxlmd = mds->cxlds.cxlmd;
> @@ -271,6 +271,17 @@ static int cxl_validate_extent(struct cxl_memdev_state *mds,
> if (!cxlr || !cxlr->cxlr_dax)
> return -ENXIO;
>
> + /*
> + * New adds wait for a bound dax driver that has read the device's
> + * pre-existing extents, so a tag already in use is never added twice.
> + */
Same as Sashiko here wrt a decoder re-attached to another region while
this scan runs.
snip
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
snip
> @@ -1627,6 +1641,10 @@ static int cxl_realize_group(struct cxl_memdev_state *mds, const uuid_t *tag,
> mds->dc_chain.group = NULL;
> if (tag_group)
> discard_tag_group(tag_group);
> +err_release:
> + /* A fresh group is simply left out of the Add response */
> + if (existing)
> + cxl_release_recovered(mds, tag, group);
> return rc;
> }
Same as Sashiko here, on releasing DPA the host has just onlined. On the
Add path the same group would only be left out of the response. Should
recovery drop such a group not just release it?
snip
> +static int cxl_read_extent_list(struct cxl_memdev_state *mds,
> + const struct range *dpa_range,
> + struct list_head *existing)
> +{
snip
> + dev_dbg(dev, "Got extent list %d-%d of %d generation Num:%d\n",
> + current_index, total_read ? total_read - 1 : 0,
> + current_total, current_gen_num);
Use %u for these u32's to be consistent w other msgs in this func.
> +
> + if (current_gen_num != initial_gen_num || total_expected != current_total) {
> + dev_warn(dev, "Extent list change detected; gen %u != %u : cnt %u != %u\n",
> + current_gen_num, initial_gen_num,
> + total_expected, current_total);
> + return -EAGAIN;
> + }
> +
> + /* No progress with more expected: a buggy device would loop forever. */
> + if (!nr_returned && total_expected > total_read) {
> + dev_warn(dev, "Device returned 0 of %u remaining extents\n",
> + total_expected - total_read);
> + return -EIO;
> + }
> +
> + for (int i = 0; i < nr_returned ; i++) {
stray space before ;
> + struct cxl_extent *extent = &extents->extent[i];
> + struct range ext_range;
> +
> + ext_range.start = le64_to_cpu(extent->start_dpa);
> + ext_range.end = ext_range.start +
> + le64_to_cpu(extent->length) - 1;
> + dev_dbg(dev, "Processing extent %d/%d %pra (%pUb) seq %u\n",
> + current_index + i, total_expected, &ext_range,
> + extent->uuid,
> + le16_to_cpu(extent->shared_extn_seq));
> + /* Another region's, or an unmapped partition's: not ours */
> + if (!range_contains(dpa_range, &ext_range))
> + continue;
> + rc = stage_pending_extent(existing, extent);
Same as Sashiko here wrt a tag group split by the per-extent filter.
There look to be 2 more beyond what Sashiko notes:
- an extent that only partly overlaps this decoder is not recovered
nor released
- a failed partial release is logged only with dev_dbg(), so those
extents stay accepted on the device with no host tracking
> + if (rc)
> + return rc;
> + }
> +
> + current_index += nr_returned;
> + } while (total_expected > total_read);
> +
> + return 0;
> +}
> +
> +static int __cxl_process_extent_list(struct cxl_endpoint_decoder *cxled)
> +{
> + struct cxl_memdev_state *mds = cxled_to_mds(cxled);
> + struct range dpa_range;
> + LIST_HEAD(existing);
How about making this less confusing w some renaming -
Here "existing" is the list, but in cxl_add_pending() and the functions
it calls the same name is the bool flag, so the call below reads as
cxl_add_pending(mds, &existing, true), with "existing" meaning two
things. How about LIST_HEAD(recovered) instead ?
snip
> +/**
> + * cxl_process_extent_list() - Read existing extents
> + * @cxled: Endpoint decoder which is part of a region
> + *
> + * Issue the Get Dynamic Capacity Extent List command to the device
> + * and add existing extents if found.
> + *
> + * A retry of 10 is somewhat arbitrary, however, extent changes should be
> + * relatively rare while bringing up a region. So 10 should be plenty.
> + */
> +int cxl_process_extent_list(struct cxl_endpoint_decoder *cxled)
I believe noted also in Patch 4. Spec says reread the extent list
on overflow, but we don't yet. Is that planned?
snip
> diff --git a/drivers/cxl/core/region_dax.c b/drivers/cxl/core/region_dax.c
snip
> index 790176a8aadd..816386301b80 100644
> --- a/drivers/cxl/core/region_dax.c
> +++ b/drivers/cxl/core/region_dax.c
> @@ -13,6 +13,8 @@ static void cxl_dax_region_release(struct device *dev)
> {
> struct cxl_dax_region *cxlr_dax = to_cxl_dax_region(dev);
>
> + if (cxlr_dax->cxled)
> + put_device(&cxlr_dax->cxled->cxld.dev);
> xa_destroy(&cxlr_dax->dc_extents);
> ida_destroy(&cxlr_dax->tag_group_ida);
> kfree(cxlr_dax);
> @@ -79,6 +81,15 @@ static struct cxl_dax_region *cxl_dax_region_alloc(struct cxl_region *cxlr)
> cxlr_dax->hpa_range.start = p->res->start;
> cxlr_dax->hpa_range.end = p->res->end;
>
> + /*
> + * DC regions are not interleaved; the probe-time scan uses this decoder
> + * and may outlive its attachment to the region, so hold a reference.
> + */
> + if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM)
> + cxlr_dax->cxled = p->targets[0];
> + if (cxlr_dax->cxled)
> + get_device(&cxlr_dax->cxled->cxld.dev);
cxled cannot be null if first test passes. How about:
if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM) {
cxlr_dax->cxled = p->targets[0];
get_device(&cxlr_dax->cxled->cxld.dev);
}
snip
> diff --git a/drivers/dax/cxl.c b/drivers/dax/cxl.c
snip
> static int cxl_dax_region_probe(struct device *dev)
> {
> struct cxl_dax_region *cxlr_dax = to_cxl_dax_region(dev);
> @@ -15,6 +21,7 @@ static int cxl_dax_region_probe(struct device *dev)
> struct dev_dax_data data;
> resource_size_t dev_size;
> unsigned long flags;
> + int rc;
>
> if (nid == NUMA_NO_NODE)
> nid = memory_add_physaddr_to_nid(cxlr_dax->hpa_range.start);
> @@ -29,11 +36,17 @@ static int cxl_dax_region_probe(struct device *dev)
> if (!dax_region)
> return -ENOMEM;
>
> - if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM)
> + if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM) {
> + /* Recover extents the device still holds for this region */
> + rc = cxl_region_add_existing_extents(cxlr_dax);
> + if (rc)
> + goto err_remove;
> +
Should a failed scan fail the whole probe?
> /* Add empty seed dax device */
> dev_size = 0;
> - else
> + } else {
> dev_size = range_len(&cxlr_dax->hpa_range);
> + }
>
> data = (struct dev_dax_data) {
> .dax_region = dax_region,
> @@ -42,12 +55,20 @@ static int cxl_dax_region_probe(struct device *dev)
> .memmap_on_memory = true,
> };
>
> - return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
> + rc = PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
> + if (rc)
> + goto err_remove;
> + return 0;
> +
> +err_remove:
> + cxl_dax_region_remove(dev);
> + return rc;
Is a probe failure meant to give the recovered extents back?
snip to end
next prev parent reply other threads:[~2026-11-30 22:07 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 23:02 [PATCH v1 00/14] DCD CXL Series: Dynamic Capacity extent handling Anisa Su
2026-11-04 23:02 ` [PATCH v1 01/14] cxl/core: Return endpoint decoder information from region search Anisa Su
2026-11-24 18:31 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 02/14] cxl/port: Add dynamic capacity options to endpoint decoder mode Anisa Su
2026-11-17 2:22 ` Jonathan Cameron
2026-11-24 18:36 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 03/14] cxl/region: Add dynamic DAX region support Anisa Su
2026-11-17 2:32 ` Jonathan Cameron
2026-11-24 18:55 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 04/14] cxl/mem: Introduce DC event handlers Anisa Su
2026-11-17 2:54 ` Jonathan Cameron
2026-11-24 19:29 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 05/14] cxl/mem: Add 20 second timeout for stalled DC event chains Anisa Su
2026-11-17 3:00 ` Jonathan Cameron
2026-11-20 20:47 ` Anisa Su
2026-11-24 19:30 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 06/14] cxl/extent: Handle DC Add Capacity events Anisa Su
2026-11-12 3:34 ` Richard Cheng
2026-11-16 21:53 ` Anisa Su
2026-11-30 19:54 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 07/14] cxl/mem: Drop misaligned DCD extent groups Anisa Su
2026-11-30 19:58 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 08/14] cxl/extent: Validate DC extent partition Anisa Su
2026-11-30 20:13 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 09/14] cxl/mem: Enforce tag-group semantics Anisa Su
2026-11-30 20:45 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 10/14] cxl/extent: Enforce cross-region tag uniqueness Anisa Su
2026-11-30 21:01 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 11/14] cxl/extent: Handle DC Release Capacity events Anisa Su
2026-11-12 7:34 ` Richard Cheng
2026-11-30 21:31 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 12/14] cxl/region: Read existing extents on region creation Anisa Su
2026-11-30 22:07 ` Alison Schofield [this message]
2026-11-04 23:02 ` [PATCH v1 13/14] cxl/mem: Trace Dynamic capacity Event Record Anisa Su
2026-11-30 22:29 ` Alison Schofield
2026-11-04 23:02 ` [PATCH v1 14/14] Documentation/cxl: Document DCD extent handling 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=aw3zpwoNIvKDl9K_@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=anisa.su887@gmail.com \
--cc=anisa.su@samsung.com \
--cc=benjamin.cheatham@amd.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=gourry@gourry.net \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=nifan.cxl@gmail.com \
--cc=nvdimm@lists.linux.dev \
--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
all inboxes | Powered by JetHome®