linux_dsm_epyc7002/drivers/media
Kosuke Tatsukawa 5063452ecb [media] media: fix waitqueue_active without memory barrier in cpia2 driver
cpia2_usb_disconnect() seems to be missing a memory barrier which might
cause the waker to not notice the waiter and miss sending a wake_up as
in the following figure.

	cpia2_usb_disconnect			sync
------------------------------------------------------------------------
					mutex_unlock(&cam->v4l2_lock);
if (waitqueue_active(&cam->wq_stream))
/* The CPU might reorder the test for
   the waitqueue up here, before
   prior writes complete */
					/* wait_event_interruptible */
					 /* __wait_event_interruptible */
					  /* ___wait_event */
					  long __int = prepare_to_wait_event(
					    &wq, &__wait, state);
					  if (!cam->streaming ||
					    frame->status == FRAME_READY)
cam->curbuff->status = FRAME_READY;
cam->curbuff->length = 0;
					  schedule()
------------------------------------------------------------------------

The attached patch removes the call to waitqueue_active() leaving just
wake_up() behind.  This fixes the problem because the call to
spin_lock_irqsave() in wake_up() will be an ACQUIRE operation.

I found this issue when I was looking through the linux source code
for places calling waitqueue_active() before wake_up*(), but without
preceding memory barriers, after sending a patch to fix a similar
issue in drivers/tty/n_tty.c  (Details about the original issue can be
found here: https://lkml.org/lkml/2015/9/28/849).

Signed-off-by: Kosuke Tatsukawa <tatsu@ab.jp.nec.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-17 14:55:06 -02:00
..
common [media] include/media: move driver interface headers to a separate dir 2015-11-17 06:57:29 -02:00
dvb-core [media] dvb_frontend.h: improve documentation for struct dvb_tuner_ops 2015-11-17 06:46:42 -02:00
dvb-frontends [media] stb6100: get rid of get_state()/set_state() 2015-11-17 06:45:05 -02:00
firewire [media] dvb: Get rid of typedev usage for enums 2015-06-09 17:47:35 -03:00
i2c [media] adv7511: fix incorrect bit offset 2015-11-17 14:39:54 -02:00
mmc [media] siano: register media controller earlier 2015-02-26 09:10:39 -03:00
pci [media] av7110: potential divide by zero 2015-11-17 14:38:18 -02:00
platform [media] media/core: Replace ctrl_class with which 2015-11-17 14:44:03 -02:00
radio [media] radio-shark2: constify radio_tea5777_ops structures 2015-11-17 14:52:15 -02:00
rc [media] include/media: move platform_data to linux/platform_data/media 2015-11-17 06:58:42 -02:00
tuners [media] dvb_frontend: get rid of set_state ops & related data 2015-11-17 06:46:02 -02:00
usb [media] media: fix waitqueue_active without memory barrier in cpia2 driver 2015-11-17 14:55:06 -02:00
v4l2-core [media] media: videobuf2: fix compare_const_fl.cocci warnings 2015-11-17 14:48:48 -02:00
Kconfig media updates for v4.2-rc1 2015-06-25 17:55:48 -07:00
Makefile [media] bq/c-qcam, w9966, pms: move to staging in preparation for removal 2014-12-16 23:21:44 -02:00
media-device.c [media] media: Use strlcpy instead of custom code 2014-09-21 20:27:08 -03:00
media-devnode.c [media] media-devnode: just return 0 instead of using a var 2014-09-03 17:59:28 -03:00
media-entity.c [media] media-entity.c: get rid of var length arrays 2015-10-01 18:10:05 -03:00