Skip to content

Commit 39aa1d4

Browse files
djbwdavejiang
authored andcommitted
dax/cxl, hmem: Initialize hmem early and defer dax_cxl binding
Move hmem/ earlier in the dax Makefile so that hmem_init() runs before dax_cxl. In addition, defer registration of the dax_cxl driver to a workqueue instead of using module_cxl_driver(). This ensures that dax_hmem has an opportunity to initialize and register its deferred callback and make ownership decisions before dax_cxl begins probing and claiming Soft Reserved ranges. Mark the dax_cxl driver as PROBE_PREFER_ASYNCHRONOUS so its probe runs out of line from other synchronous probing avoiding ordering dependencies while coordinating ownership decisions with dax_hmem. Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Tested-by: Tomasz Wolski <tomasz.wolski@fujitsu.com> Link: https://patch.msgid.link/20260322195343.206900-6-Smita.KoralahalliChannabasappa@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent edfcf1e commit 39aa1d4

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

drivers/dax/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
obj-y += hmem/
23
obj-$(CONFIG_DAX) += dax.o
34
obj-$(CONFIG_DEV_DAX) += device_dax.o
45
obj-$(CONFIG_DEV_DAX_KMEM) += kmem.o
@@ -10,5 +11,3 @@ dax-y += bus.o
1011
device_dax-y := device.o
1112
dax_pmem-y := pmem.o
1213
dax_cxl-y := cxl.o
13-
14-
obj-y += hmem/

drivers/dax/cxl.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,35 @@ static struct cxl_driver cxl_dax_region_driver = {
3838
.id = CXL_DEVICE_DAX_REGION,
3939
.drv = {
4040
.suppress_bind_attrs = true,
41+
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
4142
},
4243
};
4344

44-
module_cxl_driver(cxl_dax_region_driver);
45+
static void cxl_dax_region_driver_register(struct work_struct *work)
46+
{
47+
cxl_driver_register(&cxl_dax_region_driver);
48+
}
49+
50+
static DECLARE_WORK(cxl_dax_region_driver_work, cxl_dax_region_driver_register);
51+
52+
static int __init cxl_dax_region_init(void)
53+
{
54+
/*
55+
* Need to resolve a race with dax_hmem wanting to drive regions
56+
* instead of CXL
57+
*/
58+
queue_work(system_long_wq, &cxl_dax_region_driver_work);
59+
return 0;
60+
}
61+
module_init(cxl_dax_region_init);
62+
63+
static void __exit cxl_dax_region_exit(void)
64+
{
65+
flush_work(&cxl_dax_region_driver_work);
66+
cxl_driver_unregister(&cxl_dax_region_driver);
67+
}
68+
module_exit(cxl_dax_region_exit);
69+
4570
MODULE_ALIAS_CXL(CXL_DEVICE_DAX_REGION);
4671
MODULE_DESCRIPTION("CXL DAX: direct access to CXL regions");
4772
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)