From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249939; b=hIbftbAZFjmRa1IYIhsxXmUsRn+mKR7uha4dtwwB3l4zJgtmdtI/JGdoD42+3WW9VqWa gri/ig6/sOoiYBricWBUIkUMg3eShJ/HcRs2rF2HSMmXIil9kdpK4JRT0uWegOSNzrrM/ 5ia3izweQ7KHApzA4cJnFeFQhlhKIYdgHk/Bie4c++xHjKGIIB48S4iz9At6K8OLHT3fN lqDME6lgycFAEPrj5MeKAR40WN/hj62ngBWZXS38NYjWl3gbkAxxhJWlVe8AuDwgiMQg9 Z+4lKd/pJp40hgmtKAO59tMLJQnBPtX+5n5CvHmKe+EIteUtju3CpnFa3lvba95q5RQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249939; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=DTX6Io5p5+nWkMixolTdnU0e0FIFU/zr/TB55VfOX9M=; b=GWnQDXhctQkDN6el/30p+dGtYz/s+6OvareUzOLr33DEkVxx2une1U9pF7oQPZI7rxrN AoYjyua+ejT6H2tgtmSV4ekN/gCAUub9BJt9eJmTOaEEkT+Ffw49qK72NW7jRdUJBTudk hJr74z9fhFz+X9jLf/ffoFgZEDS9PEopEx7kJWl7awd2qm1eXH6okLOZMidYILrTMRfZk lIKmWtE30diF8kXm0n5P/lIqcrbMp/aPspcEW+Z2fAjEAP3sXExEyvKKxH/sve1deQ1OJ UyNL1S+/0Bb5Wuj87x0DxQ/4EvGri38uHcS5Criv/qUBJpYV4AIUN7puLJua0Vk7+MA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lXwCNUFr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2B12606A322 for ; Wed, 2 Dec 2026 22:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lXwCNUFr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F85F1F00896; Wed, 2 Dec 2026 22:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796249938; bh=DTX6Io5p5+nWkMixolTdnU0e0FIFU/zr/TB55VfOX9M=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lXwCNUFrsnW7fFfWq2vkSMKkoHtOqpajiWHOYcrMT5hkBRrwhs2ndwI8QfiWy5vP2 VTt7t7VfHPOfQylyXdUlRddgR/gFe+AQtZxyrVo/qs4FI6iqj+eGFkRWZQbRDwIrAT 8S0AtxiJnjs38Cs9rfRKAgODTpE5Ph0NiI9R2nKxeQQjlgr1KmelfktjrhQvyEDR6e 6r1FzMb4mxTtRSqdz8/kUze1T/1nQTnl2ACvcGMgyjl8ynp0iI7SEIScpCd9iKbqQN XgnqriKaIJ6p799oKulRk6PgyqLy/+i+Np+S3PzcWITis7n2fJTM1dVCyfjLcJet77 yvLqdMTnk97gw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v1] usb: typec: ucsi: Enable notifications before registering connectors Reply-To: sashiko-reviews@lists.linux.dev To: "Jameson Thies" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261202220649.4142702-1-jthies@google.com> References: <20261202220649.4142702-1-jthies@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 22:18:56 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] usb: typec: ucsi: unordered stores to connector and ntfy in ucsi_init() - [Low] usb: typec: ucsi: missing Fixes trailer for ucsi_init() notification race -- commit fb6ff5dde5812aba57fdefe58a43defbff6be873 Author: Jameson Thies > usb: typec: ucsi: Enable notifications before registering connectors > > 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 [Severity: Low] Should this bug fix include a Fixes: tag for the commit that introduced the ucsi_init() registration sequence: Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface") > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c > index 9e453d216c169..ced04c2b66bbf 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 =3D 0; i < ucsi->cap.num_connectors; i++) > lockdep_register_key(&connector[i].lock_key); > =20 > + /* Enable all supported notifications */ > + ntfy =3D ucsi_get_supported_notifications(ucsi); > + command =3D UCSI_SET_NOTIFICATION_ENABLE | ntfy; > + ret =3D ucsi_send_command(ucsi, command, NULL, 0); > + if (ret < 0) > + goto err_unregister; > + > /* Register all connectors */ > for (i =3D 0; i < ucsi->cap.num_connectors; i++) { > connector[i].num =3D i + 1; > @@ -2135,20 +2142,12 @@ static int ucsi_init(struct ucsi *ucsi) > } > =20 > /* > - * 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 =3D connector; > - > - /* Enable all supported notifications */ > - ntfy =3D ucsi_get_supported_notifications(ucsi); > - command =3D UCSI_SET_NOTIFICATION_ENABLE | ntfy; > - ret =3D ucsi_send_command(ucsi, command, NULL, 0); > - if (ret < 0) > - goto err_unregister; > - > ucsi->ntfy =3D ntfy; [Severity: Medium] Can ucsi_connector_change() observe ucsi->ntfy with UCSI_ENABLE_NTFY_CONNECTOR_CHANGE set while ucsi->connector is still NULL? Previously, ucsi_send_command() separated the store to ucsi->connector from the store to ucsi->ntfy and only enabled notifications in the PPM after ucsi->connector was set. With notifications now enabled in the PPM before the registration loop, a connector change interrupt can arrive on another CPU while ucsi_init() writes ucsi->connector and ucsi->ntfy: CPU0 CPU1 ucsi_init() ucsi_connector_change() ucsi->connector =3D connector; ucsi->ntfy =3D ntfy; if (!(ucsi->ntfy & ...)) con =3D &ucsi->connector[num - 1]; schedule_work(&con->work); <-- NULL pointer dereference Because neither side holds a common lock or uses memory barriers, the stores to ucsi->connector and ucsi->ntfy and the corresponding loads in ucsi_connector_change() can be reordered on weakly-ordered architectures. Pairing smp_store_release(&ucsi->ntfy, ntfy) here with smp_load_acquire(&ucsi->ntfy) in ucsi_connector_change() would enforce the ordering described in the comment. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202220649.4142= 702-1-jthies@google.com?part=3D1