[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <681e2cb5ca5a9_27eca0294d7@dwillia2-xfh.jf.intel.com.notmuch>
Date: Fri, 9 May 2025 09:26:29 -0700
From: Dan Williams <dan.j.williams@...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>, Dave Jiang
<dave.jiang@...el.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>,
Robert Richter <rrichter@....com>
Subject: Re: [PATCH v6 09/14] cxl/region: Factor out code to find the root
decoder
Robert Richter wrote:
> In function cxl_add_to_region() there is code to determine the root
> decoder associated to an endpoint decoder. Factor out that code for
> later reuse. This has the benefit of reducing cxl_add_to_region()'s
> function complexity.
>
> The reference count must be decremented after using the root decoder.
> cxl_find_root_decoder() is paired with the put_cxl_root_decoder
> cleanup helper that can be used for this.
[..]
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 59d0d6becbd1..45f5d2c7dfdf 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
[..]
> @@ -3384,29 +3407,17 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
>
> int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
> {
> - struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
> - struct cxl_port *port = cxled_to_port(cxled);
> - struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
> + struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) = NULL;
Please avoid the "obj __free(...) = NULL" pattern. Per the documentation
in include/linux/cleanup.h.
> struct range *hpa = &cxled->cxld.hpa_range;
> - struct cxl_decoder *cxld = &cxled->cxld;
> - struct device *cxlrd_dev, *region_dev;
> - struct cxl_root_decoder *cxlrd;
> + struct device *region_dev;
> struct cxl_region_params *p;
> struct cxl_region *cxlr;
> bool attach = false;
> int rc;
>
> - cxlrd_dev = device_find_child(&cxl_root->port.dev, &cxld->hpa_range,
> - match_root_decoder_by_range);
> - if (!cxlrd_dev) {
> - dev_err(cxlmd->dev.parent,
> - "%s:%s no CXL window for range %#llx:%#llx\n",
> - dev_name(&cxlmd->dev), dev_name(&cxld->dev),
> - cxld->hpa_range.start, cxld->hpa_range.end);
> + cxlrd = cxl_find_root_decoder(cxled);
...i.e. always instantiate and asssign a scope-based cleanup variable in
one statement.
cxlrd __free(put_cxl_root_decoder) = cxl_find_root_decoder(cxled);
Otherwise, this looks good.
Powered by blists - more mailing lists