Skip to content

Commit 718b36a

Browse files
lumaggregkh
authored andcommitted
usb: typec: qcom-pmic-typec: split HPD bridge alloc and registration
If a probe function returns -EPROBE_DEFER after creating another device there is a change of ending up in a probe deferral loop, (see commit fbc35b4 ("Add documentation on meaning of -EPROBE_DEFER"). In case of the qcom-pmic-typec driver the tcpm_register_port() function looks up external resources (USB role switch and inherently via called typec_register_port() USB-C muxes, switches and retimers). In order to prevent such probe-defer loops caused by qcom-pmic-typec driver, use the API added by Johan Hovold and move HPD bridge registration to the end of the probe function. The devm_drm_dp_hpd_bridge_add() is called at the end of the probe function after all TCPM start functions. This is done as a way to overcome a different problem, the DRM subsystem can not properly cope with the DRM bridges being destroyed once the bridge is attached. Having this function call at the end of the probe function prevents possible DRM bridge device creation followed by destruction in case one of the TCPM start functions returns an error. Reported-by: Caleb Connolly <[email protected]> Acked-by: Bryan O'Donoghue <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e7899eb commit 718b36a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
4141
struct device_node *np = dev->of_node;
4242
const struct pmic_typec_resources *res;
4343
struct regmap *regmap;
44-
struct device *bridge_dev;
44+
struct auxiliary_device *bridge_dev;
4545
u32 base;
4646
int ret;
4747

@@ -92,7 +92,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
9292
if (!tcpm->tcpc.fwnode)
9393
return -EINVAL;
9494

95-
bridge_dev = drm_dp_hpd_bridge_register(tcpm->dev, to_of_node(tcpm->tcpc.fwnode));
95+
bridge_dev = devm_drm_dp_hpd_bridge_alloc(tcpm->dev, to_of_node(tcpm->tcpc.fwnode));
9696
if (IS_ERR(bridge_dev))
9797
return PTR_ERR(bridge_dev);
9898

@@ -110,8 +110,14 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
110110
if (ret)
111111
goto port_stop;
112112

113+
ret = devm_drm_dp_hpd_bridge_add(tcpm->dev, bridge_dev);
114+
if (ret)
115+
goto pdphy_stop;
116+
113117
return 0;
114118

119+
pdphy_stop:
120+
tcpm->pdphy_stop(tcpm);
115121
port_stop:
116122
tcpm->port_stop(tcpm);
117123
port_unregister:

0 commit comments

Comments
 (0)