Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1061918rwe; Thu, 25 Aug 2022 14:47:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7oXYkvmH3g0rLm8nbq12+x4EiXBgEdQ9JiKhX8KNEnS877z7RL3thiZ/thT/ejs6gwLVZl X-Received: by 2002:a17:90b:2404:b0:1fc:b5d1:446f with SMTP id nr4-20020a17090b240400b001fcb5d1446fmr1053790pjb.58.1661464024086; Thu, 25 Aug 2022 14:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661464024; cv=none; d=google.com; s=arc-20160816; b=ellR2/ZY4h5959RZrj5Fl4DHRiWm4LYlRkyc1KRfd5qvBwjqmS7HfnH//rKRNmKx7q l6yEuyjT9DCQSAPf3ZepzI9Nu7xuilirHF1mD4Slot/Sog9S2QCtLEGAYzs+gK6uterA iHrZ7bnh8apTV5kRX827bAazPz1qteIaVD8dFCxOrtvyifxJO9HIruXmwhuKVHVT2YlB +4BCtkNNdOjLaCWVBgQf4pR0BSfvxLpTlSiriZ2NreuRDFaMTUuWdGCt1dysSXLMzHq+ iHt6udkE6GZ4swbWVBmbtPeytFFgX3yaFMGXfMlno6YpAN5Tu7Dtuh75KndNoOQSjZXY XaNA== 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=S+BxiqaH71h1xd9DneoBgjt53lZC5EPrruUqpKoLEFI=; b=QYeksTf44lNqAkt3Zz6LNB43g7casoYQTKhJnPN+ik8BlkaO0s+WgnW+lJUUZlnVfG bavCW3jGkbLTN+CmH/kU3bwQnHTn7hdgvsVGC4ocRuI/UfSYRA5XoAkBQhyGbRyZspA0 o/j8LFghvSwOIroi7lLrKRU6Pvz5sXBtlTi8bdObTduKfEhkwMdFxKBwSE6mxnZIp4NC WeiBqF16ApO5b8aGIIuRxpNv1LlH+lVEZz5W+WfbeoLhQsfcqZa/OuorN5e15yDvYQho 6XS1jMjDkcO27oyMtg3g9n+O9JELEnj8LWKiwAxaDYe5WEJvf5MDBTyxsgjpdkixaIp9 +QNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CWB5jvf4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a170902cf0300b0016fed2b1341si27541plg.580.2022.08.25.14.46.52; Thu, 25 Aug 2022 14:47:04 -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=@gmail.com header.s=20210112 header.b=CWB5jvf4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243293AbiHYVOH (ORCPT + 99 others); Thu, 25 Aug 2022 17:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243207AbiHYVN5 (ORCPT ); Thu, 25 Aug 2022 17:13:57 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD3F0B2CD3; Thu, 25 Aug 2022 14:13:55 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id k17so10812037wmr.2; Thu, 25 Aug 2022 14:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=S+BxiqaH71h1xd9DneoBgjt53lZC5EPrruUqpKoLEFI=; b=CWB5jvf4hyAFyEInzBIoB1UYsnMzqSc5qpaWyatPOnBcyRIwN7C6gITXKQaqkX9J0P Ms8TXsLhgYSS1B/XDqLowYkoSxCz3a4aMAN+hVtXqCo4OFrf+8FxuB/eOXPDf3pNuPkJ ggzlRRNRkPgbpJca1KNH5fhHn7hN1Vrchog2xBbMLu+I5lhVZ5FwR8Nt81qtudalm8yR PO8/RkQoycF/S7lD0gtzquazXYUjBt9YCXk3J8CZUwwp6I+fbvTYq3PglDSOMJul9HEX Am7sJ15mMh7+s9QdjqWaqTvf5QXs2+jFuJp9pkS86oUtCW4GQKk1bidmXoaOxxiM1uBJ G1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=S+BxiqaH71h1xd9DneoBgjt53lZC5EPrruUqpKoLEFI=; b=Lg7Hve3SOl5vsjlZKfDIfpbCsq5Djd7tHaZ86/IrJbSQ0tpm3xMH2TeWopPcJbtl2L 3D3w4C9IyL8kLU1sdHFEb3X/AvDGSYCuK4DStiBc33hApaO4twDHmkNOzq/l5jxF6ipV ul8HdlQX7rQVqXw9n6LDiEB/NModL++DoH3vIE7SrdT7gTtdlTKnULj59A5iwtmnkbl3 8yyLbCqy814E5says0QVmXMj1yBHQ2ku5FpLpjlhM/DD99HOPy9iC1y9o/RYkmM3vI78 JaY0y4MQF3OhaRdc7P4xrzlnodbTofgOF9WcHQ4TjVc5Gn8mu+klSojiliKv3d/WaEmt NNAA== X-Gm-Message-State: ACgBeo2FbTr+ND1rBs5Fs+uO4M1dk0FVeTqEbSmVlIPxqAQ+7ErXRCPH 1YmQxBHY9StD2g02pGDFYr8u8FZpHUuhWw== X-Received: by 2002:a05:600c:190b:b0:3a5:f8a3:7a8c with SMTP id j11-20020a05600c190b00b003a5f8a37a8cmr3201245wmq.54.1661462034344; Thu, 25 Aug 2022 14:13:54 -0700 (PDT) Received: from kista.localnet (82-149-1-172.dynamic.telemach.net. [82.149.1.172]) by smtp.gmail.com with ESMTPSA id v64-20020a1cac43000000b003a5fcae64d4sm372013wme.29.2022.08.25.14.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 14:13:53 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: linux-media@vger.kernel.org, Maxime Ripard , Paul Kocialkowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Chen-Yu Tsai , Samuel Holland , Nicolas Dufresne Cc: kernel@collabora.com, Dmitry Osipenko , 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: Re: Re: [PATCH v1 3/3] media: cedrus: Fix endless loop in cedrus_h265_skip_bits() Date: Thu, 25 Aug 2022 23:13:52 +0200 Message-ID: <1733932.VLH7GnMWUR@kista> In-Reply-To: <52bb86cf12450ce78d2f196a1b86b4137ec61a07.camel@collabora.com> References: <20220818203308.439043-1-nicolas.dufresne@collabora.com> <5849126.lOV4Wx5bFT@jernej-laptop> <52bb86cf12450ce78d2f196a1b86b4137ec61a07.camel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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_NONE,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 Dne petek, 19. avgust 2022 ob 17:39:25 CEST je Nicolas Dufresne napisal(a): > Le vendredi 19 ao=C3=BBt 2022 =C3=A0 06:16 +0200, Jernej =C5=A0krabec a = =C3=A9crit : > > Dne =C4=8Detrtek, 18. avgust 2022 ob 22:33:08 CEST je Nicolas Dufresne= =20 napisal(a): > > > From: Dmitry Osipenko > > >=20 > > > The busy status bit may never de-assert if number of programmed skip > > > bits is incorrect, resulting in a kernel hang because the bit is poll= ed > > > endlessly in the code. Fix it by adding timeout for the bit-polling. > > > This problem is reproducible by setting the data_bit_offset field of > > > the HEVC slice params to a wrong value by userspace. > > >=20 > > > Cc: stable@vger.kernel.org > > > Reported-by: Nicolas Dufresne > > > Signed-off-by: Dmitry Osipenko > > > Signed-off-by: Nicolas Dufresne > >=20 > > Fixes tag would be nice. > >=20 > > > --- > > >=20 > > > drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 6 ++++-- > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > >=20 > > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > > b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index > > > f703c585d91c5..f0bc118021b0a 100644 > > > --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > > @@ -227,6 +227,7 @@ static void cedrus_h265_pred_weight_write(struct > > > cedrus_dev *dev, static void cedrus_h265_skip_bits(struct cedrus_dev > > > *dev, > > > int num) { > > >=20 > > > int count =3D 0; > > >=20 > > > + u32 reg; > > >=20 > > > while (count < num) { > > > =09 > > > int tmp =3D min(num - count, 32); > > >=20 > > > @@ -234,8 +235,9 @@ static void cedrus_h265_skip_bits(struct cedrus_d= ev > > > *dev, int num) cedrus_write(dev, VE_DEC_H265_TRIGGER, > > >=20 > > > VE_DEC_H265_TRIGGER_FLUSH_BITS | > > > VE_DEC_H265_TRIGGER_TYPE_N_BITS(tmp)); > > >=20 > > > - while (cedrus_read(dev, VE_DEC_H265_STATUS) & > > > VE_DEC_H265_STATUS_VLD_BUSY) - udelay(1); > > > + > > > + if (cedrus_wait_for(dev, VE_DEC_H265_STATUS, > > > VE_DEC_H265_STATUS_VLD_BUSY)) + > >=20 > > dev_err_ratelimited(dev->dev, "timed out > >=20 > > > waiting to skip bits\n"); > >=20 > > Reporting issue is nice, but better would be to propagate error, since > > there is no way to properly decode this slice if above code block fails. > This mimic what was already there, mind if we do that later ? The > propagation is doing to be a lot more intrusive. Since backporting fixes before 6.0 isn't priority, viability for backpporti= ng=20 isn't that important. You would only need to return 0 or -ETIMEDOUT and che= ck=20 for error in only one location. That doesn't sound very intrusive for me. Best regards, Jernej >=20 > > Best regards, > > Jernej > >=20 > > > count +=3D tmp; > > > =09 > > > }