From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F21BCCA47F for ; Tue, 12 Jul 2022 21:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R1i5J1DrnZ06Sscmydv9u7mWW/ADXyeDIcGrKORa+AY=; b=An8m3d4DKeUYpf OOQo18erfQhbb/TPYkyoZjpnb6CUnnYVoCwxaKi5IlXSefxFM/Scyr/KKJpckgjTxnEBDRI1SEuEl wO06C8Tu7ovq1MA4FG5XNBTzLzGZkTws7RUwadLRdUBwD+p+xbsPBkIMhPdyfdUpmKnSZqEGY0ItP StwLrdZS6g96ukz/W8jtQKgkZnur5AZexREwyP7v2ASZQg5CNqC6Pv9zITe8dbGjicEYikYzZo72c GqLJt7eKZWUNJ/guUgA/yn91nqfoYLCW/2jUXgRCj/tJfENqG0qy3QU66tK5kN03qOmMGW80AkXks xlwh4vhNE6uC2UPdpdxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBNNg-00EvaT-Vp; Tue, 12 Jul 2022 21:25:21 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBNNd-00EvV3-OH for linux-arm-kernel@lists.infradead.org; Tue, 12 Jul 2022 21:25:19 +0000 Received: by mail-ed1-x532.google.com with SMTP id eq6so11757041edb.6 for ; Tue, 12 Jul 2022 14:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tBChpcrNJ7uqMkrlYvpxSCbNo0rDEKF5+LZTTXtJt14=; b=Ywi86ClERDeLuKNgFXaQC9C0Am+AWfURZcVsReXCWgtWBy1GfoVl0R6WPPPTlHQErG jvoRgofZ0r3jKGOSWj0M8PBwVMxTkkaRoo9gXi9CDdA9GorEEpP7oqu+ssUCkREX1Ovs peY1IMAAGlLTZkp+oCV6xVzieZqlH9W3ODaeDlSQZn4/bx/A/Fv291MUyKaxtF+VIsMc K+SDlZDCHgMvG4FKXPZPY8CN2X7fsz+eS3QTTKj7DrL5OXrQ6HD0C08KH6DrA5HHQtgU 53jzf3YbyqCBEx9/MbYCtQmxXiEr6k3msPTAUICZe6d/xtuVMXyaCKrho0FDfkPU2CAv DEgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tBChpcrNJ7uqMkrlYvpxSCbNo0rDEKF5+LZTTXtJt14=; b=ETcwHp+m3yKIXY0WJNp6RXyUkdQjsKOb18N1RQBAvj5pr/+E8tlRFIZvwmZsv12Xh1 RSMT1Vj0Q3Oc9aUhu2I5OtyNAkEtGJHbhEhEm1f+iBPyDb/ba8nI83oR26P7nPNY7yZ2 r2Z855pGhoVtvYA7ZHMzn9391c4GHXdKBbcWWRe19vL56uGMLJtXaRHXEGf3mTe6eVGR ZeufDR/Fq39vpCllygU29c2OlV3ri9CtOJYLrXW+n3Iuy+Gqg67LWgHImoHvnNuzsWho acdPAQa55RftjKkCp5T/fKRKzo2s5WQVZvHEP6eFMIJGnfF/IskwzKjOz8+XVvT9GMzt 6iWA== X-Gm-Message-State: AJIora/vTMqsUTlVeBcuAe2sK+0L7P2WafwfXk1IRIBQoNnyl7oxY0MU 618xnnudnW8IeLFCr82fIqo= X-Google-Smtp-Source: AGRyM1s+hQS+QLnU/6lQQ0tzxXZ5MhaAO+TPHGDbqYL360sXVhmOZtETjA1glKjKTh/Rh8MDdn6VUQ== X-Received: by 2002:a05:6402:4395:b0:43a:c694:907d with SMTP id o21-20020a056402439500b0043ac694907dmr161122edc.310.1657661113418; Tue, 12 Jul 2022 14:25:13 -0700 (PDT) Received: from kista.localnet (213-161-3-76.dynamic.telemach.net. [213.161.3.76]) by smtp.gmail.com with ESMTPSA id r17-20020a056402019100b0043a9144d8ecsm6650252edv.71.2022.07.12.14.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 14:25:12 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Ezequiel Garcia Cc: mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, samuel@sholland.org, mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, linux-media@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 5/7] media: cedrus: h265: Add a couple of error checks Date: Tue, 12 Jul 2022 23:25:00 +0200 Message-ID: <37675481.J2Yia2DhmK@kista> In-Reply-To: References: <20220620175517.648767-1-jernej.skrabec@gmail.com> <20220620175517.648767-6-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220712_142517_835671_A2EA38C2 X-CRM114-Status: GOOD ( 33.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Ezequiel. Dne ponedeljek, 11. julij 2022 ob 23:31:11 CEST je Ezequiel Garcia napisal(a): > On Mon, Jun 20, 2022 at 07:55:15PM +0200, Jernej Skrabec wrote: > > Now that we have infrastructure for reporting errors, let's add two > > checks, which will make sure slice can be actually decoded. > > > > Signed-off-by: Jernej Skrabec > > --- > > > > drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index > > cfde4ccf6011..99020b9f9ff8 100644 > > --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > > Now that you've allowed setup to fail, I would suggest > to have some documentation/comments on struct cedrus_dec_ops, > to set the expectation/rules for each ops, including the > call paths for each operation, which of them are allowed to sleep, > etc. Documentation can be always added, but it should be separate patch. > > > @@ -435,9 +435,17 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, > > struct cedrus_run *run)> > > * instead of start of slice data. Padding is 8 bits at most (one bit > > set to 1 and * at most seven bits set to 0), so we have to inspect > > only one byte before slice data. */ > > > > + > > + if (slice_params->data_byte_offset == 0) > > + return -EOPNOTSUPP; > > + > > AFAICS, cedrus_h265_setup is called from .device_run. > We've been discussing control validation before, and I think the > ideal place to do that is v4l2_ctrl_ops.s_ctrl, if that's > at all possible. Yeah, this particular check can be moved to s_ctrl handler. > > Driver's mem2mem device_run are executed in the context > of a work_struct and the failure won't really get reported > up the stack. Well, at least there will be a notice in dmesg. Not ideal, I know. > > > padding = (u8 *)vb2_plane_vaddr(&run->src->vb2_buf, 0) + > > > > slice_params->data_byte_offset - 1; > > > > + /* at least one bit must be set in that byte */ > > + if (*padding == 0) > > + return -EINVAL; > > + > > Maybe this is something to check at cedrus_buf_prepare(), > when the buffer is queued? I don't think so. This check is HEVC specific, but cedrus_buf_prepare() is not and we need to have slice control ready, which I'm not sure is the case for cedrus_buf_prepare(). Best regards, Jernej > > Thanks, > Ezequiel > > > for (count = 0; count < 8; count++) > > > > if (*padding & (1 << count)) > > > > break; > > > > -- > > 2.36.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel