Re: [PATCH RFC v2 07/18] cxl/mem: Expose device dynamic capacity configuration

From: Ira Weiny
Date: Tue Sep 05 2023 - 16:46:02 EST


Jonathan Cameron wrote:
> On Mon, 28 Aug 2023 22:20:58 -0700
> ira.weiny@xxxxxxxxx wrote:
>
> > From: Navneet Singh <navneet.singh@xxxxxxxxx>
> >
> > To properly configure CXL regions on Dynamic Capacity Devices (DCD),
> > user space will need to know the details of the DC Regions available on
> > a device.
> >
> > Expose driver dynamic capacity configuration through sysfs
> > attributes.
> >
> > Co-developed-by: Navneet Singh <navneet.singh@xxxxxxxxx>
> > Signed-off-by: Navneet Singh <navneet.singh@xxxxxxxxx>
> > Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> >
> One trivial comment inline. I wondered a bit if it would
> be better to not present dc at all on devices that don't support
> dynamic capacity, but for now there isn't an elegant way to do that
> (some discussions and patches are flying around however so maybe this
> will be resolved before this series merges giving us that elegant
> option).

For now I will keep this yes. But if there is a better way then sure.

>
> With commented code tidied up
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>

Thanks.

> > diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> > index 492486707fd0..397262e0ebd2 100644
> > --- a/drivers/cxl/core/memdev.c
> > +++ b/drivers/cxl/core/memdev.c
> > @@ -101,6 +101,20 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
> > static struct device_attribute dev_attr_pmem_size =
> > __ATTR(size, 0444, pmem_size_show, NULL);
> >
> > +static ssize_t region_count_show(struct device *dev, struct device_attribute *attr,
> > + char *buf)
> > +{
> > + struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
> > + struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
> > + int len = 0;
> > +
> > + len = sysfs_emit(buf, "%d\n", mds->nr_dc_region);
> > + return len;
>
> return sysfs_emit(buf, "...);
>

Done thanks!
Ira