From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249217; b=x2QlkcL0TLqmFjRxY3d23IV1He01PB8IOkQ/5riDinzGrCQJdk+TCWOnWe9b+s9lXw3z BPaO9tgZ44uhtGMmcKRU/fWA3YRW61uX03iKtL4/OrpRzi9P17cnupukzvOD9m1IbmBbx yvA/rBYEgYRteDWP+edg0IfigQuHNNKg4amUOc85/14kFPA+JycYNnsiwbGd1H5b5nR/S ZS1WfeBTsZsQvlAj3mtSTuxzvjlW3fTZ42vXnw1lYTaY5u0D4Kvhr9Wb9laFwcqjw4Z82 EBr/5TtPTc5GCpEhsu4xjWVRNfOPI0ufmzcv8WpcxJtviviL5v+OMDCaqJWUNAzk3zg== 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-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=7/X4UY650YyXsY8x2SZiNDElY509v5hkMmWsqeZwDWQ=; b=OiD15knPWtNiPkMmSiYKqp3AkMe1FpNZ+pfRn45t6MIVnmsbamjSoOo6X1lQYtT9FsC2 a/U43kmvDsz66rwCLRZ2TS4U6u+q4QO1RuttiGDETVAfo3W89hOFv6wva4z8CQgO8gEYL zCh2JI12rlgJZxd889GXYuQR7FRIGhEGjiNxzuK9LPF2Vy7IbLx0KodkHeI/4E3VRRJ0q yHmEZaAcxvbqwOacuh8/2aJMvrzd6p3K8vwqK4EMC9hdHIWO4u1DGVanAhohipQdyTVVB dORIxT1PKbN5A8AAfGseKV9lf8HoKCzhG+90pmMXtmlJLHbvlT4SY5TdC4v7WNBvvLQ== 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.199 Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) (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 C94EA606A322 for ; Wed, 2 Dec 2026 22:06:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C94EA606A322 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-f199.google.com with SMTP id 5a478bee46e88-3846d5f54c1so14894446eec.1 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=D6ac19kGwhhK6rswmtVwynDgjet4A25bi+cFPp8ZxEaUracTd5asm5GJAPH9ofKHbl pV4MCvHhDNWFFB0kPqT8dMnj8WDbEzoUQTvXt4kaVUV9TSUo2MSsiLM3vUachJ95hPlh Zn680JE50AxL0FKS0nu3Bscs7EV4uOYT2ufKodO+BRdtpYVJNNo1hOHy4r+pKGyDVlrT RZntR2LtBFj4asFcd1p58fhEmOHXN1VMjYDBKV3TrTAtX3GQ99s7Jvn7up3T+0iWZOjD nbNoxlNnTmhz/UdcyA7w0n+bKs/36lHrjW+goOLzy8UTO91syCNn5aZk4fY72cEDr+fO M3NA== X-Forwarded-Encrypted: i=1; AL+hErHtAbtYXf5oZAbdFDvC+x13Fd25dSKkiMZT0g/pMda05x3nfeLSkZDXShlFqFoFy7EaFhz6WkY5Ea76GYE=@vger.kernel.org X-Gm-Message-State: APuU4Z8pMzboI0PokKcNd1u6Pt4G9IPeEBySkTt33MwIpMh/w1HVLI7B 30KEUQP/211fQAnmghymMojalxXUhRDhldDMbVb9b/CJAxUelxbIzxH2nwzMugzjlDbNb08yAw0 aDmGZMw== 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-kernel@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