From: Richard Cheng <icheng@nvidia.com>
To: dave@stgolabs.net, jic23@kernel.org, dave.jiang@intel.com,
alison.schofield@intel.com, vishal.l.verma@intel.com,
djbw@kernel.org, danwilliams@nvidia.com
Cc: iweiny@kernel.org, ming.li@zohomail.com, gourry@gourry.net,
rrichter@amd.com, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org, sreddym@nvidia.com,
smadhavan@nvidia.com, kaihengf@nvidia.com, kobak@nvidia.com,
newtonl@nvidia.com, kristinc@nvidia.com, mochs@nvidia.com,
Richard Cheng <icheng@nvidia.com>
Subject: [PATCH] cxl/region: Restore passthrough decoder enable on region re-assembly
Date: Mon, 27 Jul 2026 18:37:43 +0800 [thread overview]
Message-ID: <20260727103743.63343-1-icheng@nvidia.com> (raw)
After a CXL endpoint is PCI hot-removed and the bus rescanned, an
auto-discovered region fails to rebiuld and is lost, evne though the
device's HDM decoder is still committed and decoding.
A single-dport host bridge/root port has no HDM decoder capability, so
its switch decoder is a SW-only passthrough. Its CXL_DECODER_F_ENABLE
flag is cleared on region teardown and never restored on rescan, so
cxl_port_setup_targets() fails with -ENXIO.
Re-enable the passthrough decoder when its interleave and HPA config
still match the region, it holds no HW state.
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
drivers/cxl/core/region.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 1e211542b6b6..011ceb5bae79 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1574,6 +1574,19 @@ static int cxl_port_setup_targets(struct cxl_port *port,
}
if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) {
+ /*
+ * A passthrough switch decoder holds no HW decode state.
+ * It's CXL_DECODER_F_ENABLE flag is pure software bookkeeping
+ * that is cleared when the region is torn down. On auto-discovery
+ * re-assembly after a subsequent rescan the decode config still
+ * matches the region, so restore the flag rather than fail to
+ * rebuild a region that HW is in fact still decoding.
+ */
+ if (!cxld->commit && cxld->interleave_ways == iw &&
+ (iw <= 1 || cxld->interleave_granularity == ig) &&
+ spa_maps_hpa(p, &cxld->hpa_range))
+ cxld->flags |= CXL_DECODER_F_ENABLE;
+
if (cxld->interleave_ways != iw ||
(iw > 1 && cxld->interleave_granularity != ig) ||
!spa_maps_hpa(p, &cxld->hpa_range) ||
base-commit: 4539944e515183668109bdf4d0c3d7d228383d88
--
2.43.0
next reply other threads:[~2026-07-27 10:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 10:37 Richard Cheng [this message]
2026-07-27 20:25 ` [PATCH] cxl/region: Restore passthrough decoder enable on region re-assembly Dave Jiang
2026-07-28 3:03 ` Richard Cheng
2026-07-28 4:14 ` Gregory Price
2026-07-31 9:13 ` Richard Cheng
2026-07-28 14:25 ` Dave Jiang
2026-08-05 6:21 ` Richard Cheng
2026-08-05 6:55 ` Gregory Price
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=20260727103743.63343-1-icheng@nvidia.com \
--to=icheng@nvidia.com \
--cc=alison.schofield@intel.com \
--cc=danwilliams@nvidia.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=gourry@gourry.net \
--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=rrichter@amd.com \
--cc=smadhavan@nvidia.com \
--cc=sreddym@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