20 Sep, 2013

1 commit

  • Commit 448bd85 (PCI/PM: add PCIe runtime D3cold support) added a
    piece of code to pci_acpi_wake_dev() causing that function to behave
    in a special way for devices in D3cold (so that their configuration
    registers are not accessed before those devices are resumed).
    However, it didn't take the clearing of the pme_poll flag into
    account. That has to be done for all devices, even if they are in
    D3cold, or pci_pme_list_scan() will not know that wakeup has been
    signaled for the device and will poll its PME Status bit
    unnecessarily.

    Fix the problem by moving the clearing of the pme_poll flag in
    pci_acpi_wake_dev() before the code introduced by commit 448bd85.

    Reported-and-tested-by: David E. Box
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Bjorn Helgaas
    Cc: 3.6+ # 3.6+

    Rafael J. Wysocki
     

27 Aug, 2013

1 commit

  • * acpi-pci-hotplug: (34 commits)
    ACPI / PM: Hold acpi_scan_lock over system PM transitions
    ACPI / hotplug / PCI: Fix NULL pointer dereference in cleanup_bridge()
    PCI / ACPI: Use dev_dbg() instead of dev_info() in acpi_pci_set_power_state()
    ACPI / hotplug / PCI: Get rid of check_sub_bridges()
    ACPI / hotplug / PCI: Clean up bridge_mutex usage
    ACPI / hotplug / PCI: Redefine enable_device() and disable_device()
    ACPI / hotplug / PCI: Sanitize acpiphp_get_(latch)|(adapter)_status()
    ACPI / hotplug / PCI: Get rid of unused constants in acpiphp.h
    ACPI / hotplug / PCI: Check for new devices on enabled slots
    ACPI / hotplug / PCI: Allow slots without new devices to be rescanned
    ACPI / hotplug / PCI: Do not check SLOT_ENABLED in enable_device()
    ACPI / hotplug / PCI: Do not exectute _PS0 and _PS3 directly
    ACPI / hotplug / PCI: Do not queue up event handling work items in vain
    ACPI / hotplug / PCI: Consolidate slot disabling and ejecting
    ACPI / hotplug / PCI: Drop redundant checks from check_hotplug_bridge()
    ACPI / hotplug / PCI: Rework namespace scanning and trimming routines
    ACPI / hotplug / PCI: Store parent in functions and bus in slots
    ACPI / hotplug / PCI: Drop handle field from struct acpiphp_bridge
    ACPI / hotplug / PCI: Drop handle field from struct acpiphp_func
    ACPI / hotplug / PCI: Embed function struct into struct acpiphp_context
    ...

    Rafael J. Wysocki
     

08 Aug, 2013

1 commit

  • In theory, under a given ACPI namespace node there should be only
    one child device object with _ADR whose value matches a given bus
    address exactly. In practice, however, there are systems in which
    multiple child device objects under a given parent have _ADR matching
    exactly the same address. In those cases we use _STA to determine
    which of the multiple matching devices is enabled, since some systems
    are known to indicate which ACPI device object to associate with the
    given physical (usually PCI) device this way.

    Unfortunately, as it turns out, there are systems in which many
    device objects under the same parent have _ADR matching exactly the
    same bus address and none of them has _STA, in which case they all
    should be regarded as enabled according to the spec. Still, if
    those device objects are supposed to represent bridges (e.g. this
    is the case for device objects corresponding to PCIe ports), we can
    try harder and skip the ones that have no child device objects in the
    ACPI namespace. With luck, we can avoid using device objects that we
    are not expected to use this way.

    Although this only works for bridges whose children also have ACPI
    namespace representation, it is sufficient to address graphics
    adapter detection issues on some systems, so rework the code finding
    a matching device ACPI handle for a given bus address to implement
    this idea.

    Introduce a new function, acpi_find_child(), taking three arguments:
    the ACPI handle of the device's parent, a bus address suitable for
    the device's bus type and a bool indicating if the device is a
    bridge and make it work as outlined above. Reimplement the function
    currently used for this purpose, acpi_get_child(), as a call to
    acpi_find_child() with the last argument set to 'false' and make
    the PCI subsystem use acpi_find_child() with the bridge information
    passed as the last argument to it. [Lan Tianyu notices that it is
    not sufficient to use pci_is_bridge() for that, because the device's
    subordinate pointer hasn't been set yet at this point, so use
    hdr_type instead.]

    This change fixes a regression introduced inadvertently by commit
    33f767d (ACPI: Rework acpi_get_child() to be more efficient) which
    overlooked the fact that for acpi_walk_namespace() "post-order" means
    "after all children have been visited" rather than "on the way back",
    so for device objects without children and for namespace walks of
    depth 1, as in the acpi_get_child() case, the "post-order" callbacks
    ordering is actually the same as the ordering of "pre-order" ones.
    Since that commit changed the namespace walk in acpi_get_child() to
    terminate after finding the first matching object instead of going
    through all of them and returning the last one, it effectively
    changed the result returned by that function in some rare cases and
    that led to problems (the switch from a "pre-order" to a "post-order"
    callback was supposed to prevent that from happening, but it was
    ineffective).

    As it turns out, the systems where the change made by commit
    33f767d actually matters are those where there are multiple ACPI
    device objects representing the same PCIe port (which effectively
    is a bridge). Moreover, only one of them, and the one we are
    expected to use, has child device objects in the ACPI namespace,
    so the regression can be addressed as described above.

    References: https://bugzilla.kernel.org/show_bug.cgi?id=60561
    Reported-by: Peter Wu
    Tested-by: Vladimir Lalov
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Bjorn Helgaas
    Cc: 3.9+ # 3.9+

    Rafael J. Wysocki
     

