OSDN Git Service

tomoyo/tomoyo-test1.git
11 months agoMerge tag 'thunderbolt-for-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Greg Kroah-Hartman [Wed, 21 Jun 2023 16:02:00 +0000 (18:02 +0200)]
Merge tag 'thunderbolt-for-v6.5-rc1' of git://git./linux/kernel/git/westeri/thunderbolt into usb-next

Mika writes:

thunderbolt: Changes for v6.5 merge window

This includes following Thunderbolt/USB4 changes for the v6.5 merge
window:

  - Improve debug logging
  - Rework for TMU and CL states handling
  - Retimer access improvements
  - Initial support for USB4 v2 features:

    * 80G symmetric link support
    * New notifications
    * PCIe extended encapsulation
    * enhanced uni-directional TMU mode
    * CL2 link low power state
    * DisplayPort 2.x tunneling

  - Support for Intel Barlow Ridge Thunderbolt/USB4 controller
  - Minor fixes and improvements.

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

* tag 'thunderbolt-for-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: (55 commits)
  thunderbolt: Add test case for 3 DisplayPort tunnels
  thunderbolt: Add DisplayPort 2.x tunneling support
  thunderbolt: Make bandwidth allocation mode function names consistent
  thunderbolt: Enable CL2 low power state
  thunderbolt: Add support for enhanced uni-directional TMU mode
  thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller
  thunderbolt: Move constants related to NVM into nvm.c
  thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
  thunderbolt: Add Intel Barlow Ridge PCI ID
  thunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
  thunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
  thunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers
  thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
  thunderbolt: Announce USB4 v2 connection manager support
  thunderbolt: Reset USB4 v2 host router
  thunderbolt: Add the new USB4 v2 notification types
  thunderbolt: Add support for USB4 v2 80 Gb/s link
  thunderbolt: Identify USB4 v2 routers
  thunderbolt: Do not touch lane 1 adapter path config space
  thunderbolt: Ignore data CRC mismatch for USB4 routers
  ...

11 months agoUSB: gadget: f_hid: make hidg_class a static const structure
Ivan Orlov [Tue, 20 Jun 2023 09:44:17 +0000 (11:44 +0200)]
USB: gadget: f_hid: make hidg_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the hidg_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230620094412.508580-11-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoUSB: gadget: f_printer: make usb_gadget_class a static const structure
Ivan Orlov [Tue, 20 Jun 2023 09:44:16 +0000 (11:44 +0200)]
USB: gadget: f_printer: make usb_gadget_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the usb_gadget_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230620094412.508580-10-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoUSB: mon: make mon_bin_class a static const structure
Ivan Orlov [Tue, 20 Jun 2023 09:44:15 +0000 (11:44 +0200)]
USB: mon: make mon_bin_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the mon_bin_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230620094412.508580-9-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoUSB: gadget: udc: core: make udc_class a static const structure
Ivan Orlov [Tue, 20 Jun 2023 09:44:14 +0000 (11:44 +0200)]
USB: gadget: udc: core: make udc_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the udc_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230620094412.508580-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoUSB: roles: make role_class a static const structure
Ivan Orlov [Tue, 20 Jun 2023 09:44:13 +0000 (11:44 +0200)]
USB: roles: make role_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the role_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230620094412.508580-7-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: usb: dwc3: Add interrupt-names property support for wakeup interrupt
Piyush Mehta [Mon, 19 Jun 2023 10:50:32 +0000 (16:20 +0530)]
dt-bindings: usb: dwc3: Add interrupt-names property support for wakeup interrupt

The hibernation feature enabled for Xilinx Versal NET SoC in DWC3 IP.
As the DWC3 IP supports the hibernation feature, to handle the wakeup
or hibernation interrupt, add host mode "wakeup" interrupt-names
optional property in the binding schema to capture remote-wakeup and
connect/ disconnect event in the hibernation state and increased maxItems
to 4 for the interrupts and interrupt-names property.

We have a dedicated IRQ line specifically for the hibernation feature.
When the "wakeup" IRQ line is triggered, it initiates a hibernation
interrupt, causing the system to wake up from the hibernation state.

Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230619105032.2888128-1-piyush.mehta@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: usb: Add StarFive JH7110 USB controller
Minda Chen [Thu, 18 May 2023 11:27:48 +0000 (19:27 +0800)]
dt-bindings: usb: Add StarFive JH7110 USB controller

StarFive JH7110 platforms USB have a wrapper module around
the Cadence USBSS-DRD controller. Add binding information doc
for that.

Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20230518112750.57924-6-minda.chen@starfivetech.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: usb: dwc3: Add IPQ9574 compatible
Varadarajan Narayanan [Fri, 9 Jun 2023 05:56:30 +0000 (11:26 +0530)]
dt-bindings: usb: dwc3: Add IPQ9574 compatible

* Document the IPQ9574 dwc3 compatible.

* Make power-domains as optional since IPQ9574 doesn't have GDSCs

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Link: https://lore.kernel.org/r/27fc578e549e12a4d689cdd434107964b529c4f4.1686289721.git.quic_varada@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: cdns2: Fix spelling mistake in a trace message "Wakupe" -> "Wakeup"
Colin Ian King [Thu, 15 Jun 2023 14:40:52 +0000 (15:40 +0100)]
usb: cdns2: Fix spelling mistake in a trace message "Wakupe" -> "Wakeup"

There is a spelling mistake in a trace message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20230615144052.2254528-1-colin.i.king@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: gadget: function: printer: Replace strlcpy with strscpy
Azeem Shaikh [Thu, 15 Jun 2023 18:03:18 +0000 (18:03 +0000)]
usb: gadget: function: printer: Replace strlcpy with strscpy

strlcpy() reads the entire source buffer first.
This read may exceed the destination size limit.
This is both inefficient and can lead to linear read
overflows if a source string is not NUL-terminated [1].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().

Direct replacement is safe here since return value of -errno
is used to check for truncation instead of PAGE_SIZE.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Link: https://lore.kernel.org/r/20230615180318.400639-1-azeemshaikh38@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: typec: tcpm: add get max power support
Frank Wang [Fri, 16 Jun 2023 07:52:41 +0000 (15:52 +0800)]
usb: typec: tcpm: add get max power support

Traverse fixed pdos to calculate the maximum power that the charger
can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT
property.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230616075241.27690-2-frank.wang@rock-chips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: typec: tcpm: fix cc role at port reset
Frank Wang [Fri, 16 Jun 2023 07:52:40 +0000 (15:52 +0800)]
usb: typec: tcpm: fix cc role at port reset

In the current implementation, the tcpm set CC1/CC2 role to open when
it do port reset would cause the VBUS removed by the Type-C partner.

This sets CC1/CC2 according to the default state of port to fix it.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230616075241.27690-1-frank.wang@rock-chips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agothunderbolt: Add test case for 3 DisplayPort tunnels
Mika Westerberg [Mon, 14 Feb 2022 12:09:50 +0000 (14:09 +0200)]
thunderbolt: Add test case for 3 DisplayPort tunnels

Intel Barlow Ridge Thunderbolt controller has 3 DP IN adapters. This
allows 3 simultaneus DisplayPort tunnels through either one or two USB4
downstream ports (in any possible configuration). Add test case for
this.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Add DisplayPort 2.x tunneling support
Mika Westerberg [Mon, 23 Jan 2023 08:42:58 +0000 (10:42 +0200)]
thunderbolt: Add DisplayPort 2.x tunneling support

This adds support for the UHBR (Ultra High Bit Rate) bandwidths
introduced with DisplayPort 2.0 (and refined in 2.1). These can go up to
80 Gbit/s and their support is represent in additional bits in the DP IN
capability.

This updates the DisplayPort tunneling to support these new rates too.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Make bandwidth allocation mode function names consistent
Mika Westerberg [Wed, 1 Feb 2023 11:21:37 +0000 (13:21 +0200)]
thunderbolt: Make bandwidth allocation mode function names consistent

Make sure the DisplayPort bandwidth allocation mode function names are
consistent with the existing ones, such as USB3.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Enable CL2 low power state
Mika Westerberg [Sun, 6 Nov 2022 11:07:43 +0000 (13:07 +0200)]
thunderbolt: Enable CL2 low power state

For USB4 v2 routers we can also enable CL2 which allows better power
savings and thermal management than CL0s and CL1.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Add support for enhanced uni-directional TMU mode
Mika Westerberg [Tue, 11 Oct 2022 09:11:09 +0000 (12:11 +0300)]
thunderbolt: Add support for enhanced uni-directional TMU mode

This is new TMU mode introduced with the USB4 v2. This mode is simpler
than the existing ones and allows all CL states as well. Enable this for
all links where both side routers are v2 and keep the existing
functionality for the v1 and earlier links.

Currently only support the MedRes rate. We can add the HiFi rate later
too if it turns out to be useful.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller
Gil Fine [Thu, 11 May 2023 08:19:20 +0000 (11:19 +0300)]
thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller

Intel Barlow Ridge discrete USB4 controller has larger NOR Flash, hence
increase NVM_MAX_SIZE to support it.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Move constants related to NVM into nvm.c
Gil Fine [Thu, 11 May 2023 08:19:19 +0000 (11:19 +0300)]
thunderbolt: Move constants related to NVM into nvm.c

Move constants related to NVM into nvm.c to make the code cleaner. Use a
separate constant for USB4_DATA_DWORDS in usb4.c.

No functional changes.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Limit Intel Barlow Ridge USB3 bandwidth
Mika Westerberg [Wed, 17 May 2023 07:45:53 +0000 (10:45 +0300)]
thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth

Intel Barlow Ridge discrete USB4 host router has the same limitation as
the previous generations so make sure the USB3 bandwidth limitation
quirk is applied to Barlow Ridge too.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Add Intel Barlow Ridge PCI ID
Mika Westerberg [Sat, 17 Dec 2022 06:35:04 +0000 (08:35 +0200)]
thunderbolt: Add Intel Barlow Ridge PCI ID

Intel Barlow Ridge is the first USB4 v2 controller from Intel. The
controller exposes standard USB4 PCI class ID in typical configurations,
however there is a way to configure it so that it uses a special class
ID to allow using s different driver than the Windows inbox one. For
this reason add the Barlow Ridge PCI ID to the Linux driver too so that
the driver can attach regardless of the class ID.

Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Fix PCIe adapter capability length for USB4 v2 routers
Gil Fine [Wed, 25 Jan 2023 09:48:14 +0000 (11:48 +0200)]
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>
11 months agothunderbolt: Fix DisplayPort IN adapter capability length for USB4 v2 routers
Gil Fine [Wed, 25 Jan 2023 09:48:13 +0000 (11:48 +0200)]
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>
11 months agothunderbolt: Add two additional double words for adapters TMU for USB4 v2 routers
Gil Fine [Wed, 25 Jan 2023 09:48:12 +0000 (11:48 +0200)]
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>
11 months agothunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation
Gil Fine [Thu, 29 Sep 2022 09:49:48 +0000 (12:49 +0300)]
thunderbolt: Enable USB4 v2 PCIe TLP/DLLP extended encapsulation

USB4 v2 spec introduces modified encapsulation of PCIe TLP and DLLP
packets. This improves the PCIe tunneled traffic usage by reducing
overhead. Enable this if both sides of the link support it.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Announce USB4 v2 connection manager support
Gil Fine [Thu, 29 Sep 2022 10:17:24 +0000 (13:17 +0300)]
thunderbolt: Announce USB4 v2 connection manager support

Program the CMUV (Connection Manager USB4 Version) field for USB4 v2 and
v1 routers according to the spec.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Reset USB4 v2 host router
Mika Westerberg [Fri, 23 Dec 2022 14:59:00 +0000 (16:59 +0200)]
thunderbolt: Reset USB4 v2 host router

USB4 v2 added a bit that can be used to reset the host router so we use
this to trigger reset when the driver probes. This will reset the
already connected topology as well but doing this simplifies things a
lot if for instance the link is already set to asymmetric. We also add
a module parameter to prevent this in case of problems.

While there rename the REG_HOP_COUNT to REG_CAPS to match the USB4 spec
naming better.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Add the new USB4 v2 notification types
Mika Westerberg [Fri, 23 Dec 2022 08:45:51 +0000 (10:45 +0200)]
thunderbolt: Add the new USB4 v2 notification types

