Skip to content

Commit d585bc8

Browse files
liming011davejiang
authored andcommitted
cxl/region: Add a region sysfs interface for region lock status
There are 3 scenarios that leads to a locked region: 1. A region is created on a root decoder with Fixed Device Confiuration attribute. 2. CXL_HDM_DECODER0_CTRL_LOCK. Both 1 & 1 are well described in: commit 2230c4b ("cxl: Add handling of locked CXL decoder") 3) Platform that has region creation with PRMT address translation always locks the region, regardless of the FIXED attribute or decoder ctrl bit. Region locked means region destroy operations are not permitted. CXL region driver returns -EPERM for region destroy operations. 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. [ dj: Amended commit log with additional locking scenarios. ] Signed-off-by: Li Ming <ming.li@zohomail.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alejandro Lucero <alucerop@amd.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20260401124951.1290041-1-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 261a02b commit d585bc8

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-bus-cxl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,19 @@ Description:
508508
(RO) The size of extended linear cache, if there is an extended
509509
linear cache. Otherwise the attribute will not be visible.
510510

511+
512+
What: /sys/bus/cxl/devices/regionZ/locked
513+
Date: Mar, 2026
514+
KernelVersion: v7.1
515+
Contact: linux-cxl@vger.kernel.org
516+
Description:
517+
(RO) The CXL driver has the capability to lock a region based on
518+
a BIOS or platform dependent configuration. Regions created as
519+
locked are never permitted to be destroyed. Resets to participating
520+
decoders will not result in a region destroy and will not free the
521+
decoder resources.
522+
523+
511524
What: /sys/bus/cxl/devices/regionZ/mode
512525
Date: January, 2023
513526
KernelVersion: v6.3

drivers/cxl/core/region.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,22 @@ static ssize_t extended_linear_cache_size_show(struct device *dev,
767767
}
768768
static DEVICE_ATTR_RO(extended_linear_cache_size);
769769

770+
static ssize_t locked_show(struct device *dev,
771+
struct device_attribute *attr,
772+
char *buf)
773+
{
774+
struct cxl_region *cxlr = to_cxl_region(dev);
775+
int rc;
776+
777+
ACQUIRE(rwsem_read_intr, rwsem)(&cxl_rwsem.region);
778+
if ((rc = ACQUIRE_ERR(rwsem_read_intr, &rwsem)))
779+
return rc;
780+
781+
rc = test_bit(CXL_REGION_F_LOCK, &cxlr->flags);
782+
return sysfs_emit(buf, "%d\n", rc);
783+
}
784+
static DEVICE_ATTR_RO(locked);
785+
770786
static struct attribute *cxl_region_attrs[] = {
771787
&dev_attr_uuid.attr,
772788
&dev_attr_commit.attr,
@@ -776,6 +792,7 @@ static struct attribute *cxl_region_attrs[] = {
776792
&dev_attr_size.attr,
777793
&dev_attr_mode.attr,
778794
&dev_attr_extended_linear_cache_size.attr,
795+
&dev_attr_locked.attr,
779796
NULL,
780797
};
781798

0 commit comments

Comments
 (0)