Message ID | a96fe39d-9b0e-a644-fc5c-e4945b8a0609@xs4all.nl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | v4l2-dev: call vb2_queue_release in video_unregister_device() | expand |
Hi Hans,
I love your patch! Yet something to improve:
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.8-rc4 next-20200708]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Hans-Verkuil/v4l2-dev-call-vb2_queue_release-in-video_unregister_device/20200709-015251
base: git://linuxtv.org/media_tree.git master
config: arm64-randconfig-r004-20200708 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "vb2_queue_release" [drivers/media/v4l2-core/videodev.ko] undefined!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index a593ea0598b5..ebe1a1647816 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -28,6 +28,7 @@ #include <media/v4l2-common.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> +#include <media/videobuf2-v4l2.h> #define VIDEO_NUM_DEVICES 256 #define VIDEO_NAME "video4linux" @@ -1086,6 +1087,17 @@ void video_unregister_device(struct video_device *vdev) */ clear_bit(V4L2_FL_REGISTERED, &vdev->flags); mutex_unlock(&videodev_lock); + if (vdev->queue && vdev->queue->owner) { + struct mutex *lock = vdev->queue->lock ? + vdev->queue->lock : vdev->lock; + + if (lock) + mutex_lock(lock); + vb2_queue_release(vdev->queue); + vdev->queue->owner = NULL; + if (lock) + mutex_unlock(lock); + } device_unregister(&vdev->dev); } EXPORT_SYMBOL(video_unregister_device);
When a video device is unregistered the video device node may still be open (this is the case if the driver is unbound). Normally vb2_queue_release() is called from vb2_fop_release() which in turn is called when the filehandle that 'owns' the queue is closed. But that might happen quite a long time afterwards when sensor drivers etc. have already been unbound as well. This causes problems in the more complex drivers, but it makes sense to just release the queue when the device is unregistered instead of waiting for the filehandle to be closed. Drivers that do not use vb2_fop_release() will still have to do this manually when they call video_unregister_device() if necessary. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> ---