Skip to content

Commit

Permalink
media: cedrus: Fix watchdog race condition
Browse files Browse the repository at this point in the history
commit fe8b81f 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: 7c38a55 ("media: cedrus: Add watchdog for job completion")
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
ndufresne authored and gregkh committed Oct 21, 2022
1 parent 107a47e commit 0b88c0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/staging/media/sunxi/cedrus/cedrus_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b88c0e

Please sign in to comment.