]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/bridge: ti-sn65dsi83: protect device resources on unplug
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 12 Nov 2025 16:34:35 +0000 (17:34 +0100)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Thu, 11 Dec 2025 10:28:43 +0000 (11:28 +0100)
commitd2e8d1bc840b849fc23d8812995645cc79990e7b
treecafad840066bba0099db3c1e3de7e617c633ff20
parentd36137085a4aa2d2f039359a0d67d9e07667f2de
drm/bridge: ti-sn65dsi83: protect device resources on unplug

To support hot-unplug of this bridge we need to protect access to device
resources in case sn65dsi83_remove() happens concurrently to other code.

Some care is needed for the case when the unplug happens before
sn65dsi83_atomic_disable() has a chance to enter the critical section
(i.e. a successful drm_bridge_enter() call), which occurs whenever the
hardware is removed while the display is active. When that happens,
sn65dsi83_atomic_disable() in unable to release the resources taken by
sn65dsi83_atomic_pre_enable().

To ensure those resources are released exactly once on device removal:

 * move the code to release them to a dedicated function
 * register that function when the resources are taken in
   sn65dsi83_atomic_pre_enable()
 * if sn65dsi83_atomic_disable() happens before sn65dsi83_remove()
   (typical non-hot-unplug case):
   * sn65dsi83_atomic_disable() can enter the critical section
     (drm_bridge_enter() returns 0) -> it releases and executes the
     devres action
 * if sn65dsi83_atomic_disable() happens after sn65dsi83_remove()
   (typical hot-unplug case):
   * sn65dsi83_remove() -> drm_bridge_unplug() prevents
     sn65dsi83_atomic_disable() from entering the critical section
     (drm_bridge_enter() returns nonzero), so sn65dsi83_atomic_disable()
     cannot release and execute the devres action
   * the devres action is executed at the end of sn65dsi83_remove()

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patch.msgid.link/20251112-drm-bridge-atomic-vs-remove-v3-2-85db717ce094@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/bridge/ti-sn65dsi83.c