Commit Graph

184 Commits

Author SHA1 Message Date
Linus Torvalds a93e884edf Driver core changes for 6.3-rc1
Here is the large set of driver core changes for 6.3-rc1.
 
 There's a lot of changes this development cycle, most of the work falls
 into two different categories:
   - fw_devlink fixes and updates.  This has gone through numerous review
     cycles and lots of review and testing by lots of different devices.
     Hopefully all should be good now, and Saravana will be keeping a
     watch for any potential regression on odd embedded systems.
   - driver core changes to work to make struct bus_type able to be moved
     into read-only memory (i.e. const)  The recent work with Rust has
     pointed out a number of areas in the driver core where we are
     passing around and working with structures that really do not have
     to be dynamic at all, and they should be able to be read-only making
     things safer overall.  This is the contuation of that work (started
     last release with kobject changes) in moving struct bus_type to be
     constant.  We didn't quite make it for this release, but the
     remaining patches will be finished up for the release after this
     one, but the groundwork has been laid for this effort.
 
 Other than that we have in here:
   - debugfs memory leak fixes in some subsystems
   - error path cleanups and fixes for some never-able-to-be-hit
     codepaths.
   - cacheinfo rework and fixes
   - Other tiny fixes, full details are 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-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCY/ipdg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynL3gCgwzbcWu0So3piZyLiJKxsVo9C2EsAn3sZ9gN6
 6oeFOjD3JDju3cQsfGgd
 =Su6W
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the large set of driver core changes for 6.3-rc1.

  There's a lot of changes this development cycle, most of the work
  falls into two different categories:

   - fw_devlink fixes and updates. This has gone through numerous review
     cycles and lots of review and testing by lots of different devices.
     Hopefully all should be good now, and Saravana will be keeping a
     watch for any potential regression on odd embedded systems.

   - driver core changes to work to make struct bus_type able to be
     moved into read-only memory (i.e. const) The recent work with Rust
     has pointed out a number of areas in the driver core where we are
     passing around and working with structures that really do not have
     to be dynamic at all, and they should be able to be read-only
     making things safer overall. This is the contuation of that work
     (started last release with kobject changes) in moving struct
     bus_type to be constant. We didn't quite make it for this release,
     but the remaining patches will be finished up for the release after
     this one, but the groundwork has been laid for this effort.

  Other than that we have in here:

   - debugfs memory leak fixes in some subsystems

   - error path cleanups and fixes for some never-able-to-be-hit
     codepaths.

   - cacheinfo rework and fixes

   - Other tiny fixes, full details are in the shortlog

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

