1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

usb: typec: ucsi: Store the notification mask

The driver needs to ignore any Connector Change Events
before the Connector Change Indication notifications have
actually been enabled. This adds a check to
ucsi_connector_change() function to make sure the function
does not try to process the event unless the Connector
Change notifications have been enabled.

It is quite common that the firmware representing the "PPM"
(Platform Policy Manager) starts generating Connector Change
notifications even when only the Command Completion
notifications are enabled.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20191230133431.63445-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Heikki Krogerus 2019-12-30 16:34:30 +03:00 committed by Greg Kroah-Hartman
parent 5311f88e07
commit 71a1fa0df2
2 changed files with 13 additions and 5 deletions

View file

@ -189,7 +189,7 @@ int ucsi_resume(struct ucsi *ucsi)
u64 command; u64 command;
/* Restore UCSI notification enable mask after system resume */ /* Restore UCSI notification enable mask after system resume */
command = UCSI_SET_NOTIFICATION_ENABLE | UCSI_ENABLE_NTFY_ALL; command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
return ucsi_send_command(ucsi, command, NULL, 0); return ucsi_send_command(ucsi, command, NULL, 0);
} }
@ -589,6 +589,11 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num)
{ {
struct ucsi_connector *con = &ucsi->connector[num - 1]; struct ucsi_connector *con = &ucsi->connector[num - 1];
if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) {
dev_dbg(ucsi->dev, "Bogus connetor change event\n");
return;
}
if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags)) if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags))
schedule_work(&con->work); schedule_work(&con->work);
} }
@ -656,7 +661,7 @@ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
ucsi_reset_ppm(con->ucsi); ucsi_reset_ppm(con->ucsi);
mutex_unlock(&con->ucsi->ppm_lock); mutex_unlock(&con->ucsi->ppm_lock);
c = UCSI_SET_NOTIFICATION_ENABLE | UCSI_ENABLE_NTFY_ALL; c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;
ucsi_send_command(con->ucsi, c, NULL, 0); ucsi_send_command(con->ucsi, c, NULL, 0);
ucsi_reset_connector(con, true); ucsi_reset_connector(con, true);
@ -890,8 +895,8 @@ int ucsi_init(struct ucsi *ucsi)
} }
/* Enable basic notifications */ /* Enable basic notifications */
command = UCSI_SET_NOTIFICATION_ENABLE; ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;
command |= UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR; command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
ret = ucsi_run_command(ucsi, command, NULL, 0); ret = ucsi_run_command(ucsi, command, NULL, 0);
if (ret < 0) if (ret < 0)
goto err_reset; goto err_reset;
@ -923,7 +928,7 @@ int ucsi_init(struct ucsi *ucsi)
} }
/* Enable all notifications */ /* Enable all notifications */
command = UCSI_SET_NOTIFICATION_ENABLE | UCSI_ENABLE_NTFY_ALL; command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
ret = ucsi_run_command(ucsi, command, NULL, 0); ret = ucsi_run_command(ucsi, command, NULL, 0);
if (ret < 0) if (ret < 0)
goto err_unregister; goto err_unregister;

View file

@ -269,6 +269,9 @@ struct ucsi {
/* PPM Communication lock */ /* PPM Communication lock */
struct mutex ppm_lock; struct mutex ppm_lock;
/* The latest "Notification Enable" bits (SET_NOTIFICATION_ENABLE) */
u64 ntfy;
/* PPM communication flags */ /* PPM communication flags */
unsigned long flags; unsigned long flags;
#define EVENT_PENDING 0 #define EVENT_PENDING 0