01 Aug, 2013

1 commit

  • acpi_pci_set_power_state() uses dev_info() to print diagnostic
    messages regarding ACPI power state changes of devices, but that
    results in too much not really interesting output into the kernel
    log in some cases.

    For this reason, change it to use dev_dbg() instead and prevent
    kernel log from being spammed.

    [rjw: Changelog]
    References: https://bugzilla.kernel.org/show_bug.cgi?id=60636
    Suggested-by: Alan Stern
    Signed-off-by: Lan Tianyu
    Acked-by: Bjorn Helgaas
    Signed-off-by: Rafael J. Wysocki

    Lan Tianyu
     

23 Jul, 2013

1 commit

  • Since acpi_pci_slot_enumerate() and acpiphp_enumerate_slots() can get
    the ACPI device handle they need from bus->bridge, it is not
    necessary to pass that handle to them as an argument.

    Drop the second argument of acpi_pci_slot_enumerate() and
    acpiphp_enumerate_slots(), rework them to obtain the ACPI handle
    from bus->bridge and make acpi_pci_add_bus() and
    acpi_pci_remove_bus() entirely symmetrical.

    Tested-by: Mika Westerberg
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu

    Rafael J. Wysocki
     

15 Jun, 2013

1 commit

  • Make acpi_pci_set_power_state() print the name of the ACPI device
    power state the device has been actually put into instead of printing
    the name of the requested PCI device power state, which need not be
    the same.

    [bhelgaas: use ACPI_STATE_D3_COLD (ACPI_STATE_D3 == ACPI_STATE_D3_COLD)]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bjorn Helgaas

    Rafael J. Wysocki
     

29 May, 2013

1 commit


30 Apr, 2013

1 commit

  • Pull PCI updates from Bjorn Helgaas:
    "PCI changes for the v3.10 merge window:

    PCI device hotplug
    - Remove ACPI PCI subdrivers (Jiang Liu, Myron Stowe)
    - Make acpiphp builtin only, not modular (Jiang Liu)
    - Add acpiphp mutual exclusion (Jiang Liu)

    Power management
    - Skip "PME enabled/disabled" messages when not supported (Rafael
    Wysocki)
    - Fix fallback to PCI_D0 (Rafael Wysocki)

    Miscellaneous
    - Factor quirk_io_region (Yinghai Lu)
    - Cache MSI capability offsets & cleanup (Gavin Shan, Bjorn Helgaas)
    - Clean up EISA resource initialization and logging (Bjorn Helgaas)
    - Fix prototype warnings (Andy Shevchenko, Bjorn Helgaas)
    - MIPS: Initialize of_node before scanning bus (Gabor Juhos)
    - Fix pcibios_get_phb_of_node() declaration "weak" annotation (Gabor
    Juhos)
    - Add MSI INTX_DISABLE quirks for AR8161/AR8162/etc (Xiong Huang)
    - Fix aer_inject return values (Prarit Bhargava)
    - Remove PME/ACPI dependency (Andrew Murray)
    - Use shared PCI_BUS_NUM() and PCI_DEVID() (Shuah Khan)"

    * tag 'pci-v3.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (63 commits)
    vfio-pci: Use cached MSI/MSI-X capabilities
    vfio-pci: Use PCI_MSIX_TABLE_BIR, not PCI_MSIX_FLAGS_BIRMASK
    PCI: Remove "extern" from function declarations
    PCI: Use PCI_MSIX_TABLE_BIR, not PCI_MSIX_FLAGS_BIRMASK
    PCI: Drop msi_mask_reg() and remove drivers/pci/msi.h
    PCI: Use msix_table_size() directly, drop multi_msix_capable()
    PCI: Drop msix_table_offset_reg() and msix_pba_offset_reg() macros
    PCI: Drop is_64bit_address() and is_mask_bit_support() macros
    PCI: Drop msi_data_reg() macro
    PCI: Drop msi_lower_address_reg() and msi_upper_address_reg() macros
    PCI: Drop msi_control_reg() macro and use PCI_MSI_FLAGS directly
    PCI: Use cached MSI/MSI-X offsets from dev, not from msi_desc
    PCI: Clean up MSI/MSI-X capability #defines
    PCI: Use cached MSI-X cap while enabling MSI-X
    PCI: Use cached MSI cap while enabling MSI interrupts
    PCI: Remove MSI/MSI-X cap check in pci_msi_check_device()
    PCI: Cache MSI/MSI-X capability offsets in struct pci_dev
    PCI: Use u8, not int, for PM capability offset
    [SCSI] megaraid_sas: Use correct #define for MSI-X capability
    PCI: Remove "extern" from function declarations
    ...

    Linus Torvalds
     

