• Mika Westerberg's avatar
    PCI: Add runtime PM support for PCIe ports · 006d44e4
    Mika Westerberg authored
    Add back runtime PM support for PCIe ports that was removed by
    fe9a743a ("PCI/PM: Drop unused runtime PM support code for PCIe
    ports").
    
    We cannot enable it automatically for all ports since there have been
    problems previously [1].  In summary suspended PCIe ports were not able
    to deal with ACPI-based hotplug reliably.  One reason why this might happen
    is the fact that when a PCIe port is powered down, config space access to
    the devices behind the port is not possible.  If the BIOS hotplug SMI
    handler assumes the port is always in D0 it will not be able to find the
    hotplugged devices.  To be on the safe side only enable runtime PM if the
    port does not claim to support hotplug.
    
    For PCIe ports not using hotplug, we enable and allow runtime PM
    automatically.  Since 'bridge_d3' can be changed any time we check this in
    driver ->runtime_idle() and ->runtime_suspend() and only allow runtime
    suspend if the flag is still set.  Use autosuspend with default of 100ms
    idle time to prevent the port from repeatedly suspending and resuming on
    continuous configuration space access of devices behind the port.
    
    The actual power transition to D3 and back is handled in the PCI core.
    
    Idea to automatically unblock (allow) runtime PM for PCIe ports came from
    Dave Airlie.
    
    [1] https://bugzilla.kernel.org/show_bug.cgi?id=53811
    
    This includes a fix for lockdep issue reported by Valdis Kletnieks.
    Tested-by: default avatarLukas Wunner <lukas@wunner.de>
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    006d44e4
portdrv_pci.c 10.1 KB