03 Nov, 2014

1 commit

  • This patch migrates swsusp_show_speed and its callers to using ktime_t instead
    of 'struct timeval' which suffers from the y2038 problem.

    Changes to swsusp_show_speed:
    - use ktime_t for start and stop times
    - pass start and stop times by value
    Calling functions affected:
    - load_image
    - load_image_lzo
    - save_image
    - save_image_lzo
    - hibernate_preallocate_memory
    Design decisions:
    - use ktime_t to preserve same granularity of reporting as before
    - use centisecs logic as before to avoid 'div by zero' issues caused by
    using seconds and nanoseconds directly
    - use monotonic time (ktime_get()) since we only care about elapsed time.

    Signed-off-by: Tina Ruchandani
    Suggested-by: Arnd Bergmann
    Reviewed-by: Arnd Bergmann
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Tina Ruchandani
     

28 Oct, 2014

1 commit

  • If a device's dev_pm_ops::freeze callback fails during the QUIESCE
    phase, we don't rollback things correctly calling the thaw and complete
    callbacks. This could leave some devices in a suspended state in case of
    an error during resuming from hibernation.

    Signed-off-by: Imre Deak
    Cc: All applicable
    Signed-off-by: Rafael J. Wysocki

    Imre Deak
     

17 Jul, 2014

1 commit

  • ftrace_stop() and ftrace_start() were added to the suspend and hibernate
    process because there was some function within the work flow that caused
    the system to reboot if it was traced. This function has recently been
    found (restore_processor_state()). Now there's no reason to disable
    function tracing while we are going into suspend or hibernate, which means
    that being able to trace this will help tremendously in debugging any
    issues with suspend or hibernate.

    This also means that the ftrace_stop/start() functions can be removed
    and simplify the function tracing code a bit.

    Link: http://lkml.kernel.org/r/1518201.VD9cU33jRU@vostro.rjw.lan

    Acked-by: "Rafael J. Wysocki"
    Reviewed-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

17 Jun, 2014

2 commits

  • Changes kASLR from being compile-time selectable (blocked by
    CONFIG_HIBERNATION), to being boot-time selectable (with hibernation
    available by default) via the "kaslr" kernel command line.

    Signed-off-by: Kees Cook
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Kees Cook
     
  • To support using kernel features that are not compatible with hibernation,
    this creates the "nohibernate" kernel boot parameter to disable both
    hibernation and resume. This allows hibernation support to be a boot-time
    choice instead of only a compile-time choice.

    Signed-off-by: Kees Cook
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Kees Cook
     

07 Jun, 2014

1 commit

  • Adds trace events that give finer resolution into suspend/resume. These
    events are graphed in the timelines generated by the analyze_suspend.py
    script. They represent large areas of time consumed that are typical to
    suspend and resume.

    The event is triggered by calling the function "trace_suspend_resume"
    with three arguments: a string (the name of the event to be displayed
    in the timeline), an integer (case specific number, such as the power
    state or cpu number), and a boolean (where true is used to denote the start
    of the timeline event, and false to denote the end).

    The suspend_resume trace event reproduces the data that the machine_suspend
    trace event did, so the latter has been removed.

    Signed-off-by: Todd Brandt
    Acked-by: Steven Rostedt
    Signed-off-by: Rafael J. Wysocki

    Todd E Brandt
     

17 May, 2014

1 commit

  • In the original code "resume_delay" is an int so on 64 bits, the call to
    kstrtoul() will cause memory corruption. We may as well fix a style
    issue here as well and make "resume_delay" unsigned int, since that's
    what we pass to ssleep().

    Fixes: 317cf7e5e85e (PM / hibernate: convert simple_strtoul to kstrtoul)
    Signed-off-by: Dan Carpenter
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Dan Carpenter
     

10 May, 2014

1 commit


01 May, 2014

1 commit

  • Reboot logic in kernel/reboot will avoid calling kernel_power_off
    when pm_power_off is null, and instead uses kernel_halt. Change
    hibernate's power_down to follow the behavior in the reboot call.

    Calling the notifier twice (once for SYS_POWER_OFF and again for
    SYS_HALT) causes a panic during hibernation on Kirkwood
    Openblocks A6 board.

    Signed-off-by: Sebastian Capella
    Reported-by: Ezequiel Garcia
    Reviewed-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Sebastian Capella
     

