Re: [RFC PATCH 2/5] cxl/region: Factor decoder poison-list retrieval
From: Jonathan Cameron
Date: Fri Oct 16 2026 - 18:24:33 EST
On Sat, 10 Oct 2026 21:50:10 +0530
Shaikh Kamaluddin <shaikhkamal2012@xxxxxxxxx> wrote:
> poison_by_decoder() performs two different operations: it queries an
> unmapped DPA gap preceding an endpoint decoder, then queries the DPA
> resource assigned to that decoder and its region.
>
> Factor the second operation into cxl_get_poison_by_decoder(). Give the
> helper an optional snapshot so a later region-probe caller can retain
> records from exactly one mapped decoder. Keep the existing endpoint
> walk, skipped-DPA queries, partition-tail queries, -EFAULT handling, and
> trace behavior unchanged.
>
> Signed-off-by: Shaikh Kamaluddin <shaikhkamal2012@xxxxxxxxx>
> ---
> drivers/cxl/core/region.c | 41 ++++++++++++++++++++++++++++++++++-----
> 1 file changed, 36 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 75b8092e6dc2..c72524923b38 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2940,6 +2940,40 @@ static int cxl_get_poison_unmapped(struct cxl_memdev *cxlmd,
> return rc;
> }
>
> +enum cxl_poison_query_policy {
> + CXL_POISON_QUERY_DIAGNOSTIC,
> + CXL_POISON_QUERY_PREONLINE,
For now, perhaps focus on flags defining what you want done, not when the
query is happening.
> +};
> +
> +static int cxl_get_poison_by_decoder(struct cxl_endpoint_decoder *cxled,
> + struct cxl_poison_snapshot *snapshot,
> + enum cxl_poison_query_policy policy)
> +{
> + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
> + struct cxl_dev_state *cxlds = cxlmd->cxlds;
> + enum cxl_partition_mode mode;
> + u64 offset, length;
> + int rc;
> +
> + if (!cxled->dpa_res)
> + return 0;
> +
> + mode = cxlds->part[cxled->part].mode;
> + offset = cxled->dpa_res->start;
> + length = resource_size(cxled->dpa_res);
> + if (snapshot)
> + rc = cxl_mem_get_poison_snapshot(cxlmd, offset, length,
> + cxled->cxld.region, snapshot);
> + else
> + rc = cxl_mem_get_poison(cxlmd, offset, length,
> + cxled->cxld.region);
> +
> + if (rc == -EFAULT && mode == CXL_PARTMODE_RAM &&
> + policy == CXL_POISON_QUERY_DIAGNOSTIC)
This is becoming odd enough I'd add some comments saying why
we are eating the error return.
> + rc = 0;
> + return rc;
> +}
> +
> static int poison_by_decoder(struct device *dev, void *arg)
> {
> struct cxl_poison_context *ctx = arg;
> @@ -2971,11 +3005,8 @@ static int poison_by_decoder(struct device *dev, void *arg)
> return rc;
> }
>
> - offset = cxled->dpa_res->start;
> - length = cxled->dpa_res->end - offset + 1;
> - rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region);
> - if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
> - rc = 0;
> + rc = cxl_get_poison_by_decoder(cxled, NULL,
> + CXL_POISON_QUERY_DIAGNOSTIC);
> if (rc)
> return rc;
>