From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
To: "Jernej Škrabec" <jernej.skrabec@gmail.com>
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: Wed, 13 Jul 2022 13:45:01 -0300 [thread overview]
Message-ID: <Ys72jfI1QdGm+q0g@eze-laptop> (raw)
In-Reply-To: <37675481.J2Yia2DhmK@kista>
Hi Jernej,
On Tue, Jul 12, 2022 at 11:25:00PM +0200, Jernej Škrabec wrote:
> 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 <jernej.skrabec@gmail.com>
> > > ---
> > >
> > > 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.
>
Of course, this wasn't a comment meant to block the patch in any way.
> >
> > > @@ -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().
>
Hm... this is indeed a special case. The buffer contents
depend on a control, and both buffer and control are part of the same
request.
At least the decoding job would fail, and would get signaled
by the dequeued CAPTURE buffers and the V4L2_BUF_FLAG_ERROR flag,
which makes perfect sense.
In general vb2_ops.buf_prepare() is called for each
buffer (either through VIDIOC_QBUF or through MEDIA_REQUEST_IOC_QUEUE),
so for some buffer validations .buf_prepare() _might_ work better
than .device_run for validation.
In any case, the patch looks good, I don't think these
comments should block the patch:
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Thanks,
Ezequiel
> 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
next prev parent reply other threads:[~2022-07-13 16:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 17:55 [PATCH 0/7] media: cedrus: h265: Implement tiles support Jernej Skrabec
2022-06-20 17:55 ` [PATCH 1/7] media: cedrus: h265: Fix flag name Jernej Skrabec
2022-06-20 17:55 ` [PATCH 2/7] media: cedrus: h265: Fix logic for not low delay flag Jernej Skrabec
2022-06-20 17:55 ` [PATCH 3/7] media: cedrus: Improve error messages for controls Jernej Skrabec
2022-07-11 21:35 ` Ezequiel Garcia
2022-06-20 17:55 ` [PATCH 4/7] media: cedrus: Add error handling for failed setup Jernej Skrabec
2022-07-11 21:21 ` Ezequiel Garcia
2022-06-20 17:55 ` [PATCH 5/7] media: cedrus: h265: Add a couple of error checks Jernej Skrabec
2022-07-11 21:31 ` Ezequiel Garcia
2022-07-12 21:25 ` Jernej Škrabec
2022-07-13 16:45 ` Ezequiel Garcia [this message]
2022-06-20 17:55 ` [PATCH 6/7] media: cedrus: Add helper for determining number of elements Jernej Skrabec
2022-07-11 21:35 ` Ezequiel Garcia
2022-06-20 17:55 ` [PATCH 7/7] media: cedrus: h265: Implement support for tiles Jernej Skrabec
2022-07-11 21:34 ` Ezequiel Garcia
2022-07-12 21:28 ` [PATCH 0/7] media: cedrus: h265: Implement tiles support Jernej Škrabec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ys72jfI1QdGm+q0g@eze-laptop \
--to=ezequiel@vanguardiasur.com.ar \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=paul.kocialkowski@bootlin.com \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox