Re: [RFC PATCH v1 0/2] cxl/cli: HPA-ordered destroy-region teardown
From: Alison Schofield
Date: Tue Dec 02 2025 - 22:38:40 EST
On Tue, Nov 25, 2025 at 11:38:22PM +0900, Pawel Mielimonka wrote:
> This series addresses an issue in destroy-region, where
> region teardown relied on libcxl enumeration order, which is not
> guaranteed to match the increasing HPA order exposed by the kernel.
> When a decoder window is fully populated, attempting to destroy a
> non-last region causes kernel-side validation to fail (e.g.
> set_dpa_size(..., 0) returns an error), and subsequent destroy/create
> sequences may become impossible.
>
> The CXL specification requires that decoder programming (and the
> implicit teardown path) must preserve continuous HPA coverage and
> proceed strictly in order: decoder m before decoder m+1, with each
> covering an HPA range below the next one. Practically, this means that
> region teardown must follow HPA-descending order and must stop as soon
> as a gap in the requested suffix is encountered.
>
> The patch introduces destroy_multiple_regions(), which collects all
> regions under a given root decoder, sorts them by HPA, and destroys
> only the suffix requested by the user (or all regions in the case of
> “all”). The implementation guarantees that only valid teardown
> sequences are attempted and prevents decoder state inconsistencies
> observed during repeated destroy/create cycles.
>
> Enable/disable paths and all existing bus/port/decoder filtering
> remain unchanged.
Hi Pawel,
Thanks - this is much needed!
It's very valuable that now trying to destroy any region out of
order will fail 'gracefully'.
This worked for 'all' and needs a small fixup for the decoder option.
That's noted in Patch 2 reply. I didn't test the other filtering yet
but started updating a unit test to cover these cases.
See https://github.com/pmem/ndctl/blob/main/CONTRIBUTING.md for
a few housekeeping tips on submitting to NDCTL.
-- Alison
>
> Pawel Mielimonka (2):
> cxl/cli: add helpers to collect and sort regions by HPA
> cxl/cli: enforce HPA-descending teardown order for destroy-region
>
> cxl/region.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 111 insertions(+), 3 deletions(-)
>
> --
> 2.45.1.windows.1
>
>