@@ -37,6 +37,13 @@ DECLARE_RWSEM(cxl_region_rwsem);
37
37
static DEFINE_IDA (cxl_port_ida );
38
38
static DEFINE_XARRAY (cxl_root_buses );
39
39
40
+ int cxl_num_decoders_committed (struct cxl_port * port )
41
+ {
42
+ lockdep_assert_held (& cxl_region_rwsem );
43
+
44
+ return port -> commit_end + 1 ;
45
+ }
46
+
40
47
static ssize_t devtype_show (struct device * dev , struct device_attribute * attr ,
41
48
char * buf )
42
49
{
@@ -537,8 +544,33 @@ static void cxl_port_release(struct device *dev)
537
544
kfree (port );
538
545
}
539
546
547
+ static ssize_t decoders_committed_show (struct device * dev ,
548
+ struct device_attribute * attr , char * buf )
549
+ {
550
+ struct cxl_port * port = to_cxl_port (dev );
551
+ int rc ;
552
+
553
+ down_read (& cxl_region_rwsem );
554
+ rc = sysfs_emit (buf , "%d\n" , cxl_num_decoders_committed (port ));
555
+ up_read (& cxl_region_rwsem );
556
+
557
+ return rc ;
558
+ }
559
+
560
+ static DEVICE_ATTR_RO (decoders_committed );
561
+
562
+ static struct attribute * cxl_port_attrs [] = {
563
+ & dev_attr_decoders_committed .attr ,
564
+ NULL ,
565
+ };
566
+
567
+ static struct attribute_group cxl_port_attribute_group = {
568
+ .attrs = cxl_port_attrs ,
569
+ };
570
+
540
571
static const struct attribute_group * cxl_port_attribute_groups [] = {
541
572
& cxl_base_attribute_group ,
573
+ & cxl_port_attribute_group ,
542
574
NULL ,
543
575
};
544
576
0 commit comments