Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2172672rdf; Mon, 6 Nov 2023 06:49:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBO3jSfPABXoE8naOeovtOOtPWvkrca7fN/TuXRS22kR0uWb+Ak/VuDfJnvvuJQE2m7L52 X-Received: by 2002:a05:6a20:12c4:b0:181:275f:3b53 with SMTP id v4-20020a056a2012c400b00181275f3b53mr14704099pzg.42.1699282166259; Mon, 06 Nov 2023 06:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699282166; cv=none; d=google.com; s=arc-20160816; b=BZ5pz05w6oSBZzugA043A0BeLZ+t+7nGWxs4iZ04NtWNin4hkEHManQ1qNO4W3k8ab eVJZqexkIiEkC0i8Eh/aWJH4tuBd/yk/IHJpExSWzyhd/Vzr0fhmwmZz7ETkTh6rM0m4 ZOdhAi5GhDFPflATQX4lp7GJTAjhDkyW3+tHeR3htMw71nhNL47LhXq8la58EKIIt4Kx ksT0z8km6KM0owVOcZ1nzq1wzD5aEI99UhYogsB6bpW6t+uFuLMdewjOJC46fshVUcmT vIML4eSmrPAol6oN2MnXe5nGI6/AS9GJuQEdYfFzbZcGSM0pKHmIuo8FouAUTsXUcw6g LFbA== 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=J+2+1vbe2QKJ61F+pm+qTQ42g1lLVufrDL4LIIdBYUE=; b=yiWY6FHXIyNnJgzJpETv3ZPRy/NDkg8drMSDWiCVa+jWiQeO/mkhAornvsm4fa5Al1 d3ay/n9isw7yflwORW8HJq+8SKTROjpcGbSj63cLQV0V8tex66Cbnkra3IaEm7XD3Oy9 2wl52kQj8kBIKL6tolffdfSL3AbGUdv2ZwsoLvJYvnfRc9eXHmQrBMdo/g1gvpCKVyPd 0KJkiNI/iUkR3/JyvhMJ4cTj+VIftpOJpqiHhFK1xwh9ZHz5X7mZ/KKFg70CaR54UL6U 2sy4etRBkpd2I3dU4xK+xeUwz5mytBhBCXcrcmaXzI0jNzqQJ+D15UHjLPNTkoI0XqbI CKmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=icMCVQ56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 31-20020a63175f000000b005b861446521si8387194pgx.281.2023.11.06.06.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:49:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=icMCVQ56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 7AEBB8027671; Mon, 6 Nov 2023 06:49:24 -0800 (PST) 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 S231942AbjKFOtO (ORCPT + 99 others); Mon, 6 Nov 2023 09:49:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjKFOtG (ORCPT ); Mon, 6 Nov 2023 09:49:06 -0500 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3250EEA; Mon, 6 Nov 2023 06:49:00 -0800 (PST) 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=icMCVQ56bJbR9Qbyx5nf8 0K8Qsm3F0mVQpUaeIG9VWBB+uvDnib0yQlDhY6wUINDGKYU317uWmk0ttZf7EoVy 6kaDmtMy3pWOzXfqtTVI5dKzpWYc5pUSFlCZSOIS346pbgYo1UqwxXe/9M+sKjuu 7a9qCM/qUzF6yGpD5ntDXE= Received: from leanderwang-LC4.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g2-2 (Coremail) with SMTP id _____wAXH5Gu_Ehl9FmbBw--.1952S5; Mon, 06 Nov 2023 22:48:21 +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, amergnat@baylibre.com, wenst@chromium.org, stable@vger.kernel.org, Zheng Wang Subject: [RESEND PATCH v2 3/3] media: mtk-jpeg: Fix timeout schedule error in mtk_jpegdec_worker. Date: Mon, 6 Nov 2023 22:48:11 +0800 Message-Id: <20231106144811.868127-4-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231106144811.868127-1-zyytlz.wz@163.com> References: <20231106144811.868127-1-zyytlz.wz@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wAXH5Gu_Ehl9FmbBw--.1952S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar15uF1rKrW5Gr4xtw4Dtwb_yoW8ZF1rpF WfK3yqkrWUWrZ8tF4UA3W7ZFy5G34Fgr47Ww43Xwn5A343XF47tryjya4xtFWIyFy2ka4F yF4vg34xJFsFyFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UF1v3UUUUU= X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/xtbBmwsgU1etjJUTHQAAsO 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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Mon, 06 Nov 2023 06:49:24 -0800 (PST) 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