13 Apr, 2013

3 commits

  • Previously the acpiphp driver registered itself as an ACPI PCI subdriver,
    so its callbacks were invoked when creating/destroying PCI root
    buses to manage ACPI-based PCI hotplug slots. But it doesn't handle
    P2P bridge hotplug events, so it will cause strange behaviour if there
    are hotplug slots associated with a hot-removed P2P bridge.

    This patch fixes this issue by:
    1) Directly hooking into PCI core to update hotplug slot devices when
    creating/destroying PCI buses through:
    pci_{add|remove}_bus() -> acpi_pci_{add|remove}_bus()
    2) Getting rid of unused ACPI PCI subdriver-related code

    It also cleans up unused code in the acpiphp driver.

    [bhelgaas: keep acpi_pci_add_bus() stub for CONFIG_ACPI=n]
    Signed-off-by: Jiang Liu
    Signed-off-by: Yijing Wang
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Yinghai Lu
    Cc: "Rafael J. Wysocki"
    Cc: Toshi Kani

    Jiang Liu
     
  • Currently the pci_slot driver doesn't update PCI slot devices when PCI
    device hotplug event happens, which may cause memory leak and returning
    stale information to user.

    Now the pci_slot driver has been changed as built-in driver, so invoke
    PCI slot enumeration and destroy routines directly from the PCI core.
    And remove ACPI PCI sub-driver related code because it isn't needed
    any more.

    [bhelgas: removed "extern" from function declarations]
    Signed-off-by: Jiang Liu
    Signed-off-by: Yijing Wang
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Yinghai Lu
    Acked-by: Rafael J. Wysocki
    Cc: Toshi Kani

    Jiang Liu
     
  • Prepare two stub functions to handle ACPI PCI slots and ACPI PCI hotplug
    slots, which will be invoked by the PCI core when creating/destroying
    PCI buses.

    It will be used to get rid of ACPI PCI subdrivers for pci_slot and
    acpiphp, and eventually remove the ACPI PCI subdriver mechanism.

    And it will also be used to handle ACPI PCI (hotplug) slots in a unified
    way, both at boot time and for PCI hotplug operations.

    Signed-off-by: Jiang Liu
    Signed-off-by: Yijing Wang
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Yinghai Lu
    Cc: "Rafael J. Wysocki"
    Cc: Toshi Kani
    Cc: Tony Luck
    Cc: Fenghua Yu
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Myron Stowe

    Jiang Liu
     

04 Apr, 2013

1 commit

  • It turns out that the _Lxx control methods provided by some BIOSes
    clear the PME Status bit of PCI devices they handle, which means that
    pci_acpi_wake_dev() cannot really use that bit to check whether or
    not the device has signalled wakeup.

    One symptom of the problem is, for example, that when an affected PCI
    USB controller is runtime-suspended, then plugging in a new USB device
    into one of the controller's ports will not wake up the controller,
    which should happen.

    For this reason, make pci_acpi_wake_dev() always attempt to resume
    the device it is called for regardless of the device's PME Status bit
    value (that bit still has to be cleared if set at this point,
    though).

    Reported-by: Sarah Sharp
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bjorn Helgaas
    Acked-by: Matthew Garrett
    CC: stable@vger.kernel.org # v3.7+

    Rafael J. Wysocki
     

04 Mar, 2013

1 commit

  • USB uses the .find_bridge() callback from struct acpi_bus_type
    incorrectly, because as a result of the way it is used by USB every
    device in the system that doesn't have a bus type or parent is
    passed to usb_acpi_find_device() for inspection.

    What USB actually needs, though, is to call usb_acpi_find_device()
    for USB ports that don't have a bus type defined, but have
    usb_port_device_type as their device type, as well as for USB
    devices.

    To fix that replace the struct bus_type pointer in struct
    acpi_bus_type used for matching devices to specific subsystems
    with a .match() callback to be used for this purpose and update
    the users of struct acpi_bus_type, including USB, accordingly.
    Define the .match() callback routine for USB, usb_acpi_bus_match(),
    in such a way that it will cover both USB devices and USB ports
    and remove the now redundant .find_bridge() callback pointer from
    usb_acpi_bus.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Acked-by: Yinghai Lu
    Acked-by: Jeff Garzik

    Rafael J. Wysocki
     

26 Feb, 2013

