Jonathan Cameron wrote: > On Thu, 23 Jun 2022 19:46:21 -0700 > Dan Williams <dan.j.williams@xxxxxxxxx> wrote: > > > Previously the target routing specifics of switch decoders and platfom > > CXL window resource tracking of root decoders were factored out of > > 'struct cxl_decoder'. While switch decoders translate from SPA to > > downstream ports, endpoint decoders translate from SPA to DPA. > > > > This patch, 3 of 3, adds a 'struct cxl_endpoint_decoder' that tracks an > > endpoint-specific Device Physical Address (DPA) resource. For now this > > just defines ->dpa_res, a follow-on patch will handle requesting DPA > > resource ranges from a device-DPA resource tree. > > > > Co-developed-by: Ben Widawsky <bwidawsk@xxxxxxxxxx> > > Signed-off-by: Ben Widawsky <bwidawsk@xxxxxxxxxx> > > Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> > > --- > > drivers/cxl/core/hdm.c | 12 +++++++++--- > > drivers/cxl/core/port.c | 36 +++++++++++++++++++++++++++--------- > > drivers/cxl/cxl.h | 15 ++++++++++++++- > > tools/testing/cxl/test/cxl.c | 11 +++++++++-- > > 4 files changed, 59 insertions(+), 15 deletions(-) > > > > > > > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > > index 6dd1e4c57a67..579f2d802396 100644 > > > > int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map); > > -struct cxl_decoder *cxl_endpoint_decoder_alloc(struct cxl_port *port); > > +struct cxl_endpoint_decoder *cxl_endpoint_decoder_alloc(struct cxl_port *port); > > int cxl_decoder_add_locked(struct cxl_decoder *cxld, int *target_map); > > int cxl_decoder_autoremove(struct device *host, struct cxl_decoder *cxld); > > int cxl_endpoint_autoremove(struct cxl_memdev *cxlmd, struct cxl_port *endpoint); > > diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c > > index 68288354b419..f52a5dd69d36 100644 > > --- a/tools/testing/cxl/test/cxl.c > > +++ b/tools/testing/cxl/test/cxl.c > > @@ -459,8 +459,15 @@ static int mock_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm) > > cxld = ERR_CAST(cxlsd); > > else > > cxld = &cxlsd->cxld; > > - } else > > - cxld = cxl_endpoint_decoder_alloc(port); > > + } else { > > + struct cxl_endpoint_decoder *cxled; > > + > > + cxled = cxl_endpoint_decoder_alloc(port); > > + if (IS_ERR(cxled)) > > + cxld = ERR_CAST(cxled); > > It's my favourite code pattern to moan about today :) > Same thing - just handle error here and it'll be easier to read for cost of a few > lines of additional code. Few other cases of it in here. Done and done.