28 Apr, 2014

1 commit

  • do_div() needs 'u64' type, or it reports warning. And negative number
    is meaningless for "speed", so change all signed to unsigned within
    swsusp_show_speed().

    The related warning (with allmodconfig for unicore32):

    CC kernel/power/hibernate.o
    kernel/power/hibernate.c: In function ‘swsusp_show_speed’:
    kernel/power/hibernate.c:237: warning: comparison of distinct pointer types lacks a cast

    Signed-off-by: Chen Gang
    [rjw: Subject]
    Signed-off-by: Rafael J. Wysocki

    Chen Gang
     

01 Mar, 2014

1 commit

  • Use the name_to_dev_t call to parse the device name echo'd to
    to /sys/power/resume. This imitates the method used in hibernate.c
    in software_resume, and allows the resume partition to be specified
    using other equivalent device formats as well. By allowing
    /sys/debug/resume to accept the same syntax as the resume=device
    parameter, we can parse the resume=device in the init script and
    use the resume device directly from the kernel command line.

    Signed-off-by: Sebastian Capella
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Sebastian Capella
     

06 Jan, 2014

1 commit

  • Since create_image() only executes platform_leave() if in_suspend is
    not set, enable_nonboot_cpus() is run by it with EC transactions
    blocked (on ACPI systems) in the image creation code path (that is,
    for in_suspend set), which may cause CPU online to fail for the CPUs
    in question. In particular, this causes the acpi_cpufreq driver's
    initialization to fail for those CPUs on some systems with the
    following dmesg:

    cpufreq: adding CPU 1
    acpi_cpufreq_cpu_init
    cpufreq: FREQ: 1401000 - CPU: 0
    ACPI Exception: AE_BAD_PARAMETER, Returned by Handler for [EmbeddedControl] (20130725/evregion-287)
    ACPI Error: Method parse/execution failed [\_SB_.PCI0.LPC_.EC__.LPMD] (Node ffff88023249ab28), AE_BAD_PARAMETER (20130725/psparse-536)
    ACPI Error: Method parse/execution failed [\_PR_.CPU0._PPC] (Node ffff88023270e3f8), AE_BAD_PARAMETER (20130725/psparse-536)
    ACPI Error: Method parse/execution failed [\_PR_.CPU1._PPC] (Node ffff88023270e290), AE_BAD_PARAMETER (20130725/psparse-536)
    ACPI Exception: AE_BAD_PARAMETER, Evaluating _PPC (20130725/processor_perflib-140)
    cpufreq: initialization failed
    CPU1 is up

    To fix this problem, modify create_image() to execute platform_leave()
    unconditionally. [rjw: This shouldn't lead to any significant side
    effects on ACPI systems.]

    Signed-off-by: Bjørn Mork
    [rjw: Changelog]
    Signed-off-by: Rafael J. Wysocki

    Bjørn Mork
     

30 Nov, 2013

1 commit

  • To support the ability to implement PM hibernation code as modules
    the hibernation_set_ops function requires to be exported.

    Similar solution already available for suspend_set_ops
    (please refer to commit a5e4fd8783a2bec861ecf1138cdc042269ff59aa).

    Signed-off-by: Leonardo Potenza
    Signed-off-by: Edwin Verplanke
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Rafael J. Wysocki

    Leonardo Potenza
     

25 Oct, 2013

1 commit

  • software_resume is being called after deferred_probe_initcall in
    drivers base. If the probing of the device that contains the resume
    image is deferred, and the system has been instructed to wait for
    it to show up, this wait will occur in software_resume. This causes
    a deadlock.

    Move software_resume into late_initcall_sync so that it happens
    after all the other late_initcalls.

    Signed-off-by: Russ Dill
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Russ Dill
     

13 Sep, 2013

