Linux USB
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: "Achim Löbbert" <aloebbert@gmx.de>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [REGRESSION/BUG] thunderbolt: ASM4242 fails to restore DP tunnel after resume on Ryzen 8700G (7.4-rc4)
Date: Mon, 30 Nov 2026 22:29:52 -0600	[thread overview]
Message-ID: <23779328-dbcf-4e22-a6c0-3ad79a367b9d@kernel.org> (raw)
In-Reply-To: <M_M6ExAFSL2bkAE8yye4Lg@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 4964 bytes --]

On 11/30/26 13:16, Achim Löbbert wrote:
> Hi Mario,
> 
> On Sunday, 29. November 2026 04:36:45 CET Mario Limonciello wrote:
>>
>> A few ideas.
>>
>> 1) Can you force a modeset after resume?  You can do this with a CLI
>> tool like modetest if you don't have a drm master running.  Or you can
>> do it from your compositor (like kwin or mutter).
> 
> No, because after resume kscreen-doctor complains that there are no output
> screens. Sorry for not providing exact output but it aborts momentarily after
> resume when remotely accessing the machine by ssh.
> 
> Before suspend it produced this:
> Output: 1 DP-2 68382564-284f-4c12-80de-9c08948d1c05
>      enabled
>      connected
>      priority 1
>      DisplayPort
>      replication source:0
>      Modes:  1:3840x2160@60.00!  2:3840x2160@120.00*  3:3840x2160@119.88
> 4:3840x2160@120.00  5:3840x2160@60.00  6:3840x2160@59.94  7:3840x2160@50.00
> 8:3840x2160@30.00  9:3840x2160@29.97  10:3840x2160@25.00  11:3840x2160@24.00
> 12:3840x2160@23.98  13:2560x1440@120.00  14:2560x1440@59.95
> 15:1920x1200@59.88  16:1920x1080@120.00  17:1920x1080@119.88
> 18:1920x1080@60.00  19:1920x1080@60.00  20:1920x1080@59.94  21:1920x1080@50.00
> 22:1920x1080@30.00  23:1920x1080@29.97  24:1920x1080@25.00  25:1920x1080@24.00
> 26:1920x1080@23.98  27:1600x1200@60.00  28:1680x1050@59.95  29:1600x900@60.00
> 30:1280x1024@75.03  31:1280x1024@60.02  32:1280x800@59.81  33:1152x864@75.00
> 34:1280x720@60.00  35:1280x720@59.94  36:1280x720@50.00  37:1024x768@75.03
> 38:1024x768@60.00  39:800x600@75.00  40:800x600@60.32  41:720x576@50.00
> 42:720x480@60.00  43:720x480@59.94  44:640x480@75.00  45:640x480@60.00
> 46:640x480@59.94  47:640x480@59.94
>      Custom modes: None
>      Geometry: 0,0 2649x1490
>      Scale: 1.45
>      Rotation: 1
>      Overscan: 0
>      Vrr: Never
>      RgbRange: Automatic
>      HDR: incapable
>      Wide Color Gamut: incapable
>      ICC profile: none
>      Color profile source: sRGB
>      Color power preference: prefer efficiency and performance
>      Brightness control: supported, set to 40% and dimming to 100%
>      Color resolution: automatic (10), range: [8; 16] bits per color
>      Allow EDR: unsupported
>      Sharpness control: unsupported
>      Automatic brightness: unsupported
>      Auto Rotate Policy: incapable
>      Adaptive backlight modulation: unsupported
> 
>> If a modeset makes it work I'd guess we're missing an HPD event to
>> trigger all the GPU driver actions.  Maybe at the end of
>> tb_add_dp_resources()?  Or right after where it was placed in
>> tb_restore_children()?  Not sure.
> 
> Related to this, output of
> $ for i in /sys/class/drm/card0-DP-*/status; do echo "$i: $(cat $i)"; done
> 
> Before suspend:
> /sys/class/drm/card0-DP-1/status: disconnected
> /sys/class/drm/card0-DP-2/status: connected
> /sys/class/drm/card0-DP-3/status: disconnected
> /sys/class/drm/card0-DP-4/status: disconnected
> /sys/class/drm/card0-DP-5/status: disconnected
> /sys/class/drm/card0-DP-6/status: disconnected
> 
> After resume:
> /sys/class/drm/card0-DP-1/status: disconnected
> /sys/class/drm/card0-DP-2/status: disconnected
> /sys/class/drm/card0-DP-3/status: disconnected
> /sys/class/drm/card0-DP-4/status: disconnected
> /sys/class/drm/card0-DP-5/status: disconnected
> /sys/class/drm/card0-DP-6/status: disconnected
> 
>> 2) I guess I would say try drm.debug=0x106 and then let's see what
>> events show up during the resume cycle to confirm this too.
> 
> Please find dmesg with with 'drm.debug=0x106 thunderbolt.dyndbg=+p' attached.
> Seems like verbosity made dmesg ringbufer overflow, but the suspend/resume
> cycle is still contained.
> 
> One more observation, the following suspend/resume script seems to fix it:
> means a single keypress wakes the system up and the unlock screen is displayed
> after about 20-50 seconds randomly, but very reliably:
> 
> #!/bin/sh
> # File: /etc/elogind/system-sleep/99-bolt-wake.sh
> 
> # USB controller: ASMedia Technology Inc. ASM4242 USB 4 / Thunderbolt 3 Host
> Router (rev 01)
> PCI_ADDR="0000:71:00.0"
> 
> case "$1" in
>    pre)  # suspend
>      if [ -e "/sys/bus/pci/drivers/thunderbolt/$PCI_ADDR" ]; then
>        echo "$PCI_ADDR" > /sys/bus/pci/drivers/thunderbolt/unbind
>      fi
>      ;;
>    post)  #resume
>      if [ ! -e "/sys/bus/pci/drivers/thunderbolt/$PCI_ADDR" ]; then
>        echo "$PCI_ADDR" > /sys/bus/pci/drivers/thunderbolt/bind
>      fi
>      # Wait up to 5s for the USB4 DP tunnel + amdgpu hotplug to report
> "connected"
>      for (( i=0; $i < 50; i++ )); do
>        if grep -q "^connected$" /sys/class/drm/card0-DP-*/status 2>/dev/null;
> then
>          break
>        fi
>        sleep 0.1
>      done
>      ;;
> esac
> 
> BR, Achim

