[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251215135303.00002f63@huawei.com>
Date: Mon, 15 Dec 2025 13:53:03 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: <alejandro.lucero-palau@....com>
CC: <linux-cxl@...r.kernel.org>, <netdev@...r.kernel.org>,
<dan.j.williams@...el.com>, <edward.cree@....com>, <davem@...emloft.net>,
<kuba@...nel.org>, <pabeni@...hat.com>, <edumazet@...gle.com>,
<dave.jiang@...el.com>, Alejandro Lucero <alucerop@....com>
Subject: Re: [PATCH v22 13/25] cxl: Export functions for unwinding cxl by
accelerators
On Fri, 5 Dec 2025 11:52:36 +0000
<alejandro.lucero-palau@....com> wrote:
> From: Alejandro Lucero <alucerop@....com>
>
> Add unregister_region() and cxl_decoder_detach() to the accelerator
> driver API for a clean exit.
>
> Signed-off-by: Alejandro Lucero <alucerop@....com>
In general seems fine but comment on type safety inline.
Jonathan
> ---
> drivers/cxl/core/core.h | 5 -----
> drivers/cxl/core/region.c | 4 +++-
> include/cxl/cxl.h | 9 +++++++++
> 3 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
> index 1c1726856139..9a6775845afe 100644
> --- a/drivers/cxl/core/core.h
> +++ b/drivers/cxl/core/core.h
> @@ -15,11 +15,6 @@ extern const struct device_type cxl_pmu_type;
>
> extern struct attribute_group cxl_base_attribute_group;
>
> -enum cxl_detach_mode {
> - DETACH_ONLY,
> - DETACH_INVALIDATE,
> -};
> -
> #ifdef CONFIG_CXL_REGION
> extern struct device_attribute dev_attr_create_pmem_region;
> extern struct device_attribute dev_attr_create_ram_region;
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 8166a402373e..104caa33b7bb 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2199,6 +2199,7 @@ int cxl_decoder_detach(struct cxl_region *cxlr,
> }
> return 0;
> }
> +EXPORT_SYMBOL_NS_GPL(cxl_decoder_detach, "CXL");
>
> static int __attach_target(struct cxl_region *cxlr,
> struct cxl_endpoint_decoder *cxled, int pos,
> @@ -2393,7 +2394,7 @@ static struct cxl_region *to_cxl_region(struct device *dev)
> return container_of(dev, struct cxl_region, dev);
> }
>
> -static void unregister_region(void *_cxlr)
> +void unregister_region(void *_cxlr)
> {
> struct cxl_region *cxlr = _cxlr;
> struct cxl_region_params *p = &cxlr->params;
> @@ -2412,6 +2413,7 @@ static void unregister_region(void *_cxlr)
> cxl_region_iomem_release(cxlr);
> put_device(&cxlr->dev);
> }
> +EXPORT_SYMBOL_NS_GPL(unregister_region, "CXL");
>
> static struct lock_class_key cxl_region_key;
>
> diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
> index f02dd817b40f..b8683c75dfde 100644
> --- a/include/cxl/cxl.h
> +++ b/include/cxl/cxl.h
> @@ -255,4 +255,13 @@ struct cxl_endpoint_decoder *cxl_get_committed_decoder(struct cxl_memdev *cxlmd,
> struct cxl_region **cxlr);
> struct range;
> int cxl_get_region_range(struct cxl_region *region, struct range *range);
> +enum cxl_detach_mode {
> + DETACH_ONLY,
> + DETACH_INVALIDATE,
> +};
> +
> +int cxl_decoder_detach(struct cxl_region *cxlr,
> + struct cxl_endpoint_decoder *cxled, int pos,
> + enum cxl_detach_mode mode);
> +void unregister_region(void *_cxlr);
I'd wrap this for an exposed interface that isn't going to be used
as a devm callback so we can make it type safe. Maybe making the
existing devm callback the one doing wrapping is cleanest route.
> #endif /* __CXL_CXL_H__ */
Powered by blists - more mailing lists