USB4 v2 spec adds a bunch of new notifications that the connection
manager can use instead of polling. While we do not use these yet we
need to ack the ones routers expect to be acked.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Add support for USB4 v2 80 Gb/s link
Gil Fine [Thu, 29 Sep 2022 10:00:09 +0000 (13:00 +0300)]
thunderbolt: Add support for USB4 v2 80 Gb/s link

USB4 v2 bumps the per-lane speed up to 40 Gb/s. Also the lanes are
always bonded which gives 80 Gb/s symmetric link (and 120/40 Gb/s
asymmetric). This updates the speed and width of routers and XDomain
connections to support the Gen 4 link. For now we keep the link as is
even if it is already asymmetric.

While there make tb_port_set_link_width() static.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Identify USB4 v2 routers
Gil Fine [Thu, 22 Sep 2022 22:30:43 +0000 (01:30 +0300)]
thunderbolt: Identify USB4 v2 routers

Add a new function usb4_switch_version() that can be used to figure out
the spec version of the router and make tb_switch_is_usb4() to use it as
well. Update the uevent accordingly.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Do not touch lane 1 adapter path config space
Mika Westerberg [Fri, 16 Dec 2022 14:28:05 +0000 (16:28 +0200)]
thunderbolt: Do not touch lane 1 adapter path config space

It is not required to be implemented at all because USB4 does not use
lane 1 for tunneling except when aggregated with lane 0. For this reason
do not try to read the path config space of USB4 lane 1 adapters.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Ignore data CRC mismatch for USB4 routers
Mika Westerberg [Fri, 16 Dec 2022 11:41:12 +0000 (13:41 +0200)]
thunderbolt: Ignore data CRC mismatch for USB4 routers

This is also something not always updated after the DROM contents itself
so issue warning but continue parsing it as we do for pre-USB4 DROMs
too.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agousb: typec: add support for the nb7vpq904m Type-C Linear Redriver
Dmitry Baryshkov [Thu, 15 Jun 2023 10:32:55 +0000 (12:32 +0200)]
usb: typec: add support for the nb7vpq904m Type-C Linear Redriver

Add support for the ON Semiconductor NB7VPQ904M Type-C USB SuperSpeed
and DisplayPort ALT Mode Linear Redriver chip found on some devices
with a Type-C port.

The redriver compensates ultra High-Speeed DisplayPort and USB
Super Speed signal integrity losses mainly due to PCB & transmission
cables.

The redriver doesn't support SuperSpeed lines swapping, but
can support Type-C SBU lines swapping.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Message-ID: <20230601-topic-sm8x50-upstream-redriver-v4-2-91d5820f3a03@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoMAINTAINERS: USB: add uapi header files to USB SUBSYSTEM entry
Greg Kroah-Hartman [Thu, 15 Jun 2023 09:43:07 +0000 (11:43 +0200)]
MAINTAINERS: USB: add uapi header files to USB SUBSYSTEM entry

For some reason the include/uapi/linux/usb/ directory is missing in the
USB SUBSYSTEM entry, so get_maintainer will not know to cc: the proper
mailing lists.  Fix this up by adding an entry for this directory.

Message-ID: <20230615094306.2072827-2-gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: reset: convert the xlnx,zynqmp-reset.txt to yaml
Piyush Mehta [Tue, 13 Jun 2023 12:30:48 +0000 (18:00 +0530)]
dt-bindings: reset: convert the xlnx,zynqmp-reset.txt to yaml

Convert the binding to DT schema format. It also updates the
reset-controller description.

Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Message-ID: <20230613123048.2935502-1-piyush.mehta@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: usb: add ON Semiconductor nb7vpq904m Type-C Linear Redriver bindings
Neil Armstrong [Tue, 13 Jun 2023 14:50:07 +0000 (16:50 +0200)]
dt-bindings: usb: add ON Semiconductor nb7vpq904m Type-C Linear Redriver bindings

Document bindings for this ON Semiconductor Type-C USB SuperSpeed
and DisplayPort ALT Mode Linear Redriver.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Message-ID: <20230601-topic-sm8x50-upstream-redriver-v3-1-988c560e2195@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: ch9: Replace 1-element array with flexible array
Kees Cook [Wed, 14 Jun 2023 18:13:11 +0000 (11:13 -0700)]
usb: ch9: Replace 1-element array with flexible array

Since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"),
UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. Walking
wData will trigger a warning, so make it a proper flexible array. Add a
union to keep the struct size identical for userspace in case anything
was depending on the old size.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202306102333.8f5a7443-oliver.sang@intel.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: kernel test robot <lkp@intel.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: "Jó Ágila Bitsch" <jgilab@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Message-ID: <20230614181307.gonna.256-kees@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoRevert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
Greg Kroah-Hartman [Thu, 15 Jun 2023 09:30:35 +0000 (11:30 +0200)]
Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"

This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.

Heikki reports that this should not be a global flag just to work around
one broken driver and should be fixed differently, so revert it.

Reported-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Fixes: edd60d24bd85 ("usb: common: usb-conn-gpio: Set last role to unknown before initial detection")
Link: https://lore.kernel.org/r/ZImE4L3YgABnCIsP@kuha.fi.intel.com
Cc: Prashanth K <quic_prashk@quicinc.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: chipidea: imx: add missing USB PHY DPDM wakeup setting
Xu Yang [Wed, 17 May 2023 08:19:07 +0000 (16:19 +0800)]
usb: chipidea: imx: add missing USB PHY DPDM wakeup setting

USB PHY DPDM wakeup bit is enabled by default, when USB wakeup
is not required(/sys/.../wakeup is disabled), this bit should be
disabled, otherwise we will have unexpected wakeup if do USB device
connect/disconnect while system sleep.
This bit can be enabled for both host and device mode.

Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Message-ID: <20230517081907.3410465-3-xu.yang_2@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: chipidea: imx: turn off vbus comparator when suspend
Xu Yang [Wed, 17 May 2023 08:19:06 +0000 (16:19 +0800)]
usb: chipidea: imx: turn off vbus comparator when suspend

As we use bvalid for vbus wakeup source, to save power when
suspend, turn off the vbus comparator for imx7d and imx8mm.

Below is this bit description from RM of iMX8MM
"VBUS Valid Comparator Enable:

