Commit graph

661 commits

Author SHA1 Message Date
Greg Kroah-Hartman
7ccecc84ef 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmTkfGsgHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKBDZhAAi7BjitUFsFOv
 6VsNuhztPaO5GKqlDwBfIST2/k6qzdPJSBMwr6biMLcloNkehyRlRPSPgHPEjbv/
 lqF7BkUpg7Ghw164VBq0nU1WKq6u/+HvoZL5Tkacz87ObWyfX7s/BfeOm1nW7++t
 kROG39ZZhLKG1RASqWRJsu3eSZIpbSXD2c7ErnuNRNobPqrx3ts1gS0FBiZwZfG6
 96lG1cSNlujjQFreKIikz/CIgpgCFkdcw5cEieHY13wSNU90gMEcZ1PEKz48eMMI
 E70RrfwEQd8f+M239JLSmer2Kh1dx90RJ8GJKsS4UyxBn07r7FXoBeo3DMaNLKB0
 PIMW5G5dsRJr7tqpOSJIHpprmAMlOL4xMBQ+XlsJiSPYCC+xeFPxVyIqdLdCpxjF
 NWSJExiSDgFkOPJQltu91egFWWQBXXugGxbxkFvQsqwF0JU6oD5XIESVK5Lq3SvT
 xOQdpMQFVXOQCqYTZ2Xc2K/bAO/EYbJVLoRbSBGcwXHyiHe3Vyc4agcCPrxDqbU1
 SxD1GgTU0ooHdkikbIeGEj5VUsMRRNSJVxvUXGZlhh0GCy/c/KYOur2AG9vIwi3T
 RYtik2MY2mtT+wTE1Kb8gmPv4xtog6LpNfEINF+bBat7rUCKO5KlUnLcVJbVmTW4
 lQhBqTv2W9Aki36iewRVPAjZ/7kZMUY=
 =US+s
 -----END PGP SIGNATURE-----

Merge tag 'thunderbolt-for-v6.6-rc1' of 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-22 14:22:35 +02:00
Mika Westerberg
d589fd42cf thunderbolt: Check Intel vendor ID in tb_switch_get_generation()
Only Intel made Thunderbolt 1-3 devices so to avoid possible confusion
check for the Intel vendor ID before deciding the device generation.
While there move the USB4 check to happen first.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-08-08 08:13:17 +03:00
Mika Westerberg
408e1d965a thunderbolt: Log a warning if device links are not found
The software connection manager needs the device links in order to
establish the tunnels before the native protocols so log a warning if
they are not found.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-08-08 08:13:11 +03:00
Mika Westerberg
596a5123cc thunderbolt: Fix memory leak in tb_handle_dp_bandwidth_request()
The memory allocated in tb_queue_dp_bandwidth_request() needs to be
released once the request is handled to avoid leaking it.

