All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jameson Thies <jthies@google.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Benson Leung <bleung@chromium.org>,
	Andrei Kuchynski <akuchynski@chromium.org>,
	 Jameson Thies <jthies@google.com>
Subject: [PATCH v1] usb: typec: ucsi: Enable notifications before registering connectors
Date: Wed,  2 Dec 2026 22:06:49 +0000	[thread overview]
Message-ID: <20261202220649.4142702-1-jthies@google.com> (raw)

During ucsi_init(), the UCSI driver registers each connector and queries
its initial status before sending SET_NOTIFICATION_ENABLE to enable
connector change notifications. If a port's connection state changes
after its connector is registered but before notifications are enabled,
the PPM does not latch the connector change in CCI and the event is
lost, leaving the port in a stale state.

Move SET_NOTIFICATION_ENABLE before registering connectors so the PPM
latches any connector changes in CCI during port registration. Keep
ucsi->ntfy unset until all connectors are registered so early interrupts
are ignored without sending ACK_CONNECTOR_CHANGE, leaving the change
in CCI for the read_cci() check at the end of ucsi_init() to handle once
registration completes.

Signed-off-by: Jameson Thies <jthies@google.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 9e453d216c16..ced04c2b66bb 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -2126,6 +2126,13 @@ static int ucsi_init(struct ucsi *ucsi)
 	for (i = 0; i < ucsi->cap.num_connectors; i++)
 		lockdep_register_key(&connector[i].lock_key);
 
+	/* Enable all supported notifications */
+	ntfy = ucsi_get_supported_notifications(ucsi);
+	command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
+	ret = ucsi_send_command(ucsi, command, NULL, 0);
+	if (ret < 0)
+		goto err_unregister;
+
 	/* Register all connectors */
 	for (i = 0; i < ucsi->cap.num_connectors; i++) {
 		connector[i].num = i + 1;
@@ -2135,20 +2142,12 @@ static int ucsi_init(struct ucsi *ucsi)
 	}
 
 	/*
-	 * Set ucsi->connector before enabling notifications. A connector
-	 * change event can be handled as soon as the notifications are
-	 * enabled below, and ucsi_connector_change() indexes into
+	 * Set ucsi->connector before setting ucsi->ntfy. A connector
+	 * change event can be handled as soon as ucsi->ntfy is updated
+	 * below, and ucsi_connector_change() indexes into
 	 * ucsi->connector, so it must not be NULL at that point.
 	 */
 	ucsi->connector = connector;
-
-	/* Enable all supported notifications */
-	ntfy = ucsi_get_supported_notifications(ucsi);
-	command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
-	ret = ucsi_send_command(ucsi, command, NULL, 0);
-	if (ret < 0)
-		goto err_unregister;
-
 	ucsi->ntfy = ntfy;
 
 	mutex_lock(&ucsi->ppm_lock);

base-commit: 9357829ac604c28510b71b154cb6630af81226ff
-- 
2.56.1.911.g883d8bcb20-goog


                 reply	other threads:[~2026-12-02 22:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202220649.4142702-1-jthies@google.com \
    --to=jthies@google.com \
    --cc=akuchynski@chromium.org \
    --cc=bleung@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.