mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-02 00:40:59 -05:00
usb: typec: ucsi: Fix role swapping
commit eb5d7ff3cf0d55093c619b5ad107cd5c05ce8134 upstream.
All attempts to swap the roles timed out because the
completion was done without releasing the port lock. Fixing
that by releasing the lock before starting to wait for the
completion.
Link: https://lore.kernel.org/linux-usb/[email protected]/
Fixes: ad74b8649b ("usb: typec: ucsi: Preliminary support for alternate modes")
Cc: [email protected]
Reported-and-tested-by: Jia-Ju Bai <[email protected]>
Signed-off-by: Heikki Krogerus <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
0366beb402
commit
324e67c3b2
1 changed files with 13 additions and 7 deletions
|
|
@ -748,14 +748,18 @@ ucsi_dr_swap(const struct typec_capability *cap, enum typec_data_role role)
|
|||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
mutex_unlock(&con->lock);
|
||||
|
||||
if (!wait_for_completion_timeout(&con->complete,
|
||||
msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
|
||||
ret = -ETIMEDOUT;
|
||||
msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
|
||||
return -ETIMEDOUT;
|
||||
|
||||
return 0;
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&con->lock);
|
||||
|
||||
return ret < 0 ? ret : 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -780,11 +784,13 @@ ucsi_pr_swap(const struct typec_capability *cap, enum typec_role role)
|
|||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
mutex_unlock(&con->lock);
|
||||
|
||||
if (!wait_for_completion_timeout(&con->complete,
|
||||
msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS))) {
|
||||
ret = -ETIMEDOUT;
|
||||
goto out_unlock;
|
||||
}
|
||||
msecs_to_jiffies(UCSI_SWAP_TIMEOUT_MS)))
|
||||
return -ETIMEDOUT;
|
||||
|
||||
mutex_lock(&con->lock);
|
||||
|
||||
/* Something has gone wrong while swapping the role */
|
||||
if (con->status.pwr_op_mode != UCSI_CONSTAT_PWR_OPMODE_PD) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue