Hello Mike, Thanks for your reply, Yes, I see a problem in my case, because When " tb_cfg_get_upstream_port", " upstream_port" variable gets updated with wrong value not the actual "upstream port" corresponding value in the Router configuration space of the USB4 host controller. Regards, Mohamed -----Original Message----- From: mika.westerberg@xxxxxxxxxxxxxxx <mika.westerberg@xxxxxxxxxxxxxxx> Sent: Thursday, February 29, 2024 2:31 PM To: Rayan, Mohamed (DI SW ICS MNA RD HAV4 VER) <mohamed.rayan@xxxxxxxxxxx> Cc: andreas.noever@xxxxxxxxx; michael.jamet@xxxxxxxxx; YehezkelShB@xxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx; Samy, Mohamed (DI SW ICS MNA RD HAV4) <mohamed.samy@xxxxxxxxxxx>; El Nahas, Mohamed (DI SW ICS MNA RD HAV4) <mohamed.el_nahas@xxxxxxxxxxx>; Hassan, Ahmed (DI SW ICS MNA RD HAV4 HW) <ahmed_mohammed@xxxxxxxxxxx> Subject: Re: Inquiry about tb/usb4 driver Hi, On Thu, Feb 29, 2024 at 12:18:31PM +0000, mohamed.rayan@xxxxxxxxxxx wrote: > Hello, > > > > Hope this mail finds you well, It does but sending HTML has some issues if the receiver such as me uses text based mail client ;-) > I am sending this mail asking you for some help in the usage of tb/usb4 > driver, > > I have downloaded this driver for kernel v6.5 to install it with a certain > USB4 host controller, Here is the driver link: > > [1]https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fe > lixir.bootlin.com%2Flinux%2Fv6.5%2Fsource%2Fdrivers%2Fthunderbol&data= > 05%7C02%7Cmohamed.rayan%40siemens.com%7C1c2fa047920349b1524608dc392243 > 2f%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C0%7C638448066550189604%7CU > nknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > WwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=d1OOH9C3dVRNlwo%2FEEXyKDvQ2s4xboR > 1TMiBV2m9MbU%3D&reserved=0 > > > > I have found something not clear to me in "switch.c", and exactly at line > #2260: "[2]tb_switch_alloc", which is responsible for allocating and > initialization a switch: > > 1- This function has a local variable called "upstream_port" > > 2- A "tb_cfg_get_upstream_port" is first called to get the value > of "upstream_port" from Switch config space > > 3- When I checked "tb_cfg_get_upstream_port" function, I found > that it reads first DW (DW#0) of the router configuration space > > 4- In USB4 standard specifications, the first DW of the router > config space is Vendor/Product IDs, not the Upstream Adapter, please > check the below snapshot from USB4 standard > > 5- Later in the code of the "[3]tb_switch_alloc" function, at line#2297, this value of "upstream_port" is used to overwrite another variable in the struct as follow: > > > > > > > > > > 6- So at the end, "sw->config.upstream_port_number" will get updated with incorrect settings, So I am wondering if this is an expected behavior, Am I missing something? This is historic to support Thunderbolt 1-3 devices where the upstream port could change. In USB4 routers it is read-only. Do you see any real issue with this?