Can you have a try with this patch to force replug events?  I think it 
should help on top of Mika's other inline patch.  Whether it should be a 
quirk or some other form can be up for discussion.  Let's see if the 
concept works.

[-- Attachment #2: 0001-thunderbolt-Re-plug-ASM4242-DP-tunnels-once-system-r.patch --]
[-- Type: text/x-patch, Size: 8528 bytes --]

From a170b8a638b464cb6bbbbd6e8ea9e16f2007f655 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <mario.limonciello@amd.com>
Date: Mon, 30 Nov 2026 22:25:05 -0600
Subject: [PATCH] thunderbolt: Re-plug ASM4242 DP tunnels once system resume is
 complete
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Even with the DP IN resources added back during resume, the Dell U3225QE
connected to an ASMedia ASM4242 host router on a Ryzen 8700G desktop
only comes back after the first suspend/resume cycle. On the following
cycles the DP tunnel is established just fine but amdgpu keeps reporting
every DP connector as disconnected until the host router is unbound and
bound again from a post-resume hook.

The logs from the working and the failing cycles are identical from the
thunderbolt point of view. What is different is the timing relative to
the GPU driver. The thunderbolt driver resumes in the noirq phase and
the DP tunnel is re-created right after that. The DP IN adapter does
not assert HPD toward the DP source before its DPRX capabilities read
is complete, which on the ASM4242 takes close to a second:

  [  139.707417] thunderbolt 0000:71:00.0: resume finished
  [  139.709975] thunderbolt 0000:71:00.0: 0:10 <-> 1:13 (DP): activating
  [  140.587569] amdgpu 0000:72:00.0: [drm] DMUB hardware initialized: version=0x08006500
  [  140.688304] thunderbolt 0000:71:00.0: 0:10 <-> 1:13 (DP): DPRX capabilities read completed
  [  140.883827] PM: resume devices took 0.990 seconds

That is exactly when amdgpu runs its resume time connector detection
(about 0.9 s after the thunderbolt resume in the drm.debug log). When
the HPD comes after the detection but before the HPD interrupts are
enabled again the plug is simply lost, and the monitor stays black.
Re-binding the driver after resume works reliably because the tunnel,
and therefore the HPD, then comes after the GPU is fully resumed.

Force a HPD toward the DP source from the PM complete() callback, which
runs after every driver has resumed: tear down the DP tunnels that were
created while the system was resuming and create them again. This
de-asserts HPD toward the GPU and asserts it again once the new tunnel
is up, which the GPU driver now handles as an ordinary hotplug.

Limit this to the ASM4242 with a quirk for now. Intel host routers send
plug events for the DP IN adapters themselves and no problems have been
reported with them, so there is no reason to add an extra unplug/plug
cycle to those.

Reported-by: Achim Löbbert <aloebbert@gmx.de>
Link: https://lore.kernel.org/linux-usb/UCVQtIkrSxeOKGOgiChTpA@gmx.de/
---
 drivers/thunderbolt/quirks.c | 15 ++++++++
 drivers/thunderbolt/tb.c     | 73 ++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/tb.h     |  5 +++
 3 files changed, 93 insertions(+)

diff --git a/drivers/thunderbolt/quirks.c b/drivers/thunderbolt/quirks.c
index 2722918e0e095..8712fa466481c 100644
--- a/drivers/thunderbolt/quirks.c
+++ b/drivers/thunderbolt/quirks.c
@@ -52,6 +52,12 @@ static void quirk_block_rpm_in_redrive(struct tb_switch *sw)
 	tb_sw_dbg(sw, "preventing runtime PM in DP redrive mode\n");
 }
 
