diff options
author | Hans de Goede <hdegoede@redhat.com> | 2020-07-24 19:47:02 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-29 14:11:05 +0200 |
commit | 754498c1d6369d47b6433e9a05ba926255c2d699 (patch) | |
tree | 12a07c97a5165d62e191ab8f73d3ed3387762d4d /drivers/usb | |
parent | usb: typec: tcpm: Fix AB BA lock inversion between tcpm code and the alt-mode... (diff) | |
download | linux-754498c1d6369d47b6433e9a05ba926255c2d699.tar.xz linux-754498c1d6369d47b6433e9a05ba926255c2d699.zip |
usb: typec: tcpm: Add WARN_ON ensure we are not trying to send 2 VDM packets at the same time
The tcpm.c code for sending VDMs assumes that there will only be one VDM
in flight at the time. The "queue" used by tcpm_queue_vdm is only 1 entry
deep.
This assumes that the higher layers (tcpm state-machine and alt-mode
drivers) ensure that queuing a new VDM before the old one has been
completely send (or it timed out) add a WARN_ON to check for this.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200724174702.61754-6-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/typec/tcpm/tcpm.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 87ed5e2f79ca..3ef37202ee37 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -971,6 +971,9 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, { WARN_ON(!mutex_is_locked(&port->lock)); + /* Make sure we are not still processing a previous VDM packet */ + WARN_ON(port->vdm_state > VDM_STATE_DONE); + port->vdo_count = cnt + 1; port->vdo_data[0] = header; memcpy(&port->vdo_data[1], data, sizeof(u32) * cnt); |