diff mbox series

[2/3] usb: typec: ps883x: fix missing accessibility check

Message ID 20250218152933.22992-3-johan+linaro@kernel.org
State New
Headers show
Series usb: typec: ps883x: follow-up fixes | expand

Commit Message

Johan Hovold Feb. 18, 2025, 3:29 p.m. UTC
Make sure that the retimer is accessible before registering to avoid
having later consumer calls fail to configure it, something which, for
example, can lead to a hotplugged display not being recognised:

	[drm:msm_dp_panel_read_sink_caps [msm]] *ERROR* read dpcd failed -110

Fixes: 257a087c8b52 ("usb: typec: Add support for Parade PS8830 Type-C Retimer")
Cc: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/usb/typec/mux/ps883x.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Jens Glathe March 2, 2025, 1:34 p.m. UTC | #1
Hi Johan,

On 2/18/25 16:29, Johan Hovold wrote:
> Make sure that the retimer is accessible before registering to avoid
> having later consumer calls fail to configure it, something which, for
> example, can lead to a hotplugged display not being recognised:
>
> 	[drm:msm_dp_panel_read_sink_caps [msm]] *ERROR* read dpcd failed -110
>
> Fixes: 257a087c8b52 ("usb: typec: Add support for Parade PS8830 Type-C Retimer")
> Cc: Abel Vesa <abel.vesa@linaro.org>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>

unfortunately, this one goes south on the HP Omnibook X14, and also on
the Elitebook G1Q. After excluding a lot of other causes, like inverted
resets and wrong i2c channels, I did a bisect and landed at this commit.

Looking at it, I speculatively increased the firmware initialization
delay to 200ms. To no effect. Reverting this patch "resolves" the issue.

with best regards

Jens
Johan Hovold March 3, 2025, 7:07 a.m. UTC | #2
Hi Jens,

On Sun, Mar 02, 2025 at 02:34:41PM +0100, Jens Glathe wrote:
> On 2/18/25 16:29, Johan Hovold wrote:
> > Make sure that the retimer is accessible before registering to avoid
> > having later consumer calls fail to configure it, something which, for
> > example, can lead to a hotplugged display not being recognised:
> >
> > 	[drm:msm_dp_panel_read_sink_caps [msm]] *ERROR* read dpcd failed -110
> >
> > Fixes: 257a087c8b52 ("usb: typec: Add support for Parade PS8830 Type-C Retimer")
> > Cc: Abel Vesa <abel.vesa@linaro.org>
> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> 
> unfortunately, this one goes south on the HP Omnibook X14, and also on
> the Elitebook G1Q. After excluding a lot of other causes, like inverted
> resets and wrong i2c channels, I did a bisect and landed at this commit.

According to the X14 ACPI tables there is no ps8830 on &i2c7i (I2C8),
which means that the devicetree is broken.

> Looking at it, I speculatively increased the firmware initialization
> delay to 200ms. To no effect. Reverting this patch "resolves" the issue.

This patch (series) only makes sure that there actually is a retimer at
the described address so it appears to work as intended.

You may unknowingly have been relying on firmware configuration or reset
values. Does orientation switching (SuperSpeed in both orientations) and
DP altmode work at all on the second USB-C port with this patch
reverted?

Johan
diff mbox series

Patch

diff --git a/drivers/usb/typec/mux/ps883x.c b/drivers/usb/typec/mux/ps883x.c
index 274de7abe585..f8b47187f4cf 100644
--- a/drivers/usb/typec/mux/ps883x.c
+++ b/drivers/usb/typec/mux/ps883x.c
@@ -291,6 +291,7 @@  static int ps883x_retimer_probe(struct i2c_client *client)
 	struct typec_switch_desc sw_desc = { };
 	struct typec_retimer_desc rtmr_desc = { };
 	struct ps883x_retimer *retimer;
+	unsigned int val;
 	int ret;
 
 	retimer = devm_kzalloc(dev, sizeof(*retimer), GFP_KERNEL);
@@ -360,6 +361,16 @@  static int ps883x_retimer_probe(struct i2c_client *client)
 
 		/* firmware initialization delay */
 		msleep(60);
+
+		/* make sure device is accessible */
+		ret = regmap_read(retimer->regmap, REG_USB_PORT_CONN_STATUS_0,
+				  &val);
+		if (ret) {
+			dev_err(dev, "failed to read conn_status_0: %d\n", ret);
+			if (ret == -ENXIO)
+				ret = -EIO;
+			goto err_clk_disable;
+		}
 	}
 
 	sw_desc.drvdata = retimer;