Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: jic23@kernel.org, alison.schofield@intel.com,
	ming.li@zohomail.com, icheng@nvidia.com,
	linux-cxl@vger.kernel.org
Subject: Re: [PATCH] cxl/hdm: Account for locked decoders regardless of commit state
Date: Thu, 29 Oct 2026 16:08:35 -0700	[thread overview]
Message-ID: <197c7286-6961-4934-80f7-896cf8a37ef6@intel.com> (raw)
In-Reply-To: <20261029201327.1119231-1-dave@stgolabs.net>



On 10/29/26 1:13 PM, Davidlohr Bueso wrote:
> 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>

Can you commit the decoder in locked state? Or are you just stuck in this weird state?

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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


  reply	other threads:[~2026-10-29 23:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=197c7286-6961-4934-80f7-896cf8a37ef6@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dave@stgolabs.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox