musb: fix remote wakeup racing with suspend
Quoted 17 lines · Daniel Glöckner
Hi,
Quoted 14 lines · Bin Liu
Quoted 12 lines · Daniel Glöckner
It has been observed that writing
0xF2to the power register while it reads as0xF4results in the register having the value0xF0, i.e. clearing RESUME and setting SUSPENDM in one go does not work. It might also violate the USB spec to transition directly from resume to suspend, especially when not takingT_DRSMDNinto account. But this is what happens when a remote wakeup occurs between SetPortFeatureUSB_PORT_FEAT_SUSPENDon the root hub andmusb_bus_suspendbeing called.This commit returns
-EBUSYwhenmusb_bus_suspendis called while remote wakeup is signalled and thus avoids to reset the RESUME bit. Remember that resume can be signalled only when the bus was already suspended, so it is safe to skip the following steps even whenmusb_hub_controlignores the
Quoted 4 lines
Quoted 1 line
what do you mean by "skip the following steps"?
Setting
USB_PORT_STAT_SUSPENDinmusb->port1_status, changingmusb->xceiv->otg->state, settingmusb->is_active, etc.
Okay, but I am not sure how "even musb_hub_control ignores the error..." is relevant in this statement. The steps are safely skipped in musb_port_suspend() when MUSB_POWER_RESUME bit is set, no matter how musb_hub_control() to deal with the return code from musb_port_suspend(). Did I misunderstand anything?
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
error returned by
musb_port_suspend.The resume part of
musb_port_suspendis modified to also accept a pending remote wakeup, to bring it to the end afterT_DRSMDNhas passed.
Quoted 7 lines
Quoted 3 lines
Can you please explain more here? I am not sure when
musb_port_suspend()is involved in resume by remote wakeup, and what case is a 'pending' remote wakeup?With 'pending' I was referring to the situation when
MUSB_POWER_RESUMEhas been set by the controller in the power register as a result of of a detected remote wakeup.
Okay.
Quoted 2 lines
I see...
finish_resume_workis already scheduled bymusb_stage0_irq.
Yes.
Quoted 1 line
So the condition of the if statement probably does not need to be
I think so too. BTY, I don't think this pending remote wakeup situation will trigger ClearPortFeature, which is the only case that invokes that if statement you changed.
Quoted 5 lines
changed. I'll test without that part and make a v2 patch if it works.
Btw., do you know why that 10000 iterations while loop is needed in
musb_port_suspendto pass the OTG Protocol Test as indicated by the comment?
Unfortunately I don't. There are many mysteries in the musb drivers :)
Regards,
-Bin.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html