mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Li Ming <ming.li@zohomail.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	"Vishal Verma" <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	"Dan Williams" <dan.j.williams@intel.com>,
	<linux-kernel@vger.kernel.org>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH] cxl/region: Add a region sysfs interface for region lock status
Date: Tue, 31 Mar 2026 16:57:26 -0700	[thread overview]
Message-ID: <acxfZiQWfYaIY2BU@aschofie-mobl2.lan> (raw)
In-Reply-To: <20260329-expose_region_locked_status-v1-1-cd860feaff6e@zohomail.com>

On Sun, Mar 29, 2026 at 10:44:17PM +0800, Li Ming wrote:
> If a region is created on a root decoder with Fixed Device Confiuration
> attribute, the region will be locked , meaning region destroy
> operations are not permitted. CXL region driver returns -EPERM for
> region destroy operations.
> 

There is at least 3 paths to a locked region:

1) the FIXED root decoder attribute (above)

2) CXL_HDM_DECODER0_CTRL_LOCK
   Both 1) and 2) well described in:
   2230c4bdc412 ("cxl: Add handling of locked CXL decoder")

3) AMD Zen5 region creation always locks the region, regardless of the
   FIXED attribute or decoder ctrl bit.


I like the added info provided by this patch. Please consider expanding
the sysfs 'Decription:' field. If user reads the decoder lock sysfs
description they may think they can reset their way out of a region lock
situation, and I don't think they can.

more...

> Although the locked status of the corresponding root decoder implies the
> region is also locked, exposing the region lock status directly to
> userspace improves usability for users who may not be aware of this
> relationship.
> 
> Signed-off-by: Li Ming <ming.li@zohomail.com>
> ---
>  Documentation/ABI/testing/sysfs-bus-cxl | 10 ++++++++++
>  drivers/cxl/core/region.c               | 17 +++++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl
> index c80a1b5a03db..50bf7334465b 100644
> --- a/Documentation/ABI/testing/sysfs-bus-cxl
> +++ b/Documentation/ABI/testing/sysfs-bus-cxl
> @@ -508,6 +508,16 @@ Description:
>  		(RO) The size of extended linear cache, if there is an extended
>  		linear cache. Otherwise the attribute will not be visible.
>  
> +
> +What:		/sys/bus/cxl/devices/regionZ/locked
> +Date:		Mar, 2026
> +KernelVersion:	v7.1
> +Contact:	linux-cxl@vger.kernel.org
> +Description:
> +		(RO) The lock status of the region, region destroy operations
> +		are not permitted if the region is locked.

Maybe similar to the sys/bus/cxl/devices/decoderX.Y/locked, say:

The CXL driver has the capability to lock a region based on a
BIOS or platform dependent configuration. Regions created as locked
are never permitted to be destroyed. Resets to participating decoders
will not result in a region destroy and will not free the decoder
resources.

Maybe the last sentence is too much.


> +
> +
>  What:		/sys/bus/cxl/devices/regionZ/mode
>  Date:		January, 2023
>  KernelVersion:	v6.3
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 42874948b589..95d81816008e 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -767,6 +767,22 @@ static ssize_t extended_linear_cache_size_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(extended_linear_cache_size);
>  
> +static ssize_t locked_show(struct device *dev,
> +			   struct device_attribute *attr,
> +			   char *buf)
> +{
> +	struct cxl_region *cxlr = to_cxl_region(dev);
> +	int rc;
> +
> +	ACQUIRE(rwsem_read_intr, rwsem)(&cxl_rwsem.region);
> +	if ((rc = ACQUIRE_ERR(rwsem_read_intr, &rwsem)))
> +		return rc;
> +
> +	rc = test_bit(CXL_REGION_F_LOCK, &cxlr->flags);
> +	return sysfs_emit(buf, "%d\n", rc);
> +}
> +static DEVICE_ATTR_RO(locked);
> +
>  static struct attribute *cxl_region_attrs[] = {
>  	&dev_attr_uuid.attr,
>  	&dev_attr_commit.attr,
> @@ -776,6 +792,7 @@ static struct attribute *cxl_region_attrs[] = {
>  	&dev_attr_size.attr,
>  	&dev_attr_mode.attr,
>  	&dev_attr_extended_linear_cache_size.attr,
> +	&dev_attr_locked.attr,
>  	NULL,
>  };
>  
> 
> ---
> base-commit: c369299895a591d96745d6492d4888259b004a9e
> change-id: 20260329-expose_region_locked_status-b05c4b8f97d6
> 
> Best regards,
> -- 
> Li Ming <ming.li@zohomail.com>
> 

      parent reply	other threads:[~2026-03-31 23:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-29 14:44 Li Ming
2026-03-30 21:57 ` Dave Jiang
2026-03-31  5:48 ` Alejandro Lucero Palau
2026-03-31 23:57 ` Alison Schofield [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acxfZiQWfYaIY2BU@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®