Skip to content

RFC drm bridge hotplug

Luca Ceresoli dri-devel imx linux-arm-kernel lkml 3 versions – New

Get series with b4
b4 am [email protected] change-id 20260515-drm-bridge-hotplug-46265d3a2f85

Versions newest first

  1. v3 RFC Latest31 patches 0 repliesNew
  2. v2 RFC24 patches 0 repliesSuperseded
  3. v137 patches 54 repliesSuperseded

Changes in v3 from the cover letter

- Handle use cases where the first bridge after the encoder is hotpluggable
(in v1 and v2 the first bridge was required to be always present)
as well as all cases where the first bridge is a DSI host
- Removed "samsung-dsim: move drm_bridge_add() call to probe", not
needed anymore
- Handle hot-pluggable bridges supporting HPD, add TI SN65DSI86 DSI-to-DP
- Fully implement dynamic connector in drm_bridge_connector (CEC helpers
were missing in v2)
- Fixed shutdown to not shutdown the whole card
- as a consequence, removed (not needed anymore)
"drm/atomic: move [...] from drm_atomic_helper to drm_atomic"
- Many smaller fixes and improvements
- Link to v2: https://patch.msgid.link/[email protected]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/31drm/display: hdmi-cec-helper: use drmm_ prefix for drmm actiondrivers/gpu/drm/display/drm_hdmi_cec_helper.c+2 -20 replies
2/31drm/display: hdmi-cec-helper: add non-drmm API variantdrivers/gpu/drm/display/drm_hdmi_cec_helper.c include/drm/display/drm_hdmi_cec_helper.h+47 -190 replies
3/31drm/display: hdmi-cec-notifier-helper: use drmm_ prefix for drmm actiondrivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c+2 -20 replies
4/31drm/display: hdmi-cec-notifier-helper: add non-drmm API variantdrivers/gpu/drm/display/drm_hdmi_cec_notifier_helper.c include/drm/display/drm_hdmi_cec_helper.h+40 -50 replies
5/31drm/connector: split drmm_connector_hdmi_init() in 3 partsdrivers/gpu/drm/drm_connector.c+55 -330 replies
6/31drm/connector: add drm_connector_hdmi_dynamic_init()drivers/gpu/drm/drm_connector.c include/drm/drm_connector.h+49 -00 replies
7/31drm/display: bridge-connector: split allocation code from initialization codedrivers/gpu/drm/display/drm_bridge_connector.c+38 -240 replies
8/31drm/display: bridge-connector: hoist error management to common codedrivers/gpu/drm/display/drm_bridge_connector.c+2 -40 replies
9/31drm/display: bridge-connector: use a dynamic connectordrivers/gpu/drm/display/drm_bridge_connector.c+102 -390 replies
10/31drm/display: bridge-connector: add APIs to add/remove the connector dynamicallydrivers/gpu/drm/display/drm_bridge_connector.c include/drm/drm_bridge_connector.h+27 -10 replies
11/31drm/bridge: constify of_drm_find_and_get_bridge() device_node parameterdrivers/gpu/drm/drm_bridge.c include/drm/drm_bridge.h+2 -20 replies
12/31drm/bridge: initialize chain_node list head on allocationdrivers/gpu/drm/drm_bridge.c+1 -00 replies
13/31drm/bridge: initialize chain_node list head on detach and attach errorsdrivers/gpu/drm/drm_bridge.c+2 -20 replies
14/31drm/bridge: ti-sn65dsi86: protect device resources on unplugdrivers/gpu/drm/bridge/ti-sn65dsi86.c+46 -40 replies
15/31drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from listdrivers/gpu/drm/drm_atomic.c+6 -00 replies
16/31drm: event-notifier: add mechanism to notify about hotplug eventsMAINTAINERS drivers/gpu/drm/Kconfig drivers/gpu/drm/Makefile +2 more+127 -00 replies
17/31drm/bridge: notify about added and detached bridgesdrivers/gpu/drm/Kconfig drivers/gpu/drm/drm_bridge.c+7 -00 replies
18/31drm/mipi-dsi: notify about DSI attachdrivers/gpu/drm/Kconfig drivers/gpu/drm/drm_mipi_dsi.c+4 -00 replies
19/31drm/bridge: add drm_bridge_get_next() and supporting funcdrivers/gpu/drm/drm_bridge.c include/drm/drm_bridge.h+55 -00 replies
20/31drm/panel: implement .get_next_bridgedrivers/gpu/drm/drm_panel.c+7 -10 replies
21/31drm/bridge: display-connector: implement .get_next_bridgedrivers/gpu/drm/bridge/display-connector.c+7 -00 replies
22/31drm/bridge: ti-sn65dsi83: implement .get_next_bridgedrivers/gpu/drm/bridge/ti-sn65dsi83.c+9 -00 replies
23/31drm/bridge: ti-sn65dsi86: implement .get_next_bridgedrivers/gpu/drm/bridge/ti-sn65dsi86.c+10 -10 replies
24/31drm/bridge: samsung-dsim: implement .get_next_bridgedrivers/gpu/drm/bridge/samsung-dsim.c+9 -00 replies
25/31drm/bridge: add drm_bridge_detach_from()drivers/gpu/drm/drm_bridge.c+34 -00 replies
26/31drm/atomic: add drm_atomic_shutdown_encoder()drivers/gpu/drm/drm_atomic.c include/drm/drm_atomic.h+146 -00 replies
27/31drm/tests: atomic: add tests for drm_atomic_shutdown_encoder()drivers/gpu/drm/tests/drm_bridge_test.c+209 -00 replies
28/31drm/bridge: clear bridge->encoder on detachdrivers/gpu/drm/drm_bridge.c+1 -00 replies
29/31drm/bridge: shutdown encoder and detach downstream bridges on bridge unplugdrivers/gpu/drm/drm_bridge.c+9 -00 replies
30/31drm: drm_hotplug_helper: new helper to implement bridge hotplugMAINTAINERS drivers/gpu/drm/display/Kconfig drivers/gpu/drm/display/Makefile +2 more+372 -00 replies
31/31drm/mxsfb/lcdif: enable bridge hotplugdrivers/gpu/drm/mxsfb/Kconfig drivers/gpu/drm/mxsfb/lcdif_drv.c+20 -220 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH RFC v3 00/31] drm bridge hotplug