1 commit

  • Pull ACPI and power management fixes from Rafael Wysocki:
    "All of these commits are fixes that have emerged recently and some of
    them fix bugs introduced during this merge window.

    Specifics:

    1) ACPI-based PCI hotplug (ACPIPHP) fixes related to spurious events

    After the recent ACPIPHP changes we've seen some interesting
    breakage on a system that triggers device check notifications
    during boot for non-existing devices. Although those
    notifications are really spurious, we should be able to deal with
    them nevertheless and that shouldn't introduce too much overhead.
    Four commits to make that work properly.

    2) Memory hotplug and hibernation mutual exclusion rework

    This was maent to be a cleanup, but it happens to fix a classical
    ABBA deadlock between system suspend/hibernation and ACPI memory
    hotplug which is possible if they are started roughly at the same
    time. Three commits rework memory hotplug so that it doesn't
    acquire pm_mutex and make hibernation use device_hotplug_lock
    which prevents it from racing with memory hotplug.

    3) ACPI Intel LPSS (Low-Power Subsystem) driver crash fix

    The ACPI LPSS driver crashes during boot on Apple Macbook Air with
    Haswell that has slightly unusual BIOS configuration in which one
    of the LPSS device's _CRS method doesn't return all of the
    information expected by the driver. Fix from Mika Westerberg, for
    stable.

    4) ACPICA fix related to Store->ArgX operation

    AML interpreter fix for obscure breakage that causes AML to be
    executed incorrectly on some machines (observed in practice).
    From Bob Moore.

    5) ACPI core fix for PCI ACPI device objects lookup

    There still are cases in which there is more than one ACPI device
    object matching a given PCI device and we don't choose the one
    that the BIOS expects us to choose, so this makes the lookup take
    more criteria into account in those cases.

    6) Fix to prevent cpuidle from crashing in some rare cases

    If the result of cpuidle_get_driver() is NULL, which can happen on
    some systems, cpuidle_driver_ref() will crash trying to use that
    pointer and the Daniel Fu's fix prevents that from happening.

    7) cpufreq fixes related to CPU hotplug

    Stephen Boyd reported a number of concurrency problems with
    cpufreq related to CPU hotplug which are addressed by a series of
    fixes from Srivatsa S Bhat and Viresh Kumar.

    8) cpufreq fix for time conversion in time_in_state attribute

    Time conversion carried out by cpufreq when user space attempts to
    read /sys/devices/system/cpu/cpu*/cpufreq/stats/time_in_state
    won't work correcty if cputime_t doesn't map directly to jiffies.
    Fix from Andreas Schwab.

    9) Revert of a troublesome cpufreq commit

    Commit 7c30ed5 (cpufreq: make sure frequency transitions are
    serialized) was intended to address some known concurrency
    problems in cpufreq related to the ordering of transitions, but
    unfortunately it introduced several problems of its own, so I
    decided to revert it now and address the original problems later
    in a more robust way.

    10) Intel Haswell CPU models for intel_pstate from Nell Hardcastle.

    11) cpufreq fixes related to system suspend/resume

    The recent cpufreq changes that made it preserve CPU sysfs
    attributes over suspend/resume cycles introduced a possible NULL
    pointer dereference that caused it to crash during the second
    attempt to suspend. Three commits from Srivatsa S Bhat fix that
    problem and a couple of related issues.

    12) cpufreq locking fix

    cpufreq_policy_restore() should acquire the lock for reading, but
    it acquires it for writing. Fix from Lan Tianyu"

    * tag 'pm+acpi-fixes-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (25 commits)
    cpufreq: Acquire the lock in cpufreq_policy_restore() for reading
    cpufreq: Prevent problems in update_policy_cpu() if last_cpu == new_cpu
    cpufreq: Restructure if/else block to avoid unintended behavior
    cpufreq: Fix crash in cpufreq-stats during suspend/resume
    intel_pstate: Add Haswell CPU models
    Revert "cpufreq: make sure frequency transitions are serialized"
    cpufreq: Use signed type for 'ret' variable, to store negative error values
    cpufreq: Remove temporary fix for race between CPU hotplug and sysfs-writes
    cpufreq: Synchronize the cpufreq store_*() routines with CPU hotplug
    cpufreq: Invoke __cpufreq_remove_dev_finish() after releasing cpu_hotplug.lock
    cpufreq: Split __cpufreq_remove_dev() into two parts
    cpufreq: Fix wrong time unit conversion
    cpufreq: serialize calls to __cpufreq_governor()
    cpufreq: don't allow governor limits to be changed when it is disabled
    ACPI / bind: Prefer device objects with _STA to those without it
    ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
    ACPI / hotplug / PCI: Use _OST to notify firmware about notify status
    ACPI / hotplug / PCI: Avoid doing too much for spurious notifies
    ACPICA: Fix for a Store->ArgX when ArgX contains a reference to a field.
    ACPI / hotplug / PCI: Don't trim devices before scanning the namespace
    ...

    Linus Torvalds
     

