Commit Graph

715 Commits

Author SHA1 Message Date
Linus Torvalds 8c94ccc7cd USB / Thunderbolt changes for 6.8-rc1
Here is the big set of USB and Thunderbolt changes for 6.8-rc1.
 Included in here are the following:
   - Thunderbolt subsystem and driver updates for USB 4 hardware and
     issues reported by real devices
   - xhci driver updates
   - dwc3 driver updates
   - uvc_video gadget driver updates
   - typec driver updates
   - gadget string functions cleaned up
   - other small changes
 
 All of these have been in the linux-next tree for a while with no
 reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZaedng8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yndHACfX3SA2ipK5umpMsWOoLMCBV6VyrwAn3t+FPd/
 z4mNiCuNUhbEnU7RinK0
 =k/E9
 -----END PGP SIGNATURE-----

Merge tag 'usb-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB / Thunderbolt updates from Greg KH:
 "Here is the big set of USB and Thunderbolt changes for 6.8-rc1.
  Included in here are the following:

   - Thunderbolt subsystem and driver updates for USB 4 hardware and
     issues reported by real devices

   - xhci driver updates

   - dwc3 driver updates

   - uvc_video gadget driver updates

   - typec driver updates

   - gadget string functions cleaned up

   - other small changes

  All of these have been in the linux-next tree for a while with no
  reported issues"

* tag 'usb-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (169 commits)
  usb: typec: tipd: fix use of device-specific init function
  usb: typec: tipd: Separate reset for TPS6598x
  usb: mon: Fix atomicity violation in mon_bin_vma_fault
  usb: gadget: uvc: Remove nested locking
  usb: gadget: uvc: Fix use are free during STREAMOFF
  usb: typec: class: fix typec_altmode_put_partner to put plugs
  dt-bindings: usb: dwc3: Limit num-hc-interrupters definition
  dt-bindings: usb: xhci: Add num-hc-interrupters definition
  xhci: add support to allocate several interrupters
  USB: core: Use device_driver directly in struct usb_driver and usb_device_driver
  arm64: dts: mediatek: mt8195: Add 'rx-fifo-depth' for cherry
  usb: xhci-mtk: fix a short packet issue of gen1 isoc-in transfer
  dt-bindings: usb: mtk-xhci: add a property for Gen1 isoc-in transfer issue
  arm64: dts: qcom: msm8996: Remove PNoC clock from MSS
  arm64: dts: qcom: msm8996: Remove AGGRE2 clock from SLPI
  arm64: dts: qcom: msm8998: Remove AGGRE2 clock from SLPI
  arm64: dts: qcom: msm8939: Drop RPM bus clocks
  arm64: dts: qcom: sdm630: Drop RPM bus clocks
  arm64: dts: qcom: qcs404: Drop RPM bus clocks
  arm64: dts: qcom: msm8996: Drop RPM bus clocks
  ...
2024-01-18 11:43:55 -08:00
Greg Kroah-Hartman 21bea26c84 thunderbolt: Changes for v6.8 merge window
This includes following USB4/Thunderbolt changes for the v6.8 merge
 window:
 
   - Intel Lunar Lake support
   - PCIe tunneling improvements
   - DisplayPort tunneling improvements
   - Asymmetric switching improvements
   - Couple of minor fixes and cleanups.
 
 All these have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmWUAPogHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKDmuhAAgL4vManzvZn4
 OykdKEFG2nl/1r66SnhM1F30qRzoBs3LuFWfEkPr17Lw0u4yR3QccJS39Z2/GuOV
 vXpnSRv8AxWSajpmFiZTTPh7zkRtMkl0PHvyhmjBMBZus+8w5iwWMO3PQtjUY+fl
 2OpCMv/bFDD90PIox4JaYXaHXxuny4ZcT9BuuXx79ZwlRWG0cnRKtX8ythKqOpIV
 +J/Sz0nGjXgIbecjsqa03tFfNZZUi0WNV3XpmrFI2kskW6iVlSgPK4k0+WsCKrNT
 ZWu0EA7J6Uch15kh7CxHXHqywX9RkNmS5HImUS1SUxtiyYdOlS4XC5IcRr9EElss
 LGs//zDkFEfAbD06Ykl7//sL/mGVIJ8o4SqGd/OsnLZapV2v507M+0DJOuyQNHvD
 y3NicERYqVyb/3A+FJcuW8k1gYIEA4LFWoQO3kIfs5mFBu36Q193J3sj/grLu2rc
 DOLGnx8lhHCNvliEqM6kl/h3GnUmF2bqP0jmttszHyn1TWOUo5uYLQcinsSVTh/n
 GNRHJ0vepVLPNLogiSeULgV4gHytPZIF0BnyQ/xBmnyAJYw/un8qWHZTw72DoUA+
 X3BzgcjeNx9NVI0XRZt/iEyiVSFHXfwQ6A7PUATPvrTa64AqEf2dT3j7gkaibor0
 C5csepYZuoX0WIAZMuWX34/NfoB+5i8=
 =N7QT
 -----END PGP SIGNATURE-----