1 commit

  • Pull PCI changes from Bjorn Helgaas:
    "Host bridge hotplug
    - Major overhaul of ACPI host bridge add/start (Rafael Wysocki, Yinghai Lu)
    - Major overhaul of PCI/ACPI binding (Rafael Wysocki, Yinghai Lu)
    - Split out ACPI host bridge and ACPI PCI device hotplug (Yinghai Lu)
    - Stop caching _PRT and make independent of bus numbers (Yinghai Lu)

    PCI device hotplug
    - Clean up cpqphp dead code (Sasha Levin)
    - Disable ARI unless device and upstream bridge support it (Yijing Wang)
    - Initialize all hot-added devices (not functions 0-7) (Yijing Wang)

    Power management
    - Don't touch ASPM if disabled (Joe Lawrence)
    - Fix ASPM link state management (Myron Stowe)

    Miscellaneous
    - Fix PCI_EXP_FLAGS accessor (Alex Williamson)
    - Disable Bus Master in pci_device_shutdown (Konstantin Khlebnikov)
    - Document hotplug resource and MPS parameters (Yijing Wang)
    - Add accessor for PCIe capabilities (Myron Stowe)
    - Drop pciehp suspend/resume messages (Paul Bolle)
    - Make pci_slot built-in only (not a module) (Jiang Liu)
    - Remove unused PCI/ACPI bind ops (Jiang Liu)
    - Removed used pci_root_bus (Bjorn Helgaas)"

    * tag 'pci-v3.9-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (51 commits)
    PCI/ACPI: Don't cache _PRT, and don't associate them with bus numbers
    PCI: Fix PCI Express Capability accessors for PCI_EXP_FLAGS
    ACPI / PCI: Make pci_slot built-in only, not a module
    PCI/PM: Clear state_saved during suspend
    PCI: Use atomic_inc_return() rather than atomic_add_return()
    PCI: Catch attempts to disable already-disabled devices
    PCI: Disable Bus Master unconditionally in pci_device_shutdown()
    PCI: acpiphp: Remove dead code for PCI host bridge hotplug
    PCI: acpiphp: Create companion ACPI devices before creating PCI devices
    PCI: Remove unused "rc" in virtfn_add_bus()
    PCI: pciehp: Drop suspend/resume ENTRY messages
    PCI/ASPM: Don't touch ASPM if forcibly disabled
    PCI/ASPM: Deallocate upstream link state even if device is not PCIe
    PCI: Document MPS parameters pci=pcie_bus_safe, pci=pcie_bus_perf, etc
    PCI: Document hpiosize= and hpmemsize= resource reservation parameters
    PCI: Use PCI Express Capability accessor
    PCI: Introduce accessor to retrieve PCIe Capabilities Register
    PCI: Put pci_dev in device tree as early as possible
    PCI: Skip attaching driver in device_add()
    PCI: acpiphp: Keep driver loaded even if no slots found
    ...

    Linus Torvalds
     

20 Feb, 2013

1 commit


17 Feb, 2013

1 commit

  • Previously, we cached _PRT (PCI routing table, ACPI 5.0 sec 6.2.12)
    contents and associated each _PRT entry with a PCI bus number. The bus
    number association means dependencies on PCI device enumeration and bus
    number assignment, as well as on the PCI/ACPI binding process.

    After 4f535093cf ("PCI: Put pci_dev in device tree as early as possible"),
    these dependencies caused the IRQ issues reported by Peter:

    pci 0000:00:1e.0: PCI bridge to [bus 09] (subtractive decode)
    pci 0000:00:1e.0: can't derive routing for PCI INT A
    snd_ctxfi 0000:09:02.0: PCI INT A: no GSI - using ISA IRQ 5
    irq 18: nobody cared (try booting with the "irqpoll" option)

    This patch removes _PRT caching. Instead, we evaluate _PRT as needed
    in the pci_enable_device() path. This also removes the dependency on
    PCI bus numbers: we can simply look at the _PRT associated with each
    bridge as we walk upstream toward the root.

    [bhelgaas: changelog]
    Reference: https://bugzilla.kernel.org/show_bug.cgi?id=53561
    Reported-and-tested-by: Peter Hurley
    Suggested-by: Bjorn Helgaas
    Signed-off-by: Yinghai Lu
    Signed-off-by: Bjorn Helgaas

    Yinghai Lu
     

17 Jan, 2013

1 commit

  • Commit 0090def6 (ACPI: Add interface to register/unregister device
    to/from power resources) made it possible to indicate to the ACPI
    core that if the given device depends on any power resources, then
    it should be resumed as soon as all of the power resources required
    by it to transition to the D0 power state have been turned on.

    Unfortunately, however, this was a mistake, because all devices
    depending on power resources should be treated this way (i.e. they
    should be resumed when all power resources required by their D0
    state have been turned on) and for the majority of those devices
    the ACPI core can figure out by itself which (physical) devices
    depend on what power resources.

    For this reason, replace the code added by commit 0090def6 with a
    new, much more straightforward, mechanism that will be used
    internally by the ACPI core and remove all references to that code
    from kernel subsystems using ACPI.

    For the cases when there are (physical) devices that should be
    resumed whenever a not directly related ACPI device node goes into
    D0 as a result of power resources configuration changes, like in
    the SATA case, add two new routines, acpi_dev_pm_add_dependent()
    and acpi_dev_pm_remove_dependent(), allowing subsystems to manage
    such dependencies. Convert the SATA subsystem to use the new
    functions accordingly.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

14 Jan, 2013

1 commit

  • The ACPI handles of PCI root bridges need to be known to
    acpi_bind_one(), so that it can create the appropriate
    "firmware_node" and "physical_node" files for them, but currently
    the way it gets to know those handles is not exactly straightforward
    (to put it lightly).

    This is how it works, roughly:

    1. acpi_bus_scan() finds the handle of a PCI root bridge,
    creates a struct acpi_device object for it and passes that
    object to acpi_pci_root_add().

    2. acpi_pci_root_add() creates a struct acpi_pci_root object,
    populates its "device" field with its argument's address
    (device->handle is the ACPI handle found in step 1).

    3. The struct acpi_pci_root object created in step 2 is passed
    to pci_acpi_scan_root() and used to get resources that are
    passed to pci_create_root_bus().

    4. pci_create_root_bus() creates a struct pci_host_bridge object
    and passes its "dev" member to device_register().

    5. platform_notify(), which for systems with ACPI is set to
    acpi_platform_notify(), is called.

    So far, so good. Now it starts to be "interesting".

    6. acpi_find_bridge_device() is used to find the ACPI handle of
    the given device (which is the PCI root bridge) and executes
    acpi_pci_find_root_bridge(), among other things, for the
    given device object.

    7. acpi_pci_find_root_bridge() uses the name (sic!) of the given
    device object to extract the segment and bus numbers of the PCI
    root bridge and passes them to acpi_get_pci_rootbridge_handle().

    8. acpi_get_pci_rootbridge_handle() browses the list of ACPI PCI
    root bridges and finds the one that matches the given segment
    and bus numbers. Its handle is then used to initialize the
    ACPI handle of the PCI root bridge's device object by
    acpi_bind_one(). However, this is *exactly* the ACPI handle we
    started with in step 1.

    Needless to say, this is quite embarassing, but it may be avoided
    thanks to commit f3fd0c8 (ACPI: Allow ACPI handles of devices to be
    initialized in advance), which makes it possible to initialize the
    ACPI handle of a device before passing it to device_register().

    Accordingly, add a new __weak routine, pcibios_root_bridge_prepare(),
    defaulting to an empty implementation that can be replaced by the
    interested architecutres (x86 and ia64 at the moment) with functions
    that will set the root bridge's ACPI handle before its dev member is
    passed to device_register(). Make both x86 and ia64 provide such
    implementations of pcibios_root_bridge_prepare() and remove
    acpi_pci_find_root_bridge() and acpi_get_pci_rootbridge_handle() that
    aren't necessary any more.

    Included is a fix for breakage on systems with non-ACPI PCI host
    bridges from Bjorn Helgaas.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bjorn Helgaas

    Rafael J. Wysocki
     

03 Jan, 2013

2 commits

  • Move the code related to _PRT setup and removal and to power
    resources from acpi_pci_bind() and acpi_pci_unbind() to the .setup()
    and .cleanup() callbacks in acpi_pci_bus and remove acpi_pci_bind()
    and acpi_pci_unbind() that have no purpose any more. Accordingly,
    remove the code related to device .bind() and .unbind() operations
    from the ACPI PCI root bridge driver.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu
    Acked-by: Toshi Kani

    Rafael J. Wysocki
     
  • Currently, the ACPI wakeup capability of PCI devices is set up
    in two different places, partially in acpi_pci_bind() where
    runtime wakeup is initialized and partially in
    platform_pci_wakeup_init(), where system wakeup is initialized.
    The cleanup is only done in acpi_pci_unbind() and it only covers
    runtime wakeup.

    Use the new .setup() and .cleanup() callbacks in struct acpi_bus_type
    to consolidate that code and do the setup and the cleanup each in one
    place.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Yinghai Lu
    Acked-by: Toshi Kani

    Rafael J. Wysocki
     

15 Nov, 2012

1 commit


24 Oct, 2012

1 commit

  • Make ACPI power management routines and PCI power management
    routines depending on ACPI take device PM QoS flags into account
    when deciding what power state to put the device into.

    In particular, after this change acpi_pm_device_sleep_state() will
    not return ACPI_STATE_D3_COLD as the deepest available low-power
    state if PM_QOS_FLAG_NO_POWER_OFF is requested for the device and it
    will not require remote wakeup to work for the device in the returned
    low-power state if there is at least one PM QoS flags request for the
    device, but PM_QOS_FLAG_REMOTE_WAKEUP is not requested for it.

    Accordingly, acpi_pci_set_power_state() will refuse to put the
    device into D3cold if PM_QOS_FLAG_NO_POWER_OFF is requested for it.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Jean Pihet
    Reviewed-by: Huang Ying

    Rafael J. Wysocki
     

16 Aug, 2012

1 commit

  • If a PCI device is put into D3_cold by acpi_bus_set_power(),
    the message printed by acpi_pci_set_power_state() says that its
    power state has been changed to D4, which doesn't make sense.
    In turn, if the device is put into D3_hot, the message simply
    says "D3" without specifying the variant of the D3 state.

    Fix this by using the pci_power_name() macro for printing the state
    name instead of building it from the numeric value corresponding to
    the given state directly.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bjorn Helgaas

    Rafael J. Wysocki
     

24 Jun, 2012

