• A
    USB: hub: Fix handling of connect changes during sleep · 9f952e26
    Alan Stern 提交于
    Commit 8099f58f ("USB: hub: Don't record a connect-change event
    during reset-resume") wasn't very well conceived.  The problem it
    tried to fix was that if a connect-change event occurred while the
    system was asleep (such as a device disconnecting itself from the bus
    when it is suspended and then reconnecting when it resumes)
    requiring a reset-resume during the system wakeup transition, the hub
    port's change_bit entry would remain set afterward.  This would cause
    the hub driver to believe another connect-change event had occurred
    after the reset-resume, which was wrong and would lead the driver to
    send unnecessary requests to the device (which could interfere with a
    firmware update).
    
    The commit tried to fix this by not setting the change_bit during the
    wakeup.  But this was the wrong thing to do; it means that when a
    device is unplugged while the system is asleep, the hub driver doesn't
    realize anything has happened: The change_bit flag which would tell it
    to handle the disconnect event is clear.
    
    The commit needs to be reverted and the problem fixed in a different
    way.  Fortunately an alternative solution was noted in the commit's
    Changelog: We can continue to set the change_bit entry in
    hub_activate() but then clear it when a reset-resume occurs.  That way
    the the hub driver will see the change_bit when a device is
    disconnected but won't see it when the device is still present.
    
    That's what this patch does.
    Reported-and-tested-by: NPeter Chen <peter.chen@nxp.com>
    Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
    Fixes: 8099f58f ("USB: hub: Don't record a connect-change event during reset-resume")
    Tested-by: NPaul Zimmerman <pauldzim@gmail.com>
    CC: <stable@vger.kernel.org>
    
    Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2004221602480.11262-100000@iolanthe.rowland.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    9f952e26
hub.c 174.1 KB