mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cxl/region: Restore passthrough decoder enable on region re-assembly
@ 2026-07-27 10:37 Richard Cheng
  2026-07-27 20:25 ` Dave Jiang
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Cheng @ 2026-07-27 10:37 UTC (permalink / raw)
  To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma, djbw,
	danwilliams
  Cc: iweiny, ming.li, gourry, rrichter, linux-cxl, linux-kernel,
	sreddym, smadhavan, kaihengf, kobak, newtonl, kristinc, mochs,
	Richard Cheng

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-05  6:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 10:37 [PATCH] cxl/region: Restore passthrough decoder enable on region re-assembly Richard Cheng
2026-07-27 20:25 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®