aboutsummaryrefslogtreecommitdiff
path: root/drivers/thunderbolt/debugfs.c
AgeCommit message (Collapse)AuthorFilesLines
2024-08-22thunderbolt: Improve software receiver lane marginingR Kannappan1-16/+279
USB4 specification defines the metadata needed to perform software margining, as well as the necessary steps which include waiting for dwell time. - Add dwell_time attribute to set the wait time while performing margining and checking for link errors. - Add error_counter attribute to configure error counter prior to margining test. - Add voltage_time_offset attribute to set the voltage or time offset steps before performing the software margining test. - Perform software margining test for dwell duration, break if there are link errors, stop the clocks and provide results. Below is a minimalistic example how this can be used. Note these values are just examples. The exact values in practice depend on host specific capabilities and the type of measurement to be performed. # cd /sys/kernel/debug/thunderbolt/ROUTER/portX/margining/ # echo software > mode # echo 400 > dwell_time # echo 1 > run As usual the results attribute contains the results of a succesfull run. Signed-off-by: R Kannappan <[email protected]> Co-developed-by: Rene Sapiens <[email protected]> Signed-off-by: Rene Sapiens <[email protected]> Co-developed-by: Aapo Vienamo <[email protected]> Signed-off-by: Aapo Vienamo <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-08-22thunderbolt: Add optional voltage offset range for receiver lane marginingRene Sapiens1-0/+74
Add optional extended voltage offset range support for software and hardware margining as defined by the USB4 specification. If supported, it can be enabled like below: # cd /sys/kernel/debug/thunderbolt/ROUTER/portX/margining/ # echo Y > optional_voltage_offset Signed-off-by: Rene Sapiens <[email protected]> Co-developed-by: R Kannappan <[email protected]> Signed-off-by: R Kannappan <[email protected]> Co-developed-by: Aapo Vienamo <[email protected]> Signed-off-by: Aapo Vienamo <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-08-22thunderbolt: Consolidate margining parameters into a structureRene Sapiens1-9/+23
Consolidate the hardware and software margining parameters into a single structure to reduce the number of parameters passed to the margining functions. Signed-off-by: Rene Sapiens <[email protected]> Co-developed-by: Aapo Vienamo <[email protected]> Signed-off-by: Aapo Vienamo <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-08-22thunderbolt: Add missing usb4_port_sb_read() to usb4_port_sw_margin()Aapo Vienamo1-3/+2
Synchronize the operation completion by reading back the software margining operation completion metadata into margining->results. Signed-off-by: Aapo Vienamo <[email protected]> Co-developed-by: R Kannappan <[email protected]> Signed-off-by: R Kannappan <[email protected]> Co-developed-by: Rene Sapiens <[email protected]> Signed-off-by: Rene Sapiens <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-08-02thunderbolt: Fix memory leaks in {port|retimer}_sb_regs_write()Aapo Vienamo1-4/+6
Add missing free_page() call for the memory allocated by validate_and_copy_from_user(). Fixes: 6d241fa00159 ("thunderbolt: Add sideband register access to debugfs") Signed-off-by: Aapo Vienamo <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-06-19thunderbolt: debugfs: Use FIELD_GET()Aapo Vienamo1-18/+11
Use the FIELD_GET() macro instead of open coding the masks and shifts. This makes the code more compact and improves readability as it avoids the need to wrap excessively long lines. Signed-off-by: Aapo Vienamo <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Yehezkel Bernat <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2024-06-17thunderbolt: Add receiver lane margining support for retimersMika Westerberg1-26/+66
Retimers support lane margining as well so make this available through debugfs in the same way as we do for the USB4 ports. When this is enabled we also expose retimers on the other side of the cable because typically margining is implemented only on direction towards the cable. However, for the retimers on the other side of the cable we do not allow NVM upgrade to avoid confusing the existing userspace (the same retimer may now appear twice with different name) and is probably not a good idea anyway. Signed-off-by: Mika Westerberg <[email protected]>
2024-06-17thunderbolt: Make margining functions accept target and retimer indexMika Westerberg1-6/+10
In order to add lane margining support for retimers make the margining functions take sideband target and retimer index as parameters. This makes it possible to access both router and retimer sideband using the same functions. Signed-off-by: Mika Westerberg <[email protected]>
2024-06-17thunderbolt: Split out margining from USB4 portMika Westerberg1-122/+112
We are going to expand lane margining support for retimers too so split out the generic margining functionality out of being specific to USB4 ports. Signed-off-by: Mika Westerberg <[email protected]>
2024-06-17thunderbolt: Add sideband register access to debugfsMika Westerberg1-0/+293
This makes it possible to read and write USB4 port and retimer sideband registers through debugfs which is useful for debugging and manufacturing purposes. We add "sb_regs" debugfs attribute under each USB4 port and retimer that is used to access the sideband. Signed-off-by: Mika Westerberg <[email protected]>
2024-05-31thunderbolt: debugfs: Fix margin debugfs node creation conditionAapo Vienamo1-2/+3
The margin debugfs node controls the "Enable Margin Test" field of the lane margining operations. This field selects between either low or high voltage margin values for voltage margin test or left or right timing margin values for timing margin test. According to the USB4 specification, whether or not the "Enable Margin Test" control applies, depends on the values of the "Independent High/Low Voltage Margin" or "Independent Left/Right Timing Margin" capability fields for voltage and timing margin tests respectively. The pre-existing condition enabled the debugfs node also in the case where both low/high or left/right margins are returned, which is incorrect. This change only enables the debugfs node in question, if the specific required capability values are met. Signed-off-by: Aapo Vienamo <[email protected]> Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining") Cc: [email protected] Signed-off-by: Mika Westerberg <[email protected]>
2024-04-24thunderbolt: There are only 5 basic router registers in pre-USB4 routersMika Westerberg1-1/+1
Intel pre-USB4 routers only have ROUTER_CS_0 up to ROUTER_CS_4 and it immediately follows the TMU router registers. Correct this accordingly. Reported-by: Rajaram Regupathy <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2023-11-27thunderbolt: Fix memory leak in margining_port_remove()Yaxiong Tian1-1/+1
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: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining") Cc: [email protected] Signed-off-by: Yaxiong Tian <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2023-06-16thunderbolt: Fix PCIe adapter capability length for USB4 v2 routersGil Fine1-2/+6
For USB4 v2 routers, the PCIe adapter capability length is longer. Display the correct capability length in the debugfs register dump. Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2023-06-16thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routersGil Fine1-5/+8
For USB4 v2 routers, the DisplayPort IN adapter capability length is longer. Display the correct capability length in the debugfs register dump. Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2023-06-16thunderbolt: Add two additional double words for adapters TMU for USB4 v2 ↵Gil Fine1-2/+6
routers For USB4 v2 routers, the adapters's TMU capability has two additional double words. Include them in the debugfs register dump. Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2023-06-09thunderbolt: Make tb_switch_clx_disable() return CL states that were enabledMika Westerberg1-11/+24
This allows us to disable all CL states temporarily when running lane margining and then return back the previously enabled states. Signed-off-by: Mika Westerberg <[email protected]>
2023-06-09thunderbolt: Move CLx support functions into clx.cMika Westerberg1-1/+1
There really don't belong to switch.c so move them into their own file. As we do this rename the functions to match the conventions used elsewhere in the driver. No functional changes. Signed-off-by: Mika Westerberg <[email protected]>
2023-03-13thunderbolt: Fix memory leak in marginingMika Westerberg1-6/+6
Memory for the usb4->margining needs to be relased for the upstream port of the router as well, even though the debugfs directory gets released with the router device removal. Fix this. Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining") Cc: [email protected] Signed-off-by: Mika Westerberg <[email protected]>
2023-01-17thunderbolt: Include the additional DP IN double word in debugfs dumpMika Westerberg1-1/+4
When DisplayPort bandwidth allocation mode is supported by the DP IN adapter it has an extra double word in the adapter config space. Include this in the debugfs register dump. Signed-off-by: Mika Westerberg <[email protected]>
2022-09-07thunderbolt: debugfs: Fix spelling mistakes in seq_puts textColin Ian King1-2/+2
There are a handful of spelling mistakes in seq_puts text. Fix them. Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2022-09-05thunderbolt: Add support for receiver lane marginingMika Westerberg1-0/+836
USB4 spec defines standard set of registers to be used for receiver lane margining. This is useful for I/O interface quality and electrical robustness validation during manufacturing. Expose receiver lane margining through new debugfs directory "margining" that is added under each connected USB4 port. Users can then run the margining by writing to the exposed attributes under that directory. Signed-off-by: Mika Westerberg <[email protected]>
2021-03-12thunderbolt: debugfs: Show all accessible dwordsGil Fine1-5/+3
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 <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2021-03-08thunderbolt: debugfs: Handle fail reading blockGil Fine1-13/+26
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 <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2020-12-08Merge tag 'thunderbolt-for-v5.11-rc1' of ↵Greg Kroah-Hartman1-0/+24
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 ...
2020-11-11thunderbolt: Create debugfs directory automatically for servicesMika Westerberg1-0/+24
This allows service drivers to use it as parent directory if they need to add their own debugfs entries. Signed-off-by: Mika Westerberg <[email protected]> Acked-by: Yehezkel Bernat <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]>
2020-11-05thunderbolt: Add uaccess dependency to debugfs interfaceCasey Bowman1-0/+1
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: 54e418106c76 ("thunderbolt: Add debugfs interface") Signed-off-by: Casey Bowman <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2020-09-10thunderbolt: debugfs: Fix uninitialized return in counters_write()Dan Carpenter1-0/+1
If the first line is in an invalid format then the "ret" value is uninitialized. We should return -EINVAL instead. Fixes: 54e418106c76 ("thunderbolt: Add debugfs interface") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
2020-09-03thunderbolt: Add debugfs interfaceGil Fine1-0/+700
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 <[email protected]> Signed-off-by: Mika Westerberg <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]>