3 commits

  • * topic/huang-d3cold-v7:
    PCI/PM: add PCIe runtime D3cold support
    PCI: do not call pci_set_power_state with PCI_D3cold
    PCI/PM: add runtime PM support to PCIe port
    ACPI/PM: specify lowest allowed state for device sleep state

    Bjorn Helgaas
     
  • This patch adds runtime D3cold support and corresponding ACPI platform
    support. This patch only enables runtime D3cold support; it does not
    enable D3cold support during system suspend/hibernate.

    D3cold is the deepest power saving state for a PCIe device, where its main
    power is removed. While it is in D3cold, you can't access the device at
    all, not even its configuration space (which is still accessible in D3hot).
    Therefore the PCI PM registers can not be used to transition into/out of
    the D3cold state; that must be done by platform logic such as ACPI _PR3.

    To support wakeup from D3cold, a system may provide auxiliary power, which
    allows a device to request wakeup using a Beacon or the sideband WAKE#
    signal. WAKE# is usually connected to platform logic such as ACPI GPE.
    This is quite different from other power saving states, where devices
    request wakeup via a PME message on the PCIe link.

    Some devices, such as those in plug-in slots, have no direct platform
    logic. For example, there is usually no ACPI _PR3 for them. D3cold
    support for these devices can be done via the PCIe Downstream Port leading
    to the device. When the PCIe port is powered on/off, the device is powered
    on/off too. Wakeup events from the device will be notified to the
    corresponding PCIe port.

    For more information about PCIe D3cold and corresponding ACPI support,
    please refer to:

    - PCI Express Base Specification Revision 2.0
    - Advanced Configuration and Power Interface Specification Revision 5.0

    [bhelgaas: changelog]
    Reviewed-by: Rafael J. Wysocki
    Originally-by: Zheng Yan
    Signed-off-by: Huang Ying
    Signed-off-by: Bjorn Helgaas

    Huang Ying
     
  • Lower device sleep state can save more power, but has more exit
    latency too. Sometimes, to satisfy some power QoS and other
    requirement, we need to constrain the lowest device sleep state.

    In this patch, a parameter to specify lowest allowed state for
    acpi_pm_device_sleep_state is added. So that the caller can enforce
    the constraint via the parameter.

    This is needed by PCIe D3cold support, where the lowest power state
    allowed may be D3_HOT instead of default D3_COLD.

    CC: Len Brown
    CC: linux-acpi@vger.kernel.org
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Huang Ying
    Signed-off-by: Bjorn Helgaas

    Huang Ying
     

23 Jun, 2012

1 commit


18 May, 2012

1 commit

  • Commit 1cc0c998fdf2 ("ACPI: Fix D3hot v D3cold confusion") introduced a
    bug in __acpi_bus_set_power() and changed the behavior of
    acpi_pci_set_power_state() in such a way that it generally doesn't work
    as expected if PCI_D3hot is passed to it as the second argument.

    First off, if ACPI_STATE_D3 (equal to ACPI_STATE_D3_COLD) is passed to
    __acpi_bus_set_power() and the explicit_set flag is set for the D3cold
    state, the function will try to execute AML method called "_PS4", which
    doesn't exist.

    Fix this by adding a check to ensure that the name of the AML method
    to execute for transitions to ACPI_STATE_D3_COLD is correct in
    __acpi_bus_set_power(). Also make sure that the explicit_set flag
    for ACPI_STATE_D3_COLD will be set if _PS3 is present and modify
    acpi_power_transition() to avoid accessing power resources for
    ACPI_STATE_D3_COLD, because they don't exist.

    Second, if PCI_D3hot is passed to acpi_pci_set_power_state() as the
    target state, the function will request a transition to
    ACPI_STATE_D3_HOT instead of ACPI_STATE_D3. However,
    ACPI_STATE_D3_HOT is now only marked as supported if the _PR3 AML
    method is defined for the given device, which is rare. This causes
    problems to happen on systems where devices were successfully put
    into ACPI D3 by pci_set_power_state(PCI_D3hot) which doesn't work
    now. In particular, some unused graphics adapters are not turned
    off as a result.

    To fix this issue restore the old behavior of
    acpi_pci_set_power_state(), which is to request a transition to
    ACPI_STATE_D3 (equal to ACPI_STATE_D3_COLD) if either PCI_D3hot or
    PCI_D3cold is passed to it as the argument.

    This approach is not ideal, because generally power should not
    be removed from devices if PCI_D3hot is the target power state,
    but since this behavior is relied on, we have no choice but to
    restore it at the moment and spend more time on designing a
    better solution in the future.

    References: https://bugzilla.kernel.org/show_bug.cgi?id=43228
    Reported-by: rocko
    Reported-by: Cristian Rodríguez
    Reported-and-tested-by: Peter
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

05 May, 2012

