On Thu, 5 Nov 2026 08:02:27 +0900 Anisa Su <[email protected]> wrote:
> From: Ira Weiny <[email protected]> > > 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. > 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 <[email protected]> > Co-developed-by: Anisa Su <[email protected]> > Signed-off-by: Anisa Su <[email protected]> > Tested-by: Wonjae Lee <[email protected]> > Tested-by: Junhee Park <[email protected]> > Tested-by: Heesoo Kim <[email protected]> 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. > } > @@ -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? > > + 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)) {
