video: rockchip: vcodec: fix reboot crash when playing
authorJung Zhao <jung.zhao@rock-chips.com>
Tue, 10 Jan 2017 06:53:40 +0000 (14:53 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 19 Jan 2017 03:15:50 +0000 (11:15 +0800)
shutdown function need wait last irq finish and then continue
its work.

Change-Id: I12bed04f6eeac1f12eedf55a09699be49fb4ac35
Signed-off-by: Jung Zhao <jung.zhao@rock-chips.com>
drivers/video/rockchip/vcodec/vcodec_service.c

index 69e04b8..8426bd9 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/uaccess.h>
 #include <linux/debugfs.h>
 #include <linux/pm_runtime.h>
+#include <linux/iopoll.h>
 
 #include <linux/rockchip/cru.h>
 #include <linux/rockchip/pmu.h>
@@ -2636,6 +2637,8 @@ static void vcodec_shutdown(struct platform_device *pdev)
 {
        struct vpu_subdev_data *data = platform_get_drvdata(pdev);
        struct vpu_service_info *pservice = data->pservice;
+       int val;
+       int ret;
 
        dev_info(&pdev->dev, "vcodec shutdown");
 
@@ -2643,6 +2646,12 @@ static void vcodec_shutdown(struct platform_device *pdev)
        atomic_set(&pservice->service_on, 0);
        mutex_unlock(&pservice->shutdown_lock);
 
+       ret = readx_poll_timeout(atomic_read,
+                                &pservice->total_running,
+                                val, val == 0, 20000, 200000);
+       if (ret == -ETIMEDOUT)
+               dev_err(&pdev->dev, "wait total running time out\n");
+
        vcodec_exit_mode(data);
 
        vpu_service_power_on(data, pservice);