All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: linux-media@vger.kernel.org, Maxime Ripard <mripard@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	kernel@collabora.com, 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: [PATCH v1 1/3] media: cedrus: Fix watchdog race condition
Date: Mon, 22 Aug 2022 10:04:09 +0200	[thread overview]
Message-ID: <YwM4efK9V4t38RFe@aptenodytes> (raw)
In-Reply-To: <20220818203308.439043-2-nicolas.dufresne@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 1911 bytes --]

Hi Nicolas,

On Thu 18 Aug 22, 16:33, Nicolas Dufresne wrote:
> 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.

Good catch, thanks!

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Cheers,

Paul

> Cc: stable@vger.kernel.org
> Fixes: 7c38a551bda1 ("media: cedrus: Add watchdog for job completion")
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
>  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
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: linux-media@vger.kernel.org, Maxime Ripard <mripard@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	kernel@collabora.com, 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: [PATCH v1 1/3] media: cedrus: Fix watchdog race condition
Date: Mon, 22 Aug 2022 10:04:09 +0200	[thread overview]
Message-ID: <YwM4efK9V4t38RFe@aptenodytes> (raw)
In-Reply-To: <20220818203308.439043-2-nicolas.dufresne@collabora.com>


[-- Attachment #1.1: Type: text/plain, Size: 1911 bytes --]

Hi Nicolas,

On Thu 18 Aug 22, 16:33, Nicolas Dufresne wrote:
> 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.

Good catch, thanks!

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Cheers,

Paul

> Cc: stable@vger.kernel.org
> Fixes: 7c38a551bda1 ("media: cedrus: Add watchdog for job completion")
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
>  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
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-08-22  8:04 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 20:33 [PATCH v1 0/3] cedrus: Various bug fixes Nicolas Dufresne
2022-08-18 20:33 ` [PATCH v1 1/3] media: cedrus: Fix watchdog race condition Nicolas Dufresne
2022-08-18 20:33   ` Nicolas Dufresne
2022-08-22  8:04   ` Paul Kocialkowski [this message]
2022-08-22  8:04     ` Paul Kocialkowski
2022-08-25 21:02   ` Jernej Škrabec
2022-08-25 21:02     ` Jernej Škrabec
2022-08-18 20:33 ` [PATCH v1 2/3] media: cedrus: Set the platform driver data earlier Nicolas Dufresne
2022-08-18 20:33   ` Nicolas Dufresne
2022-08-19  4:17   ` Jernej Škrabec
2022-08-19  4:17     ` Jernej Škrabec
2022-08-19 15:37     ` Nicolas Dufresne
2022-08-19 15:37       ` Nicolas Dufresne
2022-08-20  8:25       ` Jernej Škrabec
2022-08-20  8:25         ` Jernej Škrabec
2022-08-21 20:40         ` Dmitry Osipenko
2022-08-21 20:40           ` Dmitry Osipenko
2022-08-25 21:04           ` Jernej Škrabec
2022-08-25 21:04             ` Jernej Škrabec
2022-08-23  3:57         ` Samuel Holland
2022-08-23  3:57           ` Samuel Holland
2022-08-23 12:22           ` Paul Kocialkowski
2022-08-23 12:22             ` Paul Kocialkowski
2022-08-18 20:33 ` [PATCH v1 3/3] media: cedrus: Fix endless loop in cedrus_h265_skip_bits() Nicolas Dufresne
2022-08-18 20:33   ` Nicolas Dufresne
2022-08-18 20:39   ` Dmitry Osipenko
2022-08-18 20:39     ` Dmitry Osipenko
2022-08-18 21:17     ` Nicolas Dufresne
2022-08-18 21:17       ` Nicolas Dufresne
2022-08-19  4:16   ` Jernej Škrabec
2022-08-19  4:16     ` Jernej Škrabec
2022-08-19 15:39     ` Nicolas Dufresne
2022-08-19 15:39       ` Nicolas Dufresne
2022-08-25 21:13       ` Jernej Škrabec
2022-08-25 21:13         ` 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=YwM4efK9V4t38RFe@aptenodytes \
    --to=paul.kocialkowski@bootlin.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=kernel@collabora.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=nicolas.dufresne@collabora.com \
    --cc=samuel@sholland.org \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.