[PATCH v2 09/15] cxl/region: Use the endpoint's SPA range to create a region

Robert Richter posted 15 patches 10 months ago
[PATCH v2 09/15] cxl/region: Use the endpoint's SPA range to create a region
Posted by Robert Richter 10 months ago
To create a region, SPA ranges must be used. With address translation
the endpoint's HPA range is not the same as the SPA range. Use the
previously calculated SPA range instead.

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

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index ffe6038249ed..6e0434eee6df 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -3445,14 +3445,14 @@ cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa)
 	return to_cxl_region(region_dev);
 }
 
-/* Establish an empty region covering the given HPA range */
+/* Establish an empty region covering the given SPA range */
 static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 					   struct cxl_endpoint_decoder *cxled)
 {
 	struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
 	struct cxl_port *port = cxlrd_to_port(cxlrd);
 	struct cxl_dev_state *cxlds = cxlmd->cxlds;
-	struct range *hpa = &cxled->cxld.hpa_range;
+	struct range *spa = &cxled->spa_range;
 	int rc, part = READ_ONCE(cxled->part);
 	struct cxl_region_params *p;
 	struct cxl_region *cxlr;
@@ -3493,7 +3493,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 		goto err;
 	}
 
-	*res = DEFINE_RES_MEM_NAMED(hpa->start, range_len(hpa),
+	*res = DEFINE_RES_MEM_NAMED(spa->start, range_len(spa),
 				    dev_name(&cxlr->dev));
 	rc = insert_resource(cxlrd->res, res);
 	if (rc) {
-- 
2.39.5
Re: [PATCH v2 09/15] cxl/region: Use the endpoint's SPA range to create a region
Posted by Gregory Price 8 months, 2 weeks ago
On Tue, Feb 18, 2025 at 02:23:50PM +0100, Robert Richter wrote:
> To create a region, SPA ranges must be used. With address translation
> the endpoint's HPA range is not the same as the SPA range. Use the
> previously calculated SPA range instead.
>

Same with patch 8, I think this probably should just be rolled in with
patch 5.  You can simplify the notes in patch 5 by saying:

"""
 since cxled->spa_range is set to cxled->cxld.hpa_range at endpoint
 initialization, this patch is effectively a no-op for all systems
 that do not provide a translation callback.

 Change all refs to cxled->cxld.hpa_range to cxled->spa_range.
"""

This should also help simplify the patch series overall.

I haven't gone through to check if there are any other missed hpa_range
references yet (e.g. [1])

[1] https://lore.kernel.org/linux-cxl/20250218132356.1809075-1-rrichter@amd.com/T/#m26a8e4d8b1783dfb837553f184f7f174b61b7825

~Gregory
Re: [PATCH v2 09/15] cxl/region: Use the endpoint's SPA range to create a region
Posted by Jonathan Cameron 9 months, 1 week ago
On Tue, 18 Feb 2025 14:23:50 +0100
Robert Richter <rrichter@amd.com> wrote:

> To create a region, SPA ranges must be used. With address translation
> the endpoint's HPA range is not the same as the SPA range. Use the
> previously calculated SPA range instead.
> 
> Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Re: [PATCH v2 09/15] cxl/region: Use the endpoint's SPA range to create a region
Posted by Gregory Price 10 months ago
On Tue, Feb 18, 2025 at 02:23:50PM +0100, Robert Richter wrote:
> To create a region, SPA ranges must be used. With address translation
> the endpoint's HPA range is not the same as the SPA range. Use the
> previously calculated SPA range instead.
> 
> Signed-off-by: Robert Richter <rrichter@amd.com>

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