Now that we have generic functionality available in nvm.c make the DMA
port code call it instead of duplicating the functionality.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We do this for Thunderbolt 2/3 devices through DMA port, USB4 devices
and retimers pretty much the same way. Only the actual block read/write
is different. For this reason split out the NVM read/write functions
from usb4.c to nvm.c and make USB4 device code call these when needed.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Add new device known to support self-authenticate on disconnect.
Signed-off-by: Crag Wang <crag.wang@dell.com>
Reviewed-by: Mario Limonciello <mario.limonciello@outlook.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Up to 64 bytes of data can be read from NVM in one go.
Read address must be dword aligned. Data is read into a local buffer.
If caller asks to read data starting at an unaligned address then full
dword is anyway read from NVM into a local buffer. Data is then copied
from the local buffer starting at the unaligned offset to the caller
buffer.
In cases where asked data length + unaligned offset is over 64 bytes
we need to make sure we don't read past the 64 bytes in the local
buffer when copying to caller buffer, and make sure that we don't
skip copying unaligned offset bytes from local buffer anymore after
the first round of 64 byte NVM data read.
Fixes: b04079837b ("thunderbolt: Add initial support for USB4")
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Up to 64 bytes of data can be read from NVM in one go. Read address
must be dword aligned. Data is read into a local buffer.
If caller asks to read data starting at an unaligned address then full
dword is anyway read from NVM into a local buffer. Data is then copied
from the local buffer starting at the unaligned offset to the caller
buffer.
In cases where asked data length + unaligned offset is over 64 bytes
we need to make sure we don't read past the 64 bytes in the local
buffer when copying to caller buffer, and make sure that we don't
skip copying unaligned offset bytes from local buffer anymore after
the first round of 64 byte NVM data read.
Fixes: 3e13676862 ("thunderbolt: Add support for DMA configuration based mailbox")
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This includes following Thunderbolt/USB4 changes for v5.13 merge window:
* Debugfs improvements
* Align the inter-domain (peer-to-peer) support with the USB4
inter-domain spec for better interoperability
* Add support for USB4 DROM and the new product descriptor
* More KUnit tests
* Detailed uevent for routers
* Few miscellaneous improvements
All these have been in linux-next without reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmB1aWcgHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKB01g/+N8mjL2V4Bvfi
uKQJGsuK+5Bbg1x51Hx8tjxG2I75QMzImoikYJlq99ttPC/+/sBJeXbfPp4yZZQ8
9dxKoXlAu7Ij43/5VNwb9IhMsCktzTsLEsOS0brp4xS5zLAnTKhps4sM8h8pcSgF
IYcNs0thBXoGL9dOOKfRjst4Zs+ksH4wE/FSS581y2dVu3jzqEYRM0O+hSWt6Ekz
UJrt1DJ63coFKqHdHBG2Vnxj1q3+f5S+crGgjVvoDqVLBeur9JGuenllxKfgtJ9k
jKW9pm5P4F5k6l4t7SPk7y10GHmif8JnCJ4zZX4mb29CrgdtG3+P92stkwCWaP1b
yxeLuWv3lOWJrDKdt29cC4tKGCMM3HTsVGOdFHI8IaLOodazMHFXonKSrlaFBRBX
eP94i4OrgR6lmuBD2w5u15LosNJSr7TeCmvDakKW90S3jVohDSS4AfVw4euk1cdu
k0AIJYzmoADdfxY4bHVJ8ZdmUQoRHOMMCpUIAc+nQiP8bGHh9sVx+SRqbEA2BZu1
BrJ5x/zi72We10SySNzMW9l2CL9PTDUIKtebLov0F5kiCFGTGQOqLU8ps3A+r6sR
GB0Dk9mjyozNE88EhjxquzbStm1Mxf2ahvlGSntEk0+5trdbHHK7axPb6ormcQVX
W66XT9bGQ0wyb+qvxY6D/X7lrk3sXXc=
=RzJl
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v5.13 merge window
This includes following Thunderbolt/USB4 changes for v5.13 merge window:
* Debugfs improvements
* Align the inter-domain (peer-to-peer) support with the USB4
inter-domain spec for better interoperability
* Add support for USB4 DROM and the new product descriptor
* More KUnit tests
* Detailed uevent for routers
* Few miscellaneous improvements
All these have been in linux-next without reported issues.
* tag 'thunderbolt-for-v5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (24 commits)
thunderbolt: Hide authorized attribute if router does not support PCIe tunnels
thunderbolt: Add details to router uevent
thunderbolt: Unlock on error path in tb_domain_add()
thunderbolt: Add support for USB4 DROM
thunderbolt: Check quirks in tb_switch_add()
thunderbolt: Add KUnit tests for DMA tunnels
thunderbolt: Add KUnit tests for XDomain properties
net: thunderbolt: Align the driver to the USB4 networking spec
thunderbolt: Allow multiple DMA tunnels over a single XDomain connection
thunderbolt: Drop unused tb_port_set_initial_credits()
thunderbolt: Use dedicated flow control for DMA tunnels
thunderbolt: Add support for maxhopid XDomain property
thunderbolt: Add tb_property_copy_dir()
thunderbolt: Align XDomain protocol timeouts with the spec
thunderbolt: Use pseudo-random number as initial property block generation
thunderbolt: Do not re-establish XDomain DMA paths automatically
thunderbolt: Add more logging to XDomain connections
Documentation / thunderbolt: Drop speed/lanes entries for XDomain
thunderbolt: Decrease control channel timeout for software connection manager
thunderbolt: Do not pass timeout for tb_cfg_reset()
...
With USB4 devices PCIe tunneling is optional so for device routers
without PCIe upstream adapter it does not make much sense to expose the
authorized attribute. For this reason hide it if PCIe tunneling is not
supported by the device router.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Expose two environment variables for routers as part of the initial
uevent:
USB4_VERSION=1.0
USB4_TYPE=host|device|hub
Userspace can use this information to expose more details about each
connected device. Only USB4 devices have USB4_VERSION but all devices
have USB4_TYPE.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This array uses 1-based indexing so it corrupts memory one element
beyond of the array. Fix it by making the array one element larger.
Fixes: dacb12877d ("thunderbolt: Add support for on-board retimers")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
After the device_register() succeeds, then the correct way to clean up
is to call device_unregister(). The unregister calls both device_del()
and device_put(). Since this code was only device_del() it results in
a memory leak.
Fixes: dacb12877d ("thunderbolt: Add support for on-board retimers")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We accidentally deleted this unlock on the error path. Undelete it.
Fixes: 7f0a34d790 ("thunderbolt: Decrease control channel timeout for software connection manager")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
USB4 router DROM differs sligthly from Thunderbolt 1-3 DROM. For
instance it does not include UID and CRC8 in the header section, and it
has product descriptor genereric entry to describe the product IDs and
related information. If the "Version" field in the DROM header section
reads 3 it means the router only has USB4 DROM and if it reads 1 it
means the router supports TBT3 compatible DROM.
For this reason, update the DROM parsing code to support "pure" USB4
DROMs too.
While there drop the extra empty line at the end of tb_drom_read().
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently we have had an artificial limitation of a single DMA tunnel
per XDomain connection. However, hardware wise there is no such limit
and software based connection manager can take advantage of all the DMA
rings available on the host to establish tunnels.
For this reason make the tb_xdomain_[enable|disable]_paths() to take the
DMA ring and HopID as parameter instead of storing them in the struct
tb_xdomain. We also add API functions to allocate input and output
HopIDs of the XDomain connection that the service drivers can use
instead of hard-coding.
Also convert the two existing service drivers over to this API.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The USB4 inter-domain service spec recommends using dedicated flow
control scheme so update the driver accordingly.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
USB4 inter-domain spec mandates that the compatible hosts expose a new
property "maxhopid" that tells the connection manager on the other side
what is the maximum supported input HopID over the connection. Since
this is depend on the lane adapter the cable is connected it needs to be
filled in dynamically.
For this reason we take a copy of the global properties and fill then
for each XDomain connection upon first connect, and then keep updating
it if the generation changes as services are being added/removed. We
also take advantage of this copy to fill in the hostname.
We also expose this maxhopid as an attribute under each XDomain device.
While there drop kernel-doc entry for property_lock which seems to be
left there when the structure was originally introduced.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This function takes a deep copy of the properties. We need this in order
to support more dynamic properties per XDomain connection as required by
the USB4 inter-domain service spec.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The USB4 inter-domain service spec has slightly different recommended
timeouts for the XDomain protocol so align the driver with those.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
As recommended by USB4 inter-domain service spec use pseudo-random value
instead of zero as initial XDomain property block generation value.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This step is actually not needed. The service drivers themselves will
handle this once they have negotiated the service up and running again
with the remote side. Also dropping this makes it easier to add support
for multiple DMA tunnels over a single XDomain connection.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently the driver is pretty quiet when another host is connected
which makes debugging possible issues harder. For this reason add more
logging on debug level that can be turned on as needed.
While there log the host-to-host connection on info level analogous to
routers and retimers.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
When the firmware connection manager is not proxying between the
software and the hardware we can decrease the timeout for control
packets significantly. The USB4 spec recommends 10 ms +- 1 ms but we use
slightly larger value (100 ms) which is recommendation from Intel
Thunderbolt firmware folks. When firmware connection manager is running
then we keep using the existing 5000 ms.
To implement this we move the control channel allocation to
tb_domain_alloc(), and pass the timeout from that function to the
tb_ctl_alloc(). Then make both connection manager implementations pass
the timeout when they alloc the domain structure.
While there update kernel-doc of struct tb_ctl to match the reality.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
There is only one user for this function and it passes the default
timeout to it anyway, so remove the parameter completely. This is also
needed in the subsequent patch where we allow connection manager
implementations to use different timeout for non-raw control channel
messages.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
In most cases the response packet is lost because the router in question
was disconnected by the user. Resending the control packet in that case
just adds unnecessary delays, so disable that for intra-domain control
packets. For inter-domain (XDomain) packets we continue retrying.
This also aligns the driver better what the Intel connection manager
firmware is doing.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently, when first failure occurs while reading of the block,
we stop reading the block and jump to the next capability.
This doesn't cover the case of block with "holes" of inaccessible
dwords, followed by accessible dwords.
This patch address this problem.
In case of failure while reading the complete block in one transaction,
(because of one or more dwords is inaccessible), we read the remaining
dwords of the block dword-by-dword, one dword per transaction,
till the end of the block.
By doing this, we handle the case of block with "holes" of inaccessible
dwords, followed by accessible dwords. The accessible dwords are shown
with the fields: <offset> <relative_offset> <cap_id> <vs_cap_id> <value>
E.g.:
0x01eb 236 0x05 0x06 0x0000d166
While the inaccesible dwords are shown as: <offset> <not accessible>
E.g.:
0x01ed <not accessible>
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
If the driver is unbound and then bound back it goes over the topology
and figure out the existing tunnels. However, if it finds DP tunnel it
should make sure the domain does not runtime suspend as otherwise it
will tear down the DP tunnel unexpectedly.
Fixes: 6ac6faee5d ("thunderbolt: Add runtime PM for Software CM")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
If there is a failure before the tb_switch_add() is called the switch
object is released by tb_switch_release() but at that point HopID IDAs
have not yet been initialized. So we see splat like this:
BUG: spinlock bad magic on CPU#2, kworker/u8:5/115
...
Workqueue: thunderbolt0 tb_handle_hotplug
Call Trace:
dump_stack+0x97/0xdc
? spin_bug+0x9a/0xa7
do_raw_spin_lock+0x68/0x98
_raw_spin_lock_irqsave+0x3f/0x5d
ida_destroy+0x4f/0x127
tb_switch_release+0x6d/0xfd
device_release+0x2c/0x7d
kobject_put+0x9b/0xbc
tb_handle_hotplug+0x278/0x452
process_one_work+0x1db/0x396
worker_thread+0x216/0x375
kthread+0x14d/0x155
? pr_cont_work+0x58/0x58
? kthread_blkcg+0x2e/0x2e
ret_from_fork+0x1f/0x40
Fix this by always initializing HopID IDAs in tb_switch_alloc().
Fixes: 0b2863ac3c ("thunderbolt: Add functions for allocating and releasing HopIDs")
Cc: stable@vger.kernel.org
Reported-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Drop the two functions not used anymore in the driver.
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
There are cases when reading block of dwords in single transaction fail,
for several reasons, mostly if HW publish to implement all of the dwords,
while actually it doesn't or if some dwords not accessible for read
for security reasons. We handle these cases by trying to read the block,
dword-by-dword, one dword per transaction, till we get a failure.
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This includes following Thunderbolt/USB4 changes for v5.12 merge
window:
* Start lane initialization after sleep for Thunderbolt 3 compatible
devices
* Add support for de-authorizing PCIe tunnels (software based
connection manager only)
* Add support for new ACPI 6.4 USB4 _OSC
* Allow disabling XDomain protocol
* Add support for new SL5 security level
* Clean up kernel-docs to pass W=1 builds
* A couple of cleanups and minor fixes
All these have been in linux-next without reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmAib9IgHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKAykw/+JfXClHYVlqRh
IH7kFkD4nA7g7359PpmSLxRBzvkivz7w66BqNtp6GhIF1oGRtDJ5t5ufgwdYX3Ld
tqH2Glhw9gV5EmeqDzq3TbLzAU+zm9a5bVE3vwQbxpgPGtDigKpDjqUobGFooDaB
F8EX3H3rwI3i+1/S1vBAZbuJqND0cuDM2yQNYJ//Dch2wnZ/Vy6darzY+GpJYSWi
ZlzWsvhfbo1V3n1PphzRkvzcMbVcJriVfwJihtY1h3H6RnnD4pqQJ7e1ec+4Pgdv
fql3lJg0M02rzTSYLyLwuMOojZA+gPqLWb3Fj5pkfjcKoneq1BNTsl4xRzDpqwP3
/DeOPE+TO6SAsAkRksyH5W9nvaYGmLy0r9JREkkzdhH41RML4ueEjstaJyfWn1N+
bX2Ba+5A9pIWKYbwfbNTZPyHk9r94IdDDXzjXFLSeOTcCwMf97XX4sgrbPHedxh6
VAjIrYxuSCTRRN1G6xtPI9aer5wh7e01W71WK3SJhvpqs092E0m0p4gN/nm6yW1Z
SSJg36uqp0egjU/NxsyNvB1ePQFiUkO7WIow9pVBU+US7vSuW9IXbC59lAx0XUE5
tonIF7zAiz1hLp6DZRYfTX7R9xbyshep0uhESceCcIsF5winsgUXL76QEMN0fEjf
wmUG/HWrOd2O/IH8704rfnu7ajxATGM=
=pzr4
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v5.12 merge window
This includes following Thunderbolt/USB4 changes for v5.12 merge
window:
* Start lane initialization after sleep for Thunderbolt 3 compatible
devices
* Add support for de-authorizing PCIe tunnels (software based
connection manager only)
* Add support for new ACPI 6.4 USB4 _OSC
* Allow disabling XDomain protocol
* Add support for new SL5 security level
* Clean up kernel-docs to pass W=1 builds
* A couple of cleanups and minor fixes
All these have been in linux-next without reported issues.
* tag 'thunderbolt-for-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (27 commits)
thunderbolt: Add support for native USB4 _OSC
ACPI: Add support for native USB4 control _OSC
ACPI: Execute platform _OSC also with query bit clear
thunderbolt: Allow disabling XDomain protocol
thunderbolt: Add support for PCIe tunneling disabled (SL5)
thunderbolt: dma_test: Drop unnecessary include
thunderbolt: Add clarifying comments about USB4 terms router and adapter
thunderbolt: switch: Fix kernel-doc descriptions of non-static functions
thunderbolt: nhi: Fix kernel-doc descriptions of non-static functions
thunderbolt: path: Fix kernel-doc descriptions of non-static functions
thunderbolt: eeprom: Fix kernel-doc descriptions of non-static functions
thunderbolt: ctl: Fix kernel-doc descriptions of non-static functions
thunderbolt: switch: Fix function name in the header
thunderbolt: tunnel: Fix misspelling of 'receive_path'
thunderbolt: icm: Fix a couple of formatting issues
thunderbolt: switch: Demote a bunch of non-conformant kernel-doc headers
thunderbolt: tb: Kernel-doc function headers should document their parameters
thunderbolt: nhi: Demote some non-conformant kernel-doc headers
thunderbolt: xdomain: Fix 'tb_unregister_service_driver()'s 'drv' param
thunderbolt: eeprom: Demote non-conformant kernel-doc headers to standard comment blocks
...
ACPI 6.4 introduced a new _OSC capability used to negotiate whether the
OS is supposed to use Software (native) or Firmware based Connection
Manager. If the native support is granted then there are set of bits
that enable/disable different tunnel types that the Software Connection
Manager is allowed to tunnel.
This adds support for this new USB4 _OSC accordingly. When PCIe
tunneling is disabled then the driver switches security level to be
"nopcie" following the security level 5 used in Firmware based
Connection Manager.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
This allows disabling XDomain protocol completely if the user does not
plan to use the USB4/Thunderbolt peer-to-peer functionality, or for
security reasons.
XDomain protocol is enabled by default but with this commit it is
possible to disable it by passing "xdomain=0" as module parameter (or
through the kernel command line).
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Recent Intel Thunderbolt firmware connection manager has support for
another security level, SL5, that disables PCIe tunneling. This option
can be turned on from the BIOS.
When this is set the driver exposes a new security level "nopcie" to the
userspace and hides the authorized attribute under connected devices.
While there we also hide it when "dponly" security level is enabled
since it is not really usable in that case anyway.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
USB4 spec talks about routers and adapters whereas Thunderbolt 1-3
talked about CIO (Converged I/O) switches and ports. These are the same
thing but might cause confusion so add clarifying comments to struct
tb_switch and struct tb_port about the USB4 terms.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fix kernel-doc descriptions of all non-static functions. This also gets
rid of the warnings on W=1 build.
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lee Jones <lee.jones@linaro.org>
Fix kernel-doc descriptions of the two non-static functions. This also
gets rids of the warnings on W=1 build.
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lee Jones <lee.jones@linaro.org>
Fix kernel-doc descriptions of the two non-static functions. This also
gets rid of the warnings on W=1 build.
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lee Jones <lee.jones@linaro.org>
Fix kernel-doc descriptions of the two non-static functions. This also
gets rid of the rest of the warnings on W=1 build.
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lee Jones <lee.jones@linaro.org>
Fix kernel-doc descriptions of all non-static functions and struct
tb_cfg. Gets rid of several warnings on W=1 builds too.
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Lee Jones <lee.jones@linaro.org>
When we walk up the device hierarchy in tb_acpi_add_link() make sure we
break the loop if the device has no parent. Otherwise we may crash the
kernel by dereferencing a NULL pointer.
Fixes: b2be2b05cf ("thunderbolt: Create device links from ACPI description")
Cc: stable@vger.kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/switch.c:1322: warning: expecting prototype for reset_switch(). Prototype was for tb_switch_reset() instead
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/tunnel.c:841: warning: Function parameter or member 'receive_path' not described in 'tb_tunnel_alloc_dma'
drivers/thunderbolt/tunnel.c:841: warning: Excess function parameter 'reveive_path' description in 'tb_tunnel_alloc_dma'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/icm.c:122: warning: Function parameter or member 'xdomain_connected' not described in 'icm'
drivers/thunderbolt/icm.c:122: warning: Function parameter or member 'xdomain_disconnected' not described in 'icm'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/switch.c:730: warning: Function parameter or member 'port' not described in 'tb_init_port'
drivers/thunderbolt/switch.c:1348: warning: Function parameter or member 'sw' not described in 'tb_plug_events_active'
drivers/thunderbolt/switch.c:1348: warning: Function parameter or member 'active' not described in 'tb_plug_events_active'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
[ mw: Demote only static functions ]
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/tb.c:535: warning: Function parameter or member 'sw' not described in 'tb_scan_switch'
drivers/thunderbolt/tb.c:551: warning: Function parameter or member 'port' not described in 'tb_scan_port'
drivers/thunderbolt/tb.c:711: warning: Function parameter or member 'tb' not described in 'tb_free_invalid_tunnels'
drivers/thunderbolt/tb.c:726: warning: Function parameter or member 'sw' not described in 'tb_free_unplugged_children'
drivers/thunderbolt/tb.c:1129: warning: Function parameter or member 'work' not described in 'tb_handle_hotplug'
drivers/thunderbolt/tb.c:1239: warning: Function parameter or member 'tb' not described in 'tb_handle_event'
drivers/thunderbolt/tb.c:1239: warning: Function parameter or member 'type' not described in 'tb_handle_event'
drivers/thunderbolt/tb.c:1239: warning: Function parameter or member 'buf' not described in 'tb_handle_event'
drivers/thunderbolt/tb.c:1239: warning: Function parameter or member 'size' not described in 'tb_handle_event'
drivers/thunderbolt/tb.c:1239: warning: expecting prototype for tb_schedule_hotplug_handler(). Prototype was for tb_handle_event() instead
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/nhi.c:53: warning: Function parameter or member 'ring' not described in 'ring_interrupt_active'
drivers/thunderbolt/nhi.c:53: warning: Function parameter or member 'active' not described in 'ring_interrupt_active'
drivers/thunderbolt/nhi.c:114: warning: Function parameter or member 'nhi' not described in 'nhi_disable_interrupts'
drivers/thunderbolt/nhi.c:191: warning: Function parameter or member 'ring' not described in 'ring_write_descriptors'
drivers/thunderbolt/nhi.c:225: warning: Function parameter or member 'work' not described in 'ring_work'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
[ mw: Demote only static functions ]
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/xdomain.c:678: warning: Function parameter or member 'drv' not described in 'tb_unregister_service_driver'
drivers/thunderbolt/xdomain.c:678: warning: Excess function parameter 'xdrv' description in 'tb_unregister_service_driver'
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/eeprom.c:19: warning: Function parameter or member 'sw' not described in 'tb_eeprom_ctl_write'
drivers/thunderbolt/eeprom.c:19: warning: Function parameter or member 'ctl' not described in 'tb_eeprom_ctl_write'
drivers/thunderbolt/eeprom.c:27: warning: Function parameter or member 'sw' not described in 'tb_eeprom_ctl_read'
drivers/thunderbolt/eeprom.c:27: warning: Function parameter or member 'ctl' not described in 'tb_eeprom_ctl_read'
drivers/thunderbolt/eeprom.c:27: warning: expecting prototype for tb_eeprom_ctl_write(). Prototype was for tb_eeprom_ctl_read() instead
drivers/thunderbolt/eeprom.c:43: warning: Function parameter or member 'sw' not described in 'tb_eeprom_active'
drivers/thunderbolt/eeprom.c:43: warning: Function parameter or member 'enable' not described in 'tb_eeprom_active'
drivers/thunderbolt/eeprom.c:73: warning: Function parameter or member 'sw' not described in 'tb_eeprom_transfer'
drivers/thunderbolt/eeprom.c:73: warning: Function parameter or member 'ctl' not described in 'tb_eeprom_transfer'
drivers/thunderbolt/eeprom.c:73: warning: Function parameter or member 'direction' not described in 'tb_eeprom_transfer'
drivers/thunderbolt/eeprom.c:97: warning: Function parameter or member 'sw' not described in 'tb_eeprom_out'
drivers/thunderbolt/eeprom.c:97: warning: Function parameter or member 'val' not described in 'tb_eeprom_out'
drivers/thunderbolt/eeprom.c:117: warning: Function parameter or member 'sw' not described in 'tb_eeprom_in'
drivers/thunderbolt/eeprom.c:117: warning: Function parameter or member 'val' not described in 'tb_eeprom_in'
drivers/thunderbolt/eeprom.c:138: warning: Function parameter or member 'sw' not described in 'tb_eeprom_get_drom_offset'
drivers/thunderbolt/eeprom.c:138: warning: Function parameter or member 'offset' not described in 'tb_eeprom_get_drom_offset'
drivers/thunderbolt/eeprom.c:170: warning: Function parameter or member 'sw' not described in 'tb_eeprom_read_n'
drivers/thunderbolt/eeprom.c:170: warning: Function parameter or member 'offset' not described in 'tb_eeprom_read_n'
drivers/thunderbolt/eeprom.c:170: warning: Function parameter or member 'val' not described in 'tb_eeprom_read_n'
drivers/thunderbolt/eeprom.c:170: warning: Function parameter or member 'count' not described in 'tb_eeprom_read_n'
drivers/thunderbolt/eeprom.c:383: warning: Function parameter or member 'sw' not described in 'tb_drom_parse_entries'
drivers/thunderbolt/eeprom.c:417: warning: Function parameter or member 'sw' not described in 'tb_drom_copy_efi'
drivers/thunderbolt/eeprom.c:417: warning: Function parameter or member 'size' not described in 'tb_drom_copy_efi'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
[ mw: Demote only static functions ]
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/ctl.c:38: warning: expecting prototype for struct tb_cfg. Prototype was for struct tb_ctl instead
drivers/thunderbolt/ctl.c:350: warning: Function parameter or member 'ctl' not described in 'tb_ctl_tx'
drivers/thunderbolt/ctl.c:350: warning: Function parameter or member 'data' not described in 'tb_ctl_tx'
drivers/thunderbolt/ctl.c:350: warning: Function parameter or member 'len' not described in 'tb_ctl_tx'
drivers/thunderbolt/ctl.c:350: warning: Function parameter or member 'type' not described in 'tb_ctl_tx'
drivers/thunderbolt/ctl.c:350: warning: expecting prototype for tb_cfg_tx(). Prototype was for tb_ctl_tx() instead
drivers/thunderbolt/ctl.c:383: warning: Function parameter or member 'ctl' not described in 'tb_ctl_handle_event'
drivers/thunderbolt/ctl.c:383: warning: Function parameter or member 'type' not described in 'tb_ctl_handle_event'
drivers/thunderbolt/ctl.c:383: warning: Function parameter or member 'pkg' not described in 'tb_ctl_handle_event'
drivers/thunderbolt/ctl.c:383: warning: Function parameter or member 'size' not described in 'tb_ctl_handle_event'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
[ mw: Demote only static functions ]
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/cap.c:189: warning: Function parameter or member 'sw' not described in 'tb_switch_find_cap'
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
... and take the error path if it fails.
Fixes the following W=1 kernel build warning(s):
drivers/thunderbolt/dma_port.c: In function ‘dma_port_flash_write_block’:
drivers/thunderbolt/dma_port.c:331:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
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
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
In some cases it is useful to be able de-authorize devices. For example
if user logs out the userspace can have a policy that disconnects PCIe
devices until logged in again. This is only possible for software based
connection manager as it directly controls the tunnels.
For this reason make the authorized attribute accept writing 0 which
makes the software connection manager to tear down the corresponding
PCIe tunnel. Userspace can check if this is supported by reading a new
domain attribute deauthorization, that holds 1 in that case.
While there correct tb_domain_approve_switch() kernel-doc and
description of authorized attribute to mention that it is only about
PCIe tunnels.
Cc: Christian Kellner <christian@kellner.me>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
USB4 spec says that for TBT3 compatible device routers the connection
manager needs to set SLI (Start Lane Initialization) to get the lanes
that were not connected back to functional state after sleep. Same needs
to be done if the link was XDomain.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
The only usage of these is to put their addresses in arrays of pointers
to const attribute_groups. Make them const to allow the compiler to put
them in read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The tb_dbg() call is using %#x that already adds the 0x prefix so don't
duplicate it.
Fixes: 9039387e16 ("thunderbolt: Add USB4 router operation proxy for firmware connection manager")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Yehezkel Bernat <YehezkelShB@gmail.com>
This includes following Thunderbolt/USB4 changes for v5.11 merge window:
* DMA traffic test driver
* USB4 router NVM upgrade improvements
* USB4 router operations proxy implementation available in the recent
Intel Connection Manager firmwares
* Support for Intel Maple Ridge discrete Thunderbolt 4 controller
* A couple of cleanups and minor improvements.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAl/PagggHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKD5DQ/+NFsABFQaf1P+
sU4HVOo9cwfvQCFCapfOsOjBsrkuLsjZPQdUqVdTzhrDzRM6uVQXHqWkcInNYxEs
D0o9f8yheYSPuZolHIIydkNZ7VjhXwhVp7FuF+6M3bIhtD9siuBUisCu7QtOjzpF
EAzBZcGHvKXkPmVAQKZS/P4WsgcZDv0/pODjeQawosgJAPOo5begZVBEYcpbOeCT
qvl1vEs+Fr5fcoFcY/58sJX932CcbbO5bZMSc01IIF94FQMsQJg3ATLdxkgc++2M
FnzcHEVQi7h8zwCmMT4deGwLJqvbyVy5SNo6GY4/Adhsf0HQzrvtWdESegoIooJK
dNWhSCuAFbXrFKGH4iBEUldigNXiCGiTwalmJ1+IIDccJQwkKC4GGU+9KEWBtYCn
OIvKkHUWPeeqNBzSeiMbFDXiK6QFe2VpNBg/iRUZwZwxibqgjgJE1rHbY098sPrL
yHRcrz6vih3wgpqZJTGdanIMk6F0MzaoHtj2egXbXaqyGf8dIdvnZJZN9gb5WDyu
ZT/ffh3XiNfBvFtsu9gosnn3m76TQ4jIb4lUesTOVZjHX2yNz3MabYet312lP4PO
qhxb1l2HGWuxnLLSxas6gzEv5arpx88ldSj6PaA86pBL/eezy59Bvn5hYrmCQ269
lVZQ19nC8y13VyCgbqcyTSpGxS+NXV0=
=+RXF
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v5.11 merge window
This includes following Thunderbolt/USB4 changes for v5.11 merge window:
* DMA traffic test driver
* USB4 router NVM upgrade improvements
* USB4 router operations proxy implementation available in the recent
Intel Connection Manager firmwares
* Support for Intel Maple Ridge discrete Thunderbolt 4 controller
* A couple of cleanups and minor improvements.
* tag 'thunderbolt-for-v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (22 commits)
thunderbolt: Add support for Intel Maple Ridge
thunderbolt: Add USB4 router operation proxy for firmware connection manager
thunderbolt: Move constants for USB4 router operations to tb_regs.h
thunderbolt: Add connection manager specific hooks for USB4 router operations
thunderbolt: Pass TX and RX data directly to usb4_switch_op()
thunderbolt: Pass metadata directly to usb4_switch_op()
thunderbolt: Perform USB4 router NVM upgrade in two phases
thunderbolt: Return -ENOTCONN when ERR_CONN is received
thunderbolt: Keep the parent runtime resumed for a while on device disconnect
thunderbolt: Log adapter numbers in decimal in path activation/deactivation
thunderbolt: Log which connection manager implementation is used
thunderbolt: Move max_boot_acl field to correct place in struct icm
MAINTAINERS: Add Isaac as maintainer of Thunderbolt DMA traffic test driver
thunderbolt: Add DMA traffic test driver
thunderbolt: Add support for end-to-end flow control
thunderbolt: Make it possible to allocate one directional DMA tunnel
thunderbolt: Create debugfs directory automatically for services
thunderbolt: Add functions for enabling and disabling lane bonding on XDomain
thunderbolt: Add link_speed and link_width to XDomain
thunderbolt: Create XDomain devices for loops back to the host
...
Maple Ridge is first discrete USB4 host controller from Intel. It comes
with firmware based connection manager and the flows are similar as used
in Intel Titan Ridge.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Intel Maple Ridge and Tiger Lake connection manager firmware implements
a USB4 router operation proxy that should be used instead of direct
register access to avoid races with the firmware. This is supported in
all firmwares where the protocol version field returned in the driver
ready response is 3 (or higher).
This adds the USB4 router proxy operations support to the driver so that
we first check the protocol version and if it is 3 (or higher) the USB4
router operation is run through the firmware provided proxy. Otherwise
the native version is used.
Most USB4 router proxy operations are pretty straightforward except
NVM_AUTH where the firmware only responds once the router is restarted
but before it sends device connected notification. To support this we
split the operation so that the reply is received asynchronously and
stored to struct icm. This last reply is then returned in
icm_usb4_switch_nvm_authenticate_status() if available.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We are going to use these in subsequent patch so make them available
outside of usb4.c.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Intel USB4 host routers that run the firmware based connection manager
(ICM) may implement a proxy for USB4 router operations. This is to avoid
the firmware to race with the OS driver, as both may need to run these
operations.
This adds two new connection manager specific callbacks which, if
provided, get called instead of the native USB4 router operation.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We are going to make usb4_switch_op() to match better the corresponding
firmware (ICM) USB4 router operation proxy interface, so that we can use
either based on the connection manager implementation.
For this reason rename usb4_switch_op() to __usb4_switch_op() that
provides the most complete interface. Then make usb4_switch_op() and
usb4_switch_op_data() call it with correct set of parameters and update
the callers accordingly.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We are going to make usb4_switch_op() to match better the corresponding
firmware (ICM) USB4 router operation proxy interface, so that we can use
either based on the connection manager implementation. For this reason
pass metadata directly to usb4_switch_op().
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The currect code expects that the router returns back the status of the
NVM authentication immediately. When tested against a real USB4 device
what happens is that the router is reset and only after that the result
is updated in the ROUTER_CS_26 register status field. This also seems to
align better what the spec suggests.
For this reason do the same what we already do with the Thunderbolt 3
devices and perform the NVM upgrade in two phases. First start the
NVM_AUTH router operation and once the router is added back after the
reset read the status in ROUTER_CS_26 and expose it to the userspace
accordingly.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This allows the calling code to distinguish if the error was due to
ERR_CONN (adapter is disconneced or disabled) or something else. Will be
needed in USB4 router NVM update in the following patch.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
When doing device firmware upgrade the device will disconnect for a
while and then reconnect back. Keep the parent device (and the whole
domain) powered for a while so we don't need to runtime resume
immediately when the device is connected back after the device upgrade
completes.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This makes it consistent with other debug logs that already are using
decimal number for adapters (ports).
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This makes it easier to figure out whether the driver is using firmware
or software based connection manager implementation.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This makes the kernel-doc to match the ordering and also this is better
place for it, not between upstream_port and vnd_cap that are used
together.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Paulian reported a crash that happens when a dock is unplugged during
hibernation:
[78436.228217] thunderbolt 0-1: device disconnected
[78436.228365] BUG: kernel NULL pointer dereference, address: 00000000000001e0
...
[78436.228397] RIP: 0010:icm_free_unplugged_children+0x109/0x1a0
...
[78436.228432] Call Trace:
[78436.228439] icm_rescan_work+0x24/0x30
[78436.228444] process_one_work+0x1a3/0x3a0
[78436.228449] worker_thread+0x30/0x370
[78436.228454] ? process_one_work+0x3a0/0x3a0
[78436.228457] kthread+0x13d/0x160
[78436.228461] ? kthread_park+0x90/0x90
[78436.228465] ret_from_fork+0x1f/0x30
This happens because remove_unplugged_switch() calls tb_switch_remove()
that releases the memory pointed by sw so the following lines reference
to a memory that might be released already.
Fix this by saving pointer to the parent device before calling
tb_switch_remove().
Reported-by: Paulian Bogdan Marinca <paulian@marinca.net>
Fixes: 4f7c2e0d87 ("thunderbolt: Make sure device runtime resume completes before taking domain lock")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This driver allows sending DMA traffic over XDomain connection.
Specifically over a loopback connection using either a Thunderbolt/USB4
cable that is connected back to the host router port, or a special
loopback dongle that has RX and TX lines crossed. This can be useful at
manufacturing floor to check whether Thunderbolt/USB4 ports are
functional.
The driver exposes debugfs directory under the XDomain service that can
be used to configure the driver, start the test and check the results.
If a loopback dongle is used the steps to send and receive 1000 packets
can be done like:
# modprobe thunderbolt_dma_test
# echo 1000 > /sys/kernel/debug/thunderbolt/<service_id>/dma_test/packets_to_receive
# echo 1000 > /sys/kernel/debug/thunderbolt/<service_id>/dma_test/packets_to_send
# echo 1 > /sys/kernel/debug/thunderbolt/<service_id>/dma_test/test
# cat /sys/kernel/debug/thunderbolt/<service_id>/dma_test/status
When a cable is connected back to host then there are two Thunderbolt
services, one is configured for receiving (does not matter which one):
# modprobe thunderbolt_dma_test
# echo 1000 > /sys/kernel/debug/thunderbolt/<service_a>/dma_test/packets_to_receive
# echo 1 > /sys/kernel/debug/thunderbolt/<service_a>/dma_test/test
The other one for sending:
# echo 1000 > /sys/kernel/debug/thunderbolt/<service_b>/dma_test/packets_to_send
# echo 1 > /sys/kernel/debug/thunderbolt/<service_b>/dma_test/test
Results can be read from both services status attributes.
Signed-off-by: Isaac Hazan <isaac.hazan@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
USB4 spec defines end-to-end (E2E) flow control that can be used between
hosts to prevent overflow of a RX ring. We previously had this partially
implemented but that code was removed with commit 53f13319d1
("thunderbolt: Get rid of E2E workaround") with the idea that we add it
back properly if there ever is need. Now that we are going to add DMA
traffic test driver (in subsequent patches) this can be useful.
For this reason we modify tb_ring_alloc_rx/tx() so that they accept
RING_FLAG_E2E and configure the hardware ring accordingly. The RX side
also requires passing TX HopID (e2e_tx_hop) used in the credit grant
packets.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
With DMA tunnels it is possible that the service using it does not
require bi-directional paths so make RX and TX optional (but of course
one of them needs to be set).
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This allows service drivers to use it as parent directory if they need
to add their own debugfs entries.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
These can be used by service drivers to enable and disable lane bonding
as needed.
Signed-off-by: Isaac Hazan <isaac.hazan@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link speed and link width are needed for checking expected values in
case of using a loopback service.
Signed-off-by: Isaac Hazan <isaac.hazan@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
It is perfectly possible to have loops back from the routers to the
host, or even from one host port to another. Instead of ignoring these,
we create XDomain devices for each. This allows creating services such
as DMA traffic test that is used in manufacturing for example.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
We are going to represent loops back to the host also as XDomains and
they all have the same (host) UUID, so finding them needs to use route
string instead. This also requires that we check if the XDomain device
is added to the bus before its properties can be updated. Otherwise the
remote UUID might not be populated yet.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
These fields are marked as vendor defined in the USB4 spec and should
not be modified by the software, so only clear them when we are dealing
with pre-USB4 hardware.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Intel Tiger Lake-H has the same Thunderbolt/USB4 controller as Tiger
Lake-LP. Add the Tiger Lake-H PCI IDs to the driver list of supported
devices.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Only USB4 lane 0 adapter has the USB4 port capability for wakes so only
program wakes on such adapters.
Fixes: b2911a593a ("thunderbolt: Enable wakes from system suspend")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Some calls in the debugfs interface are made to the linux/uaccess.h header,
but the header is not referenced. So, for x86_64 architectures, this
dependency seems to be pulled in elsewhere, which leads to a successful
compilation. However, on arm/arm64 architectures, it was found to error out
on implicit declarations.
This change fixes the implicit declaration error by adding the
linux/uaccess.h header.
Fixes: 54e418106c ("thunderbolt: Add debugfs interface")
Signed-off-by: Casey Bowman <casey.g.bowman@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The svc->key field is not released as it should be if ida_simple_get()
fails so fix that.
Fixes: 9aabb68568 ("thunderbolt: Fix to check return value of ida_simple_get")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
ring_request_msix() misses to call ida_simple_remove() in an error path.
Add a label 'err_ida_remove' and jump to it.
Fixes: 046bee1f9a ("thunderbolt: Add MSI-X support")
Cc: stable@vger.kernel.org
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This includes following Thunderbolt/USB4 changes for v5.10 merge window:
* A couple of optimizations around Tiger Lake force power logic and
NHI (Native Host Interface) LC (Link Controller) mailbox command
processing
* Power management improvements for Software Connection Manager
* Debugfs support
* Allow KUnit tests to be enabled also when Thunderbolt driver is
configured as module.
* Few minor cleanups and fixes
All these have been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAl90HsMgHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKAhOhAAnR/SpkKkTPkw
vFgL4jtQ89KY/mhJnfmbqFqcb2zLWaso9kFdWfLs6ITqOU0H3Pu1PR/shyx0Xka4
i/kIT8iuorqO7Y1ILFtWgybXkE77AEJgtp3Q+Li/Y7ZPR0kipbjUH/fmCAWPtmHd
Qkjd1nV72TQEkU3P7X6ob70Xkil2qn6i4fF1Kp5Mjg/8fGkqkrO2TZZPi7PXnsaG
PySIffJY2zeEiohjl9Q/gOqBogMCPC8DgZmcS4QJ69DS8zOF9yKLUFqGQtd31BFG
i9HgLYR8xOV7mdTVmTLZp0dzDT3rqjubnA3TfgUG7HAjQyeTZnnSGbeLlYtpoKX0
rvL4gkEmQBkn51KiqKCvCcktzdqQ6hUjyqWjVJar63qks0AIcbDHphj37DHFW4Fc
qO5lpON0T8JxBBQ0xDoQk+1aU6xq8QhaB+iOzyy5ZSU5vL3pcsAvqoOsxN+k0nud
F5hfXsHwi8M/ZWcFrxNzpID0B9IVU+Fe2FXXVTMKdmpoPy/vU1xgFHj88o7vNAAb
412u4NEzlxDOitONY6L1M6uGl9wSCVudMozfZci4dAAnAxj1/oeDurZJn5h4BtsR
q0iP2JToSqrovd4V5uQ53MEF0JqkkYVwbAaV+y4/2afwJho3SoIDa9xv3ffpei68
If1wkLHkBJIlWCci1fsiOuvJ+IH+rK0=
=KvWM
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v5.10 merge window
This includes following Thunderbolt/USB4 changes for v5.10 merge window:
* A couple of optimizations around Tiger Lake force power logic and
NHI (Native Host Interface) LC (Link Controller) mailbox command
processing
* Power management improvements for Software Connection Manager
* Debugfs support
* Allow KUnit tests to be enabled also when Thunderbolt driver is
configured as module.
* Few minor cleanups and fixes
All these have been in linux-next with no reported issues.
* tag 'thunderbolt-for-v5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (37 commits)
thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER
thunderbolt: Correct tb_check_quirks() kernel-doc
thunderbolt: Log correct zeroX entries in decode_error()
thunderbolt: Handle ERR_LOCK notification
thunderbolt: Use "if USB4" instead of "depends on" in Kconfig
thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
thunderbolt: Only stop control channel when entering freeze
thunderbolt: debugfs: Fix uninitialized return in counters_write()
thunderbolt: Add debugfs interface
thunderbolt: No need to warn in TB_CFG_ERROR_INVALID_CONFIG_SPACE
thunderbolt: Introduce tb_switch_is_tiger_lake()
thunderbolt: Introduce tb_switch_is_ice_lake()
thunderbolt: Check for Intel vendor ID when identifying controller
thunderbolt: Introduce tb_port_is_nhi()
thunderbolt: Introduce tb_switch_next_cap()
thunderbolt: Introduce tb_port_next_cap()
thunderbolt: Move struct tb_cap_any to tb_regs.h
thunderbolt: Add runtime PM for Software CM
thunderbolt: Create device links from ACPI description
ACPI: Export acpi_get_first_physical_node() to modules
...
There was copy & paste error so it always printed value of pkg->zero1.
Also use tb_ctl_warn() here, no need to print backtrace.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
If the USB4 router downstream port is locked, sending configuration
packet to a router below it causes ERR_LOCK to be sent. Instead of warn
splat about unknown error we log the error (just warning level) and
return -EACCESS instead. The idea is that we may want to do something
when such error code is received, like perform unlock.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This groups the USB4 options more nicely, and also does not require that
every config option lists explicit depends on USB4.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This adds a bit more build coverage for the tests even though these are
not expected to be enabled by normal users and distros. In order to make
this working we need to open-code kunit_test_suite() and call the
relevant functions directly in the driver init/exit hook.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
According to the kernel power management documentation freeze phase
should only quiesce the device, no need to configure wakes or put it to
low power state. For this reason we simply stop the control channel and
in case of Software Connection Manager also mark the hotplug disabled.
This should align the driver better with the PM framework expectations.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
One more fix that makes ASUS PA27AC Thunderbolt 3 monitor work more
reliably.
This has been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAl9giR0gHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKBhFA/+KVuBU+0vneG1
77j9No3wVVYp7spGa/HORYUKuBj72IBCIxARNzyjNY3h5422aKn44F5ReuTj4TGx
414cQ1iGblZSiF8Geen0e7Oyg+KSKnenkKdiIE9oa4Hy/UPT39i7uJiDBriMc0dD
PpriEEa8AMXfdjxY3WK8iynf9qoky1S2EHBo8Rz9nCQkQ+yOEKfZq8KC+Egb9XFV
ebRsRj7rM4V9VNhETnfTm54M2zPw8n7HDKkQB1z8qddyv9i6biHTFXXXRD8A/Q/7
ZrC7fW/OqUVra34bV70tGD3goSAi7kfHyMF4C4+dUhCP8lF36ozLqh/3cUt+5TOE
ghpuHNsAb35PZu70h3U4hBTn9j/KtWgo6JH++xv6TkuffPEFWo1FSuPmupKg1WZK
XMJ0CtwBeUM2JF2sXKlaUrjFsql7mxoRbnBjkp/giP9PiW7QXZzkl2Y8DgCvmDmF
mBJj4rKu/oBBjs8NyD41roY2e+02DYIos5UzkYZl2/68Vv6USa601nG580gA6dBb
Y/8RoaCFIxl3WK26+Ri08190BNlwMlVcX8ToaM9rroCI+9eDqsa5G8eb9zLmcWwC
+tTNJMMFsho2Js+DxOcJXY0LoQeNrNazFKylz6UnsgL7zsw0kI0dM3l3qpRysqha
Ua06NbrPEpqhQ62xKXtj7qAiWdIIZAo=
=sgTO
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
Mika writes:
thunderbolt: Fix for v5.9-rc6
One more fix that makes ASUS PA27AC Thunderbolt 3 monitor work more
reliably.
This has been in linux-next with no reported issues.
* tag 'thunderbolt-for-v5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
thunderbolt: Retry DROM read once if parsing fails
If the first line is in an invalid format then the "ret" value is
uninitialized. We should return -EINVAL instead.
Fixes: 54e418106c ("thunderbolt: Add debugfs interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Kai-Heng reported that sometimes DROM parsing of ASUS PA27AC Thunderbolt 3
monitor fails. This makes the driver to fail to add the device so only
DisplayPort tunneling is functional.
It is not clear what exactly happens but waiting for 100 ms and retrying
the read seems to work this around so we do that here.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206493
Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This adds debugfs interface that can be used for debugging possible
issues in hardware/software. It exposes router and adapter config spaces
through files like this:
/sys/kernel/debug/thunderbolt/<DEVICE>/regs
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT1>/regs
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT1>/path
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT1>/counters
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT2>/regs
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT2>/path
/sys/kernel/debug/thunderbolt/<DEVICE>/<PORT2>/counters
...
The "regs" is either the router or port configuration space register
dump. The "path" is the port path configuration space and "counters" is
the optional counters configuration space.
These files contains one register per line so it should be easy to use
normal filtering tools to find the registers of interest if needed.
The router and adapter regs file becomes writable when
CONFIG_USB4_DEBUGFS_WRITE is enabled (which is not supposed to be done
in production systems) and in this case the developer can write "offset
value" lines there to modify the hardware directly. For convenience this
also supports the long format the read side produces (but ignores the
additional fields). The counters file can be written even when
CONFIG_USB4_DEBUGFS_WRITE is not enabled and it is only used to clear
the counter values.
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>