[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250314113132.000043ce@huawei.com>
Date: Fri, 14 Mar 2025 11:31:32 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Robert Richter <rrichter@....com>
CC: 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>, Dave Jiang <dave.jiang@...el.com>, "Davidlohr
Bueso" <dave@...olabs.net>, <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 v4 02/14] cxl/pci: Moving code in cxl_hdm_decode_init()
On Thu, 6 Mar 2025 17:44:36 +0100
Robert Richter <rrichter@....com> wrote:
> Commit 3f9e07531778 ("cxl/pci: simplify the check of mem_enabled in
> cxl_hdm_decode_init()") changed the code flow in this function. The
> root port is determined before a check to leave the function. Since
> the root port is not used by the check it can be moved to run the
> check first. This improves code readability and avoids unnesessary
> code execution.
>
> Signed-off-by: Robert Richter <rrichter@....com>
> Reviewed-by: Gregory Price <gourry@...rry.net>
> Reviewed-by: Davidlohr Bueso <dave@...olabs.net>
> Tested-by: Gregory Price <gourry@...rry.net>
> ---
> drivers/cxl/core/pci.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> index 33c3bdd35b24..6386e84e51a4 100644
> --- a/drivers/cxl/core/pci.c
> +++ b/drivers/cxl/core/pci.c
> @@ -419,14 +419,6 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
> if (!hdm)
> return -ENODEV;
>
> - root = to_cxl_port(port->dev.parent);
> - while (!is_cxl_root(root) && is_cxl_port(root->dev.parent))
> - root = to_cxl_port(root->dev.parent);
> - if (!is_cxl_root(root)) {
> - dev_err(dev, "Failed to acquire root port for HDM enable\n");
> - return -ENODEV;
> - }
> -
> if (!info->mem_enabled) {
> rc = devm_cxl_enable_hdm(&port->dev, cxlhdm);
> if (rc)
> @@ -435,6 +427,14 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
> return devm_cxl_enable_mem(&port->dev, cxlds);
> }
>
> + root = to_cxl_port(port->dev.parent);
> + while (!is_cxl_root(root) && is_cxl_port(root->dev.parent))
> + root = to_cxl_port(root->dev.parent);
> + if (!is_cxl_root(root)) {
> + dev_err(dev, "Failed to acquire root port for HDM enable\n");
Is this error message suffering from code rot? In the path where
root is used, use no HDM enabling occurs.
> + return -ENODEV;
> + }
> +
> for (i = 0, allowed = 0; i < info->ranges; i++) {
> struct device *cxld_dev;
>
Powered by blists - more mailing lists