Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hangxiang Ma" <hangxiang.ma@oss.qualcomm.com>
Cc: vkoul@kernel.org, conor+dt@kernel.org, neil.armstrong@linaro.org,
	robh@kernel.org, media-ci@linuxtv.org,
	linux-phy@lists.infradead.org, olteanv@gmail.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v20 07/13] media: qcom: camss: csid: Add support for CSID 1080
Date: Sat, 10 Oct 2026 16:22:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-166733@kernel.org> (raw)
In-Reply-To: <20261010-kaanapali-camss-v20-7-63e98ce9ac0c@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] media: camss: data race on csid aup_update and rup_update
- [Medium] media: camss: missing initialization of CSID_CSI2_RDIN_IRQ_MASK
--

commit 929222812c3090d4d0069fbedd13096bba380a7a
Author: Hangxiang Ma <hangxiang.ma@oss.qualcomm.com>

media: qcom: camss: csid: Add support for CSID 1080

Add support for the CSID 1080 hardware found on Kaanapali SoC.
This introduces CSID 1080 hardware resource descriptions and implements
hardware-specific register programming, reset sequence, and BUF_DONE
interrupt handling.

> diff --git a/drivers/media/platform/qcom/camss/camss-csid-1080.c b/drivers/media/platform/qcom/camss/camss-csid-1080.c
> index 0000000000000..46e443e05195a
> --- /dev/null
> +++ b/drivers/media/platform/qcom/camss/camss-csid-1080.c

[ ... ]

> +static void __csid_aup_rup_clear(struct csid_device *csid, int port_id)
> +{
> +	/* Hardware clears the registers upon consuming the settings */
> +	csid->aup_update &= ~CSID_RUP_AUP_RDI(port_id);
> +	csid->rup_update &= ~CSID_RUP_AUP_RDI(port_id);
> +}
> +
> +static void __csid_aup_update(struct csid_device *csid, int port_id)
> +{
> +	csid->aup_update |= CSID_RUP_AUP_RDI(port_id);
> +	writel(csid->aup_update, csid->base + CSID_AUP_CMD);
> +
> +	__csid_aup_rup_trigger(csid);
> +}
> +
> +static void __csid_reg_update(struct csid_device *csid, int port_id)
> +{
> +	csid->rup_update |= CSID_RUP_AUP_RDI(port_id);

[Severity: High]
Could these bitwise operations lead to a data race between process and
hardirq contexts?

The __csid_aup_update() and __csid_reg_update() functions are called from
process context via csid_configure_stream(). They perform non-atomic bitwise
OR operations on csid->aup_update and csid->rup_update.

Meanwhile, __csid_aup_rup_clear() performs non-atomic bitwise AND operations
on these same fields from hardirq context (called from csid_isr() when an
INFO_RUP_DONE event occurs).

If a hardirq preempts the process context during its load-modify-store cycle,
the ISR's clearing of the bits could be silently overwritten when the process
context writes back its loaded value. This could cause the tracking bits to
get stuck, potentially leading to unintended hardware updates.

Should these state updates be protected by a spinlock or use atomic bitops?

[ ... ]

> +/* RDI IRQ Status in wrapper */
> +#define CSID_CSI2_RDIN_IRQ_STATUS(rdi)	(0x224 + (0x10 * (rdi)))
> +#define CSID_CSI2_RDIN_IRQ_MASK(rdi)	(0x228 + (0x10 * (rdi)))
> +#define CSID_CSI2_RDIN_IRQ_CLEAR(rdi)	(0x22C + (0x10 * (rdi)))
> +#define		INFO_RUP_DONE				BIT(23)

[ ... ]

> +static int csid_reset(struct csid_device *csid)
> +{
> +	unsigned long time;
> +	u32 val;
> +	int i;
> +
> +	reinit_completion(&csid->reset_complete);
> +
> +	val = INFO_RST_DONE | BUF_DONE_IRQ_STATUS;
> +	writel(val, csid->base + CSID_TOP_IRQ_CLEAR);
> +	writel(val, csid->base + CSID_TOP_IRQ_MASK);
> +
> +	val = 0;
> +	for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS_1080; i++) {
> +		if (csid->phy.en_vc & BIT(i)) {
> +			/*
> +			 * Only need to clear buf done IRQ status here,
> +			 * RUP done IRQ status will be cleared once isr
> +			 * strobe generated by CSID_RST_CMD
> +			 */
> +			val |= BIT(BUF_DONE_IRQ_STATUS_RDI_OFFSET + i);
> +		}
> +	}
> +	writel(val, csid->base + CSID_BUF_DONE_IRQ_CLEAR);
> +	writel(val, csid->base + CSID_BUF_DONE_IRQ_MASK);

[Severity: Medium]
Is the CSID_CSI2_RDIN_IRQ_MASK(i) register supposed to be initialized here to
enable the INFO_RUP_DONE interrupt?

The mask register is defined but never written to anywhere in this driver.
In csid_isr(), the driver polls CSID_CSI2_RDIN_IRQ_STATUS(i) to check for
INFO_RUP_DONE in order to clear the driver's software state tracking via
csid_subdev_reg_update().

If the hardware mask defaults to 0, the INFO_RUP_DONE status bit might never
be recorded. This would cause csid_subdev_reg_update() to be skipped,
allowing pending RUP updates to accumulate and causing redundant updates to
running streams.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010-kaanapali-camss-v20-0-63e98ce9ac0c@oss.qualcomm.com?part=7

  reply	other threads:[~2026-10-10 16:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 16:01 [PATCH v20 00/13] media: qcom: camss: Add Kaanapali support Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 01/13] dt-bindings: phy: qcom,x1e80100-csi2-phy: Add Kaanapali CSI2 PHY Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 02/13] phy: qcom-mipi-csi2: Parametrise the common status register offset Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 03/13] phy: qcom-mipi-csi2: Add Kaanapali support Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 04/13] media: dt-bindings: Add CAMSS device for Kaanapali Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 05/13] media: qcom: camss: Add Kaanapali compatible Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 06/13] media: qcom: camss: csiphy: Add support for v2.4.0 two-phase CSIPHY Hangxiang Ma
2026-10-10 16:23   ` sashiko-bot
2026-10-10 16:01 ` [PATCH v20 07/13] media: qcom: camss: csid: Add support for CSID 1080 Hangxiang Ma
2026-10-10 16:22   ` sashiko-bot [this message]
2026-10-10 16:01 ` [PATCH v20 08/13] media: qcom: camss: vfe: Add support for VFE 1080 Hangxiang Ma
2026-10-10 16:25   ` sashiko-bot
2026-10-11  8:56   ` Bryan O'Donoghue
2026-10-12  1:25     ` hangxiang.ma
2026-10-10 16:01 ` [PATCH v20 09/13] media: qcom: camss: tpg: Add support for v2.4.0 TPG Hangxiang Ma
2026-10-10 16:19   ` sashiko-bot
2026-10-10 16:01 ` [PATCH v20 10/13] arm64: dts: qcom: kaanapali: Add CAMSS and CSIPHY block definitions Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 11/13] arm64: dts: qcom: kaanapali: Add CCI controller nodes Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 12/13] arm64: dts: qcom: kaanapali: Add camera MCLK pinctrl Hangxiang Ma
2026-10-10 16:01 ` [PATCH v20 13/13] arm64: dts: qcom: kaanapali-mtp-camera-s5kjn5: Add DT overlay Hangxiang Ma
2026-10-10 16:21   ` 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-166733@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hangxiang.ma@oss.qualcomm.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=media-ci@linuxtv.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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