]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.1/usb-typec-ucsi-check-for-notifications-after-init.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-6.1 / usb-typec-ucsi-check-for-notifications-after-init.patch
1 From ca61215561a0947476576f8ee06c0dca69b25884 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 20 Mar 2024 08:39:23 +0100
4 Subject: usb: typec: ucsi: Check for notifications after init
5
6 From: Christian A. Ehrhardt <lk@c--e.de>
7
8 [ Upstream commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 ]
9
10 The completion notification for the final SET_NOTIFICATION_ENABLE
11 command during initialization can include a connector change
12 notification. However, at the time this completion notification is
13 processed, the ucsi struct is not ready to handle this notification.
14 As a result the notification is ignored and the controller
15 never sends an interrupt again.
16
17 Re-check CCI for a pending connector state change after
18 initialization is complete. Adjust the corresponding debug
19 message accordingly.
20
21 Fixes: 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask")
22 Cc: stable@vger.kernel.org
23 Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
24 Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
25 Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
26 Link: https://lore.kernel.org/r/20240320073927.1641788-3-lk@c--e.de
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 Signed-off-by: Sasha Levin <sashal@kernel.org>
29 ---
30 drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++-
31 1 file changed, 9 insertions(+), 1 deletion(-)
32
33 diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
34 index 98f335cbbcdea..1fd4aaf348047 100644
35 --- a/drivers/usb/typec/ucsi/ucsi.c
36 +++ b/drivers/usb/typec/ucsi/ucsi.c
37 @@ -855,7 +855,7 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num)
38 struct ucsi_connector *con = &ucsi->connector[num - 1];
39
40 if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) {
41 - dev_dbg(ucsi->dev, "Bogus connector change event\n");
42 + dev_dbg(ucsi->dev, "Early connector change event\n");
43 return;
44 }
45
46 @@ -1248,6 +1248,7 @@ static int ucsi_init(struct ucsi *ucsi)
47 {
48 struct ucsi_connector *con, *connector;
49 u64 command, ntfy;
50 + u32 cci;
51 int ret;
52 int i;
53
54 @@ -1300,6 +1301,13 @@ static int ucsi_init(struct ucsi *ucsi)
55
56 ucsi->connector = connector;
57 ucsi->ntfy = ntfy;
58 +
59 + ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
60 + if (ret)
61 + return ret;
62 + if (UCSI_CCI_CONNECTOR(READ_ONCE(cci)))
63 + ucsi_connector_change(ucsi, cci);
64 +
65 return 0;
66
67 err_unregister:
68 --
69 2.43.0
70