thermal-drivers-intel-initialize-rw-trip-to-thermal_temp_invalid.patch
usb-dwc3-gadget-properly-track-pending-and-queued-sg.patch
usb-gadget-udc-renesas_usb3-fix-a-race-in-usb3_start_pipen.patch
+usb-typec-mux-fix-matching-with-typec_altmode_desc.patch
+usb-typec-ucsi-clear-pending-after-acking-connector-change.patch
+usb-typec-tcpm-use-le-to-cpu-conversion-when-accessing-msg-header.patch
+usb-typec-tcpm-properly-interrupt-vdm-ams.patch
+usb-typec-tcpm-respond-not_supported-if-no-snk_vdo.patch
--- /dev/null
+From acf5631c239dfc53489f739c4ad47f490c5181ff Mon Sep 17 00:00:00 2001
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+Date: Sat, 15 May 2021 20:47:30 -0700
+Subject: usb: typec: mux: Fix matching with typec_altmode_desc
+
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+
+commit acf5631c239dfc53489f739c4ad47f490c5181ff upstream.
+
+In typec_mux_match() "nval" is assigned the number of elements in the
+"svid" fwnode property, then the variable is used to store the success
+of the read and finally attempts to loop between 0 and "success" - i.e.
+not at all - and the code returns indicating that no match was found.
+
+Fix this by using a separate variable to track the success of the read,
+to allow the loop to get a change to find a match.
+
+Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
+Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Link: https://lore.kernel.org/r/20210516034730.621461-1-bjorn.andersson@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/typec/mux.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/drivers/usb/typec/mux.c
++++ b/drivers/usb/typec/mux.c
+@@ -191,6 +191,7 @@ static void *typec_mux_match(struct fwno
+ bool match;
+ int nval;
+ u16 *val;
++ int ret;
+ int i;
+
+ /*
+@@ -218,10 +219,10 @@ static void *typec_mux_match(struct fwno
+ if (!val)
+ return ERR_PTR(-ENOMEM);
+
+- nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
+- if (nval < 0) {
++ ret = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
++ if (ret < 0) {
+ kfree(val);
+- return ERR_PTR(nval);
++ return ERR_PTR(ret);
+ }
+
+ for (i = 0; i < nval; i++) {
--- /dev/null
+From 0bc3ee92880d910a1d100b73a781904f359e1f1c Mon Sep 17 00:00:00 2001
+From: Kyle Tso <kyletso@google.com>
+Date: Sun, 23 May 2021 09:58:54 +0800
+Subject: usb: typec: tcpm: Properly interrupt VDM AMS
+
+From: Kyle Tso <kyletso@google.com>
+
+commit 0bc3ee92880d910a1d100b73a781904f359e1f1c upstream.
+
+When a VDM AMS is interrupted by Messages other than VDM, the AMS needs
+to be finished properly. Also start a VDM AMS if receiving SVDM Commands
+from the port partner to complement the functionality of tcpm_vdm_ams().
+
+Fixes: 0908c5aca31e ("usb: typec: tcpm: AMS and Collision Avoidance")
+Cc: stable <stable@vger.kernel.org>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Signed-off-by: Kyle Tso <kyletso@google.com>
+Link: https://lore.kernel.org/r/20210523015855.1785484-2-kyletso@google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/typec/tcpm/tcpm.c | 30 ++++++++++++++++++++++++++++++
+ 1 file changed, 30 insertions(+)
+
+--- a/drivers/usb/typec/tcpm/tcpm.c
++++ b/drivers/usb/typec/tcpm/tcpm.c
+@@ -1534,6 +1534,8 @@ static int tcpm_pd_svdm(struct tcpm_port
+ if (PD_VDO_SVDM_VER(p[0]) < svdm_version)
+ typec_partner_set_svdm_version(port->partner,
+ PD_VDO_SVDM_VER(p[0]));
++
++ tcpm_ams_start(port, DISCOVER_IDENTITY);
+ /* 6.4.4.3.1: Only respond as UFP (device) */
+ if (port->data_role == TYPEC_DEVICE &&
+ port->nr_snk_vdo) {
+@@ -1552,14 +1554,19 @@ static int tcpm_pd_svdm(struct tcpm_port
+ }
+ break;
+ case CMD_DISCOVER_SVID:
++ tcpm_ams_start(port, DISCOVER_SVIDS);
+ break;
+ case CMD_DISCOVER_MODES:
++ tcpm_ams_start(port, DISCOVER_MODES);
+ break;
+ case CMD_ENTER_MODE:
++ tcpm_ams_start(port, DFP_TO_UFP_ENTER_MODE);
+ break;
+ case CMD_EXIT_MODE:
++ tcpm_ams_start(port, DFP_TO_UFP_EXIT_MODE);
+ break;
+ case CMD_ATTENTION:
++ tcpm_ams_start(port, ATTENTION);
+ /* Attention command does not have response */
+ *adev_action = ADEV_ATTENTION;
+ return 0;
+@@ -2267,6 +2274,12 @@ static void tcpm_pd_data_request(struct
+ bool frs_enable;
+ int ret;
+
++ if (tcpm_vdm_ams(port) && type != PD_DATA_VENDOR_DEF) {
++ port->vdm_state = VDM_STATE_ERR_BUSY;
++ tcpm_ams_finish(port);
++ mod_vdm_delayed_work(port, 0);
++ }
++
+ switch (type) {
+ case PD_DATA_SOURCE_CAP:
+ for (i = 0; i < cnt; i++)
+@@ -2439,6 +2452,16 @@ static void tcpm_pd_ctrl_request(struct
+ enum pd_ctrl_msg_type type = pd_header_type_le(msg->header);
+ enum tcpm_state next_state;
+
++ /*
++ * Stop VDM state machine if interrupted by other Messages while NOT_SUPP is allowed in
++ * VDM AMS if waiting for VDM responses and will be handled later.
++ */
++ if (tcpm_vdm_ams(port) && type != PD_CTRL_NOT_SUPP && type != PD_CTRL_GOOD_CRC) {
++ port->vdm_state = VDM_STATE_ERR_BUSY;
++ tcpm_ams_finish(port);
++ mod_vdm_delayed_work(port, 0);
++ }
++
+ switch (type) {
+ case PD_CTRL_GOOD_CRC:
+ case PD_CTRL_PING:
+@@ -2697,6 +2720,13 @@ static void tcpm_pd_ext_msg_request(stru
+ enum pd_ext_msg_type type = pd_header_type_le(msg->header);
+ unsigned int data_size = pd_ext_header_data_size_le(msg->ext_msg.header);
+
++ /* stopping VDM state machine if interrupted by other Messages */
++ if (tcpm_vdm_ams(port)) {
++ port->vdm_state = VDM_STATE_ERR_BUSY;
++ tcpm_ams_finish(port);
++ mod_vdm_delayed_work(port, 0);
++ }
++
+ if (!(le16_to_cpu(msg->ext_msg.header) & PD_EXT_HDR_CHUNKED)) {
+ tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
+ tcpm_log(port, "Unchunked extended messages unsupported");
--- /dev/null
+From a20dcf53ea9836387b229c4878f9559cf1b55b71 Mon Sep 17 00:00:00 2001
+From: Kyle Tso <kyletso@google.com>
+Date: Sun, 23 May 2021 09:58:55 +0800
+Subject: usb: typec: tcpm: Respond Not_Supported if no snk_vdo
+
+From: Kyle Tso <kyletso@google.com>
+
+commit a20dcf53ea9836387b229c4878f9559cf1b55b71 upstream.
+
+If snk_vdo is not populated from fwnode, it implies the port does not
+support responding to SVDM commands. Not_Supported Message shall be sent
+if the contract is in PD3. And for PD2, the port shall ignore the
+commands.
+
+Fixes: 193a68011fdc ("staging: typec: tcpm: Respond to Discover Identity commands")
+Cc: stable <stable@vger.kernel.org>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Signed-off-by: Kyle Tso <kyletso@google.com>
+Link: https://lore.kernel.org/r/20210523015855.1785484-3-kyletso@google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/typec/tcpm/tcpm.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/typec/tcpm/tcpm.c
++++ b/drivers/usb/typec/tcpm/tcpm.c
+@@ -2410,7 +2410,10 @@ static void tcpm_pd_data_request(struct
+ NONE_AMS);
+ break;
+ case PD_DATA_VENDOR_DEF:
+- tcpm_handle_vdm_request(port, msg->payload, cnt);
++ if (tcpm_vdm_ams(port) || port->nr_snk_vdo)
++ tcpm_handle_vdm_request(port, msg->payload, cnt);
++ else if (port->negotiated_rev > PD_REV20)
++ tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
+ break;
+ case PD_DATA_BIST:
+ port->bist_request = le32_to_cpu(msg->payload[0]);
--- /dev/null
+From c58bbe3477f75deb7883983e6cf428404a107555 Mon Sep 17 00:00:00 2001
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Date: Wed, 19 May 2021 13:03:58 +0300
+Subject: usb: typec: tcpm: Use LE to CPU conversion when accessing msg->header
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+commit c58bbe3477f75deb7883983e6cf428404a107555 upstream.
+
+Sparse is not happy about strict type handling:
+ .../typec/tcpm/tcpm.c:2720:27: warning: restricted __le16 degrades to integer
+ .../typec/tcpm/tcpm.c:2814:32: warning: restricted __le16 degrades to integer
+
+Fix this by converting LE to CPU before use.
+
+Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
+Fixes: 64f7c494a3c0 ("typec: tcpm: Add support for sink PPS related messages")
+Cc: stable <stable@vger.kernel.org>
+Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
+Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20210519100358.64018-1-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/typec/tcpm/tcpm.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/usb/typec/tcpm/tcpm.c
++++ b/drivers/usb/typec/tcpm/tcpm.c
+@@ -2697,7 +2697,7 @@ static void tcpm_pd_ext_msg_request(stru
+ enum pd_ext_msg_type type = pd_header_type_le(msg->header);
+ unsigned int data_size = pd_ext_header_data_size_le(msg->ext_msg.header);
+
+- if (!(msg->ext_msg.header & PD_EXT_HDR_CHUNKED)) {
++ if (!(le16_to_cpu(msg->ext_msg.header) & PD_EXT_HDR_CHUNKED)) {
+ tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
+ tcpm_log(port, "Unchunked extended messages unsupported");
+ return;
+@@ -2791,7 +2791,7 @@ static void tcpm_pd_rx_handler(struct kt
+ "Data role mismatch, initiating error recovery");
+ tcpm_set_state(port, ERROR_RECOVERY, 0);
+ } else {
+- if (msg->header & PD_HEADER_EXT_HDR)
++ if (le16_to_cpu(msg->header) & PD_HEADER_EXT_HDR)
+ tcpm_pd_ext_msg_request(port, msg);
+ else if (cnt)
+ tcpm_pd_data_request(port, msg);
--- /dev/null
+From 8c9b3caab3ac26db1da00b8117901640c55a69dd Mon Sep 17 00:00:00 2001
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+Date: Sat, 15 May 2021 21:09:53 -0700
+Subject: usb: typec: ucsi: Clear pending after acking connector change
+
+From: Bjorn Andersson <bjorn.andersson@linaro.org>
+
+commit 8c9b3caab3ac26db1da00b8117901640c55a69dd upstream.
+
+It's possible that the interrupt handler for the UCSI driver signals a
+connector changes after the handler clears the PENDING bit, but before
+it has sent the acknowledge request. The result is that the handler is
+invoked yet again, to ack the same connector change.
+
+At least some versions of the Qualcomm UCSI firmware will not handle the
+second - "spurious" - acknowledgment gracefully. So make sure to not
+clear the pending flag until the change is acknowledged.
+
+Any connector changes coming in after the acknowledgment, that would
+have the pending flag incorrectly cleared, would afaict be covered by
+the subsequent connector status check.
+
+Fixes: 217504a05532 ("usb: typec: ucsi: Work around PPM losing change information")
+Cc: stable <stable@vger.kernel.org>
+Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Acked-By: Benjamin Berg <bberg@redhat.com>
+Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
+Link: https://lore.kernel.org/r/20210516040953.622409-1-bjorn.andersson@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/typec/ucsi/ucsi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/usb/typec/ucsi/ucsi.c
++++ b/drivers/usb/typec/ucsi/ucsi.c
+@@ -717,8 +717,8 @@ static void ucsi_handle_connector_change
+ ucsi_send_command(con->ucsi, command, NULL, 0);
+
+ /* 3. ACK connector change */
+- clear_bit(EVENT_PENDING, &ucsi->flags);
+ ret = ucsi_acknowledge_connector_change(ucsi);
++ clear_bit(EVENT_PENDING, &ucsi->flags);
+ if (ret) {
+ dev_err(ucsi->dev, "%s: ACK failed (%d)", __func__, ret);
+ goto out_unlock;