summaryrefslogtreecommitdiff
path: root/drivers/thunderbolt
AgeCommit message (Collapse)AuthorFilesLines
2023-08-04thunderbolt: Fix memory leak in tb_handle_dp_bandwidth_request()Mika Westerberg1-0/+2
The memory allocated in tb_queue_dp_bandwidth_request() needs to be released once the request is handled to avoid leaking it. Fixes: 6ce3563520be ("thunderbolt: Add support for DisplayPort bandwidth allocation mode") Cc: stable@vger.kernel.org Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-08-03thunderbolt: Fix Thunderbolt 3 display flickering issue on 2nd hot plug onwardsSanjay R Mehta1-1/+3
Previously, on unplug events, the TMU mode was disabled first followed by the Time Synchronization Handshake, irrespective of whether the tb_switch_tmu_rate_write() API was successful or not. However, this caused a problem with Thunderbolt 3 (TBT3) devices, as the TSPacketInterval bits were always enabled by default, leading the host router to assume that the device router's TMU was already enabled and preventing it from initiating the Time Synchronization Handshake. As a result, TBT3 monitors experienced display flickering from the second hot plug onwards. To address this issue, we have modified the code to only disable the Time Synchronization Handshake during TMU disable if the tb_switch_tmu_rate_write() function is successful. This ensures that the TBT3 devices function correctly and eliminates the display flickering issue. Co-developed-by: Sanath S <Sanath.S@amd.com> Signed-off-by: Sanath S <Sanath.S@amd.com> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add test case for 3 DisplayPort tunnelsMika Westerberg1-0/+83
Intel Barlow Ridge Thunderbolt controller has 3 DP IN adapters. This allows 3 simultaneus DisplayPort tunnels through either one or two USB4 downstream ports (in any possible configuration). Add test case for this. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add DisplayPort 2.x tunneling supportMika Westerberg2-16/+87
This adds support for the UHBR (Ultra High Bit Rate) bandwidths introduced with DisplayPort 2.0 (and refined in 2.1). These can go up to 80 Gbit/s and their support is represent in additional bits in the DP IN capability. This updates the DisplayPort tunneling to support these new rates too. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Make bandwidth allocation mode function names consistentMika Westerberg4-46/+52
Make sure the DisplayPort bandwidth allocation mode function names are consistent with the existing ones, such as USB3. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Enable CL2 low power stateMika Westerberg2-15/+25
For USB4 v2 routers we can also enable CL2 which allows better power savings and thermal management than CL0s and CL1. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add support for enhanced uni-directional TMU modeMika Westerberg6-173/+614
This is new TMU mode introduced with the USB4 v2. This mode is simpler than the existing ones and allows all CL states as well. Enable this for all links where both side routers are v2 and keep the existing functionality for the v1 and earlier links. Currently only support the MedRes rate. We can add the HiFi rate later too if it turns out to be useful. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controllerGil Fine1-1/+1
Intel Barlow Ridge discrete USB4 controller has larger NOR Flash, hence increase NVM_MAX_SIZE to support it. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Move constants related to NVM into nvm.cGil Fine3-9/+10
Move constants related to NVM into nvm.c to make the code cleaner. Use a separate constant for USB4_DATA_DWORDS in usb4.c. No functional changes. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Limit Intel Barlow Ridge USB3 bandwidthMika Westerberg2-0/+10
Intel Barlow Ridge discrete USB4 host router has the same limitation as the previous generations so make sure the USB3 bandwidth limitation quirk is applied to Barlow Ridge too. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add Intel Barlow Ridge PCI IDMika Westerberg2-0/+4
Intel Barlow Ridge is the first USB4 v2 controller from Intel. The controller exposes standard USB4 PCI class ID in typical configurations, however there is a way to configure it so that it uses a special class ID to allow using s different driver than the Windows inbox one. For this reason add the Barlow Ridge PCI ID to the Linux driver too so that the driver can attach regardless of the class ID. Tested-by: Pengfei Xu <pengfei.xu@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Fix PCIe adapter capability length for USB4 v2 routersGil Fine1-2/+6
For USB4 v2 routers, the PCIe adapter capability length is longer. Display the correct capability length in the debugfs register dump. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routersGil Fine1-5/+8
For USB4 v2 routers, the DisplayPort IN adapter capability length is longer. Display the correct capability length in the debugfs register dump. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add two additional double words for adapters TMU for USB4 v2 ↵Gil Fine1-2/+6
routers For USB4 v2 routers, the adapters's TMU capability has two additional double words. Include them in the debugfs register dump. Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulationGil Fine4-3/+70
USB4 v2 spec introduces modified encapsulation of PCIe TLP and DLLP packets. This improves the PCIe tunneled traffic usage by reducing overhead. Enable this if both sides of the link support it. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Announce USB4 v2 connection manager supportGil Fine2-2/+9
Program the CMUV (Connection Manager USB4 Version) field for USB4 v2 and v1 routers according to the spec. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Reset USB4 v2 host routerMika Westerberg2-8/+50
USB4 v2 added a bit that can be used to reset the host router so we use this to trigger reset when the driver probes. This will reset the already connected topology as well but doing this simplifies things a lot if for instance the link is already set to asymmetric. We also add a module parameter to prevent this in case of problems. While there rename the REG_HOP_COUNT to REG_CAPS to match the USB4 spec naming better. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add the new USB4 v2 notification typesMika Westerberg3-4/+48
USB4 v2 spec adds a bunch of new notifications that the connection manager can use instead of polling. While we do not use these yet we need to ack the ones routers expect to be acked. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add support for USB4 v2 80 Gb/s linkGil Fine7-86/+250
USB4 v2 bumps the per-lane speed up to 40 Gb/s. Also the lanes are always bonded which gives 80 Gb/s symmetric link (and 120/40 Gb/s asymmetric). This updates the speed and width of routers and XDomain connections to support the Gen 4 link. For now we keep the link as is even if it is already asymmetric. While there make tb_port_set_link_width() static. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Identify USB4 v2 routersGil Fine3-15/+28
Add a new function usb4_switch_version() that can be used to figure out the spec version of the router and make tb_switch_is_usb4() to use it as well. Update the uevent accordingly. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Do not touch lane 1 adapter path config spaceMika Westerberg1-1/+1
It is not required to be implemented at all because USB4 does not use lane 1 for tunneling except when aggregated with lane 0. For this reason do not try to read the path config space of USB4 lane 1 adapters. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Ignore data CRC mismatch for USB4 routersMika Westerberg1-2/+1
This is also something not always updated after the DROM contents itself so issue warning but continue parsing it as we do for pre-USB4 DROMs too. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-12thunderbolt: Enable/disable sideband depending on USB4 port offline modeMika Westerberg2-0/+24
When USB4 port is in offline mode (this mean there is no device attached) we want to keep the sideband up to make it possible to communicate with the retimers. In the same way there is no need to enable sideband transactions when the USB4 port is not offline as they are already up. For this reason make the enabling/disabling depend on the USB4 port offline status. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-12thunderbolt: Do not send UNSET_INBOUND_SBTX when retimer NVM authentication ↵Mika Westerberg1-1/+9
started Once retimer NVM authentication is started, sending UNSET_INBOUND_SBTX will fail so avoid doing that. Only send it when we are writing an image with not authentication or when the authentication failed early. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-12thunderbolt: Read retimer NVM authentication status prior ↵Mika Westerberg1-8/+21
tb_retimer_set_inbound_sbtx() According to the USB4 retimer guide the correct order is immediately after sending ENUMERATE_RETIMERS so update the code to follow this. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Disable CL states when a DMA tunnel is establishedMika Westerberg2-6/+58
Tunnels between hosts should not have CL states enabled because otherwise they might enter a low power state without the other end noticing which causes packets to be lost. For this reason disable all CL states upon first DMA tunnel creation. Once the last DMA tunnel is torn down we try to re-enable them. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Make tb_switch_clx_disable() return CL states that were enabledMika Westerberg2-13/+30
This allows us to disable all CL states temporarily when running lane margining and then return back the previously enabled states. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Initialize CL states from the hardwareMika Westerberg3-27/+78
In case the boot firmware enabled any of them, read the currently configured CL states and update the router structure accordingly. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Prefix CL state related log messages with "CLx: "Mika Westerberg1-4/+4
This makes it easier to spot from the logs and follows what we do with the TMU code already. We also log enabling/disabling CL states using the tb_sw_dbg() instead of tb_port_dbg(). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Prefix TMU post time log message with "TMU: "Mika Westerberg1-1/+1
Following what we do with other messages in this file. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Do not call CLx functions from TMU codeMika Westerberg1-23/+0
There is really no need to call any of the CLx functions in the TMU code so remove all these checks. This makes the TMU enable/disable flows easier to follow as well. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Check for first depth router in tb.cMika Westerberg2-16/+16
Currently tb_switch_clx_enable() enables CL states only for the first depth router. This is something we may want to change in the future and in addition it is not visible from the calling path at all. For this reason do the check in the tb.c so it is immediately visible that we only do this for the first depth router. Fix the kernel-docs accordingly. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Switch CL states from enum to a bitmaskMika Westerberg4-119/+113
This is more natural and follows the hardware register layout better. This makes it easier to see which CL states we enable (even though they should be enabled together). Rename 'clx_mask' to 'clx' everywhere as this is now always bitmask. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Move CLx enabling into tb_enable_clx()Mika Westerberg1-17/+17
This avoids some duplication and makes the flow slightly easier to understand. Also follows what we do in tb_enable_tmu(). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Get rid of __tb_switch_[en|dis]able_clx()Mika Westerberg1-49/+42
No need to have separate functions for these so fold them into tb_switch_clx_enable() and tb_switch_clx_disable() accordingly. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Move CLx support functions into clx.cMika Westerberg7-378/+381
There really don't belong to switch.c so move them into their own file. As we do this rename the functions to match the conventions used elsewhere in the driver. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Check valid TMU configuration in tb_switch_tmu_configure()Mika Westerberg3-10/+14
Instead of at enable time we can do this already in tb_switch_tmu_configure(). Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Move tb_enable_tmu() close to other TMU functionsMika Westerberg1-29/+29
This makes the code easier to follow. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Move TMU configuration to tb_enable_tmu()Mika Westerberg1-20/+10
There is no need to duplicate the code the enables TMU. Also update the comment to better explain why we do this in the first place. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Get rid of tb_switch_enable_tmu_1st_child()Mika Westerberg3-40/+34
This is better to be part of the software connection manager flows in tb.c. Also name the new function tb_increase_tmu_accuracy() to match what it actually does. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Rework Titan Ridge TMU objection disable functionMika Westerberg1-14/+10
Now this is split into two with one having a misleading name (tb_switch_tmu_unidirectional_enable()). Make this easier to read, rename and consolidate the two functions into one with name that explains what it actually does. Use the two constants as well that were added but never used to make it clear which bits are being set. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Drop useless 'unidirectional' parameter from ↵Mika Westerberg3-14/+9
tb_switch_tmu_is_enabled() There is no point passing it as we already have a field for that. While there clean up the kernel-doc of things that do not really belong to the API documentation (these can be figured out from the spec itself). No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Fix a couple of style issues in TMU codeMika Westerberg1-12/+11
Drop extra empty line and get rid of the '__' in function names. No functional changes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Introduce tb_xdomain_downstream_port()Mika Westerberg2-9/+18
In the same way we did for the routers add a function that returns the parent routers downstream facing port for XDomain devices. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09thunderbolt: Introduce tb_switch_downstream_port()Gil Fine7-55/+53
Introduce tb_switch_downstream_port() helper function that returns the downstream port of a parent switch that is connected to the upstream port of specified switch. From now on, we use it all across the driver where applicable. While there fix a whitespace in comment and rename 'downstream' to 'down' to be consistent with the rest of the driver. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09Merge branch 'thunderbolt/fixes' into thunderbolt/nextMika Westerberg4-13/+25
We need Thunderbolt/USB4 fixes here as well. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-05-31thunderbolt: Mask ring interrupt on Intel hardware as wellMika Westerberg1-3/+8
When resuming from system sleep states the driver issues following warning on Intel hardware: thunderbolt 0000:07:00.0: interrupt for TX ring 0 is already enabled The reason for this is that the commit in question did not mask the ring interrupt on Intel hardware leaving the interrupt active. Fix this by masking it also in Intel hardware. Reported-by: beld zhang <beldzhang@gmail.com> Tested-by: beld zhang <beldzhang@gmail.com> Closes: https://lore.kernel.org/linux-usb/ZHKW5NeabmfhgLbY@debian.me/ Fixes: c4af8e3fecd0 ("thunderbolt: Clear registers properly when auto clear isn't in use") Cc: stable@vger.kernel.org Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-05-30thunderbolt: Log DisplayPort adapter rate and lanes on discoveryMika Westerberg1-0/+43
This may be helpful when debugging possible issues around DisplayPort port tunneling. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-05-29thunderbolt: Do not touch CL state configuration during discoveryMika Westerberg1-5/+12
If the boot firmware has already established tunnels, especially ones that have special requirements from the link such as DisplayPort, we should not blindly enable CL states (nor change the TMU configuration). Otherwise the existing tunnels may not work as expected. For this reason, skip the CL state enabling when we go over the existing topology. This will also keep the TMU settings untouched because we do not change the TMU configuration when CL states are not enabled. Reported-by: Koba Ko <koba.ko@canonical.com> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7831 Cc: stable@vger.kernel.org # v6.0+ Acked-By: Yehezkel Bernat <YehezkelShB@gmail.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-05-29thunderbolt: Increase DisplayPort Connection Manager handshake timeoutMika Westerberg1-1/+1
It turns out that when plugging in VGA cable through USB-C to VGA/DVI dongle the Connection Manager handshake can take longer time, at least on Intel Titan Ridge based docks such as Dell WD91TB. This leads to following error in the dmesg: thunderbolt 0000:00:0d.3: 3:10: DP tunnel activation failed, aborting and the display stays blank (because we failed to establish the tunnel). For this reason increase the timeout to 3s. Reported-by: Koba Ko <koba.ko@canonical.com> Cc: stable@vger.kernel.org Acked-By: Yehezkel Bernat <YehezkelShB@gmail.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>