Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion drivers/net/thunderbolt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,8 +1521,16 @@ static void tbnet_remove(struct tb_service *svc)
{
struct tbnet *net = tb_service_get_drvdata(svc);

unregister_netdev(net->dev);
/*
* Take the protocol handler off the list before the interface goes
* down, so that ThunderboltIP packets arriving during the teardown
* no longer reach this device and queue new login, connect or
* disconnect work for it.
*/
tb_unregister_protocol_handler(&net->handler);
unregister_netdev(net->dev);
/* A logout received while the interface was down queued this. */
cancel_work_sync(&net->disconnect_work);
free_netdev(net->dev);
}

Expand Down
11 changes: 11 additions & 0 deletions drivers/thunderbolt/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,17 @@ void tb_domain_remove(struct tb *tb)

flush_workqueue(tb->wq);

/*
* Stopping the connection manager removed the XDomains from the
* topology and marked them unplugged, but they are still on the bus
* with their service drivers bound. Unregister them now: a service
* driver keeps its protocol handler registered until it is unbound
* and would otherwise keep answering XDomain requests through
* tb->ctl after the domain is gone. The control channel is stopped,
* so whatever the service drivers send while unbinding fails at once.
*/
tb_domain_unregister_unplugged_xdomains(tb);

if (tb->cm_ops->deinit)
tb->cm_ops->deinit(tb);

Expand Down
14 changes: 12 additions & 2 deletions drivers/thunderbolt/tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3161,12 +3161,22 @@ static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
struct tb_switch *sw;
int ret;

mutex_lock(&tb->lock);

/*
* A service driver can still ask for paths after the XDomain was
* unplugged or while the domain is being stopped, when the router
* may already be gone and tb->root_switch is NULL.
*/
if (xd->is_unplugged || !tb->root_switch) {
mutex_unlock(&tb->lock);
return -ENODEV;
}

sw = tb_to_switch(xd->dev.parent);
dst_port = tb_port_at(xd->route, sw);
nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI);

mutex_lock(&tb->lock);

/*
* When tunneling DMA paths the link should not enter CL states
* so disable them now.
Expand Down
Loading