Re: [PATCH v1 03/14] cxl/region: Add dynamic DAX region support

From: Anisa Su

Date: Thu Dec 03 2026 - 17:21:34 EST


On Tue, Nov 17, 2026 at 02:32:01AM +0000, Jonathan Cameron wrote:
> On Thu, 5 Nov 2026 08:02:27 +0900
> Anisa Su <anisa.su887@xxxxxxxxx> wrote:
>
> > From: Ira Weiny <iweiny@xxxxxxxxxx>
> >
> > CXL DAX regions must allow memory to be added or removed dynamically
> > to support DCD. In addition to the quantity of memory available, the
> > location of the memory within a DC partition is dynamic, based on the
> > extents offered by a device. CXL DAX regions must accommodate the
> > dynamic movement of this memory in the management of DAX regions and
> > devices.
> >
> > Introduce the concept of a dynamic DAX region. A dynamic region
> > carries the shareable and read-only properties of the partitions it
> > decodes, fixed when the region is created: every endpoint decoder
> > attached to it must point at a partition with exactly those
> > properties, and the region's 'mode' reports the matching selector.
> >
> > A dynamic region has no capacity when it is created, so the DAX device
> > that cxl_dax_region_probe() creates for every region gets size 0
> > instead of the region size: a seed that claims no capacity the device
> > has not offered yet. Its dax_region is created with IORESOURCE_DAX_DCD
> no capacity has not been offered? no capacity as the device
> has not offered any yet. perhaps.
Yeah oops awkward wording. Combined with Alison's feedback:

A dynamic region has no capacity when it is created, so the DAX device
that cxl_dax_region_probe() creates for every region gets size 0
instead of the region size: a seed that claims no capacity, as the
device has not offered any yet. Its dax_region reports 0 bytes
available and is created with IORESOURCE_DAX_DCD rather than
IORESOURCE_DAX_KMEM, so the DAX devices on it bind to device_dax and
not to kmem.

> > rather than IORESOURCE_DAX_KMEM, so the DAX devices on it bind to
> > device_dax and not to kmem.
> >
> > Indicate 0 byte available capacity until such time that capacity is
> > added.
> >
> > While DCD is disabled, auto region creation and the region 'target'
> > write refuse endpoint decoders on a DC partition with -ENXIO, as the
> > decoder 'mode' write already does. The sysfs entries for manual region
> > creation follow in a separate patch.
> >
> > Additionally, dynamic regions complicate the range mapping of dax
> > devices. There is no known use case for range mapping on dynamic
> > regions. Avoid the complication by preventing range mapping of dax
> > devices on dynamic regions.
> >
> > Interleaving is deferred for now.
> >
> > Based on an original patch by Navneet Singh.
> >
> > Signed-off-by: Ira Weiny <iweiny@xxxxxxxxxx>
> > Co-developed-by: Anisa Su <anisa.su@xxxxxxxxxxx>
> > Signed-off-by: Anisa Su <anisa.su@xxxxxxxxxxx>
> > Tested-by: Wonjae Lee <wj28.lee@xxxxxxxxxxx>
> > Tested-by: Junhee Park <jh9934.park@xxxxxxxxxxx>
> > Tested-by: Heesoo Kim <habil.kim@xxxxxxxxxxx>
>
> A few small things inline.
>
> > @@ -2411,6 +2432,7 @@ static size_t store_targetN(struct cxl_region *cxlr, const char *buf, int pos,
> > if (sysfs_streq(buf, "\n"))
> > rc = detach_target(cxlr, pos);
> > else {
> > + struct cxl_endpoint_decoder *cxled;
> > struct device *dev;
> >
> > dev = bus_find_device_by_name(&cxl_bus_type, NULL, buf);
> > @@ -2422,8 +2444,14 @@ static size_t store_targetN(struct cxl_region *cxlr, const char *buf, int pos,
> > goto out;
> > }
> >
> > - rc = attach_target(cxlr, to_cxl_endpoint_decoder(dev), pos,
> > - TASK_INTERRUPTIBLE);
> > + cxled = to_cxl_endpoint_decoder(dev);
> > + if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM &&
> > + !cxled_dcd_enabled(cxled)) {
> > + dev_dbg(dev, "DCD not enabled\n");
> > + rc = -ENXIO;
> > + goto out;
> > + }
> > + rc = attach_target(cxlr, cxled, pos, TASK_INTERRUPTIBLE);
> > out:
> > put_device(dev);
> Could tidy this up whilst here and use a __free() for the put device.
> Entirely up to you though.
>
Good point, dropped the out: label

> > }
>
> > @@ -3808,10 +3845,18 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
> > if (part < 0)
> > return ERR_PTR(-EBUSY);
>
> There are quite a few cxled->part[part] lookups in this function. Perhaps
> a local variable for that is worth introducing?
>
Added local variable const struct cxl_dpa_partition *dpa_part to use for the
lookups.

Thanks,
Anisa
> >
> > + if (cxlds->part[part].mode == CXL_PARTMODE_DYNAMIC_RAM &&
> > + !cxled_dcd_enabled(cxled)) {
> > + dev_dbg(&cxled->cxld.dev, "DCD not enabled\n");
> > + return ERR_PTR(-ENXIO);
> > + }
> > +
> > do {
> > cxlr = __create_region(cxlrd, cxlds->part[part].mode,
> > atomic_read(&cxlrd->region_id),
> > - cxled->cxld.target_type);
> > + cxled->cxld.target_type,
> > + cxlds->part[part].shareable,
> > + cxlds->part[part].read_only);
> > } while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY);
> >
> > if (IS_ERR(cxlr)) {
>
>