From: Greg Kroah-Hartman Date: Sun, 30 May 2021 11:20:04 +0000 (+0200) Subject: 5.12-stable patches X-Git-Tag: v4.4.271~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9270215f51f4333bff86dbced64fc64c474ecc1a;p=thirdparty%2Fkernel%2Fstable-queue.git 5.12-stable patches added patches: usb-typec-mux-fix-matching-with-typec_altmode_desc.patch usb-typec-tcpm-properly-interrupt-vdm-ams.patch usb-typec-tcpm-respond-not_supported-if-no-snk_vdo.patch usb-typec-tcpm-use-le-to-cpu-conversion-when-accessing-msg-header.patch usb-typec-ucsi-clear-pending-after-acking-connector-change.patch --- diff --git a/queue-5.12/series b/queue-5.12/series index 9adec8bf8fd..1a5cd724c64 100644 --- a/queue-5.12/series +++ b/queue-5.12/series @@ -103,3 +103,8 @@ usb-serial-pl2303-add-device-id-for-adlink-nd-6530-gc.patch 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 diff --git a/queue-5.12/usb-typec-mux-fix-matching-with-typec_altmode_desc.patch b/queue-5.12/usb-typec-mux-fix-matching-with-typec_altmode_desc.patch new file mode 100644 index 00000000000..9fc55148afa --- /dev/null +++ b/queue-5.12/usb-typec-mux-fix-matching-with-typec_altmode_desc.patch @@ -0,0 +1,51 @@ +From acf5631c239dfc53489f739c4ad47f490c5181ff Mon Sep 17 00:00:00 2001 +From: Bjorn Andersson +Date: Sat, 15 May 2021 20:47:30 -0700 +Subject: usb: typec: mux: Fix matching with typec_altmode_desc + +From: Bjorn Andersson + +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 +Cc: stable +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210516034730.621461-1-bjorn.andersson@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + 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++) { diff --git a/queue-5.12/usb-typec-tcpm-properly-interrupt-vdm-ams.patch b/queue-5.12/usb-typec-tcpm-properly-interrupt-vdm-ams.patch new file mode 100644 index 00000000000..31b523ddb1d --- /dev/null +++ b/queue-5.12/usb-typec-tcpm-properly-interrupt-vdm-ams.patch @@ -0,0 +1,99 @@ +From 0bc3ee92880d910a1d100b73a781904f359e1f1c Mon Sep 17 00:00:00 2001 +From: Kyle Tso +Date: Sun, 23 May 2021 09:58:54 +0800 +Subject: usb: typec: tcpm: Properly interrupt VDM AMS + +From: Kyle Tso + +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 +Reviewed-by: Guenter Roeck +Acked-by: Heikki Krogerus +Signed-off-by: Kyle Tso +Link: https://lore.kernel.org/r/20210523015855.1785484-2-kyletso@google.com +Signed-off-by: Greg Kroah-Hartman +--- + 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"); diff --git a/queue-5.12/usb-typec-tcpm-respond-not_supported-if-no-snk_vdo.patch b/queue-5.12/usb-typec-tcpm-respond-not_supported-if-no-snk_vdo.patch new file mode 100644 index 00000000000..737515866b3 --- /dev/null +++ b/queue-5.12/usb-typec-tcpm-respond-not_supported-if-no-snk_vdo.patch @@ -0,0 +1,39 @@ +From a20dcf53ea9836387b229c4878f9559cf1b55b71 Mon Sep 17 00:00:00 2001 +From: Kyle Tso +Date: Sun, 23 May 2021 09:58:55 +0800 +Subject: usb: typec: tcpm: Respond Not_Supported if no snk_vdo + +From: Kyle Tso + +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 +Reviewed-by: Guenter Roeck +Acked-by: Heikki Krogerus +Signed-off-by: Kyle Tso +Link: https://lore.kernel.org/r/20210523015855.1785484-3-kyletso@google.com +Signed-off-by: Greg Kroah-Hartman +--- + 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]); diff --git a/queue-5.12/usb-typec-tcpm-use-le-to-cpu-conversion-when-accessing-msg-header.patch b/queue-5.12/usb-typec-tcpm-use-le-to-cpu-conversion-when-accessing-msg-header.patch new file mode 100644 index 00000000000..f3a079bb106 --- /dev/null +++ b/queue-5.12/usb-typec-tcpm-use-le-to-cpu-conversion-when-accessing-msg-header.patch @@ -0,0 +1,49 @@ +From c58bbe3477f75deb7883983e6cf428404a107555 Mon Sep 17 00:00:00 2001 +From: Andy Shevchenko +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 + +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 +Cc: Adam Thomson +Reviewed-by: Guenter Roeck +Reviewed-by: Adam Thomson +Reviewed-by: Heikki Krogerus +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20210519100358.64018-1-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + 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); diff --git a/queue-5.12/usb-typec-ucsi-clear-pending-after-acking-connector-change.patch b/queue-5.12/usb-typec-ucsi-clear-pending-after-acking-connector-change.patch new file mode 100644 index 00000000000..8fc142cf09d --- /dev/null +++ b/queue-5.12/usb-typec-ucsi-clear-pending-after-acking-connector-change.patch @@ -0,0 +1,46 @@ +From 8c9b3caab3ac26db1da00b8117901640c55a69dd Mon Sep 17 00:00:00 2001 +From: Bjorn Andersson +Date: Sat, 15 May 2021 21:09:53 -0700 +Subject: usb: typec: ucsi: Clear pending after acking connector change + +From: Bjorn Andersson + +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 +Reviewed-by: Heikki Krogerus +Acked-By: Benjamin Berg +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210516040953.622409-1-bjorn.andersson@linaro.org +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Greg Kroah-Hartman +--- + 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;