Bug 217500 - wireless mouse on usb-hub cause thunderbolt crash when suspend / resume
Summary: wireless mouse on usb-hub cause thunderbolt crash when suspend / resume
Status: CLOSED CODE_FIX
Alias: None
Product: Power Management
Classification: Unclassified
Component: Hibernation/Suspend (show other bugs)
Hardware: IA-64 Linux
: P3 low
Assignee: Rafael J. Wysocki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-29 03:17 UTC by Beld Zhang
Modified: 2023-06-21 18:14 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
kernel dmesg output (119.13 KB, text/plain)
2023-05-29 03:17 UTC, Beld Zhang
Details
kernel config (177.80 KB, text/plain)
2023-05-29 03:18 UTC, Beld Zhang
Details

Description Beld Zhang 2023-05-29 03:17:14 UTC
Created attachment 304344 [details]
kernel dmesg output

DELL XPS 9700

USB-HUB connected to thunderbolt port, and wireless mouse on hub.

latest testing result:
	1) power on without any device
	2) plug in usb-hub, NO crash
		[ 53.###]
	3) plug in mouse, NO crash, works ok
		[114.###]
	4) suspend/resume, CRASH, mouse still working, nic on hub working
		[176.###]


[  176.838341] ------------[ cut here ]------------
[  176.838341] thunderbolt 0000:07:00.0: interrupt for TX ring 0 is already enabled
[  176.838365] WARNING: CPU: 3 PID: 1688 at drivers/thunderbolt/nhi.c:137 ring_interrupt_active+0x249/0x310 [thunderbolt]
[  176.838373] Modules linked in: usbhid r8153_ecm cdc_ether usbnet r8152 mii fuse 8021q garp mrp iptable_nat xt_MASQUERADE nf_nat nf_conntrack nf_defrag_ipv4 ip_tables x_tables efivarfs binfmt_misc snd_soc_sof_sdw snd_soc_intel_hda_dsp_common snd_soc_intel_sof_maxim_common snd_sof_probes snd_soc_rt715 regmap_sdw i915 drm_buddy snd_soc_dmic intel_gtt snd_sof_pci_intel_cnl snd_sof_intel_hda_common snd_sof_pci soundwire_intel soundwire_generic_allocation soundwire_cadence snd_sof_intel_hda_mlink snd_sof_intel_hda snd_sof snd_sof_utils snd_sof_xtensa_dsp snd_soc_acpi_intel_match snd_soc_acpi hid_multitouch snd_soc_hdac_hda hid_generic soundwire_bus snd_hda_codec_generic snd_hda_ext_core ledtrig_audio nouveau snd_hda_codec_hdmi snd_soc_core snd_compress drm_ttm_helper ac97_bus mxm_wmi i2c_algo_bit snd_hda_intel iwlmvm uvcvideo drm_display_helper snd_intel_dspcfg i2c_designware_platform uvc snd_intel_sdw_acpi i2c_designware_core ttm videobuf2_vmalloc mac80211 snd_hda_codec videobuf2_memops btusb libarc4 drm_kms_helper
[  176.838395]  videobuf2_v4l2 snd_hwdep btrtl dell_wmi processor_thermal_device_pci_legacy syscopyarea sparse_keymap btbcm iwlwifi intel_lpss_pci ucsi_ccg intel_soc_dts_iosf snd_hda_core dell_smm_hwmon sysfillrect videodev rtsx_pci_sdmmc dell_smbios btintel processor_thermal_device sysimgblt intel_lpss ucsi_acpi snd_pcm bluetooth processor_thermal_rfim mmc_core cfg80211 processor_thermal_mbox intel_rapl_msr dell_wmi_ddv drm dell_wmi_sysman videobuf2_common i2c_hid_acpi idma64 i2c_i801 typec_ucsi snd_timer kvm_intel processor_thermal_rapl coretemp i2c_nvidia_gpu ecdh_generic evdev video firmware_attributes_class dell_wmi_descriptor wmi_bmof intel_wmi_thunderbolt dcdbas kvm hwmon intel_tcc_cooling x86_pkg_temp_thermal intel_powerclamp irqbypass crc32c_intel ghash_clmulni_intel psmouse serio_raw efi_pstore snd roles i2c_smbus mc soundcore thunderbolt ecc agpgart i2c_ccgx_ucsi rtsx_pci rfkill intel_rapl_common mfd_core intel_pch_thermal typec i2c_hid button battery hid int3403_thermal int340x_thermal_zone pinctrl_cannonlake
[  176.838417]  pinctrl_intel wmi int3400_thermal intel_pmc_core acpi_thermal_rel acpi_tad acpi_pad ac usb_storage
[  176.838420] CPU: 3 PID: 1688 Comm: kworker/u32:20 Not tainted 6.4.0.rc4-dell-0a #1
[  176.838422] Hardware name: Dell Inc. XPS 17 9700/0P1CHN, BIOS 1.11.1 11/18/2021
[  176.838423] Workqueue: events_unbound async_run_entry_fn
[  176.838426] RIP: 0010:ring_interrupt_active+0x249/0x310 [thunderbolt]
[  176.838430] Code: 44 89 44 24 10 e8 97 9f 50 e1 4c 8b 0c 24 44 8b 44 24 10 4c 89 f2 48 8b 4c 24 08 48 89 c6 48 c7 c7 18 56 1c a0 e8 c7 7a f3 e0 <0f> 0b 49 8b 47 08 40 84 ed 44 8b 5c 24 14 48 89 c2 0f 84 fe fe ff
[  176.838431] RSP: 0018:ffffc90001b9bc48 EFLAGS: 00010082
[  176.838432] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[  176.838433] RDX: 0000000000000004 RSI: 0000000000000086 RDI: 00000000ffffffff
[  176.838434] RBP: 0000000000000001 R08: 80000000ffffe5ac R09: 00000000827da614
[  176.838434] R10: ffffffffffffffff R11: ffffffff827da609 R12: 0000000000000001
[  176.838435] R13: 0000000000038200 R14: ffff888101c6d620 R15: ffff88810388a0c0
[  176.838435] FS:  0000000000000000(0000) GS:ffff88887d4c0000(0000) knlGS:0000000000000000
[  176.838436] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  176.838437] CR2: 00007fc47c000010 CR3: 000000000202a004 CR4: 00000000007706e0
[  176.838438] PKRU: 55555554
[  176.838438] Call Trace:
[  176.838439]  <TASK>
[  176.838440]  ? __warn+0x78/0x130
[  176.838442]  ? ring_interrupt_active+0x249/0x310 [thunderbolt]
[  176.838446]  ? report_bug+0x1bf/0x1d0
[  176.838448]  ? handle_bug+0x3c/0x60
[  176.838450]  ? exc_invalid_op+0x14/0x60
[  176.838451]  ? asm_exc_invalid_op+0x16/0x20
[  176.838454]  ? ring_interrupt_active+0x249/0x310 [thunderbolt]
[  176.838458]  ? ring_interrupt_active+0x249/0x310 [thunderbolt]
[  176.838462]  tb_ring_start+0x160/0x300 [thunderbolt]
[  176.838466]  tb_ctl_start+0x29/0xa0 [thunderbolt]
[  176.838471]  ? pci_pm_restore_noirq+0xc0/0xc0
[  176.838473]  tb_domain_runtime_resume+0x15/0x30 [thunderbolt]
[  176.838478]  __rpm_callback+0x41/0x110
[  176.838481]  ? pci_pm_restore_noirq+0xc0/0xc0
[  176.838482]  rpm_callback+0x59/0x70
[  176.838483]  rpm_resume+0x479/0x760
[  176.838485]  ? _raw_spin_unlock_irq+0x13/0x30
[  176.838486]  ? __wait_for_common+0x171/0x1a0
[  176.838487]  ? usleep_range_state+0x90/0x90
[  176.838488]  ? __wait_for_common+0x171/0x1a0
[  176.838489]  ? preempt_count_add+0x68/0xa0
[  176.838491]  __pm_runtime_resume+0x4a/0x80
[  176.838492]  pci_pm_suspend+0x60/0x170
[  176.838494]  ? pci_pm_freeze+0xb0/0xb0
[  176.838495]  dpm_run_callback+0x95/0x1e0
[  176.838496]  __device_suspend+0x130/0x570
[  176.838498]  async_suspend+0x1a/0xa0
[  176.838500]  async_run_entry_fn+0x30/0x120
[  176.838501]  process_one_work+0x1bd/0x3f0
[  176.838503]  worker_thread+0x4d/0x3c0
[  176.838504]  ? rescuer_thread+0x380/0x380
[  176.838505]  kthread+0xee/0x120
[  176.838507]  ? kthread_complete_and_exit+0x20/0x20
[  176.838508]  ret_from_fork+0x1f/0x30
[  176.838510]  </TASK>
[  176.838510] ---[ end trace 0000000000000000 ]---
Comment 1 Beld Zhang 2023-05-29 03:18:28 UTC
Created attachment 304345 [details]
kernel config
Comment 2 Beld Zhang 2023-05-30 01:43:59 UTC
manually apply this patch, tested:

  1) rmmod thunderbolt
  2) modprobe thunderbolt
  3) suspend / resume

