drm: simplify support for transparent DRM bridges
Subsystems (9)
v5 cover drm: simplify support for transparent DRM bridges
Supporting DP/USB-C can result in a chain of several transparent bridges (PHY, redrivers, mux, etc). All attempts to implement DP support in a different way resulted either in series of hacks or in device tree not reflecting the actual hardware design. This results in drivers having similar boilerplate code for such bridges.
Next, these drivers are susceptible to -EPROBE_DEFER loops: the next bridge can either be probed from the bridge->attach callback, when it is too late to return -EPROBE_DEFER, or from the probe() callback, when the next bridge might not yet be available, because it depends on the resources provided by the probing device. Device links can not fully solve this problem since there are mutual dependencies between adjancent devices.
Last, but not least, this results in the the internal knowledge of DRM subsystem slowly diffusing into other subsystems, like PHY or USB/TYPEC.
To solve all these issues, define a separate DRM helper, which creates separate aux device just for the bridge. During probe such aux device doesn't result in the EPROBE_DEFER loops. Instead it allows the device drivers to probe properly, according to the actual resource dependencies. The bridge auxdevs are then probed when the next bridge becomes available, sparing drivers from drm_bridge_attach() returning -EPROBE_DEFER.
Changes since v4:
- Added documentation for new API (Sima)
- Added generic code to handle "last mile" DP bridges implementing just the HPD functionality.
- Rebased on top of linux-next to be able to drop #ifdef's around drm_bridge->of_node
Changes since v3:
- Moved bridge driver to gpu/drm/bridge (Neil Armstrong)
- Renamed it to aux-bridge (since there is already a simple_bridge driver)
- Made CONFIG_OF mandatory for this driver (Neil Armstrong)
- Added missing kfree and ida_free (Dan Carpenter)
Changes since v2:
- ifdef'ed bridge->of_node access (LKP)
Changes since v1:
- Added EXPORT_SYMBOL_GPL / MODULE_LICENSE / etc. to drm_simple_bridge
Dmitry Baryshkov (6):
drm/bridge: add transparent bridge helper
phy: qcom: qmp-combo: switch to DRM_AUX_BRIDGE
usb: typec: nb7vpq904m: switch to DRM_AUX_BRIDGE drm/bridge: implement generic DP HPD bridge
soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE
usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE
drivers/gpu/drm/bridge/Kconfig | 17 ++ drivers/gpu/drm/bridge/Makefile | 2 + drivers/gpu/drm/bridge/aux-bridge.c | 140 +++++++++++++++ drivers/gpu/drm/bridge/aux-hpd-bridge.c | 164 ++++++++++++++++++ drivers/phy/qualcomm/Kconfig | 2 +- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 44 +---- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/pmic_glink_altmode.c | 33 +--- drivers/usb/typec/mux/Kconfig | 2 +- drivers/usb/typec/mux/nb7vpq904m.c | 44 +---- drivers/usb/typec/tcpm/Kconfig | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 41 +---- include/drm/bridge/aux-bridge.h | 37 ++++ 13 files changed, 383 insertions(+), 145 deletions(-) create mode 100644 drivers/gpu/drm/bridge/aux-bridge.c create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.c create mode 100644 include/drm/bridge/aux-bridge.h
Signature · 1 line
2.42.0
PATCH v5 1/6 drm/bridge: add transparent bridge helper
Define a helper for creating simple transparent bridges which serve the only purpose of linking devices into the bridge chain up to the last bridge representing the connector. This is especially useful for DP/USB-C bridge chains, which can span across several devices, but do not require any additional functionality from the intermediate bridges.
--- drivers/gpu/drm/bridge/Kconfig | 9 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/aux-bridge.c | 140 ++++++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 19 ++++ 4 files changed, 169 insertions(+) create mode 100644 drivers/gpu/drm/bridge/aux-bridge.c create mode 100644 include/drm/bridge/aux-bridge.h
drivers/gpu/drm/bridge/Kconfig +9 -0
@@ -12,6 +12,15 @@ config DRM_PANEL_BRIDGE help DRM bridge wrapper of DRM panels +config DRM_AUX_BRIDGE + tristate + depends on DRM_BRIDGE && OF + select AUXILIARY_BUS + select DRM_PANEL_BRIDGE + help + Simple transparent bridge that is used by several non-DRM drivers to + build bridges chain. + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o obj-$(CONFIG_DRM_CHIPONE_ICN6211) += chipone-icn6211.o obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o
drivers/gpu/drm/bridge/aux-bridge.c new file +140 -0
140 lines not on this page · raw message
include/drm/bridge/aux-bridge.h new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2023 Linaro Ltd. +* +* Author: Dmitry Baryshkov <[email protected]> +*/ +#ifndef DRM_AUX_BRIDGE_H +#define DRM_AUX_BRIDGE_H + +#if IS_ENABLED (CONFIG_DRM_AUX_BRIDGE ) +int drm_aux_bridge_register (struct device *parent); +#else +static inline int drm_aux_bridge_register (struct device *parent) +{ +return 0 ; +} +#endif + +#endif
Signature · 1 line
2.42.0
PATCH v5 2/6 phy: qcom: qmp-combo: switch to DRM_AUX_BRIDGE
In reply to Dmitry BaryshkovSwitch to using the new DRM_AUX_BRIDGE helper to create the transparent DRM bridge device instead of handcoding corresponding functionality.
--- drivers/phy/qualcomm/Kconfig | 2 +- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 44 ++--------------------- 2 files changed, 3 insertions(+), 43 deletions(-)
drivers/phy/qualcomm/Kconfig +1 -1
@@ -63,7 +63,7 @@ config PHY_QCOM_QMP_COMBO depends on DRM || DRM=n select GENERIC_PHY select MFD_SYSCON - select DRM_PANEL_BRIDGE if DRM + select DRM_AUX_BRIDGE if DRM_BRIDGE help Enable this to support the QMP Combo PHY transceiver that is used with USB3 and DisplayPort controllers on Qualcomm chips.
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +2 -42
68 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH v5 3/6 usb: typec: nb7vpq904m: switch to DRM_AUX_BRIDGE
In reply to Dmitry BaryshkovSwitch to using the new DRM_AUX_BRIDGE helper to create the transparent DRM bridge device instead of handcoding corresponding functionality.
--- drivers/usb/typec/mux/Kconfig | 2 +- drivers/usb/typec/mux/nb7vpq904m.c | 44 ++---------------------------- 2 files changed, 3 insertions(+), 43 deletions(-)
drivers/usb/typec/mux/Kconfig +1 -1
@@ -40,7 +40,7 @@ config TYPEC_MUX_NB7VPQ904M tristate "On Semiconductor NB7VPQ904M Type-C redriver driver" depends on I2C depends on DRM || DRM=n - select DRM_PANEL_BRIDGE if DRM + select DRM_AUX_BRIDGE if DRM_BRIDGE select REGMAP_I2C help Say Y or M if your system has a On Semiconductor NB7VPQ904M Type-C
drivers/usb/typec/mux/nb7vpq904m.c +2 -42
68 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH v5 4/6 drm/bridge: implement generic DP HPD bridge
In reply to Dmitry BaryshkovSeveral USB-C controllers implement a pretty simple DRM bridge which implements just the HPD notification operations. Add special helper for creating such simple bridges.
--- drivers/gpu/drm/bridge/Kconfig | 8 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/aux-hpd-bridge.c | 164 ++++++++++++++++++++++++ include/drm/bridge/aux-bridge.h | 18 +++ 4 files changed, 191 insertions(+) create mode 100644 drivers/gpu/drm/bridge/aux-hpd-bridge.c
drivers/gpu/drm/bridge/Kconfig +8 -0
@@ -21,6 +21,14 @@ config DRM_AUX_BRIDGE Simple transparent bridge that is used by several non-DRM drivers to build bridges chain. +config DRM_AUX_HPD_BRIDGE + tristate + depends on DRM_BRIDGE && OF + select AUXILIARY_BUS + help + Simple bridge that terminates the bridge chain and provides HPD + support. + menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_AUX_BRIDGE) += aux-bridge.o +obj-$(CONFIG_DRM_AUX_HPD_BRIDGE) += aux-hpd-bridge.o obj-$(CONFIG_DRM_CHIPONE_ICN6211) += chipone-icn6211.o obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o
drivers/gpu/drm/bridge/aux-hpd-bridge.c new file +164 -0
164 lines not on this page · raw message
include/drm/bridge/aux-bridge.h +18 -0
@@ -7,6 +7,8 @@#ifndef DRM_AUX_BRIDGE_H #define DRM_AUX_BRIDGE_H +#include <drm/drm_connector.h> +#if IS_ENABLED (CONFIG_DRM_AUX_BRIDGE )int drm_aux_bridge_register (struct device *parent);#else
@@ -16,4 +18,20 @@ static inline int drm_aux_bridge_register(struct device *parent) }#endif +#if IS_ENABLED (CONFIG_DRM_AUX_HPD_BRIDGE ) +struct device *drm_dp_hpd_bridge_register (struct device *parent, +struct device_node *np); +void drm_aux_hpd_bridge_notify (struct device *dev,enum drm_connector_status status); +#else +static inline struct device *drm_dp_hpd_bridge_register (struct device *parent, +struct device_node *np); +{ +return 0 ; +} + +static inline void drm_aux_hpd_bridge_notify (struct device *dev,enum drm_connector_status status) +{ +} +#endif +#endif
Signature · 1 line
2.42.0
kernel test robot
build botRe: [PATCH v5 4/6] drm/bridge: implement generic DP HPD bridge
kernel test robot noticed the following build errors:
Hi Dmitry,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20231025]
[also build test ERROR on v6.6-rc7]
[cannot apply to drm-misc/drm-misc-next usb/usb-testing usb/usb-next usb/usb-linus drm/drm-next linus/master v6.6-rc7 v6.6-rc6 v6.6-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/drm-bridge-add-transparent-bridge-helper/20231026-063135 base: next-20231025 patch link: https://lore.kernel.org/r/20231025223027.943563-5-dmitry.baryshkov%40linaro.org patch subject: [PATCH v5 4/6] drm/bridge: implement generic DP HPD bridge config: csky-randconfig-002-20231026 (https://download.01.org/0day-ci/archive/20231026/[email protected]/config) compiler: csky-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231026/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
In file included from drivers/phy/qualcomm/phy-qcom-qmp-combo.c:24:
>> include/drm/bridge/aux-bridge.h:28:1: error: expected identifier or '(' before '{' token
28 | {
| ^
>> include/drm/bridge/aux-bridge.h:26:30: warning: 'drm_dp_hpd_bridge_register' declared 'static' but never defined [-Wunused-function] 26 | static inline struct device *drm_dp_hpd_bridge_register(struct device *parent,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
vim +28 include/drm/bridge/aux-bridge.h
20
21 #if IS_ENABLED(CONFIG_DRM_AUX_HPD_BRIDGE)
22 struct device *drm_dp_hpd_bridge_register(struct device *parent,
23 struct device_node *np);
24 void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status);
25 #else
> 26 static inline struct device *drm_dp_hpd_bridge_register(struct device *parent,
27 struct device_node *np);
> 28 {
29 return 0;
30 }
31 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v5 5/6 soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE
In reply to Dmitry BaryshkovUse the freshly defined DRM_AUX_HPD_BRIDGE instead of open-coding the same functionality for the DRM bridge chain termination.
--- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/pmic_glink_altmode.c | 33 ++++++++------------------- 2 files changed, 10 insertions(+), 24 deletions(-)
drivers/soc/qcom/Kconfig +1 -0
@@ -86,6 +86,7 @@ config QCOM_PMIC_GLINK depends on OF select AUXILIARY_BUS select QCOM_PDR_HELPERS + select DRM_AUX_HPD_BRIDGE help The Qualcomm PMIC GLINK driver provides access, over GLINK, to the USB and battery firmware running on one of the coprocessors in
drivers/soc/qcom/pmic_glink_altmode.c +9 -24
@@ -11,7 +11,7 @@#include <linux/mutex.h> #include <linux/property.h> #include <linux/soc/qcom/pdr.h> -#include <drm/drm_bridge.h> +#include <drm/bridge/aux-bridge.h> #include <linux/usb/typec_altmode.h> #include <linux/usb/typec_dp.h>
@@ -76,7 +76,7 @@ struct pmic_glink_altmode_port {struct work_struct work; -struct drm_bridge bridge; +struct device *bridge;enum typec_orientation orientation;u16 svid;
@@ -230,10 +230,10 @@ static void pmic_glink_altmode_worker(struct work_struct *work)else pmic_glink_altmode_enable_usb (altmode, alt_port); -if (alt_port->hpd_state) -drm_bridge_hpd_notify (&alt_port->bridge, connector_status_connected); -else -drm_bridge_hpd_notify (&alt_port->bridge, connector_status_disconnected); +drm_aux_hpd_bridge_notify (alt_port->bridge, + alt_port->hpd_state ? + connector_status_connected : + connector_status_disconnected);pmic_glink_altmode_request (altmode,ALTMODE_PAN_ACK , alt_port->index); };
@@ -365,16 +365,6 @@ static void pmic_glink_altmode_callback(const void *data, size_t len, void *priv } } -static int pmic_glink_altmode_attach (struct drm_bridge *bridge, -enum drm_bridge_attach_flags flags) -{ -return flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ?0 : -EINVAL ; -} - -static const struct drm_bridge_funcs pmic_glink_altmode_bridge_funcs = { - .attach = pmic_glink_altmode_attach, -}; -static void pmic_glink_altmode_put_retimer (void *data) {typec_retimer_put (data);
@@ -464,15 +454,10 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, alt_port->index = port;INIT_WORK (&alt_port->work, pmic_glink_altmode_worker); - alt_port->bridge.funcs = &pmic_glink_altmode_bridge_funcs; - alt_port->bridge.of_node =to_of_node (fwnode); - alt_port->bridge.ops =DRM_BRIDGE_OP_HPD ; - alt_port->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; - - ret =devm_drm_bridge_add (dev, &alt_port->bridge); -if (ret) { + alt_port->bridge =drm_dp_hpd_bridge_register (dev,to_of_node (fwnode)); +if (IS_ERR (alt_port->bridge)) {fwnode_handle_put (fwnode); -return ret; +return PTR_ERR (alt_port->bridge); } alt_port->dp_alt.svid =USB_TYPEC_DP_SID ;
Signature · 1 line
2.42.0
Re: [PATCH v5 5/6] soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE
Quoted 3 lines · Dmitry Baryshkov
Use the freshly defined
DRM_AUX_HPD_BRIDGEinstead of open-coding the same functionality for the DRM bridge chain termination.
Regards,
Bjorn
PATCH v5 6/6 usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE
In reply to Dmitry BaryshkovUse the freshly defined DRM_AUX_HPD_BRIDGE instead of open-coding the same functionality for the DRM bridge chain termination.
--- drivers/usb/typec/tcpm/Kconfig | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 41 +++---------------- 2 files changed, 7 insertions(+), 35 deletions(-)
drivers/usb/typec/tcpm/Kconfig +1 -0
@@ -80,6 +80,7 @@ config TYPEC_QCOM_PMIC tristate "Qualcomm PMIC USB Type-C Port Controller Manager driver" depends on ARCH_QCOM || COMPILE_TEST depends on DRM || DRM=n + select DRM_AUX_HPD_BRIDGE if DRM_BRIDGE help A Type-C port and Power Delivery driver which aggregates two discrete pieces of silicon in the PM8150b PMIC block: the
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +6 -35
75 lines not on this page · raw message
Signature · 1 line
2.42.0