Skip to content

Commit af3ea9a

Browse files
committed
cxl/region: Clarify when a cxld->commit() callback is mandatory
Both cxl_switch_decoders() and cxl_endpoint_decoders() are considered by cxl_region_decode_commit(). Flag cases where cxl_switch_decoders with multiple targets, or cxl_endpoint_decoders do not have a commit callback set. The switch case is unlikely to happen since switches are only enumerated by the CXL core, but the endpoint case may support decoders defined by drivers outside of drivers/cxl, like accerator drivers. Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/167124081824.1626103.1555704405392757219.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent f45d63c commit af3ea9a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/cxl/core/region.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)
156156
return 0;
157157
}
158158

159+
static int commit_decoder(struct cxl_decoder *cxld)
160+
{
161+
struct cxl_switch_decoder *cxlsd = NULL;
162+
163+
if (cxld->commit)
164+
return cxld->commit(cxld);
165+
166+
if (is_switch_decoder(&cxld->dev))
167+
cxlsd = to_cxl_switch_decoder(&cxld->dev);
168+
169+
if (dev_WARN_ONCE(&cxld->dev, !cxlsd || cxlsd->nr_targets > 1,
170+
"->commit() is required\n"))
171+
return -ENXIO;
172+
return 0;
173+
}
174+
159175
static int cxl_region_decode_commit(struct cxl_region *cxlr)
160176
{
161177
struct cxl_region_params *p = &cxlr->params;
@@ -174,8 +190,7 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
174190
iter = to_cxl_port(iter->dev.parent)) {
175191
cxl_rr = cxl_rr_load(iter, cxlr);
176192
cxld = cxl_rr->decoder;
177-
if (cxld->commit)
178-
rc = cxld->commit(cxld);
193+
rc = commit_decoder(cxld);
179194
if (rc)
180195
break;
181196
}

0 commit comments

Comments
 (0)