Merge tag 'thunderbolt-for-v6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into char-misc-next

Mika writes:

thunderbolt: Changes for v6.8 merge window

This includes following USB4/Thunderbolt changes for the v6.8 merge
window:

  - Intel Lunar Lake support
  - PCIe tunneling improvements
  - DisplayPort tunneling improvements
  - Asymmetric switching improvements
  - Couple of minor fixes and cleanups.

All these have been in linux-next with no reported issues.

* tag 'thunderbolt-for-v6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: Reduce retry timeout to speed up boot for some devices
  thunderbolt: Keep link as asymmetric if preferred by hardware
  thunderbolt: Add support for Intel Lunar Lake
  thunderbolt: Disable PCIe extended encapsulation upon teardown properly
  thunderbolt: Make PCIe tunnel setup and teardown follow CM guide
  thunderbolt: Improve logging when DisplayPort resource is added due to hotplug
  thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well
  thunderbolt: Disable CL states only when actually needed
  thunderbolt: Transition link to asymmetric only when both sides support it
  thunderbolt: Log XDomain link speed and width
  thunderbolt: Move width_name() helper to tb.h
  thunderbolt: Handle lane bonding of Gen 4 XDomain links properly
  thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
  thunderbolt: Remove duplicated re-assignment of pointer 'out'
2024-01-02 14:25:05 +01:00
Werner Sembach 04b99eac38 thunderbolt: Reduce retry timeout to speed up boot for some devices
This is a followup to "thunderbolt: Workaround an IOMMU fault on certain
systems with Intel Maple Ridge".

It seems like the timeout can be reduced to 250ms. This reduces the overall
delay caused by the retires to ~1s. This is about the time other things
being initialized in parallel need anyway*, so like this the effective boot
time is no longer compromised.

*I only had a single device available for my measurements: A Clevo X170KM-G
desktop replacement notebook.

Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-22 13:00:26 +02:00
Gil Fine ba2a2a86de thunderbolt: Keep link as asymmetric if preferred by hardware
In case of the link is brought up as asymmetric (due to hardware preference), we
honor that and don't transition it to symmetric, unless a router with symmetric
link got plugged below, in the topology (and a bandwidth allows transition to
symmetric).

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-22 12:58:39 +02:00
Greg Kroah-Hartman 8be0c877fb thunderbolt: make tb_bus_type const
Now that the driver core can properly handle constant struct bus_type,
move the tb_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Cc:  <linux-usb@vger.kernel.org>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/2023121904-utopia-broadcast-06d1@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-20 08:21:57 +01:00
Mika Westerberg 2cd3da4e37 thunderbolt: Add support for Intel Lunar Lake
Intel Lunar Lake has similar integrated Thunderbolt/USB4 controller as
Intel Meteor Lake with some small differences in the host router (it has
3 DP IN adapters for instance). Add the Intel Lunar Lake PCI IDs to the
driver list of supported devices.

Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Gil Fine 2b3a6239d2 thunderbolt: Disable PCIe extended encapsulation upon teardown properly
In case of PCIe tunnel teardown (including if caused by router unplug),
PCIe extended encapsulation bit should be cleared in downstream and
upstream routers accordingly.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Gil Fine 54967f4177 thunderbolt: Make PCIe tunnel setup and teardown follow CM guide
The USB4 Connection Manager guide suggests that the PCIe paths are
enabled from the upstream adapter to the downstream adapter and vice
versa on disable so make the driver follows this sequence.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Gil Fine 0b663ec9fe thunderbolt: Improve logging when DisplayPort resource is added due to hotplug
To allow us differentiate how DisplayPort resource is added to the
DisplayPort resources list make the debug log to append "hotplug" when
this was due to an actual hotplug.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Mika Westerberg 97e0a21ce8 thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well
There is no point doing this separately as the register layout is the
same. For this reason rename tb_dp_read_dprx() to tb_dp_wait_dprx() and
call tb_dp_read_cap() instead.

