[PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem

Smita Koralahalli posted 6 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem
Posted by Smita Koralahalli 1 month, 1 week ago
Update Kconfig and runtime checks to better coordinate dax_cxl and dax_hmem
registration.

Add explicit Kconfig ordering so that CXL_ACPI and CXL_PCI must be
initialized before DEV_DAX_HMEM. This prevents dax_hmem from consuming
Soft Reserved ranges before CXL drivers have had a chance to claim them.

Replace IS_ENABLED(CONFIG_CXL_REGION) with IS_ENABLED(CONFIG_DEV_DAX_CXL)
so the code more precisely reflects when CXL-specific DAX coordination is
expected.

This ensures that ownership of Soft Reserved ranges is consistently
handed off to the CXL stack when DEV_DAX_CXL is configured.

Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/dax/Kconfig     | 2 ++
 drivers/dax/hmem/hmem.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig
index d656e4c0eb84..3683bb3f2311 100644
--- a/drivers/dax/Kconfig
+++ b/drivers/dax/Kconfig
@@ -48,6 +48,8 @@ config DEV_DAX_CXL
 	tristate "CXL DAX: direct access to CXL RAM regions"
 	depends on CXL_BUS && CXL_REGION && DEV_DAX
 	default CXL_REGION && DEV_DAX
+	depends on CXL_ACPI >= DEV_DAX_HMEM
+	depends on CXL_PCI >= DEV_DAX_HMEM
 	help
 	  CXL RAM regions are either mapped by platform-firmware
 	  and published in the initial system-memory map as "System RAM", mapped
diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
index 9277e5ea0019..7ada820cb177 100644
--- a/drivers/dax/hmem/hmem.c
+++ b/drivers/dax/hmem/hmem.c
@@ -66,7 +66,7 @@ static int hmem_register_device(struct device *host, int target_nid,
 	long id;
 	int rc;
 
-	if (IS_ENABLED(CONFIG_CXL_REGION) &&
+	if (IS_ENABLED(CONFIG_DEV_DAX_CXL) &&
 	    region_intersects(res->start, resource_size(res), IORESOURCE_MEM,
 			      IORES_DESC_CXL) != REGION_DISJOINT) {
 		dev_dbg(host, "deferring range to CXL: %pr\n", res);
-- 
2.17.1
Re: [PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem
Posted by Zhijian Li (Fujitsu) 1 month ago

On 22/08/2025 11:41, Smita Koralahalli wrote:
> Update Kconfig and runtime checks to better coordinate dax_cxl and dax_hmem
> registration.
> 
> Add explicit Kconfig ordering so that CXL_ACPI and CXL_PCI must be
> initialized before DEV_DAX_HMEM. 

Is this dependency statement fully accurate? To clarify, another prerequisite for
this ordering to work correctly is that dax_hmem must explicitly call
`request_module("cxl_acpi")` and `request_module("cxl_pci")` during its initialization.
  
Therefore, I recommend consolidating the following patches into a single commit
to ensure atomic handling of the initialization order:
- [PATCH 2/6] dax/hmem: Request cxl_acpi and cxl_pci before walking Soft Reserved ranges
- [PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem

Thanks
Zhijian

> This prevents dax_hmem from consuming
> Soft Reserved ranges before CXL drivers have had a chance to claim them.
> 
> Replace IS_ENABLED(CONFIG_CXL_REGION) with IS_ENABLED(CONFIG_DEV_DAX_CXL)
> so the code more precisely reflects when CXL-specific DAX coordination is
> expected.
> 
> This ensures that ownership of Soft Reserved ranges is consistently
> handed off to the CXL stack when DEV_DAX_CXL is configured.
Re: [PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem
Posted by Koralahalli Channabasappa, Smita 3 days, 20 hours ago
On 8/31/2025 8:28 PM, Zhijian Li (Fujitsu) wrote:
> 
> 
> On 22/08/2025 11:41, Smita Koralahalli wrote:
>> Update Kconfig and runtime checks to better coordinate dax_cxl and dax_hmem
>> registration.
>>
>> Add explicit Kconfig ordering so that CXL_ACPI and CXL_PCI must be
>> initialized before DEV_DAX_HMEM.
> 
> Is this dependency statement fully accurate? To clarify, another prerequisite for
> this ordering to work correctly is that dax_hmem must explicitly call
> `request_module("cxl_acpi")` and `request_module("cxl_pci")` during its initialization.
>    
> Therefore, I recommend consolidating the following patches into a single commit
> to ensure atomic handling of the initialization order:
> - [PATCH 2/6] dax/hmem: Request cxl_acpi and cxl_pci before walking Soft Reserved ranges
> - [PATCH 3/6] dax/hmem, cxl: Tighten dependencies on DEV_DAX_CXL and dax_hmem
> 
> Thanks
> Zhijian

I have merged 2/6 and 3/6 in v2.

Thanks
Smita

>> This prevents dax_hmem from consuming
>> Soft Reserved ranges before CXL drivers have had a chance to claim them.
>>
>> Replace IS_ENABLED(CONFIG_CXL_REGION) with IS_ENABLED(CONFIG_DEV_DAX_CXL)
>> so the code more precisely reflects when CXL-specific DAX coordination is
>> expected.
>>
>> This ensures that ownership of Soft Reserved ranges is consistently
>> handed off to the CXL stack when DEV_DAX_CXL is configured.