Re: [PATCH v4 6/9] cxl/region: Add register_dax flag to defer DAX setup

From: dan.j.williams

Date: Wed Dec 03 2025 - 19:23:07 EST


Smita Koralahalli wrote:
> Stop creating cxl_dax during cxl_region_probe(). Early DAX registration
> can online memory before ownership of Soft Reserved ranges is finalized.
> This makes it difficult to tear down regions later when HMEM determines
> that a region should not claim that range.
>
> Introduce a register_dax flag in struct cxl_region_params and gate DAX
> registration on this flag. Leave probe time registration disabled for
> regions discovered during early CXL enumeration; set the flag only for
> regions created dynamically at runtime to preserve existing behaviour.
>
> This patch prepares the region code for later changes where cxl_dax
> setup occurs from the HMEM path only after ownership arbitration
> completes.

This seems backwards to me. The dax subsystem knows when it wants to
move ahead with CXL or not, dax_cxl_mode is that indicator. So, just
share that variable with drivers/dax/cxl.c, arrange for
cxl_dax_region_probe() to fail while waiting for initial CXL probing to
succeed.

Once that point is reached move dax_cxl_mode to DAX_CXL_MODE_DROP, which
means drop the hmem alias, and go with the real-deal CXL region. Rescan
the dax-bus to retry cxl_dax_region_probe(). No need to bother 'struct
cxl_region' with a 'dax' flag, it just registers per normal and lets the
dax-subsystem handle accepting / rejecting.

Now, we do need a mechanism from dax-to-cxl to trigger region removal in
the DAX_CXL_MODE_REGISTER case (proceed with the hmem registration), but
that is separate from blocking the attachment of dax to CXL regions.
Keep all that complexity local to dax.