Re: [PATCH v4 02/27] thunderbolt: No need to read UID of the root switch on resume

From: Andy Shevchenko
Date: Tue Jun 06 2017 - 09:08:18 EST


On Tue, 2017-06-06 at 15:24 +0300, Mika Westerberg wrote:
> The root switch is part of the host controller and cannot be
> physically
> removed, so there is no point of reading UID again on resume in order
> to
> check if the root switch is still the same.
>

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>


> Suggested-by: Andreas Noever <andreas.noever@xxxxxxxxx>
> Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> Signed-off-by: Andreas Noever <andreas.noever@xxxxxxxxx>
> ---
> Âdrivers/thunderbolt/switch.c | 29 ++++++++++++++++++-----------
> Â1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/thunderbolt/switch.c
> b/drivers/thunderbolt/switch.c
> index c6f30b1695a9..81f5164a6364 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -452,19 +452,26 @@ void tb_sw_set_unplugged(struct tb_switch *sw)
> Âint tb_switch_resume(struct tb_switch *sw)
> Â{
> Â int i, err;
> - u64 uid;
> Â tb_sw_info(sw, "resuming switch\n");
> Â
> - err = tb_drom_read_uid_only(sw, &uid);
> - if (err) {
> - tb_sw_warn(sw, "uid read failed\n");
> - return err;
> - }
> - if (sw != sw->tb->root_switch && sw->uid != uid) {
> - tb_sw_info(sw,
> - "changed while suspended (uid %#llx ->
> %#llx)\n",
> - sw->uid, uid);
> - return -ENODEV;
> + /*
> + Â* Check for UID of the connected switches except for root
> + Â* switch which we assume cannot be removed.
> + Â*/
> + if (tb_route(sw)) {
> + u64 uid;
> +
> + err = tb_drom_read_uid_only(sw, &uid);
> + if (err) {
> + tb_sw_warn(sw, "uid read failed\n");
> + return err;
> + }
> + if (sw->uid != uid) {
> + tb_sw_info(sw,
> + "changed while suspended (uid %#llx
> -> %#llx)\n",
> + sw->uid, uid);
> + return -ENODEV;
> + }
> Â }
> Â
> Â /* upload configuration */

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy