[PATCH v3 09/11] cxl/region: Lock decoders that need address translation

Robert Richter posted 11 patches 2 weeks, 6 days ago
[PATCH v3 09/11] cxl/region: Lock decoders that need address translation
Posted by Robert Richter 2 weeks, 6 days ago
There is only support to translate addresses from an endpoint to its
parent port, but not in the opposite direction from the parent to the
endpoint. Thus, the endpoint address range cannot be determined and
setup manually for a given SPA range of a region. If the parent
implements the ->to_hpa() callback, address translation is
needed. Then, forbid reprogramming of the decoders and lock them.

Signed-off-by: Robert Richter <rrichter@amd.com>
---
 drivers/cxl/core/region.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 9fb1e9508213..44ea59252ff0 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -3497,6 +3497,16 @@ static int setup_address_translation(struct cxl_endpoint_decoder *cxled,
 		return -ENXIO;
 	}
 
+	/*
+	 * There is only support to translate from the endpoint to its
+	 * parent port, but not in the opposite direction from the
+	 * parent to the endpoint. Thus, the endpoint address range
+	 * cannot be determined and setup manually. If the address range
+	 * was translated and modified, forbid reprogramming of the
+	 * decoders and lock them.
+	 */
+	cxld->flags |= CXL_DECODER_F_LOCK;
+
 	ctx->hpa_range = range;
 	ctx->interleave_ways = ways;
 	ctx->interleave_granularity = gran;
-- 
2.39.5
Re: [PATCH v3 09/11] cxl/region: Lock decoders that need address translation
Posted by Gregory Price 2 weeks ago
On Fri, Sep 12, 2025 at 04:45:11PM +0200, Robert Richter wrote:
> There is only support to translate addresses from an endpoint to its
> parent port, but not in the opposite direction from the parent to the
> endpoint. Thus, the endpoint address range cannot be determined and
> setup manually for a given SPA range of a region. If the parent
> implements the ->to_hpa() callback, address translation is
> needed. Then, forbid reprogramming of the decoders and lock them.
> 
> Signed-off-by: Robert Richter <rrichter@amd.com>

Reviewed-by: Gregory Price <gourry@gourry.net>

> ---
>  drivers/cxl/core/region.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 9fb1e9508213..44ea59252ff0 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3497,6 +3497,16 @@ static int setup_address_translation(struct cxl_endpoint_decoder *cxled,
>  		return -ENXIO;
>  	}
>  
> +	/*
> +	 * There is only support to translate from the endpoint to its
> +	 * parent port, but not in the opposite direction from the
> +	 * parent to the endpoint. Thus, the endpoint address range
> +	 * cannot be determined and setup manually. If the address range
> +	 * was translated and modified, forbid reprogramming of the
> +	 * decoders and lock them.
> +	 */
> +	cxld->flags |= CXL_DECODER_F_LOCK;
> +
>  	ctx->hpa_range = range;
>  	ctx->interleave_ways = ways;
>  	ctx->interleave_granularity = gran;
> -- 
> 2.39.5
>