On Thu, 5 Nov 2026 08:02:26 +0900 Anisa Su <[email protected]> wrote:
> Endpoints can now carry a dynamic ram partition following the > persistent memory partition. A DC partition is further described by > two properties reported in its CDAT DSMAS entry: shareable and > read-only. > > Expand the decoder mode to accept 'dynamic_ram', 'dynamic_ram_shared', Time to argue about bikeshed colors. So we want the subtle distinction between shared and shareable? Shared implies it is happening, shareable that it might. I don't really care either way. > 'dynamic_ram_ro' and 'dynamic_ram_shared_ro'. cxl_dpa_set_part() > selects the first dynamic ram partition whose properties match exactly. > > DCD may be disabled during validation after the DC partition(s) were > added to the DPA layout, so a decoder may only be assigned to a DC > partition while DCD is enabled for its memdev. Add a helper, > cxled_dcd_enabled(), to check cxl_dcd_supported(). > > 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]> > --- > Documentation/ABI/testing/sysfs-bus-cxl | 25 +++++++---- > drivers/cxl/core/core.h | 23 ++++++++++- > drivers/cxl/core/hdm.c | 21 ++++++++-- > drivers/cxl/core/port.c | 55 ++++++++++++++++++++++--- > 4 files changed, 105 insertions(+), 19 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-cxl > b/Documentation/ABI/testing/sysfs-bus-cxl > index 7352dbd70bc7..bcbc44fea6db 100644 > --- a/Documentation/ABI/testing/sysfs-bus-cxl > +++ b/Documentation/ABI/testing/sysfs-bus-cxl > @@ -339,22 +339,29 @@ Description: > > > What: /sys/bus/cxl/devices/decoderX.Y/mode > -Date: May, 2022 > -KernelVersion: v6.0 > +Date: May, 2022, November, 2026 > +KernelVersion: v6.0, v7.5 (dynamic_ram) > Contact: [email protected] > Description: > (RW) When a CXL decoder is of devtype "cxl_decoder_endpoint" it > translates from a host physical address range, to a device > local address range. Device-local address ranges are further > - split into a 'ram' (volatile memory) range and 'pmem' > - (persistent memory) range. The 'mode' attribute emits one of > - 'ram', 'pmem', or 'none'. The 'none' indicates the decoder is > - not actively decoding, or no DPA allocation policy has been > - set. > + split into a 'ram' (volatile memory) range, 'pmem' (persistent > + memory) range, and dynamic capacity ranges. The 'mode' > + attribute emits one of 'ram', 'pmem', 'none', or a dynamic > + capacity selector: 'dynamic_ram', 'dynamic_ram_shared', > + 'dynamic_ram_ro' or 'dynamic_ram_shared_ro', composed from the > + shareable and read-only properties of the partition the decoder > + points at. The 'none' indicates the decoder is not actively > + decoding, or no DPA allocation policy has been set. > > 'mode' can be written, when the decoder is in the 'disabled' > - state, with either 'ram' or 'pmem' to set the boundaries for the > - next allocation. > + state, with 'ram', 'pmem', or one of the dynamic capacity > + selectors to set the boundaries for the next allocation. A > + selector picks the first dynamic capacity partition whose > + shareable and read-only properties match it exactly, and is > + accepted only while the driver has dynamic capacity enabled > + for the device. > > > What: /sys/bus/cxl/devices/decoderX.Y/dpa_resource > diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h > index 8a81be004d00..24fbb5718abc 100644 > --- a/drivers/cxl/core/core.h > +++ b/drivers/cxl/core/core.h > @@ -6,6 +6,7 @@ > > #include <cxl/mailbox.h> > #include <linux/rwsem.h> > +#include <cxlmem.h> > > extern const struct device_type cxl_nvdimm_bridge_type; > extern const struct device_type cxl_nvdimm_type; > @@ -18,6 +19,25 @@ enum cxl_detach_mode { > DETACH_INVALIDATE, > }; > > +static inline struct cxl_memdev_state * > +cxled_to_mds(struct cxl_endpoint_decoder *cxled) > +{ > + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); > + > + return to_cxl_memdev_state(cxlmd->cxlds); > +} > + > +/* Type-2 devices have no memdev state; nothing else leaves @cxlds NULL here > */ Seems like an odd comment given cxlds isn't visibly used in here. Perhaps needs to refer to it via a specific path? > +static inline bool cxled_dcd_enabled(struct cxl_endpoint_decoder *cxled) > +{ > + struct cxl_memdev_state *mds = cxled_to_mds(cxled); > + > + return mds && cxl_dcd_supported(mds); > +} > diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c > index f3705ea44db7..9b71b58d4e36 100644 > --- a/drivers/cxl/core/port.c > +++ b/drivers/cxl/core/port.c > @@ -203,6 +203,40 @@ static ssize_t target_list_show(struct device *dev, > } > static DEVICE_ATTR_RO(target_list); > > +/* Dynamic capacity selectors: the flags name one kind of DC partition */ > +static const struct { > + const char *name; > + bool shareable; > + bool read_only; > +} cxl_dc_modes[] = { > + { "dynamic_ram", false, false }, > + { "dynamic_ram_shared", true, false }, This rather highlights the disconnect in naming. > + { "dynamic_ram_ro", false, true }, > + { "dynamic_ram_shared_ro", true, true }, > +}; > +
