usb: typec: qcom-pmic-typec: split HPD bridge alloc and registration
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Wed, 24 Apr 2024 02:16:57 +0000 (05:16 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 May 2024 09:36:17 +0000 (10:36 +0100)
commit718b36a7b49acbba36546371db2d235271ceb06c
treecf9255e518ad0b0ef8d337326916967f0c467580
parente7899ebb4301f87fe0af8a5d1ad28e3ddd85f4e3
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
fbc35b45f9f6 ("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 <caleb.connolly@linaro.org>
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20240424-qc-pmic-typec-hpd-split-v4-1-f7e10d147443@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c