From patchwork Wed Oct 19 08:24:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205332wrs; Wed, 19 Oct 2022 01:49:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5baaytUGpCPZv3iAryTESfTZhfSUFRWgipAB7+kZd+ZAmY82fkIPwjn3Fmaksd74HGJ5JN X-Received: by 2002:a17:90b:254e:b0:20b:7e26:f0a0 with SMTP id nw14-20020a17090b254e00b0020b7e26f0a0mr42635561pjb.203.1666169335068; Wed, 19 Oct 2022 01:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169335; cv=none; d=google.com; s=arc-20160816; b=rLpDXMPDFu/7SUQdqLHRus233o2QuTQN7l1/HvBvc/DW5MJfSZtwvQ6xskcjaq3f94 LpUc3ql6x6Nws+8wRbLNWF/iYweQmoeSp5i3vR7XPM+Ad/if6FhuMkh/4/cdWHOsSrav CM+ZSDy6Gv+XDGNtRewqMjvjeRFsRRX9hQwfZg49vjcssz8y43ahWeeUn/WMS2NGWKhL WT2b/NBEi7OU0HdpQPfGk7fJNfxy9vDr6OApKfxqHaL1i420MRGYSIgFQHj/IgygOD+q HZU80l9DO2wiogT0RSITtBbBWuTJjbZJqCAqUUbMQEGbx7NVmcKUEhVji6DcRdqHy8LW f/QQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5HJ9K8RFmhj0Ub/H6DfbEpPoiXc7amWvruTFHoNltB4=; b=AIUr8S86MFiqCTTZGRJaLuIepv7eRDd42jJDECSJctpIWgQoKrOwvbWxv3aGRRbCM+ zn3As8fZZFGg7UsBiQQtJbIxIzcBzjWSnZ+QHR31VY+HraD4SDrsw0oNHpt9c9nNxYHF HO28NpdmE12JnIW+CltQCG0A4p2ahZqD0iEEG4QmFjONXVJSwxW8PsMYKiyxyWQETRYE RUL/M3AB9lZd2ol90kd9d5dFceaZo4JUr0QCUJAadd/MvyShLN9DsXfYWgXGWA+ljQe+ zRtZuI3q+y68QwT3xB/1YvQml+5QmZmMc0p7roXIlkEthGBG2jRC/vq/noeH7RGP/ES3 oMpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ablIAMPg; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a1709028d8a00b00183e8a29776si16919198plo.36.2022.10.19.01.48.42; Wed, 19 Oct 2022 01:48:55 -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=@linuxfoundation.org header.s=korg header.b=ablIAMPg; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231603AbiJSIsN (ORCPT + 99 others); Wed, 19 Oct 2022 04:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231574AbiJSIrm (ORCPT ); Wed, 19 Oct 2022 04:47:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0112850076; Wed, 19 Oct 2022 01:45:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B5609617FF; Wed, 19 Oct 2022 08:45:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5D00C433C1; Wed, 19 Oct 2022 08:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169131; bh=UdFH1/iFHJDIGa6c18khrKEDVJy6r7SQUPt5r5yMBp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ablIAMPgWGg2k0RHRUCDJ0OevthxyWuzir4gJyvFxrtDVOKdTlYs39ebfZWKyKZhR DwUzTLec6TMbRWpEShQXvCT1JcBY5s3hQ5Qfx/5bc1m05M47I+yuP09SM3/GBFwg+D JYap1TuRvfGILVveYJhhIf6l4YAp68xi7EwbiPoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Dufresne , Paul Kocialkowski , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 6.0 169/862] media: cedrus: Fix watchdog race condition Date: Wed, 19 Oct 2022 10:24:16 +0200 Message-Id: <20221019083257.420769331@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747105176469959950?= X-GMAIL-MSGID: =?utf-8?q?1747105176469959950?= From: Nicolas Dufresne commit fe8b81fde69acfcbb5af9e85328e5b9549999fdb upstream. The watchdog needs to be scheduled 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 Reviewed-by: Paul Kocialkowski Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- 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,