]> git.karo-electronics.de Git - karo-tx-linux.git/commit
MLK-10102-7 usb: chipidea: otg: fix deadlock of usb host removal after system resume
authorLi Jun <jun.li@freescale.com>
Fri, 16 Jan 2015 05:11:57 +0000 (13:11 +0800)
committerLi Jun <jun.li@freescale.com>
Fri, 16 Jan 2015 07:02:29 +0000 (15:02 +0800)
commit6c3e2d1b9ae51858694d55703c39a3be53150fea
tree28fff5837185e393a44a1bad30ac8a5c290ca0e1
parent1c06391ce6612b48238e4a34474adc2ade666498
MLK-10102-7 usb: chipidea: otg: fix deadlock of usb host removal after system resume

This is to fix possible deadlock of usb host with mass storage removal after
system resume, by waiting host finish device disconnection and then stop host
This is a patch merge for ideas from below 2 patches:
ENGR00308442-2 usb: chipidea: otg: wait devices disconnected before stop host.
ENGR00310498 usb: chipidea: otg: fix otg role switch from host to device failure

How to reproduce:
Failure case 1:
- Enable console wakeup:
  echo enabled > /sys/class/tty/ttymxc0/power/wakeup
- Connect a udisk with ID cable to OTG port.
- Suspend the system:
  ehco mem > /sys/power/state
- Remove ID cable together with udisk.
- Wakeup the system by console.
- OTG port cannot switch to device role.
Failure case 2:
- Connect a udisk with ID cable to OTG port.
- Enable usb wakeup by ./low_power_usb.sh
- Suspend the system:
  ehco mem > /sys/power/state
- Remove ID cable together with udisk.
- System wakeup but OTG port cannot switch to device role.

Root cause:
In this case, ID change interrupt generates before port change interrupt,
so with irq disabled, ci_handle_id_switch() will find there is usb device
still connected and wait it to disconnect by sleep, but disconnect will not
happen since usb irq still disabled so port change irq has no chance to be
handled.

How this patch is fixing this issue:
This patch waits host finish handle usb device disconnection before stop host,
and enables irq before sleep and disables irq after, thus port change
rq can be handled and usb device disconnection can timely happen, then
ci_handle_id_switch() can stop host and switch to device role correctly.

Signed-off-by: Li Jun <b47624@freescale.com>
drivers/usb/chipidea/otg.c