While there add debug log if the DPRX capability read times out.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Mika Westerberg 09dc766bd6 thunderbolt: Disable CL states only when actually needed
If there is not going to be an actual transition to asymmetric or
symmetric, there is no point to disable and re-enable CL states either.
So instead disable them only when we know that an actual transition is
going to take place.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Gil Fine 3c052ec6f4 thunderbolt: Transition link to asymmetric only when both sides support it
We can transition Gen 4 link to asymmetric only when both sides of the
link support it in the required direction. For this reason make sure
that the downstream adapter also supports asymmetric link before
starting the transition.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:45 +02:00
Gil Fine ea20adddd6 thunderbolt: Log XDomain link speed and width
In the same way we do for routers. This is useful for debugging
purposes.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:44 +02:00
Gil Fine 30c6759b23 thunderbolt: Move width_name() helper to tb.h
We are going to use it in subsequent patches, so make it available outside of
switch.c. Also, change the name to tb_width_name() to follow the naming
conventions.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:44 +02:00
Gil Fine 36b6ad6ad0 thunderbolt: Handle lane bonding of Gen 4 XDomain links properly
Gen 4 links come up as bonded already so we are not supposed to initiate
lane bonding on them. However, we should still update the port
structures accordingly. Split these into their own functions to make it
easier to follow.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-14 08:07:44 +02:00
Mika Westerberg 79fff9379e thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
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-12-14 08:07:44 +02:00
Gil Fine f0b94c1c5c thunderbolt: Fix minimum allocated USB 3.x and PCIe bandwidth
With the current bandwidth allocation we end up reserving too much for the USB
3.x and PCIe tunnels that leads to reduced capabilities for the second
DisplayPort tunnel.

Fix this by decreasing the USB 3.x allocation to 900 Mb/s which then allows
both tunnels to get the maximum HBR2 bandwidth.  This way, the reserved
bandwidth for USB 3.x and PCIe, would be 1350 Mb/s (taking weights of USB 3.x
and PCIe into account). So bandwidth allocations on a link are:
USB 3.x + PCIe tunnels => 1350 Mb/s
DisplayPort tunnel #1  => 17280 Mb/s
DisplayPort tunnel #2  => 17280 Mb/s

Total consumed bandwidth is 35910 Mb/s. So that all the above can be tunneled
on a Gen 3 link (which allows maximum of 36000 Mb/s).

Fixes: 582e70b0d3 ("thunderbolt: Change bandwidth reservations to comply USB4 v2")
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-12-08 09:03:49 +02:00
Yaxiong Tian ac43c9122e thunderbolt: Fix memory leak in margining_port_remove()
The dentry returned by debugfs_lookup() needs to be released by calling
dput() which is missing in margining_port_remove(). Fix this by calling
debugfs_lookup_and_remove() that combines both and avoids the memory leak.

Fixes: d0f1e0c2a6 ("thunderbolt: Add support for receiver lane margining")
Cc: stable@vger.kernel.org
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-11-27 12:45:47 +02:00
Mika Westerberg 480713b1ba thunderbolt: Only add device router DP IN to the head of the DP resource list
When pairing DP IN and DP OUT adapters for DisplayPort tunneling, we
should prioritize the possible external GPU DP IN adapters to take
advantage of the its capabilities. However the commit in question did
this for host router DP IN adapters too and that changes ordering of the
initial DP IN resources in such way that resuming from suspend may end
up using different resource and that may confuse the user.