all of these NO crash message.


diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 4c9f2811d20d..a11650da40f9 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -60,9 +60,12 @@ static int ring_interrupt_index(const struct tb_ring *ring)
 
 static void nhi_mask_interrupt(struct tb_nhi *nhi, int mask, int ring)
 {
-	if (nhi->quirks & QUIRK_AUTO_CLEAR_INT)
-		return;
-	iowrite32(mask, nhi->iobase + REG_RING_INTERRUPT_MASK_CLEAR_BASE + ring);
+	if (nhi->quirks & QUIRK_AUTO_CLEAR_INT) {
+		u32 val = ioread32(nhi->iobase + REG_RING_INTERRUPT_BASE + ring);
+		iowrite32(val & ~mask, nhi->iobase + REG_RING_INTERRUPT_BASE + ring);
+	} else {
+		iowrite32(mask, nhi->iobase + REG_RING_INTERRUPT_MASK_CLEAR_BASE + ring);
+	}
 }
 
 static void nhi_clear_interrupt(struct tb_nhi *nhi, int ring)
Comment 3 Beld Zhang 2023-05-30 01:48:23 UTC
more: tested with 6.4-rc4.

and... the patch is good, apply fail is my fault: copied from gmail from browser, it convert <TAB> to 8 spaces ...
Comment 4 Beld Zhang 2023-05-30 02:11:11 UTC
apply to 6.1.30, all 3 tests are good.
Comment 5 Beld Zhang 2023-06-21 18:13:51 UTC
patch applied 6.4-rc7 and 6.1.35
Comment 6 Beld Zhang 2023-06-21 18:14:38 UTC
set to closed.

Note You need to log in before you can comment on or make changes to this bug.