From deccce01cd505726fbe8cbc06d39fc0440901e63 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 13 May 2024 15:10:05 +0200 Subject: [PATCH] 6.8-stable patches added patches: usb-typec-ucsi-check-for-notifications-after-init.patch usb-typec-ucsi-fix-connector-check-on-init.patch --- queue-6.8/series | 2 + ...i-check-for-notifications-after-init.patch | 64 +++++++++++++++++++ ...pec-ucsi-fix-connector-check-on-init.patch | 42 ++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 queue-6.8/usb-typec-ucsi-check-for-notifications-after-init.patch create mode 100644 queue-6.8/usb-typec-ucsi-fix-connector-check-on-init.patch diff --git a/queue-6.8/series b/queue-6.8/series index ebdfccc3b34..3841b6cd2d2 100644 --- a/queue-6.8/series +++ b/queue-6.8/series @@ -242,3 +242,5 @@ drm-amdgpu-fix-comparison-in-amdgpu_res_cpu_visible.patch drm-amdgpu-once-more-fix-the-call-oder-in-amdgpu_ttm_move-v2.patch firewire-nosy-ensure-user_length-is-taken-into-account-when-fetching-packet-contents.patch reapply-drm-qxl-simplify-qxl_fence_wait.patch +usb-typec-ucsi-check-for-notifications-after-init.patch +usb-typec-ucsi-fix-connector-check-on-init.patch diff --git a/queue-6.8/usb-typec-ucsi-check-for-notifications-after-init.patch b/queue-6.8/usb-typec-ucsi-check-for-notifications-after-init.patch new file mode 100644 index 00000000000..fe173afd8db --- /dev/null +++ b/queue-6.8/usb-typec-ucsi-check-for-notifications-after-init.patch @@ -0,0 +1,64 @@ +From 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 Mon Sep 17 00:00:00 2001 +From: "Christian A. Ehrhardt" +Date: Wed, 20 Mar 2024 08:39:23 +0100 +Subject: usb: typec: ucsi: Check for notifications after init + +From: Christian A. Ehrhardt + +commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 upstream. + +The completion notification for the final SET_NOTIFICATION_ENABLE +command during initialization can include a connector change +notification. However, at the time this completion notification is +processed, the ucsi struct is not ready to handle this notification. +As a result the notification is ignored and the controller +never sends an interrupt again. + +Re-check CCI for a pending connector state change after +initialization is complete. Adjust the corresponding debug +message accordingly. + +Fixes: 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") +Cc: stable@vger.kernel.org +Signed-off-by: Christian A. Ehrhardt +Reviewed-by: Heikki Krogerus +Tested-by: Neil Armstrong # on SM8550-QRD +Link: https://lore.kernel.org/r/20240320073927.1641788-3-lk@c--e.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/drivers/usb/typec/ucsi/ucsi.c ++++ b/drivers/usb/typec/ucsi/ucsi.c +@@ -975,7 +975,7 @@ void ucsi_connector_change(struct ucsi * + struct ucsi_connector *con = &ucsi->connector[num - 1]; + + if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) { +- dev_dbg(ucsi->dev, "Bogus connector change event\n"); ++ dev_dbg(ucsi->dev, "Early connector change event\n"); + return; + } + +@@ -1406,6 +1406,7 @@ static int ucsi_init(struct ucsi *ucsi) + { + struct ucsi_connector *con, *connector; + u64 command, ntfy; ++ u32 cci; + int ret; + int i; + +@@ -1458,6 +1459,13 @@ static int ucsi_init(struct ucsi *ucsi) + + ucsi->connector = connector; + ucsi->ntfy = ntfy; ++ ++ ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci)); ++ if (ret) ++ return ret; ++ if (UCSI_CCI_CONNECTOR(READ_ONCE(cci))) ++ ucsi_connector_change(ucsi, cci); ++ + return 0; + + err_unregister: diff --git a/queue-6.8/usb-typec-ucsi-fix-connector-check-on-init.patch b/queue-6.8/usb-typec-ucsi-fix-connector-check-on-init.patch new file mode 100644 index 00000000000..202880ceefb --- /dev/null +++ b/queue-6.8/usb-typec-ucsi-fix-connector-check-on-init.patch @@ -0,0 +1,42 @@ +From ce4c8d21054ae9396cd759fe6e8157b525616dc4 Mon Sep 17 00:00:00 2001 +From: "Christian A. Ehrhardt" +Date: Mon, 1 Apr 2024 23:05:15 +0200 +Subject: usb: typec: ucsi: Fix connector check on init + +From: Christian A. Ehrhardt + +commit ce4c8d21054ae9396cd759fe6e8157b525616dc4 upstream. + +Fix issues when initially checking for a connector change: +- Use the correct connector number not the entire CCI. +- Call ->read under the PPM lock. +- Remove a bogus READ_ONCE. + +Fixes: 808a8b9e0b87 ("usb: typec: ucsi: Check for notifications after init") +Cc: stable@kernel.org +Signed-off-by: Christian A. Ehrhardt +Reviewed-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20240401210515.1902048-1-lk@c--e.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/ucsi/ucsi.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/usb/typec/ucsi/ucsi.c ++++ b/drivers/usb/typec/ucsi/ucsi.c +@@ -1460,11 +1460,13 @@ static int ucsi_init(struct ucsi *ucsi) + ucsi->connector = connector; + ucsi->ntfy = ntfy; + ++ mutex_lock(&ucsi->ppm_lock); + ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci)); ++ mutex_unlock(&ucsi->ppm_lock); + if (ret) + return ret; +- if (UCSI_CCI_CONNECTOR(READ_ONCE(cci))) +- ucsi_connector_change(ucsi, cci); ++ if (UCSI_CCI_CONNECTOR(cci)) ++ ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci)); + + return 0; + -- 2.47.2