From: sashiko-bot@kernel.org
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v5 2/4] media: rockchip: Add JPEG decoder driver
Date: Fri, 25 Sep 2026 11:58:50 +0000 [thread overview]
Message-ID: <20260925115850.B052C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925-rockchip-jpegdec-v5-2-30658833cb68@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] pm: missing synchronous suspend in rkjpegd_remove leaks clocks
- [High] media: rkjpegd: resetting hardware before disabling IRQ causes kernel panic
- [Medium] media: rkjpegd: valid JPEGs with >= 127 bytes of trailing garbage are incorrectly rejected
- [Medium] pm: missing pm_runtime_mark_last_busy() causes autosuspend thrashing
--
commit d2574a6f04bf2bf05abc30d32244135c74b9546e
Author: Sascha Hauer <s.hauer@pengutronix.de>
Subject: media: rockchip: Add JPEG decoder driver
This commit adds a driver for the Rockchip VDPU720 JPEG hardware decoder.
It exposes a V4L2 M2M device to decode JPEG bitstreams into NV12 format.
> diff --git a/drivers/media/platform/rockchip/rkjpegd/rkjpegd.c b/drivers/media/platform/rockchip/rkjpegd/rkjpegd.c
> new file mode 100644
> index 0000000000000..e3a6c820ad1ed
> --- /dev/null
> +++ b/drivers/media/platform/rockchip/rkjpegd/rkjpegd.c
[ ... ]
> +static void rkjpegd_job_finish(struct rkjpegd_ctx *ctx,
> + enum vb2_buffer_state state)
> +{
> + struct rkjpegd_dev *jpegd = ctx->dev;
> +
> + pm_runtime_put_autosuspend(jpegd->dev);
[Severity: Medium]
Will this suspend the device immediately instead of using the configured
100ms autosuspend delay?
The device's last busy timestamp is not updated with
pm_runtime_mark_last_busy() before queuing the autosuspend here. Without
it, the PM core calculates the expiration time based on an uninitialized
or stale timestamp, which can cause the device to suspend immediately and
thrash between back-to-back frames.
> +
> + rkjpegd_job_finish_no_pm(ctx, state);
> +}
[ ... ]
> +static irqreturn_t rkjpegd_vdpu720_irq(int irq, void *dev_id)
> +{
[ ... ]
> + rkjpegd_irq_done(jpegd, state);
> + ret = IRQ_HANDLED;
> +
> +out_put:
> + pm_runtime_put_autosuspend(jpegd->dev);
[Severity: Medium]
Similar to the issue in rkjpegd_job_finish() above, is it intentional to omit
pm_runtime_mark_last_busy() here?
This also queues an autosuspend without updating the last busy timestamp,
which can defeat the autosuspend delay and cause unnecessary power cycling.
> +
> + return ret;
> +}
[ ... ]
> +static bool rkjpegd_has_eoi(const void *data, u32 start, u32 len)
> +{
> + u8 tail[128];
> + u32 n, i;
> +
> + while (len > start) {
> + n = min_t(u32, len - start, sizeof(tail));
> + memcpy(tail, data + len - n, n);
> +
> + for (i = n; i && (tail[i - 1] == 0x00 || tail[i - 1] == 0xff); i--)
> + ;
> +
> + len -= n - i;
> + if (i)
> + break;
> + }
> +
> + n = min_t(u32, len - start, sizeof(tail));
> + memcpy(tail, data + len - n, n);
> +
> + for (i = 0; i + 1 < n; i++)
> + if (tail[i] == 0xff && tail[i + 1] == 0xd9)
> + return true;
[Severity: Medium]
Can this inadvertently reject valid JPEG frames?
The search for the 0xff 0xd9 EOI marker only inspects the final 128 bytes
after stripping the 0x00 and 0xff padding. If a valid JPEG has 127 or more
bytes of trailing garbage (such as EXIF metadata or digital signatures),
the EOI marker will fall completely outside this search window and the
function will return false.
> +
> + return false;
> +}
[ ... ]
> +static void rkjpegd_remove(struct platform_device *pdev)
> +{
> + struct rkjpegd_dev *jpegd = platform_get_drvdata(pdev);
> +
> + rkjpegd_v4l2_cleanup(jpegd);
> +
> + reset_control_assert(jpegd->resets);
[Severity: High]
Does asserting the hardware reset before disabling the IRQ and PM runtime
introduce a race condition?
If a spurious interrupt fires while the IP block is held in reset, the
rkjpegd_vdpu720_irq() handler will run. Because PM runtime is still active,
pm_runtime_get_if_active() will succeed, and the handler will try to read
from the hardware (VDPU720_REG_INT), which can cause a bus stall or kernel
panic.
> + pm_runtime_dont_use_autosuspend(&pdev->dev);
> + pm_runtime_disable(&pdev->dev);
[Severity: High]
Could this leak the hardware clocks?
Disabling PM runtime here cancels the pending autosuspend timer, but it
leaves the device in the active power state with a usage count of 0.
Without an explicit synchronous suspend (like pm_runtime_suspend() or
pm_runtime_put_sync_suspend()) before pm_runtime_disable(), the
rkjpegd_runtime_suspend() callback is never executed, and
clk_bulk_disable_unprepare() is bypassed.
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260925-rockchip-jpegdec-v5-0-30658833cb68@pengutronix.de?part=2
next prev parent reply other threads:[~2026-09-25 11:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 11:45 [PATCH v5 0/4] media: rockchip: Add JPEG decoder driver Sascha Hauer
2026-09-25 11:45 ` [PATCH v5 1/4] media: dt-bindings: Add Rockchip JPEG decoder Sascha Hauer
2026-09-25 13:23 ` Nicolas Dufresne
2026-09-25 11:45 ` [PATCH v5 2/4] media: rockchip: Add JPEG decoder driver Sascha Hauer
2026-09-25 11:58 ` sashiko-bot [this message]
2026-09-25 14:31 ` Nicolas Dufresne
2026-09-28 14:23 ` Sascha Hauer
2026-09-29 19:34 ` Nicolas Dufresne
2026-10-05 9:40 ` Sascha Hauer
2026-09-25 11:45 ` [PATCH v5 3/4] arm64: dts: rockchip: rk3588: Add JPEG decoder node Sascha Hauer
2026-09-25 11:45 ` [PATCH v5 4/4] arm64: dts: rockchip: rk356x: " Sascha Hauer
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=20260925115850.B052C1F000FF@smtp.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=s.hauer@pengutronix.de \
--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