When USB-C monitor is connected directly to Intel Barlow Ridge host, it
goes into "redrive" mode that basically routes the DisplayPort signals
directly from the GPU to the USB-C monitor without any tunneling needed.
However, the host router must be powered on for this to work. Aaron
reported that there are a couple of cases where this will not work with
the current code:
- Booting with USB-C monitor plugged in.
- Plugging in USB-C monitor when the host router is in sleep state
(runtime suspended).
- Plugging in USB-C device while the system is in system sleep state.
In all these cases once the host router is runtime suspended the picture
on the connected USB-C display disappears too. This is certainly not
what the user expected.
For this reason improve the redrive mode handling to keep the host
router from runtime suspending when detect that any of the above cases
is happening.
Fixes: a75e0684ef ("thunderbolt: Keep the domain powered when USB4 port is in redrive mode")
Reported-by: Aaron Rainbolt <arainbolt@kfocus.org>
Closes: https://lore.kernel.org/linux-usb/20241009220118.70bfedd0@kf-ir16/
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The read will never succeed if NVM wasn't initialized due to an unknown
format.
Add a new callback for visibility to only show when supported.
Cc: stable@vger.kernel.org
Fixes: aef9c693e7 ("thunderbolt: Move vendor specific NVM handling into nvm.c")
Reported-by: Richard Hughes <hughsient@gmail.com>
Closes: https://github.com/fwupd/fwupd/issues/8200
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Intel Panther Lake-M/P has the same integrated Thunderbolt/USB4
controller as Lunar Lake. Add these PCI IDs to the driver list of
supported devices.
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Here is the big set of USB and Thunderbolt changes for 6.13-rc1.
Overall, a pretty slow development cycle, the majority of the work going
into the debugfs interface for the thunderbolt (i.e. USB4) code, to help
with debugging the myrad ways that hardware vendors get their interfaces
messed up. Other than that, here's the highlights:
- thunderbolt changes and additions to debugfs interfaces
- lots of device tree updates for new and old hardware
- UVC configfs gadget updates and new apis for features
- xhci driver updates and fixes
- dwc3 driver updates and fixes
- typec driver updates and fixes
- lots of other small updates and fixes, full details in the shortlog
All of these have been in linux-next for a while with no reported
problems.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-----BEGIN PGP SIGNATURE-----
iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZ0lBqA8cZ3JlZ0Brcm9h
aC5jb20ACgkQMUfUDdst+ynTXQCfSs0ldBqZoINU/22q8BUg7ybb+pcAoL5EbbEm
b2igfp6YIEWAtUkactmO
=gwwq
-----END PGP SIGNATURE-----
Merge tag 'usb-6.13-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.13-rc1.
Overall, a pretty slow development cycle, the majority of the work
going into the debugfs interface for the thunderbolt (i.e. USB4) code,
to help with debugging the myrad ways that hardware vendors get their
interfaces messed up. Other than that, here's the highlights:
- thunderbolt changes and additions to debugfs interfaces
- lots of device tree updates for new and old hardware
- UVC configfs gadget updates and new apis for features
- xhci driver updates and fixes
- dwc3 driver updates and fixes
- typec driver updates and fixes
- lots of other small updates and fixes, full details in the shortlog
All of these have been in linux-next for a while with no reported
problems"
* tag 'usb-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (148 commits)
usb: typec: tcpm: Add support for sink-bc12-completion-time-ms DT property
dt-bindings: usb: maxim,max33359: add usage of sink bc12 time property
dt-bindings: connector: Add time property for Sink BC12 detection completion
usb: dwc3: gadget: Remove dwc3_request->needs_extra_trb
usb: dwc3: gadget: Cleanup SG handling
usb: dwc3: gadget: Fix looping of queued SG entries
usb: dwc3: gadget: Fix checking for number of TRBs left
usb: dwc3: ep0: Don't clear ep0 DWC3_EP_TRANSFER_STARTED
Revert "usb: gadget: composite: fix OS descriptors w_value logic"
usb: ehci-spear: fix call balance of sehci clk handling routines
USB: make to_usb_device_driver() use container_of_const()
USB: make to_usb_driver() use container_of_const()
USB: properly lock dynamic id list when showing an id
USB: make single lock for all usb dynamic id lists
drivers/usb/storage: refactor min with min_t
drivers/usb/serial: refactor min with min_t
drivers/usb/musb: refactor min/max with min_t/max_t
drivers/usb/mon: refactor min with min_t
drivers/usb/misc: refactor min with min_t
drivers/usb/host: refactor min/max with min_t/max_t
...
This includes following USB4/Thunderbolt changes for the v6.13 merge
window:
- Add Gen 4 receiver lane margining support.
- Replace usage of deprecated PCI functions.
All these have been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmczF0UgHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKCsPxAAicCjT5tCbClp
oACICjaCNjqCh/8Bl9DApKwmi1SkWYXqbV7N5rUY+2QObPSGJLBV1U3G/PBuuqo9
QL7mj9zGQVpeSHmwqsrTO7WfgxQOvOWS9tvRXjey6lbpNlkT6+yZSCVngIS4UyYe
oUk/9gNCLTQA2QDKXdruh0vN+/EE5L9gsdKBg9pODA84HtcfW9L9dB0Q8T6hD6vI
SZpOuAQ216DNuimfUbj0YZPwjp0jr5/hjx8grc5S0g+hbbjJ3srobPU17sec+qTX
Yu1m+GyKohS4kd31+Ym8v4OZg9M+mF5neRT/booyGztHXPkuy7Yir5LyCmKPixFh
ysVU0u2qIpNOMHMWg+8RjIgKtGpj9cdVJH63eeTytPLdSgH+jl6318LOpVTWBpYH
j446DKfL8X4q15lDsxkyJ4kcJ37J7j317XDAMfdJXAAN4mISOI1vgCauJRWCzMTJ
ToSnH3Dh1VgeLjGpW/bzjb8kUH72OFejGl8hKl3qRKfrhHk/9dl2QOWaRXHVp/2O
gqPmALyrrAmAakC3g2Tr94usJHcO6LlS7S1+/+cMe2Es4da3YAl70fLJrex7yCcH
MMV+Z0VALpVCAzLhwBZMpmJhbiX4LkdJape8A0qmSQS5fv74w3Estf/Ae46ByPM6
jpbrfq/JzmrcgsbyCDEJc2s529QO6aw=
=B882
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v6.13-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v6.13 merge window
This includes following USB4/Thunderbolt changes for the v6.13 merge
window:
- Add Gen 4 receiver lane margining support.
- Replace usage of deprecated PCI functions.
All these have been in linux-next with no reported issues.
* tag 'thunderbolt-for-v6.13-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
thunderbolt: Replace deprecated PCI functions
thunderbolt: debugfs: Implement asymmetric lane margining
thunderbolt: debugfs: Don't hardcode margining results size
thunderbolt: debugfs: Refactor hardware margining result parsing
thunderbolt: debugfs: Replace margining lane numbers with an enum
thunderbolt: debugfs: Replace "both lanes" with "all lanes"
thunderbolt: debugfs: Implement Gen 4 margining eye selection
thunderbolt: debugfs: Add USB4 Gen 4 margining capabilities
thunderbolt: Don't hardcode margining capabilities size
This includes following USB4/Thunderbolt fixes for v6.12-rc7:
- Fix for retimer enumeration.
- Fix connection issue with Pluggable UD-4VPD USB4 dock.
Both have been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmcsjQIgHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKDBYw/9GC5UoKtAJQwX
/FyJBHxmy6EKgnx0YF7pREn+gv4Ryn7kseRhasqsxvW/3JDW+G3Vk+S0uRWQh7lf
DIniv7JikL/Fn5ZGUW4qO8mNxB/4NHEIii6EuQyrthA5dZPeV8Y5eYBWXLvzD/0i
jqH0rZCFevuMlXYqcX9SOxZQDBA41HBSqyX/t5QLLO4dlPu/AeDkQKKNtsob3dUO
cvnt92Hb7yPG7kmT7WIQHgAGd9qKrU/hYMiQIVzY3naD103jWa+Z8JcsDas5DJho
efYiiX4EhajMuoiOxtLKFoqxhk0y6xCdqzF/CbTdGHkl92dU5+ZlTMnn6wM8PY1K
6C/FLzs2KqiF71sLuTGSz2E9NjHY8ZG51csyzcfNCNVEpo74J4siS4DDtd/bGOgh
s5BhviQEQQP7dgqD0ZgV6uZFwfdpCHEankjyevIoSZyKl42LaEicRh9hJnEyLoai
inzbfTVswnQIpnhoWytUTmm7oP/IFTLMyb4qiemyZI0hKUuSPoMLw+RL3NERLY5M
HAhR2QbFFNvbYuUOSMYLxMyCYtVdQPorrsE8LxkStpO2O5Tno5xFCMxQHQV0rAA+
zKWOkos0mcWRRmjHC/T1RXrY2W0AWZ+9NLDG3+vTDeVNivfZ07LW5n5fl+f6zXBT
yFM/yIMND/FRSC8U0a+e8mSi4y0FzLA=
=TWJK
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v6.12-rc7' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
thunderbolt: Fixes for v6.12-rc7
This includes following USB4/Thunderbolt fixes for v6.12-rc7:
- Fix for retimer enumeration.
- Fix connection issue with Pluggable UD-4VPD USB4 dock.
Both have been in linux-next with no reported issues.
* tag 'thunderbolt-for-v6.12-rc7' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
thunderbolt: Fix connection issue with Pluggable UD-4VPD dock
thunderbolt: Add only on-board retimers when !CONFIG_USB4_DEBUGFS_MARGINING
pcim_iomap_table() and pcim_request_regions() have been deprecated in
commit e354bb84a4 ("PCI: Deprecate pcim_iomap_table(),
pcim_iomap_regions_request_all()") and commit d140f80f60 ("PCI:
Deprecate pcim_iomap_regions() in favor of pcim_iomap_region()").
Replace these functions with pcim_iomap_region().
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Rick reported that his Pluggable USB4 dock does not work anymore after
upgrading to v6.10 kernel.
It looks like commit c6ca1ac9f4 ("thunderbolt: Increase sideband
access polling delay") makes the device router enumeration happen later
than what might be expected by the dock (although there is no such limit
in the USB4 spec) which probably makes it assume there is something
wrong with the high-speed link and reset it. After the link is reset the
same issue happens again and again.
For this reason lower the sideband access delay from 5ms to 1ms. This
seems to work fine according to Rick's testing.
Reported-by: Rick Lahaye <rick@581238.xyz>
Closes: https://lore.kernel.org/linux-usb/000f01db247b$d10e1520$732a3f60$@581238.xyz/
Tested-by: Rick Lahaye <rick@581238.xyz>
Fixes: c6ca1ac9f4 ("thunderbolt: Increase sideband access polling delay")
Cc: stable@vger.kernel.org
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Add support for the RX2 receiver which is used as the third receiver in
asymmetric links. This requires expanding the results array for the
additional third data word of the hardware margining results.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Use ARRAY_SIZE() when available or pass in the array size derived from
it. This is in preparation for adding another result data word for
supporting Gen 4 asymmetric links with an additional lane.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Make the result parsing and formatting code less repetitive in
preparation for adding another result for Gen 4 asymmetric link support.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Replace the raw values and macros with an enum and use it consistently.
No functional changes.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
With USB4 Gen 4, the link can be configured into an asymmetric mode,
where there are three receivers and only one transmitter. The USB4
specification also uses the "all lanes" nomenclature instead of "both
lanes".
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Add a debugfs knob for USB4 Gen 4 margining eye selection. Gen 4 uses
3-level pulse amplitude modulation (PAM3) which changes how margining
measurements are made because PAM3 has two eyes per lane from which
the margins can be measured.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Parse the Gen 4 specific capabilities. Change the return types of
independent_voltage_margins() and independent_time_margins() to enums
that distinguish between the Gen 2/3 and Gen 4 margins since they behave
differently between generations.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Use or pass ARRAY_SIZE() of the capabilities array instead of hardcoding
it. USB4 Gen 4 introduces an additional data word, which requires
expanding the capabilities array.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Normally there is no need to enumerate retimers on the other side of the
cable. This is only needed in special cases where user wants to run
receiver lane margining against the downstream facing port of a retimer.
Furthermore this might confuse the userspace tools such as fwupd because
it cannot read the information it expects from these retimers.
Fix this by changing the retimer enumeration code to add only on-board
retimers when CONFIG_USB4_DEBUGFS_MARGINING is not enabled.
Reported-by: AceLan Kao <acelan.kao@canonical.com>
Tested-by: AceLan Kao <acelan.kao@canonical.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219420
Cc: stable@vger.kernel.org
Fixes: ff6ab055e0 ("thunderbolt: Add receiver lane margining support for retimers")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently, when configuring TMU (Time Management Unit) mode of a given
router, we take into account only its own TMU requirements ignoring
other routers in the domain. This is problematic if the router we are
configuring has lower TMU requirements than what is already configured
in the domain.
In the scenario below, we have a host router with two USB4 ports: A and
B. Port A connected to device router #1 (which supports CL states) and
existing DisplayPort tunnel, thus, the TMU mode is HiFi uni-directional.
1. Initial topology
[Host]
A/
/
[Device #1]
/
Monitor
2. Plug in device #2 (that supports CL states) to downstream port B of
the host router
[Host]
A/ B\
/ \
[Device #1] [Device #2]
/
Monitor
The TMU mode on port B and port A will be configured to LowRes which is
not what we want and will cause monitor to start flickering.
To address this we first scan the domain and search for any router
configured to HiFi uni-directional mode, and if found, configure TMU
mode of the given router to HiFi uni-directional as well.
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>
KASAN reported following issue:
BUG: KASAN: stack-out-of-bounds in tb_retimer_scan+0xffe/0x1550 [thunderbolt]
Read of size 4 at addr ffff88810111fc1c by task kworker/u56:0/11
CPU: 0 UID: 0 PID: 11 Comm: kworker/u56:0 Tainted: G U 6.11.0+ #1387
Tainted: [U]=USER
Workqueue: thunderbolt0 tb_handle_hotplug [thunderbolt]
Call Trace:
<TASK>
dump_stack_lvl+0x6c/0x90
print_report+0xd1/0x630
kasan_report+0xdb/0x110
__asan_report_load4_noabort+0x14/0x20
tb_retimer_scan+0xffe/0x1550 [thunderbolt]
tb_scan_port+0xa6f/0x2060 [thunderbolt]
tb_handle_hotplug+0x17b1/0x3080 [thunderbolt]
process_one_work+0x626/0x1100
worker_thread+0x6c8/0xfa0
kthread+0x2c8/0x3a0
ret_from_fork+0x3a/0x80
ret_from_fork_asm+0x1a/0x30
This happens because the loop variable still gets incremented by one so
max becomes 3 instead of 2, and this makes the second loop read past the
the array declared on the stack.
Fix this by assigning to max directly in the loop body.
Fixes: ff6ab055e0 ("thunderbolt: Add receiver lane margining support for retimers")
CC: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This includes following USB4/Thunderbolt changes for the v6.12 merge
window:
- Improvements for software receiver lane margining
- Enable support for optional voltage offset range for receiver lane
margining.
All these have been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmbgDt0gHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKBbUA//Y+q9ZywuKtRb
sTFttZgr82BDo1cEb2mrpxFkH9veL0cUSwAaLut9xaNwcAoGxBKbhVRE8g5G1p3W
2zGxyGcWusPe9PMLybjpfWOy5iczU3YNA6zqppimprkA1edkppv7BBzunGiVEPW8
hs54/rp7AhtphPQI/2HCifQ6YuJ3GpnrF/GgRgePvkbMoAXxq1GnrNBN3L2X1UNz
gxEtykUz8bXRwTKwP6EqdQA4cVSXhWQefXNDbgnVhbwGQLuF4aYfDU2G4Zdv02UD
NpU9h8UJ5zOFHHsYVaPicJSFTS7n0Saqt379utSuUJkKYvn6kXqFsuW6cGDc4lET
N35LH04X9HTDlwCBYF9bVe6vsxVxnBaOJ/N8kbSkkdr53H6MnD7lQqMgSbCO0opH
f/ziJNVEUAFvdjykUIE58HXICT+kmF/IWUdJnUfsx3z1wHk0XUgpO/tJVjGSA1OC
VOowGuokES7XvU5gyZ3RbEEhKz0mYjw1r14cQULy5POF/B402BGjQLqB1ThNNN0e
ynIWLFsRDFdaDw3NG1P5qZhK8TgLQ/yoLJ+OrzMPsbRtd64tGUGx3ULzBxUDZaNg
diFH9oX6iaQ1yIX5c7iYGKVtmTrMF+6NqQ3TaFwdVps8N4n+CkZKwjxaqiBkKao1
cUzOByKSehj7Qdi2DcyQvN+tuwxSops=
=bn+4
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v6.12-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v6.12 merge window
This includes following USB4/Thunderbolt changes for the v6.12 merge
window:
- Improvements for software receiver lane margining
- Enable support for optional voltage offset range for receiver lane
margining.
All these have been in linux-next with no reported issues.
* tag 'thunderbolt-for-v6.12-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
thunderbolt: Improve software receiver lane margining
thunderbolt: Add optional voltage offset range for receiver lane margining
thunderbolt: Consolidate margining parameters into a structure
thunderbolt: Add missing usb4_port_sb_read() to usb4_port_sw_margin()
USB core will create device links between tunneled USB3 devices and
USB4 Host Interface during USB device creation.
Those device links are removed with the tunneled USB3 devices, allowing
USB4 Host Interface to runtime suspend if USB3 tunnels are not used.
So remove device link creation between USB4 Host Interface and USB3 xHC
during NHI probe
Reported-by: Rajaram Regupathy <rajaram.regupathy@intel.com>
Reported-by: Saranya Gopal <saranya.gopal@intel.com>
Tested-by: Saranya Gopal <saranya.gopal@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240830152630.3943215-5-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 <r.kannappan@intel.com>
Co-developed-by: Rene Sapiens <rene.sapiens@intel.com>
Signed-off-by: Rene Sapiens <rene.sapiens@intel.com>
Co-developed-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
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 <rene.sapiens@intel.com>
Co-developed-by: R Kannappan <r.kannappan@intel.com>
Signed-off-by: R Kannappan <r.kannappan@intel.com>
Co-developed-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
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 <rene.sapiens@intel.com>
Co-developed-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Synchronize the operation completion by reading back the software
margining operation completion metadata into margining->results.
Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Co-developed-by: R Kannappan <r.kannappan@intel.com>
Signed-off-by: R Kannappan <r.kannappan@intel.com>
Co-developed-by: Rene Sapiens <rene.sapiens@intel.com>
Signed-off-by: Rene Sapiens <rene.sapiens@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
I noticed that when we do discrete host router NVM upgrade and it gets
hot-removed from the PCIe side as a result of NVM firmware authentication,
if there is another host connected with enabled paths we hang in tearing
them down. This is due to fact that the Thunderbolt networking driver
also tries to cleanup the paths and ends up blocking in
tb_disconnect_xdomain_paths() waiting for the domain lock.
However, at this point we already cleaned the paths in tb_stop() so
there is really no need for tb_disconnect_xdomain_paths() to do that
anymore. Furthermore it already checks if the XDomain is unplugged and
bails out early so take advantage of that and mark the XDomain as
unplugged when we remove the parent router.
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Here is the big set of driver core changes for 6.11-rc1.
Lots of stuff in here, with not a huge diffstat, but apis are evolving
which required lots of files to be touched. Highlights of the changes
in here are:
- platform remove callback api final fixups (Uwe took many releases to
get here, finally!)
- Rust bindings for basic firmware apis and initial driver-core
interactions. It's not all that useful for a "write a whole driver
in rust" type of thing, but the firmware bindings do help out the
phy rust drivers, and the driver core bindings give a solid base on
which others can start their work. There is still a long way to go
here before we have a multitude of rust drivers being added, but
it's a great first step.
- driver core const api changes. This reached across all bus types,
and there are some fix-ups for some not-common bus types that
linux-next and 0-day testing shook out. This work is being done to
help make the rust bindings more safe, as well as the C code, moving
toward the end-goal of allowing us to put driver structures into
read-only memory. We aren't there yet, but are getting closer.
- minor devres cleanups and fixes found by code inspection
- arch_topology minor changes
- other minor driver core cleanups
All of these have been in linux-next for a very long time with no
reported problems.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-----BEGIN PGP SIGNATURE-----
iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZqH+aQ8cZ3JlZ0Brcm9h
aC5jb20ACgkQMUfUDdst+ymoOQCfVBdLcBjEDAGh3L8qHRGMPy4rV2EAoL/r+zKm
cJEYtJpGtWX6aAtugm9E
=ZyJV
-----END PGP SIGNATURE-----
Merge tag 'driver-core-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH:
"Here is the big set of driver core changes for 6.11-rc1.
Lots of stuff in here, with not a huge diffstat, but apis are evolving
which required lots of files to be touched. Highlights of the changes
in here are:
- platform remove callback api final fixups (Uwe took many releases
to get here, finally!)
- Rust bindings for basic firmware apis and initial driver-core
interactions.
It's not all that useful for a "write a whole driver in rust" type
of thing, but the firmware bindings do help out the phy rust
drivers, and the driver core bindings give a solid base on which
others can start their work.
There is still a long way to go here before we have a multitude of
rust drivers being added, but it's a great first step.
- driver core const api changes.
This reached across all bus types, and there are some fix-ups for
some not-common bus types that linux-next and 0-day testing shook
out.
This work is being done to help make the rust bindings more safe,
as well as the C code, moving toward the end-goal of allowing us to
put driver structures into read-only memory. We aren't there yet,
but are getting closer.
- minor devres cleanups and fixes found by code inspection
- arch_topology minor changes
- other minor driver core cleanups
All of these have been in linux-next for a very long time with no
reported problems"
* tag 'driver-core-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (55 commits)
ARM: sa1100: make match function take a const pointer
sysfs/cpu: Make crash_hotplug attribute world-readable
dio: Have dio_bus_match() callback take a const *
zorro: make match function take a const pointer
driver core: module: make module_[add|remove]_driver take a const *
driver core: make driver_find_device() take a const *
driver core: make driver_[create|remove]_file take a const *
firmware_loader: fix soundness issue in `request_internal`
firmware_loader: annotate doctests as `no_run`
devres: Correct code style for functions that return a pointer type
devres: Initialize an uninitialized struct member
devres: Fix memory leakage caused by driver API devm_free_percpu()
devres: Fix devm_krealloc() wasting memory
driver core: platform: Switch to use kmemdup_array()
driver core: have match() callback in struct bus_type take a const *
MAINTAINERS: add Rust device abstractions to DRIVER CORE
device: rust: improve safety comments
MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer
MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER
firmware: rust: improve safety comments
...
In the match() callback, the struct device_driver * should not be
changed, so change the function callback to be a const *. This is one
step of many towards making the driver core safe to have struct
device_driver in read-only memory.
Because the match() callback is in all busses, all busses are modified
to handle this properly. This does entail switching some container_of()
calls to container_of_const() to properly handle the constant *.
For some busses, like PCI and USB and HV, the const * is cast away in
the match callback as those busses do want to modify those structures at
this point in time (they have a local lock in the driver structure.)
That will have to be changed in the future if they wish to have their
struct device * in read-only-memory.
Cc: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Alex Elder <elder@kernel.org>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Link: https://lore.kernel.org/r/2024070136-wrongdoer-busily-01e8@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 <aapo.vienamo@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
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 <mika.westerberg@linux.intel.com>
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 <mika.westerberg@linux.intel.com>
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 <mika.westerberg@linux.intel.com>
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 <mika.westerberg@linux.intel.com>
It is supposed to be close with the other lane margining functions so
move it there. No functional changes.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This allows the interested parties to find the Thunderbolt/USB4
debugging tools (aka tbtools) easier in case they need to look at the
information under debugfs entries.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
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 <aapo.vienamo@linux.intel.com>
Fixes: d0f1e0c2a6 ("thunderbolt: Add support for receiver lane margining")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This includes following USB4/Thunderbolt changes for the v6.10 merge
window:
- Enable NVM firmare upgrade on Intel Maple Ridge Thunderbolt 4
controller
- Improve USB3 tunnel bandwidth calculation
- Improve sideband access
- Minor cleanups and fixes.
All these have been in linux-next with no reported issues.
-----BEGIN PGP SIGNATURE-----
iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmY9p68gHG1pa2Eud2Vz
dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKAncQ/7BHfSiGFgAxo0
COALJ0sChaYBT7qOfnf6QVJv6jPV1pfRx21FrTwjbwQXGZVT+Q2QmMK66TvHviO2
5pCeJdpdphMpUR5ZQE1USY4Ig3DW3TBmDEx2HxtdOzl7ot60eVQNpcnrrp+wWJNO
ha1tWnDt2mTVsZoASDReztdZCZbZXS0zW3ODdfXMqaeRxI+/IwvmfmRo5YvL6qBG
ChdMHTMKEgPSvZY918fMVoJi46ugOiTJgXfk4X7fmGeRIMUPpcU5k6hk9TDxK9bV
L2Xi930AhSACzTNto+mLEyfdNeErkot2V4Yhx5OVaKPpLdjOjN6p1Lrh5GkcgP+F
mGG1as793JZX7VyBDrIhWp2wglELqQcZKTlmQJkuXPXyDCfLWeJTaqKDx9z1de4s
w0ltpS5cgDyeCRNLTTmY5ARq+CyUVMb/tE687ZkqWrrxYRaMfsHCZe0pupZgPVKA
OzH9ItC1xlDf7ErpiZI6whOeTunJ9pBRvhQmx2m5MYq+Gcs/kC/EH0NMO6nTjLz5
7bbTiih7WMgJUFR953dUbC/LqAo0Xg5V2dSlSU+rAJWQ4ocOVRasCK3jxp9StMzf
bdaJZbD7mDR5BT/xVhMYDYZnZiG2huwPag6L1OXyRSVPl1RLJpznIu3TvcqcunLN
MQPZKiW3S3tGPYlRmAhxmi+M2nwdbP4=
=fiCC
-----END PGP SIGNATURE-----
Merge tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next
Mika writes:
thunderbolt: Changes for v6.10 merge window
This includes following USB4/Thunderbolt changes for the v6.10 merge
window:
- Enable NVM firmare upgrade on Intel Maple Ridge Thunderbolt 4
controller
- Improve USB3 tunnel bandwidth calculation
- Improve sideband access
- Minor cleanups and fixes.
All these have been in linux-next with no reported issues.
* tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
thunderbolt: Correct trace output of firmware connection manager packets
thunderbolt: Fix kernel-doc for tb_tunnel_alloc_dp()
thunderbolt: Fix uninitialized variable in tb_tunnel_alloc_usb3()
thunderbolt: There are only 5 basic router registers in pre-USB4 routers
thunderbolt: No need to loop over all retimers if access fails
thunderbolt: Increase sideband access polling delay
thunderbolt: Get rid of TB_CFG_PKG_PREPARE_TO_SLEEP
thunderbolt: Use correct error code with ERROR_NOT_SUPPORTED
thunderbolt: Allow USB3 bandwidth to be lower than maximum supported
thunderbolt: Fix calculation of consumed USB3 bandwidth on a path
thunderbolt: Enable NVM upgrade support on Intel Maple Ridge
These are special packets that the drivers sends directly to the
firmware connection manager (ICM). These do not have route string
because they are always consumed by the firmware connection manager
running on the host router, so hard-code that in the output accordingly.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
In case of no bandwidth available for DP tunnel, the function get the arguments
@max_up and @max_down set to zero. Fix the kernel-doc to describe more
accurately the purpose of the function.
No functional changes.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently in case of no bandwidth available for USB3 tunnel, we are left
with uninitialized variable that can lead to huge negative allocated
bandwidth.
Fix this by initializing the variable to zero. While there, fix the
kernel-doc to describe more accurately the purpose of the function
tb_tunnel_alloc_usb3().
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-usb/6289898b-cd63-4fb8-906a-1b6977321af9@moroto.mountain/
Fixes: 25d905d2b8 ("thunderbolt: Allow USB3 bandwidth to be lower than maximum supported")
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
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 <rajaram.regupathy@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
When we read the NVM authentication status or unsetting the inbound SBTX
there is no point to continue the loop after first access to a retimer
fails because there won't be any more retimers after this anyway so bail
out from the loops early.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
The USB4 sideband access is slow compared to the high-speed link and the
access timing parameters are tens of milliseconds according the spec. To
avoid too much unnecessary polling for the sideband pass the wait delay
to usb4_port_wait_for_bit() and use larger (5ms) value compared to the
high-speed access.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
We check for -EOPNOTSUPP but tb_xdp_handle_error() translated it to
-ENOTSUPP instead which is dealt as "transient" error and retried after
a while. Fix this so that we bail out early when the other side clearly
tells us it is does not support this.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently USB3 tunnel setup fails if USB4 link available bandwidth is too low
to allow USB3 Maximum Supported Link Rate. In reality, this limitation is not
needed, and may cause failure of USB3 tunnel establishment, if USB4 link
available bandwidth is lower than USB3 Maximum Supported Link Rate. E.g. if we
connect to USB4 v1 host router, a USB4 v1 device router, via 10 Gb/s cable.
Hence, here we discard this limitation, and now we only limit USB3 bandwidth
allocation to be not higher than 90% of USB3 Max Supported Link Rate (for first
USB3 tunnel only).
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently, when setup a new USB3 tunnel that is starting from downstream USB3
adapter of first depth router (or deeper), to upstream USB3 adapter of a second
depth router (or deeper), we calculate consumed bandwidth. For this calculation
we take into account first USB3 tunnel consumed bandwidth while we shouldn't,
because we just recalculating the first USB3 tunnel allocated bandwidth.
Fix that, so that more bandwidth is available for the new USB3 tunnel being
setup.
While there, fix the kernel-doc to decribe more accurately the purpose of the
function.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Currently we notify PM core about occurred wakes after any resume. This
is not actually needed after resume from runtime suspend. Hence, notify
PM core about occurred wakes only after resume from system sleep. Also,
if the wake occurred in USB4 router upstream port, we don't notify the
PM core about it since it is not actually needed and can cause
unexpected autowake (e.g. if /sys/power/wakeup_count is used).
While there add the missing kernel-doc for tb_switch_resume().
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>