Thread (36 messages) 36 messages, 4 authors, 2025-12-19

Re: [PATCH v22 13/25] cxl: Export functions for unwinding cxl by accelerators

From: Alejandro Lucero Palau <hidden>
Date: 2025-12-18 12:07:29
Also in: netdev

On 12/15/25 13:53, Jonathan Cameron wrote:
On Fri, 5 Dec 2025 11:52:36 +0000
[off-list ref] wrote:
quoted
From: Alejandro Lucero <redacted>

Add unregister_region() and cxl_decoder_detach() to the accelerator
driver API for a clean exit.

Signed-off-by: Alejandro Lucero <redacted>
In general seems fine but comment on type safety inline.

Jonathan
quoted
---
  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.

I think it is a good idea. I will think how to do it following your advice.

Thanks

quoted
  #endif /* __CXL_CXL_H__ */
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help