@@ -467,21 +467,6 @@ static ssize_t commit_show(struct device *dev, struct device_attribute *attr,
467467}
468468static 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-
485470static 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}
761746static 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+
763763static 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+
774799static 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