@@ -3202,41 +3202,47 @@ static int devm_cxl_add_dax_region(struct cxl_region *cxlr)
3202
3202
return rc ;
3203
3203
}
3204
3204
3205
- static int match_root_decoder_by_range (struct device * dev ,
3206
- const void * data )
3205
+ static int match_decoder_by_range (struct device * dev , const void * data )
3207
3206
{
3208
3207
const struct range * r1 , * r2 = data ;
3209
- struct cxl_root_decoder * cxlrd ;
3208
+ struct cxl_decoder * cxld ;
3210
3209
3211
- if (!is_root_decoder (dev ))
3210
+ if (!is_switch_decoder (dev ))
3212
3211
return 0 ;
3213
3212
3214
- cxlrd = to_cxl_root_decoder (dev );
3215
- r1 = & cxlrd -> cxlsd . cxld . hpa_range ;
3213
+ cxld = to_cxl_decoder (dev );
3214
+ r1 = & cxld -> hpa_range ;
3216
3215
return range_contains (r1 , r2 );
3217
3216
}
3218
3217
3218
+ static struct cxl_decoder *
3219
+ cxl_port_find_switch_decoder (struct cxl_port * port , struct range * hpa )
3220
+ {
3221
+ struct device * cxld_dev = device_find_child (& port -> dev , hpa ,
3222
+ match_decoder_by_range );
3223
+
3224
+ return cxld_dev ? to_cxl_decoder (cxld_dev ) : NULL ;
3225
+ }
3226
+
3219
3227
static struct cxl_root_decoder *
3220
3228
cxl_find_root_decoder (struct cxl_endpoint_decoder * cxled )
3221
3229
{
3222
3230
struct cxl_memdev * cxlmd = cxled_to_memdev (cxled );
3223
3231
struct cxl_port * port = cxled_to_port (cxled );
3224
3232
struct cxl_root * cxl_root __free (put_cxl_root ) = find_cxl_root (port );
3225
- struct cxl_decoder * cxld = & cxled -> cxld ;
3233
+ struct cxl_decoder * root , * cxld = & cxled -> cxld ;
3226
3234
struct range * hpa = & cxld -> hpa_range ;
3227
- struct device * cxlrd_dev ;
3228
3235
3229
- cxlrd_dev = device_find_child (& cxl_root -> port .dev , hpa ,
3230
- match_root_decoder_by_range );
3231
- if (!cxlrd_dev ) {
3236
+ root = cxl_port_find_switch_decoder (& cxl_root -> port , hpa );
3237
+ if (!root ) {
3232
3238
dev_err (cxlmd -> dev .parent ,
3233
3239
"%s:%s no CXL window for range %#llx:%#llx\n" ,
3234
3240
dev_name (& cxlmd -> dev ), dev_name (& cxld -> dev ),
3235
3241
cxld -> hpa_range .start , cxld -> hpa_range .end );
3236
3242
return NULL ;
3237
3243
}
3238
3244
3239
- return to_cxl_root_decoder (cxlrd_dev );
3245
+ return to_cxl_root_decoder (& root -> dev );
3240
3246
}
3241
3247
3242
3248
static int match_region_by_range (struct device * dev , const void * data )
0 commit comments