Hello,

this series adds support for devices with a DRM pipeline whose final components, including one or more bridges, can be hot-plugged and hot-unplugged.

For more about the use case see the v1 cover letter:
https://lore.kernel.org/lkml/[email protected]/

Design
======

The drm_bridge_connector is nowadays the recommended way to implement DRM connectors when a chain of bridges is used.

This series proposes a small helper (drm_hotplug_helper) which drivers can use to make their encoder able to:

* receive hotplug-relevant events
* add a drm_bridge_connector when a new bridge is added making the pipeline complete in the hardware
* remove the drm_bridge_connector when a bridge is removed
* start/stop HPD polling when the connector is added/removed (despite the name, HPD is pretty much orthogonal to bridge hotplug)

Series layout
=============

There are various preparation steps before the last patches introduce bridge hotplug itself.

A. Add a dynamic variant of drmm_connector_hdmi_init() and non-drmm
hdmi-cec API
(needed for the bridge-connector to allocate the connector dynamically)

1 drm/display: hdmi-cec-helper: use drmm_ prefix for drmm action
2 drm/display: hdmi-cec-helper: add non-drmm API variant
3 drm/display: hdmi-cec-notifier-helper: use drmm_ prefix for drmm action
4 drm/display: hdmi-cec-notifier-helper: add non-drmm API variant
5 drm/connector: split drmm_connector_hdmi_init() in 3 parts
6 drm/connector: add drm_connector_hdmi_dynamic_init()

B. bridge-connector: use a dynamic drm_connector

7 drm/display: bridge-connector: split allocation code from initialization code
8 drm/display: bridge-connector: hoist error management to common code
9 drm/display: bridge-connector: use a dynamic connector
10 drm/display: bridge-connector: add APIs to add/remove the connector dynamically

C. Misc preparation work

11 drm/bridge: constify of_drm_find_and_get_bridge() device_node parameter
12 drm/bridge: initialize chain_node list head on allocation
13 drm/bridge: initialize chain_node list head on detach and attach errors
14 drm/bridge: ti-sn65dsi86: protect device resources on unplug
15 drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from list

D. Add notifier mechanism to let common code (the bridge-connector)
take actions on hotplug events

16 drm: event-notifier: add mechanism to notify about hotplug events
17 drm/bridge: notify about added and detached bridges
18 drm/mipi-dsi: notify about DSI attach

E. Let bridges return their next bridge
(allows to know when the pipeline is complete)

19 drm/bridge: add drm_bridge_get_next() and supporting func
20 drm/panel: implement .get_next_bridge
21 drm/bridge: display-connector: implement .get_next_bridge
22 drm/bridge: ti-sn65dsi83: implement .get_next_bridge
23 drm/bridge: ti-sn65dsi86: implement .get_next_bridge
24 drm/bridge: samsung-dsim: implement .get_next_bridge

