Bug 219420

Summary: Unreadable thunderbolt nvm_version under sysfs
Product: Drivers Reporter: AceLan Kao (acelan)
Component: PCIAssignee: drivers_pci (drivers_pci)
Status: NEW ---    
Severity: normal CC: hugh712, max.lee, mika.westerberg, Ruby.Hsiao
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: screenshot when encounter the issue
dmesg with thunderbolt dyndbg
v6.12-rc4 kernel config
Add only on-board retimers

Description AceLan Kao 2024-10-23 02:22:43 UTC
Created attachment 307042 [details]
screenshot when encounter the issue

Kernel: v6.11 & 6.12-rc4
Upgrading the TBT firmware through fwupdmgr and encounter the error as the screenshot shows.
It was working well with 6.8 kernel.

ubuntu@localhost:~$ sudo fwupdtool get-updates
Loading…                 [******************                     ]02:20:03.374 FuEngine             failed to add device /sys/devices/pci0000:00/0000:00:0d.3/domain1/1-0/1-1/usb4_port1/1-1:1.1: failed to read NVM
Loading…                 [*********************                  ]02:20:03.479 FuPluginIntelMe      failed to get public key using file-id 0x40002300: generic failure [0xb]
Loading…                 [************************************** ]

ubuntu@localhost:~$ find /sys/devices/pci0000:00/0000:00:0d.3/ -name nvm_version | xargs grep ''
grep: /sys/devices/pci0000:00/0000:00:0d.3/domain1/1-0/1-1/usb4_port1/1-1:1.1/nvm_version: Operation not supported
/sys/devices/pci0000:00/0000:00:0d.3/domain1/1-0/1-1/nvm_version:38.0
/sys/devices/pci0000:00/0000:00:0d.3/domain1/1-0/usb4_port1/1-0:1.1/nvm_version:23.81
Comment 1 Mika Westerberg 2024-10-23 07:34:40 UTC
Can you attach the steps, full dmesg with "thunderbolt.dyndbg=+p" in the kernel command line and also the hardware details?

Also since it works on v6.8, can you try to bisect this?
Comment 2 AceLan Kao 2024-10-23 07:47:37 UTC
Created attachment 307055 [details]
dmesg with thunderbolt dyndbg

Here is the dmesg with thunderbolt.dyndbg=+p

I can bisect the kernel if there is no further tests need me to try.
Comment 3 Max Lee 2024-10-23 07:59:00 UTC
Supplement for the device,
The device is Dell Thunderbolt Dock - WD22TB4, It doesn't have retimer in the physical hardware after the GR, so expected the nvm_version node is not able to read.
Comment 4 Mika Westerberg 2024-10-23 08:49:27 UTC
The Lunar Lake host side has retimer that's the 1-0:1.1 device, however, 1-1:1.1 is same device from downstream perspective but this is not expected to be exposed in any production kernels. Do you accidentally have CONFIG_USB4_DEBUGFS_MARGINING=y in your kernel .config?
Comment 5 AceLan Kao 2024-10-24 02:41:47 UTC
Created attachment 307064 [details]
v6.12-rc4 kernel config

This is the kernel config file I use to build the kernel.
The option is not enabled.
Comment 6 Mika Westerberg 2024-10-24 09:35:08 UTC
Created attachment 307065 [details]
Add only on-board retimers

Indeed, it turns out even if that config option is not set we accidentally expose retimers on the other side of the cable.

Can you try the attached patch? You should see the on-board retimer of Lunar Lake but not anymore the same from different direction (the :1.1 device).
Comment 7 hugh chao 2024-10-28 06:24:53 UTC
(In reply to Mika Westerberg from comment #6)
> Created attachment 307065 [details]
> Add only on-board retimers
> 
> Indeed, it turns out even if that config option is not set we accidentally
> expose retimers on the other side of the cable.
> 
> Can you try the attached patch? You should see the on-board retimer of Lunar
> Lake but not anymore the same from different direction (the :1.1 device).

Verified the patch works,
below is the output without this patch:

root@u:/sys/bus/thunderbolt/devices/domain1# find -name nvm_version
./1-0/1-1/usb4_port1/1-1:1.1/nvm_version
./1-0/1-1/nvm_version
./1-0/usb4_port1/1-0:1.1/nvm_version
root@u:/sys/bus/thunderbolt/devices/domain1# find -name nvm_version | xargs cat -
cat: './1-0/1-1/usb4_port1/1-1:1.1/nvm_version': Operation not supported
41.81
23.81

and below is the output with this patch

root@u:/sys/bus/thunderbolt/devices/domain1# find -name nvm_version
./1-0/1-1/nvm_version
./1-0/usb4_port1/1-0:1.1/nvm_version
root@u:/sys/bus/thunderbolt/devices/domain1# find -name nvm_version | xargs cat -
41.81
23.81
Comment 8 AceLan Kao 2024-10-28 09:55:21 UTC
Applied on top of thunderbolt/fixes and verified the issue is gone with the patch.
Thank Mika.

Tested-By: AceLan Kao <acelan.kao@canonical.com>