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

Alison Schofield
2026-02-19T03:44:54Z

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

>
> 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
>