Re: [PATCH v23 10/22] cxl: Export function for unwinding cxl by accelerators
From: Dave Jiang <dave.jiang@intel.com>
Date: 2026-02-19 23:16:54
Also in:
linux-cxl
On 2/1/26 8:54 AM, alejandro.lucero-palau@amd.com wrote:
From: Alejandro Lucero <redacted> Add cxl_unregister_region() to the accelerator driver API for a clean exit. Signed-off-by: Alejandro Lucero <redacted>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
quoted hunk ↗ jump to hunk
--- drivers/cxl/core/region.c | 17 ++++++++++++----- include/cxl/cxl.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-)diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index acf29ba3b205..954b8fcdbac6 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c@@ -2438,9 +2438,8 @@ 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 cxl_unregister_region(struct cxl_region *cxlr) { - struct cxl_region *cxlr = _cxlr; struct cxl_region_params *p = &cxlr->params; int i;@@ -2457,6 +2456,14 @@ static void unregister_region(void *_cxlr) cxl_region_iomem_release(cxlr); put_device(&cxlr->dev); } +EXPORT_SYMBOL_NS_GPL(cxl_unregister_region, "CXL"); + +static void __unregister_region(void *_cxlr) +{ + struct cxl_region *cxlr = _cxlr; + + return cxl_unregister_region(cxlr); +} static struct lock_class_key cxl_region_key;@@ -2608,7 +2615,7 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd, if (rc) goto err; - rc = devm_add_action_or_reset(port->uport_dev, unregister_region, cxlr); + rc = devm_add_action_or_reset(port->uport_dev, __unregister_region, cxlr); if (rc) return ERR_PTR(rc);@@ -2762,7 +2769,7 @@ static ssize_t delete_region_store(struct device *dev, if (IS_ERR(cxlr)) return PTR_ERR(cxlr); - devm_release_action(port->uport_dev, unregister_region, cxlr); + devm_release_action(port->uport_dev, __unregister_region, cxlr); put_device(&cxlr->dev); return len;@@ -3878,7 +3885,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, rc = __construct_region(cxlr, cxlrd, cxled); if (rc) { - devm_release_action(port->uport_dev, unregister_region, cxlr); + devm_release_action(port->uport_dev, __unregister_region, cxlr); return ERR_PTR(rc); }diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h index 906065e0d2a6..92880c26b2d5 100644 --- a/include/cxl/cxl.h +++ b/include/cxl/cxl.h@@ -254,4 +254,5 @@ 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); +void cxl_unregister_region(struct cxl_region *cxlr); #endif /* __CXL_CXL_H__ */