All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: dave.jiang@intel.com
Cc: jic23@kernel.org, alison.schofield@intel.com,
	ming.li@zohomail.com, icheng@nvidia.com,
	linux-cxl@vger.kernel.org, dave@stgolabs.net
Subject: [PATCH] cxl/hdm: Account for locked decoders regardless of commit state
Date: Thu, 29 Oct 2026 13:13:27 -0700	[thread overview]
Message-ID: <20261029201327.1119231-1-dave@stgolabs.net> (raw)

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


             reply	other threads:[~2026-10-29 20:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 20:13 Davidlohr Bueso [this message]
2026-10-29 23:08 ` [PATCH] cxl/hdm: Account for locked decoders regardless of commit state Dave Jiang
2026-10-29 23:25   ` Davidlohr Bueso
2026-11-20  0:16 ` Alison Schofield

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=20261029201327.1119231-1-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=icheng@nvidia.com \
    --cc=jic23@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=ming.li@zohomail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.