summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jun <jun.li@freescale.com>2015-07-02 08:13:39 +0800
committerLi Jun <jun.li@freescale.com>2015-07-22 12:30:19 +0800
commit82ed490b9fa9fc1fd066cd22b2f57e2a59a6c631 (patch)
treeaddc5eee075df713c05a96c3d2428dbc67a2cfdb
parent613892a0d32b6a6a3cbcd6ae099540b294a1ff3f (diff)
MLK-11183 usb: chipidea: otg: complete state machine before cancel hrtimer
When do usb driver module load and unload loop test for A-device, the hrtimer may be cancelled during otg state machine running, so after the hrtimer is cancelled, the otg state machine may start it again by adding a new timer, this will cause the hrtimer will be active after its function memory is freed by module unload. This patch is to fix it by trying to hold the fsm mutex lock before setting otg state to be undefined, then otg hrtimer will be cancelled after current otg fsm transition completes, and no new timer will be added. Signed-off-by: Li Jun <jun.li@freescale.com> (cherry picked from commit 8c3ab4f22bc34675aeb8f9c62e69b450a179be0f) (cherry picked from commit 95c8590c5232eeb9d054ac7504455a90a133f05a)
-rw-r--r--drivers/usb/chipidea/otg_fsm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 39eb323552cd..0c6e01961814 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -1116,6 +1116,10 @@ void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
{
enum otg_fsm_timer i;
+ mutex_lock(&ci->fsm.lock);
+ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
+ mutex_unlock(&ci->fsm.lock);
+
for (i = 0; i < NUM_OTG_FSM_TIMERS; i++)
otg_del_timer(&ci->fsm, i);
@@ -1127,7 +1131,6 @@ void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
sysfs_remove_group(&ci->dev->kobj, &inputs_attr_group);
del_timer_sync(&ci->hnp_polling_timer);
- ci->fsm.otg->state = OTG_STATE_UNDEFINED;
}
/* Restart OTG fsm if resume from power lost */