Fix this so that we only put DP IN adapters of device routers to the top
of the resource list and leave host routers as is.

Fixes: 274baf695b ("thunderbolt: Add DP IN added last in the head of the list of DP resources")
Reported-by: Pengfei Xu <pengfei.xu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-11-17 13:05:57 +02:00
Mika Westerberg 5391bcfa56 thunderbolt: Send uevent after asymmetric/symmetric switch
We should send uevent to userspace whenever the link speed or width
changes but tb_switch_asym_enable() and tb_switch_asym_disable() set the
sw->link_width already so tb_switch_update_link_attributes() never
noticed the change.

Fix this so that we let tb_switch_update_link_attributes() update the
fields accordingly.

Fixes: 81af2952e6 ("thunderbolt: Add support for asymmetric link")
Reported-by: Pengfei Xu <pengfei.xu@intel.com>
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-11-17 13:05:57 +02:00
Gil Fine 24d85bb3be thunderbolt: Set lane bonding bit only for downstream port
Fix the lane bonding procedure to follow the steps described in USB4
Connection Manager guide. Hence, set the lane bonding bit only for
downstream port. This is needed for certain ASMedia device, otherwise
lane bonding fails and the device disconnects.

Cc: stable@vger.kernel.org
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-11-17 13:05:57 +02:00
Colin Ian King 655b8af57d thunderbolt: Remove duplicated re-assignment of pointer 'out'
The pointer 'out' is initialized and then a few statements later being
re-assigned the same value. The second re-assignment is redundant and
can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-11-14 14:17:29 +02:00
Linus Torvalds 2c40c1c6ad USB/Thunderbolt changes for 6.7-rc1
Here is the "big" set of USB and Thunderbolt changes for 6.7-rc1.
 Nothing really major in here, just lots of constant development for new
 hardware.  Included in here are:
   - Thunderbolt (i.e. USB4) fixes for reported issues and support for
     new hardware types and devices
   - USB typec additions of new drivers and cleanups for some existing
     ones
   - xhci cleanups and expanded tracing support and some platform
     specific updates
   - USB "La Jolla Cove Adapter (LJCA)" support added, and the gpio, spi,
     and i2c drivers for that type of device (all acked by the respective
     subsystem maintainers.)
   - lots of USB gadget driver updates and cleanups
   - new USB dwc3 platforms supported, as well as other dwc3 fixes and
     cleanups
   - USB chipidea driver updates
   - other smaller driver cleanups and additions, full details in the
     shortlog
 
 All of these have been in the linux-next tree for a while with no
 reported problems, EXCEPT for some merge conflicts that you will run
 into in your tree.  2 of them are in device-tree files, which will be
 trivial to resolve (accept both sides), and the last in the
 drivers/gpio/gpio-ljca.c file, in the remove callback, resolution should
 be pretty trivial (take the version in this branch), see here:
 	https://lore.kernel.org/all/20231016134159.11d8f849@canb.auug.org.au/
 for details, or I can provide a resolved merge point if needed.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZUStew8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykxgQCggUyfGo+JVV8XZVu5A9KwT6nr7mUAmwUgFxhZ
 khK77t0KqF4hjXryeaHa
 =iPd+
 -----END PGP SIGNATURE-----

Merge tag 'usb-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/Thunderbolt updates from Greg KH:
 "Here is the "big" set of USB and Thunderbolt changes for 6.7-rc1.
  Nothing really major in here, just lots of constant development for
  new hardware. Included in here are:

   - Thunderbolt (i.e. USB4) fixes for reported issues and support for
     new hardware types and devices

   - USB typec additions of new drivers and cleanups for some existing
     ones

   - xhci cleanups and expanded tracing support and some platform
     specific updates

   - USB "La Jolla Cove Adapter (LJCA)" support added, and the gpio,
     spi, and i2c drivers for that type of device (all acked by the
     respective subsystem maintainers.)

   - lots of USB gadget driver updates and cleanups

   - new USB dwc3 platforms supported, as well as other dwc3 fixes and
     cleanups

   - USB chipidea driver updates

   - other smaller driver cleanups and additions, full details in the
     shortlog

  All of these have been in the linux-next tree for a while with no
  reported problems"

