On 12/3/2025 4:22 PM, [email protected] wrote:
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.

Okay. To make sure I'm aligned with your suggestion.

It should be something like below in cxl_dax_region_probe():

switch (dax_cxl_mode) {
case DAX_CXL_MODE_DEFER:
        return -EPROBE_DEFER;
case DAX_CXL_MODE_REGISTER:
        return -ENODEV;
case DAX_CXL_MODE_DROP:
default:
        break;
}

Then in the HMEM path, if the SR span is fully covered I will switch to
DAX_CXL_MODE_DROP and trigger a rescan.

Something like:

if (cxl_regions_fully_map(res->start, res->end)) {
        dax_cxl_mode = DAX_CXL_MODE_DROP;
        bus_rescan_devices(&cxl_bus_type);
} else {
        dax_cxl_mode = DAX_CXL_MODE_REGISTER;
        cxl_region_teardown(res->start, res->end);
}

hmem_register_device(host, target_nid, res);

cxl_regions_fully_map() will include changes as suggested in Patch 5.

Thanks
Smita


Reply via email to