diff mbox series

[v2] cxl: Add committed sysfs attribute to CXL decoder

Message ID 169574219129.3884437.11954592650115343944.stgit@djiang5-mobl3
State Superseded
Headers show
Series [v2] cxl: Add committed sysfs attribute to CXL decoder | expand

Commit Message

Dave Jiang Sept. 26, 2023, 3:29 p.m. UTC
Expose the committed status of a CXL decoder. The status assists CXL CLI in
determining as a sure way whether a region is active. Of coruse this is
still best effort as it's a snapshot of the state and not atomic for the
user region disable operation.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

---
v2:
- Use FIELD_GET() (Jonathan)
---
 Documentation/ABI/testing/sysfs-bus-cxl |    7 +++++++
 drivers/cxl/core/port.c                 |   12 ++++++++++++
 2 files changed, 19 insertions(+)

Comments

Verma, Vishal L Sept. 26, 2023, 5:01 p.m. UTC | #1
On Tue, 2023-09-26 at 08:29 -0700, Dave Jiang wrote:
> Expose the committed status of a CXL decoder. The status assists CXL CLI in
> determining as a sure way whether a region is active. Of coruse this is
> still best effort as it's a snapshot of the state and not atomic for the
> user region disable operation.

A minor nit here - 

"Sure way to.." immediately followed by " still best effort" feels a
bit contradictory. What about something like:

This attribute allows cxl-cli to determine whether a decoder is
actively participating in a region. This is only a snapshot of the
state, and doesn't offer any protection or serialization against a
concurrent disable-region operation.

> 
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

Everything else looks good -

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> 
> ---
> v2:
> - Use FIELD_GET() (Jonathan)
> ---
>  Documentation/ABI/testing/sysfs-bus-cxl |    7 +++++++
>  drivers/cxl/core/port.c                 |   12 ++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl
> index 087f762ebfd5..ef3fc9fe9d0d 100644
> --- a/Documentation/ABI/testing/sysfs-bus-cxl
> +++ b/Documentation/ABI/testing/sysfs-bus-cxl
> @@ -369,6 +369,13 @@ Description:
>                 provided it is currently idle / not bound to a driver.
>  
>  
> +What:          /sys/bus/cxl/devices/decoderX.Y/committed
> +Date:          Sep, 2023
> +KernelVersion: v6.7
> +Contact:       linux-cxl@vger.kernel.org
> +Description:
> +               (RO) Indicates whether the decoder is committed.
> +
>  What:          /sys/bus/cxl/devices/regionZ/uuid
>  Date:          May, 2022
>  KernelVersion: v6.0
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 724be8448eb4..fc65ef55db0f 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -277,12 +277,24 @@ static ssize_t interleave_ways_show(struct device *dev,
>  
>  static DEVICE_ATTR_RO(interleave_ways);
>  
> +static ssize_t committed_show(struct device *dev,
> +                             struct device_attribute *attr, char *buf)
> +{
> +       struct cxl_decoder *cxld = to_cxl_decoder(dev);
> +
> +       return sysfs_emit(buf, "%d\n",
> +                         FIELD_GET(CXL_DECODER_F_ENABLE, cxld->flags));
> +}
> +
> +static DEVICE_ATTR_RO(committed);
> +
>  static struct attribute *cxl_decoder_base_attrs[] = {
>         &dev_attr_start.attr,
>         &dev_attr_size.attr,
>         &dev_attr_locked.attr,
>         &dev_attr_interleave_granularity.attr,
>         &dev_attr_interleave_ways.attr,
> +       &dev_attr_committed.attr,
>         NULL,
>  };
>  
> 
>
kernel test robot Sept. 26, 2023, 6:16 p.m. UTC | #2
Hi Dave,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on cxl/next cxl/pending v6.6-rc3 next-20230926]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dave-Jiang/cxl-Add-committed-sysfs-attribute-to-CXL-decoder/20230926-233134
base:   linus/master
patch link:    https://lore.kernel.org/r/169574219129.3884437.11954592650115343944.stgit%40djiang5-mobl3
patch subject: [PATCH v2] cxl: Add committed sysfs attribute to CXL decoder
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230927/202309270116.IH2UP8s4-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230927/202309270116.IH2UP8s4-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309270116.IH2UP8s4-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/cxl/core/port.c: In function 'committed_show':
>> drivers/cxl/core/port.c:286:34: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
     286 |         return sysfs_emit(buf, "%d\n",
         |                                 ~^
         |                                  |
         |                                  int
         |                                 %ld


vim +286 drivers/cxl/core/port.c

   280	
   281	static ssize_t committed_show(struct device *dev,
   282				      struct device_attribute *attr, char *buf)
   283	{
   284		struct cxl_decoder *cxld = to_cxl_decoder(dev);
   285	
 > 286		return sysfs_emit(buf, "%d\n",
   287				  FIELD_GET(CXL_DECODER_F_ENABLE, cxld->flags));
   288	}
   289
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl
index 087f762ebfd5..ef3fc9fe9d0d 100644
--- a/Documentation/ABI/testing/sysfs-bus-cxl
+++ b/Documentation/ABI/testing/sysfs-bus-cxl
@@ -369,6 +369,13 @@  Description:
 		provided it is currently idle / not bound to a driver.
 
 
+What:		/sys/bus/cxl/devices/decoderX.Y/committed
+Date:		Sep, 2023
+KernelVersion:	v6.7
+Contact:	linux-cxl@vger.kernel.org
+Description:
+		(RO) Indicates whether the decoder is committed.
+
 What:		/sys/bus/cxl/devices/regionZ/uuid
 Date:		May, 2022
 KernelVersion:	v6.0
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 724be8448eb4..fc65ef55db0f 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -277,12 +277,24 @@  static ssize_t interleave_ways_show(struct device *dev,
 
 static DEVICE_ATTR_RO(interleave_ways);
 
+static ssize_t committed_show(struct device *dev,
+			      struct device_attribute *attr, char *buf)
+{
+	struct cxl_decoder *cxld = to_cxl_decoder(dev);
+
+	return sysfs_emit(buf, "%d\n",
+			  FIELD_GET(CXL_DECODER_F_ENABLE, cxld->flags));
+}
+
+static DEVICE_ATTR_RO(committed);
+
 static struct attribute *cxl_decoder_base_attrs[] = {
 	&dev_attr_start.attr,
 	&dev_attr_size.attr,
 	&dev_attr_locked.attr,
 	&dev_attr_interleave_granularity.attr,
 	&dev_attr_interleave_ways.attr,
+	&dev_attr_committed.attr,
 	NULL,
 };