atomisp: do not do full release if more video pipes are on use
authorYong Wang <yong.y.wang@intel.com>
Wed, 24 Oct 2012 00:42:00 +0000 (08:42 +0800)
committerYong Wang <yong.y.wang@intel.com>
Wed, 24 Oct 2012 00:42:00 +0000 (08:42 +0800)
The bug (TZSP-3288) is more or less easily reproducible on systems with
udev-like software. The helper (v4l_id) is run in parallel for all /dev/videoX
nodes twice with only purpose of checking capabilities:

 ->open("/dev/videoX")
 ->ioctl(VIDIOC_QUERYCAP)
 ->release("/dev/videoX")

The atomisp_open() call does two stages init of the internal structures. In
case of 1st opened node it does full (stage 1 + stage 2) init. Otherwise it is
a fast path (stage 1 only).

However, atomisp_release() does a fast path for non-main pipes as well. This
triggers the unbalanced power management calls:

 ->open
   -> stage 1
     -> stage 2
       -> pm_runtime_get_sync
 ->release
   -> stage 1
     -> is_main? -> (no) -> fast path

The patch is a rough approach to fix this. Any better solution is welcome.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Yong Wang <yong.y.wang@intel.com>
drivers/media/video/atomisp/atomisp_fops.c

index c6f3ab5..6269828 100644 (file)
@@ -446,7 +446,9 @@ static int atomisp_release(struct file *file)
                isp->input_format = NULL;
        }
 
-       if (!pipe->is_main)
+       if ((isp->isp_subdev.video_out_vf.opened ? 1 : 0) +
+           (isp->isp_subdev.video_out_mo.opened ? 1 : 0) +
+           (isp->isp_subdev.video_in.opened ? 1 : 0) > 1)
                goto done;
 
        if (isp->sw_contex.init == false)