1 commit

  • Before this patch, ACPI_STATE_D3 incorrectly referenced D3hot
    in some places, but D3cold in other places.

    After this patch, ACPI_STATE_D3 always means ACPI_STATE_D3_COLD;
    and all references to D3hot use ACPI_STATE_D3_HOT.

    ACPI's _PR3 method is used to enter both D3hot and D3cold states.
    What distinguishes D3hot from D3cold is the presence _PR3
    (Power Resources for D3hot) If these resources are all ON,
    then the state is D3hot. If _PR3 is not present,
    or all _PR0 resources for the devices are OFF,
    then the state is D3cold.

    This patch applies after Linux-3.4-rc1.
    A future syntax cleanup may remove ACPI_STATE_D3
    to emphasize that it always means ACPI_STATE_D3_COLD.

    Signed-off-by: Lin Ming
    Acked-by: Rafael J. Wysocki
    Reviewed-by: Aaron Lu
    Signed-off-by: Len Brown

    Lin Ming
     

30 Mar, 2012

1 commit

  • acpi_dev_run_wake() is a generic function which can be used by
    other subsystem too. Rename it to acpi_pm_device_run_wake, to be
    consistent with acpi_pm_device_sleep_wake.

    Then move it to ACPI core.

    Acked-by: Rafael J. Wysocki
    Signed-off-by: Lin Ming
    Signed-off-by: Len Brown

    Lin Ming
     

06 Dec, 2011

2 commits

  • Modify pci_acpi_wake_dev() to avoid resuming PME-capable devices
    whose PME Status bits are not set, which may happen currently if
    several devices are associated with the same wakeup GPE and all
    of them are notified whenever at least one of them signals PME.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • Right now we forcibly clear ASPM state on all devices if the BIOS indicates
    that the feature isn't supported. Based on the Microsoft presentation
    "PCI Express In Depth for Windows Vista and Beyond", I'm starting to think
    that this may be an error. The implication is that unless the platform
    grants full control via _OSC, Windows will not touch any PCIe features -
    including ASPM. In that case clearing ASPM state would be an error unless
    the platform has granted us that control.

    This patch reworks the ASPM disabling code such that the actual clearing
    of state is triggered by a successful handoff of PCIe control to the OS.
    The general ASPM code undergoes some changes in order to ensure that the
    ability to clear the bits isn't overridden by ASPM having already been
    disabled. Further, this theoretically now allows for situations where
    only a subset of PCIe roots hand over control, leaving the others in the
    BIOS state.

    It's difficult to know for sure that this is the right thing to do -
    there's zero public documentation on the interaction between all of these
    components. But enough vendors enable ASPM on platforms and then set this
    bit that it seems likely that they're expecting the OS to leave them alone.

    Measured to save around 5W on an idle Thinkpad X220.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Matthew Garrett
     

15 Oct, 2011

2 commits

  • The result returned by acpi_dev_run_wake() is always either -EINVAL
    or -ENODEV, while obviously it should return 0 on success. The
    problem is that the leftover error variable, that's not really used
    in the function, is initialized with -ENODEV and then returned
    without modification.

    To fix this issue remove the error variable from acpi_dev_run_wake()
    and make the function return 0 on success as appropriate.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     
  • The land of PCI power management is a land of sorrow and ugliness,
    especially in the area of signaling events by devices. There are
    devices that set their PME Status bits, but don't really bother
    to send a PME message or assert PME#. There are hardware vendors
    who don't connect PME# lines to the system core logic (they know
    who they are). There are PCI Express Root Ports that don't bother
    to trigger interrupts when they receive PME messages from the devices
    below. There are ACPI BIOSes that forget to provide _PRW methods for
    devices capable of signaling wakeup. Finally, there are BIOSes that
    do provide _PRW methods for such devices, but then don't bother to
    call Notify() for those devices from the corresponding _Lxx/_Exx
    GPE-handling methods. In all of these cases the kernel doesn't have
    a chance to receive a proper notification that it should wake up a
    device, so devices stay in low-power states forever. Worse yet, in
    some cases they continuously send PME Messages that are silently
    ignored, because the kernel simply doesn't know that it should clear
    the device's PME Status bit.

    This problem was first observed for "parallel" (non-Express) PCI
    devices on add-on cards and Matthew Garrett addressed it by adding
    code that polls PME Status bits of such devices, if they are enabled
    to signal PME, to the kernel. Recently, however, it has turned out
    that PCI Express devices are also affected by this issue and that it
    is not limited to add-on devices, so it seems necessary to extend
    the PME polling to all PCI devices, including PCI Express and planar
    ones. Still, it would be wasteful to poll the PME Status bits of
    devices that are known to receive proper PME notifications, so make
    the kernel (1) poll the PME Status bits of all PCI and PCIe devices
    enabled to signal PME and (2) disable the PME Status polling for
    devices for which correct PME notifications are received.

    Tested-by: Sarah Sharp
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

29 May, 2011

1 commit

  • _SxW returns an Integer containing the lowest D-state supported in state
    Sx. If OSPM has not indicated that it supports _PR3, then the value “3”
    corresponds to D3. If it has indicated _PR3 support, the value “3”
    represents D3hot and the value “4” represents D3cold.

    Linux does set _OSC._PR3, so we should fix it to expect that _SxW can
    return 4.

    Signed-off-by: Lin Ming
    Acked-by: Jesse Barnes
    Signed-off-by: Len Brown

    Lin Ming
     

