From: Sven Peter Date: Sat, 29 Aug 2026 10:08:38 +0200 Subject: [PATCH v3 6/7] thunderbolt: Tear down inactive DP tunnels when the domain is stopped MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260829-b4-tbt-fixes-v3-6-e1fab6ac54fe@kernel.org> References: <20260829-b4-tbt-fixes-v3-0-e1fab6ac54fe@kernel.org> In-Reply-To: <20260829-b4-tbt-fixes-v3-0-e1fab6ac54fe@kernel.org> To: Andreas Noever , Mika Westerberg , Yehezkel Bernat Cc: Mika Westerberg , Konrad Dybcio , asahi@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2083; i=sven@kernel.org; h=from:subject:message-id; bh=gM3ljiZ7OeI79gnw2yBh74ko5W+e/3qUprdtBSuU7QU=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9akyf217AeWne+VvSM8pZ3F4dm3jWfzVOTqDrbu1FHYP kexp/J0RykLgxgXg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAisu6MDB+2Zk/dP51x+4rz Z18/XCAWaRK7Ll7uTvTESbefdF6fZZnF8IdL7K3lC87FzPN7ny7d4WnzMHLe2sfGzxa6/U5Q9Gj SMOYGAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 List-Id: B4 Relay Submissions tb_stop only tears down DMA tunnels so a DP tunnel that is still waiting for dprx_work to complete keeps that work queued while the routers are removed and the control channel is stopped. The work only stops once the DPRX timeout has passed and because it requeues itself until then the flush_workqueue in tb_domain_remove won't wait for its final run. The callback then runs against a domain that is already torn down. A reference to that domain is kept so the completion waiting for that domain to disappear in unbind will block until the timeout is eventually reached. Tear down DP tunnels that are not active yet as well which also cancels that work. Tunnels for displays that are already alive are untouched and keep working. Fixes: d6d458d42e1e ("thunderbolt: Handle DisplayPort tunnel activation asynchronously") Cc: stable@vger.kernel.org Signed-off-by: Sven Peter --- I also didn't run into this but noticed it when fixing the hop alloc thing and think it makes sense to fix it anyway. --- drivers/thunderbolt/tb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 088323cd876d..921adba3544f 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -2958,12 +2958,14 @@ static void tb_stop(struct tb *tb) /* tunnels are only present after everything has been initialized */ list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { /* - * DMA tunnels require the driver to be functional so we - * tear them down. Other protocol tunnels can be left - * intact. + * DMA tunnels and DP tunnels which are not yet active require + * the driver to be functional so we tear them down. + * Other protocol tunnels can be left intact. */ if (tb_tunnel_is_dma(tunnel)) tb_tunnel_deactivate(tunnel); + else if (tb_tunnel_is_dp(tunnel) && !tb_tunnel_is_active(tunnel)) + tb_tunnel_deactivate(tunnel); tb_tunnel_put(tunnel); } tb_switch_remove(tb->root_switch); -- 2.55.0