Re: [PATCH v3 12/36] thunderbolt: Properly disable path

From: Lukas Wunner
Date: Sun Mar 31 2019 - 11:25:07 EST


On Thu, Mar 28, 2019 at 03:36:09PM +0300, Mika Westerberg wrote:
> +static int __tb_path_deactivate_hop(struct tb_port *port, int hop_index)
> +{
> + struct tb_regs_hop hop;
> + ktime_t timeout;
> + int ret;
> +
> + if (port->sw->is_unplugged)
> + return 0;

This check is basically a duplication of the checks added in patch 4 ...


> +
> + /* Disable the path */
> + ret = tb_port_read(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2);
> + if (ret)
> + return ret;
[...]
> static void __tb_path_deactivate_hops(struct tb_path *path, int first_hop)
> {
> int i, res;
> - struct tb_regs_hop hop = { };
> +
> for (i = first_hop; i < path->path_length; i++) {
> - res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
> - 2 * path->hops[i].in_hop_index, 2);
> + res = __tb_path_deactivate_hop(path->hops[i].in_port,
> + path->hops[i].in_hop_index);
> if (res)
> tb_port_warn(path->hops[i].in_port,
> "hop deactivation failed for hop %d, index %d\n",

... however you return 0 above to avoid the warning here whereas the checks
added in patch 4 return -ENODEV. You may want to change "if (res)" to
"if (res && res != -ENODEV)" and drop the unplugged check in
__tb_path_deactivate_hop().

Thanks,

Lukas