F. drm_bridge: stop pipeline when a bridge is removed

25 drm/bridge: add drm_bridge_detach_from()
26 drm/atomic: add drm_atomic_shutdown_encoder()
27 drm/tests: atomic: add tests for drm_atomic_shutdown_encoder()
28 drm/bridge: clear bridge->encoder on detach
29 drm/bridge: shutdown encoder and detach downstream bridges on bridge unplug

G. Implement bridge hotplug in bridge-connector, enable it in a driver

30 drm: drm_hotplug_helper: new helper to implement bridge hotplug
31 drm/mxsfb/lcdif: enable bridge hotplug

== Grand plan

This is part of the work to support hotplug of DRM bridges.

Here's the work breakdown (➜ marks the current series):

1. … add refcounting to DRM bridges struct drm_bridge,
based on devm_drm_bridge_alloc()
A. ✔ add new alloc API and refcounting (v6.16)
B. ✔ convert all bridge drivers to new API (v6.17)
C. ✔ kunit tests (v6.17)
D. ✔ add get/put to drm_bridge_add/remove() + attach/detach()
and warn on old allocation pattern (v6.17)
E. … add get/put on drm_bridge accessors
1. ✔ drm_bridge_chain_get_first_bridge(), add cleanup action (v6.18)
2. ✔ drm_bridge_get_prev_bridge() (v6.18)
3. ✔ drm_bridge_get_next_bridge() (v6.19)
4. ✔ drm_for_each_bridge_in_chain() (v6.19)
5. ✔ drm_bridge_connector_init (v6.19)
6. ✔ protect encoder bridge chain with a mutex (v7.2)
7. ✔ of_drm_find_bridge
a. ✔ add of_drm_get_bridge() (v7.0),
convert basic direct users (v7.0-v7.1)
b. ✔ convert direct of_drm_get_bridge() users, part 2 (v7.0) c. ✔ convert direct of_drm_get_bridge() users, part 3 (v7.0) d. ✔ convert direct of_drm_get_bridge() users, part 4 (v7.1-v7.2) e. ✔ bridge-only drm_of_find_panel_or_bridge() users (v7.2)
8. … panel_bridge lifetime
a. ✔ cleanup DRM_PANEL in bridge drivers (v7.4)
b. ✔ embed a drm_bridge in every drm_panel (v7.4)
c. ✔ remove *_of_get_bridge(): non-OF drivers (v7.5) d. … remove drmm_of_get_bridge()
e. … remove devm_drm_of_get_bridge(), part 1
f. remove devm_drm_of_get_bridge(), part 2
9. ✔ enforce drm_bridge_add before drm_bridge_attach (v6.19)
F. ✔ debugfs improvements
1. ✔ add top-level 'bridges' file (v6.16)
2. ✔ show refcount and list lingering bridges (v6.19)
2. ✔ handle gracefully atomic updates during bridge removal
A. ✔ Add drm_bridge_enter/exit() to protect device resources (v7.0) B. ✔ Add drm_bridge_clear_and_put() (v7.1)
3. ✕ DSI host-device driver interaction
4. ✔ removing the need for the "always-disconnected" connector
5. ✔ Migrate i.MX LCDIF driver to bridge-connector (v7.2)
6. ➜ DRM bridge hotplug
A. ➜ Bridge hotplug management in the DRM core
1. ✔ bridge-connector: attach encoder to the connector (v7.2)
2. ➜ drm bridge hotplug
B. Device tree description

---
Changes in v3:
- Handle use cases where the first bridge after the encoder is hotpluggable
(in v1 and v2 the first bridge was required to be always present)
as well as all cases where the first bridge is a DSI host
- Removed "samsung-dsim: move drm_bridge_add() call to probe", not
needed anymore
- Handle hot-pluggable bridges supporting HPD, add TI SN65DSI86 DSI-to-DP
- Fully implement dynamic connector in drm_bridge_connector (CEC helpers
were missing in v2)
- Fixed shutdown to not shutdown the whole card
- as a consequence, removed (not needed anymore)
"drm/atomic: move [...] from drm_atomic_helper to drm_atomic"
- Many smaller fixes and improvements
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Rewrote: added new drm_hotplug_helper, dropped most changes to drm_bridge_connector
- Added get_next_bridge func, dropped is_tail func, and stop
using -EPROBE_DEFER to mean a next bridge is needed but currently absent
- Rebased on drm-misc-next, which required a few reworks
- Fix dynconn mutex locking
- Fix sashiko-reported bugs
- Drop "drm/display: bridge-connector: store the drm_device pointer", not strongly needed, and adapt the remaining patches
- Simplify handle_hpd code types
- Lots of other smaller improvements
- Link to v1: https://patch.msgid.link/[email protected]

