Commit 9f9de3e0 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

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: 257a087c ("usb: typec: Add support for Parade PS8830 Type-C Retimer")
Cc: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20250218152933.22992-2-johan+linaro@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 834d1cb7
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -346,6 +346,22 @@ static int ps883x_retimer_probe(struct i2c_client *client)
		goto err_vregs_disable;
	}

	/* skip resetting if already configured */
	if (regmap_test_bits(retimer->regmap, REG_USB_PORT_CONN_STATUS_0,
			     CONN_STATUS_0_CONNECTION_PRESENT) == 1) {
		gpiod_direction_output(retimer->reset_gpio, 0);
	} else {
		gpiod_direction_output(retimer->reset_gpio, 1);

		/* VDD IO supply enable to reset release delay */
		usleep_range(4000, 14000);

		gpiod_set_value(retimer->reset_gpio, 0);

		/* firmware initialization delay */
		msleep(60);
	}

	sw_desc.drvdata = retimer;
	sw_desc.fwnode = dev_fwnode(dev);
	sw_desc.set = ps883x_sw_set;
@@ -368,21 +384,6 @@ static int ps883x_retimer_probe(struct i2c_client *client)
		goto err_switch_unregister;
	}

	/* skip resetting if already configured */
	if (regmap_test_bits(retimer->regmap, REG_USB_PORT_CONN_STATUS_0,
			     CONN_STATUS_0_CONNECTION_PRESENT) == 1)
		return gpiod_direction_output(retimer->reset_gpio, 0);

	gpiod_direction_output(retimer->reset_gpio, 1);

	/* VDD IO supply enable to reset release delay */
	usleep_range(4000, 14000);

	gpiod_set_value(retimer->reset_gpio, 0);

	/* firmware initialization delay */
	msleep(60);

	return 0;

err_switch_unregister: