Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp68579rdb; Tue, 31 Oct 2023 00:18:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErJU6aJ6pAjpyplxO6ZaVDqpXlrwmN0mcjW3ptLprkvqoAHaTSjoPNARgukdHfGNPOLCPa X-Received: by 2002:a05:6300:8005:b0:180:e4c1:3e88 with SMTP id an5-20020a056300800500b00180e4c13e88mr1970496pzc.53.1698736681507; Tue, 31 Oct 2023 00:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698736681; cv=none; d=google.com; s=arc-20160816; b=rHc72JlfVh+aLJgSJdN6+oinNqsBZT7Sihxi8ZzCpaC/BakG1It4r3ixALMTbHnFxH k3Fl6yJu92SmzPXSTRIb0Z02rLytO5yOuSUxobENjlxHvP2Hgl7AMjG/WPdWWRKL8o8J f/sAWXTHK9e9LTTwpMz4OILJvFIBpOgJRfwXnNT2TLfT3so9ea4nPttez8CasMkcjtwb VCfcZVU/s9x57gDGvvj966EJyOZYcdK4oEkqd+hjVHP99wZR3E8Xz2uDowUburUjgq6M 6aEq+ws/CaPS+YTCwM7FD2GVN+Uw7bXESFAPUgM94e+0cQJ+ZgK6+Byccuq/tyWu+QWB 2scQ== 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=fXqe7hgwqgWvpPb4rMgoLuZnHUeO+Y/G9iqqXQhW3e1UV/odW4WJDoKky9zyz3ftq7 fan3mWEeuF+EL4eTtXgn+l3dMWebJFtlUOErAmbNGznKJFdtoIDSKg0qj97OdWqbw9r6 TjwXO6wkIrcZ8KgCX43ZCYUkSxwiK3uZcVsclsEx2NSzp8FbspbfSBifwI6yK3+XeX+J go5jSWmsnzEj6fMeD5KXUh52fe8UEcn6n+ftKbQTUkdDwdYqRHkJqFA+IMMx+o8cfDuf YOxWzykF202B4Z0/1cRKWBf+9lGXVJvP70J0dtvgb14yu5usJh+B1rfe2Ip9BPF0Xx0c iGhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=OrIC40tm; 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 y12-20020a056a00180c00b006c1222d68e2si607274pfa.196.2023.10.31.00.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 00:18:01 -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=OrIC40tm; 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 1ECFD803BAA5; Tue, 31 Oct 2023 00:17:57 -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 S1343597AbjJaHRq (ORCPT + 99 others); Tue, 31 Oct 2023 03:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbjJaHRn (ORCPT ); Tue, 31 Oct 2023 03:17:43 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 778AEC1; Tue, 31 Oct 2023 00:17:40 -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=OrIC40tmci6RhEscC9gla xHTAaSCL9FiAp/BqCBDMNjAAfGuvu3Oy8IOv5zdDjJICQJj37neLCenx27GEx8Li lDKmGkTAVOqq/Bpp3Az5t9P9G/MmqKOahtO7NkY5g65hZ8Z8xHvl77lhWzfnZewR 2ALg90tvkhEUWnqMNz6TCg= Received: from leanderwang-LC4.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g3-3 (Coremail) with SMTP id _____wBn3ojfqUBlwMj4AQ--.51864S5; Tue, 31 Oct 2023 15:16:51 +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 Date: Tue, 31 Oct 2023 15:16:44 +0800 Message-Id: <20231031071644.20086-4-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231031071644.20086-1-zyytlz.wz@163.com> References: <20231031071644.20086-1-zyytlz.wz@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wBn3ojfqUBlwMj4AQ--.51864S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar15uF1rKrW5Gr4xtw4Dtwb_yoW8ZF1rpF WfK3yqkrWUWrZ8tF4UA3W7ZFy5G34Fgr47Ww43Xwn5A343XF47tryjya4xtFWIyFy2ka4F yF4vg34xJFsFyFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UTuWLUUUUU= X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/xtbBdgYaU2Dkptft7gAAsP 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:17:57 -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