@@ -489,9 +489,9 @@ static ssize_t interleave_ways_store(struct device *dev,
489489 struct device_attribute * attr ,
490490 const char * buf , size_t len )
491491{
492- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder (dev -> parent );
493- struct cxl_decoder * cxld = & cxlrd -> cxlsd .cxld ;
494492 struct cxl_region * cxlr = to_cxl_region (dev );
493+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
494+ struct cxl_decoder * cxld = & cxlrd -> cxlsd .cxld ;
495495 struct cxl_region_params * p = & cxlr -> params ;
496496 unsigned int val , save ;
497497 int rc ;
@@ -552,9 +552,9 @@ static ssize_t interleave_granularity_store(struct device *dev,
552552 struct device_attribute * attr ,
553553 const char * buf , size_t len )
554554{
555- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder (dev -> parent );
556- struct cxl_decoder * cxld = & cxlrd -> cxlsd .cxld ;
557555 struct cxl_region * cxlr = to_cxl_region (dev );
556+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
557+ struct cxl_decoder * cxld = & cxlrd -> cxlsd .cxld ;
558558 struct cxl_region_params * p = & cxlr -> params ;
559559 int rc , val ;
560560 u16 ig ;
@@ -628,7 +628,7 @@ static DEVICE_ATTR_RO(mode);
628628
629629static int alloc_hpa (struct cxl_region * cxlr , resource_size_t size )
630630{
631- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
631+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
632632 struct cxl_region_params * p = & cxlr -> params ;
633633 struct resource * res ;
634634 u64 remainder = 0 ;
@@ -1373,7 +1373,7 @@ static int cxl_port_setup_targets(struct cxl_port *port,
13731373 struct cxl_region * cxlr ,
13741374 struct cxl_endpoint_decoder * cxled )
13751375{
1376- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
1376+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
13771377 int parent_iw , parent_ig , ig , iw , rc , pos = cxled -> pos ;
13781378 struct cxl_port * parent_port = to_cxl_port (port -> dev .parent );
13791379 struct cxl_region_ref * cxl_rr = cxl_rr_load (port , cxlr );
@@ -1731,10 +1731,10 @@ static int cxl_region_validate_position(struct cxl_region *cxlr,
17311731}
17321732
17331733static int cxl_region_attach_position (struct cxl_region * cxlr ,
1734- struct cxl_root_decoder * cxlrd ,
17351734 struct cxl_endpoint_decoder * cxled ,
17361735 const struct cxl_dport * dport , int pos )
17371736{
1737+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
17381738 struct cxl_memdev * cxlmd = cxled_to_memdev (cxled );
17391739 struct cxl_switch_decoder * cxlsd = & cxlrd -> cxlsd ;
17401740 struct cxl_decoder * cxld = & cxlsd -> cxld ;
@@ -1971,7 +1971,7 @@ static int cxl_region_sort_targets(struct cxl_region *cxlr)
19711971static int cxl_region_attach (struct cxl_region * cxlr ,
19721972 struct cxl_endpoint_decoder * cxled , int pos )
19731973{
1974- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
1974+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
19751975 struct cxl_memdev * cxlmd = cxled_to_memdev (cxled );
19761976 struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
19771977 struct cxl_region_params * p = & cxlr -> params ;
@@ -2076,8 +2076,7 @@ static int cxl_region_attach(struct cxl_region *cxlr,
20762076 ep_port = cxled_to_port (cxled );
20772077 dport = cxl_find_dport_by_dev (root_port ,
20782078 ep_port -> host_bridge );
2079- rc = cxl_region_attach_position (cxlr , cxlrd , cxled ,
2080- dport , i );
2079+ rc = cxl_region_attach_position (cxlr , cxled , dport , i );
20812080 if (rc )
20822081 return rc ;
20832082 }
@@ -2100,7 +2099,7 @@ static int cxl_region_attach(struct cxl_region *cxlr,
21002099 if (rc )
21012100 return rc ;
21022101
2103- rc = cxl_region_attach_position (cxlr , cxlrd , cxled , dport , pos );
2102+ rc = cxl_region_attach_position (cxlr , cxled , dport , pos );
21042103 if (rc )
21052104 return rc ;
21062105
@@ -2396,8 +2395,8 @@ static const struct attribute_group *region_groups[] = {
23962395
23972396static void cxl_region_release (struct device * dev )
23982397{
2399- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder (dev -> parent );
24002398 struct cxl_region * cxlr = to_cxl_region (dev );
2399+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
24012400 int id = atomic_read (& cxlrd -> region_id );
24022401
24032402 /*
@@ -2480,10 +2479,12 @@ static struct cxl_region *cxl_region_alloc(struct cxl_root_decoder *cxlrd, int i
24802479 * region id allocations
24812480 */
24822481 get_device (dev -> parent );
2482+ cxlr -> cxlrd = cxlrd ;
2483+ cxlr -> id = id ;
2484+
24832485 device_set_pm_not_required (dev );
24842486 dev -> bus = & cxl_bus_type ;
24852487 dev -> type = & cxl_region_type ;
2486- cxlr -> id = id ;
24872488 cxl_region_set_lock (cxlr , & cxlrd -> cxlsd .cxld );
24882489
24892490 return cxlr ;
@@ -3115,7 +3116,7 @@ EXPORT_SYMBOL_FOR_MODULES(cxl_calculate_hpa_offset, "cxl_translate");
31153116u64 cxl_dpa_to_hpa (struct cxl_region * cxlr , const struct cxl_memdev * cxlmd ,
31163117 u64 dpa )
31173118{
3118- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
3119+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
31193120 struct cxl_region_params * p = & cxlr -> params ;
31203121 struct cxl_endpoint_decoder * cxled = NULL ;
31213122 u64 dpa_offset , hpa_offset , hpa ;
@@ -3168,7 +3169,7 @@ static int region_offset_to_dpa_result(struct cxl_region *cxlr, u64 offset,
31683169 struct dpa_result * result )
31693170{
31703171 struct cxl_region_params * p = & cxlr -> params ;
3171- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
3172+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
31723173 struct cxl_endpoint_decoder * cxled ;
31733174 u64 hpa , hpa_offset , dpa_offset ;
31743175 u16 eig = 0 ;
@@ -3522,7 +3523,7 @@ static int match_region_by_range(struct device *dev, const void *data)
35223523static int cxl_extended_linear_cache_resize (struct cxl_region * cxlr ,
35233524 struct resource * res )
35243525{
3525- struct cxl_root_decoder * cxlrd = to_cxl_root_decoder ( cxlr -> dev . parent ) ;
3526+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
35263527 struct cxl_region_params * p = & cxlr -> params ;
35273528 resource_size_t size = resource_size (res );
35283529 resource_size_t cache_size , start ;
@@ -3558,9 +3559,9 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,
35583559}
35593560
35603561static int __construct_region (struct cxl_region * cxlr ,
3561- struct cxl_root_decoder * cxlrd ,
35623562 struct cxl_endpoint_decoder * cxled )
35633563{
3564+ struct cxl_root_decoder * cxlrd = cxlr -> cxlrd ;
35643565 struct cxl_memdev * cxlmd = cxled_to_memdev (cxled );
35653566 struct range * hpa_range = & cxled -> cxld .hpa_range ;
35663567 struct cxl_region_params * p ;
@@ -3656,7 +3657,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
36563657 return cxlr ;
36573658 }
36583659
3659- rc = __construct_region (cxlr , cxlrd , cxled );
3660+ rc = __construct_region (cxlr , cxled );
36603661 if (rc ) {
36613662 devm_release_action (port -> uport_dev , unregister_region , cxlr );
36623663 return ERR_PTR (rc );
0 commit comments