15 Nov, 2007

1 commit

  • Lockdep reports a circular locking dependency in the hibernate code
    because
    - during system boot hibernate code (from an initcall) locks pm_mutex
    and then a sysfs buffer mutex via name_to_dev_t
    - during regular operation hibernate code locks pm_mutex under a
    sysfs buffer mutex because it's called from sysfs methods.

    The deadlock can never happen because during initcall invocation nothing
    can write to sysfs yet. This removes the lockdep report by marking the
    initcall locking as being in a different class.

    Signed-off-by: Johannes Berg
    Cc: "Rafael J. Wysocki"
    Cc: Alan Stern
    Acked-by: Peter Zijlstra
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     

19 Oct, 2007

5 commits

  • Make hibernation_platform_enter() execute the enter-a-sleep-state sequence
    instead of the mixed shutdown-with-entering-S4 thing.

    Replace the shutting down of devices done by kernel_shutdown_prepare(), before
    entering the ACPI S4 sleep state, with suspending them and the shutting down
    of sysdevs with calling device_power_down(PMSG_SUSPEND) (just like before
    entering S1 or S3, but the target state is now S4).  Also, disable the
    nonboot CPUs before entering the sleep state (S4), which generally always is a
    good idea.

    This is known to fix the "double disk spin down during hibernation" on some
    machines, eg. HPC nx6325 (ref. http://lkml.org/lkml/2007/8/7/316 and the
    following thread).  Moreover, it has been reported to make
    /sys/class/rtc/rtc0/wakealarm work correctly with hibernation for some users.
    It also generally causes the hibernation state (ACPI S4) to be entered faster.

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

    Rafael J. Wysocki
     
  • The following scenario leads to total confusion of the platform firmware on
    some boxes (eg. HPC nx6325):
    * Hibernate with ACPI enabled
    * Resume passing "acpi=off" to the boot kernel

    To prevent this from happening it's necessary to check if ACPI is enabled (and
    enable it if that's not the case) _right_ _after_ control has been transfered
    from the boot kernel to the image kernel, before device_power_up() is called
    (ie. with interrupts disabled).  Enabling ACPI after calling
    device_power_up() turns out to be insufficient.

    For this reason, introduce new hibernation callback ->leave() that will be
    executed before device_power_up() by the restored image kernel.  To make it
    work, it also is necessary to move swsusp_suspend() from swsusp.c to disk.c
    (it's name is changed to "create_image", which is more up to the point).

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

    Rafael J. Wysocki
     
  • The syncing of filesystems from within the freezer is generally not needed.
    Also, if there's an ext3 filesystem loopback-mounted from a FUSE one, the
    syncing results in writes to it and deadlocks. Similarly, it will deadlock if
    FUSE implements sync.

    Change freeze_processes() so that it doesn't execute sys_sync() and make the
    suspend and hibernation code path sync filesystems independently of the
    freezer.

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

    Rafael J. Wysocki
     
  • Rename 'struct hibernation_ops' to 'struct platform_hibernation_ops' in
    analogy with 'struct platform_suspend_ops'.

    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
     
  • During hibernation we also need to tell the ACPI core that we're going to put
    the system into the S4 sleep state. For this reason, an additional method in
    'struct hibernation_ops' is needed, playing the role of set_target() in
    'struct platform_suspend_operations'. Moreover, the role of the .prepare()
    method is now different, so it's better to introduce another method, that in
    general may be different from .prepare(), that will be used to prepare the
    platform for creating the hibernation image (.prepare() is used anyway to
    notify the platform that we're going to enter the low power state after the
    image has been saved).

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

    Rafael J. Wysocki
     

27 Jul, 2007

1 commit

  • Commit bd804eba1c8597cbb7cd5a5f9fe886aae16a079a ("PM: Introduce
    pm_power_off_prepare") caused problems in the poweroff path, as reported by
    YOSHIFUJI Hideaki / 吉藤英明.

    Generally, sysdev_shutdown() should be called after the ACPI preparation for
    powering the system off. To make it happen, we can separate sysdev_shutdown()
    from device_shutdown() and call it directly wherever necessary.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: YOSHIFUJI Hideaki / 吉藤英明
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

20 Jul, 2007

5 commits

  • Make it possible to register hibernation and suspend notifiers, so that
    subsystems can perform hibernation-related or suspend-related operations that
    should not be carried out by device drivers' .suspend() and .resume()
    routines.

    [akpm@linux-foundation.org: build fixes]
    [akpm@linux-foundation.org: cleanups]
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • During hibernation we call hibernation_ops->prepare() before creating the image,
    but then, before saving it, we cancel the power transition by calling
    hibernation_ops->finish(). Thus prior to calling hibernation_ops->enter() we
    should let the platform firmware know that we're going to enter the low power
    state after all.

    Signed-off-by: Rafael J. Wysocki
    Cc: Gautham R Shenoy
    Cc: Pavel Machek
    Cc: Nigel Cunningham
    Cc: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Change the code ordering so that hibernation_ops->prepare() is called after
    device_suspend(). This is needed so that we don't violate the ACPI
    specification, which states that the _PTS and _GTS system-control methods,
    executed from acpi_sleep_prepare(), ought to be called after devices have been
    put in low power states.

    The "Finish" label in hibernation_restore() is moved, because device_suspend()
    resumes devices if the suspending of them fails and the restore code ordering
    should reflect the hibernation code ordering.

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

    Rafael J. Wysocki
     
  • At least on some machines it is necessary to prepare the ACPI firmware for the
    restoration of the system memory state from the hibernation image if the
    "platform" mode of hibernation has been used. Namely, in that cases we need
    to disable the GPEs before replacing the "boot" kernel with the "frozen"
    kernel (cf. http://bugzilla.kernel.org/show_bug.cgi?id=7887). After the
    restore they will be re-enabled by hibernation_ops->finish(), but if the
    restore fails, they have to be re-enabled by the restore code explicitly.

    For this purpose we can introduce two additional hibernation operations,
    called pre_restore() and restore_cleanup() and call them from the restore code
    path. Still, they should be called if the "platform" mode of hibernation has
    been used, so we need to pass the information about the hibernation mode from
    the "frozen" kernel to the "boot" kernel in the image header.

    Apparently, we can't drop the disabling of GPEs before the restore because of
    Bug #7887 .  We also can't do it unconditionally, because the GPEs wouldn't
    have been enabled after a successful restore if the suspend had been done in
    the 'shutdown' or 'reboot' mode.

    In principle we could (and probably should) unconditionally disable the GPEs
    before each snapshot creation *and* before the restore, but then we'd have to
    unconditionally enable them after the snapshot creation as well as after the
    restore (or restore failure)   Still, for this purpose we'd need to modify
    acpi_enter_sleep_state_prep() and acpi_leave_sleep_state() and we'd have to
    introduce some mechanism synchronizing the disablind/enabling of the GPEs with
    the device drivers' .suspend()/.resume() routines and with
    disable_/enable_nonboot_cpus().  However, this would have affected the
    suspend (ie. s2ram) code as well as the hibernation, which I'd like to avoid
    in this patch series.

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

    Rafael J. Wysocki
     
  • Currently, much of the code in kernel/power/disk.c is duplicated in
    kernel/power/user.c , mainly for historical reasons. By eliminating this code
    duplication we can reduce the size of user.c quite substantially and remove
    the maintenance difficulty resulting from it.

    [bunk@stusta.de: kernel/power/disk.c: make code static]
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

17 May, 2007

1 commit

  • The sysfs files /sys/power/disk and /sys/power/state do not work as
    documented, since they allow the user to write only a few initial
    characters of the input string to trigger the option (eg. 'echo pl >
    /sys/power/disk' activates the platform mode of hibernation). Fix it.

    Special thanks to Peter Moulder for
    pointing out the problem.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    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
     

08 May, 2007

3 commits

  • Change /sys/power/disk to display all valid modes as well as the currently
    selected one in a fashion known from the LED subsystem.

    This changes userspace API, but it is apparently not used much (we asked
    some userspace developers)

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

    Johannes Berg
     
  • Make swsusp call create_basic_memory_bitmaps() before processes are frozen, so
    that GFP_KERNEL allocations can be made in it. Additionally, ensure that the
    swsusp's userland interface won't be used while either pm_suspend_disk() or
    software_resume() is being executed.

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

    Rafael J. Wysocki
     
  • Make swsusp use memory bitmaps instead of page flags for marking 'nosave' and
    free pages. This allows us to 'recycle' two page flags that can be used for
    other purposes. Also, the memory needed to store the bitmaps is allocated
    when necessary (ie. before the suspend) and freed after the resume which is
    more reasonable.

    The patch is designed to minimize the amount of changes and there are some
    nice simplifications and optimizations possible on top of it. I am going to
    implement them separately in the future.

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

    Rafael J. Wysocki
     

03 May, 2007

1 commit


01 May, 2007

2 commits

  • 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 Mar, 2007

1 commit

  • This reverts commit 94985134b7b46848267ed6b734320db01c974e72 and
    insteads removes the WARN_ON() that caused that commit in the first
    place.

    The problem is that we call disable_nonboot_cpus() in swsusp before
    powering down the system in order to avoid triggering the WARN_ON()
    in arch/x86_64/kernel/acpi/sleep.c:init_low_mapping() and this doesn't
    work well on Thomas' system.

    So instead, remove the WARN_ON() in arch/x86_64/kernel/acpi/sleep.c:
    init_low_mapping(), which triggers every time during the suspend to disk
    in the platform mode, as the potential problem it is related to doesn't
    seem to occur in practice.

    [ I think we might want to disallow the case of multiple users of that
    mm, or something. Normally, playing with the current process page
    tables on the current CPU should be fine as long as we don't have
    other threads using those tables at the same time..

    Anyway, not pretty, but better than the warning or the lockup - Linus ]

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

    Rafael J. Wysocki
     

23 Mar, 2007

1 commit

  • It causes extra moon icons blinking on x60, and breaks at least two other
    systems.

    During resume, we do not know that "reboot"/"shutdown" method was used, so
    we assume "plaform" and call BIOS, anyway...

    This is 2.6.21 material, and should fix 2 or 3 regressions from 2.6.20.

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

    Pavel Machek
     

17 Mar, 2007

2 commits


12 Feb, 2007

1 commit

  • Change the ordering of code in kernel/power/disk.c so that device_suspend() is
    called before disable_nonboot_cpus() and platform_finish() is called after
    enable_nonboot_cpus() and before device_resume(), as indicated by the recent
    discussion on Linux-PM (cf.
    http://lists.osdl.org/pipermail/linux-pm/2006-November/004164.html).

    The changes here only affect the built-in swsusp.

    [alexey.y.starikovskiy@linux.intel.com: fix LED blinking during image load]
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Greg KH
    Cc: Nigel Cunningham
    Cc: Patrick Mochel
    Cc: Alexey Starikovskiy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

16 Dec, 2006

1 commit


08 Dec, 2006

7 commits

  • Cleanup write-only variable, suggested by D Binderman.

    Signed-off-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pavel Machek
     
  • The 'testproc' swsusp debug mode thaws tasks twice in a row, which is _very_
    confusing. Fix that.

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

    Rafael J. Wysocki
     
  • Move all labels in the swsusp code to the second column, so that they won't
    fool diff -p.

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

    Rafael J. Wysocki
     
  • The power management semaphore is only used as mutex, so convert it.

    [akpm@osdl.org: fix rotten bug]
    Signed-off-by: Stephen Hemminger
    Acked-by: Ingo Molnar
    Acked-by: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Hemminger
     
  • Move process freezing functions from include/linux/sched.h to freezer.h, so
    that modifications to the freezer or the kernel configuration don't require
    recompiling just about everything.

    [akpm@osdl.org: fix ueagle driver]
    Signed-off-by: Nigel Cunningham
    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nigel Cunningham
     
  • At some point after 2.6.13, in-kernel software suspend got "incomplete" for
    the so-called "platform" mode. pm_ops->prepare() is never called. A
    visible sign of this is the "moon" light on thinkpads not flashing during
    suspend. Fix by readding the pm_ops->prepare call during suspend.

    Signed-off-by: Stefan Seyfried
    Acked-by: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stefan Seyfried
     
  • Add the kernel command line parameter "resume_offset=" allowing us to specify
    the offset, in units, from the beginning of the partition pointed
    to by the "resume=" parameter at which the swap header is located.

    This offset can be determined, for example, by an application using the FIBMAP
    ioctl to obtain the swap header's block number for given file.

    [akpm@osdl.org: we don't know what type sector_t is]
    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

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
     

02 Nov, 2006

1 commit

  • It has been reported that on some systems the functionality after a resume
    from disk is limited if the system is simply powered off during the suspend
    instead of using the ACPI S4 suspend (aka platform mode).

    Unfortunately the default is currently to power off the system during the
    suspend so the users of these systems experience problems after the resume
    if they don't switch to the platform mode explicitly. This patch makes swsusp
    use the platform mode by default to avoid such situations.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Stefan Seyfried
    Acked-by: Pavel Machek
    Signed-off-by: Len Brown

    Rafael J. Wysocki
     

12 Oct, 2006

1 commit

  • Add suspend_console() and resume_console() to the suspend-to-disk code paths
    so that the users of netconsole can use swsusp with it.

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

    Rafael J. Wysocki
     

27 Sep, 2006

1 commit

  • * master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (47 commits)
    Driver core: Don't call put methods while holding a spinlock
    Driver core: Remove unneeded routines from driver core
    Driver core: Fix potential deadlock in driver core
    PCI: enable driver multi-threaded probe
    Driver Core: add ability for drivers to do a threaded probe
    sysfs: add proper sysfs_init() prototype
    drivers/base: check errors
    drivers/base: Platform notify needs to occur before drivers attach to the device
    v4l-dev2: handle __must_check
    add CONFIG_ENABLE_MUST_CHECK
    add __must_check to device management code
    Driver core: fixed add_bind_files() definition
    Driver core: fix comments in drivers/base/power/resume.c
    sysfs_remove_bin_file: no return value, dump_stack on error
    kobject: must_check fixes
    Driver core: add ability for devices to create and remove bin files
    Class: add support for class interfaces for devices
    Driver core: create devices/virtual/ tree
    Driver core: add device_rename function
    Driver core: add ability for classes to handle devices properly
    ...

    Linus Torvalds
     

26 Sep, 2006

2 commits

  • The current suspend code has to be run on one CPU, so we use the CPU
    hotplug to take the non-boot CPUs offline on SMP machines. However, we
    should also make sure that these CPUs will not be enabled by someone else
    after we have disabled them.

    The functions disable_nonboot_cpus() and enable_nonboot_cpus() are moved to
    kernel/cpu.c, because they now refer to some stuff in there that should
    better be static. Also it's better if disable_nonboot_cpus() returns an
    error instead of panicking if something goes wrong, and
    enable_nonboot_cpus() has no reason to panic(), because the CPUs may have
    been enabled by the userland before it tries to take them online.

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

    Rafael J. Wysocki
     
  • This patch is the first of this series that should actually change any
    behavior ... by issuing the new event, now tha the rest of the kernel is
    prepared to receive it.

    This converts the PM core to issue the new PRETHAW message, which the rest of
    the kernel is now ready to receive.

    Signed-off-by: David Brownell
    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

26 Jun, 2006

1 commit