31 Aug, 2013

2 commits

  • Since all of the memory hotplug operations have to be carried out
    under device_hotplug_lock, they won't need to acquire pm_mutex if
    device_hotplug_lock is held around hibernation.

    For this reason, make the hibernation code acquire
    device_hotplug_lock after freezing user space processes and
    release it before thawing them. At the same tim drop the
    lock_system_sleep() and unlock_system_sleep() calls from
    lock_memory_hotplug() and unlock_memory_hotplug(), respectively.

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

    Rafael J. Wysocki
     
  • The hibernation core uses special memory bitmaps during image
    creation and restoration and traditionally those bitmaps are
    allocated before freezing tasks, because in the past GFP_KERNEL
    allocations might not work after all tasks had been frozen.

    However, this is an anachronism, because hibernation_snapshot()
    now calls hibernate_preallocate_memory() which allocates memory
    for the image upfront anyway, so the memory bitmaps may be
    allocated after freezing user space safely.

    For this reason, move all of the create_basic_memory_bitmaps()
    calls after freeze_processes() and all of the corresponding
    free_basic_memory_bitmaps() calls before thaw_processes().

    This will allow us to hold device_hotplug_lock around hibernation
    without the need to worry about freezing issues with user space
    processes attempting to acquire it via sysfs attributes after the
    creation of memory bitmaps and before the freezing of tasks.

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

    Rafael J. Wysocki
     

07 Aug, 2013

1 commit


23 Jul, 2012

1 commit

  • Pull power management updates from Rafael Wysocki:

    - ACPI conversion to PM handling based on struct dev_pm_ops.
    - Conversion of a number of platform drivers to PM handling based on
    struct dev_pm_ops and removal of empty legacy PM callbacks from a
    couple of PCI drivers.
    - Suspend-to-both for in-kernel hibernation from Bojan Smojver.
    - cpuidle fixes and cleanups from ShuoX Liu, Daniel Lezcano and Preeti
    Murthy.
    - cpufreq bug fixes from Jonghwa Lee and Stephen Boyd.
    - Suspend and hibernate fixes from Srivatsa Bhat and Colin Cross.
    - Generic PM domains framework updates.
    - RTC CMOS wakeup signaling update from Paul Fox.
    - sparse warnings fixes from Sachin Kamat.
    - Build warnings fixes for the generic PM domains framework and PM
    sysfs code.
    - sysfs switch for printing device suspend times from Sameer Nanda.
    - Documentation fix from Oskar Schirmer.

    * tag 'pm-for-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (70 commits)
    cpufreq: Fix sysfs deadlock with concurrent hotplug/frequency switch
    EXYNOS: bugfix on retrieving old_index from freqs.old
    PM / Sleep: call early resume handlers when suspend_noirq fails
    PM / QoS: Use NULL pointer instead of plain integer in qos.c
    PM / QoS: Use NULL pointer instead of plain integer in pm_qos.h
    PM / Sleep: Require CAP_BLOCK_SUSPEND to use wake_lock/wake_unlock
    PM / Sleep: Add missing static storage class specifiers in main.c
    cpuilde / ACPI: remove time from acpi_processor_cx structure
    cpuidle / ACPI: remove usage from acpi_processor_cx structure
    cpuidle / ACPI : remove latency_ticks from acpi_processor_cx structure
    rtc-cmos: report wakeups from interrupt handler
    PM / Sleep: Fix build warning in sysfs.c for CONFIG_PM_SLEEP unset
    PM / Domains: Fix build warning for CONFIG_PM_RUNTIME unset
    olpc-xo15-sci: Use struct dev_pm_ops for power management
    PM / Domains: Replace plain integer with NULL pointer in domain.c file
    PM / Domains: Add missing static storage class specifier in domain.c file
    PM / crypto / ux500: Use struct dev_pm_ops for power management
    PM / IPMI: Remove empty legacy PCI PM callbacks
    tpm_nsc: Use struct dev_pm_ops for power management
    tpm_tis: Use struct dev_pm_ops for power management
    ...

    Linus Torvalds
     

