Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp71271rdb; Tue, 31 Oct 2023 00:26:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx8knMm7bFsxGmUt6LLi1mepBupU/GPlsXZt5C9AHE8ug9Xpf44VyAKTH7KDjOujt5AWtx X-Received: by 2002:a17:902:e54a:b0:1ca:e9f8:2af8 with SMTP id n10-20020a170902e54a00b001cae9f82af8mr12172187plf.13.1698737204564; Tue, 31 Oct 2023 00:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698737204; cv=none; d=google.com; s=arc-20160816; b=OT/Kz4Su4vmNMrSVeflsrZNdSsmU5o96MPYJ1/MXVLvhKjbBq1Q1hJceuun/07USaX 0emmF96Abh1PL/X6NlCcwI/BxOgBZgsLyuDVZpyhm38jERH+LKSrvw6yAoCqr/xghgcV 1XIFkKjfWTHlod5hsPOCM7ZJX0RMz0RDWtltMrkDaF9lJ2blQC4YpyQ/h5QMkPETT+2J L0tnoPq19T54oUlmFP/wsYW+em7uFFNZTGrduJro0XXTxM64T6JoNBF+9OFb2EI0T+Ng kLLoZXEBrNDU3wy+XKJqneRdUoc6R+azcmtZLC2FxWcyPX8lsLxeOvp/CVLN6iMAB/dd igug== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=omdBIC+e1jVadRkJ0QsCI7L9wKGBA2OoP3PF04hqiWI=; fh=jhBAW35p4b2oJLfuOUmbxBtG0fjoiGHBapgzYTQ+zbE=; b=EGmicl+8S67cacJz45YWcptedm7lfiVgbLnnhojDatUXr51I4b2Z43v8pboFNaclwv 1tlgpxoOuYYjIACWEdRRLFJ+ZNa90ukM014K5ZJOuRKFIKe5mkMlBV05V933goskW3uU WYm5SCuDY7Heb6X0eAB+g6ywGv9bgGgEGAUSUxqCekzv8+JklTxdlopL2WyigFU0dH8t mo060faI/v+BE9fLqE/slNtYrrPKbKTnT1qVOvzEVN8eZvVPbTCVScvWwz26GEs7S58z damxLVRaO1bJqCDLTblyl+Zo0ruw7fNo7dULNikDl0IyBjjXuNhUK+LPUyekIRHzYuGT RscA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=QJgdMKf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o13-20020a170903210d00b001bb0ba81053si637269ple.50.2023.10.31.00.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 00:26:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=QJgdMKf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 60C1D8080C7C; Tue, 31 Oct 2023 00:25:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343645AbjJaHZC (ORCPT + 99 others); Tue, 31 Oct 2023 03:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343607AbjJaHZA (ORCPT ); Tue, 31 Oct 2023 03:25:00 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0C65E4; Tue, 31 Oct 2023 00:24:56 -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=omdBI C+e1jVadRkJ0QsCI7L9wKGBA2OoP3PF04hqiWI=; b=QJgdMKf9G1x2TXO+YyjER 0BC0mNKytgpKXaoFv61Lmze4alS6yIqqE4JNXxOTLjZ/4Gz05O30pmACgzNaq5OK jvffLR7nvvrPzD1VagDHsq6JH1RG9OW+RuVF81MrnIGVoqUwpHBleNLKzv0lymzX 38G8TBbSLYYqiBX2LOssg0= Received: from leanderwang-LC4.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wDXP+6wq0Blv5KVAQ--.8863S5; Tue, 31 Oct 2023 15:24:32 +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 v2 3/3] media: mtk-jpeg: Fix timeout schedule error in mtk_jpegdec_worker. Date: Tue, 31 Oct 2023 15:24:29 +0800 Message-Id: <20231031072429.21448-4-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231031072429.21448-1-zyytlz.wz@163.com> References: <20231031072429.21448-1-zyytlz.wz@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDXP+6wq0Blv5KVAQ--.8863S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar15uF1rKrW5Gr4xtw4Dtwb_yoW8ZF1rpF WfK3yqkrWUWrZ8tF4UA3W7ZFy5G34Fgr47Ww43Xwn5A343XF47tryjya4xtFWIyFy2ka4F yF4vg34xJFsFyFJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UJHUgUUUUU= X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/xtbBdhMaU2DkptgIowAAs9 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 00:25:29 -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 --- v2: - put the patches into a single series suggested by Dmitry --- 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 a39acde2724a..c3456c700c07 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1749,9 +1749,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, @@ -1761,6 +1758,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