Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/hdm: Account for locked decoders regardless of commit state
@ 2026-10-29 20:13 Davidlohr Bueso
  2026-10-29 23:08 ` Dave Jiang
  2026-11-20  0:16 ` Alison Schofield
  0 siblings, 2 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2026-10-29 20:13 UTC (permalink / raw)
  To: dave.jiang; +Cc: jic23, alison.schofield, ming.li, icheng, linux-cxl, dave

Firmware may arm a locked decoder it leaves uncommitted, a corner
case albeit a valid one. Enumeration only records the bit for committed
decoders, yet setup_hw_decoder() carries it through and the driver's
own commit triggers it read-only.

A later region teardown then writes a reset the hardware ignores and
clears CXL_DECODER_F_ENABLE anyway, so the decoder looks free while it
still decodes and releases its DPA.

Record the bit regardless of the commit state, such that the decoder
then reads locked from probe, and a region built on it is locked at
attach.

Tested on qemu modified to enforce locked, arming the bit on an
uncommitted endpoint decoder before the endpoint probes, then
committing and deleting a 256M region on it and creating a 512M one.
Before, the decoder and region read unlocked, the DPA is freed and the
second region reports committed while the hardware still decodes the
first; after, both read locked from attach, decommit fails with
-EPERM, the DPA release with -EBUSY, and the second region cannot
allocate DPA.

Fixes: 2230c4bdc412 ("cxl: Add handling of locked CXL decoder")
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 drivers/cxl/core/hdm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index fdcef20e01ba..a34f3509ab1f 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -1064,11 +1064,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
 		.end = base + size - 1,
 	};
 
+	if (ctrl & CXL_HDM_DECODER0_CTRL_LOCK)
+		cxld->flags |= CXL_DECODER_F_LOCK;
+
 	/* decoders are enabled if committed */
 	if (committed) {
 		cxld->flags |= CXL_DECODER_F_ENABLE;
-		if (ctrl & CXL_HDM_DECODER0_CTRL_LOCK)
-			cxld->flags |= CXL_DECODER_F_LOCK;
 		if (FIELD_GET(CXL_HDM_DECODER0_CTRL_HOSTONLY, ctrl))
 			cxld->target_type = CXL_DECODER_HOSTONLYMEM;
 		else
-- 
2.39.5


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

end of thread, other threads:[~2026-11-20  0:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 20:13 [PATCH] cxl/hdm: Account for locked decoders regardless of commit state Davidlohr Bueso
2026-10-29 23:08 ` Dave Jiang
2026-10-29 23:25   ` Davidlohr Bueso
2026-11-20  0:16 ` Alison Schofield

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