This signal controls the USB OTG PHY VBUS Valid comparator which
indicates whether the voltage on the USB_OTG*_VBUS pin is below
the VBUS Valid threshold. The VBUS Valid threshold is nominally
4.75V on this USB PHY. The VBUS Valid threshold can be adjusted
using the USBNC_OTGn_PHY_CFG1[OTGTUNE0] bit field. Status of the
VBUS Valid comparator, when it is enabled, is reported on the
USBNC_OTGn_PHY_STATUS[VBUS_VLD] bit.
When OTGDISABLE0 (USBNC_USB_OTGx_PHY_CFG2[10])is set to 1'b0 and
DRVVBUS0 is set to 1'b1, the Bandgap circuitry and VBUS Valid
comparator are powered, even in Suspend or Sleep mode.
DRVVBUS0 should be reset to 1'b0 when the internal VBUS Valid comparator
is not required, to reduce quiescent current in Suspend or Sleep mode.
 - 0 The VBUS Valid comparator is disabled
  - 1 The VBUS Valid comparator is enabled"

Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Message-ID: <20230517081907.3410465-2-xu.yang_2@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoMAINTAINERS: add Cadence USBHS driver entry
Pawel Laszczak [Fri, 2 Jun 2023 10:26:44 +0000 (06:26 -0400)]
MAINTAINERS: add Cadence USBHS driver entry

Patch adds entry for USBHS (CDNS2) driver into MAINTARNERS file

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Message-ID: <20230602102644.77470-5-pawell@cadence.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: cdns2: Add tracepoints for CDNS2 driver
Pawel Laszczak [Fri, 2 Jun 2023 10:26:43 +0000 (06:26 -0400)]
usb: cdns2: Add tracepoints for CDNS2 driver

Patch adds the series of tracepoints that can be used for
debugging issues detected in driver.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Message-ID: <20230602102644.77470-4-pawell@cadence.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: cdns2: Add main part of Cadence USBHS driver
Pawel Laszczak [Fri, 2 Jun 2023 10:26:42 +0000 (06:26 -0400)]
usb: cdns2: Add main part of Cadence USBHS driver

This patch introduces the main part of Cadence USBHS driver
to Linux kernel.
To reduce the patch size a little bit, the header file gadget.h was
intentionally added as separate patch.

The Cadence USB 2.0 Controller is a highly configurable IP Core which
supports both full and high speed data transfer.

The current driver has been validated with FPGA platform. We have
support for PCIe bus, which is used on FPGA prototyping.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Message-ID: <20230602102644.77470-3-pawell@cadence.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: cdns2: Device side header file for CDNS2 driver
Pawel Laszczak [Fri, 2 Jun 2023 10:26:41 +0000 (06:26 -0400)]
usb: cdns2: Device side header file for CDNS2 driver

Patch defines macros, registers and structures used by
Device side driver.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Message-ID: <20230602102644.77470-2-pawell@cadence.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()
Christophe JAILLET [Sat, 10 Jun 2023 13:32:52 +0000 (15:32 +0200)]
usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()

If dwc3_meson_g12a_otg_init() fails, resources allocated by the previous
of_platform_populate() call should be released, as already done in the
error handling path.

Fixes: 1e355f21d3fb ("usb: dwc3: Add Amlogic A1 DWC3 glue")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Message-ID: <9d28466de1808ccc756b4cc25fc72c482d133d13.1686403934.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: update the ctime as well when updating mtime after an ioctl
Jeff Layton [Mon, 12 Jun 2023 10:45:18 +0000 (06:45 -0400)]
usb: update the ctime as well when updating mtime after an ioctl

In general, POSIX requires that when the mtime is updated that the ctime
be updated as well. Add the missing timestamp updates to the usb ioctls.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Message-ID: <20230612104524.17058-3-jlayton@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: core: add sysfs entry for usb device state
Roy Luo [Thu, 8 Jun 2023 01:59:12 +0000 (01:59 +0000)]
usb: core: add sysfs entry for usb device state

Expose usb device state to userland as the information is useful in
detecting non-compliant setups and diagnosing enumeration failures.
For example:
- End-to-end signal integrity issues: the device would fail port reset
  repeatedly and thus be stuck in POWERED state.
- Charge-only cables (missing D+/D- lines): the device would never enter
  POWERED state as the HC would not see any pullup.

What's the status quo?
We do have error logs such as "Cannot enable. Maybe the USB cable is bad?"
to flag potential setup issues, but there's no good way to expose them to
userspace.

Why add a sysfs entry in struct usb_port instead of struct usb_device?
The struct usb_device is not device_add() to the system until it's in
ADDRESS state hence we would miss the first two states. The struct
usb_port is a better place to keep the information because its life
cycle is longer than the struct usb_device that is attached to the port.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202306042228.e532af6e-oliver.sang@intel.com
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Roy Luo <royluo@google.com>
Message-ID: <20230608015913.1679984-1-royluo@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: common: usb-conn-gpio: Set last role to unknown before initial detection
Prashanth K [Wed, 31 May 2023 14:41:14 +0000 (20:11 +0530)]
usb: common: usb-conn-gpio: Set last role to unknown before initial detection

Currently if we bootup a device without cable connected, then
usb-conn-gpio won't call set_role() since last_role is same as
current role. This happens because during probe last_role gets
initialised to zero.

To avoid this, added a new constant in enum usb_role, last_role
is set to USB_ROLE_UNKNOWN before performing initial detection.

While at it, also handle default case for the usb_role switch
in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid
build warnings.

Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Message-ID: <1685544074-17337-1-git-send-email-quic_prashk@quicinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: chipidea: imx: don't request QoS for imx8ulp
Xu Yang [Tue, 30 May 2023 10:40:07 +0000 (18:40 +0800)]
usb: chipidea: imx: don't request QoS for imx8ulp

Use dedicated imx8ulp usb compatible to remove QoS request
since imx8ulp has no such limitation of imx7ulp: DMA will
not work if system enters idle.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Message-ID: <20230530104007.1294702-2-xu.yang_2@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agodt-bindings: usb: ci-hdrc-usb2: add fsl,imx8ulp-usb compatible
Xu Yang [Tue, 30 May 2023 10:40:06 +0000 (18:40 +0800)]
dt-bindings: usb: ci-hdrc-usb2: add fsl,imx8ulp-usb compatible

