On 24/09/25 01:47PM, Dave Jiang wrote:
+++ b/drivers/cxl/core/pmem_region.c
@@ -290,3 +290,56 @@ int devm_cxl_add_pmem_region(struct cxl_region *cxlr)
return rc;
}
EXPORT_SYMBOL_NS_GPL(devm_cxl_add_pmem_region, "CXL");
+
+static int match_free_ep_decoder(struct device *dev, const void *data)
+{
+ struct cxl_decoder *cxld = to_cxl_decoder(dev);
I think this is needed if the function is match_free_ep_decoder().
if (!is_endpoint_decoder(dev))
return 0;
Yes this check is required, I will add this.
+
+ return !cxld->region;
+}
May want to borrow some code from match_free_decoder() in core/region.c. I
think the decoder commit order matters?
Yes Dave, Looking at [1], seems commit order matters. Sure I will look
at match_free_decoder() in core/region.c
[1]
https://lore.kernel.org/all/172964783668.81806.14962699553881333486.st...@dwillia2-xfh.jf.intel.com/
+
+static struct cxl_decoder *cxl_find_free_ep_decoder(struct cxl_port *port)
+{
+ struct device *dev;
+
+ dev = device_find_child(&port->dev, NULL, match_free_ep_decoder);
+ if (!dev)
+ return NULL;
+
+ /* Release device ref taken via device_find_child() */
+ put_device(dev);
Should have the caller put the device.
Its like taking device ref temporarly and releasing it then and there
after finding proper root decoder. I believe, releasing device ref
from caller would make it look little out of context.
Regards,
Neeraj