@@ -37,6 +37,13 @@ DECLARE_RWSEM(cxl_region_rwsem);
3737static DEFINE_IDA (cxl_port_ida );
3838static DEFINE_XARRAY (cxl_root_buses );
3939
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+
4047static ssize_t devtype_show (struct device * dev , struct device_attribute * attr ,
4148 char * buf )
4249{
@@ -537,8 +544,33 @@ static void cxl_port_release(struct device *dev)
537544 kfree (port );
538545}
539546
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+
540571static const struct attribute_group * cxl_port_attribute_groups [] = {
541572 & cxl_base_attribute_group ,
573+ & cxl_port_attribute_group ,
542574 NULL ,
543575};
544576
0 commit comments