linux/drivers/media/platform/vsp1
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
..
Makefile media: v4l: vsp1: Add support for the DISCOM entity 2018-05-17 06:22:08 -04:00
vsp1_brx.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_brx.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_clu.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_clu.h media: vsp1: Convert display lists to use new body pool 2018-05-25 18:42:46 -04:00
vsp1_dl.c media: vsp1: Move video configuration to a cached dlb 2018-05-25 19:05:46 -04:00
vsp1_dl.h media: vsp1: Move video configuration to a cached dlb 2018-05-25 19:05:46 -04:00
vsp1_drm.c media: v4l: vsp1: Fix deadlock in VSPDL DRM pipelines 2018-07-30 08:22:59 -04:00
vsp1_drm.h media: v4l: vsp1: Integrate DISCOM in display pipeline 2018-05-17 06:22:08 -04:00
vsp1_drv.c media: vsp1: Move video suspend resume handling to video object 2018-05-25 18:37:32 -04:00
vsp1_entity.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
vsp1_entity.h media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_hgo.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_hgo.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_hgt.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_hgt.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_histo.c media: v4l: vsp1: Reset the crop and compose rectangles in the set_fmt helper 2018-05-17 06:22:08 -04:00
vsp1_histo.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_hsit.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_hsit.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_lif.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_lif.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_lut.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_lut.h media: vsp1: Convert display lists to use new body pool 2018-05-25 18:42:46 -04:00
vsp1_pipe.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_pipe.h media: vsp1: Move video configuration to a cached dlb 2018-05-25 19:05:46 -04:00
vsp1_regs.h media: v4l: vsp1: Add support for the DISCOM entity 2018-05-17 06:22:08 -04:00
vsp1_rpf.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_rwpf.c media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_rwpf.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_sru.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_sru.h media: v4l: vsp1: Use SPDX license headers 2018-05-17 06:22:08 -04:00
vsp1_uds.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_uds.h media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_uif.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1_uif.h media: v4l: vsp1: Add support for the DISCOM entity 2018-05-17 06:22:08 -04:00
vsp1_video.c media: vsp1: Move video configuration to a cached dlb 2018-05-25 19:05:46 -04:00
vsp1_video.h media: vsp1: Move video suspend resume handling to video object 2018-05-25 18:37:32 -04:00
vsp1_wpf.c media: vsp1: Adapt entities to configure into a body 2018-05-25 19:04:35 -04:00
vsp1.h media: v4l: vsp1: Add support for the DISCOM entity 2018-05-17 06:22:08 -04:00