Fixes: 6ce3563520 ("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-04 16:17:47 +03:00
Sanjay R Mehta
583893a66d thunderbolt: Fix Thunderbolt 3 display flickering issue on 2nd hot plug onwards
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-08-03 12:57:55 +03:00
Tom Rix
6dacc6db46 thunderbolt: Set variable tmu_params storage class specifier to static
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-07-31 14:12:39 +03:00
Mika Westerberg
481012b479 thunderbolt: Add test case for 3 DisplayPort tunnels
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-16 09:53:29 +03:00
Mika Westerberg
2d7e047297 thunderbolt: Add DisplayPort 2.x tunneling support
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-16 09:53:29 +03:00
Mika Westerberg
8d73f6b8e0 thunderbolt: Make bandwidth allocation mode function names consistent
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-16 09:53:29 +03:00
Mika Westerberg
fd4d58d1fe thunderbolt: Enable CL2 low power state
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-16 09:53:28 +03:00
Mika Westerberg
d49b4f043d thunderbolt: Add support for enhanced uni-directional TMU mode
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-16 09:53:28 +03:00
Gil Fine
322ff701ff thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller
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-16 09:53:28 +03:00
Gil Fine
7c81a578cb thunderbolt: Move constants related to NVM into nvm.c
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-16 09:53:28 +03:00
Mika Westerberg
f2bfa94408 thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
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-16 09:53:28 +03:00
Mika Westerberg
6f14a21066 thunderbolt: Add Intel Barlow Ridge PCI ID
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-16 09:53:28 +03:00
Gil Fine
0209c808a5 thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
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-16 09:53:28 +03:00
Gil Fine
75abb4f5ff thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
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-16 09:53:28 +03:00
Gil Fine
ee22d52aee thunderbolt: Add two additional double words for adapters TMU for USB4 v2 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-16 09:53:28 +03:00
Gil Fine
6e19d48ea0 thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
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-16 09:53:28 +03:00
Gil Fine
14200a2631 thunderbolt: Announce USB4 v2 connection manager support
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-16 09:53:28 +03:00
Mika Westerberg
0fc7088656 thunderbolt: Reset USB4 v2 host router
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-16 09:53:28 +03:00
Mika Westerberg
235d019481 thunderbolt: Add the new USB4 v2 notification types
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-16 09:53:28 +03:00
Gil Fine
e111fb9251 thunderbolt: Add support for USB4 v2 80 Gb/s link
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-16 09:53:27 +03:00
Gil Fine
6e21007d0f thunderbolt: Identify USB4 v2 routers
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-16 09:53:27 +03:00
Mika Westerberg
2ad3e1314c thunderbolt: Do not touch lane 1 adapter path config space
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-16 09:53:27 +03:00
Mika Westerberg
4796efdd16 thunderbolt: Ignore data CRC mismatch for USB4 routers
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-16 09:53:27 +03:00
Mika Westerberg
8720037181 thunderbolt: Enable/disable sideband depending on USB4 port offline mode
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-12 08:38:01 +03:00
Mika Westerberg
b7b83911f7 thunderbolt: Do not send UNSET_INBOUND_SBTX when retimer NVM authentication 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-12 08:38:01 +03:00
Mika Westerberg
1402ba08ab thunderbolt: Read retimer NVM authentication status prior 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-12 08:38:00 +03:00
Mika Westerberg
53ba2e1695 thunderbolt: Disable CL states when a DMA tunnel is established
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-09 12:07:24 +03:00
Mika Westerberg
4a420eb142 thunderbolt: Make tb_switch_clx_disable() return CL states that were enabled
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-09 12:07:24 +03:00
Mika Westerberg
768e6fe69f thunderbolt: Initialize CL states from the hardware
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-09 12:07:24 +03:00
Mika Westerberg
b5d15961d9 thunderbolt: Prefix CL state related log messages with "CLx: "
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-09 12:07:24 +03:00
Mika Westerberg
cb625ec6e5 thunderbolt: Prefix TMU post time log message with "TMU: "
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-09 12:07:24 +03:00
Mika Westerberg
bdc6660e55 thunderbolt: Do not call CLx functions from TMU code
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-09 12:07:23 +03:00
Mika Westerberg
9650de7379 thunderbolt: Check for first depth router in tb.c
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-09 12:07:23 +03:00
Mika Westerberg
3562735306 thunderbolt: Switch CL states from enum to a bitmask
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-09 12:07:23 +03:00
Mika Westerberg
1a9b6cb8b5 thunderbolt: Move CLx enabling into tb_enable_clx()
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-09 12:07:23 +03:00
Mika Westerberg
4f9a4f25ad thunderbolt: Get rid of __tb_switch_[en|dis]able_clx()
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-09 12:07:23 +03:00
Mika Westerberg
12a14f2fca thunderbolt: Move CLx support functions into clx.c
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-09 12:07:23 +03:00
Mika Westerberg
ef34add89e thunderbolt: Check valid TMU configuration in tb_switch_tmu_configure()
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-09 12:07:23 +03:00
Mika Westerberg
4e7b4955cb thunderbolt: Move tb_enable_tmu() close to other TMU functions
This makes the code easier to follow. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09 12:07:23 +03:00
Mika Westerberg
20c2fae9db thunderbolt: Move TMU configuration to tb_enable_tmu()
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-09 12:07:23 +03:00
Mika Westerberg
7d283f4148 thunderbolt: Get rid of tb_switch_enable_tmu_1st_child()
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-09 12:07:22 +03:00
Mika Westerberg
701e73a823 thunderbolt: Rework Titan Ridge TMU objection disable function
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-09 12:07:22 +03:00
Mika Westerberg
826f55d50d thunderbolt: Drop useless 'unidirectional' parameter from 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-09 12:07:22 +03:00
Mika Westerberg
c437dcb183 thunderbolt: Fix a couple of style issues in TMU code
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-09 12:07:22 +03:00
Mika Westerberg
17fb1a3df9 thunderbolt: Introduce tb_xdomain_downstream_port()
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-09 12:07:22 +03:00
Gil Fine
7ce542219b thunderbolt: Introduce tb_switch_downstream_port()
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-09 12:07:22 +03:00
Mika Westerberg
ef65afa074 Merge branch 'thunderbolt/fixes' into thunderbolt/next
We need Thunderbolt/USB4 fixes here as well.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-06-09 12:06:52 +03:00