+static void quirk_dp_replug_after_resume(struct tb_switch *sw)
+{
+	sw->quirks |= QUIRK_DP_REPLUG_AFTER_RESUME;
+	tb_sw_dbg(sw, "re-plugging DP tunnels after system resume\n");
+}
+
 static void quirk_stuck_pending(struct tb_switch *sw)
 {
 	struct tb_port *port;
@@ -135,6 +141,15 @@ static const struct tb_quirk tb_quirks[] = {
 	 * interface adapter.
 	 */
 	{ 0x174c, 0x2428, 0x0000, 0x0000, quirk_stuck_pending },
+	/*
+	 * ASMedia ASM4242 DP IN adapters do not generate plug events and
+	 * they assert HPD toward the DP source only once the DP tunnel is
+	 * established and the DPRX capabilities read has completed. After
+	 * system resume that happens while the GPU driver may still be
+	 * resuming, so the GPU can miss the HPD and the monitor stays
+	 * black. Re-plug the DP tunnels once resume is complete.
+	 */
+	{ 0x174c, 0x2428, 0x0000, 0x0000, quirk_dp_replug_after_resume },
 };
 
 /**
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index ea569e554d49e..d5cadd13ad76c 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -57,6 +57,9 @@ MODULE_PARM_DESC(asym_threshold,
  *		    events and exit if this is not set (it needs to
  *		    acquire the lock one more time). Used to drain wq
  *		    after cfg has been paused.
+ * @dp_replug_pending: DP tunnels established while the system was
+ *		       resuming need to be re-plugged once the resume
+ *		       is complete (see tb_complete()).
  * @remove_work: Work used to remove any unplugged routers after
  *		 runtime resume
  * @groups: Bandwidth groups used in this domain.
@@ -65,6 +68,7 @@ struct tb_cm {
 	struct list_head tunnel_list;
 	struct list_head dp_resources;
 	bool hotplug_active;
+	bool dp_replug_pending;
 	struct delayed_work remove_work;
 	struct tb_bandwidth_group groups[MAX_GROUPS];
 };
@@ -3229,6 +3233,8 @@ static int tb_resume_noirq(struct tb *tb)
 	tb_switch_enter_redrive(tb->root_switch);
 	 /* Allow tb_handle_hotplug to progress events */
 	tcm->hotplug_active = true;
+	/* DP tunnels created from here on may need to be re-plugged */
+	tcm->dp_replug_pending = true;
 	tb_dbg(tb, "resume finished\n");
 
 	return 0;
@@ -3250,8 +3256,70 @@ static int tb_thaw_noirq(struct tb *tb)
 	return 0;
 }
 
