Re: [PATCH v6 3/9] cxl/region: Skip decoder reset on detach for autodiscovered regions

Koralahalli Channabasappa, Smita
2026-02-20T20:35:57Z

Hi Alison,

On 2/18/2026 7:44 PM, Alison Schofield wrote:
> On Tue, Feb 10, 2026 at 06:44:55AM +0000, Smita Koralahalli wrote:
>> __cxl_decoder_detach() currently resets decoder programming whenever a
>> region is detached if cxl_config_state is beyond CXL_CONFIG_ACTIVE. For
>
> Not sure 'detached' is the right word. Unregistered maybe?
>
>> autodiscovered regions, this can incorrectly tear down decoder state
>> that may be relied upon by other consumers or by subsequent ownership
>> decisions.
>>
>> Skip cxl_region_decode_reset() during detach when CXL_REGION_F_AUTO is
>> set.
>
> I get how this is needed in the failover to DAX case, yet I'm not clear
> how it fits in with folks that just want to destroy that auto region
> and resuse the pieces.
>
> Your other recent patch cxl/hdm: Avoid DVSEC fallback after region teardown[1],
> showed me that the memdevs, when left with the endpoint decoders not reset,
> will keep trying to create another region when reprobed.
>
> [1] https://lore.kernel.org/linux-cxl/aY6pTk63ivjkanlR@aschofie-mobl2.lan/
>
> I think the patch does what it says it does. Perhaps expand on why that
> is always the right thing to do.
>
> --Alison
>
>
>>

Thanks for the review. I will fix detached to unregistered in the commit
message for v7.

I think there are two paths here: Correct me if I'm wrong.

F_AUTO guard only applies to __cxl_decoder_detach(), which is called
from unregister_region()
(unregister_region()->detach_target()->cxl_decoder_detach()..) path and
via store_targetN()
(store_targetN()->detach_target()->cxl_decoder_detach()..). In both
cases, this patch is preserving decoder state for auto-discovered regions.

When a user explicitly destroys an auto-discovered region via cxl
destroy-region, or decommits via commit_store, those paths call
cxl_region_decode_reset()
(commit_store()->cxl_region_decode_reset()->cxld->reset)
unconditionally, they are not gated by F_AUTO. So users who want to
destroy the auto region and reuse the pieces can still do so. The
decoder state is fully reset in that path.

On the DVSEC fallback fix: The endpoint decoders were being reset (by
cxl_region_decode_reset() unconditionally), which zeroed the registers.
On reprobe, should_emulate_decoders() checked per decoder COMMITTED
bits, found them cleared, and incorrectly fell back to DVSEC range
emulation, treating the decoder as AUTO and creating a spurious region..

Also, since nothing in the dax_hmem path calls unregister_region today,
this F_AUTO guard in __cxl_decoder_detach() is only for preserving
firmware decoder state during auto region teardown. I need to rephrase
that in commit message properly. I will also expand the commit message
for v7 documenting how the explicit decommit path still remains available.

Thanks
Smita

>> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>> Reviewed-by: Alejandro Lucero <alucerop@amd.com>
>> ---
>> drivers/cxl/core/region.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>> index ae899f68551f..45ee598daf95 100644
>> --- a/drivers/cxl/core/region.c
>> +++ b/drivers/cxl/core/region.c
>> @@ -2178,7 +2178,9 @@ __cxl_decoder_detach(struct cxl_region *cxlr,
>> cxled->part = -1;
>>
>> if (p->state > CXL_CONFIG_ACTIVE) {
>> - cxl_region_decode_reset(cxlr, p->interleave_ways);
>> + if (!test_bit(CXL_REGION_F_AUTO, &cxlr->flags))
>> + cxl_region_decode_reset(cxlr, p->interleave_ways);
>> +
>> p->state = CXL_CONFIG_ACTIVE;
>> }
>>
>> --
>> 2.17.1
>>