All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qianhui Xu" <xiaqinghuan@mail.ustc.edu.cn>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH 8/9] media: camss: vfe: add the gen4 block and SM8750 camera subsystem
Date: Wed, 28 Oct 2026 04:00:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-187458@kernel.org> (raw)
In-Reply-To: <20261028034105.326535-9-xiaqinghuan@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] media: camss: race on CSID reg_update state between vfe_reg_update() and csid_isr()
--

commit 9a87e4e329c131d366318a8a449031db90e2ea2c
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>

media: camss: vfe: add the gen4 block and SM8750 camera subsystem

This commit adds support for the gen4 VFE block, where buffer done, register
update completion, and start of frame events come from the 980 CSID, and
requires 256-byte alignment for DMA addresses and frame sizes. It also
instantiates the CSIPHY, CSID, VFE, interconnect, and top-level resources for
SM8750.

> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-gen4.c b/drivers/media/platform/qcom/camss/camss-vfe-gen4.c
> new file mode 100644
> index 0000000000000..2ee82898f37dc
> --- /dev/null
> +++ b/drivers/media/platform/qcom/camss/camss-vfe-gen4.c
> @@ -0,0 +1,212 @@

[ ... ]

> +static void vfe_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
> +{
> +	int port_id = line_id;
> +
> +	camss_reg_update(vfe->camss, vfe->id, port_id, false);
> +}
> +
> +static inline void vfe_reg_update_clear(struct vfe_device *vfe,
> +					enum vfe_line_id line_id)
> +{
> +	int port_id = line_id;
> +
> +	camss_reg_update(vfe->camss, vfe->id, port_id, true);
> +}

[Severity: Medium]
Can vfe_reg_update() race with csid_isr() on csid->aup_update,
csid->rup_update, and csid->reg_update?

When an active stream has fewer than two buffers in hardware
(output->gen2.active_num < 2) and userspace queues a buffer via VIDIOC_QBUF,
vfe_queue_buffer_v2() acquires vfe->output_lock and calls into CSID 980:

vfe_queue_buffer_v2()
  vfe_reg_update()
    camss_reg_update(..., false)
      csid_subdev_reg_update(..., false)
        __csid_aup_update()

In drivers/media/platform/qcom/camss/camss-csid-980.c, __csid_aup_update()
modifies csid->reg_update or csid->aup_update and then re-reads the field to
write the command register:

	if (csid_is_lite(csid)) {
		csid->reg_update |= CSID_LITE_AUP_RDI(port_id);
		writel(csid->reg_update, csid->base + CSID_LITE_RUP_AUP_CMD);
	} else {
		csid->aup_update |= CSID_RUP_AUP_RDI(port_id);
		writel(csid->aup_update, csid->base + CSID_AUP_CMD);
		__csid_full_aup_rup_trigger(csid);
	}

Concurrently on another CPU, csid_isr() in camss-csid-980.c handles
INFO_RUP_DONE without holding vfe->output_lock or any CSID lock:

csid_isr()
  if (val & INFO_RUP_DONE)
    csid_subdev_reg_update(csid, i, true)
      __csid_aup_rup_clear()

where __csid_aup_rup_clear() performs a non-atomic read-modify-write:

	if (csid_is_lite(csid)) {
		csid->reg_update &= ~CSID_LITE_RUP_RDI(port_id);
		csid->reg_update &= ~CSID_LITE_AUP_RDI(port_id);
	} else {
		csid->aup_update &= ~CSID_RUP_AUP_RDI(port_id);
		csid->rup_update &= ~CSID_RUP_AUP_RDI(port_id);
	}

If __csid_aup_rup_clear() clears the bit between the |= and the writel() in
__csid_aup_update() (or races across RDI ports on the same CSID when
vfe_enable_output_v2() or vfe_queue_buffer_v2() updates one RDI line while
csid_isr() clears another), won't the writel() drop the pending AUP command
or write a stale RDI port update bit, stalling frame capture on that stream?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261028034105.326535-1-xiaqinghuan@mail.ustc.edu.cn?part=8

  reply	other threads:[~2026-10-28  4:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  3:40 [PATCH 0/9] media: camss: add SM8750 support Qianhui Xu
2026-10-28  3:40 ` [PATCH 1/9] dt-bindings: media: add the Qualcomm SM8750 camera subsystem Qianhui Xu
2026-10-28  3:52   ` sashiko-bot
2026-10-28  3:40 ` [PATCH 2/9] media: camss: csiphy: add CSIPHY 2.4.0 lane settings for SM8750 Qianhui Xu
2026-10-29  7:53   ` Shuai Liu
2026-10-28  3:40 ` [PATCH 3/9] media: camss: csid: unwind the power-on path through a single error label Qianhui Xu
2026-10-28  3:41 ` [PATCH 4/9] media: camss: csid: add the 980 generation Qianhui Xu
2026-10-28  4:03   ` sashiko-bot
2026-10-29  7:54   ` Shuai Liu
2026-10-28  3:41 ` [PATCH 5/9] media: camss: csid: report frame starts from CSID Qianhui Xu
2026-10-28  4:01   ` sashiko-bot
2026-10-28  3:41 ` [PATCH 6/9] media: camss: video: check that a buffer is DMA contiguous and add a prepare hook Qianhui Xu
2026-10-28  3:41 ` [PATCH 7/9] media: camss: video: stop the subdevices already started when a start fails Qianhui Xu
2026-10-28  3:41 ` [PATCH 8/9] media: camss: vfe: add the gen4 block and SM8750 camera subsystem Qianhui Xu
2026-10-28  4:00   ` sashiko-bot [this message]
2026-10-29  7:54   ` Shuai Liu
2026-10-28  3:41 ` [PATCH 9/9] arm64: dts: qcom: sm8750: add the " Qianhui Xu
2026-10-28  4:06   ` sashiko-bot
2026-10-29  7:54   ` Shuai Liu
2026-10-29  9:37 ` [PATCH 0/9] media: camss: add SM8750 support Bryan O'Donoghue

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-187458@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaqinghuan@mail.ustc.edu.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.