linux-stable/drivers/gpu/drm/vc4
Maíra Canal 479d4f0be4
drm/vc4: drop all currently held locks if deadlock happens
If vc4_hdmi_reset_link() returns -EDEADLK, it means that a deadlock
happened in the locking context. This situation should be addressed by
dropping all currently held locks and block until the contended lock
becomes available. Currently, vc4 is not dealing with the deadlock
properly, producing the following output when PROVE_LOCKING is enabled:

[  825.612809] ------------[ cut here ]------------
[  825.612852] WARNING: CPU: 1 PID: 116 at drivers/gpu/drm/drm_modeset_lock.c:276 drm_modeset_drop_locks+0x60/0x68 [drm]
[  825.613458] Modules linked in: 8021q mrp garp stp llc
raspberrypi_cpufreq brcmfmac brcmutil crct10dif_ce hci_uart cfg80211
btqca btbcm bluetooth vc4 raspberrypi_hwmon snd_soc_hdmi_codec cec
clk_raspberrypi ecdh_generic drm_display_helper ecc rfkill
drm_dma_helper drm_kms_helper pwm_bcm2835 bcm2835_thermal bcm2835_rng
rng_core i2c_bcm2835 drm fuse ip_tables x_tables ipv6
[  825.613735] CPU: 1 PID: 116 Comm: kworker/1:2 Tainted: G        W 6.1.0-rc6-01399-g941aae326315 #3
[  825.613759] Hardware name: Raspberry Pi 3 Model B Rev 1.2 (DT)
[  825.613777] Workqueue: events output_poll_execute [drm_kms_helper]
[  825.614038] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  825.614063] pc : drm_modeset_drop_locks+0x60/0x68 [drm]
[  825.614603] lr : drm_helper_probe_detect+0x120/0x1b4 [drm_kms_helper]
[  825.614829] sp : ffff800008313bf0
[  825.614844] x29: ffff800008313bf0 x28: ffffcd7778b8b000 x27: 0000000000000000
[  825.614883] x26: 0000000000000001 x25: 0000000000000001 x24: ffff677cc35c2758
[  825.614920] x23: ffffcd7707d01430 x22: ffffcd7707c3edc7 x21: 0000000000000001
[  825.614958] x20: 0000000000000000 x19: ffff800008313c10 x18: 000000000000b6d3
[  825.614995] x17: ffffcd777835e214 x16: ffffcd7777cef870 x15: fffff81000000000
[  825.615033] x14: 0000000000000000 x13: 0000000000000099 x12: 0000000000000002
[  825.615070] x11: 72917988020af800 x10: 72917988020af800 x9 : 72917988020af800
[  825.615108] x8 : ffff677cc665e0a8 x7 : d00a8c180000110c x6 : ffffcd77774c0054
[  825.615145] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000
[  825.615181] x2 : ffff677cc55e1880 x1 : ffffcd7777cef8ec x0 : ffff800008313c10
[  825.615219] Call trace:
[  825.615232]  drm_modeset_drop_locks+0x60/0x68 [drm]
[  825.615773]  drm_helper_probe_detect+0x120/0x1b4 [drm_kms_helper]
[  825.616003]  output_poll_execute+0xe4/0x224 [drm_kms_helper]
[  825.616233]  process_one_work+0x2b4/0x618
[  825.616264]  worker_thread+0x24c/0x464
[  825.616288]  kthread+0xec/0x110
[  825.616310]  ret_from_fork+0x10/0x20
[  825.616335] irq event stamp: 7634
[  825.616349] hardirqs last  enabled at (7633): [<ffffcd777831ee90>] _raw_spin_unlock_irq+0x3c/0x78
[  825.616384] hardirqs last disabled at (7634): [<ffffcd7778315a78>] __schedule+0x134/0x9f0
[  825.616411] softirqs last  enabled at (7630): [<ffffcd7707aacea0>] local_bh_enable+0x4/0x30 [ipv6]
[  825.617019] softirqs last disabled at (7618): [<ffffcd7707aace70>] local_bh_disable+0x4/0x30 [ipv6]
[  825.617586] ---[ end trace 0000000000000000 ]---

Therefore, deal with the deadlock as suggested by [1], using the
function drm_modeset_backoff().

[1] https://docs.kernel.org/gpu/drm-kms.html?highlight=kms#kms-locking

Fixes: 6bed2ea3cb ("drm/vc4: hdmi: Reset link on hotplug")
Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20221229194638.178712-1-mcanal@igalia.com
2023-01-02 11:38:28 +01:00
..
tests drm/vc4: tests: Add unit test suite for the PV muxing 2022-12-08 09:56:56 +01:00
Kconfig drm/vc4: tests: Introduce a mocking infrastructure 2022-12-08 09:56:56 +01:00
Makefile drm/vc4: tests: Add unit test suite for the PV muxing 2022-12-08 09:56:56 +01:00
vc4_bo.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_crtc.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_debugfs.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_dpi.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_drv.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_drv.h drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_dsi.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_fence.c
vc4_gem.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
vc4_hdmi.c drm/vc4: drop all currently held locks if deadlock happens 2023-01-02 11:38:28 +01:00
vc4_hdmi.h Linux 6.1-rc6 2022-11-24 11:05:43 +10:00
vc4_hdmi_phy.c
vc4_hdmi_regs.h drm/vc4: tests: Fail the current test if we access a register 2022-12-08 09:56:56 +01:00
vc4_hvs.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_irq.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
vc4_kms.c drm/vc4: Move HVS state to main header 2022-12-08 09:56:56 +01:00
vc4_packet.h
vc4_perfmon.c drm/vc4: perfmon: Add missing mutex_destroy 2022-07-13 10:46:13 +02:00
vc4_plane.c drm/vc4: plane: protect device resources after removal 2022-08-25 09:44:25 +02:00
vc4_qpu_defines.h
vc4_regs.h drm/vc4: drop unexpected word "the" in the comments 2022-06-22 09:22:55 +02:00
vc4_render_cl.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
vc4_trace.h
vc4_trace_points.c
vc4_txp.c drm/vc4: tests: Fail the current test if we access a register 2022-12-08 09:56:56 +01:00
vc4_v3d.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00
vc4_validate.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
vc4_validate_shaders.c drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
vc4_vec.c drm/vc4: use new debugfs device-centered functions 2022-12-22 14:59:16 -03:00