[COMMON] fimc-is2: Flush the old H/W frames for shot done sequence
authorSanghoon Lee <shoon114.lee@samsung.com>
Fri, 1 Jun 2018 07:21:44 +0000 (16:21 +0900)
committerEunyoung Lee <ey470.lee@samsung.com>
Tue, 19 Jun 2018 08:43:41 +0000 (17:43 +0900)
If there are the old frames in H/W frame manager,
the matched frames in subdev frame manager will be flushed to user as NDONE.
When user gets the shot data of these frames, every kernel virtual address for the frames is unmapped.
To avoid accessing invalid kernel virtual address in H/W frames,
they should also be flushed in shot done sequence.

Change-Id: I2e1262cac42a31fd7c3567885e0afbc82790ab83
Signed-off-by: Sanghoon Lee <shoon114.lee@samsung.com>
drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.c

index 977179fb083b6175cafe9fb1076d86a3da2f9354..c2854b31fcaf02401ad96518e135a4e476ecd626 100644 (file)
@@ -2367,6 +2367,23 @@ exit:
        trans_frame(framemgr, frame, FS_HW_FREE);
        framemgr_x_barrier_common(framemgr, 0, flags);
        atomic_set(&frame->shot_done_flag, 0);
+
+       /* Force flush the old H/W frames with DONE state */
+       framemgr_e_barrier_common(framemgr, 0, flags);
+       if (framemgr->queued_count[FS_HW_WAIT_DONE] > 0) {
+               u32 fcount = frame->fcount;
+
+               frame = peek_frame(framemgr, FS_HW_WAIT_DONE);
+               while (frame && frame->fcount < fcount) {
+                       msinfo_hw("[F%d]force flush\n",
+                                       frame->instance, hw_ip, frame->fcount);
+                       trans_frame(framemgr, frame, FS_HW_FREE);
+                       atomic_set(&frame->shot_done_flag, 0);
+                       frame = peek_frame(framemgr, FS_HW_WAIT_DONE);
+               }
+       }
+       framemgr_x_barrier_common(framemgr, 0, flags);
+
        if (framemgr->queued_count[FS_HW_FREE] > 10)
                atomic_set(&hw_ip->hardware->bug_count, 0);