* tag 'usb-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (167 commits)
  usb: gadget: uvc: Add missing initialization of ssp config descriptor
  usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility
  usb: raw-gadget: report suspend, resume, reset, and disconnect events
  usb: raw-gadget: don't disable device if usb_ep_queue fails
  usb: raw-gadget: properly handle interrupted requests
  usb:cdnsp: remove TRB_FLUSH_ENDPOINT command
  usb: gadget: aspeed_udc: Convert to platform remove callback returning void
  dt-bindings: usb: fsa4480: Add compatible for OCP96011
  usb: typec: fsa4480: Add support to swap SBU orientation
  dt-bindings: usb: fsa4480: Add data-lanes property to endpoint
  usb: typec: tcpm: Fix NULL pointer dereference in tcpm_pd_svdm()
  Revert "dt-bindings: usb: Add bindings for multiport properties on DWC3 controller"
  Revert "dt-bindings: usb: qcom,dwc3: Add bindings for SC8280 Multiport"
  thunderbolt: Fix one kernel-doc comment
  usb: gadget: f_ncm: Always set current gadget in ncm_bind()
  usb: core: Remove duplicated check in usb_hub_create_port_device
  usb: typec: tcpm: Add additional checks for contaminant
  arm64: dts: rockchip: rk3588s: Add USB3 host controller
  usb: dwc3: add optional PHY interface clocks
  dt-bindings: usb: add rk3588 compatible to rockchip,dwc3
  ...
2023-11-03 16:00:42 -10:00
Greg Kroah-Hartman 9b6db9a3a6 thunderbolt: Changes for v6.7 merge window
This includes following USB4/Thunderbolt changes for the v6.7 merge
 window:
 
   - Configure asymmetric link if the DisplayPort bandwidth requires so
   - Enable path power management packet support for USB4 v2 routers
   - Make the bandwidth reservations to follow the USB4 v2 connection
     manager guide suggestions
   - DisplayPort tunneling improvements
   - Small cleanups and improvements around the driver.
 
 All these have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmU6IT8gHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKCP4A//YPiWn0pzbvwB
 cYtkViTHuimKCG++NLWk2kOJG79AfdPfbophwdgBEs55FPb9oWtWtwyWyrGWGCRR
 n6Elts87EfjcFdkVq08tgtPSrqkJSwYEIhm/UHtOrSaw5VJR6Snk5/oHzUttX1W6
 zL7Ii+I+qMjj4Tg6la9EtYV1UrgXy9iCU1IPaKf2KwPZyt8eTly13iEzQhoKzPq2
 pkckjEN8oyqJZFKh/bB0MNezVmCSqtw0X5LWOWDRB3jG9i2e1aaTcCO7Y9amC1Qu
 mLWWOA/U10RFwjocZ+85iPurbymZMBEqvqHY1MJ1m+lQM/W5hjZbvYub/HPSKsHN
 8DwaV/Ty/Dixn5/Epdt1JJtWl53kP/ofmSdRxUFHTDhbb3Jx1QyQdKolV37Z7juZ
 66bFfQ7WDgDiEV7nHXR15uBtp2nvww1BpE6ACyB7BIHBziOaY961bEHDWzhwQmXe
 BhwIBYziEXLxlY4W0/1dFil1OJ4H4c9SA79VR9gSbBwFn+w0FWWthOkvXUl+OXoD
 fCpsiMVm9ZXlJ8SXjXmnqxNEZMSd0Jg+wWTJnjcBmsawPz6Ab56gxZBKTt8CJIL4
 rtFbbQw7dNFS9dSmLlycojoRKyFhrdrZmdyf+7yFH+XD9Xmus0FPCLu2Fsbw6Ifk
 Jxhi+ZGUPEklMNrIQg0EdG9s+j5oZDk=
 =PZEP
 -----END PGP SIGNATURE-----

Merge tag 'thunderbolt-for-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next

Mika writes:

thunderbolt: Changes for v6.7 merge window

