msm: vidc: flush dynamic output buffers in reconfig

In dynamic buffer mode, if driver receives a
flush during reconfig, it should release all
buffers held in the kernel and not queued to
firmware. Without this change, the buffers held in
the kernel do not get flushed and video client
hangs waiting for release of output buffer.

Change-Id: I39bc31bda755947dec0db8a55583da8ad5b21678
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
(cherry picked from commit bfad056e62cdc78901a2c16136f52d998cd57fae)
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 780f2c4..b6d2f6d 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -2670,6 +2670,7 @@
 	}
 
 	mutex_lock(&inst->sync_lock);
+	msm_comm_flush_dynamic_buffers(inst);
 	if (inst->in_reconfig && !ip_flush && op_flush) {
 		if (!list_empty(&inst->pendingq)) {
 			/*Execution can never reach here since port reconfig
@@ -2702,8 +2703,6 @@
 			}
 		}
 
-		msm_comm_flush_dynamic_buffers(inst);
-
 		/*Do not send flush in case of session_error */
 		if (!(inst->state == MSM_VIDC_CORE_INVALID &&
 			  core->state != VIDC_CORE_INVALID))