19 Jul, 2012

1 commit

  • Commit a7a20d103994 ("sd: limit the scope of the async probe domain")
    make the SCSI device probing run device discovery in it's own async
    domain.

    However, as a result, the partition detection was no longer synchronized
    by async_synchronize_full() (which, despite the name, only synchronizes
    the global async space, not all of them). Which in turn meant that
    "wait_for_device_probe()" would not wait for the SCSI partitions to be
    parsed.

    And "wait_for_device_probe()" was what the boot time init code relied on
    for mounting the root filesystem.

    Now, most people never noticed this, because not only is it
    timing-dependent, but modern distributions all use initrd. So the root
    filesystem isn't actually on a disk at all. And then before they
    actually mount the final disk filesystem, they will have loaded the
    scsi-wait-scan module, which not only does the expected
    wait_for_device_probe(), but also does scsi_complete_async_scans().

    [ Side note: scsi_complete_async_scans() had also been partially broken,
    but that was fixed in commit 43a8d39d0137 ("fix async probe
    regression"), so that same commit a7a20d103994 had actually broken
    setups even if you used scsi-wait-scan explicitly ]

    Solve this problem by just moving the scsi_complete_async_scans() call
    into wait_for_device_probe(). Everybody who wants to wait for device
    probing to finish really wants the SCSI probing to complete, so there's
    no reason not to do this.

    So now "wait_for_device_probe()" really does what the name implies, and
    properly waits for device probing to finish. This also removes the now
    unnecessary extra calls to scsi_complete_async_scans().

    Reported-and-tested-by: Artem S. Tashkinov
    Cc: Dan Williams
    Cc: Alan Stern
    Cc: James Bottomley
    Cc: Borislav Petkov
    Cc: linux-scsi
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

01 Jul, 2012

2 commits

  • If function tracing is enabled for some of the low-level suspend/resume
    functions, it leads to triple fault during resume from suspend, ultimately
    ending up in a reboot instead of a resume (or a total refusal to come out
    of suspended state, on some machines).

    This issue was explained in more detail in commit f42ac38c59e0a03d (ftrace:
    disable tracing for suspend to ram). However, the changes made by that commit
    got reverted by commit cbe2f5a6e84eebb (tracing: allow tracing of
    suspend/resume & hibernation code again). So, unfortunately since things are
    not yet robust enough to allow tracing of low-level suspend/resume functions,
    suspend/resume is still broken when ftrace is enabled.

    So fix this by disabling function tracing during suspend/resume & hibernation.

    Signed-off-by: Srivatsa S. Bhat
    Cc: stable@vger.kernel.org
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     
  • It is often useful to suspend to memory after hibernation image has been
    written to disk. If the battery runs out or power is otherwise lost, the
    computer will resume from the hibernated image. If not, it will resume
    from memory and hibernation image will be discarded.

    Signed-off-by: Bojan Smojver
    Signed-off-by: Rafael J. Wysocki

    Bojan Smojver
     

19 May, 2012

1 commit


29 Mar, 2012

2 commits

  • The core suspend/hibernation code calls usermodehelper_disable() to
    avoid race conditions between the freezer and the starting of
    usermode helpers and each code path has to do that on its own.
    However, it is always called right before freeze_processes()
    and usermodehelper_enable() is always called right after
    thaw_processes(). For this reason, to avoid code duplication and
    to make the connection between usermodehelper_disable() and the
    freezer more visible, make freeze_processes() call it and remove the
    direct usermodehelper_disable() and usermodehelper_enable() calls
    from all suspend/hibernation code paths.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Cc: stable@vger.kernel.org

    Rafael J. Wysocki
     
  • There is no reason to call usermodehelper_disable() before creating
    memory bitmaps in hibernate() and software_resume(), so call it right
    before freeze_processes(), in accordance with the other suspend and
    hibernation code. Consequently, call usermodehelper_enable() right
    after the thawing of tasks rather than after freeing the memory
    bitmaps.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Cc: stable@vger.kernel.org

    Rafael J. Wysocki
     

05 Mar, 2012

1 commit


10 Feb, 2012

2 commits


30 Jan, 2012

1 commit

  • The current device suspend/resume phases during system-wide power
    transitions appear to be insufficient for some platforms that want
    to use the same callback routines for saving device states and
    related operations during runtime suspend/resume as well as during
    system suspend/resume. In principle, they could point their
    .suspend_noirq() and .resume_noirq() to the same callback routines
    as their .runtime_suspend() and .runtime_resume(), respectively,
    but at least some of them require device interrupts to be enabled
    while the code in those routines is running.

    It also makes sense to have device suspend-resume callbacks that will
    be executed with runtime PM disabled and with device interrupts
    enabled in case someone needs to run some special code in that
    context during system-wide power transitions.

    Apart from this, .suspend_noirq() and .resume_noirq() were introduced
    as a workaround for drivers using shared interrupts and failing to
    prevent their interrupt handlers from accessing suspended hardware.
    It appears to be better not to use them for other porposes, or we may
    have to deal with some serious confusion (which seems to be happening
    already).

    For the above reasons, introduce new device suspend/resume phases,
    "late suspend" and "early resume" (and analogously for hibernation)
    whose callback will be executed with runtime PM disabled and with
    device interrupts enabled and whose callback pointers generally may
    point to runtime suspend/resume routines.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mark Brown
    Reviewed-by: Kevin Hilman

    Rafael J. Wysocki
     

09 Dec, 2011

1 commit


07 Dec, 2011

4 commits

  • * pm-freezer: (26 commits)
    Freezer / sunrpc / NFS: don't allow TASK_KILLABLE sleeps to block the freezer
    Freezer: fix more fallout from the thaw_process rename
    freezer: fix wait_event_freezable/__thaw_task races
    freezer: kill unused set_freezable_with_signal()
    dmatest: don't use set_freezable_with_signal()
    usb_storage: don't use set_freezable_with_signal()
    freezer: remove unused @sig_only from freeze_task()
    freezer: use lock_task_sighand() in fake_signal_wake_up()
    freezer: restructure __refrigerator()
    freezer: fix set_freezable[_with_signal]() race
    freezer: remove should_send_signal() and update frozen()
    freezer: remove now unused TIF_FREEZE
    freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE
    cgroup_freezer: prepare for removal of TIF_FREEZE
    freezer: clean up freeze_processes() failure path
    freezer: kill PF_FREEZING
    freezer: test freezable conditions while holding freezer_lock
    freezer: make freezing indicate freeze condition in effect
    freezer: use dedicated lock instead of task_lock() + memory barrier
    freezer: don't distinguish nosig tasks on thaw
    ...

    Rafael J. Wysocki
     
  • The hibernation test modes 'test' and 'testproc' are deprecated, because
    the 'pm_test' framework offers much more fine-grained control for debugging
    suspend and hibernation related problems.

    So, remove the deprecated 'test' and 'testproc' hibernation test modes.

    Suggested-by: Rafael J. Wysocki
    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     
  • Commit 2aede851ddf08666f68ffc17be446420e9d2a056 (PM / Hibernate: Freeze
    kernel threads after preallocating memory) moved the freezing of kernel
    threads to hibernation_snapshot() function.

    So now, if the call to hibernation_snapshot() returns early due to a
    successful hibernation test, the caller has to thaw processes to ensure
    that the system gets back to its original state.

    But in SNAPSHOT_CREATE_IMAGE hibernation ioctl, the caller does not thaw
    processes in case hibernation_snapshot() returned due to a successful
    freezer test. Fix this issue. But note we still send the value of 'in_suspend'
    (which is now 0) to userspace, because we are not in an error path per-se,
    and moreover, the value of in_suspend correctly depicts the situation here.

    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     
  • In the software_resume() function defined in kernel/power/hibernate.c,
    if the call to create_basic_memory_bitmaps() fails, the usermodehelpers
    are not enabled (which had been disabled in the previous step). Fix it.

    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     

24 Nov, 2011

3 commits

  • The goto statements in hibernation_snapshot() are a bit complex.
    Refactor the code to remove some of them, thereby simplifying the
    implementation.

    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     
  • * 'pm-freezer' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc: (24 commits)
    freezer: fix wait_event_freezable/__thaw_task races
    freezer: kill unused set_freezable_with_signal()
    dmatest: don't use set_freezable_with_signal()
    usb_storage: don't use set_freezable_with_signal()
    freezer: remove unused @sig_only from freeze_task()
    freezer: use lock_task_sighand() in fake_signal_wake_up()
    freezer: restructure __refrigerator()
    freezer: fix set_freezable[_with_signal]() race
    freezer: remove should_send_signal() and update frozen()
    freezer: remove now unused TIF_FREEZE
    freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE
    cgroup_freezer: prepare for removal of TIF_FREEZE
    freezer: clean up freeze_processes() failure path
    freezer: kill PF_FREEZING
    freezer: test freezable conditions while holding freezer_lock
    freezer: make freezing indicate freeze condition in effect
    freezer: use dedicated lock instead of task_lock() + memory barrier
    freezer: don't distinguish nosig tasks on thaw
    freezer: remove racy clear_freeze_flag() and set PF_NOFREEZE on dead tasks
    freezer: rename thaw_process() to __thaw_task() and simplify the implementation
    ...

    Rafael J. Wysocki
     
  • The hibernation core code forgets to release memory preallocated
    for hibernation if there's an error in its early stages or if test
    modes causing hibernation_snapshot() to return early are used. This
    causes the system to be hardly usable, because the amount of
    preallocated memory is usually huge. Fix this problem.

    Reported-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Srivatsa S. Bhat

    Rafael J. Wysocki
     

22 Nov, 2011

1 commit

  • freeze_processes() failure path is rather messy. Freezing is canceled
    for workqueues and tasks which aren't frozen yet but frozen tasks are
    left alone and should be thawed by the caller and of course some
    callers (xen and kexec) didn't do it.

    This patch updates __thaw_task() to handle cancelation correctly and
    makes freeze_processes() and freeze_kernel_threads() call
    thaw_processes() on failure instead so that the system is fully thawed
    on failure. Unnecessary [suspend_]thaw_processes() calls are removed
    from kernel/power/hibernate.c, suspend.c and user.c.

    While at it, restructure error checking if clause in suspend_prepare()
    to be less weird.

    -v2: Srivatsa spotted missing removal of suspend_thaw_processes() in
    suspend_prepare() and error in commit message. Updated.

    Signed-off-by: Tejun Heo
    Acked-by: Srivatsa S. Bhat

    Tejun Heo
     

19 Nov, 2011

1 commit

  • Commit 2aede851ddf08666f68ffc17be446420e9d2a056
    (PM / Hibernate: Freeze kernel threads after preallocating memory)
    postponed the freezing of kernel threads to after preallocating memory
    for hibernation. But while doing that, the hibernation test TEST_FREEZER
    and the test mode HIBERNATION_TESTPROC were not moved accordingly.

    As a result, when using these test modes, it only goes upto the freezing of
    userspace and exits, when in fact it should go till the complete end of task
    freezing stage, namely the freezing of kernel threads as well.

    So, move these points of exit to appropriate places so that freezing of
    kernel threads is also tested while using these test harnesses.

    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     

01 Nov, 2011

1 commit