[ Geert Uytterhoeven points out that that last sentence isn't true, and
  that there's a pending report that has a fix that is queued up - Linus ]

* tag 'driver-core-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (124 commits)
  debugfs: drop inline constant formatting for ERR_PTR(-ERROR)
  OPP: fix error checking in opp_migrate_dentry()
  debugfs: update comment of debugfs_rename()
  i3c: fix device.h kernel-doc warnings
  dma-mapping: no need to pass a bus_type into get_arch_dma_ops()
  driver core: class: move EXPORT_SYMBOL_GPL() lines to the correct place
  Revert "driver core: add error handling for devtmpfs_create_node()"
  Revert "devtmpfs: add debug info to handle()"
  Revert "devtmpfs: remove return value of devtmpfs_delete_node()"
  driver core: cpu: don't hand-override the uevent bus_type callback.
  devtmpfs: remove return value of devtmpfs_delete_node()
  devtmpfs: add debug info to handle()
  driver core: add error handling for devtmpfs_create_node()
  driver core: bus: update my copyright notice
  driver core: bus: add bus_get_dev_root() function
  driver core: bus: constify bus_unregister()
  driver core: bus: constify some internal functions
  driver core: bus: constify bus_get_kset()
  driver core: bus: constify bus_register/unregister_notifier()
  driver core: remove private pointer from struct bus_type
  ...
2023-02-24 12:58:55 -08:00
Greg Kroah-Hartman 162736b0d7 driver core: make struct device_type.uevent() take a const *
The uevent() callback in struct device_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Mark Gross <markgross@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Maximilian Luz <luzmaximilian@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: Sean Young <sean@mess.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Won Chung <wonchung@google.com>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-6-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-27 13:45:36 +01:00
Mika Westerberg e70a8f3698 thunderbolt: Take CL states into account when waiting for link to come up
If CL states are enabled for the link it may be in these states too when
reading the lane adapter state but it will enter CL0 as soon as there is
traffic in the high-speed lanes. Upon discovery we want to make sure
that is accounted as the link being up, otherwise we end up tearing down
the topology with no good reason.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2023-01-17 11:36:55 +02:00
Andy Shevchenko 87fa05b6db thunderbolt: Use str_enabled_disabled() helper
Use str_enabled_disabled() helper instead of open coding the same.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-10-23 09:46:05 +03:00
Linus Torvalds d3dcbe24a0 USB/Thunderbolt changes for 6.1-rc1
Here is the big set of USB and Thunderbolt driver changes for 6.1-rc1.
 
 Nothing major in here, lots of little things with new devices supported
 and updates for a few drivers.  Highlights include:
 	- thunderbolt/USB4 devices supported a bit better than before,
 	  and some new ids to enable new hardware devices
 	- USB gadget uvc updates for newer video formats and better v4l
 	  integration (the v4l portions were acked by those maintainers)
 	- typec updates for tiny issues and more typec drivers for new
 	  chips.
 	- xhci tiny updates for minor issues
 	- big usb-serial ftdi_sio driver update to handle new devices
 	  better
 	- lots of tiny dwc3 fixes and updates for the IP block that is
 	  showing up everywhere these days
 	- dts updates for new devices being supported
 	- other tiny janitorial and cleanups fixes for lots of different
 	  USB drivers.  Full details are in the shortlog.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCY0BN9g8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yljdgCdH4Fev4Nvf2Nokfv0q0krcRB3YpUAn1aZfpb/
 EbgxsxhPnTJg+mmXyLms
 =IxUy
 -----END PGP SIGNATURE-----

Merge tag 'usb-6.1-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 driver changes for 6.1-rc1.

  Nothing major in here, lots of little things with new devices
  supported and updates for a few drivers. Highlights include:

   - thunderbolt/USB4 devices supported a bit better than before, and
     some new ids to enable new hardware devices

   - USB gadget uvc updates for newer video formats and better v4l
     integration (the v4l portions were acked by those maintainers)

   - typec updates for tiny issues and more typec drivers for new chips.

   - xhci tiny updates for minor issues

   - big usb-serial ftdi_sio driver update to handle new devices better

   - lots of tiny dwc3 fixes and updates for the IP block that is
     showing up everywhere these days

   - dts updates for new devices being supported

   - other tiny janitorial and cleanups fixes for lots of different USB
     drivers. Full details are in the shortlog.

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

* tag 'usb-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (169 commits)
  usb: gadget: uvc: don't put item still in use
  usb: gadget: uvc: Fix argument to sizeof() in uvc_register_video()
  usb: host: ehci-exynos: switch to using gpiod API
  Revert "usb: dwc3: Don't switch OTG -> peripheral if extcon is present"
  Revert "USB: fixup for merge issue with "usb: dwc3: Don't switch OTG -> peripheral if extcon is present""
  dt-bindings: usb: Convert FOTG210 to dt schema
  usb: mtu3: fix failed runtime suspend in host only mode
  USB: omap_udc: Fix spelling mistake: "tranceiver_ctrl" -> "transceiver_ctrl"
  usb: typec: ucsi_ccg: Disable UCSI ALT support on Tegra
  usb: typec: Replace custom implementation of device_match_fwnode()
  usb: typec: ucsi: Don't warn on probe deferral
  usb: add quirks for Lenovo OneLink+ Dock
  MAINTAINERS: switch dwc3 to Thinh
  usb: idmouse: fix an uninit-value in idmouse_open
  USB: PHY: JZ4770: Switch to use dev_err_probe() helper
  usb: phy: generic: Switch to use dev_err_probe() helper
  usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs
  usb: cdns3: remove dead code
  usb: cdc-wdm: Use skb_put_data() instead of skb_put/memcpy pair
  usb: musb: sunxi: Switch to use dev_err_probe() helper
  ...
2022-10-07 16:48:26 -07:00
Greg Kroah-Hartman bffcd14fac thunderbolt: Changes for v6.1 merge window
This includes following Thunderbolt/USB4 changes for the v6.1 merge
 window:
 
   - Support for Intel Meteor Lake integrated Thunderbolt/USB4 controller
   - Support for ASMedia USB4 controller NVM firmware upgrade
   - Receiver lane margining support
   - Few fixes and cleanups.
 
 All these have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmM0G3ogHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKAhEg/8CuUZvDwLog7O
 SbpKAPqGOvDC3EM0VhtJyjJAUVWImVaRuSHAWEHn/XJAICaRTxMJJM7xoJnr+X7O
 4VMFzPhF6oF+28VMzy8OLm15kiiNtpXimOKaXNXzoDzJ6aqjgr9KpHSpzhOx3MuF
 HUzhoMWk2RHwnrkxlpewU9wJg8ZtG6syI5QV534KsqIwxOcO+8pr7nKz8V8HrUt9
 EwFIgU4op/eKCsgeLmotw/8CXI33ezIheMeUdSit3Gqa3Ey9u/JtzVaN7siEOhxy
 c3nBO8MgYhKaX0RCVKFGRm/YktFlrECStfDNhgtUbBS2lfoePcaeZGKwuCRpmhkj
 WicPxph8m5slKborqGVaoZtgtxqftOt1tWmvnJntqSLcOycPM4bX8gDfWZmoi6JX
 f+Vritdy9DDTCE00/Hc2gCpQG0rfX+DzpYvLz4Z8tIa5oU9X5CfCNs8qb20VSQAg
 xgmyRe+6/UzJAMKQ7uPy8wSKt/rpKOxsIQC+bhhdiN9g000YS7A56juiC0Z8IfrH
 rZae7pvtoD/r7lrJlRcFKtNPup+QrZZ/kdLzWpZbAmKYZ7DkI44KA4iHVBpt24rg
 8e23s2/U6ezhNMcR0dLWwIrE+KoiB15BkX9/J1CJxhJLW9lw+fxlSfeZDI0rfjE2
 HqcC/Fxx1dMNJykbXAyrO9HYmT551Vs=
 =67d1
 -----END PGP SIGNATURE-----

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

Mika writes:
  "thunderbolt: Changes for v6.1 merge window

   This includes following Thunderbolt/USB4 changes for the v6.1 merge
   window:
     - Support for Intel Meteor Lake integrated Thunderbolt/USB4 controller
     - Support for ASMedia USB4 controller NVM firmware upgrade
     - Receiver lane margining support
     - Few fixes and cleanups.

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

* tag 'thunderbolt-for-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: Explicitly enable lane adapter hotplug events at startup
  thunderbolt: Use dev_err_probe()
  thunderbolt: Convert to use sysfs_emit()/sysfs_emit_at() APIs
  thunderbolt: Fix spelling mistake "simultaneusly" -> "simultaneously"
  thunderbolt: debugfs: Fix spelling mistakes in seq_puts text
  thunderbolt: Add support for ASMedia NVM image format
  thunderbolt: Move vendor specific NVM handling into nvm.c
  thunderbolt: Provide tb_retimer_nvm_read() analogous to tb_switch_nvm_read()
  thunderbolt: Rename and make nvm_read() available for other files
  thunderbolt: Extend NVM version fields to 32-bits
  thunderbolt: Allow NVM upgrade of USB4 host routers
  thunderbolt: Add support for receiver lane margining
  thunderbolt: Add helper to check if CL states are enabled on port
  thunderbolt: Pass CL state bitmask to tb_port_clx_supported()
  thunderbolt: Move port CL state functions into correct place in switch.c
  thunderbolt: Move tb_xdomain_parent() to tb.h
  thunderbolt: Add support for Intel Meteor Lake
  thunderbolt: Add comment where Thunderbolt 4 PCI IDs start
  thunderbolt: Add DP OUT resource when DP tunnel is discovered
2022-09-30 13:44:59 +02:00
Mario Limonciello 5d2569cb4a thunderbolt: Explicitly enable lane adapter hotplug events at startup
Software that has run before the USB4 CM in Linux runs may have disabled
hotplug events for a given lane adapter.

Other CMs such as that one distributed with Windows 11 will enable hotplug
events. Do the same thing in the Linux CM which fixes hotplug events on
"AMD Pink Sardine".

Cc: stable@vger.kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-26 20:18:25 +03:00
Andy Shevchenko 8283fb57e4 thunderbolt: Convert to use sysfs_emit()/sysfs_emit_at() APIs
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the value
to be returned to user space.

While at it, use Elvis operator in some cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-24 09:22:01 +03:00
Mario Limonciello 31f87f705b thunderbolt: Explicitly reset plug events delay back to USB4 spec value
If any software has interacted with the USB4 registers before the Linux
USB4 CM runs, it may have modified the plug events delay. It has been
observed that if this value too large, it's possible that hotplugged
devices will negotiate a fallback mode instead in Linux.

To prevent this, explicitly align the plug events delay with the USB4
spec value of 10ms.

Cc: stable@vger.kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-22 14:32:16 +03:00
Szuying Chen aef9c693e7 thunderbolt: Move vendor specific NVM handling into nvm.c
As there will be more USB4 devices that support NVM firmware upgrade from
various vendors, it makes sense to split out the Intel specific NVM
image handling from the generic code. This moves the Intel specific NVM
handling into a new structure that will be matched by the device type
and the vendor ID. Do this for both routers and retimers.

This makes it easier to extend the NVM support to cover new vendors and
NVM image formats in the future.

Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-07 09:06:51 +03:00
Szuying Chen 7bfafaa518 thunderbolt: Rename and make nvm_read() available for other files
In order to support non-Intel NVM formats the vendor specific NVM
validation code that will live in nvm.c needs to be able to read various
parts of the NVM so make the function available outside of switch.c and
rename it accordingly.

Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-07 09:06:51 +03:00
Szuying Chen 5424e1bf16 thunderbolt: Extend NVM version fields to 32-bits
In order to support non-Intel NVM image formats extend the NVM major and
minor version to 32-bits to better accommondate different versioning
schemes.

No functional impact.

Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-07 09:06:50 +03:00
Mika Westerberg b12d2955e7 thunderbolt: Add helper to check if CL states are enabled on port
We will need this when enabling lane margining support.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-05 09:02:16 +03:00
Mika Westerberg 3846d01140 thunderbolt: Pass CL state bitmask to tb_port_clx_supported()
Instead of testing just a single CL state we can pass a bitmask of
states to check. This makes it simpler for callers of the function.

We also add a check for CL2 even though not fully supported by the
driver yet.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-05 09:02:16 +03:00
Mika Westerberg 95f8f1cbc8 thunderbolt: Move port CL state functions into correct place in switch.c
They should be close to other functions dealing with USB4 ports. No
functional impact.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-09-05 09:02:16 +03:00
Mika Westerberg 93a3c0d4e8 thunderbolt: Check router generation before connecting xHCI
Only Thunderbolt 3 routers need the xHCI connection flow. This also
ensures the router actually has both lane adapters (1 and 3). While
there move declaration of the boolean variables inside the block where
they are being used.

Fixes: 30a4eca69b ("thunderbolt: Add internal xHCI connect flows for Thunderbolt 3 devices")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-08-18 11:55:52 +03:00
Gil Fine b017a46d48 thunderbolt: Add CL1 support for USB4 and Titan Ridge routers
In this patch we add support for a second low power state of the link: CL1.
Low power states (called collectively CLx) are used to reduce
transmitter and receiver power when a high-speed lane is idle.
We enable it, if both sides of the link support it,
and only for the first hop router (i.e. the first device that connected
to the host router). This is needed for better thermal management.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06 12:24:56 +03:00
Gil Fine b4e08d5d08 thunderbolt: Fix typos in CLx enabling
Fix few typos in CLx enabling.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06 12:19:23 +03:00
Gil Fine 418a5a3d65 thunderbolt: CLx disable before system suspend only if previously enabled
Disable CLx before system suspended only if previously was enabled.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-06-06 12:19:23 +03:00
Mika Westerberg 0a2e1667a7 thunderbolt: Ignore port locked error in tb_port_wait_for_link_width()
Sometimes when polling for the port after target link width is changed
we get back port locked notification (because the link actually was
reset and then re-trained). Instead of bailing out we can ignore these
when polling for the width change as this is expected.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-05-05 09:25:16 +03:00
Mika Westerberg 0e14dd5e14 thunderbolt: Split setting link width and lane bonding into own functions
When bonding lanes over XDomain the host that has "higher" UUID triggers
link re-train for bonding, and the host that has "lower" UUID just waits
for this to happen. To support this split setting the link width and
triggering the actual bonding a separate functions that can be called as
needed.

While there remove duplicated empty line in the kernel-doc comment of
tb_port_lane_bonding_disable().

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-05-05 09:25:04 +03:00
Mika Westerberg 90f720d229 thunderbolt: Add debug logging when lane is enabled/disabled
This is useful when debugging possible issues.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-05-05 09:24:49 +03:00
Mario Limonciello 6915812bbd thunderbolt: Do not make DROM read success compulsory
The USB4 specification doesn't make any requirements that reading
a device router's DROM is needed for the operation of the device.

Other connection manager solutions don't necessarily read it or gate
the usability of the device on whether it was read.

So make failures when reading the DROM show warnings but not
fail the initialization of the router.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-03-04 17:10:36 +03:00
Mario Limonciello a283de3ec6 thunderbolt: Do not resume routers if UID is not set
Routers might not have a UID set if the DROM read failed during
initialization previously.

Normally upon resume the UID is re-read to confirm it's the same
device connected.
* If the DROM read failed during init but then succeeded during
  resume it could either be a new device or faulty device
* If the DROM read failed during init and also failed during resume
  it might be a different device plugged in all together.

Detect this situation and prevent re-using the same configuration in
these cirucmstances.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-03-04 17:10:36 +03:00
Mika Westerberg 30a4eca69b thunderbolt: Add internal xHCI connect flows for Thunderbolt 3 devices
Both Alpine Ridge and Titan Ridge require special flows in order to
activate the internal xHCI controller when there is USB device connected
to the downstream type-C port. This implements the missing flows for
both.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2022-02-02 13:56:51 +03:00
Gil Fine fa487b2a90 thunderbolt: Add module parameter for CLx disabling
Add a module parameter that allows user to completely disable CLx
functionality in case problems are found.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-28 10:43:56 +03:00
Gil Fine 43f977bc60 thunderbolt: Enable CL0s for Intel Titan Ridge
Low power link states (called collectively CLx) are used to reduce
transmitter and receiver power when a high-speed lane is idle. The
simplest one being called CL0s. Follow what we already do for USB4
device routers and enable CL0s for Intel Titan Ridge device router too.
This allows better thermal management.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-28 10:43:56 +03:00
Gil Fine 23ccd21ccb thunderbolt: Implement TMU time disruption for Intel Titan Ridge
Intel Titan Ridge based routers have slightly different flow for time
disruption than USB4 compliant routers. This makes it work on Titan
Ridge too. Needed to enable link low power states on Titan Ridge.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-22 17:13:14 +03:00
Gil Fine 1639664fb7 thunderbolt: Move usb4_switch_wait_for_bit() to switch.c
Currently usb4_switch_wait_for_bit() used only in usb4.c Moving to
switch.c to call it from other files. Also change the prefix to "tb_"
to follow to the naming convention.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-22 17:13:14 +03:00
Gil Fine 8a90e4fa3b thunderbolt: Add CL0s support for USB4 routers
In this patch we add enabling of CL0s - a low power state of the link.
Low power states (called collectively CLx) are used to reduce
transmitter and receiver power when a high-speed lane is idle. For now,
we add support only for first low power state: CL0s.  We enable it, if
both sides of the link support it, and only for the first hop router.
(i.e. the first device that connected to the host router). This is
needed for better thermal management.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-22 17:13:14 +03:00
Mika Westerberg ce05b99742 thunderbolt: Add debug logging of DisplayPort resource allocation
Add more debugging around DP resource allocation/de-allocation.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-07 15:18:34 +03:00
Mika Westerberg e5bb88e961 thunderbolt: Do not program path HopIDs for USB4 routers
These fields are marked read-only for USB4 routers so do not touch them
in that case. Update the kernel-doc of tb_dp_port_set_hops() to reflect
this too.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-07 15:18:33 +03:00
Mika Westerberg 6cb27a04fb thunderbolt: Do not allow subtracting more NFC credits than configured
This might happen if the boot firmware uses different amount of NFC
credits than what the router suggests, or we are dealing with pre-USB4
device.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-12-07 15:18:33 +03:00
Greg Kroah-Hartman bfa109d761 thunderbolt: Changes for v5.15 merge window
This includes following Thunderbolt/USB4 changes for the v5.15 merge
 window:
 
   * Include authorized value in the KOBJ_CHANGE event of a device router
   * A couple of improvements to get the driver working also with the AMD
     USB4 host controller.
 
 All these have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJUBAABCgA+FiEEVTdhRGBbNzLrSUBaAP2fSd+ZWKAFAmEkzz8gHG1pa2Eud2Vz
 dGVyYmVyZ0BsaW51eC5pbnRlbC5jb20ACgkQAP2fSd+ZWKCU1hAAiyvLKqFBsgye
 y8Zp6aeKkIjZ8wqnM0q97ba+cq23T/NwGsgSVDPLJesZc2hJPbAQIf0Iy3BKFjL3
 G5feynsWxLhHqnOsY3tL7iw1lUJoreeagPycZ5Bj4xkVDEsCbvyGnDCrlLsO4MzP
 Ia9zFN6kHyLGEmk0DROM1lAWZiAf7gIL6XW+mU2KDCYYaTcgQE2Im199yr3oqgi/
 8y4VsYkHolg3r0DtiwKBa5jFZ+iiCJJqAjz8+Yh12bjB0+dSBlxJWSpeH/fsDPwq
 FqMX6lMZuQPd71dlBOAIFr8RHjEg0owX8HUyxVb9MLoufhLFf0MIS/uKYRRfxTIH
 zcTf8LOmZIM8FUqtsnXT3nO7rdCz2YWUmmjPLkYX2Ssi1XoxWvkeWBfKmZyXHiKB
 uWwaHc3+uLSJSMvMqSLCTG6pK24Ux8C0LELoun4cj6CVi7018yLp+JiYAIn/QSoI
 QFIXg9EKC2WOXo539LxlkNVDnLumVhc3e/Sg+ykq8KVj++AfMbZzaOpvyhuDs9cj
 PHfSybRpC0+Q6RUMhazxjiMs2u8uRYkfp4kS6htg1MrxGcEbvv/22y0TuKl3D/nr
 pBEZGELgvnMd69TuhFP9yM4504P6BFaoQCDy9XhReeUTbRnmBBMDG5uSAoj/+gbe
 od3B0YhSIjujKBewMeXh689+30DYtqQ=
 =1bPR
 -----END PGP SIGNATURE-----

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

Mika writes:

thunderbolt: Changes for v5.15 merge window

This includes following Thunderbolt/USB4 changes for the v5.15 merge
window:

  * Include authorized value in the KOBJ_CHANGE event of a device router
  * A couple of improvements to get the driver working also with the AMD
    USB4 host controller.

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

* tag 'thunderbolt-for-v5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: Fix port linking by checking all adapters
  thunderbolt: Do not read control adapter config space
  thunderbolt: Handle ring interrupt by reading interrupt status register
  thunderbolt: Add vendor specific NHI quirk for auto-clearing interrupt status
  thunderbolt: Add authorized value to the KOBJ_CHANGE uevent
2021-08-24 15:31:33 +02:00
Sanjay R Mehta 42716425ad thunderbolt: Fix port linking by checking all adapters
In tb_switch_default_link_ports(), while linking of ports,
only odd-numbered ports (1,3,5..) are considered and even-numbered
ports are not considered.

AMD host router has lane adapters at 2 and 3 and link ports at adapter 2
is not considered due to which lane bonding gets disabled.

Hence added a fix such that all ports are considered during
linking of ports.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-08-09 14:58:29 +03:00
Sanjay R Mehta fb7a89ad2f thunderbolt: Do not read control adapter config space
Adapter 0 is the control adapter and as per USB4 spec in section 2.2.6.2
control Adapters do not have an adapter configuration space.

For this reason skip reading adapter config space in tb_port_init() when
the port number is 0. This actually simplifies the rest of the function
as we don't need to check for the port->port == 0 anymore.

While there drop the extra empty line at the end of the function.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-08-09 14:58:29 +03:00
Rajat Jain 1651d9e781 thunderbolt: Add authorized value to the KOBJ_CHANGE uevent
For security reasons, we would like to monitor and track when the
Thunderbolt devices are authorized and deauthorized (i.e. when the
Thunderbolt sysfs "authorized" attribute changes). Currently the
userspace gets a udev change notification when there is a change, but
the state may have changed (again) by the time we look at the authorized
attribute in sysfs. So an authorization event may go unnoticed. Thus
make it easier by informing the actual change (new value of authorized
attribute) in the udev change notification.

The change is included as a key value "authorized=<val>" where <val>
is the new value of sysfs attribute "authorized", and is described at
Documentation/ABI/testing/sysfs-bus-thunderbolt under
/sys/bus/thunderbolt/devices/.../authorized.

Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-08-02 18:03:36 +03:00
Mika Westerberg 8e3341257e Revert "thunderbolt: Hide authorized attribute if router does not support PCIe tunnels"
This reverts commit 6f3badead6.

It turns out bolt depends on having authorized attribute visible under
each device. Hiding it makes bolt crash as several people have reported
on various bug trackers. For this reason revert the commit.

Link: https://gitlab.freedesktop.org/bolt/bolt/-/issues/174
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1979765
Link: https://bugs.archlinux.org/task/71569
Cc: stable@vger.kernel.org
Cc: Christian Kellner <ckellner@redhat.com>
Fixes: 6f3badead6 ("thunderbolt: Hide authorized attribute if router does not support PCIe tunnels")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20210727142501.27476-1-mika.westerberg@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-27 18:14:25 +02:00
Mika Westerberg 1cbf680f76 thunderbolt: Allow router NVM authenticate separately
It may be useful if the actual NVM authentication can be delayed to be
run later, for instance when the user logs out. For this reason add a
new NVM operation (AUHENTICATE_ONLY) that just triggers the authentication
procedure over whatever was written to the NVM storage.

This is not supported with Thunderbolt 1-3 devices, though.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-01 10:53:32 +03:00
Rajmohan Mani ff3a830645 thunderbolt: Move nvm_write_ops to tb.h
Currently these write ops are used for updating router firmware images
only. Moving to tb.h helps the retimers also to use the same ops.

Also add tb_ prefix to the enum while there.

Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-01 10:53:32 +03:00
Rajmohan Mani 3fb10ea4ce thunderbolt: Add support for retimer NVM upgrade when there is no link
With help from platform firmware (ACPI) it is possible to power on
retimers even when there is no USB4 link (e.g nothing is connected to
the USB4 ports). This allows us to bring the USB4 sideband up so that we
can access retimers and upgrade their NVM firmware.

If the platform has support for this, we expose two additional
attributes under USB4 ports: offline and rescan. These can be used to
bring the port offline, rescan for the retimers and put the port online
again. The retimer NVM upgrade itself works the same way than with cable
connected.

Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
Co-developed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-01 10:53:31 +03:00
Mika Westerberg cae5f5151d thunderbolt: Add USB4 port devices
Create devices for each USB4 port. This is needed when we add retimer
access when there is no device connected but may be useful for other
purposes too following what USB subsystem does. This exports a single
attribute "link" that shows the type of the USB4 link (or "none" if
there is no cable connected).

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-01 10:53:31 +03:00
Mika Westerberg 69fea377e6 thunderbolt: Update port credits after bonding is enabled/disabled
Once lane bonding has been enabled (or disabled) both lane adapters may
update their total credits accordingly. For this reason re-read the port
credits after lane bonding has been enabled or disabled.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-06-01 10:48:59 +03:00
Mika Westerberg 56ad3aef5c thunderbolt: Read router preferred credit allocation information
USB4 routers must expose their preferred credit (buffer) allocation
information through router operation. This information tells the
connection manager how the router prefers its buffers to be allocated to
get the expected bandwidth for the supported protocols.

Read this information and store it as part of struct tb_switch for each
USB4 router.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-06-01 10:48:59 +03:00
Mika Westerberg e7051beab8 thunderbolt: Wait for the lanes to actually bond
It may take some time until the two lanes enter bonded state so poll for
the link width to match what is expected before going forward. This ensures
the link is in expected state before we start establishing paths through
it.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-06-01 10:48:59 +03:00
Mika Westerberg 1c561e4e65 thunderbolt: Make tb_port_type() take const parameter
The function does not modify the object in any way so make the parameter
const to reflect this.

No functional changes intended.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-06-01 10:48:59 +03:00
Mika Westerberg 6026b703e8 thunderbolt: Add wake from DisplayPort
Latest USB4 spec added a new wake bit for DisplayPort so add this to the
driver when runtime suspending. This way wake up the domain when a new
monitor is plugged in to any of the device routers.

Also do the same for pre-USB4 devices through the link controller
registers as documented in chapter 13 of the USB4 spec.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2021-05-31 14:39:52 +03:00
Greg Kroah-Hartman 5367f82a21 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.
 -----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()
  ...
2021-04-13 12:17:14 +02:00
Mika Westerberg 6f3badead6 thunderbolt: Hide authorized attribute if router does not support PCIe tunnels
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>
2021-04-09 12:26:24 +03:00
Mika Westerberg 2f608ba196 thunderbolt: Add details to router uevent
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>
2021-04-09 12:26:10 +03:00