The imx8ulp and imx8dxl are compatible. This will add fsl,imx8ulp-usb
to the compatible property.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Message-ID: <20230530104007.1294702-1-xu.yang_2@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: dwc3: qcom: use dev_err_probe() where appropriate
Andrew Halaney [Mon, 5 Jun 2023 19:36:25 +0000 (14:36 -0500)]
usb: dwc3: qcom: use dev_err_probe() where appropriate

Update to using dev_err_probe() throughout to reduce spam and log useful
information in devices_deferred.

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Message-ID: <20230605193625.63187-1-ahalaney@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()
Christophe JAILLET [Sun, 4 Jun 2023 14:56:34 +0000 (16:56 +0200)]
usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()

If dwc3_qcom_create_urs_usb_platdev() fails, some resources still need to
be released, as already done in the other error handling path of the
probe.

Fixes: c25c210f590e ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Message-ID: <b69fa8dd68d816e7d24c88d3eda776ceb28c5dc5.1685890571.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
Christophe JAILLET [Sun, 4 Jun 2023 15:04:37 +0000 (17:04 +0200)]
usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()

In the probe, some resources are allocated with
dwc3_qcom_of_register_core() or dwc3_qcom_acpi_register_core(). The
corresponding resources are already coorectly freed in the error handling
path of the probe, but not in the remove function.

Fix it.

Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Message-ID: <c0215a84cdf18fb3514c81842783ec53cf149deb.1685891059.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: gadget: f_mass_storage: remove unnecessary open check
David Disseldorp [Wed, 7 Jun 2023 21:54:02 +0000 (23:54 +0200)]
usb: gadget: f_mass_storage: remove unnecessary open check

The fsg_lun_is_open() test can be eliminated and the code merged with
the preceding conditional, because the LUN won't be open if
cfg->filename wasn't set. Similarly, the error_lun label will never be
reached with an open lun (non-null filp) so remove the unnecessary
fsg_lun_close() call.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Message-ID: <20230607215401.22563-1-ddiss@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: gadget: uvc: clean up comments and styling in video_pump
Avichal Rakesh [Fri, 2 Jun 2023 22:04:55 +0000 (15:04 -0700)]
usb: gadget: uvc: clean up comments and styling in video_pump

This patch elaborates on some of the edge cases handled by
video_pump around setting no_interrupt flag, and brings the
code style in line with rest of the file.

Link: https://lore.kernel.org/20230602151916.GH26944@pendragon.ideasonboard.com/
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Message-ID: <20230602220455.313801-1-arakesh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: gadget: udc: udc-xilinx: Add identifier to read_fn function arg
Piyush Mehta [Wed, 7 Jun 2023 07:29:59 +0000 (12:59 +0530)]
usb: gadget: udc: udc-xilinx: Add identifier to read_fn function arg

