15 Sep, 2009

1 commit

  • In a number of cases, the .suspend, .freeze, .poweroff and .resume,
    .thaw, .restore functions are identical. However, they all need to be
    assigned to avoid regressionsm as the previous code called .suspend
    resp. .resume in all those cases. SIMPLE_DEV_PM_OPS helps to deal
    with this case.

    [rjw: Changed the name of the macro and added the comment explaining its
    purpose.]

    Signed-off-by: Albin Tonnerre
    Signed-off-by: Rafael J. Wysocki

    Albin Tonnerre
     

23 Aug, 2009

1 commit

  • Introduce a core framework for run-time power management of I/O
    devices. Add device run-time PM fields to 'struct dev_pm_info'
    and device run-time PM callbacks to 'struct dev_pm_ops'. Introduce
    a run-time PM workqueue and define some device run-time PM helper
    functions at the core level. Document all these things.

    Special thanks to Alan Stern for his help with the design and
    multiple detailed reviews of the pereceding versions of this patch
    and to Magnus Damm for testing feedback.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     

13 Jun, 2009

2 commits

  • This patch (as1241) renames a bunch of functions in the PM core.
    Rather than go through a boring list of name changes, suffice it to
    say that in the end we have a bunch of pairs of functions:

    device_resume_noirq dpm_resume_noirq
    device_resume dpm_resume
    device_complete dpm_complete
    device_suspend_noirq dpm_suspend_noirq
    device_suspend dpm_suspend
    device_prepare dpm_prepare

    in which device_X does the X operation on a single device and dpm_X
    invokes device_X for all devices in the dpm_list.

    In addition, the old dpm_power_up and device_resume_noirq have been
    combined into a single function (dpm_resume_noirq).

    Lastly, dpm_suspend_start and dpm_resume_end are the renamed versions
    of the former top-level device_suspend and device_resume routines.

    Signed-off-by: Alan Stern
    Acked-by: Magnus Damm
    Signed-off-by: Rafael J. Wysocki

    Alan Stern
     
  • Rename the functions performing "_noirq" dev_pm_ops
    operations from device_power_down() and device_power_up()
    to device_suspend_noirq() and device_resume_noirq().

    The new function names are chosen to show that the functions
    are responsible for calling the _noirq() versions to finalize
    the suspend/resume operation. The current function names do
    not perform power down/up anymore so the names may be misleading.

    Global function renames:
    - device_power_down() -> device_suspend_noirq()
    - device_power_up() -> device_resume_noirq()

    Static function renames:
    - suspend_device_noirq() -> __device_suspend_noirq()
    - resume_device_noirq() -> __device_resume_noirq()

    Signed-off-by: Magnus Damm
    Acked-by: Greg Kroah-Hartman
    Acked-by: Len Brown
    Signed-off-by: Rafael J. Wysocki

    Magnus Damm
     

25 Mar, 2009

1 commit

  • dpm_list currently relies on the fact that child devices will
    be registered after their parents to get a correct suspend
    order. Using device_move() however destroys this assumption, as
    an already registered device may be moved under a newly registered
    one.

    This patch adds a new argument to device_move(), allowing callers
    to specify how dpm_list should be adapted.

    Signed-off-by: Cornelia Huck
    Acked-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     

23 Feb, 2009

1 commit


07 Jan, 2009

2 commits

  • This patch (as1167) fixes some misspellings in various recently-added
    macros in pm.h. Fortunately these macros are not yet used anywhere.

    Signed-off-by: Alan Stern
    Acked-by: Rafael J. Wysocki

    Alan Stern
     
  • PM: Simplify the new suspend/hibernation framework for devices

    Following the discussion at the Kernel Summit, simplify the new
    device PM framework by merging 'struct pm_ops' and
    'struct pm_ext_ops' and removing pointers to 'struct pm_ext_ops'
    from 'struct platform_driver' and 'struct pci_driver'.

    After this change, the suspend/hibernation callbacks will only
    reside in 'struct device_driver' as well as at the bus type/
    device class/device type level. Accordingly, PCI and platform
    device drivers are now expected to put their suspend/hibernation
    callbacks into the 'struct device_driver' embedded in
    'struct pci_driver' or 'struct platform_driver', respectively.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Jesse Barnes
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

