From 6b3091381b8d4d7c49c0871cd623a3268e68791f Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Wed, 24 May 2017 12:25:15 -0700 Subject: [PATCH] usb: pd: policy_engine: Disable vconn first upon disconnect Currently vconn is getting disabled late after disabling vbus. This is causing failure if type-C compliance TD.4.8.3(DRP Connect Alternate Mode), as delay is disabling vconn goes above 35ms. Fix the issue by moving vconn disable as first step upon receiving disconnect notification. Also, making policy engine workqueue as high priority workqueue to be able to run state machine work with lower latency. Change-Id: If9a979b4cc5bab3aa2ebf42397c36e5b434b50b9 Signed-off-by: Hemant Kumar --- drivers/usb/pd/policy_engine.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c index 055c6203577a..bd21d9b64bfa 100644 --- a/drivers/usb/pd/policy_engine.c +++ b/drivers/usb/pd/policy_engine.c @@ -1539,6 +1539,11 @@ static void usbpd_sm(struct work_struct *w) if (pd->current_state == PE_UNKNOWN) goto sm_done; + if (pd->vconn_enabled) { + regulator_disable(pd->vconn); + pd->vconn_enabled = false; + } + usbpd_info(&pd->dev, "USB Type-C disconnect\n"); if (pd->pd_phy_opened) { @@ -1574,11 +1579,6 @@ static void usbpd_sm(struct work_struct *w) pd->vbus_enabled = false; } - if (pd->vconn_enabled) { - regulator_disable(pd->vconn); - pd->vconn_enabled = false; - } - if (pd->current_dr == DR_UFP) stop_usb_peripheral(pd); else if (pd->current_dr == DR_DFP) @@ -3179,7 +3179,7 @@ struct usbpd *usbpd_create(struct device *parent) if (ret) goto free_pd; - pd->wq = alloc_ordered_workqueue("usbpd_wq", WQ_FREEZABLE); + pd->wq = alloc_ordered_workqueue("usbpd_wq", WQ_FREEZABLE | WQ_HIGHPRI); if (!pd->wq) { ret = -ENOMEM; goto del_pd;