+/*
+ * tb_replug_dp_tunnels() - Force HPD toward the DP source after resume
+ * @tb: Domain structure
+ *
+ * DP tunnels are re-established early during system resume, from
+ * tb_resume_noirq() and the hotplug events processed right after it.
+ * The DP IN adapter asserts HPD toward the DP source (GPU) only once
+ * the tunnel is up and, on USB4, after the DPRX capabilities read has
+ * completed. That can land in the middle of the GPU driver resume,
+ * after it has already done its connector detection but before it is
+ * ready to handle hotplug interrupts, so the plug is lost and the
+ * monitor stays black.
+ *
+ * This is called from the PM complete() callback, after all drivers
+ * have resumed. Tear down and re-create the DP tunnels of the routers
+ * that need it. This de-asserts the HPD toward the DP source and
+ * asserts it again once the new tunnel is up, which the GPU driver now
+ * handles as a normal hotplug.
+ */
+static void tb_replug_dp_tunnels(struct tb *tb)
+{
+	struct tb_cm *tcm = tb_priv(tb);
+	struct tb_tunnel *tunnel, *n;
+	bool replug = false;
+
+	lockdep_assert_held(&tb->lock);
+
+	list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) {
+		struct tb_switch *sw;
+
+		if (!tb_tunnel_is_dp(tunnel))
+			continue;
+
+		sw = tunnel->src_port->sw;
+		if (!(sw->quirks & QUIRK_DP_REPLUG_AFTER_RESUME))
+			continue;
+
+		tb_tunnel_dbg(tunnel, "re-plugging to force HPD toward DP source\n");
+		tb_deactivate_and_free_tunnel(tunnel);
+		replug = true;
+	}
+
+	if (!replug)
+		return;
+
+	/* The DP IN/OUT adapters are still in the resource list, pair them again */
+	tb_recalc_estimated_bandwidth(tb);
+	tb_tunnel_dp(tb);
+}
+
 static void tb_complete(struct tb *tb)
 {
+	struct tb_cm *tcm = tb_priv(tb);
+
+	/*
+	 * All drivers, including the ones for the DP sources, have
+	 * resumed by now so it is safe to re-plug the DP tunnels.
+	 */
+	if (tcm->dp_replug_pending) {
+		tcm->dp_replug_pending = false;
+		scoped_guard(mutex, &tb->lock)
+			tb_replug_dp_tunnels(tb);
+	}
+
 	/*
 	 * Unregister unplugged XDomains and if there is a case where
 	 * another domain is swapped in place of unplugged XDomain we
@@ -3307,6 +3375,11 @@ static int tb_runtime_resume(struct tb *tb)
 		tb_tunnel_activate(tunnel);
 	tb_switch_enter_redrive(tb->root_switch);
 	tcm->hotplug_active = true;
+	/*
+	 * If we get here from nhi_complete() the DP source drivers have
+	 * already resumed so no need to re-plug the DP tunnels.
+	 */
+	tcm->dp_replug_pending = false;
 	mutex_unlock(&tb->lock);
 
 	/*
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 8ed373e94b652..6b295f8e69c28 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -26,6 +26,11 @@
 #define QUIRK_NO_CLX					BIT(1)
 /* Need to keep power on while USB4 port is in redrive mode */
 #define QUIRK_KEEP_POWER_IN_DP_REDRIVE			BIT(2)
+/*
+ * Re-plug DP tunnels of the router once system resume is complete so
+ * that the DP source (GPU) does not miss the HPD.
+ */
+#define QUIRK_DP_REPLUG_AFTER_RESUME			BIT(3)
 
 /**
  * struct tb_nvm - Structure holding NVM information
-- 
2.43.0


      reply	other threads:[~2026-12-01  4:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:10 [REGRESSION/BUG] thunderbolt: ASM4242 fails to restore DP tunnel after resume on Ryzen 8700G (7.4-rc4) Achim Löbbert
2026-11-26  7:31 ` Mika Westerberg
2026-11-26  8:53   ` Achim Löbbert
2026-11-26 12:27     ` Mika Westerberg
2026-11-26 16:59       ` Achim Löbbert
2026-11-27  5:35         ` Mika Westerberg
2026-11-27 18:13           ` Achim Löbbert
2026-11-29  3:36             ` Mario Limonciello
2026-11-30 19:16               ` Achim Löbbert
2026-12-01  4:29                 ` Mario Limonciello [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23779328-dbcf-4e22-a6c0-3ad79a367b9d@kernel.org \
    --to=superm1@kernel.org \
    --cc=aloebbert@gmx.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox