Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1021187rdh; Fri, 27 Oct 2023 02:20:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpT01sI/BxMIJu+mfu8YDmMtRfczWd0ThuId5ma/dcOIXlrbLcXmqot1U1u+ENX1IV4ZLL X-Received: by 2002:a25:aa2e:0:b0:da0:d0e6:905d with SMTP id s43-20020a25aa2e000000b00da0d0e6905dmr1761248ybi.59.1698398418656; Fri, 27 Oct 2023 02:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698398418; cv=none; d=google.com; s=arc-20160816; b=CRqkVcfwfRIYvgS4Aj+HV8KZqeQb9sItF9hDCVFsutmmQXs0R6Ania3/EfOIep5nfE xWpeQJBWZoyXWK4f1fIdq4/il5RMvumL0nW2A1YHgl4tdwPSa+fTjiIN7sD+gKBCgADH 5N6II2VITuQEijKdESB4tRL1Xaynsg0ny+Kaq29VTSIT6mTUUz0+2mUxfSCeAgaX9Uy1 rJcWFd+vC5Bbe18nclqvDtyiAKwWczDnxpcO1cgmalSJ4ZMxvNTqWYcfmeC8L06F2YWb bkaznE2NqgAj3h+eLP1SZkESJgcLcV5XNLF1i54RFdL0bNWRKNcw8QjRlNnnyFD6QEgZ WpEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=x7fivBQJq72nSMKux0IKJcpLOEh/ZK4DVTpIIvCRjkA=; fh=jhBAW35p4b2oJLfuOUmbxBtG0fjoiGHBapgzYTQ+zbE=; b=IJe40pB71MwgL0aPJPr9daFDKZVNWDpw4fjlTgtk8mb8gST6bHn1p090YeANG2+bYy H/GeIS8qym2HMz4uB20/A/XB5utqX6y+0PqNin+rssQbEo2tIHF6dPSD2NG9pQx7OeGy /RiN6i73KUdPgJK3zh+xEY6/JyEDJfVL4sXKmnxroFOA/i6nRLdigDDGyTXev6k0xy0h BBHN9seSt9zTPVpWJvT0Kwr1A/IRUi41hNw85ZcsAND2nzuomM4KYjYLla2wKuIg4/oH UbAILap2A1nRF2nXwTUSW7GrRXhPA7LpUAovpTG64ai5BuAP5m9Jg77Suh0Ehs8i+Mvt nC2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=OWIxMHln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j85-20020a252358000000b00d81841ef6c0si1887880ybj.28.2023.10.27.02.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 02:20:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=OWIxMHln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7897982CC42A; Fri, 27 Oct 2023 02:20:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235145AbjJ0JUE (ORCPT + 99 others); Fri, 27 Oct 2023 05:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345577AbjJ0JT7 (ORCPT ); Fri, 27 Oct 2023 05:19:59 -0400 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE9CA11F; Fri, 27 Oct 2023 02:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=x7fiv BQJq72nSMKux0IKJcpLOEh/ZK4DVTpIIvCRjkA=; b=OWIxMHlnmEetMmBrF5wNU iet7mM3/6axuVHUu3jZFNsHOXrsp3S/VMOPP91EA/7OGOW1vfuOg4lGzPHZ8O033 /rHAIxiNMDBr4lwpT8LaVY3j2FeWV8laEfkO7c4V97x9T1h0WgNl0B3v2P0kty8b vk6rDiF5DKyGBqGlQOlDYI= Received: from leanderwang-LC4.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g0-0 (Coremail) with SMTP id _____wBnD_ZrgDtlHuRqBg--.47942S2; Fri, 27 Oct 2023 17:18:35 +0800 (CST) From: Zheng Wang To: dmitry.osipenko@collabora.com Cc: Kyrie.Wu@mediatek.com, bin.liu@mediatek.com, mchehab@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Irui.Wang@mediatek.com, security@kernel.org, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, amergnat@baylibre.com, wenst@chromium.org, Zheng Wang , stable@vger.kernel.org Subject: [PATCH 2/2] media: mtk-jpeg: Fix timeout schedule error in mtk_jpegdec_worker. Date: Fri, 27 Oct 2023 17:18:32 +0800 Message-Id: <20231027091832.39082-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wBnD_ZrgDtlHuRqBg--.47942S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar15uF1rKrW5Gr4xtw4Dtwb_yoW8Cw1kpF Z3K3yqkrW5Wrs8tF4UA3W7ZFy5G3s0gr47WF43Wws3J343XF47tryjya4xtFWIyFy2ka4F vF4vg34xJFsFyFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziiIDxUUUUU= X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiXA4WU1Xl75dK2QAAsM X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 02:20:11 -0700 (PDT) In mtk_jpegdec_worker, if error occurs in mtk_jpeg_set_dec_dst, it will start the timeout worker and invoke v4l2_m2m_job_finish at the same time. This will break the logic of design for there should be only one function to call v4l2_m2m_job_finish. But now the timeout handler and mtk_jpegdec_worker will both invoke it. Fix it by start the worker only if mtk_jpeg_set_dec_dst successfully finished. Fixes: da4ede4b7fd6 ("media: mtk-jpeg: move data/code inside CONFIG_OF blocks") Signed-off-by: Zheng Wang Signed-off-by: Dmitry Osipenko Cc: stable@vger.kernel.org --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 7194f88edc0f..d099a9b67930 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1750,9 +1750,6 @@ static void mtk_jpegdec_worker(struct work_struct *work) v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - schedule_delayed_work(&comp_jpeg[hw_id]->job_timeout_work, - msecs_to_jiffies(MTK_JPEG_HW_TIMEOUT_MSEC)); - mtk_jpeg_set_dec_src(ctx, &src_buf->vb2_buf, &bs); if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, @@ -1762,6 +1759,9 @@ static void mtk_jpegdec_worker(struct work_struct *work) goto setdst_end; } + schedule_delayed_work(&comp_jpeg[hw_id]->job_timeout_work, + msecs_to_jiffies(MTK_JPEG_HW_TIMEOUT_MSEC)); + spin_lock_irqsave(&comp_jpeg[hw_id]->hw_lock, flags); ctx->total_frame_num++; mtk_jpeg_dec_reset(comp_jpeg[hw_id]->reg_base); -- 2.25.1