From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249217; b=USJ9D7K43kUe6F8c0K1WGfWfgoNwR617z++31PtDrxJwHrMKs5i4kR35LQQHfozn9U5e 05pzMgWSTmiZ9CrCj2poMtVYgMQM1+xk12ZigK/UcGUSZk6Q6ltlRacxA+YTVPzX8dh5R 8/cszGQ1z+bqvH3byv1KO5Tjlv+LVLjKfQwjNFMOLcaFGN23XH7PcJLxWe76J4QE5yeVc NGjz8RFP/cmkgr7pKPYykQ7HPfdHbGi2MX4fa9hfHnMvz5gUZPgz83l8o+hLkp0mm92ou 22tD3LARSh7Afcl+1w9z3+wE4LP1G1vjrPREhC2+M/ORr9URp1HIaFK0z/x/19j/h7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249217; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:Mime-Version:X-Mailer:Message-ID: Subject:From:To:Cc:Content-Type; bh=7/X4UY650YyXsY8x2SZiNDElY509v5hkMmWsqeZwDWQ=; b=hxt9hf+WIuZuOD4JWOg+1f1JqO2L6sSVFJ++IS5ua8Za8wn0JBQ1q9gWrwVdxK91ssZO tjEySprK60/Lafc3cAQT4iN/hxpzMy0ldPlrVexbUjjcjtk2L188ydqgV3BwvtX0aTxSH QFflQskVJP2+L9o8QgAF42XylzwT3j2X9IoGRQDVsYkmD/O8dIuO8PGdUnR+BU3DxJ9IM rsP3H6WGbqM1g4nW5FQWq1wQLlnoOitaTp2iowWDs4DUN7PypVWz6c9UmfpyfBVemlu35 XPeHC8fHDOg8XsIc7bidhiXpEfcDCQgooy8/NeCYXuvy7qktSzExg+jkiQNXnq33ioQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iw9dkvdg; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC164606A32C for ; Wed, 2 Dec 2026 22:06:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC164606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iw9dkvdg Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-384c78aa0dbso16634697eec.0 for ; Wed, 02 Dec 2026 14:06:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796249216; x=1796854016; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7/X4UY650YyXsY8x2SZiNDElY509v5hkMmWsqeZwDWQ=; b=iw9dkvdghepKp3iZVa2RyIbHjpVFCfB5SbQ4dYi8ycYfzIqGyVLyc9SY0AZsch+/KO g7cINRvkLCSg3EnKW6wYSLatdLvgkvfWvNV/m9pCobxzVi0bKTnR+S6P4zfBg9NqylvN Hge6vn5Z6OqKTZoeLdP3/fTdgwUX3hNpHDwBVfGd+FMU6j0Z3TcmWgSoAV+50CzOGbYS iQWmf9TtySuRMgzfP93dMhEb/6up4hCMfQ7FuDqbthuww3XbmSRczyZIpHUo7iHhi5QH 8BhoYiINFz3CYyW5UH7VdH2Os/S1PvN1/9KMqHToTdwbBFHdMIGV8VoQCLOq1bZsxEfG lEiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796249216; x=1796854016; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7/X4UY650YyXsY8x2SZiNDElY509v5hkMmWsqeZwDWQ=; b=0wO/0ptdPJWQKqiLeAcrwv+N6NYkEW4M/UpBci5euL62B6Xsbnvy19cqliNWkiTCX0 BH71yDA0H+6S865u1FUIWxwMfD/7Zq+13xEsAN8WwHQ5Pkl8cuKqDptduPyZO9/J3RQD hbbZjW5S3NTzlDfapohCLNX5itrp9fCpe2/VyVdgtVFo8tBHEeZgKZdcQq6Q/+eyyV6m xwhEBEJLOMB9+k2tbDp7UsLrytbQtsikG95z1nfMHyVz52fnA3LE7rBcdUxvM3hPm+F4 AufZDAfODci4mBqIe3mIRtnL8a0qNAqbV3D481VYZu9bnN+bfC4atlE4fc8LwHEvFu2G vj9A== X-Gm-Message-State: APuU4Z86+WYgoi3c9CA5MbsVYCInW7wE+/bq2zLOJyPJHpmp/b2NRvDF WhI7ALO/0WidGefthFb3lo0O8SMZ8ZCTGiC+onlXkGcu8rANQprenIsYKmdwdpXhVq6dko9Tv7k qj5IEug== X-Received: from dybla7.prod.google.com ([2002:a05:7301:1a87:b0:381:610e:404b]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:60d7:b0:386:a01f:a31e with SMTP id 5a478bee46e88-386a01fa8a5mr40499320eec.29.1796249215343; Wed, 02 Dec 2026 14:06:55 -0800 (PST) Date: Wed, 2 Dec 2026 22:06:49 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202220649.4142702-1-jthies@google.com> Subject: [PATCH v1] usb: typec: ucsi: Enable notifications before registering connectors From: Jameson Thies To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Benson Leung , Andrei Kuchynski , Jameson Thies Content-Type: text/plain; charset="UTF-8" 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 --- 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