This includes following USB4/Thunderbolt changes for the v6.7 merge
window:

  - Configure asymmetric link if the DisplayPort bandwidth requires so
  - Enable path power management packet support for USB4 v2 routers
  - Make the bandwidth reservations to follow the USB4 v2 connection
    manager guide suggestions
  - DisplayPort tunneling improvements
  - Small cleanups and improvements around the driver.

All these have been in linux-next with no reported issues.

* tag 'thunderbolt-for-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (25 commits)
  thunderbolt: Fix one kernel-doc comment
  thunderbolt: Configure asymmetric link if needed and bandwidth allows
  thunderbolt: Add support for asymmetric link
  thunderbolt: Introduce tb_switch_depth()
  thunderbolt: Introduce tb_for_each_upstream_port_on_path()
  thunderbolt: Introduce tb_port_path_direction_downstream()
  thunderbolt: Set path power management packet support bit for USB4 v2 routers
  thunderbolt: Change bandwidth reservations to comply USB4 v2
  thunderbolt: Make is_gen4_link() available to the rest of the driver
  thunderbolt: Use weight constants in tb_usb3_consumed_bandwidth()
  thunderbolt: Use constants for path weight and priority
  thunderbolt: Add DP IN added last in the head of the list of DP resources
  thunderbolt: Create multiple DisplayPort tunnels if there are more DP IN/OUT pairs
  thunderbolt: Log NVM version of routers and retimers
  thunderbolt: Use tb_tunnel_xxx() log macros in tb.c
  thunderbolt: Expose tb_tunnel_xxx() log macros to the rest of the driver
  thunderbolt: Use tb_tunnel_dbg() where possible to make logging more consistent
  thunderbolt: Fix typo of HPD bit for Hot Plug Detect
  thunderbolt: Fix typo in enum tb_link_width kernel-doc
  thunderbolt: Fix debug log when DisplayPort adapter not available for pairing
  ...
2023-10-27 11:41:07 +02:00
Yang Li a558892b34 thunderbolt: Fix one kernel-doc comment
Fix a spelling errors in kernel doc comment, silence the warning:

drivers/thunderbolt/tb.c:760: warning: expecting prototype for tb_maximum_banwidth(). Prototype was for tb_maximum_bandwidth() instead

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7048
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-24 07:49:17 +03:00
Gil Fine 3e36528c11 thunderbolt: Configure asymmetric link if needed and bandwidth allows
USB4 v2 spec defines a Gen 4 link that can operate as an asymmetric
120/40G. When the link is asymmetric, the USB4 port on one side of the
link operates with three TX lanes and one RX lane, while the USB4 port
on the opposite side of the link operates with three RX lanes and one TX
lane. Using asymmetric link we can get much more bandwidth from one
direction and that allows us to support the new Ultra High Bit Rate
DisplayPort modes (that consume up to 77.37 Gb/s).

Add the basic logic for changing Gen 4 links to asymmetric and back
following the below rules:

  1) The default threshold is 45 Gb/s (tunable by asym_threshold)
  2) When DisplayPort tunnel is established, or when there is bandwidth
     request through bandwidth allocation mode, the links can be
     transitioned to asymmetric or symmetric (depending on the
     required bandwidth).
  3) Only DisplayPort bandwidth on a link, is taken into account when
     deciding whether a link is transitioned to asymmetric or symmetric
  4) If bandwidth on a link is >= asym_threshold transition the link to
     asymmetric
  5) If bandwidth on a link < asym_threshold transition the link to
     symmetric (unless the bandwidth request is above currently
     allocated on a tunnel).
  6) If a USB4 v2 device router with symmetric link is connected,
     transition all the links above it to symmetric if the bandwidth
     allows.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Gil Fine 81af2952e6 thunderbolt: Add support for asymmetric link
USB4 v2 spec defines a Gen 4 link that can operate as an aggregated
symmetric (80/80G) or asymmetric (120/40G). When the link is asymmetric,
the USB4 port on one side of the link operates with three TX lanes and
one RX lane, while the USB4 port on the opposite side of the link
operates with three RX lanes and one TX lane.