17 Oct, 2008

1 commit


25 Jul, 2008

4 commits


11 Jun, 2008

1 commit

  • Introduce 'struct pm_ops' and 'struct pm_ext_ops' ('ext' meaning
    'extended') representing suspend and hibernation operations for bus
    types, device classes, device types and device drivers.

    Modify the PM core to use 'struct pm_ops' and 'struct pm_ext_ops'
    objects, if defined, instead of the ->suspend(), ->resume(),
    ->suspend_late(), and ->resume_early() callbacks (the old callbacks
    will be considered as legacy and gradually phased out).

    The main purpose of doing this is to separate suspend (aka S2RAM and
    standby) callbacks from hibernation callbacks in such a way that the
    new callbacks won't take arguments and the semantics of each of them
    will be clearly specified. This has been requested for multiple
    times by many people, including Linus himself, and the reason is that
    within the current scheme if ->resume() is called, for example, it's
    difficult to say why it's been called (ie. is it a resume from RAM or
    from hibernation or a suspend/hibernation failure etc.?).

    The second purpose is to make the suspend/hibernation callbacks more
    flexible so that device drivers can handle more than they can within
    the current scheme. For example, some drivers may need to prevent
    new children of the device from being registered before their
    ->suspend() callbacks are executed or they may want to carry out some
    operations requiring the availability of some other devices, not
    directly bound via the parent-child relationship, in order to prepare
    for the execution of ->suspend(), etc.

    Ultimately, we'd like to stop using the freezing of tasks for suspend
    and therefore the drivers' suspend/hibernation code will have to take
    care of the handling of the user space during suspend/hibernation.
    That, in turn, would be difficult within the current scheme, without
    the new ->prepare() and ->complete() callbacks.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

30 Apr, 2008

1 commit


20 Apr, 2008

3 commits

  • This patch (as1058) improves the wakeup macros in include/linux/pm.h.
    All but the trivial ones are converted to inline routines, which
    requires moving them to a separate header file since they depend on
    the definition of struct device.

    Signed-off-by: Alan Stern
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • The various wakeup flags and their accessor macros in struct
    dev_pm_info should be available whenever CONFIG_PM is enabled, not
    just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always
    be configurable for runtime power management. This patch (as1056b)
    fixes the oversight.

    David Brownell adds:
    More accurately, fixes the "regression" ... as noted sometime
    last summer, after 296699de6bdc717189a331ab6bbe90e05c94db06
    introduced CONFIG_SUSPEND. But that didn't make the regression
    list for that kernel, ergo the delay in fixing it.

    [rjw: rebased]

    Signed-off-by: Alan Stern
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • Modify the PM core to protect its data structures, specifically the
    dpm_active list, from being corrupted if a child of the currently
    suspending device is registered concurrently with its ->suspend()
    callback. In that case, since the new device (the child) is added
    to dpm_active after its parent, the PM core will attempt to
    suspend it after the parent, which is wrong.

    Introduce a new member of struct dev_pm_info, called 'sleeping',
    and use it to check if the parent of the device being added to
    dpm_active has been suspended, in which case the device registration
    fails. Also, use 'sleeping' for checking if the ordering of devices
    on dpm_active is correct.

    Introduce variable 'all_sleeping' that will be set to 'true' once all
    devices have been suspended and make new device registrations fail
    until 'all_sleeping' is reset to 'false', in order to avoid having
    unsuspended devices around while the system is going into a sleep state.

    Remove pm_sleep_rwsem which is not necessary any more.

    Special thanks to Alan Stern for discussions and suggestions that
    lead to the creation of this patch.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

24 Feb, 2008

