Skip to content

Commit 9f9de3e

Browse files
jhovoldgregkh
authored andcommitted
usb: typec: ps883x: fix registration race
Make sure that the retimer is fully setup before registering it to avoid having consumers try to access it while it is being reset. Fixes: 257a087 ("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> Link: https://lore.kernel.org/r/20250218152933.22992-2-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 834d1cb commit 9f9de3e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/usb/typec/mux/ps883x.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,22 @@ static int ps883x_retimer_probe(struct i2c_client *client)
346346
goto err_vregs_disable;
347347
}
348348

349+
/* skip resetting if already configured */
350+
if (regmap_test_bits(retimer->regmap, REG_USB_PORT_CONN_STATUS_0,
351+
CONN_STATUS_0_CONNECTION_PRESENT) == 1) {
352+
gpiod_direction_output(retimer->reset_gpio, 0);
353+
} else {
354+
gpiod_direction_output(retimer->reset_gpio, 1);
355+
356+
/* VDD IO supply enable to reset release delay */
357+
usleep_range(4000, 14000);
358+
359+
gpiod_set_value(retimer->reset_gpio, 0);
360+
361+
/* firmware initialization delay */
362+
msleep(60);
363+
}
364+
349365
sw_desc.drvdata = retimer;
350366
sw_desc.fwnode = dev_fwnode(dev);
351367
sw_desc.set = ps883x_sw_set;
@@ -368,21 +384,6 @@ static int ps883x_retimer_probe(struct i2c_client *client)
368384
goto err_switch_unregister;
369385
}
370386

371-
/* skip resetting if already configured */
372-
if (regmap_test_bits(retimer->regmap, REG_USB_PORT_CONN_STATUS_0,
373-
CONN_STATUS_0_CONNECTION_PRESENT) == 1)
374-
return gpiod_direction_output(retimer->reset_gpio, 0);
375-
376-
gpiod_direction_output(retimer->reset_gpio, 1);
377-
378-
/* VDD IO supply enable to reset release delay */
379-
usleep_range(4000, 14000);
380-
381-
gpiod_set_value(retimer->reset_gpio, 0);
382-
383-
/* firmware initialization delay */
384-
msleep(60);
385-
386387
return 0;
387388

388389
err_switch_unregister:

0 commit comments

Comments
 (0)