From bd4e0a5116838f240618b19a07bdfa8ac7a6fc79 Mon Sep 17 00:00:00 2001 From: Surajit Podder Date: Sat, 28 Jan 2017 02:26:44 +0530 Subject: msm: vidc: Return buffers from driver on streamon failure Return queued buffers from driver on streamon failure as vb2 expects driver to return all buffers queued before streamon. Change-Id: Id8280d513f9f6233976a5d07af83f386dfd9f5cd Signed-off-by: Surajit Podder --- drivers/media/platform/msm/vidc/msm_vdec.c | 16 +++++++++++++++- drivers/media/platform/msm/vidc/msm_venc.c | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/msm/vidc/msm_vdec.c b/drivers/media/platform/msm/vidc/msm_vdec.c index f958cf13f1e3..a20252f08f44 100644 --- a/drivers/media/platform/msm/vidc/msm_vdec.c +++ b/drivers/media/platform/msm/vidc/msm_vdec.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1782,6 +1782,7 @@ static int msm_vdec_start_streaming(struct vb2_queue *q, unsigned int count) struct msm_vidc_inst *inst; int rc = 0; struct hfi_device *hdev; + struct vb2_buf_entry *temp, *next; if (!q || !q->drv_priv) { dprintk(VIDC_ERR, "Invalid input, q = %pK\n", q); return -EINVAL; @@ -1824,6 +1825,19 @@ static int msm_vdec_start_streaming(struct vb2_queue *q, unsigned int count) } stream_start_failed: + if (rc) { + mutex_lock(&inst->pendingq.lock); + list_for_each_entry_safe(temp, next, &inst->pendingq.list, + list) { + if (temp->vb->type == q->type) { + vb2_buffer_done(temp->vb, + VB2_BUF_STATE_QUEUED); + list_del(&temp->list); + kfree(temp); + } + } + mutex_unlock(&inst->pendingq.lock); + } return rc; } diff --git a/drivers/media/platform/msm/vidc/msm_venc.c b/drivers/media/platform/msm/vidc/msm_venc.c index 6127c03df581..d02d975b8e15 100644 --- a/drivers/media/platform/msm/vidc/msm_venc.c +++ b/drivers/media/platform/msm/vidc/msm_venc.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1758,6 +1758,7 @@ static int msm_venc_start_streaming(struct vb2_queue *q, unsigned int count) { struct msm_vidc_inst *inst; int rc = 0; + struct vb2_buf_entry *temp, *next; if (!q || !q->drv_priv) { dprintk(VIDC_ERR, "Invalid input, q = %pK\n", q); return -EINVAL; @@ -1795,6 +1796,19 @@ static int msm_venc_start_streaming(struct vb2_queue *q, unsigned int count) } stream_start_failed: + if (rc) { + mutex_lock(&inst->pendingq.lock); + list_for_each_entry_safe(temp, next, &inst->pendingq.list, + list) { + if (temp->vb->type == q->type) { + vb2_buffer_done(temp->vb, + VB2_BUF_STATE_QUEUED); + list_del(&temp->list); + kfree(temp); + } + } + mutex_unlock(&inst->pendingq.lock); + } return rc; } -- cgit v1.2.3