• Johan Hovold's avatar
    USB: musb: fix late external abort on suspend · 0c3aae9b
    Johan Hovold authored
    The musb delayed irq work was never flushed on suspend, something which
    since 4.9 can lead to an external abort if the work is scheduled after
    the grandparent's clock has been disabled:
    
    PM: Suspending system (mem)
    PM: suspend of devices complete after 125.224 msecs
    PM: suspend devices took 0.132 seconds
    PM: late suspend of devices complete after 7.423 msecs
    PM: noirq suspend of devices complete after 7.083 msecs
    suspend debug: Waiting for 5 second(s).
    Unhandled fault: external abort on non-linefetch (0x1008) at 0xd0262c60
    ...
    [<c054880c>] (musb_default_readb) from [<c0547b5c>] (musb_irq_work+0x48/0x220)
    [<c0547b5c>] (musb_irq_work) from [<c014f8a4>] (process_one_work+0x1f4/0x758)
    [<c014f8a4>] (process_one_work) from [<c014fe5c>] (worker_thread+0x54/0x514)
    [<c014fe5c>] (worker_thread) from [<c015704c>] (kthread+0x128/0x158)
    [<c015704c>] (kthread) from [<c0109330>] (ret_from_fork+0x14/0x24)
    
    Commit 2bff3916 ("usb: musb: Fix PM for hub disconnect") started
    scheduling musb_irq_work with a delay of up to a second and with
    retries thereby making this easy to trigger, for example, by suspending
    shortly after a disconnect.
    
    Note that we set a flag to prevent the irq work from rescheduling itself
    during suspend and instead process a disconnect immediately. This takes
    care of the case where we are disconnected shortly before suspending.
    
    However, when in host mode, a disconnect while suspended will still
    go unnoticed and thus prevent the controller from runtime suspending
    upon resume as the session bit is always set. This will need to be
    addressed separately.
    
    Fixes: 550a7375 ("USB: Add MUSB and TUSB support")
    Fixes: 467d5c98 ("usb: musb: Implement session bit based runtime PM for musb-core")
    Fixes: 2bff3916 ("usb: musb: Fix PM for hub disconnect")
    Cc: stable <stable@vger.kernel.org>     # 4.9
    Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
    Cc: Tony Lindgren <tony@atomide.com>
    Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
    Tested-by: default avatarTony Lindgren <tony@atomide.com>
    Signed-off-by: default avatarBin Liu <b-liu@ti.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0c3aae9b
musb_core.h 17.5 KB