Skip to contentSkip to conversation

musb: fix remote wakeup racing with suspend

DISCUSSION Bin Liu 1 participant 1 message May 2, 2018 USB

lore
Share & tools
lore

Bin Liu

author
#0 lore raw
Quoted 17 lines · Daniel Glöckner

Hi,

Quoted 14 lines · Bin Liu
Quoted 12 lines · Daniel Glöckner

It has been observed that writing 0xF2 to the power register while it reads as 0xF4 results in the register having the value 0xF0, 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 taking T_DRSMDN into account. But this is what happens when a remote wakeup occurs between SetPortFeature USB_PORT_FEAT_SUSPEND on the root hub and musb_bus_suspend being called.

This commit returns -EBUSY when musb_bus_suspend is 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 when musb_hub_control ignores the

Quoted 4 lines
Quoted 1 line

what do you mean by "skip the following steps"?

Setting USB_PORT_STAT_SUSPEND in musb->port1_status, changing musb->xceiv->otg->state, setting musb->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_suspend is modified to also accept a pending remote wakeup, to bring it to the end after T_DRSMDN has 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_RESUME has 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_work is already scheduled by musb_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_suspend to 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