usb: typec: tcpm: Fix for GKI

Fixes: b1302e6a83 ("usb: typec: tcpm: add pd handler lock")
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: Ic0709a80851490a8dca4c53a8e0fa50b18bf0a63
This commit is contained in:
Tao Huang
2022-03-14 19:53:43 +08:00
parent 463bcb6c7f
commit cf394eddf2

View File

@@ -360,7 +360,9 @@ struct tcpm_port {
unsigned long delay_ms;
spinlock_t pd_event_lock;
#ifdef CONFIG_NO_GKI
struct mutex pd_handler_lock;
#endif
u32 pd_events;
struct kthread_work event_work;
@@ -1464,16 +1466,18 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header,
static void tcpm_queue_vdm_unlocked(struct tcpm_port *port, const u32 header,
const u32 *data, int cnt)
{
#ifdef CONFIG_NO_GKI
mutex_lock(&port->pd_handler_lock);
if (tcpm_port_is_disconnected(port))
goto unlock;
#endif
mutex_lock(&port->lock);
tcpm_queue_vdm(port, header, data, cnt);
mutex_unlock(&port->lock);
#ifdef CONFIG_NO_GKI
unlock:
mutex_unlock(&port->pd_handler_lock);
#endif
}
static void svdm_consume_identity(struct tcpm_port *port, const u32 *p, int cnt)
@@ -5396,7 +5400,9 @@ static void tcpm_pd_event_handler(struct kthread_work *work)
event_work);
u32 events;
#ifdef CONFIG_NO_GKI
mutex_lock(&port->pd_handler_lock);
#endif
mutex_lock(&port->lock);
spin_lock(&port->pd_event_lock);
@@ -5459,7 +5465,9 @@ static void tcpm_pd_event_handler(struct kthread_work *work)
}
spin_unlock(&port->pd_event_lock);
mutex_unlock(&port->lock);
#ifdef CONFIG_NO_GKI
mutex_unlock(&port->pd_handler_lock);
#endif
}
void tcpm_cc_change(struct tcpm_port *port)
@@ -6467,7 +6475,9 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
mutex_init(&port->lock);
mutex_init(&port->swap_lock);
#ifdef CONFIG_NO_GKI
mutex_init(&port->pd_handler_lock);
#endif
port->wq = kthread_create_worker(0, dev_name(dev));
if (IS_ERR(port->wq))