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)
commit1057c64d5a4e547cae53e5c466a1d18ea75368bc
tree7e3653e25855f82c1175196c0e5945e135f91d6a
parent7551753298dda533d78b95e5cb8b27d1fccef017
atomisp: do not do full release if more video pipes are on use

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