From: sashiko-bot@kernel.org
To: "Anthony McGivern" <anthony.mcgivern@arm.com>,
devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH 12/24] media: mali-c720: Add video capture nodes
Date: Tue, 24 Nov 2026 17:35:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-231709@kernel.org> (raw)
In-Reply-To: <20261124-b4-initial-upstream-candidate-v1-12-0cb9bde1bd30@arm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] media: mali-c720: unrecovered output buffer state on context
stop
- [Medium] media: mali-c720: race between
mali_c720_s_fmt_vid_cap_mplane() and link validation
- [Low] media: mali-c720: uninitialized vdev.name logged in
mali_c720_register_cap_dev()
--
commit 5de5962e721900ab8951fa2e8cce61caedd37777
Author: Anthony McGivern <Anthony.McGivern@arm.com>
media: mali-c720: Add video capture nodes
This commit adds RGB and YUV V4L2 video capture nodes for the full-resolution
output 0 (FR0) subdevice and wires up their buffer completion handling.
> diff --git a/drivers/media/platform/arm/mali-c720/mali-c720-capture.c b/drivers/media/platform/arm/mali-c720/mali-c720-capture.c
> new file mode 100644
> index 0000000000000..78e9f5aba97d5
> --- /dev/null
> +++ b/drivers/media/platform/arm/mali-c720/mali-c720-capture.c
> @@ -0,0 +1,747 @@
[ ... ]
> +void mali_c720_cap_dev_buffer_done(struct mali_c720_cap_dev *cap_dev,
> + bool success)
> +{
> + struct mali_c720 *mali_c720 = cap_dev->mali_c720;
> + struct mali_c720_context *ctx = mali_c720_get_active_context(mali_c720);
> + struct mali_c720_cap_buffer *buf;
> +
> + if (!video_is_registered(&cap_dev->vdev))
> + return;
> +
> + if (!vb2_is_streaming(&cap_dev->queue))
> + return;
> +
> + guard(spinlock)(&cap_dev->buffers.lock);
> +
> + buf = list_first_entry_or_null(&cap_dev->buffers.processing,
> + struct mali_c720_cap_buffer, queue);
> + if (!buf)
> + return;
> +
> + if (mali_c720_ctx_mgr_check_output_buffer_status(ctx, &cap_dev->buffers.pool))
> + success = false;
> +
> + if (success) {
> + buf->vb.vb2_buf.timestamp = ctx->timestamp;
> + buf->vb.sequence = ctx->frame_sequence;
> + }
> +
> + vb2_buffer_done(&buf->vb.vb2_buf, success ? VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR);
> + list_del(&buf->queue);
> +}
[Severity: Medium]
When one capture device stops streaming while another capture device is still
streaming with an in-flight buffer in buffers.processing, does retiring that
buffer leave the still-streaming device's hardware output buffer descriptor
in MALI_C720_BUFFER_STATE_HW_EMPTY (or MALI_C720_BUFFER_STATE_HW_ERROR)
instead of resetting it to MALI_C720_BUFFER_STATE_SW_EMPTY?
mali_c720_vb2_stop_streaming() disables isp_sd, which invokes
mali_c720_ctx_mgr_stop_context():
drivers/media/platform/arm/mali-c720/mali-c720-ctx-mgr.c:mali_c720_ctx_mgr_stop_context() {
...
scoped_guard(spinlock_irq, &ctx->state_lock) {
ctx->state = MALI_C720_SLOT_STATE_STOPPED;
...
/* Retire in-flight buffers on all queues, including those still streaming. */
mali_c720_ctx_mgr_buffer_done(ctx, false);
Because ctx->state is already MALI_C720_SLOT_STATE_STOPPED when
mali_c720_cap_dev_buffer_done() runs,
mali_c720_ctx_mgr_check_output_buffer_status() returns 0 immediately:
drivers/media/platform/arm/mali-c720/mali-c720-ctx-mgr.c:mali_c720_ctx_mgr_check_output_buffer_status() {
...
if (ctx->state == MALI_C720_SLOT_STATE_STOPPED)
return 0;
The stopping capture device then releases its buffer pool, which cancels and
uninitializes its descriptor, but the sibling capture device that remains
streaming keeps its pool with the hardware descriptor still under hardware
control and pointing at the retired vb2 buffer's DMA address.
[ ... ]
> +static int mali_c720_s_fmt_vid_cap_mplane(struct file *file, void *fh,
> + struct v4l2_format *f)
> +{
> + struct mali_c720_cap_dev *cap_dev = video_drvdata(file);
> +
> + if (media_entity_is_streaming(&cap_dev->vdev.entity))
> + return -EBUSY;
> +
> + if (vb2_is_busy(&cap_dev->queue))
> + return -EBUSY;
> +
> + mali_c720_set_format(cap_dev, &f->fmt.pix_mp);
> + return 0;
> +}
[Severity: Medium]
Can mali_c720_s_fmt_vid_cap_mplane() race with mali_c720_link_validate() on a
sibling capture device sharing the media pipeline?
Each capture device has its own cap_dev->lock, while both FR0 capture nodes
share mali_c720->pipe when both links from fr_pipe are enabled:
CPU0 (cap_devs[0] STREAMON) CPU1 (cap_devs[1] S_FMT)
mali_c720_vb2_start_streaming()
lock(&mali_c720->device_lock)
video_device_pipeline_start()
...
mali_c720_link_validate()
/* on cap_devs[1] */
mali_c720_s_fmt_vid_cap_mplane()
/* lock(&cap_devs[1].lock) held */
media_entity_is_streaming() -> false
reads cap_devs[1].format
mali_c720_set_format()
writes cap_devs[1].format <-- data race
sets cap_devs[1].pad.pipe
Because pad->pipe is only assigned after link_validate() succeeds and
mali_c720_s_fmt_vid_cap_mplane() does not take mali_c720->device_lock, CPU1
passes media_entity_is_streaming() and can overwrite cap_dev->format with an
unvalidated resolution or pixel format while or right after
mali_c720_link_validate() checks it.
[ ... ]
> +static int mali_c720_register_cap_dev(struct mali_c720 *mali_c720,
> + enum mali_c720_cap_devs cap_dev_id)
> +{
[ ... ]
> + ret = vb2_queue_init(vb2q);
> + if (ret) {
> + dev_err(mali_c720->dev, "%s vb2 queue init failed\n",
> + cap_dev->vdev.name);
> + goto err_cleanup_media_entity;
> + }
> +
> + strscpy(cap_dev->vdev.name, capture_device_names[cap_dev_id],
> + sizeof(cap_dev->vdev.name));
[Severity: Low]
If vb2_queue_init() fails, dev_err() logs cap_dev->vdev.name before strscpy()
initializes it, printing an empty name.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-b4-initial-upstream-candidate-v1-0-0cb9bde1bd30@arm.com?part=12
next prev parent reply other threads:[~2026-11-24 17:35 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:07 [PATCH 00/24] Add Arm Mali-C720 Image Signal Processor Driver Anthony McGivern
2026-11-24 17:07 ` [PATCH 01/24] media: uapi: Add 24-bit Bayer media bus formats Anthony McGivern
2026-11-24 17:07 ` [PATCH 02/24] dt-bindings: media: Add bindings for Arm Mali-C720 Anthony McGivern
2026-11-24 17:18 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 03/24] media: uapi: Add a control ID base for Mali-C720 ISP Anthony McGivern
2026-11-24 17:07 ` [PATCH 04/24] media: mali-c720: Add register access helpers Anthony McGivern
2026-11-24 17:07 ` [PATCH 05/24] media: mali-c720: Add hardware identification Anthony McGivern
2026-11-24 17:07 ` [PATCH 06/24] media: mali-c720: Add format handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 07/24] media: mali-c720: Add hardware discovery support Anthony McGivern
2026-11-24 17:07 ` [PATCH 08/24] media: mali-c720: Add context manager and interrupt handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 09/24] media: mali-c720: Add input frontend subdevice Anthony McGivern
2026-11-24 17:07 ` [PATCH 10/24] media: mali-c720: Add ISP and human vision subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 11/24] media: mali-c720: Add full-resolution output subdevice Anthony McGivern
2026-11-24 17:21 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 12/24] media: mali-c720: Add video capture nodes Anthony McGivern
2026-11-24 17:35 ` sashiko-bot [this message]
2026-11-24 17:07 ` [PATCH 13/24] media: mali-c720: Add Mali-C720 ISP driver Anthony McGivern
2026-11-24 17:07 ` [PATCH 14/24] media: mali-c720: Add test pattern generator subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 15/24] media: Documentation: Add Mali-C720 ISP documentation Anthony McGivern
2026-11-24 17:20 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 16/24] media: uapi: Add Mali-C720 statistics meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 17/24] media: uapi: Add statistics structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:26 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 18/24] media: mali-c720: Add 3A statistics video node Anthony McGivern
2026-11-24 17:31 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 19/24] media: Documentation: Document Mali-C720 statistics capture Anthony McGivern
2026-11-24 17:25 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 20/24] media: uapi: Add Mali-C720 parameters meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 21/24] media: uapi: Add parameter structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:33 ` sashiko-bot
2026-11-24 17:07 ` [PATCH 22/24] media: mali-c720: Add parameters video node Anthony McGivern
2026-11-24 17:07 ` [PATCH 23/24] media: Documentation: Document Mali-C720 parameter settings Anthony McGivern
2026-11-24 17:07 ` [PATCH 24/24] MAINTAINERS: Add entry for mali-c720 driver Anthony McGivern
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-231709@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anthony.mcgivern@arm.com \
--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 \
/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