25 Feb, 2011

1 commit

  • The wakeup.run_wake_count ACPI device field is only used by the PCI
    runtime PM code to "protect" devices from being prepared for
    generating wakeup signals more than once in a row. However, it
    really doesn't provide any protection, because (1) all of the
    functions it is supposed to protect use their own reference counters
    effectively ensuring that the device will be set up for generating
    wakeup signals just once and (2) the PCI runtime PM code uses
    wakeup.run_wake_count in a racy way, since nothing prevents
    acpi_dev_run_wake() from being called concurrently from two different
    threads for the same device.

    Remove the wakeup.run_wake_count ACPI device field which is
    unnecessary, confusing and used in a wrong way.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

15 Jan, 2011

1 commit


24 Dec, 2010

1 commit

  • We currently refuse to touch the ASPM registers if the BIOS tells us that
    ASPM isn't supported. This can cause problems if the BIOS has (for any
    reason) enabled ASPM on some devices anyway. Change the code such that we
    explicitly clear ASPM if the FADT indicates that ASPM isn't supported,
    and make sure we tidy up appropriately on device removal in order to deal
    with the hotplug case. If ASPM is disabled because the BIOS doesn't hand
    over control then we won't touch the registers.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Matthew Garrett
     

08 Aug, 2010

1 commit

  • * 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (27 commits)
    ACPI / ACPICA: Simplify acpi_ev_initialize_gpe_block()
    ACPI / ACPICA: Fail acpi_gpe_wakeup() if ACPI_GPE_CAN_WAKE is unset
    ACPI / ACPICA: Do not execute _PRW methods during initialization
    ACPI: Fix bogus GPE test in acpi_bus_set_run_wake_flags()
    ACPICA: Update version to 20100702
    ACPICA: Fix for Alias references within Package objects
    ACPICA: Fix lint warning for 64-bit constant
    ACPICA: Remove obsolete GPE function
    ACPICA: Update debug output components
    ACPICA: Add support for WDDT - Watchdog Descriptor Table
    ACPICA: Drop acpi_set_gpe
    ACPICA: Use low-level GPE enable during GPE block initialization
    ACPI / EC: Do not use acpi_set_gpe
    ACPI / EC: Drop suspend and resume routines
    ACPICA: Remove wakeup GPE reference counting which is not used
    ACPICA: Introduce acpi_gpe_wakeup()
    ACPICA: Rename acpi_hw_gpe_register_bit
    ACPICA: Update version to 20100528
    ACPICA: Add signatures for undefined tables: ATKG, GSCI, IEIT
    ACPICA: Optimization: Reduce the number of namespace walks
    ...

    Linus Torvalds
     

19 Jul, 2010

1 commit

  • One of the arguments during the suspend blockers discussion was that
    the mainline kernel didn't contain any mechanisms making it possible
    to avoid races between wakeup and system suspend.

    Generally, there are two problems in that area. First, if a wakeup
    event occurs exactly when /sys/power/state is being written to, it
    may be delivered to user space right before the freezer kicks in, so
    the user space consumer of the event may not be able to process it
    before the system is suspended. Second, if a wakeup event occurs
    after user space has been frozen, it is not generally guaranteed that
    the ongoing transition of the system into a sleep state will be
    aborted.

    To address these issues introduce a new global sysfs attribute,
    /sys/power/wakeup_count, associated with a running counter of wakeup
    events and three helper functions, pm_stay_awake(), pm_relax(), and
    pm_wakeup_event(), that may be used by kernel subsystems to control
    the behavior of this attribute and to request the PM core to abort
    system transitions into a sleep state already in progress.

    The /sys/power/wakeup_count file may be read from or written to by
    user space. Reads will always succeed (unless interrupted by a
    signal) and return the current value of the wakeup events counter.
    Writes, however, will only succeed if the written number is equal to
    the current value of the wakeup events counter. If a write is
    successful, it will cause the kernel to save the current value of the
    wakeup events counter and to abort the subsequent system transition
    into a sleep state if any wakeup events are reported after the write
    has returned.

    [The assumption is that before writing to /sys/power/state user space
    will first read from /sys/power/wakeup_count. Next, user space
    consumers of wakeup events will have a chance to acknowledge or
    veto the upcoming system transition to a sleep state. Finally, if
    the transition is allowed to proceed, /sys/power/wakeup_count will
    be written to and if that succeeds, /sys/power/state will be written
    to as well. Still, if any wakeup events are reported to the PM core
    by kernel subsystems after that point, the transition will be
    aborted.]

    Additionally, put a wakeup events counter into struct dev_pm_info and
    make these per-device wakeup event counters available via sysfs,
    so that it's possible to check the activity of various wakeup event
    sources within the kernel.

    To illustrate how subsystems can use pm_wakeup_event(), make the
    low-level PCI runtime PM wakeup-handling code use it.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Jesse Barnes
    Acked-by: Greg Kroah-Hartman
    Acked-by: markgross
    Reviewed-by: Alan Stern

    Rafael J. Wysocki