[PATCH v1 19/20] cxl/region: Add function to find a region's duplicate

Robert Richter posted 20 patches 2 months, 3 weeks ago
[PATCH v1 19/20] cxl/region: Add function to find a region's duplicate
Posted by Robert Richter 2 months, 3 weeks ago
Before registering a region, there is a check if a region with the
same parameters already exists. Rename the existing function
cxl_find_region_by_range() to cxl_region_find_duplicate() and modify
the argument list to only pass the @cxlr argument, which also
simplifies the function's interface.

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

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 8faef2b2ee05..5c30c417de1a 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -3312,9 +3312,10 @@ static int match_region_by_range(struct device *dev, const void *data)
 	return 0;
 }
 
-static struct cxl_region *
-cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa)
+static struct cxl_region *cxl_region_find_duplicate(struct cxl_region *cxlr)
 {
+	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
+	struct range *hpa = &cxlr->hpa_range;
 	struct device *region_dev;
 
 	region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
@@ -3486,7 +3487,7 @@ static struct cxl_region *construct_region(struct cxl_region *__cxlr)
 		dev_name(&cxlr->dev), __func__, p->res, p->interleave_ways,
 		p->interleave_granularity);
 
-	/* Pair with cxl_find_region_by_range() in cxl_endpoint_get_region(). */
+	/* Pair with cxl_region_find_duplicate() in cxl_endpoint_get_region(). */
 	get_device(&cxlr->dev);
 
 	return no_free_ptr(cxlr);
@@ -3502,12 +3503,13 @@ cxl_endpoint_get_region(struct cxl_endpoint_decoder *cxled)
 		return new;
 
 	/*
-	 * Ensure that if multiple threads race to construct_region() for @hpa
-	 * one does the construction and the others add to that.
+	 * Ensure that if multiple threads race to construct_region()
+	 * for the hpa range one does the construction and the others
+	 * add to that.
 	 */
 	guard(mutex)(&new->cxlrd->range_lock);
 
-	cxlr = cxl_find_region_by_range(new->cxlrd, &new->hpa_range);
+	cxlr = cxl_region_find_duplicate(new);
 	if (!cxlr)
 		return construct_region(new);
 
-- 
2.39.5