Add support for the asymmetric link and provide functions that can be
used to transition the link to asymmetric and back.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Mika Westerberg c4ff144369 thunderbolt: Introduce tb_switch_depth()
This is useful helper to find out the depth of a connected router.
Convert the existing users to call this helper instead of open-coding.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Mika Westerberg 956c3abe72 thunderbolt: Introduce tb_for_each_upstream_port_on_path()
This is useful when walking over upstream lane adapters over given path.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Gil Fine 2bfeca73e9 thunderbolt: Introduce tb_port_path_direction_downstream()
Introduce tb_port_path_direction_downstream() to check if path from
source adapter to destination adapter is directed towards downstream.
Convert existing users to call this helper instead of open-coding.

No functional changes.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Mika Westerberg ce91d793ab thunderbolt: Set path power management packet support bit for USB4 v2 routers
USB4 v2 spec allows USB4 links that are part of a pass through tunnel
(such as DisplayPort and USB 3.x Gen T) to enter lower CL states, which
provide better power management. For this USB4 v2 routers in their path
config space of lane 0 adapter include a new bit PMPS (PM packet
support) that needs to be set.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Gil Fine 582e70b0d3 thunderbolt: Change bandwidth reservations to comply USB4 v2
USB4 v2 Connection Manager guide (section 6.1.2.3) suggests to reserve
bandwidth in a sligthly different manner. It suggests to keep minimum of
1500 Mb/s for each path that carry a bulk traffic. Here we change the
bandwidth reservations to comply to the above for USB 3.x and PCIe
protocols over Gen 4 link, taking weights into account (that's 1500 Mb/s
for PCIe and 3000 Mb/s for USB 3.x).

For Gen 3 and below we use the existing reservation.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Gil Fine aa673d6060 thunderbolt: Make is_gen4_link() available to the rest of the driver
Rework the function to return the link generation, update the name to
tb_port_get_link_generation(), and make available to the rest of the
driver. This is needed in the subsequent patches.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:01 +03:00
Mika Westerberg 4d24db0c80 thunderbolt: Use weight constants in tb_usb3_consumed_bandwidth()
Instead of magic numbers use the constants we introduced in the previous
commit to make the code more readable. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:00 +03:00
Mika Westerberg f73edddfa2 thunderbolt: Use constants for path weight and priority
Makes it easier to follow and update. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-20 18:18:00 +03:00
Greg Kroah-Hartman 8b695369a6 thunderbolt: Fix for v6.6-rc7
This includes a single commit that fixes a memory leak when DisplayPort
 bandwidth allocation request is being handled by the driver.
 
 This has been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmUulYsgHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKA6RA/+NZ2xVqKwHVrT
 mnTj04uDFTPxNAmYvu2mBzNY3mQoILbimai7epHsohyVs4R8Y+gyZqYtJEN+b6gH
 2QJ8CLrydJ/YcKAiTnVg1ZT1HYlXJHbMbt2J1+rovC4hkmkHh5FWWRony6Ouilgv
 sK6LGYEBxRhyOsoma4pvE6Q51ntmLHSW9o/kjMkffdLoQ8QhOjymc5OT4uDk3Jad
 C8Fee0egkc6YfdCM2bQX3K0Nrs1yAxW7aWzfjgUeM5TYADhhOZx5n9vTXFSW312a
 C5DP2Kn8MkhXgILMk5Ye4fHmY5foCAyiJRAnl9p/bQSKrPN99PbgBxGdXZcw6lhf
 hUQk2jZVJDCCR0e2bMQLi4+qmyJj/zUJ7HCoyX5OdVBzQbRHjhD8G+ZlX8MpWoTr
 0J0St4/GzrEfZ/VaxT3ZW2GzrM0IFnrTJQaXFkQZiiBfsqvThOVpfrOqWSK/J8Nh
 vdpKf9waF/mb5/C5pIe1d2jowX4aTolpV62wlQpKdAy6MbDOGyrVfFNHHuCPECha
 UQCvaEXf72AuyCIQtxi1+dkjiBULF39p2K6h9mj2IaI6W+XCdF4tdGVubQB6DA3E
 2z/437fD8WPecsP5lz8iDhJlE7ThrPp+yy49/ugnzhmfqlxQM1RUbiQt4XzDLozR
 ibaaFGQ5aX333vkI+dqJe12cOY7Rq9E=
 =+UeU
 -----END PGP SIGNATURE-----

