summaryrefslogtreecommitdiff
path: root/drivers/thunderbolt/tmu.c
AgeCommit message (Collapse)AuthorFilesLines
2023-12-14thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() failsMika Westerberg1-1/+1
Dan reported that the kernel test robot found an issue with the TMU code namely in tb_switch_tmu_change_mode() where we should actually go back to the previous mode in case of failure instead of just returning back the error. Fix this by unwinding the configuration as we do with the other error paths in this function. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202311030814.AXtCk7PO-lkp@intel.com/ Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-09-15thunderbolt: Correct TMU mode initialization from hardwareMika Westerberg1-1/+1
David reported that cppcheck found following possible copy & paste error from tmu_mode_init(): tmu.c:385:50: style: Expression is always false because 'else if' condition matches previous condition at line 383. [multiCondition] And indeed this is a bug. Fix it to use correct index (TB_SWITCH_TMU_MODE_HIFI_UNI). Reported-by: David Binderman <dcb314@hotmail.com> Fixes: d49b4f043d63 ("thunderbolt: Add support for enhanced uni-directional TMU mode") Cc: stable@vger.kernel.org Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-08-22Merge tag 'thunderbolt-for-v6.6-rc1' of ↵Greg Kroah-Hartman1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next Mika writes: thunderbolt: Changes for v6.6 merge window This includes following Thunderbolt/USB4 changes for the v6.6 merge window: - Replace broken mailing list address in the ABI document - Small improvements. All these have been in linux-next with no reported issues. * tag 'thunderbolt-for-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: Documentation/ABI: thunderbolt: Replace 01.org in contact thunderbolt: Check Intel vendor ID in tb_switch_get_generation() thunderbolt: Log a warning if device links are not found thunderbolt: Set variable tmu_params storage class specifier to static
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-07-31thunderbolt: Set variable tmu_params storage class specifier to staticTom Rix1-1/+1
smatch reports drivers/thunderbolt/tmu.c:30:3: warning: symbol 'tmu_params' was not declared. Should it be static? This variable is only used in its defining file so should be static. Signed-off-by: Tom Rix <trix@redhat.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-16thunderbolt: Add support for enhanced uni-directional TMU modeMika Westerberg1-124/+471
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-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: Move CLx support functions into clx.cMika Westerberg1-3/+3
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 Westerberg1-5/+8
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: Get rid of tb_switch_enable_tmu_1st_child()Mika Westerberg1-29/+0
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 Westerberg1-7/+4
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_switch_downstream_port()Gil Fine1-16/+13
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>
2022-06-06thunderbolt: Change TMU mode to HiFi uni-directional once DisplayPort tunneledGil Fine1-0/+29
Here we configure TMU mode to HiFi uni-directional once DP tunnel is created. This is due to accuracy requirement for DP tunneling as appears in CM guide 1.0, section 7.3.2. Due to Intel hardware limitation, once we changed the TMU mode to HiFi uni-directional (when DP tunnel exists), we don't change TMU mode back to normal uni-directional, even if DP tunnel is torn down later. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06thunderbolt: Add CL1 support for USB4 and Titan Ridge routersGil Fine1-27/+150
In this patch we add support for a second low power state of the link: CL1. Low power states (called collectively CLx) are used to reduce transmitter and receiver power when a high-speed lane is idle. We enable it, if both sides of the link support it, and only for the first hop router (i.e. the first device that connected to the host router). This is needed for better thermal management. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06thunderbolt: Change downstream router's TMU rate in both TMU uni/bidir modeGil Fine1-6/+7
In case of uni-directional time sync, TMU handshake is initiated by upstream router. In case of bi-directional time sync, TMU handshake is initiated by downstream router. In order to handle correctly the case of uni-directional mode, we avoid changing the upstream router's rate to off, because it might have another downstream router plugged that is set to uni-directional mode (and we don't want to change its mode). Instead, we always change downstream router's rate. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06thunderbolt: Fix typos in CLx enablingGil Fine1-1/+1
Fix few typos in CLx enabling. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-28thunderbolt: Enable CL0s for Intel Titan RidgeGil Fine1-2/+51
Low power link states (called collectively CLx) are used to reduce transmitter and receiver power when a high-speed lane is idle. The simplest one being called CL0s. Follow what we already do for USB4 device routers and enable CL0s for Intel Titan Ridge device router too. This allows better thermal management. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-22thunderbolt: Implement TMU time disruption for Intel Titan RidgeGil Fine1-7/+13
Intel Titan Ridge based routers have slightly different flow for time disruption than USB4 compliant routers. This makes it work on Titan Ridge too. Needed to enable link low power states on Titan Ridge. Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-22thunderbolt: Add TMU uni-directional modeGil Fine1-46/+228
Up until Titan Ridge (Thunderbolt 3) device routers only supported bi-directional mode. In this patch we add to TMU a uni-directional mode. The uni-directional mode is needed for enabling of low power state of the link (CLx). Signed-off-by: Gil Fine <gil.fine@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2019-12-18thunderbolt: Add support for Time Management UnitRajmohan Mani1-0/+383
Time Management Unit (TMU) is included in each USB4 router. It is used to synchronize time across the USB4 fabric. By default when USB4 router is plugged to the domain, its TMU is turned off. This differs from Thunderbolt (1, 2 and 3) devices whose TMU is by default configured to bi-directional HiFi mode. Since time synchronization is needed for proper Display Port tunneling this means we need to configure the TMU on USB4 compliant devices. The USB4 spec allows some flexibility on how the TMU can be configured. This makes it possible to enable link power management states (CLx) in certain topologies, where for example DP tunneling is not used. TMU can also be re-configured dynamicaly depending on types of tunnels created over the USB4 fabric. In this patch we simply configure the TMU to be in bi-directional HiFi mode. This way we can tunnel any kind of traffic without need to perform complex steps to re-configure the domain dynamically. We can add more fine-grained TMU configuration later on when we start enabling CLx states. Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com> Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Link: https://lore.kernel.org/r/20191217123345.31850-8-mika.westerberg@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>