Re: [PATCH v4 04/14] cxl/region: Add @hpa_range argument to function cxl_calc_interleave_pos()

From: Alison Schofield
Date: Mon Nov 03 2025 - 22:05:15 EST


On Mon, Nov 03, 2025 at 07:47:45PM +0100, 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 @hpa_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().
>
> Refactor only, no functional changes.
>
> Patch is a prerequisite to implement address translation.
>
> Reviewed-by: Gregory Price <gourry@xxxxxxxxxx>
> Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> ---
> drivers/cxl/core/region.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)

snip

> @@ -2094,7 +2095,7 @@ static int cxl_region_attach(struct cxl_region *cxlr,
> struct cxl_endpoint_decoder *cxled = p->targets[i];
> int test_pos;
>
> - test_pos = cxl_calc_interleave_pos(cxled);
> + test_pos = cxl_calc_interleave_pos(cxled, &cxlr->hpa_range);

This is accessing the new hpa_range that Patch 2/14 started storing in
struct cxl_region. It stores it only for auto-regions and this is
a user created region path.

So the fixup is actually in Patch 2 - but this is the why. It shows
up as a bunch of dev_errs() from find_pos_and_ways() running unit
tests that create regions.


> dev_dbg(&cxled->cxld.dev,
> "Test cxl_calc_interleave_pos(): %s test_pos:%d cxled->pos:%d\n",
> (test_pos == cxled->pos) ? "success" : "fail",
> --
> 2.47.3
>