@@ -173,14 +173,10 @@ static ssize_t target_list_show(struct device *dev,
173173{
174174 struct cxl_switch_decoder * cxlsd = to_cxl_switch_decoder (dev );
175175 ssize_t offset ;
176- unsigned int seq ;
177176 int rc ;
178177
179- do {
180- seq = read_seqbegin (& cxlsd -> target_lock );
181- rc = emit_target_list (cxlsd , buf );
182- } while (read_seqretry (& cxlsd -> target_lock , seq ));
183-
178+ guard (rwsem_read )(& cxl_region_rwsem );
179+ rc = emit_target_list (cxlsd , buf );
184180 if (rc < 0 )
185181 return rc ;
186182 offset = rc ;
@@ -1678,7 +1674,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_find_port, CXL);
16781674static int decoder_populate_targets (struct cxl_switch_decoder * cxlsd ,
16791675 struct cxl_port * port , int * target_map )
16801676{
1681- int i , rc = 0 ;
1677+ int i ;
16821678
16831679 if (!target_map )
16841680 return 0 ;
@@ -1688,19 +1684,16 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd,
16881684 if (xa_empty (& port -> dports ))
16891685 return - EINVAL ;
16901686
1691- write_seqlock ( & cxlsd -> target_lock );
1692- for (i = 0 ; i < cxlsd -> nr_targets ; i ++ ) {
1687+ guard ( rwsem_write )( & cxl_region_rwsem );
1688+ for (i = 0 ; i < cxlsd -> cxld . interleave_ways ; i ++ ) {
16931689 struct cxl_dport * dport = find_dport (port , target_map [i ]);
16941690
1695- if (!dport ) {
1696- rc = - ENXIO ;
1697- break ;
1698- }
1691+ if (!dport )
1692+ return - ENXIO ;
16991693 cxlsd -> target [i ] = dport ;
17001694 }
1701- write_sequnlock (& cxlsd -> target_lock );
17021695
1703- return rc ;
1696+ return 0 ;
17041697}
17051698
17061699struct cxl_dport * cxl_hb_modulo (struct cxl_root_decoder * cxlrd , int pos )
@@ -1770,7 +1763,6 @@ static int cxl_switch_decoder_init(struct cxl_port *port,
17701763 return - EINVAL ;
17711764
17721765 cxlsd -> nr_targets = nr_targets ;
1773- seqlock_init (& cxlsd -> target_lock );
17741766 return cxl_decoder_init (port , & cxlsd -> cxld );
17751767}
17761768
0 commit comments