---
Luca Ceresoli (31):
drm/display: hdmi-cec-helper: use drmm_ prefix for drmm action drm/display: hdmi-cec-helper: add non-drmm API variant drm/display: hdmi-cec-notifier-helper: use drmm_ prefix for drmm action drm/display: hdmi-cec-notifier-helper: add non-drmm API variant drm/connector: split drmm_connector_hdmi_init() in 3 parts drm/connector: add drm_connector_hdmi_dynamic_init()
drm/display: bridge-connector: split allocation code from initialization code drm/display: bridge-connector: hoist error management to common code drm/display: bridge-connector: use a dynamic connector drm/display: bridge-connector: add APIs to add/remove the connector dynamically drm/bridge: constify of_drm_find_and_get_bridge() device_node parameter drm/bridge: initialize chain_node list head on allocation drm/bridge: initialize chain_node list head on detach and attach errors drm/bridge: ti-sn65dsi86: protect device resources on unplug drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from list
drm: event-notifier: add mechanism to notify about hotplug events drm/bridge: notify about added and detached bridges
drm/mipi-dsi: notify about DSI attach
drm/bridge: add drm_bridge_get_next() and supporting func drm/panel: implement .get_next_bridge
drm/bridge: display-connector: implement .get_next_bridge drm/bridge: ti-sn65dsi83: implement .get_next_bridge
drm/bridge: ti-sn65dsi86: implement .get_next_bridge
drm/bridge: samsung-dsim: implement .get_next_bridge
drm/bridge: add drm_bridge_detach_from()
drm/atomic: add drm_atomic_shutdown_encoder()
drm/tests: atomic: add tests for drm_atomic_shutdown_encoder() drm/bridge: clear bridge->encoder on detach
drm/bridge: shutdown encoder and detach downstream bridges on bridge unplug
drm: drm_hotplug_helper: new helper to implement bridge hotplug drm/mxsfb/lcdif: enable bridge hotplug

 MAINTAINERS                                        |  16 +
 drivers/gpu/drm/Kconfig                            |   5 +
 drivers/gpu/drm/Makefile                           |   2 +
 drivers/gpu/drm/bridge/display-connector.c         |   7 +
 drivers/gpu/drm/bridge/samsung-dsim.c              |   9 +
 drivers/gpu/drm/bridge/ti-sn65dsi83.c              |   9 +
 drivers/gpu/drm/bridge/ti-sn65dsi86.c              |  61 +++-
 drivers/gpu/drm/display/Kconfig                    |   7 +
 drivers/gpu/drm/display/Makefile                   |   2 +
 drivers/gpu/drm/display/drm_bridge_connector.c     | 225 ++++++++++----
 drivers/gpu/drm/display/drm_hdmi_cec_helper.c      |  62 ++--
 .../gpu/drm/display/drm_hdmi_cec_notifier_helper.c |  34 ++-
 drivers/gpu/drm/display/drm_hotplug_helper.c       | 325 +++++++++++++++++++++
 drivers/gpu/drm/drm_atomic.c                       | 151 ++++++++++
 drivers/gpu/drm/drm_bridge.c                       |  87 +++++-
 drivers/gpu/drm/drm_connector.c                    | 131 ++++++---
 drivers/gpu/drm/drm_hotplug_event_notifier.c       |  62 ++++
 drivers/gpu/drm/drm_mipi_dsi.c                     |   3 +
 drivers/gpu/drm/drm_panel.c                        |   8 +-
 drivers/gpu/drm/mxsfb/Kconfig                      |   2 +-
 drivers/gpu/drm/mxsfb/lcdif_drv.c                  |  40 ++-
 drivers/gpu/drm/tests/drm_bridge_test.c            | 209 +++++++++++++
 include/drm/display/drm_hdmi_cec_helper.h          |  21 ++
 include/drm/drm_atomic.h                           |   1 +
 include/drm/drm_bridge.h                           |  27 +-
 include/drm/drm_bridge_connector.h                 |   4 +
 include/drm/drm_connector.h                        |   6 +
 include/drm/drm_hotplug_event_notifier.h           |  52 ++++
 include/drm/drm_hotplug_helper.h                   |  30 ++
 29 files changed, 1442 insertions(+), 156 deletions(-)

---
base-commit: 9c327dceb627a7947de3e82da6363fa508fd619b
change-id: 20260515-drm-bridge-hotplug-46265d3a2f85

Best regards,

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com