• Alan Stern's avatar
    PCI: EHCI: fix crash during suspend on ASUS computers · dbf0e4c7
    Alan Stern authored
    Quite a few ASUS computers experience a nasty problem, related to the
    EHCI controllers, when going into system suspend.  It was observed
    that the problem didn't occur if the controllers were not put into the
    D3 power state before starting the suspend, and commit
    151b6128 (USB: EHCI: fix crash during
    suspend on ASUS computers) was created to do this.
    
    It turned out this approach messed up other computers that didn't have
    the problem -- it prevented USB wakeup from working.  Consequently
    commit c2fb8a3f (USB: add
    NO_D3_DURING_SLEEP flag and revert 151b6128) was merged; it
    reverted the earlier commit and added a whitelist of known good board
    names.
    
    Now we know the actual cause of the problem.  Thanks to AceLan Kao for
    tracking it down.
    
    According to him, an engineer at ASUS explained that some of their
    BIOSes contain a bug that was added in an attempt to work around a
    problem in early versions of Windows.  When the computer goes into S3
    suspend, the BIOS tries to verify that the EHCI controllers were first
    quiesced by the OS.  Nothing's wrong with this, but the BIOS does it
    by checking that the PCI COMMAND registers contain 0 without checking
    the controllers' power state.  If the register isn't 0, the BIOS
    assumes the controller needs to be quiesced and tries to do so.  This
    involves making various MMIO accesses to the controller, which don't
    work very well if the controller is already in D3.  The end result is
    a system hang or memory corruption.
    
    Since the value in the PCI COMMAND register doesn't matter once the
    controller has been suspended, and since the value will be restored
    anyway when the controller is resumed, we can work around the BIOS bug
    simply by setting the register to 0 during system suspend.  This patch
    (as1590) does so and also reverts the second commit mentioned above,
    which is now unnecessary.
    
    In theory we could do this for every PCI device.  However to avoid
    introducing new problems, the patch restricts itself to EHCI host
    controllers.
    
    Finally the affected systems can suspend with USB wakeup working
    properly.
    
    Reference: https://bugzilla.kernel.org/show_bug.cgi?id=37632
    Reference: https://bugzilla.kernel.org/show_bug.cgi?id=42728Based-on-patch-by: default avatarAceLan Kao <acelan.kao@canonical.com>
    Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Tested-by: default avatarDâniel Fraga <fragabr@gmail.com>
    Tested-by: default avatarJavier Marcet <jmarcet@gmail.com>
    Tested-by: default avatarAndrey Rahmatullin <wrar@wrar.name>
    Tested-by: default avatarOleksij Rempel <bug-track@fisher-privat.net>
    Tested-by: default avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
    Cc: stable <stable@vger.kernel.org>
    Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Acked-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    dbf0e4c7
quirks.c 110 KB