From 4b22222dab46525823a654dbb3bc28a73ead2083 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 29 Jan 2022 17:24:17 +0100 Subject: [PATCH] 5.16-stable patches added patches: kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch serial-stm32-fix-software-flow-control-transfer.patch tty-add-support-for-brainboxes-uc-cards.patch tty-n_gsm-fix-sw-flow-control-encoding-handling.patch tty-partially-revert-the-removal-of-the-cyclades-public-api.patch tty-rpmsg-fix-race-condition-releasing-tty-port.patch ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch usb-common-ulpi-fix-crash-in-ulpi_match.patch usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch --- ...ux-cyclades.h-from-header-file-check.patch | 34 ++++ ...-size-when-using-reg-offset-property.patch | 52 ++++++ ...rect-rs485-rts-polarity-on-set_mctrl.patch | 42 +++++ ...2-fix-software-flow-control-transfer.patch | 34 ++++ queue-5.16/series | 20 +++ ...-add-support-for-brainboxes-uc-cards.patch | 139 ++++++++++++++++ ...ix-sw-flow-control-encoding-handling.patch | 64 ++++++++ ...e-removal-of-the-cyclades-public-api.patch | 78 +++++++++ ...ix-race-condition-releasing-tty-port.patch | 149 ++++++++++++++++++ ...-dev_int-bit-only-when-starting-ccg4.patch | 40 +++++ ...on-fault-in-cdns_lost_power-function.patch | 38 +++++ ...-common-ulpi-fix-crash-in-ulpi_match.patch | 47 ++++++ ...b_kill_urb-by-adding-memory-barriers.patch | 128 +++++++++++++++ ...error-handling-when-getting-usb3-phy.patch | 44 ++++++ ...b3-register-settings-for-usb2.0-mode.patch | 56 +++++++ ...oc-transfer-for-usb_speed_super_plus.patch | 33 ++++ ...devs-entry-for-vl817-usb-sata-bridge.patch | 59 +++++++ ...t-touch-cc-line-if-it-s-vconn-source.patch | 88 +++++++++++ ...ot-disconnect-when-receiving-vsafe0v.patch | 54 +++++++ ...-disconnect-while-receiving-vbus-off.patch | 53 +++++++ ...h-when-suspend-if-remote-wake-enable.patch | 74 +++++++++ 21 files changed, 1326 insertions(+) create mode 100644 queue-5.16/kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch create mode 100644 queue-5.16/serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch create mode 100644 queue-5.16/serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch create mode 100644 queue-5.16/serial-stm32-fix-software-flow-control-transfer.patch create mode 100644 queue-5.16/tty-add-support-for-brainboxes-uc-cards.patch create mode 100644 queue-5.16/tty-n_gsm-fix-sw-flow-control-encoding-handling.patch create mode 100644 queue-5.16/tty-partially-revert-the-removal-of-the-cyclades-public-api.patch create mode 100644 queue-5.16/tty-rpmsg-fix-race-condition-releasing-tty-port.patch create mode 100644 queue-5.16/ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch create mode 100644 queue-5.16/usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch create mode 100644 queue-5.16/usb-common-ulpi-fix-crash-in-ulpi_match.patch create mode 100644 queue-5.16/usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch create mode 100644 queue-5.16/usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch create mode 100644 queue-5.16/usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch create mode 100644 queue-5.16/usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch create mode 100644 queue-5.16/usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch create mode 100644 queue-5.16/usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch create mode 100644 queue-5.16/usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch create mode 100644 queue-5.16/usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch create mode 100644 queue-5.16/usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch diff --git a/queue-5.16/kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch b/queue-5.16/kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch new file mode 100644 index 00000000000..cc55f75d973 --- /dev/null +++ b/queue-5.16/kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch @@ -0,0 +1,34 @@ +From d1ad2721b1eb05d54e81393a7ebc332d4a35c68f Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Thu, 27 Jan 2022 08:33:04 +0100 +Subject: kbuild: remove include/linux/cyclades.h from header file check + +From: Greg Kroah-Hartman + +commit d1ad2721b1eb05d54e81393a7ebc332d4a35c68f upstream. + +The file now rightfully throws up a big warning that it should never be +included, so remove it from the header_check test. + +Fixes: f23653fe6447 ("tty: Partially revert the removal of the Cyclades public API") +Cc: stable +Cc: Masahiro Yamada +Cc: "Maciej W. Rozycki" +Reported-by: Stephen Rothwell +Reported-by: kernel test robot +Link: https://lore.kernel.org/r/20220127073304.42399-1-gregkh@linuxfoundation.org +Signed-off-by: Greg Kroah-Hartman +--- + usr/include/Makefile | 1 + + 1 file changed, 1 insertion(+) + +--- a/usr/include/Makefile ++++ b/usr/include/Makefile +@@ -28,6 +28,7 @@ no-header-test += linux/am437x-vpfe.h + no-header-test += linux/android/binder.h + no-header-test += linux/android/binderfs.h + no-header-test += linux/coda.h ++no-header-test += linux/cyclades.h + no-header-test += linux/errqueue.h + no-header-test += linux/fsmap.h + no-header-test += linux/hdlc/ioctl.h diff --git a/queue-5.16/serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch b/queue-5.16/serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch new file mode 100644 index 00000000000..3b2e7b0c789 --- /dev/null +++ b/queue-5.16/serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch @@ -0,0 +1,52 @@ +From d06b1cf28297e27127d3da54753a3a01a2fa2f28 Mon Sep 17 00:00:00 2001 +From: Robert Hancock +Date: Wed, 12 Jan 2022 13:42:14 -0600 +Subject: serial: 8250: of: Fix mapped region size when using reg-offset property + +From: Robert Hancock + +commit d06b1cf28297e27127d3da54753a3a01a2fa2f28 upstream. + +8250_of supports a reg-offset property which is intended to handle +cases where the device registers start at an offset inside the region +of memory allocated to the device. The Xilinx 16550 UART, for which this +support was initially added, requires this. However, the code did not +adjust the overall size of the mapped region accordingly, causing the +driver to request an area of memory past the end of the device's +allocation. For example, if the UART was allocated an address of +0xb0130000, size of 0x10000 and reg-offset of 0x1000 in the device +tree, the region of memory reserved was b0131000-b0140fff, which caused +the driver for the region starting at b0140000 to fail to probe. + +Fix this by subtracting reg-offset from the mapped region size. + +Fixes: b912b5e2cfb3 ([POWERPC] Xilinx: of_serial support for Xilinx uart 16550.) +Cc: stable +Signed-off-by: Robert Hancock +Link: https://lore.kernel.org/r/20220112194214.881844-1-robert.hancock@calian.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/8250/8250_of.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/8250/8250_of.c ++++ b/drivers/tty/serial/8250/8250_of.c +@@ -83,8 +83,17 @@ static int of_platform_serial_setup(stru + port->mapsize = resource_size(&resource); + + /* Check for shifted address mapping */ +- if (of_property_read_u32(np, "reg-offset", &prop) == 0) ++ if (of_property_read_u32(np, "reg-offset", &prop) == 0) { ++ if (prop >= port->mapsize) { ++ dev_warn(&ofdev->dev, "reg-offset %u exceeds region size %pa\n", ++ prop, &port->mapsize); ++ ret = -EINVAL; ++ goto err_unprepare; ++ } ++ + port->mapbase += prop; ++ port->mapsize -= prop; ++ } + + port->iotype = UPIO_MEM; + if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { diff --git a/queue-5.16/serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch b/queue-5.16/serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch new file mode 100644 index 00000000000..6eda34ffd09 --- /dev/null +++ b/queue-5.16/serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch @@ -0,0 +1,42 @@ +From 62f676ff7898f6c1bd26ce014564773a3dc00601 Mon Sep 17 00:00:00 2001 +From: Jochen Mades +Date: Sat, 23 Jan 2021 05:10:14 +0100 +Subject: serial: pl011: Fix incorrect rs485 RTS polarity on set_mctrl + +From: Jochen Mades + +commit 62f676ff7898f6c1bd26ce014564773a3dc00601 upstream. + +Commit 8d479237727c ("serial: amba-pl011: add RS485 support") sought to +keep RTS deasserted on set_mctrl if rs485 is enabled. However it did so +only if deasserted RTS polarity is high. Fix it in case it's low. + +Fixes: 8d479237727c ("serial: amba-pl011: add RS485 support") +Cc: stable@vger.kernel.org # v5.15+ +Cc: Lino Sanfilippo +Signed-off-by: Jochen Mades +[lukas: copyedit commit message, add stable designation] +Signed-off-by: Lukas Wunner +Link: https://lore.kernel.org/r/85fa3323ba8c307943969b7343e23f34c3e652ba.1642909284.git.lukas@wunner.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/amba-pl011.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/tty/serial/amba-pl011.c ++++ b/drivers/tty/serial/amba-pl011.c +@@ -1615,8 +1615,12 @@ static void pl011_set_mctrl(struct uart_ + container_of(port, struct uart_amba_port, port); + unsigned int cr; + +- if (port->rs485.flags & SER_RS485_ENABLED) +- mctrl &= ~TIOCM_RTS; ++ if (port->rs485.flags & SER_RS485_ENABLED) { ++ if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ++ mctrl &= ~TIOCM_RTS; ++ else ++ mctrl |= TIOCM_RTS; ++ } + + cr = pl011_read(uap, REG_CR); + diff --git a/queue-5.16/serial-stm32-fix-software-flow-control-transfer.patch b/queue-5.16/serial-stm32-fix-software-flow-control-transfer.patch new file mode 100644 index 00000000000..4fa7202c53f --- /dev/null +++ b/queue-5.16/serial-stm32-fix-software-flow-control-transfer.patch @@ -0,0 +1,34 @@ +From 037b91ec7729524107982e36ec4b40f9b174f7a2 Mon Sep 17 00:00:00 2001 +From: Valentin Caron +Date: Tue, 11 Jan 2022 17:44:41 +0100 +Subject: serial: stm32: fix software flow control transfer + +From: Valentin Caron + +commit 037b91ec7729524107982e36ec4b40f9b174f7a2 upstream. + +x_char is ignored by stm32_usart_start_tx() when xmit buffer is empty. + +Fix start_tx condition to allow x_char to be sent. + +Fixes: 48a6092fb41f ("serial: stm32-usart: Add STM32 USART Driver") +Cc: stable +Signed-off-by: Erwan Le Ray +Signed-off-by: Valentin Caron +Link: https://lore.kernel.org/r/20220111164441.6178-3-valentin.caron@foss.st.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/stm32-usart.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/tty/serial/stm32-usart.c ++++ b/drivers/tty/serial/stm32-usart.c +@@ -696,7 +696,7 @@ static void stm32_usart_start_tx(struct + struct serial_rs485 *rs485conf = &port->rs485; + struct circ_buf *xmit = &port->state->xmit; + +- if (uart_circ_empty(xmit)) ++ if (uart_circ_empty(xmit) && !port->x_char) + return; + + if (rs485conf->flags & SER_RS485_ENABLED) { diff --git a/queue-5.16/series b/queue-5.16/series index 9525a8c78f4..638810c4363 100644 --- a/queue-5.16/series +++ b/queue-5.16/series @@ -62,3 +62,23 @@ arm64-extable-fix-load_unaligned_zeropad-reg-indices.patch dm-revert-partial-fix-for-redundant-bio-based-io-accounting.patch block-add-bio_start_io_acct_time-to-control-start_time.patch dm-properly-fix-redundant-bio-based-io-accounting.patch +serial-pl011-fix-incorrect-rs485-rts-polarity-on-set_mctrl.patch +serial-8250-of-fix-mapped-region-size-when-using-reg-offset-property.patch +serial-stm32-fix-software-flow-control-transfer.patch +tty-rpmsg-fix-race-condition-releasing-tty-port.patch +tty-n_gsm-fix-sw-flow-control-encoding-handling.patch +tty-partially-revert-the-removal-of-the-cyclades-public-api.patch +tty-add-support-for-brainboxes-uc-cards.patch +kbuild-remove-include-linux-cyclades.h-from-header-file-check.patch +usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch +usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch +usb-common-ulpi-fix-crash-in-ulpi_match.patch +usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch +usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch +usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch +usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch +usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch +usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch +usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch +usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch +ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch diff --git a/queue-5.16/tty-add-support-for-brainboxes-uc-cards.patch b/queue-5.16/tty-add-support-for-brainboxes-uc-cards.patch new file mode 100644 index 00000000000..b5e3d1140c7 --- /dev/null +++ b/queue-5.16/tty-add-support-for-brainboxes-uc-cards.patch @@ -0,0 +1,139 @@ +From 152d1afa834c84530828ee031cf07a00e0fc0b8c Mon Sep 17 00:00:00 2001 +From: Cameron Williams +Date: Mon, 24 Jan 2022 09:42:23 +0000 +Subject: tty: Add support for Brainboxes UC cards. + +From: Cameron Williams + +commit 152d1afa834c84530828ee031cf07a00e0fc0b8c upstream. + +This commit adds support for the some of the Brainboxes PCI range of +cards, including the UC-101, UC-235/246, UC-257, UC-268, UC-275/279, +UC-302, UC-310, UC-313, UC-320/324, UC-346, UC-357, UC-368 +and UC-420/431. + +Signed-off-by: Cameron Williams +Cc: stable +Link: https://lore.kernel.org/r/AM5PR0202MB2564688493F7DD9B9C610827C45E9@AM5PR0202MB2564.eurprd02.prod.outlook.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/8250/8250_pci.c | 100 ++++++++++++++++++++++++++++++++++++- + 1 file changed, 98 insertions(+), 2 deletions(-) + +--- a/drivers/tty/serial/8250/8250_pci.c ++++ b/drivers/tty/serial/8250/8250_pci.c +@@ -5174,8 +5174,30 @@ static const struct pci_device_id serial + { PCI_VENDOR_ID_INTASHIELD, PCI_DEVICE_ID_INTASHIELD_IS400, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */ + pbn_b2_4_115200 }, ++ /* Brainboxes Devices */ + /* +- * BrainBoxes UC-260 ++ * Brainboxes UC-101 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0BA1, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-235/246 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0AA1, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_1_115200 }, ++ /* ++ * Brainboxes UC-257 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0861, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-260/271/701/756 + */ + { PCI_VENDOR_ID_INTASHIELD, 0x0D21, + PCI_ANY_ID, PCI_ANY_ID, +@@ -5183,7 +5205,81 @@ static const struct pci_device_id serial + pbn_b2_4_115200 }, + { PCI_VENDOR_ID_INTASHIELD, 0x0E34, + PCI_ANY_ID, PCI_ANY_ID, +- PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, ++ PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, ++ pbn_b2_4_115200 }, ++ /* ++ * Brainboxes UC-268 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0841, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_4_115200 }, ++ /* ++ * Brainboxes UC-275/279 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0881, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_8_115200 }, ++ /* ++ * Brainboxes UC-302 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x08E1, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-310 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x08C1, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-313 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x08A3, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-320/324 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0A61, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_1_115200 }, ++ /* ++ * Brainboxes UC-346 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0B02, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_4_115200 }, ++ /* ++ * Brainboxes UC-357 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0A81, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ { PCI_VENDOR_ID_INTASHIELD, 0x0A83, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_2_115200 }, ++ /* ++ * Brainboxes UC-368 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0C41, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, ++ pbn_b2_4_115200 }, ++ /* ++ * Brainboxes UC-420/431 ++ */ ++ { PCI_VENDOR_ID_INTASHIELD, 0x0921, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, + pbn_b2_4_115200 }, + /* + * Perle PCI-RAS cards diff --git a/queue-5.16/tty-n_gsm-fix-sw-flow-control-encoding-handling.patch b/queue-5.16/tty-n_gsm-fix-sw-flow-control-encoding-handling.patch new file mode 100644 index 00000000000..c2ebc1a0edf --- /dev/null +++ b/queue-5.16/tty-n_gsm-fix-sw-flow-control-encoding-handling.patch @@ -0,0 +1,64 @@ +From 8838b2af23caf1ff0610caef2795d6668a013b2d Mon Sep 17 00:00:00 2001 +From: "daniel.starke@siemens.com" +Date: Thu, 20 Jan 2022 02:18:57 -0800 +Subject: tty: n_gsm: fix SW flow control encoding/handling + +From: daniel.starke@siemens.com + +commit 8838b2af23caf1ff0610caef2795d6668a013b2d upstream. + +n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. +See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516 +The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to +the newer 27.010 here. Chapter 5.2.7.3 states that DC1 (XON) and DC3 (XOFF) +are the control characters defined in ISO/IEC 646. These shall be quoted if +seen in the data stream to avoid interpretation as flow control characters. + +ISO/IEC 646 refers to the set of ISO standards described as the ISO +7-bit coded character set for information interchange. Its final version +is also known as ITU T.50. +See https://www.itu.int/rec/T-REC-T.50-199209-I/en + +To abide the standard it is needed to quote DC1 and DC3 correctly if these +are seen as data bytes and not as control characters. The current +implementation already tries to enforce this but fails to catch all +defined cases. 3GPP 27.010 chapter 5.2.7.3 clearly states that the most +significant bit shall be ignored for DC1 and DC3 handling. The current +implementation handles only the case with the most significant bit set 0. +Cases in which DC1 and DC3 have the most significant bit set 1 are left +unhandled. + +This patch fixes this by masking the data bytes with ISO_IEC_646_MASK (only +the 7 least significant bits set 1) before comparing them with XON +(a.k.a. DC1) and XOFF (a.k.a. DC3) when testing which byte values need +quotation via byte stuffing. + +Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") +Cc: stable@vger.kernel.org +Signed-off-by: Daniel Starke +Link: https://lore.kernel.org/r/20220120101857.2509-1-daniel.starke@siemens.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/n_gsm.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/tty/n_gsm.c ++++ b/drivers/tty/n_gsm.c +@@ -322,6 +322,7 @@ static int addr_cnt; + #define GSM1_ESCAPE_BITS 0x20 + #define XON 0x11 + #define XOFF 0x13 ++#define ISO_IEC_646_MASK 0x7F + + static const struct tty_port_operations gsm_port_ops; + +@@ -531,7 +532,8 @@ static int gsm_stuff_frame(const u8 *inp + int olen = 0; + while (len--) { + if (*input == GSM1_SOF || *input == GSM1_ESCAPE +- || *input == XON || *input == XOFF) { ++ || (*input & ISO_IEC_646_MASK) == XON ++ || (*input & ISO_IEC_646_MASK) == XOFF) { + *output++ = GSM1_ESCAPE; + *output++ = *input++ ^ GSM1_ESCAPE_BITS; + olen++; diff --git a/queue-5.16/tty-partially-revert-the-removal-of-the-cyclades-public-api.patch b/queue-5.16/tty-partially-revert-the-removal-of-the-cyclades-public-api.patch new file mode 100644 index 00000000000..488a763c288 --- /dev/null +++ b/queue-5.16/tty-partially-revert-the-removal-of-the-cyclades-public-api.patch @@ -0,0 +1,78 @@ +From f23653fe64479d96910bfda2b700b1af17c991ac Mon Sep 17 00:00:00 2001 +From: "Maciej W. Rozycki" +Date: Wed, 26 Jan 2022 09:22:54 +0000 +Subject: tty: Partially revert the removal of the Cyclades public API + +From: Maciej W. Rozycki + +commit f23653fe64479d96910bfda2b700b1af17c991ac upstream. + +Fix a user API regression introduced with commit f76edd8f7ce0 ("tty: +cyclades, remove this orphan"), which removed a part of the API and +caused compilation errors for user programs using said part, such as +GCC 9 in its libsanitizer component[1]: + +.../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:160:10: fatal error: linux/cyclades.h: No such file or directory + 160 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +make[4]: *** [Makefile:664: sanitizer_platform_limits_posix.lo] Error 1 + +As the absolute minimum required bring `struct cyclades_monitor' and +ioctl numbers back then so as to make the library build again. Add a +preprocessor warning as to the obsolescence of the features provided. + +References: + +[1] GCC PR sanitizer/100379, "cyclades.h is removed from linux kernel + header files", + +Fixes: f76edd8f7ce0 ("tty: cyclades, remove this orphan") +Cc: stable@vger.kernel.org # v5.13+ +Reviewed-by: Christoph Hellwig +Signed-off-by: Maciej W. Rozycki +Link: https://lore.kernel.org/r/alpine.DEB.2.20.2201260733430.11348@tpp.orcam.me.uk +Signed-off-by: Greg Kroah-Hartman +--- + include/uapi/linux/cyclades.h | 35 +++++++++++++++++++++++++++++++++++ + 1 file changed, 35 insertions(+) + create mode 100644 include/uapi/linux/cyclades.h + +--- /dev/null ++++ b/include/uapi/linux/cyclades.h +@@ -0,0 +1,35 @@ ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ ++ ++#ifndef _UAPI_LINUX_CYCLADES_H ++#define _UAPI_LINUX_CYCLADES_H ++ ++#warning "Support for features provided by this header has been removed" ++#warning "Please consider updating your code" ++ ++struct cyclades_monitor { ++ unsigned long int_count; ++ unsigned long char_count; ++ unsigned long char_max; ++ unsigned long char_last; ++}; ++ ++#define CYGETMON 0x435901 ++#define CYGETTHRESH 0x435902 ++#define CYSETTHRESH 0x435903 ++#define CYGETDEFTHRESH 0x435904 ++#define CYSETDEFTHRESH 0x435905 ++#define CYGETTIMEOUT 0x435906 ++#define CYSETTIMEOUT 0x435907 ++#define CYGETDEFTIMEOUT 0x435908 ++#define CYSETDEFTIMEOUT 0x435909 ++#define CYSETRFLOW 0x43590a ++#define CYGETRFLOW 0x43590b ++#define CYSETRTSDTR_INV 0x43590c ++#define CYGETRTSDTR_INV 0x43590d ++#define CYZSETPOLLCYCLE 0x43590e ++#define CYZGETPOLLCYCLE 0x43590f ++#define CYGETCD1400VER 0x435910 ++#define CYSETWAIT 0x435912 ++#define CYGETWAIT 0x435913 ++ ++#endif /* _UAPI_LINUX_CYCLADES_H */ diff --git a/queue-5.16/tty-rpmsg-fix-race-condition-releasing-tty-port.patch b/queue-5.16/tty-rpmsg-fix-race-condition-releasing-tty-port.patch new file mode 100644 index 00000000000..545cc4aa039 --- /dev/null +++ b/queue-5.16/tty-rpmsg-fix-race-condition-releasing-tty-port.patch @@ -0,0 +1,149 @@ +From db7f19c0aa0abcb751ff0ed694a071363f702b1d Mon Sep 17 00:00:00 2001 +From: Arnaud Pouliquen +Date: Tue, 4 Jan 2022 17:35:45 +0100 +Subject: tty: rpmsg: Fix race condition releasing tty port + +From: Arnaud Pouliquen + +commit db7f19c0aa0abcb751ff0ed694a071363f702b1d upstream. + +The tty_port struct is part of the rpmsg_tty_port structure. +The issue is that the rpmsg_tty_port structure is freed on +rpmsg_tty_remove while it is still referenced in the tty_struct. +Its release is not predictable due to workqueues. + +For instance following ftrace shows that rpmsg_tty_close is called after +rpmsg_tty_release_cport: + + nr_test.sh-389 [000] ..... 212.093752: rpmsg_tty_remove <-rpmsg_dev_ +remove + cat-1191 [001] ..... 212.095697: tty_release <-__fput + nr_test.sh-389 [000] ..... 212.099166: rpmsg_tty_release_cport <-rpm +sg_tty_remove + cat-1191 [001] ..... 212.115352: rpmsg_tty_close <-tty_release + cat-1191 [001] ..... 212.115371: release_tty <-tty_release_str + +As consequence, the port must be free only when user has released the TTY +interface. + +This path : +- Introduce the .destruct port tty ops function to release the allocated + rpmsg_tty_port structure. +- Introduce the .hangup tty ops function to call tty_port_hangup. +- Manages the tty port refcounting to trig the .destruct port ops, +- Introduces the rpmsg_tty_cleanup function to ensure that the TTY is + removed before decreasing the port refcount. + +Fixes: 7c0408d80579 ("tty: add rpmsg driver") +Cc: stable +Signed-off-by: Arnaud Pouliquen +Link: https://lore.kernel.org/r/20220104163545.34710-1-arnaud.pouliquen@foss.st.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/rpmsg_tty.c | 40 ++++++++++++++++++++++++++-------------- + 1 file changed, 26 insertions(+), 14 deletions(-) + +--- a/drivers/tty/rpmsg_tty.c ++++ b/drivers/tty/rpmsg_tty.c +@@ -50,10 +50,17 @@ static int rpmsg_tty_cb(struct rpmsg_dev + static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty) + { + struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index); ++ struct tty_port *port; + + tty->driver_data = cport; + +- return tty_port_install(&cport->port, driver, tty); ++ port = tty_port_get(&cport->port); ++ return tty_port_install(port, driver, tty); ++} ++ ++static void rpmsg_tty_cleanup(struct tty_struct *tty) ++{ ++ tty_port_put(tty->port); + } + + static int rpmsg_tty_open(struct tty_struct *tty, struct file *filp) +@@ -106,12 +113,19 @@ static unsigned int rpmsg_tty_write_room + return size; + } + ++static void rpmsg_tty_hangup(struct tty_struct *tty) ++{ ++ tty_port_hangup(tty->port); ++} ++ + static const struct tty_operations rpmsg_tty_ops = { + .install = rpmsg_tty_install, + .open = rpmsg_tty_open, + .close = rpmsg_tty_close, + .write = rpmsg_tty_write, + .write_room = rpmsg_tty_write_room, ++ .hangup = rpmsg_tty_hangup, ++ .cleanup = rpmsg_tty_cleanup, + }; + + static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void) +@@ -137,8 +151,10 @@ static struct rpmsg_tty_port *rpmsg_tty_ + return cport; + } + +-static void rpmsg_tty_release_cport(struct rpmsg_tty_port *cport) ++static void rpmsg_tty_destruct_port(struct tty_port *port) + { ++ struct rpmsg_tty_port *cport = container_of(port, struct rpmsg_tty_port, port); ++ + mutex_lock(&idr_lock); + idr_remove(&tty_idr, cport->id); + mutex_unlock(&idr_lock); +@@ -146,7 +162,10 @@ static void rpmsg_tty_release_cport(stru + kfree(cport); + } + +-static const struct tty_port_operations rpmsg_tty_port_ops = { }; ++static const struct tty_port_operations rpmsg_tty_port_ops = { ++ .destruct = rpmsg_tty_destruct_port, ++}; ++ + + static int rpmsg_tty_probe(struct rpmsg_device *rpdev) + { +@@ -166,7 +185,8 @@ static int rpmsg_tty_probe(struct rpmsg_ + cport->id, dev); + if (IS_ERR(tty_dev)) { + ret = dev_err_probe(dev, PTR_ERR(tty_dev), "Failed to register tty port\n"); +- goto err_destroy; ++ tty_port_put(&cport->port); ++ return ret; + } + + cport->rpdev = rpdev; +@@ -177,12 +197,6 @@ static int rpmsg_tty_probe(struct rpmsg_ + rpdev->src, rpdev->dst, cport->id); + + return 0; +- +-err_destroy: +- tty_port_destroy(&cport->port); +- rpmsg_tty_release_cport(cport); +- +- return ret; + } + + static void rpmsg_tty_remove(struct rpmsg_device *rpdev) +@@ -192,13 +206,11 @@ static void rpmsg_tty_remove(struct rpms + dev_dbg(&rpdev->dev, "Removing rpmsg tty device %d\n", cport->id); + + /* User hang up to release the tty */ +- if (tty_port_initialized(&cport->port)) +- tty_port_tty_hangup(&cport->port, false); ++ tty_port_tty_hangup(&cport->port, false); + + tty_unregister_device(rpmsg_tty_driver, cport->id); + +- tty_port_destroy(&cport->port); +- rpmsg_tty_release_cport(cport); ++ tty_port_put(&cport->port); + } + + static struct rpmsg_device_id rpmsg_driver_tty_id_table[] = { diff --git a/queue-5.16/ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch b/queue-5.16/ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch new file mode 100644 index 00000000000..f0e07c53fc8 --- /dev/null +++ b/queue-5.16/ucsi_ccg-check-dev_int-bit-only-when-starting-ccg4.patch @@ -0,0 +1,40 @@ +From 825911492eb15bf8bb7fb94bc0c0421fe7a6327d Mon Sep 17 00:00:00 2001 +From: Sing-Han Chen +Date: Wed, 12 Jan 2022 17:41:43 +0800 +Subject: ucsi_ccg: Check DEV_INT bit only when starting CCG4 + +From: Sing-Han Chen + +commit 825911492eb15bf8bb7fb94bc0c0421fe7a6327d upstream. + +CCGx clears Bit 0:Device Interrupt in the INTR_REG +if CCGx is reset successfully. However, there might +be a chance that other bits in INTR_REG are not +cleared due to internal data queued in PPM. This case +misleads the driver that CCGx reset failed. + +The commit checks bit 0 in INTR_REG and ignores other +bits. The ucsi driver would reset PPM later. + +Fixes: 247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") +Cc: stable@vger.kernel.org +Reviewed-by: Heikki Krogerus +Signed-off-by: Sing-Han Chen +Signed-off-by: Wayne Chang +Link: https://lore.kernel.org/r/20220112094143.628610-1-waynec@nvidia.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/ucsi/ucsi_ccg.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/typec/ucsi/ucsi_ccg.c ++++ b/drivers/usb/typec/ucsi/ucsi_ccg.c +@@ -325,7 +325,7 @@ static int ucsi_ccg_init(struct ucsi_ccg + if (status < 0) + return status; + +- if (!data) ++ if (!(data & DEV_INT)) + return 0; + + status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data)); diff --git a/queue-5.16/usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch b/queue-5.16/usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch new file mode 100644 index 00000000000..7395432bdef --- /dev/null +++ b/queue-5.16/usb-cdnsp-fix-segmentation-fault-in-cdns_lost_power-function.patch @@ -0,0 +1,38 @@ +From 79aa3e19fe8f5be30e846df8a436bfe306e8b1a6 Mon Sep 17 00:00:00 2001 +From: Pawel Laszczak +Date: Tue, 11 Jan 2022 10:07:37 +0100 +Subject: usb: cdnsp: Fix segmentation fault in cdns_lost_power function + +From: Pawel Laszczak + +commit 79aa3e19fe8f5be30e846df8a436bfe306e8b1a6 upstream. + +CDNSP driver read not initialized cdns->otg_v0_regs +which lead to segmentation fault. Patch fixes this issue. + +Fixes: 2cf2581cd229 ("usb: cdns3: add power lost support for system resume") +cc: +Signed-off-by: Pawel Laszczak +Link: https://lore.kernel.org/r/20220111090737.10345-1-pawell@gli-login.cadence.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/cdns3/drd.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/usb/cdns3/drd.c ++++ b/drivers/usb/cdns3/drd.c +@@ -483,11 +483,11 @@ int cdns_drd_exit(struct cdns *cdns) + /* Indicate the cdns3 core was power lost before */ + bool cdns_power_is_lost(struct cdns *cdns) + { +- if (cdns->version == CDNS3_CONTROLLER_V1) { +- if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) ++ if (cdns->version == CDNS3_CONTROLLER_V0) { ++ if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) + return true; + } else { +- if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) ++ if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) + return true; + } + return false; diff --git a/queue-5.16/usb-common-ulpi-fix-crash-in-ulpi_match.patch b/queue-5.16/usb-common-ulpi-fix-crash-in-ulpi_match.patch new file mode 100644 index 00000000000..ff489da4296 --- /dev/null +++ b/queue-5.16/usb-common-ulpi-fix-crash-in-ulpi_match.patch @@ -0,0 +1,47 @@ +From 2e3dd4a6246945bf84ea6f478365d116e661554c Mon Sep 17 00:00:00 2001 +From: Jon Hunter +Date: Mon, 17 Jan 2022 15:00:39 +0000 +Subject: usb: common: ulpi: Fix crash in ulpi_match() + +From: Jon Hunter + +commit 2e3dd4a6246945bf84ea6f478365d116e661554c upstream. + +Commit 7495af930835 ("ARM: multi_v7_defconfig: Enable drivers for +DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM +multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash +on the Tegra20 Ventana platform in the ulpi_match() function. + +The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS, +registers a ulpi_driver but this driver does not provide an 'id_table', +so when ulpi_match() is called on the Tegra20 Ventana platform, it +crashes when attempting to deference the id_table pointer which is not +valid. The Qualcomm USB HS PHY driver uses device-tree for matching the +ULPI driver with the device and so fix this crash by using device-tree +for matching if the id_table is not valid. + +Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT") +Cc: stable +Signed-off-by: Jon Hunter +Link: https://lore.kernel.org/r/20220117150039.44058-1-jonathanh@nvidia.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/common/ulpi.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/usb/common/ulpi.c ++++ b/drivers/usb/common/ulpi.c +@@ -39,8 +39,11 @@ static int ulpi_match(struct device *dev + struct ulpi *ulpi = to_ulpi_dev(dev); + const struct ulpi_device_id *id; + +- /* Some ULPI devices don't have a vendor id so rely on OF match */ +- if (ulpi->id.vendor == 0) ++ /* ++ * Some ULPI devices don't have a vendor id ++ * or provide an id_table so rely on OF match. ++ */ ++ if (ulpi->id.vendor == 0 || !drv->id_table) + return of_driver_match_device(dev, driver); + + for (id = drv->id_table; id->vendor; id++) diff --git a/queue-5.16/usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch b/queue-5.16/usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch new file mode 100644 index 00000000000..229a329f476 --- /dev/null +++ b/queue-5.16/usb-core-fix-hang-in-usb_kill_urb-by-adding-memory-barriers.patch @@ -0,0 +1,128 @@ +From 26fbe9772b8c459687930511444ce443011f86bf Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Mon, 24 Jan 2022 15:23:45 -0500 +Subject: USB: core: Fix hang in usb_kill_urb by adding memory barriers + +From: Alan Stern + +commit 26fbe9772b8c459687930511444ce443011f86bf upstream. + +The syzbot fuzzer has identified a bug in which processes hang waiting +for usb_kill_urb() to return. It turns out the issue is not unlinking +the URB; that works just fine. Rather, the problem arises when the +wakeup notification that the URB has completed is not received. + +The reason is memory-access ordering on SMP systems. In outline form, +usb_kill_urb() and __usb_hcd_giveback_urb() operating concurrently on +different CPUs perform the following actions: + +CPU 0 CPU 1 +---------------------------- --------------------------------- +usb_kill_urb(): __usb_hcd_giveback_urb(): + ... ... + atomic_inc(&urb->reject); atomic_dec(&urb->use_count); + ... ... + wait_event(usb_kill_urb_queue, + atomic_read(&urb->use_count) == 0); + if (atomic_read(&urb->reject)) + wake_up(&usb_kill_urb_queue); + +Confining your attention to urb->reject and urb->use_count, you can +see that the overall pattern of accesses on CPU 0 is: + + write urb->reject, then read urb->use_count; + +whereas the overall pattern of accesses on CPU 1 is: + + write urb->use_count, then read urb->reject. + +This pattern is referred to in memory-model circles as SB (for "Store +Buffering"), and it is well known that without suitable enforcement of +the desired order of accesses -- in the form of memory barriers -- it +is entirely possible for one or both CPUs to execute their reads ahead +of their writes. The end result will be that sometimes CPU 0 sees the +old un-decremented value of urb->use_count while CPU 1 sees the old +un-incremented value of urb->reject. Consequently CPU 0 ends up on +the wait queue and never gets woken up, leading to the observed hang +in usb_kill_urb(). + +The same pattern of accesses occurs in usb_poison_urb() and the +failure pathway of usb_hcd_submit_urb(). + +The problem is fixed by adding suitable memory barriers. To provide +proper memory-access ordering in the SB pattern, a full barrier is +required on both CPUs. The atomic_inc() and atomic_dec() accesses +themselves don't provide any memory ordering, but since they are +present, we can use the optimized smp_mb__after_atomic() memory +barrier in the various routines to obtain the desired effect. + +This patch adds the necessary memory barriers. + +CC: +Reported-and-tested-by: syzbot+76629376e06e2c2ad626@syzkaller.appspotmail.com +Signed-off-by: Alan Stern +Link: https://lore.kernel.org/r/Ye8K0QYee0Q0Nna2@rowland.harvard.edu +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/core/hcd.c | 14 ++++++++++++++ + drivers/usb/core/urb.c | 12 ++++++++++++ + 2 files changed, 26 insertions(+) + +--- a/drivers/usb/core/hcd.c ++++ b/drivers/usb/core/hcd.c +@@ -1563,6 +1563,13 @@ int usb_hcd_submit_urb (struct urb *urb, + urb->hcpriv = NULL; + INIT_LIST_HEAD(&urb->urb_list); + atomic_dec(&urb->use_count); ++ /* ++ * Order the write of urb->use_count above before the read ++ * of urb->reject below. Pairs with the memory barriers in ++ * usb_kill_urb() and usb_poison_urb(). ++ */ ++ smp_mb__after_atomic(); ++ + atomic_dec(&urb->dev->urbnum); + if (atomic_read(&urb->reject)) + wake_up(&usb_kill_urb_queue); +@@ -1665,6 +1672,13 @@ static void __usb_hcd_giveback_urb(struc + + usb_anchor_resume_wakeups(anchor); + atomic_dec(&urb->use_count); ++ /* ++ * Order the write of urb->use_count above before the read ++ * of urb->reject below. Pairs with the memory barriers in ++ * usb_kill_urb() and usb_poison_urb(). ++ */ ++ smp_mb__after_atomic(); ++ + if (unlikely(atomic_read(&urb->reject))) + wake_up(&usb_kill_urb_queue); + usb_put_urb(urb); +--- a/drivers/usb/core/urb.c ++++ b/drivers/usb/core/urb.c +@@ -715,6 +715,12 @@ void usb_kill_urb(struct urb *urb) + if (!(urb && urb->dev && urb->ep)) + return; + atomic_inc(&urb->reject); ++ /* ++ * Order the write of urb->reject above before the read ++ * of urb->use_count below. Pairs with the barriers in ++ * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). ++ */ ++ smp_mb__after_atomic(); + + usb_hcd_unlink_urb(urb, -ENOENT); + wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); +@@ -756,6 +762,12 @@ void usb_poison_urb(struct urb *urb) + if (!urb) + return; + atomic_inc(&urb->reject); ++ /* ++ * Order the write of urb->reject above before the read ++ * of urb->use_count below. Pairs with the barriers in ++ * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). ++ */ ++ smp_mb__after_atomic(); + + if (!urb->dev || !urb->ep) + return; diff --git a/queue-5.16/usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch b/queue-5.16/usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch new file mode 100644 index 00000000000..75b80ecb97c --- /dev/null +++ b/queue-5.16/usb-dwc3-xilinx-fix-error-handling-when-getting-usb3-phy.patch @@ -0,0 +1,44 @@ +From 2cc9b1c93b1c4caa2d971856c0780fb5f7d04692 Mon Sep 17 00:00:00 2001 +From: Robert Hancock +Date: Tue, 25 Jan 2022 18:02:51 -0600 +Subject: usb: dwc3: xilinx: Fix error handling when getting USB3 PHY + +From: Robert Hancock + +commit 2cc9b1c93b1c4caa2d971856c0780fb5f7d04692 upstream. + +The code that looked up the USB3 PHY was ignoring all errors other than +EPROBE_DEFER in an attempt to handle the PHY not being present. Fix and +simplify the code by using devm_phy_optional_get and dev_err_probe so +that a missing PHY is not treated as an error and unexpected errors +are handled properly. + +Fixes: 84770f028fab ("usb: dwc3: Add driver for Xilinx platforms") +Cc: stable +Signed-off-by: Robert Hancock +Link: https://lore.kernel.org/r/20220126000253.1586760-3-robert.hancock@calian.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/dwc3-xilinx.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/usb/dwc3/dwc3-xilinx.c ++++ b/drivers/usb/dwc3/dwc3-xilinx.c +@@ -102,12 +102,12 @@ static int dwc3_xlnx_init_zynqmp(struct + int ret; + u32 reg; + +- usb3_phy = devm_phy_get(dev, "usb3-phy"); +- if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) { +- ret = -EPROBE_DEFER; ++ usb3_phy = devm_phy_optional_get(dev, "usb3-phy"); ++ if (IS_ERR(usb3_phy)) { ++ ret = PTR_ERR(usb3_phy); ++ dev_err_probe(dev, ret, ++ "failed to get USB3 PHY\n"); + goto err; +- } else if (IS_ERR(usb3_phy)) { +- usb3_phy = NULL; + } + + /* diff --git a/queue-5.16/usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch b/queue-5.16/usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch new file mode 100644 index 00000000000..ea5468bc8a0 --- /dev/null +++ b/queue-5.16/usb-dwc3-xilinx-skip-resets-and-usb3-register-settings-for-usb2.0-mode.patch @@ -0,0 +1,56 @@ +From 9678f3361afc27a3124cd2824aec0227739986fb Mon Sep 17 00:00:00 2001 +From: Robert Hancock +Date: Tue, 25 Jan 2022 18:02:50 -0600 +Subject: usb: dwc3: xilinx: Skip resets and USB3 register settings for USB2.0 mode + +From: Robert Hancock + +commit 9678f3361afc27a3124cd2824aec0227739986fb upstream. + +It appears that the PIPE clock should not be selected when only USB 2.0 +is being used in the design and no USB 3.0 reference clock is used. +Also, the core resets are not required if a USB3 PHY is not in use, and +will break things if USB3 is actually used but the PHY entry is not +listed in the device tree. + +Skip core resets and register settings that are only required for +USB3 mode when no USB3 PHY is specified in the device tree. + +Fixes: 84770f028fab ("usb: dwc3: Add driver for Xilinx platforms") +Cc: stable +Signed-off-by: Robert Hancock +Link: https://lore.kernel.org/r/20220126000253.1586760-2-robert.hancock@calian.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/dwc3-xilinx.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/drivers/usb/dwc3/dwc3-xilinx.c ++++ b/drivers/usb/dwc3/dwc3-xilinx.c +@@ -110,6 +110,18 @@ static int dwc3_xlnx_init_zynqmp(struct + usb3_phy = NULL; + } + ++ /* ++ * The following core resets are not required unless a USB3 PHY ++ * is used, and the subsequent register settings are not required ++ * unless a core reset is performed (they should be set properly ++ * by the first-stage boot loader, but may be reverted by a core ++ * reset). They may also break the configuration if USB3 is actually ++ * in use but the usb3-phy entry is missing from the device tree. ++ * Therefore, skip these operations in this case. ++ */ ++ if (!usb3_phy) ++ goto skip_usb3_phy; ++ + crst = devm_reset_control_get_exclusive(dev, "usb_crst"); + if (IS_ERR(crst)) { + ret = PTR_ERR(crst); +@@ -188,6 +200,7 @@ static int dwc3_xlnx_init_zynqmp(struct + goto err; + } + ++skip_usb3_phy: + /* + * This routes the USB DMA traffic to go through FPD path instead + * of reaching DDR directly. This traffic routing is needed to diff --git a/queue-5.16/usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch b/queue-5.16/usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch new file mode 100644 index 00000000000..12b6e9dbf15 --- /dev/null +++ b/queue-5.16/usb-gadget-f_sourcesink-fix-isoc-transfer-for-usb_speed_super_plus.patch @@ -0,0 +1,33 @@ +From 904edf8aeb459697129be5fde847e2a502f41fd9 Mon Sep 17 00:00:00 2001 +From: Pavankumar Kondeti +Date: Sat, 22 Jan 2022 08:33:22 +0530 +Subject: usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS + +From: Pavankumar Kondeti + +commit 904edf8aeb459697129be5fde847e2a502f41fd9 upstream. + +Currently when gadget enumerates in super speed plus, the isoc +endpoint request buffer size is not calculated correctly. Fix +this by checking the gadget speed against USB_SPEED_SUPER_PLUS +and update the request buffer size. + +Fixes: 90c4d05780d4 ("usb: fix various gadgets null ptr deref on 10gbps cabling.") +Cc: stable +Signed-off-by: Pavankumar Kondeti +Link: https://lore.kernel.org/r/1642820602-20619-1-git-send-email-quic_pkondeti@quicinc.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/f_sourcesink.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/usb/gadget/function/f_sourcesink.c ++++ b/drivers/usb/gadget/function/f_sourcesink.c +@@ -584,6 +584,7 @@ static int source_sink_start_ep(struct f + + if (is_iso) { + switch (speed) { ++ case USB_SPEED_SUPER_PLUS: + case USB_SPEED_SUPER: + size = ss->isoc_maxpacket * + (ss->isoc_mult + 1) * diff --git a/queue-5.16/usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch b/queue-5.16/usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch new file mode 100644 index 00000000000..6e50b7b528f --- /dev/null +++ b/queue-5.16/usb-storage-add-unusual-devs-entry-for-vl817-usb-sata-bridge.patch @@ -0,0 +1,59 @@ +From 5b67b315037250a61861119683e7fcb509deea25 Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Mon, 24 Jan 2022 15:14:40 -0500 +Subject: usb-storage: Add unusual-devs entry for VL817 USB-SATA bridge +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Alan Stern + +commit 5b67b315037250a61861119683e7fcb509deea25 upstream. + +Two people have reported (and mentioned numerous other reports on the +web) that VIA's VL817 USB-SATA bridge does not work with the uas +driver. Typical log messages are: + +[ 3606.232149] sd 14:0:0:0: [sdg] tag#2 uas_zap_pending 0 uas-tag 1 inflight: CMD +[ 3606.232154] sd 14:0:0:0: [sdg] tag#2 CDB: Write(16) 8a 00 00 00 00 00 18 0c c9 80 00 00 00 80 00 00 +[ 3606.306257] usb 4-4.4: reset SuperSpeed Plus Gen 2x1 USB device number 11 using xhci_hcd +[ 3606.328584] scsi host14: uas_eh_device_reset_handler success + +Surprisingly, the devices do seem to work okay for some other people. +The cause of the differing behaviors is not known. + +In the hope of getting the devices to work for the most users, even at +the possible cost of degraded performance for some, this patch adds an +unusual_devs entry for the VL817 to block it from binding to the uas +driver by default. Users will be able to override this entry by means +of a module parameter, if they want. + +CC: +Reported-by: DocMAX +Reported-and-tested-by: Thomas Weißschuh +Signed-off-by: Alan Stern +Link: https://lore.kernel.org/r/Ye8IsK2sjlEv1rqU@rowland.harvard.edu +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/storage/unusual_devs.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/usb/storage/unusual_devs.h ++++ b/drivers/usb/storage/unusual_devs.h +@@ -2301,6 +2301,16 @@ UNUSUAL_DEV( 0x2027, 0xa001, 0x0000, 0x + USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, + US_FL_SCM_MULT_TARG ), + ++/* ++ * Reported by DocMAX ++ * and Thomas Weißschuh ++ */ ++UNUSUAL_DEV( 0x2109, 0x0715, 0x9999, 0x9999, ++ "VIA Labs, Inc.", ++ "VL817 SATA Bridge", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_IGNORE_UAS), ++ + UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, + "ST", + "2A", diff --git a/queue-5.16/usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch b/queue-5.16/usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch new file mode 100644 index 00000000000..44424d4f548 --- /dev/null +++ b/queue-5.16/usb-typec-tcpci-don-t-touch-cc-line-if-it-s-vconn-source.patch @@ -0,0 +1,88 @@ +From 5638b0dfb6921f69943c705383ff40fb64b987f2 Mon Sep 17 00:00:00 2001 +From: Xu Yang +Date: Thu, 13 Jan 2022 17:29:43 +0800 +Subject: usb: typec: tcpci: don't touch CC line if it's Vconn source + +From: Xu Yang + +commit 5638b0dfb6921f69943c705383ff40fb64b987f2 upstream. + +With the AMS and Collision Avoidance, tcpm often needs to change the CC's +termination. When one CC line is sourcing Vconn, if we still change its +termination, the voltage of the another CC line is likely to be fluctuant +and unstable. + +Therefore, we should verify whether a CC line is sourcing Vconn before +changing its termination and only change the termination that is not +a Vconn line. This can be done by reading the Vconn Present bit of +POWER_ STATUS register. To determine the polarity, we can read the +Plug Orientation bit of TCPC_CONTROL register. Since Vconn can only be +sourced if Plug Orientation is set. + +Fixes: 0908c5aca31e ("usb: typec: tcpm: AMS and Collision Avoidance") +cc: +Reviewed-by: Guenter Roeck +Acked-by: Heikki Krogerus +Signed-off-by: Xu Yang +Link: https://lore.kernel.org/r/20220113092943.752372-1-xu.yang_2@nxp.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/tcpm/tcpci.c | 26 ++++++++++++++++++++++++++ + drivers/usb/typec/tcpm/tcpci.h | 1 + + 2 files changed, 27 insertions(+) + +--- a/drivers/usb/typec/tcpm/tcpci.c ++++ b/drivers/usb/typec/tcpm/tcpci.c +@@ -75,9 +75,25 @@ static int tcpci_write16(struct tcpci *t + static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) + { + struct tcpci *tcpci = tcpc_to_tcpci(tcpc); ++ bool vconn_pres; ++ enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1; + unsigned int reg; + int ret; + ++ ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, ®); ++ if (ret < 0) ++ return ret; ++ ++ vconn_pres = !!(reg & TCPC_POWER_STATUS_VCONN_PRES); ++ if (vconn_pres) { ++ ret = regmap_read(tcpci->regmap, TCPC_TCPC_CTRL, ®); ++ if (ret < 0) ++ return ret; ++ ++ if (reg & TCPC_TCPC_CTRL_ORIENTATION) ++ polarity = TYPEC_POLARITY_CC2; ++ } ++ + switch (cc) { + case TYPEC_CC_RA: + reg = (TCPC_ROLE_CTRL_CC_RA << TCPC_ROLE_CTRL_CC1_SHIFT) | +@@ -112,6 +128,16 @@ static int tcpci_set_cc(struct tcpc_dev + break; + } + ++ if (vconn_pres) { ++ if (polarity == TYPEC_POLARITY_CC2) { ++ reg &= ~(TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT); ++ reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT); ++ } else { ++ reg &= ~(TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT); ++ reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT); ++ } ++ } ++ + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; +--- a/drivers/usb/typec/tcpm/tcpci.h ++++ b/drivers/usb/typec/tcpm/tcpci.h +@@ -98,6 +98,7 @@ + #define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4) + #define TCPC_POWER_STATUS_VBUS_DET BIT(3) + #define TCPC_POWER_STATUS_VBUS_PRES BIT(2) ++#define TCPC_POWER_STATUS_VCONN_PRES BIT(1) + #define TCPC_POWER_STATUS_SINKING_VBUS BIT(0) + + #define TCPC_FAULT_STATUS 0x1f diff --git a/queue-5.16/usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch b/queue-5.16/usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch new file mode 100644 index 00000000000..ceda6a2cc43 --- /dev/null +++ b/queue-5.16/usb-typec-tcpm-do-not-disconnect-when-receiving-vsafe0v.patch @@ -0,0 +1,54 @@ +From 746f96e7d6f7a276726860f696671766bfb24cf0 Mon Sep 17 00:00:00 2001 +From: Badhri Jagan Sridharan +Date: Fri, 21 Jan 2022 17:55:20 -0800 +Subject: usb: typec: tcpm: Do not disconnect when receiving VSAFE0V + +From: Badhri Jagan Sridharan + +commit 746f96e7d6f7a276726860f696671766bfb24cf0 upstream. + +With some chargers, vbus might momentarily raise above VSAFE5V and fall +back to 0V causing VSAFE0V to be triggered. This will +will report a VBUS off event causing TCPM to transition to +SNK_UNATTACHED state where it should be waiting in either SNK_ATTACH_WAIT +or SNK_DEBOUNCED state. This patch makes TCPM avoid VSAFE0V events +while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state. + +Stub from the spec: + "4.5.2.2.4.2 Exiting from AttachWait.SNK State + A Sink shall transition to Unattached.SNK when the state of both + the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. + A DRP shall transition to Unattached.SRC when the state of both + the CC1 and CC2 pins is SNK.Open for at least tPDDebounce." + +[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] +[23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] +[23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] +[23.300579] VBUS off +[23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] +[23.301014] VBUS VSAFE0V +[23.301111] Start toggling + +Fixes: 28b43d3d746b8 ("usb: typec: tcpm: Introduce vsafe0v for vbus") +Cc: stable@vger.kernel.org +Acked-by: Heikki Krogerus +Signed-off-by: Badhri Jagan Sridharan +Link: https://lore.kernel.org/r/20220122015520.332507-2-badhri@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/tcpm/tcpm.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/usb/typec/tcpm/tcpm.c ++++ b/drivers/usb/typec/tcpm/tcpm.c +@@ -5264,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct + case PR_SWAP_SNK_SRC_SOURCE_ON: + /* Do nothing, vsafe0v is expected during transition */ + break; ++ case SNK_ATTACH_WAIT: ++ case SNK_DEBOUNCED: ++ /*Do nothing, still waiting for VSAFE5V for connect */ ++ break; + default: + if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled) + tcpm_set_state(port, SNK_UNATTACHED, 0); diff --git a/queue-5.16/usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch b/queue-5.16/usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch new file mode 100644 index 00000000000..0f5b95bc57a --- /dev/null +++ b/queue-5.16/usb-typec-tcpm-do-not-disconnect-while-receiving-vbus-off.patch @@ -0,0 +1,53 @@ +From 90b8aa9f5b09edae6928c0561f933fec9f7a9987 Mon Sep 17 00:00:00 2001 +From: Badhri Jagan Sridharan +Date: Fri, 21 Jan 2022 17:55:19 -0800 +Subject: usb: typec: tcpm: Do not disconnect while receiving VBUS off + +From: Badhri Jagan Sridharan + +commit 90b8aa9f5b09edae6928c0561f933fec9f7a9987 upstream. + +With some chargers, vbus might momentarily raise above VSAFE5V and fall +back to 0V before tcpm gets to read port->tcpc->get_vbus. This will +will report a VBUS off event causing TCPM to transition to +SNK_UNATTACHED where it should be waiting in either SNK_ATTACH_WAIT +or SNK_DEBOUNCED state. This patch makes TCPM avoid vbus off events +while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state. + +Stub from the spec: + "4.5.2.2.4.2 Exiting from AttachWait.SNK State + A Sink shall transition to Unattached.SNK when the state of both + the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. + A DRP shall transition to Unattached.SRC when the state of both + the CC1 and CC2 pins is SNK.Open for at least tPDDebounce." + +[23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] +[23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] +[23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] +[23.300579] VBUS off +[23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] +[23.301014] VBUS VSAFE0V +[23.301111] Start toggling + +Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)") +Cc: stable@vger.kernel.org +Acked-by: Heikki Krogerus +Signed-off-by: Badhri Jagan Sridharan +Link: https://lore.kernel.org/r/20220122015520.332507-1-badhri@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/tcpm/tcpm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/usb/typec/tcpm/tcpm.c ++++ b/drivers/usb/typec/tcpm/tcpm.c +@@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcp + case SNK_TRYWAIT_DEBOUNCE: + break; + case SNK_ATTACH_WAIT: +- tcpm_set_state(port, SNK_UNATTACHED, 0); ++ case SNK_DEBOUNCED: ++ /* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ + break; + + case SNK_NEGOTIATE_CAPABILITIES: diff --git a/queue-5.16/usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch b/queue-5.16/usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch new file mode 100644 index 00000000000..a2b0acb32ac --- /dev/null +++ b/queue-5.16/usb-xhci-plat-fix-crash-when-suspend-if-remote-wake-enable.patch @@ -0,0 +1,74 @@ +From 9df478463d9feb90dae24f183383961cf123a0ec Mon Sep 17 00:00:00 2001 +From: Frank Li +Date: Mon, 10 Jan 2022 11:27:38 -0600 +Subject: usb: xhci-plat: fix crash when suspend if remote wake enable + +From: Frank Li + +commit 9df478463d9feb90dae24f183383961cf123a0ec upstream. + +Crashed at i.mx8qm platform when suspend if enable remote wakeup + +Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP +Modules linked in: +CPU: 2 PID: 244 Comm: kworker/u12:6 Not tainted 5.15.5-dirty #12 +Hardware name: Freescale i.MX8QM MEK (DT) +Workqueue: events_unbound async_run_entry_fn +pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) +pc : xhci_disable_hub_port_wake.isra.62+0x60/0xf8 +lr : xhci_disable_hub_port_wake.isra.62+0x34/0xf8 +sp : ffff80001394bbf0 +x29: ffff80001394bbf0 x28: 0000000000000000 x27: ffff00081193b578 +x26: ffff00081193b570 x25: 0000000000000000 x24: 0000000000000000 +x23: ffff00081193a29c x22: 0000000000020001 x21: 0000000000000001 +x20: 0000000000000000 x19: ffff800014e90490 x18: 0000000000000000 +x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 +x14: 0000000000000000 x13: 0000000000000002 x12: 0000000000000000 +x11: 0000000000000000 x10: 0000000000000960 x9 : ffff80001394baa0 +x8 : ffff0008145d1780 x7 : ffff0008f95b8e80 x6 : 000000001853b453 +x5 : 0000000000000496 x4 : 0000000000000000 x3 : ffff00081193a29c +x2 : 0000000000000001 x1 : 0000000000000000 x0 : ffff000814591620 +Call trace: + xhci_disable_hub_port_wake.isra.62+0x60/0xf8 + xhci_suspend+0x58/0x510 + xhci_plat_suspend+0x50/0x78 + platform_pm_suspend+0x2c/0x78 + dpm_run_callback.isra.25+0x50/0xe8 + __device_suspend+0x108/0x3c0 + +The basic flow: + 1. run time suspend call xhci_suspend, xhci parent devices gate the clock. + 2. echo mem >/sys/power/state, system _device_suspend call xhci_suspend + 3. xhci_suspend call xhci_disable_hub_port_wake, which access register, + but clock already gated by run time suspend. + +This problem was hidden by power domain driver, which call run time resume before it. + +But the below commit remove it and make this issue happen. + commit c1df456d0f06e ("PM: domains: Don't runtime resume devices at genpd_prepare()") + +This patch call run time resume before suspend to make sure clock is on +before access register. + +Reviewed-by: Peter Chen +Cc: stable +Signed-off-by: Frank Li +Testeb-by: Abel Vesa +Link: https://lore.kernel.org/r/20220110172738.31686-1-Frank.Li@nxp.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/host/xhci-plat.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/usb/host/xhci-plat.c ++++ b/drivers/usb/host/xhci-plat.c +@@ -437,6 +437,9 @@ static int __maybe_unused xhci_plat_susp + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + ++ if (pm_runtime_suspended(dev)) ++ pm_runtime_resume(dev); ++ + ret = xhci_priv_suspend_quirk(hcd); + if (ret) + return ret; -- 2.47.2