History log of /linux-master/drivers/thunderbolt/debugfs.c
Revision Date Author Comments
# ac43c912 22-Nov-2023 Yaxiong Tian <tianyaxiong@kylinos.cn>

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: d0f1e0c2a699 ("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>


# 0209c808 25-Jan-2023 Gil Fine <gil.fine@linux.intel.com>

thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers

For USB4 v2 routers, the PCIe adapter capability length is longer.
Display the correct capability length in the debugfs register dump.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 75abb4f5 25-Jan-2023 Gil Fine <gil.fine@linux.intel.com>

thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers

For USB4 v2 routers, the DisplayPort IN adapter capability length is
longer. Display the correct capability length in the debugfs register
dump.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# ee22d52a 25-Jan-2023 Gil Fine <gil.fine@linux.intel.com>

thunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers

For USB4 v2 routers, the adapters's TMU capability has two additional
double words. Include them in the debugfs register dump.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 4a420eb1 18-Nov-2022 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Make tb_switch_clx_disable() return CL states that were enabled

This allows us to disable all CL states temporarily when running lane
margining and then return back the previously enabled states.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 12a14f2f 07-Oct-2022 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Move CLx support functions into clx.c

There really don't belong to switch.c so move them into their own file.
As we do this rename the functions to match the conventions used
elsewhere in the driver.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# acec7264 03-Mar-2023 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Fix memory leak in margining

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: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 630f211b 29-Apr-2022 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Include the additional DP IN double word in debugfs dump

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 <mika.westerberg@linux.intel.com>


# 706d7383 06-Sep-2022 Colin Ian King <colin.i.king@gmail.com>

thunderbolt: debugfs: Fix spelling mistakes in seq_puts text

There are a handful of spelling mistakes in seq_puts text. Fix them.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# d0f1e0c2 22-Feb-2022 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Add support for receiver lane margining

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 <mika.westerberg@linux.intel.com>


# 3382665a 09-Mar-2021 Gil Fine <gil.fine@intel.com>

thunderbolt: debugfs: Show all accessible dwords

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>


# 815f421b 16-Feb-2021 Gil Fine <gil.fine@intel.com>

thunderbolt: debugfs: Handle fail reading block

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>


# 407ac931 07-Oct-2020 Mika Westerberg <mika.westerberg@linux.intel.com>

thunderbolt: Create debugfs directory automatically for services

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>


# 77455129 07-Oct-2020 Casey Bowman <casey.g.bowman@intel.com>

thunderbolt: Add uaccess dependency to debugfs interface

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 <casey.g.bowman@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 77e4907f 10-Sep-2020 Dan Carpenter <dan.carpenter@oracle.com>

thunderbolt: debugfs: Fix uninitialized return in counters_write()

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 <dan.carpenter@oracle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


# 54e41810 29-Jun-2020 Gil Fine <gil.fine@intel.com>

thunderbolt: Add debugfs interface

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>