From 9d636b6b880214fa676ab4558ea64777ae583787 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Apr 19 2024 16:28:37 +0000 Subject: usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset (stable-fixes). --- diff --git a/patches.suse/usb-typec-ucsi-Clear-UCSI_CCI_RESET_COMPLETE-before-.patch b/patches.suse/usb-typec-ucsi-Clear-UCSI_CCI_RESET_COMPLETE-before-.patch new file mode 100644 index 0000000..1088b2a --- /dev/null +++ b/patches.suse/usb-typec-ucsi-Clear-UCSI_CCI_RESET_COMPLETE-before-.patch @@ -0,0 +1,80 @@ +From 3de4f996a0b5412aa451729008130a488f71563e Mon Sep 17 00:00:00 2001 +From: "Christian A. Ehrhardt" +Date: Wed, 20 Mar 2024 08:39:26 +0100 +Subject: [PATCH] usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset +Git-commit: 3de4f996a0b5412aa451729008130a488f71563e +Patch-mainline: v6.9-rc2 +References: stable-fixes + +Check the UCSI_CCI_RESET_COMPLETE complete flag before starting +another reset. Use a UCSI_SET_NOTIFICATION_ENABLE command to clear +the flag if it is set. + +Signed-off-by: Christian A. Ehrhardt +Cc: stable +Reviewed-by: Heikki Krogerus +Tested-by: Neil Armstrong # on SM8550-QRD +Link: https://lore.kernel.org/r/20240320073927.1641788-6-lk@c--e.de +Signed-off-by: Greg Kroah-Hartman +Acked-by: Takashi Iwai + +--- + drivers/usb/typec/ucsi/ucsi.c | 36 ++++++++++++++++++++++++++++++++++- + 1 file changed, 35 insertions(+), 1 deletion(-) + +diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c +index 63f340dbd867..85e507df7fa8 100644 +--- a/drivers/usb/typec/ucsi/ucsi.c ++++ b/drivers/usb/typec/ucsi/ucsi.c +@@ -1264,13 +1264,47 @@ static int ucsi_reset_connector(struct ucsi_connector *con, bool hard) + + static int ucsi_reset_ppm(struct ucsi *ucsi) + { +- u64 command = UCSI_PPM_RESET; ++ u64 command; + unsigned long tmo; + u32 cci; + int ret; + + mutex_lock(&ucsi->ppm_lock); + ++ ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci)); ++ if (ret < 0) ++ goto out; ++ ++ /* ++ * If UCSI_CCI_RESET_COMPLETE is already set we must clear ++ * the flag before we start another reset. Send a ++ * UCSI_SET_NOTIFICATION_ENABLE command to achieve this. ++ * Ignore a timeout and try the reset anyway if this fails. ++ */ ++ if (cci & UCSI_CCI_RESET_COMPLETE) { ++ command = UCSI_SET_NOTIFICATION_ENABLE; ++ ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command, ++ sizeof(command)); ++ if (ret < 0) ++ goto out; ++ ++ tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS); ++ do { ++ ret = ucsi->ops->read(ucsi, UCSI_CCI, ++ &cci, sizeof(cci)); ++ if (ret < 0) ++ goto out; ++ if (cci & UCSI_CCI_COMMAND_COMPLETE) ++ break; ++ if (time_is_before_jiffies(tmo)) ++ break; ++ msleep(20); ++ } while (1); ++ ++ WARN_ON(cci & UCSI_CCI_RESET_COMPLETE); ++ } ++ ++ command = UCSI_PPM_RESET; + ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command, + sizeof(command)); + if (ret < 0) +-- +2.43.0 + diff --git a/series.conf b/series.conf index 6a54e56..c817607 100644 --- a/series.conf +++ b/series.conf @@ -46236,6 +46236,7 @@ patches.suse/usb-typec-ucsi-Clear-EVENT_PENDING-under-PPM-lock.patch patches.suse/usb-typec-ucsi-Check-for-notifications-after-init.patch patches.suse/usb-typec-ucsi-Ack-unsupported-commands.patch + patches.suse/usb-typec-ucsi-Clear-UCSI_CCI_RESET_COMPLETE-before-.patch patches.suse/scsi-lpfc-Correct-size-for-wqe-for-memset.patch patches.suse/scsi-lpfc-Correct-size-for-cmdwqe-rspwqe-for-memset.patch patches.suse/scsi-qla2xxx-Prevent-command-send-on-chip-reset.patch