Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp866520rwb; Thu, 18 Aug 2022 13:49:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7P+je1hJ7Ugt6sXSZ1rGKfscDFmI7C3iC7VKQStWe23LMDs6HajFX+QWWMQUuKqUwvdstk X-Received: by 2002:a05:6402:514f:b0:445:e158:9eb7 with SMTP id n15-20020a056402514f00b00445e1589eb7mr3492742edd.322.1660855761271; Thu, 18 Aug 2022 13:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660855761; cv=none; d=google.com; s=arc-20160816; b=mCZZDShXMQzw1jtXcUo27TEFw2E8V3CPGntk5w9snOjGSm3Y/ppnHpKrdGTi/0W1q0 Cu3BRCh6EiqXVsIa94fLVLmpvJ4ihguLVT7FKA554UkbA02iT0mxh2PiumgGUn9iJ5ig 4x5joylM5Mt32IlA/LSDRQk2INdhJ0gBfd2g3C2OVkePa/6E2+ble7a9Cnu1NbKCqzIC /Inm71xrsCNrk/qluXImlUHHSlfgOxK394BJeuW9uJTBnnkSmNOrd7jFsfgqVef/Tg2f zYxuv4dJvn6ge6+zWXmSQLgPf+E3W2pmonuQk34h5SBrwz09DJlzhMxmjn1X9sVVEYj0 p8+Q== 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=iAntAw6WCg7nwEJF+ql9CF6u7Gxjvbcq7nLCoaXTqwE=; b=0LKyi0rx0LwUoKvH0C09HYxYwYU3FjBDjLNlXu0iUG0FQJsaHbGa+rC2gqzBCno451 P//A9V8SmTRoeJwSbxGPBZhXLigvNacTfgC2BF1EgqkOQbW7OHGd5w5z40v9EE+NBRvs Zl6qrB5A4Gjc6sP1g03lw31fEuWx2p5ZZJP+kJgZmpZY4NyQD63kpKs4Zcq7YuT5Iq9u fqofFyNvslJ4MiAdbqZ5CZWVMXpPBy+9kJO3ziDycHF8SP56ji2P7waqMXX4Sfl8u6GK Uk/K11NWW1z5mV7lCMiPEnj+E8G0LnY+T/XwdS+S+DTflMeSPWmU/lgFsvPXBjfTMaqb NpZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=V2yfagMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a056402518700b0043cae183e35si1485775edd.422.2022.08.18.13.48.49; Thu, 18 Aug 2022 13:49:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=V2yfagMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346082AbiHRUd4 (ORCPT + 99 others); Thu, 18 Aug 2022 16:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238275AbiHRUdy (ORCPT ); Thu, 18 Aug 2022 16:33:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12EE633A0E; Thu, 18 Aug 2022 13:33:51 -0700 (PDT) Received: from whitebuilder.lan (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 026F96601B46; Thu, 18 Aug 2022 21:33:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1660854830; bh=pggMW/0Bxy8VjFzlvpemyaipfIDNrL2BmOAkso3LhhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2yfagMG57Nh3EXsVf9/Smr/3esiSEbIWwaYOIiLAHA+6nV2niIE9P/2HYaJiywov G8QzDCDnzOeAeslg/Tnf6Y9Fa3il7jyPDhLjVbM7IVs/H25Cncmgrkt9lNIanNMXIH osCQAXJsYJM/LZFnYttXjTZGnrlrEAZGby67oDBvlz6EPuX9kn5AGAraiJ8vISeafA KZV1o2iv9NY/0c63k5T/OFe3i3YohHc1x0KoPwBvSjXyfhTNG0GaSs3gFmR3bVKV1j rwpyCFPLSBmjLyK3NVkNNEQlz6x/P9B6B1wKrascvZhZh9JV39AGv6CnYK47ccsQ/a wNOz5rtW8yh6Q== From: Nicolas Dufresne To: linux-media@vger.kernel.org, Maxime Ripard , Paul Kocialkowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Ezequiel Garcia , Hans Verkuil Cc: kernel@collabora.com, Nicolas Dufresne , stable@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/3] media: cedrus: Fix watchdog race condition Date: Thu, 18 Aug 2022 16:33:06 -0400 Message-Id: <20220818203308.439043-2-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220818203308.439043-1-nicolas.dufresne@collabora.com> References: <20220818203308.439043-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 The watchdog needs to be schedule before we trigger the decode operation, otherwise there is a risk that the decoder IRQ will be called before we have schedule the watchdog. As a side effect, the watchdog would never be cancelled and its function would be called at an inappropriate time. This was observed while running Fluster with GStreamer as a backend. Some programming error would cause the decoder IRQ to be call very quickly after the trigger. Later calls into the driver would deadlock due to the unbalanced state. Cc: stable@vger.kernel.org Fixes: 7c38a551bda1 ("media: cedrus: Add watchdog for job completion") Signed-off-by: Nicolas Dufresne --- drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index 3b6aa78a2985f..e7f7602a5ab40 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -106,11 +106,11 @@ void cedrus_device_run(void *priv) /* Trigger decoding if setup went well, bail out otherwise. */ if (!error) { - dev->dec_ops[ctx->current_codec]->trigger(ctx); - /* Start the watchdog timer. */ schedule_delayed_work(&dev->watchdog_work, msecs_to_jiffies(2000)); + + dev->dec_ops[ctx->current_codec]->trigger(ctx); } else { v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, -- 2.37.2