Re: [PATCH v10 02/12] cxl: Pass decoder settings to HDM commit helpers

[email protected] Tue, 04 Aug 2026 19:49:49 +0000
Newsgroups org.kernel.vger.linux-cxl,org.kernel.vger.linux-pci
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [High] New pre-checks in `setup_hw_decoder()` permanently wedge the decod=
er after an error and cause spurious failures during quick reset-recommit c=
ycles.
--

--- Patch [2]: [PATCH v10 02/12] cxl: Pass decoder settings to HDM commit h=
elpers ---
commit e130015805d1a3746154432a62193b6dcb3f71f9
Author: Srirangan Madhavan <[email protected]>

cxl: Pass decoder settings to HDM commit helpers

Introduce struct cxl_decoder_settings as a plain snapshot of HDM decoder
programming state and pass it to the shared commit helpers. Split the helper
entry points into cxl_commit_start() and cxl_commit_wait() so hdm.c keeps
the existing DPA-lock and commit policy flow while later reset restore code
can reuse the register programming sequence.

> diff --git a/drivers/cxl/core/resource.c b/drivers/cxl/core/resource.c
> index dd8bed3d3ff0c..dd5e0cc82da49 100644
> --- a/drivers/cxl/core/resource.c
> +++ b/drivers/cxl/core/resource.c

[ ... ]

> +static int setup_hw_decoder(struct cxl_decoder_settings *settings,
> +			    void __iomem *hdm)
>  {
> -	int id =3D cxld->id;
> +	int id =3D settings->id;
> +	u64 target_or_skip;
>  	u64 base, size;
>  	u32 ctrl;
> =20
> -	/* common decoder settings */
> -	ctrl =3D readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(cxld->id));
> -	cxld_set_interleave(cxld, &ctrl);
> -	cxld_set_type(cxld, &ctrl);
> -	base =3D cxld->hpa_range.start;
> -	size =3D range_len(&cxld->hpa_range);
> +	ctrl =3D readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(id));
> +	if (ctrl & CXL_HDM_DECODER0_CTRL_COMMITTED)
> +		return -EBUSY;
> +	if (ctrl & CXL_HDM_DECODER0_CTRL_COMMIT)
> +		return -ETIMEDOUT;
> +	if (ctrl & CXL_HDM_DECODER0_CTRL_COMMIT_ERROR)
> +		return -EIO;

[Severity: High]
Will these new pre-checks permanently wedge the decoder if a previous commit
attempt timed out or encountered an error?

If a commit times out, cxld_await_commit() returns -ETIMEDOUT leaving the
CXL_HDM_DECODER0_CTRL_COMMIT bit set. Because CXL_DECODER_F_ENABLE is not s=
et
on failure, cxl_decoder_reset() refuses to run, so the COMMIT bit is never
cleared.

When a subsequent commit attempt occurs, won't it immediately return
-ETIMEDOUT from these checks without attempting to clear the error?

Similarly, for quick reset-recommit cycles, cxl_decoder_reset() clears
the COMMIT bit but does not wait for the hardware to clear COMMITTED.
Could this leave the hardware in a transient state that triggers the newly
added -EBUSY check?

> +	cxld_set_interleave(settings, &ctrl);
> +	cxld_set_type(settings, &ctrl);
> +	base =3D settings->hpa_range.start;
> +	size =3D range_len(&settings->hpa_range);

[ ... ]

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260804192958.1823=
[email protected]?part=3D2