Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] exynos-gsc: Handle ctx job finish when aborted

When the current context is running,
1] If release() or streamoff() is called on the current context,
it waits until the job is aborted or finished.
2] If the job is finished, driver will call the v4l2_m2m_job_finish().
3] If the job is aborted inside device_run callback, then driver
has to inform the v4l2 mem2mem framework about the same by calling
v4l2_m2m_job_finish() with VB2_BUF_STATE_ERROR.

The current code doesn't call v4l2_m2m_job_finish() in the case, where
the job is aborted from the device_run callback. This scenerio is
producing a hang as the other queued contexts are not getting scheduled.

By adding the ABORT state, driver can understand the current job
is aborted and not finished. By checking this flag, driver can call
v4l2_m2m_job_finish() with VB2_BUF_STATE_ERROR.

Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com>
Signed-off-by: Avnd Kiran <avnd.kiran@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Shaik Ameer Basha and committed by
Mauro Carvalho Chehab
d9315160 84e68098

+17 -13
+1
drivers/media/platform/exynos-gsc/gsc-core.h
··· 45 45 #define GSC_DST_FMT (1 << 2) 46 46 #define GSC_CTX_M2M (1 << 3) 47 47 #define GSC_CTX_STOP_REQ (1 << 6) 48 + #define GSC_CTX_ABORT (1 << 7) 48 49 49 50 enum gsc_dev_flags { 50 51 /* for global */
+16 -13
drivers/media/platform/exynos-gsc/gsc-m2m.c
··· 46 46 return ret == 0 ? -ETIMEDOUT : ret; 47 47 } 48 48 49 + static void __gsc_m2m_job_abort(struct gsc_ctx *ctx) 50 + { 51 + int ret; 52 + 53 + ret = gsc_m2m_ctx_stop_req(ctx); 54 + if ((ret == -ETIMEDOUT) || (ctx->state & GSC_CTX_ABORT)) { 55 + gsc_ctx_state_lock_clear(GSC_CTX_STOP_REQ | GSC_CTX_ABORT, ctx); 56 + gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); 57 + } 58 + } 59 + 49 60 static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count) 50 61 { 51 62 struct gsc_ctx *ctx = q->drv_priv; ··· 69 58 static int gsc_m2m_stop_streaming(struct vb2_queue *q) 70 59 { 71 60 struct gsc_ctx *ctx = q->drv_priv; 72 - int ret; 73 61 74 - ret = gsc_m2m_ctx_stop_req(ctx); 75 - if (ret == -ETIMEDOUT) 76 - gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); 62 + __gsc_m2m_job_abort(ctx); 77 63 78 64 pm_runtime_put(&ctx->gsc_dev->pdev->dev); 79 65 ··· 99 91 } 100 92 } 101 93 102 - 103 94 static void gsc_m2m_job_abort(void *priv) 104 95 { 105 - struct gsc_ctx *ctx = priv; 106 - int ret; 107 - 108 - ret = gsc_m2m_ctx_stop_req(ctx); 109 - if (ret == -ETIMEDOUT) 110 - gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); 96 + __gsc_m2m_job_abort((struct gsc_ctx *)priv); 111 97 } 112 98 113 99 static int gsc_get_bufs(struct gsc_ctx *ctx) ··· 152 150 gsc->m2m.ctx = ctx; 153 151 } 154 152 155 - is_set = (ctx->state & GSC_CTX_STOP_REQ) ? 1 : 0; 156 - ctx->state &= ~GSC_CTX_STOP_REQ; 153 + is_set = ctx->state & GSC_CTX_STOP_REQ; 157 154 if (is_set) { 155 + ctx->state &= ~GSC_CTX_STOP_REQ; 156 + ctx->state |= GSC_CTX_ABORT; 158 157 wake_up(&gsc->irq_queue); 159 158 goto put_device; 160 159 }