Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Drew Fustini" <fustini@kernel.org>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v13 1/5] riscv_cbqri: Add capacity controller core
Date: Thu, 03 Dec 2026 10:14:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-247531@kernel.org> (raw)
In-Reply-To: <20261203-dfustini-atl-sc-cbqri-dt-v13-1-eaa688b1624c@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] riscv_cbqri: incomplete AT-mirror verification in
  cbqri_apply_cache_config()
--

commit a00d96c0d30cb11391c930e3a47a96f149912607
Author: Drew Fustini <fustini@kernel.org>

riscv_cbqri: Add capacity controller core

This commit adds the core driver for RISC-V CBQRI capacity controllers,
including capability probing and MMIO operations to program and read back
per-RCID capacity block masks.

> diff --git a/drivers/resctrl/cbqri_devices.c b/drivers/resctrl/cbqri_devices.c
> new file mode 100644
> index 0000000000000..d6c2e08a5546d
> --- /dev/null
> +++ b/drivers/resctrl/cbqri_devices.c

[ ... ]

> +int cbqri_apply_cache_config(struct cbqri_controller *ctrl, u32 closid,
> +			     const struct cbqri_cc_config *cfg)
> +{

[ ... ]

> +	/* Capacity config limit operation for the AT half implied by cfg->at */
> +	err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT,
> +				closid, cfg->at, cfg->cbm);
> +	if (err < 0)
> +		return err;
> +
> +	/*
> +	 * CDP-off mirror: on AT-capable controllers, also program the
> +	 * other AT half with the same mask so the two halves stay in sync.
> +	 */
> +	if (need_at_mirror) {
> +		u32 other = (cfg->at == CBQRI_CONTROL_REGISTERS_AT_CODE) ?
> +			    CBQRI_CONTROL_REGISTERS_AT_DATA :
> +			    CBQRI_CONTROL_REGISTERS_AT_CODE;
> +
> +		err = cbqri_cc_alloc_op(ctrl,
> +					CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT,
> +					closid, other, cfg->cbm);
> +		if (err < 0) {
> +			int rerr;
> +
> +			/*
> +			 * Best-effort revert of the cfg->at half so the two
> +			 * halves stay in sync. A schemata read sees only one
> +			 * half, so silent divergence would otherwise report
> +			 * the new value as if the write had succeeded.
> +			 */
> +			rerr = cbqri_cc_alloc_op(ctrl,
> +						 CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT,
> +						 closid, cfg->at, saved_cbm);
> +			if (rerr < 0)
> +				pr_err_ratelimited("AT-mirror revert failed (err=%d), AT halves diverged\n",
> +						   rerr);
> +			return err;
> +		}
> +	}
> +
> +	/* Read the limit back to verify the block mask landed */
> +	err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT,
> +				closid, cfg->at, 0);
> +	if (err < 0)
> +		return err;
> +
> +	/*
> +	 * Read the capacity block mask and narrow to u32 to match resctrl's CBM
> +	 * width. cbqri_probe_cc() rejects ncblks > 32 so the upper bits are
> +	 * reserved zero.
> +	 */
> +	reg = cbqri_readq(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> +	if (lower_32_bits(reg) != cfg->cbm) {
> +		pr_err_ratelimited("CBM verify mismatch (reg=%llx != cbm=%llx)\n",
> +				   reg, cfg->cbm);
> +		err = -EIO;
> +	}

[Severity: Low]
Can the two AT halves still diverge when need_at_mirror is true?

The post-write CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT check only reads back
cfg->at, so a silent failure to apply cfg->cbm on the mirrored other
half goes undetected and cbqri_apply_cache_config() returns 0.

In addition, because cfg->at is verified after other has already been
written, a readback error or mismatch on cfg->at returns -EIO without
reverting other to saved_cbm.

Verifying cfg->at before programming other, and then verifying other
while reverting cfg->at to saved_cbm on either error or mismatch, would
keep both halves checked and consistent.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-dfustini-atl-sc-cbqri-dt-v13-0-eaa688b1624c@kernel.org?part=1

  reply	other threads:[~2026-12-03 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:57 [PATCH v13 0/5] riscv: Add initial CBQRI resctrl support Drew Fustini
2026-12-03  9:57 ` [PATCH v13 1/5] riscv_cbqri: Add capacity controller core Drew Fustini
2026-12-03 10:14   ` sashiko-bot [this message]
2026-12-03  9:57 ` [PATCH v13 2/5] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-12-03  9:57 ` [PATCH v13 3/5] riscv_cbqri: Make RESCTRL_FS available on RISC-V Drew Fustini
2026-12-03  9:57 ` [PATCH v13 4/5] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-12-03 10:14   ` sashiko-bot
2026-12-03  9:57 ` [PATCH v13 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-12-03 10:18   ` sashiko-bot

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=sashiko-outbox-247531@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fustini@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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