Ensure that cxl_acpi has published CXL Window resources before dax_hmem
walks Soft Reserved ranges.
Replace MODULE_SOFTDEP("pre: cxl_acpi") with an explicit, synchronous
request_module("cxl_acpi"). MODULE_SOFTDEP() only guarantees eventual
loading, it does not enforce that the dependency has finished init
before the current module runs. This can cause dax_hmem to start before
cxl_acpi has populated the resource tree, breaking detection of overlaps
between Soft Reserved and CXL Windows.
Also, request cxl_pci before dax_hmem walks Soft Reserved ranges. Unlike
cxl_acpi, cxl_pci attach is asynchronous and creates dependent devices
that trigger further module loads. Asynchronous probe flushing
(wait_for_device_probe()) is added later in the series in a deferred
context before dax_hmem makes ownership decisions for Soft Reserved
ranges.
Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/dax/hmem/hmem.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
index d5b8f06d531e..9277e5ea0019 100644
--- a/drivers/dax/hmem/hmem.c
+++ b/drivers/dax/hmem/hmem.c
@@ -146,6 +146,16 @@ static __init int dax_hmem_init(void)
{
int rc;
+ /*
+ * Ensure that cxl_acpi and cxl_pci have a chance to kick off
+ * CXL topology discovery at least once before scanning the
+ * iomem resource tree for IORES_DESC_CXL resources.
+ */
+ if (IS_ENABLED(CONFIG_DEV_DAX_CXL)) {
+ request_module("cxl_acpi");
+ request_module("cxl_pci");
+ }
+
rc = platform_driver_register(&dax_hmem_platform_driver);
if (rc)
return rc;
@@ -166,13 +176,6 @@ static __exit void dax_hmem_exit(void)
module_init(dax_hmem_init);
module_exit(dax_hmem_exit);
-/* Allow for CXL to define its own dax regions */
-#if IS_ENABLED(CONFIG_CXL_REGION)
-#if IS_MODULE(CONFIG_CXL_ACPI)
-MODULE_SOFTDEP("pre: cxl_acpi");
-#endif
-#endif
-
MODULE_ALIAS("platform:hmem*");
MODULE_ALIAS("platform:hmem_platform*");
MODULE_DESCRIPTION("HMEM DAX: direct access to 'specific purpose' memory");
--
2.17.1
On 8/21/25 8:41 PM, Smita Koralahalli wrote: > Ensure that cxl_acpi has published CXL Window resources before dax_hmem > walks Soft Reserved ranges. > > Replace MODULE_SOFTDEP("pre: cxl_acpi") with an explicit, synchronous > request_module("cxl_acpi"). MODULE_SOFTDEP() only guarantees eventual > loading, it does not enforce that the dependency has finished init > before the current module runs. This can cause dax_hmem to start before > cxl_acpi has populated the resource tree, breaking detection of overlaps > between Soft Reserved and CXL Windows. > > Also, request cxl_pci before dax_hmem walks Soft Reserved ranges. Unlike > cxl_acpi, cxl_pci attach is asynchronous and creates dependent devices > that trigger further module loads. Asynchronous probe flushing > (wait_for_device_probe()) is added later in the series in a deferred > context before dax_hmem makes ownership decisions for Soft Reserved > ranges. > > Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> > --- > drivers/dax/hmem/hmem.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c > index d5b8f06d531e..9277e5ea0019 100644 > --- a/drivers/dax/hmem/hmem.c > +++ b/drivers/dax/hmem/hmem.c > @@ -146,6 +146,16 @@ static __init int dax_hmem_init(void) > { > int rc; > > + /* > + * Ensure that cxl_acpi and cxl_pci have a chance to kick off > + * CXL topology discovery at least once before scanning the > + * iomem resource tree for IORES_DESC_CXL resources. > + */ > + if (IS_ENABLED(CONFIG_DEV_DAX_CXL)) { > + request_module("cxl_acpi"); > + request_module("cxl_pci"); > + } > + > rc = platform_driver_register(&dax_hmem_platform_driver); > if (rc) > return rc; > @@ -166,13 +176,6 @@ static __exit void dax_hmem_exit(void) > module_init(dax_hmem_init); > module_exit(dax_hmem_exit); > > -/* Allow for CXL to define its own dax regions */ > -#if IS_ENABLED(CONFIG_CXL_REGION) > -#if IS_MODULE(CONFIG_CXL_ACPI) > -MODULE_SOFTDEP("pre: cxl_acpi"); > -#endif > -#endif > - > MODULE_ALIAS("platform:hmem*"); > MODULE_ALIAS("platform:hmem_platform*"); > MODULE_DESCRIPTION("HMEM DAX: direct access to 'specific purpose' memory");
I personally recommend that this patch be moved to position 1/6 in the series, as it specifically addresses the existing issue. Thanks Zhijian On 22/08/2025 11:41, Smita Koralahalli wrote: > Ensure that cxl_acpi has published CXL Window resources before dax_hmem > walks Soft Reserved ranges. > > Replace MODULE_SOFTDEP("pre: cxl_acpi") with an explicit, synchronous > request_module("cxl_acpi"). MODULE_SOFTDEP() only guarantees eventual > loading, it does not enforce that the dependency has finished init > before the current module runs. This can cause dax_hmem to start before > cxl_acpi has populated the resource tree, breaking detection of overlaps > between Soft Reserved and CXL Windows. > > Also, request cxl_pci before dax_hmem walks Soft Reserved ranges. Unlike > cxl_acpi, cxl_pci attach is asynchronous and creates dependent devices > that trigger further module loads. Asynchronous probe flushing > (wait_for_device_probe()) is added later in the series in a deferred > context before dax_hmem makes ownership decisions for Soft Reserved > ranges. > > Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > drivers/dax/hmem/hmem.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c > index d5b8f06d531e..9277e5ea0019 100644 > --- a/drivers/dax/hmem/hmem.c > +++ b/drivers/dax/hmem/hmem.c > @@ -146,6 +146,16 @@ static __init int dax_hmem_init(void) > { > int rc; > > + /* > + * Ensure that cxl_acpi and cxl_pci have a chance to kick off > + * CXL topology discovery at least once before scanning the > + * iomem resource tree for IORES_DESC_CXL resources. > + */ > + if (IS_ENABLED(CONFIG_DEV_DAX_CXL)) { > + request_module("cxl_acpi"); > + request_module("cxl_pci"); > + } > + > rc = platform_driver_register(&dax_hmem_platform_driver); > if (rc) > return rc; > @@ -166,13 +176,6 @@ static __exit void dax_hmem_exit(void) > module_init(dax_hmem_init); > module_exit(dax_hmem_exit); > > -/* Allow for CXL to define its own dax regions */ > -#if IS_ENABLED(CONFIG_CXL_REGION) > -#if IS_MODULE(CONFIG_CXL_ACPI) > -MODULE_SOFTDEP("pre: cxl_acpi"); > -#endif > -#endif > - > MODULE_ALIAS("platform:hmem*"); > MODULE_ALIAS("platform:hmem_platform*"); > MODULE_DESCRIPTION("HMEM DAX: direct access to 'specific purpose' memory");
© 2016 - 2025 Red Hat, Inc.