[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <43772918-1911-46a5-8165-bf612056a8e6@intel.com>
Date: Wed, 24 Sep 2025 11:11:12 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Neeraj Kumar <s.neeraj@...sung.com>, linux-cxl@...r.kernel.org,
nvdimm@...ts.linux.dev, linux-kernel@...r.kernel.org, gost.dev@...sung.com
Cc: a.manzanares@...sung.com, vishak.g@...sung.com, neeraj.kernel@...il.com,
cpgs@...sung.com
Subject: Re: [PATCH V3 15/20] cxl: Add a routine to find cxl root decoder on
cxl bus using cxl port
On 9/17/25 6:41 AM, Neeraj Kumar wrote:
> Add cxl_find_root_decoder_by_port() to find root decoder on cxl bus.
> It is used to find root decoder using cxl port.
>
> Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
> ---
> drivers/cxl/core/port.c | 27 +++++++++++++++++++++++++++
> drivers/cxl/cxl.h | 1 +
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8f36ff413f5d..647d9ce32b64 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -518,6 +518,33 @@ struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev)
> }
> EXPORT_SYMBOL_NS_GPL(to_cxl_switch_decoder, "CXL");
>
> +static int match_root_decoder(struct device *dev, const void *data)
> +{
> + return is_root_decoder(dev);
> +}
> +
> +/**
> + * cxl_find_root_decoder_by_port() - find a cxl root decoder on cxl bus
> + * @port: any descendant port in CXL port topology
> + */
> +struct cxl_root_decoder *cxl_find_root_decoder_by_port(struct cxl_port *port)
> +{
> + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
> + struct device *dev;
> +
> + if (!cxl_root)
> + return NULL;
> +
> + dev = device_find_child(&cxl_root->port.dev, NULL, match_root_decoder);
> + if (!dev)
> + return NULL;
> +
> + /* Release device ref taken via device_find_child() */
> + put_device(dev);
Should the caller release the device reference instead?
DJ
> + return to_cxl_root_decoder(dev);
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_find_root_decoder_by_port, "CXL");
> +
> static void cxl_ep_release(struct cxl_ep *ep)
> {
> put_device(ep->ep);
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 3abadc3dc82e..1eb1aca7c69f 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -866,6 +866,7 @@ struct cxl_nvdimm *to_cxl_nvdimm(struct device *dev);
> bool is_cxl_nvdimm(struct device *dev);
> int devm_cxl_add_nvdimm(struct cxl_port *parent_port, struct cxl_memdev *cxlmd);
> struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_port *port);
> +struct cxl_root_decoder *cxl_find_root_decoder_by_port(struct cxl_port *port);
>
> #ifdef CONFIG_CXL_REGION
> bool is_cxl_pmem_region(struct device *dev);
Powered by blists - more mailing lists