Re: [PATCH v3 05/11] cxl/region: Add @range argument to function cxl_calc_interleave_pos()

From: Robert Richter

Date: Fri Sep 26 2025 - 14:22:36 EST


On 23.09.25 14:52:04, Alison Schofield wrote:
> On Fri, Sep 12, 2025 at 04:45:07PM +0200, Robert Richter wrote:
> > cxl_calc_interleave_pos() uses the endpoint decoder's HPA range to
> > determine its interleaving position. This requires the endpoint
> > decoders to be an SPA, which is not the case for systems that need
> > address translation.
> >
> > Add a separate @range argument to function cxl_calc_interleave_pos()
> > to specify the address range. Now it is possible to pass the SPA
> > translated address range of an endpoint decoder to function
> > cxl_calc_interleave_pos().
> >
> > Patch is a prerequisite to implement address translation.
> >
> > Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> > ---
> > drivers/cxl/core/region.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 8ccc171ac724..106692f1e310 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -1844,11 +1844,11 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,
> > * Return: position >= 0 on success
> > * -ENXIO on failure
> > */
> > -static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled)
> > +static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled,
> > + struct range *range)
> > {
> > struct cxl_port *iter, *port = cxled_to_port(cxled);
> > struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
> > - struct range *range = &cxled->cxld.hpa_range;
> > int parent_ways = 0, parent_pos = 0, pos = 0;
> > int rc;
>
> Will this work? Change the assignment rather than adding a parameter:
>
> - struct range *range = &cxled->cxld.hpa_range;
> + struct range *range = &cxled->cxld.region->hpa_range;

For cxl_region_sort_targets() it doesn't as the region is not yet
attached. This is the calling order:

cxl_region_sort_targets
cxl_calc_interleave_pos
# needs cxlr->hpa_range
cxl_region_attach_position
...
cxld->region = cxlr;

It would be nice if we can make this work and drop the argument. Will
take a look.

Thanks,

-Robert