diff mbox series

[2/5] drivers/thunderbolt: don't resume switches without uid set

Message ID 20220302220709.3138846-2-mario.limonciello@amd.com (mailing list archive)
State Accepted
Commit a283de3ec646f19b09f3c8e4c8f57c0e017c9b2b
Headers show
Series [1/5] drivers/thunderbolt: Retry DROM reads for more failure scenarios | expand

Commit Message

Mario Limonciello March 2, 2022, 10:07 p.m. UTC
Switches might not have a uid set if the DROM read failed during
initialization previously.

Normally upon resume the uid is re-read to confirm it's the same
device connected.
* If the DROM read failed during init but then succeeded during
  resume it could either be a new device or faulty device
* If the DROM read failed during init and also failed during resume
  it might be a different device plugged in all together.

Detect this situation and prevent re-using the same configuration in
these cirucmstances.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/thunderbolt/switch.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mika Westerberg March 3, 2022, 7:43 a.m. UTC | #1
Hi Mario,

On Wed, Mar 02, 2022 at 04:07:06PM -0600, Mario Limonciello wrote:
> Switches might not have a uid set if the DROM read failed during

That's "Routers" and "UID" :)

Also $subject should have prefix "thunderbolt: " not
"drivers/thunderbolt". Please capitalize the summary too:

  thunderbolt: Do not resume routers if UID is not set

The patch itself looks good to me.

> initialization previously.
> 
> Normally upon resume the uid is re-read to confirm it's the same
> device connected.
> * If the DROM read failed during init but then succeeded during
>   resume it could either be a new device or faulty device
> * If the DROM read failed during init and also failed during resume
>   it might be a different device plugged in all together.
> 
> Detect this situation and prevent re-using the same configuration in
> these cirucmstances.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/thunderbolt/switch.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index b5fb3e76ed09..294518af4ee4 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -2980,6 +2980,10 @@ int tb_switch_resume(struct tb_switch *sw)
>  			return err;
>  		}
>  
> +		/* We don't have any way to confirm this was the same device */
> +		if (!sw->uid)
> +			return -ENODEV;
> +
>  		if (tb_switch_is_usb4(sw))
>  			err = usb4_switch_read_uid(sw, &uid);
>  		else
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index b5fb3e76ed09..294518af4ee4 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2980,6 +2980,10 @@  int tb_switch_resume(struct tb_switch *sw)
 			return err;
 		}
 
+		/* We don't have any way to confirm this was the same device */
+		if (!sw->uid)
+			return -ENODEV;
+
 		if (tb_switch_is_usb4(sw))
 			err = usb4_switch_read_uid(sw, &uid);
 		else