Merge tag 'thunderbolt-for-v6.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus

Mika writes:

thunderbolt: Fix for v6.6-rc7

This includes a single commit that fixes a memory leak when DisplayPort
bandwidth allocation request is being handled by the driver.

This has been in linux-next with no reported issues.

* tag 'thunderbolt-for-v6.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: Call tb_switch_put() once DisplayPort bandwidth request is finished
2023-10-17 19:25:42 +02:00
Gil Fine 274baf695b thunderbolt: Add DP IN added last in the head of the list of DP resources
If DP IN on device router exist, position it at the beginning of the DP
resources list, so that it is used before DP IN on host router. This way
external GPU will be prioritized when pairing DP IN and DP OUT for
DisplayPort tunnel setup.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:14 +03:00
Gil Fine 8648c6465c thunderbolt: Create multiple DisplayPort tunnels if there are more DP IN/OUT pairs
Currently we only create one DisplayPort tunnel even if there would be
more DP IN/OUT pairs available. Specifically this happens when a router
is unplugged and we check if a new DisplayPort tunnel can be created. To
cover this create tunnels as long as we find suitable DP IN/OUT pairs.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Gil Fine d80d926c5b thunderbolt: Log NVM version of routers and retimers
This is useful when debugging possible issues.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg 34c5def565 thunderbolt: Use tb_tunnel_xxx() log macros in tb.c
Now that the macros are available we can use them in tb.c. This makes
the log output more consistent.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg d27bd2c37d thunderbolt: Expose tb_tunnel_xxx() log macros to the rest of the driver
In order to allow more consistent logging of tunnel related information
make these logging macros available to the rest of the driver.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg fe8a0293c9 thunderbolt: Use tb_tunnel_dbg() where possible to make logging more consistent
This makes it easier to find out the tunnel in question. Also drop a
couple of lines that generate duplicate information.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Gil Fine 6ed0b900d8 thunderbolt: Fix typo of HPD bit for Hot Plug Detect
Fix typo of HPD bit stands for Hot Plug Detect.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Gil Fine 6b8ac54f31 thunderbolt: Fix debug log when DisplayPort adapter not available for pairing
Fix debug log when looking for a DisplayPort adapter pair of DP IN and
DP OUT. In case of no DP adapter available, log the type of the DP
adapter that is not available.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg 9e4f5b2af2 thunderbolt: Check for unplugged router in tb_switch_clx_disable()
There is no point disabling CL states if the router is unplugged so in
that case return early.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg 35c9ab4fd6 thunderbolt: Make tb_switch_clx_is_supported() static
This function is not used outside of clx.c so make it static. No
functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg 92b8f7a1b1 thunderbolt: Get rid of usb4_usb3_port_actual_link_rate()
It turns out there is no need to use the actual link rate when
reclaiming bandwidth for USB 3.x. The reason is that we use consumed
bandwidth which is coming from xHCI when releasing bandwidth (for
example for DisplayPort tunneling) and this can be anything between
1000 Mb/s to maximum, so when reclaiming we can just bump it up back to
maximum instead of actual link rate (which is always <= maximum).

This allows us to get rid of couple of unnecessary lines of code.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:13 +03:00
Mika Westerberg 7b304040c8 thunderbolt: dma_test: Use enum tb_link_width
Since we have it, use it in the DMA test driver as well.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-13 08:49:12 +03:00
Gil Fine ec4405ed92 thunderbolt: Call tb_switch_put() once DisplayPort bandwidth request is finished
When handling DisplayPort bandwidth request tb_switch_find_by_route() is
called and it returns a router structure with reference count increased.
In order to avoid resource leak call tb_switch_put() when finished.

Fixes: 6ce3563520 ("thunderbolt: Add support for DisplayPort bandwidth allocation mode")
Cc: stable@vger.kernel.org
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-10-05 12:06:50 +03:00
Mika Westerberg 0c35ac1825 thunderbolt: Apply USB 3.x bandwidth quirk only in software connection manager
This is not needed when firmware connection manager is run so limit this
to software connection manager.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-09-15 13:04:43 +03:00