Re: [PATCH v4 06/14] cxl/region: Separate region parameter setup and region construction

Robert Richter
2025-11-07T15:59:03Z

On 03.11.25 15:05:28, Dave Jiang wrote:
>
>
> On 11/3/25 11:47 AM, Robert Richter wrote:
> > To construct a region, the region parameters such as address range and
> > interleaving config need to be determined. This is done while
> > constructing the region by inspecting the endpoint decoder
> > configuration. The endpoint decoder is passed as a function argument.
> >
> > With address translation the endpoint decoder data is no longer
> > sufficient to extract the region parameters as some of the information
> > is obtained using other methods such as using firmware calls.
> >
> > In a first step, separate code to determine the region parameters from
> > the region construction. Temporarily store all the data to create the
> > region in the new struct cxl_region_context. Once the region data is
> > determined and struct cxl_region_context is filled, construct the
> > region.
> >
> > Patch is a prerequisite to implement address translation. The code
> > separation helps to later extend it to determine region parameters
> > using other methods as needed, esp. to support address translation.
> >
> > Reviewed-by: Gregory Price <gourry@gourry.net>
> > Signed-off-by: Robert Richter <rrichter@amd.com>
>
> Just a small thing below, otherwise
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>
> > ---
> > drivers/cxl/core/core.h | 9 +++++++++
> > drivers/cxl/core/region.c | 32 +++++++++++++++++++++-----------
> > 2 files changed, 30 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
> > index 1fb66132b777..2bc37f3aee21 100644
> > --- a/drivers/cxl/core/core.h
> > +++ b/drivers/cxl/core/core.h
> > @@ -19,6 +19,15 @@ enum cxl_detach_mode {
> > };
> >
> > #ifdef CONFIG_CXL_REGION
> > +
> > +struct cxl_region_context {
> > + struct cxl_endpoint_decoder *cxled;
> > + struct cxl_memdev *cxlmd;
>
> cxlmd may not be needed.
>
> struct cxl_memdev *cxlmd = cxled_to_memdev(cxlr_ctx->cxled);
>
> which you used later on in this patch to init the cxlmd member :)

This was on purpose to eliminate an unnecessary frequent call of
cxled_to_memdev() while holding the context. There is at least a
3-level pointer chasing to get to cxlmd.

Maybe it's wort to add it to struct cxl_endpoint_decoder.

-Robert