1 commit

  • During the last step of hibernation in the "platform" mode (with the
    help of ACPI) we use the suspend code, including the devices'
    ->suspend() methods, to prepare the system for entering the ACPI S4
    system sleep state.

    But at least for some devices the operations performed by the
    ->suspend() callback in that case must be different from its operations
    during regular suspend.

    For this reason, introduce the new PM event type PM_EVENT_HIBERNATE and
    pass it to the device drivers' ->suspend() methods during the last phase
    of hibernation, so that they can distinguish this case and handle it as
    appropriate. Modify the drivers that handle PM_EVENT_SUSPEND in a
    special way and need to handle PM_EVENT_HIBERNATE in the same way.

    These changes are necessary to fix a hibernation regression related
    to the i915 driver (ref. http://lkml.org/lkml/2008/2/22/488).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Tested-by: Jeff Chua
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

03 Feb, 2008

1 commit


12 Jan, 2008

1 commit

  • ACPI and APM used "pm_active" to guarantee that
    they would not be simultaneously active.

    But pm_active was recently moved under CONFIG_PM_LEGACY,
    so that without CONFIG_PM_LEGACY, pm_active became a NOP --
    allowing ACPI and APM to both be simultaneously enabled.
    This caused unpredictable results, including boot hangs.

    Further, the code under CONFIG_PM_LEGACY is scheduled
    for removal.

    So replace pm_active with pm_flags.
    pm_flags depends only on CONFIG_PM,
    which is present for both CONFIG_APM and CONFIG_ACPI.

    http://bugzilla.kernel.org/show_bug.cgi?id=9194

    Signed-off-by: Len Brown
    Signed-off-by: Rafael J. Wysocki

    Len Brown
     

19 Oct, 2007

1 commit

  • Move the definition of 'struct pm_ops' and related functions from
    to .

    There are, at least, the following reasons to do that:
    * 'struct pm_ops' is specifically related to suspend and not to the power
    management in general.
    * As long as 'struct pm_ops' is defined in , any modification of it
    causes the entire kernel to be recompiled, which is unnecessary and annoying.
    * Some suspend-related features are already defined in , so it
    is logical to move the definition of 'struct pm_ops' into there.
    * 'struct hibernation_ops', being the hibernation-related counterpart of
    'struct pm_ops', is defined in .

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Len Brown
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

31 Jul, 2007

1 commit


30 Jul, 2007

1 commit

  • Introduce CONFIG_SUSPEND representing the ability to enter system sleep
    states, such as the ACPI S3 state, and allow the user to choose SUSPEND
    and HIBERNATION independently of each other.

    Make HOTPLUG_CPU be selected automatically if SUSPEND or HIBERNATION has
    been chosen and the kernel is intended for SMP systems.

    Also, introduce CONFIG_PM_SLEEP which is automatically selected if
    CONFIG_SUSPEND or CONFIG_HIBERNATION is set and use it to select the
    code needed for both suspend and hibernation.

    The top-level power management headers and the ACPI code related to
    suspend and hibernation are modified to use the new definitions (the
    changes in drivers/acpi/sleep/main.c are, mostly, moving code to reduce
    the number of ifdefs).

    There are many other files in which CONFIG_PM can be replaced with
    CONFIG_PM_SLEEP or even with CONFIG_SUSPEND, but they can be updated in
    the future.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

20 Jul, 2007

1 commit

  • Introduce the pm_power_off_prepare() callback that can be registered by the
    interested platforms in analogy with pm_idle() and pm_power_off(), used for
    preparing the system to power off (needed by ACPI).

    This allows us to drop acpi_sysclass and device_acpi that are only defined in
    order to register the ACPI power off preparation callback, which is needed by
    pm_power_off() registered in a much different way.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

19 Jul, 2007

1 commit

  • This patch (as933) removes the deprecated dpm_runtime_suspend() and
    dpm_runtime_resume() routines from the PM core. The only user of
    those routines is the PCMCIA ds driver; local replacements are added.

    Signed-off-by: Alan Stern
    CC: Dominik Brodowski
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

12 Jul, 2007

3 commits

  • The prev_state member of struct dev_pm_info (defined in include/linux/pm.h) is
    only used during a resume to check if the device's state before the suspend was
    'off', in which case the device is not resumed. However, in such cases the
    decision whether or not to resume the device should be made on the driver level
    and the resume callbacks from the device's bus and class should be executed
    anyway (the may be needed for some things other than just powering on the
    device).

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • The saved_state member of struct dev_pm_info, defined in include/linux/pm.h, is
    not used anywhere, so it can be removed.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • The pm_parent member of struct dev_pm_info (defined in include/linux/pm.h) is
    only used to check if the device's parent is in the right state while the
    device is being suspended or resumed. However, this can be done just as well
    with the help of the parent pointer in struct device, so pm_parent can be
    removed along with some code that handles it.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: David Brownell
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

02 Jul, 2007

1 commit

  • Commit 52ade9b3b97fd3bea42842a056fe0786c28d0555 changed the suspend code
    ordering to execute pm_ops->prepare() after the device model per-device
    .suspend() calls in order to fix some ACPI-related issues. Unfortunately, it
    broke the at91 platform which assumed that pm_ops->prepare() would be called
    before suspending devices.

    at91 used pm_ops->prepare() to get notified of the target system sleep state,
    so that it could use this information while suspending devices. However, with
    the current suspend code ordering pm_ops->prepare() is called too late for
    this purpose. Thus, at91 needs an additional method in 'struct pm_ops' that
    will be used for notifying the platform of the target system sleep state.
    Moreover, in the future such a method will also be needed by ACPI.

    This patch adds the .set_target() method to 'struct pm_ops' and makes the
    suspend code call it, if implemented, before executing the device model
    per-device .suspend() calls. It also modifies the at91 code to use
    pm_ops->set_target() instead of pm_ops->prepare().

    Signed-off-by: Rafael J. Wysocki
    Acked-by: David Brownell
    Cc: Pavel Machek
    Cc: Johannes Berg
    Cc: Len Brown
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

10 May, 2007

1 commit

  • [ With Johannes Berg ]

    Separate the hibernation (aka suspend to disk code) from the other suspend
    code. In particular:

    * Remove the definitions related to hibernation from include/linux/pm.h
    * Introduce struct hibernation_ops and a new hibernate() function to hibernate
    the system, defined in include/linux/suspend.h
    * Separate suspend code in kernel/power/main.c from hibernation-related code
    in kernel/power/disk.c and kernel/power/user.c (with the help of
    hibernation_ops)
    * Switch ACPI (the only user of pm_ops.pm_disk_mode) to hibernation_ops

    Signed-off-by: Rafael J. Wysocki
    Cc: Greg KH
    Cc: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

01 May, 2007

5 commits

  • For backwards compatibility, call_platform_enable_wakeup() can return 0
    instead of -EIO since we aren't guaranteed to have errno defined.

    Cc: David Brownell
    Signed-off-by: David Rientjes
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • This patch changes the docs and behaviour from "all states valid" to "no
    states valid" if no .valid callback is assigned. Users of pm_ops that only
    need mem sleep can assign pm_valid_only_mem without any overhead, others
    will require more elaborate callbacks.

    Now that all users of pm_ops have a .valid callback this is a safe thing to
    do and prevents things from getting messy again as they were before.

    Signed-off-by: Johannes Berg
    Acked-by: Pavel Machek
    Looks-okay-to: Rafael J. Wysocki
    Cc:
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     
  • Almost all users of pm_ops only support mem sleep, don't check in .valid and
    don't reject any others in .prepare so users can be confused if they check
    /sys/power/state, especially when new states are added (these would then
    result in s-t-r although they're supposed to be something different).

    This patch implements a generic pm_valid_only_mem function that is then
    exported for users and puts it to use in almost all existing pm_ops.

    Signed-off-by: Johannes Berg
    Cc: David Brownell
    Acked-by: Pavel Machek
    Cc: linux-pm@lists.linux-foundation.org
    Cc: Len Brown
    Acked-by: Russell King
    Cc: Greg KH
    Cc: "Rafael J. Wysocki"
    Cc: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     
  • This patch removes the firmware disk suspend mode which is the wrong approach,
    it is supposed to be used for implementing firmware-based disk suspend but
    cannot actually be used for that.

    Signed-off-by: Johannes Berg
    Acked-by: Pavel Machek
    Cc:
    Cc: David Brownell
    Cc: Len Brown
    Acked-by: Russell King
    Cc: Greg KH
    Cc: "Rafael J. Wysocki"
    Cc: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     
  • This patch series cleans up some misconceptions about pm_ops. Some users of
    the pm_ops structure attempt to use it to stop the user from entering suspend
    to disk, this, however, is not possible since the user can always use
    "shutdown" in /sys/power/disk and then the pm_ops are never invoked. Also,
    platforms that don't support suspend to disk simply should not allow
    configuring SOFTWARE_SUSPEND (read the help text on it, it only selects
    suspend to disk and nothing else, all the other stuff depends on PM).

    The pm_ops structure is actually intended to provide a way to enter
    platform-defined sleep states (currently supported states are "standby" and
    "mem" (suspend to ram)) and additionally (if SOFTWARE_SUSPEND is configured)
    allows a platform to support a platform specific way to enter low-power mode
    once everything has been saved to disk. This is currently only used by ACPI
    (S4).

    This patch:

    The pm_ops.pm_disk_mode is used in totally bogus ways since nobody really
    seems to understand what it actually does.

    This patch clarifies the pm_disk_mode description.

    It also removes all the arm and sh users that think they can veto suspend to
    disk via pm_ops; not so since the user can always do echo shutdown >
    /sys/power/disk, they need to find a better way involving Kconfig or such.

    ACPI is the only user left with a non-zero pm_disk_mode.

    The patch also sets the default mode to shutdown again, but when a new pm_ops
    is registered its pm_disk_mode is selected as default, that way the default
    stays for ACPI where it is apparently required.

    Signed-off-by: Johannes Berg
    Cc: David Brownell
    Acked-by: Pavel Machek
    Cc:
    Cc: Len Brown
    Acked-by: Russell King
    Cc: Greg KH
    Cc: "Rafael J. Wysocki"
    Acked-by: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     

28 Apr, 2007

2 commits

  • After some more discussion this patch replaces it:

    From: Johannes Berg
    Subject: suspend: add arch irq disable/enable hooks

    For powermac, we need to do some things between suspending devices and
    device_power_off, for example setting the decrementer. This patch
    allows architectures to define arch_s2ram_{en,dis}able_irqs in their
    asm/suspend.h to have control over this step.

    Signed-off-by: Johannes Berg
    Acked-by: Pavel Machek
    Cc: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • This defines a platform hook to enable/disable a device as a wakeup event
    source. It's initially for use with ACPI, but more generally it could be used
    whenever enable_irq_wake()/disable_irq_wake() don't suffice.

    The hook is called -- if available -- inside pci_enable_wake(); and the
    semantics of that call are enhanced so that support for PCI PME# is no longer
    needed. It can now work for devices with "legacy PCI PM", when platform
    support allows it. (That support would use some board-specific signal for for
    the same purpose as PME#.)

    [akpm@linux-foundation.org: Make it compile with CONFIG_PM=n]
    Signed-off-by: David Brownell
    Signed-off-by: Zhang Rui
    Cc: Len Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

24 Feb, 2007

1 commit

  • Because the pm ops in powermac are obviously not using them as intended, I
    added documentation for it in kernel-doc format.

    Reordering the fields in struct pm_ops not only makes the output of kernel-doc
    make more sense but also removes a hole from the structure on 64-bit
    platforms.

    Signed-off-by: Johannes Berg
    Cc: "Randy.Dunlap"
    Cc: Rafael J. Wysocki
    Cc: Pavel Macheck
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     

04 Nov, 2006

1 commit

  • Add a swsusp debugging mode. This does everything that's needed for a suspend
    except for actually suspending. So we can look in the log messages and work
    out a) what code is being slow and b) which drivers are misbehaving.

    (1)
    # echo testproc > /sys/power/disk
    # echo disk > /sys/power/state

    This should turn off the non-boot CPU, freeze all processes, wait for 5
    seconds and then thaw the processes and the CPU.

    (2)
    # echo test > /sys/power/disk
    # echo disk > /sys/power/state

    This should turn off the non-boot CPU, freeze all processes, shrink
    memory, suspend all devices, wait for 5 seconds, resume the devices etc.

    Cc: Pavel Machek
    Cc: Stefan Seyfried
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki