Re: [PATCH v4 02/14] cxl/region: Store HPA range in struct cxl_region

Robert Richter
2025-11-11T11:25:13Z

On 03.11.25 19:47:43, Robert Richter wrote:
> Each region has a known host physical address (HPA) range it is
> assigned to. Endpoint decoders assigned to a region share the same HPA
> range. The region's address range is the system's physical address
> (SPA) range.
>
> Endpoint decoders in systems that need address translation use HPAs
> which are not SPAs. To make the SPA range accessible to the endpoint
> decoders, store and track the region's SPA range in struct cxl_region.
> Introduce the @hpa_range member to the struct. Now, the SPA range of
> an endpoint decoder can be determined based on its assigned region.
>
> Patch is a prerequisite to implement address translation which uses
> struct cxl_region to store all relevant region and interleaving
> parameters.
>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Reviewed-by: Gregory Price <gourry@gourry.net>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> ---
> drivers/cxl/core/region.c | 7 +++++++
> drivers/cxl/cxl.h | 2 ++
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 45b1386a18d7..a780e65532a7 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -670,6 +670,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
> return PTR_ERR(res);
> }
>
> + cxlr->hpa_range = DEFINE_RANGE(0, -1);
> +

Alison, thanks for pointing out the wrong initialization for the
non-auto case. I think this must be the following instead:

cxlr->hpa_range = DEFINE_RANGE(res->start, res->end);

> p->res = res;
> p->state = CXL_CONFIG_INTERLEAVE_ACTIVE;

Will change that.

-Robert