linux/drivers/media
Laurent Pinchart 8eb0e64219 media: v4l: vsp1: Fix deadlock in VSPDL DRM pipelines
The VSP uses a lock to protect the BRU and BRS assignment when
configuring pipelines. The lock is taken in vsp1_du_atomic_begin() and
released in vsp1_du_atomic_flush(), as well as taken and released in
vsp1_du_setup_lif(). This guards against multiple pipelines trying to
assign the same BRU and BRS at the same time.

The DRM framework calls the .atomic_begin() operations in a loop over
all CRTCs included in an atomic commit. On a VSPDL (the only VSP type
where this matters), a single VSP instance handles two CRTCs, with a
single lock. This results in a deadlock when the .atomic_begin()
operation is called on the second CRTC.

The DRM framework serializes atomic commits that affect the same CRTCs,
but doesn't know about two CRTCs sharing the same VSPDL. Two commits
affecting the VSPDL LIF0 and LIF1 respectively can thus race each other,
hence the need for a lock.

This could be fixed on the DRM side by forcing serialization of commits
affecting CRTCs backed by the same VSPDL, but that would negatively
affect performances, as the locking is only needed when the BRU and BRS
need to be reassigned, which is an uncommon case.

The lock protects the whole .atomic_begin() to .atomic_flush() sequence.
The only operation that can occur in-between is vsp1_du_atomic_update(),
which doesn't touch the BRU and BRS, and thus doesn't need to be
protected by the lock. We can thus only take the lock around the
pipeline setup calls in vsp1_du_atomic_flush(), which fixes the
deadlock.

Fixes: f81f9adc4e ("media: v4l: vsp1: Assign BRU and BRS to pipelines dynamically")

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-30 08:22:59 -04:00
..
cec media: cec: fix wrong tx/rx_status values when canceling a msg 2018-05-28 16:25:25 -04:00
common treewide: Use array_size() in vzalloc() 2018-06-12 16:19:22 -07:00
dvb-core docs: Fix some broken references 2018-06-15 18:10:01 -03:00
dvb-frontends media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
firewire vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
i2c media: max2175: fix location of driver's companion documentation 2018-06-15 18:10:41 -03:00
mmc media: siano: use GFP_DMA only for smssdio 2018-05-15 08:04:42 -04:00
pci media: v4l: fix broken video4linux docs locations 2018-06-15 18:10:01 -03:00
platform media: v4l: vsp1: Fix deadlock in VSPDL DRM pipelines 2018-07-30 08:22:59 -04:00
radio media: v4l: fix broken video4linux docs locations 2018-06-15 18:10:01 -03:00
rc media: rc: read out of bounds if bpf reports high protocol number 2018-07-30 08:19:53 -04:00
spi media: cxd2880-spi: Modified how to declare structure 2018-05-05 10:37:12 -04:00
tuners Linux 4.17-rc4 2018-05-10 07:19:23 -04:00
usb media: v4l: fix broken video4linux docs locations 2018-06-15 18:10:01 -03:00
v4l2-core treewide: Use array_size() in vzalloc() 2018-06-12 16:19:22 -07:00
Kconfig media: cec: Kconfig coding style issue 2018-05-09 16:26:50 -04:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
media-device.c media: media-device: fix ioctl function types 2018-05-09 16:33:46 -04:00
media-devnode.c MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00
media-entity.c media: media.h: reorganize header to make it easier to understand 2018-02-26 10:14:46 -05:00