From: Richard Cheng <icheng@nvidia.com>
To: jic23@kernel.org, dave@stgolabs.net, dave.jiang@intel.com,
vishal.l.verma@intel.com, djbw@kernel.org,
danwilliams@nvidia.com, alison.schofield@intel.com
Cc: iweiny@kernel.org, ming.li@zohomail.com, kaihengf@nvidia.com,
kobak@nvidia.com, vaslot@nvidia.com, mochs@nvidia.com,
newtonl@nvidia.com, kristinc@nvidia.com,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
Richard Cheng <icheng@nvidia.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH v9 1/3] cxl/region: Simplify poison_by_decoder() error handling
Date: Wed, 5 Aug 2026 13:55:22 +0800 [thread overview]
Message-ID: <20260805055524.22311-2-icheng@nvidia.com> (raw)
In-Reply-To: <20260805055524.22311-1-icheng@nvidia.com>
"rc" carries both an error code and the loop control
signal for device_for_each_child(), so returning it bare is misleading,
the early guards mean "keep walking", not "no error". Zeroing "rc" to
forgive an -EFAULT on a RAM partition adds to that by discarding what
the device actually returned.
Return a literal 0 where the walk should continue, and test the
forgiven case directly instead of rewriting "rc". Give that test a
name, poison_efault_forgiven(), so cxl_get_poison_unmapped() and
poison_by_decoder() spell the same rule the same way. No functional
change.
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
---
Changelog:
v8 -> v9:
- Add the poison_efault_forgiven() helper and use it in
cxl_get_poison_unmapped()
v7 -> v8:
- New patch. Splits the poison_by_decoder() readability cleanup out
of "cxl/hdm: Allow zero sized HDM decoders" so the functional
change is not mixed with a refactor of pre-existing code.
---
drivers/cxl/core/region.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 1e211542b6b6..45536909cc17 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2905,6 +2905,16 @@ struct cxl_poison_context {
u64 offset;
};
+/*
+ * A device may answer a Get Poison List request with "physical address
+ * specified is invalid" (-EFAULT). That answer is tolerated for a RAM
+ * partition and the poison walk continues.
+ */
+static inline bool poison_efault_forgiven(int rc, enum cxl_partition_mode mode)
+{
+ return rc == -EFAULT && mode == CXL_PARTMODE_RAM;
+}
+
static int cxl_get_poison_unmapped(struct cxl_memdev *cxlmd,
struct cxl_poison_context *ctx)
{
@@ -2933,7 +2943,7 @@ static int cxl_get_poison_unmapped(struct cxl_memdev *cxlmd,
if (!length)
break;
rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
- if (rc == -EFAULT && cxlds->part[i].mode == CXL_PARTMODE_RAM)
+ if (poison_efault_forgiven(rc, cxlds->part[i].mode))
continue;
if (rc)
break;
@@ -2950,14 +2960,14 @@ static int poison_by_decoder(struct device *dev, void *arg)
struct cxl_dev_state *cxlds;
struct cxl_memdev *cxlmd;
u64 offset, length;
- int rc = 0;
+ int rc;
if (!is_endpoint_decoder(dev))
- return rc;
+ return 0;
cxled = to_cxl_endpoint_decoder(dev);
if (!cxled->dpa_res)
- return rc;
+ return 0;
cxlmd = cxled_to_memdev(cxled);
cxlds = cxlmd->cxlds;
@@ -2967,18 +2977,14 @@ static int poison_by_decoder(struct device *dev, void *arg)
offset = cxled->dpa_res->start - cxled->skip;
length = cxled->skip;
rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
- if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
- rc = 0;
- if (rc)
+ if (rc && !poison_efault_forgiven(rc, mode))
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;
- if (rc)
+ if (rc && !poison_efault_forgiven(rc, mode))
return rc;
/* Iterate until commit_end is reached */
--
2.43.0
next prev parent reply other threads:[~2026-08-05 5:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 5:55 [PATCH v9 0/3] Support zero-sized HDM decoders Richard Cheng
2026-08-05 5:55 ` Richard Cheng [this message]
2026-08-05 6:09 ` [PATCH v9 1/3] cxl/region: Simplify poison_by_decoder() error handling sashiko-bot
2026-08-05 5:55 ` [PATCH v9 2/3] cxl/hdm: Allow zero sized HDM decoders Richard Cheng
2026-08-05 6:09 ` sashiko-bot
2026-08-05 5:55 ` [PATCH v9 3/3] tools/testing/cxl: Enable zero sized decoders under hb0 Richard Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805055524.22311-2-icheng@nvidia.com \
--to=icheng@nvidia.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=danwilliams@nvidia.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=kaihengf@nvidia.com \
--cc=kobak@nvidia.com \
--cc=kristinc@nvidia.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=mochs@nvidia.com \
--cc=newtonl@nvidia.com \
--cc=vaslot@nvidia.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox