RE: [PATCH] cxl/region: Fix target accounting when detaching direct EP

From: 차준호

Date: Thu Nov 19 2026 - 21:17:19 EST


On Wed, Nov 04, 2026 at 05:28:40PM +0800, Richard Cheng wrote:
> E.g. 2 direct EP using a 2-target switch decoder, clearing one region
> targetN entry leaves nr_targets at 2 instead of 1. Refilling that entry
> then attempts to add a 3rd target and fails with -ENXIO, even though the
> requested config fits.

I reproduced this with cxl_test in an x86_64 guest, with the CXL
modules built from cxl/next (32af7819352b) on a 7.4-rc3 kernel. On an
unbound 2-way RAM region over the two endpoints below
cxl_switch_uport.0, clearing target0 and writing the same decoder back
fails with -ENXIO ("overflows targets: 2") without this patch. With
it, the refill and the recommit both succeed.

Tested-by: Junho Cha <junho.cha@xxxxxxxxx>