Add an identifier in the read_fn function declaration because based on
commit ca0d8929e75a ("checkpatch: add warning for unnamed function
definition arguments") it is the preferred coding style even C standard
allows both formats.

Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
Message-ID: <20230607072959.2334046-1-piyush.mehta@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: usb251xb: Use of_property_read_u16()
Christophe JAILLET [Sun, 4 Jun 2023 11:11:18 +0000 (13:11 +0200)]
usb: usb251xb: Use of_property_read_u16()

Use of_property_read_u16() instead of of_property_read_u16_array() when
only 1 element is read.
This slightly simplifies the code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Message-ID: <97478908a814d4fa694e0ca44212c3776cf3e6e9.1685877052.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: gadget: u_serial: Add null pointer check in gs_start_io
Kuen-Han Tsai [Fri, 2 Jun 2023 07:00:06 +0000 (15:00 +0800)]
usb: gadget: u_serial: Add null pointer check in gs_start_io

If gs_close has cleared port->port.tty and gs_start_io is called
afterwards, then the function tty_wakeup will attempt to access the value
of the pointer port->port.tty which will cause a null pointer
dereference error.

To avoid this, add a null pointer check to gs_start_io before attempting
to access the value of the pointer port->port.tty.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Message-ID: <20230602070009.1353946-1-khtsai@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: typec: intel_pmc_mux: Expose IOM port status to debugfs
Rajat Khandelwal [Wed, 31 May 2023 10:50:50 +0000 (16:20 +0530)]
usb: typec: intel_pmc_mux: Expose IOM port status to debugfs

IOM status has a crucial role during debugging to check the
current state of the type-C port.
There are ways to fetch the status, but all those require the
IOM port status offset, which could change with platform.

Make a debugfs directory for intel_pmc_mux and expose the status
under it per port basis.

Signed-off-by: Rajat Khandelwal <rajat.khandelwal@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Message-ID: <20230531105050.638250-1-rajat.khandelwal@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Add ZHAOXIN xHCI host U1/U2 feature support
Weitao Wang [Fri, 2 Jun 2023 14:40:09 +0000 (17:40 +0300)]
xhci: Add ZHAOXIN xHCI host U1/U2 feature support

Add U1/U2 feature support of xHCI for ZHAOXIN.
Since both INTEL and ZHAOXIN need to check the tier where the device is
located to determine whether to enabled U1/U2, remove the previous INTEL
U1/U2 tier policy and add common policy in xhci_check_tier_policy.
If vendor has specific U1/U2 enable policy,quirks can be add to declare.

Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-12-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Show ZHAOXIN xHCI root hub speed correctly
Weitao Wang [Fri, 2 Jun 2023 14:40:08 +0000 (17:40 +0300)]
xhci: Show ZHAOXIN xHCI root hub speed correctly

Some ZHAOXIN xHCI controllers follow usb3.1 spec, but only support
gen1 speed 5Gbps. While in Linux kernel, if xHCI suspport usb3.1,
root hub speed will show on 10Gbps.
To fix this issue of ZHAOXIN xHCI platforms, read usb speed ID
supported by xHCI to determine root hub speed. And add a quirk
XHCI_ZHAOXIN_HOST for this issue.

[fix warning about uninitialized symbol -Mathias]

Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-11-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Fix TRB prefetch issue of ZHAOXIN hosts
Weitao Wang [Fri, 2 Jun 2023 14:40:07 +0000 (17:40 +0300)]
xhci: Fix TRB prefetch issue of ZHAOXIN hosts

On some ZHAOXIN hosts, xHCI will prefetch TRB for performance
improvement. However this TRB prefetch mechanism may cross page boundary,
which may access memory not allocated by xHCI driver. In order to fix
this issue, two pages was allocated for a segment and only the first
page will be used. And add a quirk XHCI_ZHAOXIN_TRB_FETCH for this issue.

Cc: stable@vger.kernel.org
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-10-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Fix resume issue of some ZHAOXIN hosts
Weitao Wang [Fri, 2 Jun 2023 14:40:06 +0000 (17:40 +0300)]
xhci: Fix resume issue of some ZHAOXIN hosts

On ZHAOXIN ZX-100 project, xHCI can't work normally after resume
from system Sx state. To fix this issue, when resume from system
Sx state, reinitialize xHCI instead of restore.
So, Add XHCI_RESET_ON_RESUME quirk for ZX-100 to fix issue of
resuming from system Sx state.

Cc: stable@vger.kernel.org
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-9-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Stop unnecessary tracking of free trbs in a ring
Mathias Nyman [Fri, 2 Jun 2023 14:40:05 +0000 (17:40 +0300)]
xhci: Stop unnecessary tracking of free trbs in a ring

Trying to keep track of free trbs in a ring by adding and subtracting
deltas each time a enqueue or dequeue is increased or moved has proven to
be buggy and complicated, especially over long periods of time.

Recently a bug in counting free trbs was fixed, now taking into account
cancelled URBs that were turned into no-ops, preventing free_trbs to
slowly wander off causing unnecessary ring expansion. See
commit fe82f16aafda ("xhci: Fix incorrect tracking of free space on
transfer rings")

Turns out its a lot easier to just calculate the numer of free TRB
based on ring size and the current enqueue and dequeue pointer values.
This is currently only needed for the command ring as multi segment
transfer rings already ensures there is enough room the ring during
the ring expansion check.

We could get rid of the ring->num_trbs_free entry completely, but as
the xhci DbC code also uses it we don't clean that up in this patch.

Reported-by: Miller Hunter <MillerH@hearthnhome.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217242
Tested-by: Miller Hunter <MillerH@hearthnhome.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-8-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Fix transfer ring expansion size calculation
Mathias Nyman [Fri, 2 Jun 2023 14:40:04 +0000 (17:40 +0300)]
xhci: Fix transfer ring expansion size calculation

The amount of new TRBs needed is calculated incorrectly when expanding a
transfer ring.

The room_on_ring() helper will correctly report that the ring needs
expansion if the enqueue pointer is about to reach the dequeue segment.
If enqueue reaches the dequeue segment then there is no easy way
to expand the ring by adding new segments between enqueue and dequeue.

This leads to ring expansion even if num_trbs_free is larger than
num_trbs we are queueing.

As a result we try to store a negative number in a unsigned int, leading
to a huge percieved trb need, and doubling of ring size.

Rework and rename the room_on_ring() to a helper that checks if ring
needs expansion, and return number of new segments needed. Don't rely on
the tracked ring->num_trbs_free value as turns out it has been unreliable.
Use ring enqueue and dequeue positions to determine expansion need.

The unsigned int issue was first reported first Chao zeng, and a bit
later seen in a real world bug.

Reported-by: chao zeng <chao.zengup@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217242
Tested-by: Miller Hunter <MillerH@hearthnhome.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-7-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: split allocate interrupter into separate alloacte and add parts
Mathias Nyman [Fri, 2 Jun 2023 14:40:03 +0000 (17:40 +0300)]
xhci: split allocate interrupter into separate alloacte and add parts

The current function that both allocates and adds the interrupter isn't
optimal when using several interrupters. The array of interrupters need
to be protected with a lock while adding or removing interrupters.
If memory is allocated under the default xhci spinlock then GFP_KERNEL
can't be used.

There is no need to allocate the interrupter memory under the lock, so
split this code into separate unlocked allocate part, and a lock
protected add part.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-6-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup
Mathias Nyman [Fri, 2 Jun 2023 14:40:02 +0000 (17:40 +0300)]
xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup

The XHCI_PLAT quirk was only needed to ensure non-PCI xHC host avoided
setting up MSI interrupts in generic xhci codepaths.

The MSI setup code is now moved to PCI specific xhci-pci.c file so
the quirk is no longer needed.

Remove setting the XHCI_PLAT quirk for HiSilocon SoC xHC, NVIDIA Tegra xHC,
MediaTek xHC, the generic xhci-plat driver, and the checks for XHCI_PLAT
in xhci-pci.c MSI setup code.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-5-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Don't require a valid get_quirks() function pointer during xhci setup
Mathias Nyman [Fri, 2 Jun 2023 14:40:01 +0000 (17:40 +0300)]
xhci: Don't require a valid get_quirks() function pointer during xhci setup

Not all platforms drivers need to set up custom quirks during the xhci
generic setup. Allow them to pass NULL as the function pointer when
calling xhci_gen_setup()

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-4-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agoxhci: Add usb cold attach (CAS) as a reason to resume root hub.
Mathias Nyman [Fri, 2 Jun 2023 14:40:00 +0000 (17:40 +0300)]
xhci: Add usb cold attach (CAS) as a reason to resume root hub.

Check for the cold attach (CAS) bit while checking for other usb3
roothub port changes during host resume.

The CAS bit is set if a USB 3 device is connected while the host is
suspended in such a way it can't perform proper link training and
progress the link to the enabled U0 state.

If the CAS bit set we want to resume the root hub, and reset and
enumerate the newly connected device.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-3-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agousb: xhci: Remove unused udev from xhci_log_ctx trace event
Udipto Goswami [Fri, 2 Jun 2023 14:39:59 +0000 (17:39 +0300)]
usb: xhci: Remove unused udev from xhci_log_ctx trace event

xhci_log_ctx event is not utilizing the extracted udev to
print out anything, hence removing it.

Fixes: 1d27fabec068 ("xhci: add xhci_address_ctx trace event")
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-2-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
11 months agothunderbolt: Enable/disable sideband depending on USB4 port offline mode
Mika Westerberg [Fri, 26 May 2023 11:55:20 +0000 (14:55 +0300)]
thunderbolt: Enable/disable sideband depending on USB4 port offline mode

When USB4 port is in offline mode (this mean there is no device
attached) we want to keep the sideband up to make it possible to
communicate with the retimers. In the same way there is no need to
enable sideband transactions when the USB4 port is not offline as they
are already up.

For this reason make the enabling/disabling depend on the USB4 port
offline status.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Do not send UNSET_INBOUND_SBTX when retimer NVM authentication started
Mika Westerberg [Fri, 26 May 2023 11:51:23 +0000 (14:51 +0300)]
thunderbolt: Do not send UNSET_INBOUND_SBTX when retimer NVM authentication started

Once retimer NVM authentication is started, sending UNSET_INBOUND_SBTX
will fail so avoid doing that. Only send it when we are writing an image
with not authentication or when the authentication failed early.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
11 months agothunderbolt: Read retimer NVM authentication status prior tb_retimer_set_inbound_sbtx()
Mika Westerberg [Fri, 26 May 2023 11:46:44 +0000 (14:46 +0300)]
thunderbolt: Read retimer NVM authentication status prior tb_retimer_set_inbound_sbtx()

According to the USB4 retimer guide the correct order is immediately
after sending ENUMERATE_RETIMERS so update the code to follow this.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Disable CL states when a DMA tunnel is established
Mika Westerberg [Fri, 24 Mar 2023 11:04:39 +0000 (13:04 +0200)]
thunderbolt: Disable CL states when a DMA tunnel is established

Tunnels between hosts should not have CL states enabled because
otherwise they might enter a low power state without the other end
noticing which causes packets to be lost. For this reason disable all
CL states upon first DMA tunnel creation. Once the last DMA tunnel is
torn down we try to re-enable them.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Make tb_switch_clx_disable() return CL states that were enabled
Mika Westerberg [Fri, 18 Nov 2022 13:42:27 +0000 (15:42 +0200)]
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>
12 months agothunderbolt: Initialize CL states from the hardware
Mika Westerberg [Wed, 24 May 2023 10:33:57 +0000 (13:33 +0300)]
thunderbolt: Initialize CL states from the hardware

In case the boot firmware enabled any of them, read the currently
configured CL states and update the router structure accordingly.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Prefix CL state related log messages with "CLx: "
Mika Westerberg [Thu, 25 May 2023 09:22:11 +0000 (12:22 +0300)]
thunderbolt: Prefix CL state related log messages with "CLx: "

This makes it easier to spot from the logs and follows what we do with
the TMU code already. We also log enabling/disabling CL states using the
tb_sw_dbg() instead of tb_port_dbg().

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Prefix TMU post time log message with "TMU: "
Mika Westerberg [Fri, 26 May 2023 10:53:35 +0000 (13:53 +0300)]
thunderbolt: Prefix TMU post time log message with "TMU: "

Following what we do with other messages in this file. No functional
changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Do not call CLx functions from TMU code
Mika Westerberg [Mon, 10 Oct 2022 15:52:24 +0000 (18:52 +0300)]
thunderbolt: Do not call CLx functions from TMU code

There is really no need to call any of the CLx functions in the TMU code
so remove all these checks. This makes the TMU enable/disable flows
easier to follow as well.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Check for first depth router in tb.c
Mika Westerberg [Fri, 18 Nov 2022 13:26:12 +0000 (15:26 +0200)]
thunderbolt: Check for first depth router in tb.c

Currently tb_switch_clx_enable() enables CL states only for the first
depth router. This is something we may want to change in the future and
in addition it is not visible from the calling path at all. For this
reason do the check in the tb.c so it is immediately visible that we
only do this for the first depth router. Fix the kernel-docs
accordingly.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Switch CL states from enum to a bitmask
Mika Westerberg [Mon, 10 Oct 2022 10:36:56 +0000 (13:36 +0300)]
thunderbolt: Switch CL states from enum to a bitmask

This is more natural and follows the hardware register layout better.
This makes it easier to see which CL states we enable (even though they
should be enabled together). Rename 'clx_mask' to 'clx' everywhere as
this is now always bitmask.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Move CLx enabling into tb_enable_clx()
Mika Westerberg [Mon, 10 Oct 2022 08:31:07 +0000 (11:31 +0300)]
thunderbolt: Move CLx enabling into tb_enable_clx()

This avoids some duplication and makes the flow slightly easier to
understand. Also follows what we do in tb_enable_tmu().

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Get rid of __tb_switch_[en|dis]able_clx()
Mika Westerberg [Mon, 10 Oct 2022 09:10:33 +0000 (12:10 +0300)]
thunderbolt: Get rid of __tb_switch_[en|dis]able_clx()

No need to have separate functions for these so fold them into
tb_switch_clx_enable() and tb_switch_clx_disable() accordingly.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Move CLx support functions into clx.c
Mika Westerberg [Fri, 7 Oct 2022 15:12:02 +0000 (18:12 +0300)]
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>
12 months agothunderbolt: Check valid TMU configuration in tb_switch_tmu_configure()
Mika Westerberg [Mon, 10 Oct 2022 15:04:16 +0000 (18:04 +0300)]
thunderbolt: Check valid TMU configuration in tb_switch_tmu_configure()

Instead of at enable time we can do this already in
tb_switch_tmu_configure().

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Move tb_enable_tmu() close to other TMU functions
Mika Westerberg [Fri, 7 Oct 2022 14:49:01 +0000 (17:49 +0300)]
thunderbolt: Move tb_enable_tmu() close to other TMU functions

This makes the code easier to follow. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Move TMU configuration to tb_enable_tmu()
Mika Westerberg [Fri, 7 Oct 2022 13:53:58 +0000 (16:53 +0300)]
thunderbolt: Move TMU configuration to tb_enable_tmu()

There is no need to duplicate the code the enables TMU. Also update the
comment to better explain why we do this in the first place.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Get rid of tb_switch_enable_tmu_1st_child()
Mika Westerberg [Fri, 7 Oct 2022 12:40:21 +0000 (15:40 +0300)]
thunderbolt: Get rid of tb_switch_enable_tmu_1st_child()

This is better to be part of the software connection manager flows in
tb.c. Also name the new function tb_increase_tmu_accuracy() to match
what it actually does.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Rework Titan Ridge TMU objection disable function
Mika Westerberg [Fri, 26 May 2023 06:22:06 +0000 (09:22 +0300)]
thunderbolt: Rework Titan Ridge TMU objection disable function

Now this is split into two with one having a misleading name
(tb_switch_tmu_unidirectional_enable()).

Make this easier to read, rename and consolidate the two functions into
one with name that explains what it actually does. Use the two constants
as well that were added but never used to make it clear which bits are
being set.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Drop useless 'unidirectional' parameter from tb_switch_tmu_is_enabled()
Mika Westerberg [Fri, 7 Oct 2022 10:19:09 +0000 (13:19 +0300)]
thunderbolt: Drop useless 'unidirectional' parameter from tb_switch_tmu_is_enabled()

There is no point passing it as we already have a field for that. While
there clean up the kernel-doc of things that do not really belong to the
API documentation (these can be figured out from the spec itself).

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Fix a couple of style issues in TMU code
Mika Westerberg [Fri, 7 Oct 2022 10:14:13 +0000 (13:14 +0300)]
thunderbolt: Fix a couple of style issues in TMU code

Drop extra empty line and get rid of the '__' in function names. No
functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Introduce tb_xdomain_downstream_port()
Mika Westerberg [Fri, 30 Sep 2022 08:12:42 +0000 (11:12 +0300)]
thunderbolt: Introduce tb_xdomain_downstream_port()

In the same way we did for the routers add a function that returns the
parent routers downstream facing port for XDomain devices.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agothunderbolt: Introduce tb_switch_downstream_port()
Gil Fine [Thu, 22 Sep 2022 22:30:38 +0000 (01:30 +0300)]
thunderbolt: Introduce tb_switch_downstream_port()

Introduce tb_switch_downstream_port() helper function that returns the
downstream port of a parent switch that is connected to the upstream
port of specified switch. From now on, we use it all across the driver
where applicable.

While there fix a whitespace in comment and rename 'downstream' to
'down' to be consistent with the rest of the driver.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agoMerge branch 'thunderbolt/fixes' into thunderbolt/next
Mika Westerberg [Fri, 9 Jun 2023 09:05:44 +0000 (12:05 +0300)]
Merge branch 'thunderbolt/fixes' into thunderbolt/next

We need Thunderbolt/USB4 fixes here as well.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
12 months agoMerge 6.4-rc5 into usb-next
Greg Kroah-Hartman [Mon, 5 Jun 2023 05:39:02 +0000 (07:39 +0200)]
Merge 6.4-rc5 into usb-next

We need the USB fixes in here are well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 months agoLinux 6.4-rc5 v6.4-rc5
Linus Torvalds [Sun, 4 Jun 2023 18:04:27 +0000 (14:04 -0400)]
Linux 6.4-rc5

12 months agoMerge tag 'irq_urgent_for_v6.4_rc5' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 4 Jun 2023 15:57:38 +0000 (11:57 -0400)]
Merge tag 'irq_urgent_for_v6.4_rc5' of git://git./linux/kernel/git/tip/tip

Pull irq fix from Borislav Petkov:

 - Fix open firmware quirks validation so that they don't get applied
   wrongly

* tag 'irq_urgent_for_v6.4_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/gic: Correctly validate OF quirk descriptors

12 months agoMerge tag 'media/v6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
Linus Torvalds [Sun, 4 Jun 2023 13:10:43 +0000 (09:10 -0400)]
Merge tag 'media/v6.4-4' of git://git./linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:
 "Some driver fixes:
   - a regression fix for the verisilicon driver
   - uvcvideo: don't expose unsupported video formats to userspace
   - camss-video: don't zero subdev format after init
   - mediatek: some fixes for 4K decoder formats
   - fix a Sphinx build warning (missing doc for client_caps)
   - some fixes for imx and atomisp staging drivers

  And two CEC core fixes:
   - don't set last_initiator if TX in progress
   - disable adapter in cec_devnode_unregister"

* tag 'media/v6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: uvcvideo: Don't expose unsupported formats to userspace
  media: v4l2-subdev: Fix missing kerneldoc for client_caps
  media: staging: media: imx: initialize hs_settle to avoid warning
  media: v4l2-mc: Drop subdev check in v4l2_create_fwnode_links_to_pad()
  media: staging: media: atomisp: init high & low vars
  media: cec: core: don't set last_initiator if tx in progress
  media: cec: core: disable adapter in cec_devnode_unregister
  media: mediatek: vcodec: Only apply 4K frame sizes on decoder formats
  media: camss: camss-video: Don't zero subdev format again after initialization
  media: verisilicon: Additional fix for the crash when opening the driver

12 months agoMerge tag 'char-misc-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
Linus Torvalds [Sun, 4 Jun 2023 12:32:30 +0000 (08:32 -0400)]
Merge tag 'char-misc-6.4-rc5' of git://git./linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
 "Here are a bunch of tiny char/misc/other driver fixes for 6.4-rc5 that
  resolve a number of reported issues. Included in here are:

   - iio driver fixes

   - fpga driver fixes

   - test_firmware bugfixes

   - fastrpc driver tiny bugfixes

   - MAINTAINERS file updates for some subsystems

  All of these have been in linux-next this past week with no reported
  issues"

* tag 'char-misc-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (34 commits)
  test_firmware: fix the memory leak of the allocated firmware buffer
  test_firmware: fix a memory leak with reqs buffer
  test_firmware: prevent race conditions by a correct implementation of locking
  firmware_loader: Fix a NULL vs IS_ERR() check
  MAINTAINERS: Vaibhav Gupta is the new ipack maintainer
  dt-bindings: fpga: replace Ivan Bornyakov maintainership
  MAINTAINERS: update Microchip MPF FPGA reviewers
  misc: fastrpc: reject new invocations during device removal
  misc: fastrpc: return -EPIPE to invocations on device removal
  misc: fastrpc: Reassign memory ownership only for remote heap
  misc: fastrpc: Pass proper scm arguments for secure map request
  iio: imu: inv_icm42600: fix timestamp reset
  iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag
  dt-bindings: iio: adc: renesas,rcar-gyroadc: Fix adi,ad7476 compatible value
  iio: dac: mcp4725: Fix i2c_master_send() return value handling
  iio: accel: kx022a fix irq getting
  iio: bu27034: Ensure reset is written
  iio: dac: build ad5758 driver when AD5758 is selected
  iio: addac: ad74413: fix resistance input processing
  iio: light: vcnl4035: fixed chip ID check
  ...