Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [FROMLIST] media: mtk-jpeg: only init/cancel work for multi-core variants#1803

Merged
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:mtk-jpeg-6.6
Jun 3, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6.y] [FROMLIST] media: mtk-jpeg: only init/cancel work for multi-core variants#1803
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:mtk-jpeg-6.6

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented Jun 2, 2026

Single-core variants of this hardware do not use the work at all, and the worker function is set to NULL, which leads to warnings when cancelling the work in release callback.

Skip the work init/cancel code when the JPEG hardware isn't multi-core.

Cc: stable@vger.kernel.org
Fixes: 34c519feef3e ("media: mtk-jpeg: fix use-after-free in release path due to uncancelled work")
Fixes: d40e952 ("media: mtk-jpeg: reconstructs the initialization mode of worker")

[WangYuli: Fix conflicts]
Link: https://lore.kernel.org/all/20260601073218.1281840-1-zhengxingda@iscas.ac.cn/

Summary by Sourcery

Bug Fixes:

  • Avoid warnings in the Mediatek JPEG driver by skipping work initialization and cancellation on single-core JPEG variants that do not use a worker.

Single-core variants of this hardware do not use the work at all, and
the worker function is set to NULL, which leads to warnings when
cancelling the work in release callback.

Skip the work init/cancel code when the JPEG hardware isn't multi-core.

Cc: stable@vger.kernel.org
Fixes: 34c519feef3e ("media: mtk-jpeg: fix use-after-free in release path due to uncancelled work")
Fixes: d40e952 ("media: mtk-jpeg: reconstructs the initialization mode of worker")
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
[WangYuli: Fix conflicts]
Link: https://lore.kernel.org/all/20260601073218.1281840-1-zhengxingda@iscas.ac.cn/
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714 Avenger-285714 requested review from Copilot and opsiff June 2, 2026 13:05
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 2, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Mediatek JPEG driver to only initialize and cancel the JPEG workqueue for multi-core hardware variants, avoiding warnings and incorrect work handling on single-core variants.

Flow diagram for conditional JPEG work init/cancel on multi-core variants

flowchart TD
    subgraph OpenPath[mtk_jpeg_open]
        O_start([open]) --> O_check{jpeg.variant.multi_core}
        O_check -- yes --> O_init[INIT_WORK ctx.jpeg_work jpeg.variant.jpeg_worker]
        O_check -- no --> O_skip_init["skip INIT_WORK"]
    end

    subgraph ReleasePath[mtk_jpeg_release]
        R_start([release]) --> R_check{jpeg.variant.multi_core}
        R_check -- yes --> R_cancel[cancel_work_sync ctx.jpeg_work]
        R_check -- no --> R_skip_cancel["skip cancel_work_sync"]
    end
Loading

File-Level Changes

Change Details Files
Guard workqueue initialization and cancellation with the multi-core capability flag in the Mediatek JPEG driver open/release paths.
  • Initialize ctx->jpeg_work only when jpeg->variant->multi_core is true in the open path
  • Cancel ctx->jpeg_work only when jpeg->variant->multi_core is true in the release path
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a release-path warning in the MediaTek JPEG V4L2 mem2mem driver by avoiding workqueue initialization/cancellation on single-core hardware variants that never use the per-context worker (and may have a NULL worker function pointer).

Changes:

  • Guard INIT_WORK(&ctx->jpeg_work, ...) behind jpeg->variant->multi_core in mtk_jpeg_open().
  • Guard cancel_work_sync(&ctx->jpeg_work) behind jpeg->variant->multi_core in mtk_jpeg_release().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@opsiff opsiff merged commit 60acbd8 into deepin-community:linux-6.6.y Jun 3, 2026
14 of 16 checks passed
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: opsiff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants