[COMMON] fimc-is2: modify "head" base when group is stopped
authorWooyeon Kim <wooy88.kim@samsung.com>
Mon, 15 Apr 2019 10:18:10 +0000 (19:18 +0900)
committerlingsen1 <lingsen1@lenovo.com>
Mon, 10 Jun 2019 03:25:07 +0000 (11:25 +0800)
 - when camera is suddenly closed, wrong refer group caused
   smp trigger stuck problem

 PR JIRA ID: CPR-958

CRs-fixed: (CR)

Change-Id: I311a14c062906d4aab7aa5f9e36fb151ba80107e
Signed-off-by: Wooyeon Kim <wooy88.kim@samsung.com>
Reviewed-on: https://gerrit.mot.com/1337226
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Dawei Wang <wangdw10@motorola.com>
Reviewed-by: Biming Li <libm1@motorola.com>
Reviewed-by: Zhichao Chen <chenzc2@motorola.com>
Submit-Approved: Jira Key

drivers/media/platform/exynos/fimc-is2/fimc-is-groupmgr.c

index 3fe65817bef55a8fd67019a855256ce837efc916..097c3f9b3e8d9574bdb86ff5b42c04e32913e407 100644 (file)
@@ -2215,6 +2215,7 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
        struct fimc_is_framemgr *framemgr;
        struct fimc_is_device_ischain *device;
        struct fimc_is_device_sensor *sensor;
+       struct fimc_is_group *head;
        struct fimc_is_group *child;
        struct fimc_is_subdev *subdev;
        struct fimc_is_group_task *gtask;
@@ -2229,7 +2230,6 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
        device = group->device;
        sensor = device->sensor;
        framemgr = GET_HEAD_GROUP_FRAMEMGR(group);
-       gtask = &groupmgr->gtask[group->id];
        if (!framemgr) {
                mgerr("framemgr is NULL", group, group);
                goto p_err;
@@ -2241,6 +2241,10 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
                return -EPERM;
        }
 
+       FIMC_BUG(!group->head);
+       head = group->head;
+       gtask = &groupmgr->gtask[head->id];
+
        /* force stop set if only HEAD group OTF input */
        if (test_bit(FIMC_IS_GROUP_OTF_INPUT, &group->head->state)) {
                if (test_bit(FIMC_IS_GROUP_REQUEST_FSTOP, &group->state))
@@ -2250,31 +2254,31 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
 
        retry = 150;
        while (--retry && framemgr->queued_count[FS_REQUEST]) {
-               if (test_bit(FIMC_IS_GROUP_OTF_INPUT, &group->state) &&
-                       !list_empty(&group->smp_trigger.wait_list)) {
+               if (test_bit(FIMC_IS_GROUP_OTF_INPUT, &head->state) &&
+                       !list_empty(&head->smp_trigger.wait_list)) {
 
                        if (!sensor) {
-                               mwarn(" sensor is NULL, forcely trigger(pc %d)", device, group->pcount);
-                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &group->state);
-                               up(&group->smp_trigger);
-                       } else if (!test_bit(FIMC_IS_SENSOR_OPEN, &sensor->state)) {
-                               mwarn(" sensor is closed, forcely trigger(pc %d)", device, group->pcount);
-                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &group->state);
-                               up(&group->smp_trigger);
+                               mwarn(" sensor is NULL, forcely trigger(pc %d)", device, head->pcount);
+                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &head->state);
+                               up(&head->smp_trigger);
+                       } else if (!test_bit(FIMC_IS_SENSOR_OPEN, &head->state)) {
+                               mwarn(" sensor is closed, forcely trigger(pc %d)", device, head->pcount);
+                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &head->state);
+                               up(&head->smp_trigger);
                        } else if (!test_bit(FIMC_IS_SENSOR_FRONT_START, &sensor->state)) {
-                               mwarn(" front is stopped, forcely trigger(pc %d)", device, group->pcount);
-                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &group->state);
-                               up(&group->smp_trigger);
+                               mwarn(" front is stopped, forcely trigger(pc %d)", device, head->pcount);
+                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &head->state);
+                               up(&head->smp_trigger);
                        } else if (!test_bit(FIMC_IS_SENSOR_BACK_START, &sensor->state)) {
-                               mwarn(" back is stopped, forcely trigger(pc %d)", device, group->pcount);
-                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &group->state);
-                               up(&group->smp_trigger);
+                               mwarn(" back is stopped, forcely trigger(pc %d)", device, head->pcount);
+                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &head->state);
+                               up(&head->smp_trigger);
                        } else if (retry < 100) {
-                               merr(" sensor is working but no trigger(pc %d)", device, group->pcount);
-                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &group->state);
-                               up(&group->smp_trigger);
+                               merr(" sensor is working but no trigger(pc %d)", device, head->pcount);
+                               set_bit(FIMC_IS_GROUP_FORCE_STOP, &head->state);
+                               up(&head->smp_trigger);
                        } else {
-                               mwarn(" wating for sensor trigger(pc %d)", device, group->pcount);
+                               mwarn(" wating for sensor trigger(pc %d)", device, head->pcount);
                        }
 #ifdef ENABLE_SYNC_REPROCESSING
                } else if (!test_bit(FIMC_IS_GROUP_OTF_INPUT, &group->state)) {
@@ -2288,14 +2292,14 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
 #endif
                }
 
-               mgwarn(" %d reqs waiting...(pc %d) smp_resource(%d)", device, group,
-                               framemgr->queued_count[FS_REQUEST], group->pcount,
+               mgwarn(" %d reqs waiting...(pc %d) smp_resource(%d)", device, head,
+                               framemgr->queued_count[FS_REQUEST], head->pcount,
                                list_empty(&gtask->smp_resource.wait_list));
                msleep(20);
        }
 
        if (!retry) {
-               mgerr(" waiting(until request empty) is fail(pc %d)", device, group, group->pcount);
+               mgerr(" waiting(until request empty) is fail(pc %d)", device, head, head->pcount);
                errcnt++;
        }
 
@@ -2334,22 +2338,22 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
 
        retry = 150;
        while (--retry && framemgr->queued_count[FS_PROCESS]) {
-               mgwarn(" %d pros waiting...(pc %d)", device, group, framemgr->queued_count[FS_PROCESS], group->pcount);
+               mgwarn(" %d pros waiting...(pc %d)", device, head, framemgr->queued_count[FS_PROCESS], head->pcount);
                msleep(20);
        }
 
        if (!retry) {
-               mgerr(" waiting(until process empty) is fail(pc %d)", device, group, group->pcount);
+               mgerr(" waiting(until process empty) is fail(pc %d)", device, head, head->pcount);
                errcnt++;
        }
 
-       rcount = atomic_read(&group->rcount);
+       rcount = atomic_read(&head->rcount);
        if (rcount) {
-               mgerr(" request is NOT empty(%d) (pc %d)", device, group, rcount, group->pcount);
+               mgerr(" request is NOT empty(%d) (pc %d)", device, head, rcount, head->pcount);
                errcnt++;
        }
        /* the count of request should be clear for next streaming */
-       atomic_set(&group->rcount, 0);
+       atomic_set(&head->rcount, 0);
 
        child = group;
        while(child) {
@@ -2396,7 +2400,7 @@ int fimc_is_group_stop(struct fimc_is_groupmgr *groupmgr,
                child = child->child;
        }
 
-       fimc_is_gframe_flush(groupmgr, group);
+       fimc_is_gframe_flush(groupmgr, head);
 
        if (test_bit(FIMC_IS_GROUP_OTF_INPUT, &group->state))
                mginfo(" sensor fcount: %d, fcount: %d\n", device, group,