Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Drew Fustini" <fustini@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v7 1/5] riscv_cbqri: Add capacity controller probe and allocation device ops
Date: Tue, 01 Sep 2026 22:42:34 +0000	[thread overview]
Message-ID: <20260901224234.DAFDD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-dfustini-atl-sc-cbqri-dt-v7-1-ca2935d85622@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Hardware race condition: writing staging registers before verifying BUSY == 0
--

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

riscv_cbqri: Add capacity controller probe and allocation device ops

This commit adds support for the RISC-V CBQRI capacity controller. It provides
a platform driver that probes the controller and registers allocation device ops
with the resctrl filesystem.

> diff --git a/drivers/resctrl/cbqri_devices.c b/drivers/resctrl/cbqri_devices.c
> new file mode 100644
> index 0000000000000..e93261dfa4fa9
> --- /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)
> +{
> +	bool need_at_mirror;
> +	u64 saved_cbm = 0;
> +	int err = 0;
> +	u64 reg;
> +
> +	mutex_lock(&ctrl->lock);
> +
> +	need_at_mirror = ctrl->cc.supports_alloc_at_code && !cfg->cdp_enabled;
> +
> +	/*
> +	 * Capture the cfg->at half CBM before any write so a partial
> +	 * AT-mirror failure can revert and keep the two halves consistent.
> +	 * Pre-clear cc_block_mask so a silent firmware no-op (status
> +	 * SUCCESS but staging not updated) shows as a zero readback
> +	 * rather than carrying stale data from a prior op.
> +	 */
> +	if (need_at_mirror) {
> +		cbqri_set_cbm(ctrl, 0);
> +		err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT,
> +					closid, cfg->at);

[Severity: Medium]
Does this overwrite the cc_block_mask staging register before verifying the
hardware is idle?

If a previous operation timed out but the controller is still actively
processing it, modifying the CBM register here before cbqri_cc_alloc_op()
checks the BUSY flag could corrupt the in-flight operation.

> +		if (err < 0)
> +			goto out;
> +		saved_cbm = cbqri_readq(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> +	}
> +
> +	/* Set capacity block mask (cc_block_mask) */
> +	cbqri_set_cbm(ctrl, cfg->cbm);
> +	cbqri_clear_cunits(ctrl);
> +
> +	/* 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);

[Severity: Medium]
Similarly, does this overwrite both the CBM and CUNITS staging registers
before verifying the hardware has finished any previous operations?

cbqri_cc_alloc_op() waits for BUSY == 0, but this happens after these
staging registers have already been written. If a previous caller's
operation timed out and the hardware is still busy, could this cause
the new operation to use corrupted staging data or disrupt the pending
operation?

> +	if (err < 0)
> +		goto out;
[ ... ]

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

  reply	other threads:[~2026-09-01 22:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 22:31 [PATCH v7 0/5] riscv: Add Ssqosid and initial CBQRI resctrl support Drew Fustini
2026-09-01 22:31 ` [PATCH v7 1/5] riscv_cbqri: Add capacity controller probe and allocation device ops Drew Fustini
2026-09-01 22:42   ` sashiko-bot [this message]
2026-09-01 22:31 ` [PATCH v7 2/5] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-09-01 22:31 ` [PATCH v7 3/5] riscv: Enable resctrl filesystem for Ssqosid Drew Fustini
2026-09-01 22:31 ` [PATCH v7 4/5] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-09-01 22:31 ` [PATCH v7 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-09-03  3:24 ` [PATCH v7 0/5] riscv: Add Ssqosid and initial CBQRI resctrl support Chen Pei

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=20260901224234.DAFDD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fustini@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --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