[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <288d1d01-5e63-4bbc-872e-5f49e1500329@intel.com>
Date: Thu, 20 Feb 2025 09:50:22 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Robert Richter <rrichter@....com>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Davidlohr Bueso <dave@...olabs.net>
Cc: linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org,
Gregory Price <gourry@...rry.net>,
"Fabio M. De Francesco" <fabio.m.de.francesco@...ux.intel.com>,
Terry Bowman <terry.bowman@....com>
Subject: Re: [PATCH v3 10/18] cxl/region: Factor out code to find a root
decoder's region
On 2/11/25 2:53 AM, Robert Richter wrote:
> In function cxl_add_to_region() there is code to determine a root
> decoder's region. Factor that code out. This is in preparation to
> further rework and simplify function cxl_add_to_region().
>
> No functional changes.
>
> Signed-off-by: Robert Richter <rrichter@....com>
> Reviewed-by: Gregory Price <gourry@...rry.net>
> Tested-by: Gregory Price <gourry@...rry.net>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>
> ---
> drivers/cxl/core/region.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index c641c8922455..9ce0282c0042 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3256,6 +3256,19 @@ static int match_region_by_range(struct device *dev, const void *data)
> return rc;
> }
>
> +static struct cxl_region *
> +cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa)
> +{
> + struct device *region_dev;
> +
> + region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
> + match_region_by_range);
> + if (!region_dev)
> + return NULL;
> +
> + return to_cxl_region(region_dev);
> +}
> +
> /* Establish an empty region covering the given HPA range */
> static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
> struct cxl_endpoint_decoder *cxled)
> @@ -3347,7 +3360,6 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
> int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
> {
> struct range *hpa = &cxled->cxld.hpa_range;
> - struct device *region_dev;
> struct cxl_root_decoder *cxlrd;
> struct cxl_region_params *p;
> struct cxl_region *cxlr;
> @@ -3363,13 +3375,9 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
> * one does the construction and the others add to that.
> */
> mutex_lock(&cxlrd->range_lock);
> - region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
> - match_region_by_range);
> - if (!region_dev) {
> + cxlr = cxl_find_region_by_range(cxlrd, hpa);
> + if (!cxlr)
> cxlr = construct_region(cxlrd, cxled);
> - region_dev = &cxlr->dev;
> - } else
> - cxlr = to_cxl_region(region_dev);
> mutex_unlock(&cxlrd->range_lock);
>
> rc = PTR_ERR_OR_ZERO(cxlr);
> @@ -3394,7 +3402,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
> p->res);
> }
>
> - put_device(region_dev);
> + put_device(&cxlr->dev); /* cxl_find_region_by_range() */
>
> return rc;
> }
Powered by blists - more mailing lists