Skip to content

Commit 482dc84

Browse files
committed
Merge branch 'for-6.19/cxl-elc' into cxl-for-next
- Add extended linear cache size sysfs attribute. - Adjust failure emission of extended linear cache detection in cxl_acpi.
2 parents 87c6967 + d6602e2 commit 482dc84

3 files changed

Lines changed: 61 additions & 26 deletions

File tree

Documentation/ABI/testing/sysfs-bus-cxl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,17 @@ Description:
496496
changed, only freed by writing 0. The kernel makes no guarantees
497497
that data is maintained over an address space freeing event, and
498498
there is no guarantee that a free followed by an allocate
499-
results in the same address being allocated.
499+
results in the same address being allocated. If extended linear
500+
cache is present, the size indicates extended linear cache size
501+
plus the CXL region size.
500502

503+
What: /sys/bus/cxl/devices/regionZ/extended_linear_cache_size
504+
Date: October, 2025
505+
KernelVersion: v6.19
506+
Contact: linux-cxl@vger.kernel.org
507+
Description:
508+
(RO) The size of extended linear cache, if there is an extended
509+
linear cache. Otherwise the attribute will not be visible.
501510

502511
What: /sys/bus/cxl/devices/regionZ/mode
503512
Date: January, 2023

drivers/cxl/acpi.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static int cxl_acpi_set_cache_size(struct cxl_root_decoder *cxlrd)
372372

373373
rc = hmat_get_extended_linear_cache_size(&res, nid, &cache_size);
374374
if (rc)
375-
return rc;
375+
return 0;
376376

377377
/*
378378
* The cache range is expected to be within the CFMWS.
@@ -397,21 +397,18 @@ static void cxl_setup_extended_linear_cache(struct cxl_root_decoder *cxlrd)
397397
int rc;
398398

399399
rc = cxl_acpi_set_cache_size(cxlrd);
400-
if (!rc)
401-
return;
402-
403-
if (rc != -EOPNOTSUPP) {
400+
if (rc) {
404401
/*
405-
* Failing to support extended linear cache region resize does not
402+
* Failing to retrieve extended linear cache region resize does not
406403
* prevent the region from functioning. Only causes cxl list showing
407404
* incorrect region size.
408405
*/
409406
dev_warn(cxlrd->cxlsd.cxld.dev.parent,
410-
"Extended linear cache calculation failed rc:%d\n", rc);
411-
}
407+
"Extended linear cache retrieval failed rc:%d\n", rc);
412408

413-
/* Ignoring return code */
414-
cxlrd->cache_size = 0;
409+
/* Ignoring return code */
410+
cxlrd->cache_size = 0;
411+
}
415412
}
416413

417414
DEFINE_FREE(put_cxlrd, struct cxl_root_decoder *,

drivers/cxl/core/region.c

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -467,21 +467,6 @@ static ssize_t commit_show(struct device *dev, struct device_attribute *attr,
467467
}
468468
static DEVICE_ATTR_RW(commit);
469469

470-
static umode_t cxl_region_visible(struct kobject *kobj, struct attribute *a,
471-
int n)
472-
{
473-
struct device *dev = kobj_to_dev(kobj);
474-
struct cxl_region *cxlr = to_cxl_region(dev);
475-
476-
/*
477-
* Support tooling that expects to find a 'uuid' attribute for all
478-
* regions regardless of mode.
479-
*/
480-
if (a == &dev_attr_uuid.attr && cxlr->mode != CXL_PARTMODE_PMEM)
481-
return 0444;
482-
return a->mode;
483-
}
484-
485470
static ssize_t interleave_ways_show(struct device *dev,
486471
struct device_attribute *attr, char *buf)
487472
{
@@ -760,6 +745,21 @@ static ssize_t size_show(struct device *dev, struct device_attribute *attr,
760745
}
761746
static DEVICE_ATTR_RW(size);
762747

748+
static ssize_t extended_linear_cache_size_show(struct device *dev,
749+
struct device_attribute *attr,
750+
char *buf)
751+
{
752+
struct cxl_region *cxlr = to_cxl_region(dev);
753+
struct cxl_region_params *p = &cxlr->params;
754+
ssize_t rc;
755+
756+
ACQUIRE(rwsem_read_intr, rwsem)(&cxl_rwsem.region);
757+
if ((rc = ACQUIRE_ERR(rwsem_read_intr, &rwsem)))
758+
return rc;
759+
return sysfs_emit(buf, "%#llx\n", p->cache_size);
760+
}
761+
static DEVICE_ATTR_RO(extended_linear_cache_size);
762+
763763
static struct attribute *cxl_region_attrs[] = {
764764
&dev_attr_uuid.attr,
765765
&dev_attr_commit.attr,
@@ -768,9 +768,34 @@ static struct attribute *cxl_region_attrs[] = {
768768
&dev_attr_resource.attr,
769769
&dev_attr_size.attr,
770770
&dev_attr_mode.attr,
771+
&dev_attr_extended_linear_cache_size.attr,
771772
NULL,
772773
};
773774

775+
static umode_t cxl_region_visible(struct kobject *kobj, struct attribute *a,
776+
int n)
777+
{
778+
struct device *dev = kobj_to_dev(kobj);
779+
struct cxl_region *cxlr = to_cxl_region(dev);
780+
781+
/*
782+
* Support tooling that expects to find a 'uuid' attribute for all
783+
* regions regardless of mode.
784+
*/
785+
if (a == &dev_attr_uuid.attr && cxlr->mode != CXL_PARTMODE_PMEM)
786+
return 0444;
787+
788+
/*
789+
* Don't display extended linear cache attribute if there is no
790+
* extended linear cache.
791+
*/
792+
if (a == &dev_attr_extended_linear_cache_size.attr &&
793+
cxlr->params.cache_size == 0)
794+
return 0;
795+
796+
return a->mode;
797+
}
798+
774799
static const struct attribute_group cxl_region_group = {
775800
.attrs = cxl_region_attrs,
776801
.is_visible = cxl_region_visible,
@@ -3580,6 +3605,10 @@ static int __construct_region(struct cxl_region *cxlr,
35803605
"Extended linear cache calculation failed rc:%d\n", rc);
35813606
}
35823607

3608+
rc = sysfs_update_group(&cxlr->dev.kobj, &cxl_region_group);
3609+
if (rc)
3610+
return rc;
3611+
35833612
rc = insert_resource(cxlrd->res, res);
35843613
if (rc) {
35853614
/*

0 commit comments

Comments
 (0)