Commit bc83240b authored by Christian A. Ehrhardt's avatar Christian A. Ehrhardt Committed by sanglipeng1
Browse files

usb: typec: ucsi: Check for notifications after init

stable inclusion
from stable-v5.10.217
commit 3b0b6b3276578170bc7b4f543b034810972dadfc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAWLXC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3b0b6b3276578170bc7b4f543b034810972dadfc



--------------------------------

commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 upstream.

The completion notification for the final SET_NOTIFICATION_ENABLE
command during initialization can include a connector change
notification.  However, at the time this completion notification is
processed, the ucsi struct is not ready to handle this notification.
As a result the notification is ignored and the controller
never sends an interrupt again.

Re-check CCI for a pending connector state change after
initialization is complete. Adjust the corresponding debug
message accordingly.

Fixes: 71a1fa0d ("usb: typec: ucsi: Store the notification mask")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Link: https://lore.kernel.org/r/20240320073927.1641788-3-lk@c--e.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent b251d32e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num)
	struct ucsi_connector *con = &ucsi->connector[num - 1];

	if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) {
		dev_dbg(ucsi->dev, "Bogus connector change event\n");
		dev_dbg(ucsi->dev, "Early connector change event\n");
		return;
	}

@@ -1204,6 +1204,7 @@ static int ucsi_init(struct ucsi *ucsi)
{
	struct ucsi_connector *con;
	u64 command, ntfy;
	u32 cci;
	int ret;
	int i;

@@ -1255,6 +1256,13 @@ static int ucsi_init(struct ucsi *ucsi)
		goto err_unregister;

	ucsi->ntfy = ntfy;

	ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
	if (ret)
		return ret;
	if (UCSI_CCI_CONNECTOR(READ_ONCE(cci)))
		ucsi_connector_change(ucsi, cci);

	return 0;

err_unregister: