Re: [PATCH v2 2/7] thunderbolt: Make the DP tunnel activation callback mandatory
Mika Westerberg <[email protected]>
| Newsgroups | dev.linux.lists.asahi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-usb,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Aug 23, 2026 at 06:09:15PM +0200, Sven Peter wrote:
> tb_tunnel_alloc_dp() takes an optional callback which is run from
> dprx_work once the DPRX capabilities read has completed. Without that
> callback tb_dp_dprx_start() reads the capabilities synchronously and
> never queues the work. It however always takes a tunnel reference which
> is only dropped by dprx_work itself or by tb_dp_dprx_stop() when
> cancel_delayed_work() actually canceled that work. That reference is
> thus leaked for every tunnel without a callback.
>
> The only tunnels without one are those from tb_tunnel_discover_dp(),
> which are activated again when restoring from hibernation.
> Pass the callback to tb_tunnel_discover_dp() as well and drop the
> synchronous path such that the DPRX capabilities are always read from
> dprx_work. Hibernation restore then also no longer blocks for up to 12
> seconds while waiting for that read to complete.
>
> Also fix up the KUnit tests.
>
> Fixes: d6d458d42e1e ("thunderbolt: Handle DisplayPort tunnel activation asynchronously")
> Cc: [email protected]
> Signed-off-by: Sven Peter <[email protected]>
> ---
> drivers/thunderbolt/tb.c | 4 +++-
> drivers/thunderbolt/test.c | 37 +++++++++++++++++++++++-----------
> drivers/thunderbolt/tunnel.c | 47 ++++++++++++++++++++++++--------------------
> drivers/thunderbolt/tunnel.h | 8 +++++---
> 4 files changed, 60 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index f43f2d952372..29b9879c40d8 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -89,6 +89,7 @@ static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port,
> const char *reason);
> static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port,
> int retry, unsigned long delay);
> +static void tb_dp_tunnel_active(struct tb_tunnel *tunnel, void *data);
If possible move the whole function here instead of forward declaration.
>
> static void tb_queue_hotplug(struct tb *tb, u64 route, u8 port, bool unplug)
> {
> @@ -385,7 +386,8 @@ static void tb_switch_discover_tunnels(struct tb_switch *sw,
>
> switch (port->config.type) {
> case TB_TYPE_DP_HDMI_IN:
> - tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids);
> + tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids,
> + tb_dp_tunnel_active, tb);