31 Jul, 2012

1 commit

  • On the suspend/resume path the boot CPU does not go though an
    offline->online transition. This breaks the NMI detector post-resume
    since it depends on PMU state that is lost when the system gets
    suspended.

    Fix this by forcing a CPU offline->online transition for the lockup
    detector on the boot CPU during resume.

    To provide more context, we enable NMI watchdog on Chrome OS. We have
    seen several reports of systems freezing up completely which indicated
    that the NMI watchdog was not firing for some reason.

    Debugging further, we found a simple way of repro'ing system freezes --
    issuing the command 'tasket 1 sh -c "echo nmilockup > /proc/breakme"'
    after the system has been suspended/resumed one or more times.

    With this patch in place, the system freeze result in panics, as
    expected.

    These panics provide a nice stack trace for us to debug the actual issue
    causing the freeze.

    [akpm@linux-foundation.org: fiddle with code comment]
    [akpm@linux-foundation.org: make lockup_detector_bootcpu_resume() conditional on CONFIG_SUSPEND]
    [akpm@linux-foundation.org: fix section errors]
    Signed-off-by: Sameer Nanda
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: "Rafael J. Wysocki"
    Cc: Don Zickus
    Cc: Mandeep Singh Baines
    Cc: Srivatsa S. Bhat
    Cc: Anshuman Khandual
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sameer Nanda
     

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

2 commits

  • 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
     
  • Require processes wanting to use the wake_lock/wake_unlock sysfs
    files to have the CAP_BLOCK_SUSPEND capability, which also is
    required for the eventpoll EPOLLWAKEUP flag to be effective, so that
    all interfaces related to blocking autosleep depend on the same
    capability.

    Signed-off-by: Rafael J. Wysocki
    Cc: stable@vger.kernel.org
    Acked-by: Michael Kerrisk

    Rafael J. Wysocki
     

01 Jul, 2012

5 commits

  • With the introduction of suspend to both into in-kernel hibernation
    code, dmesg was getting polluted with backspace characters printed as
    part of image saving progress indicator. This patch introduces printing
    of progress indicator on image save/load every 10% and one line at a
    time. As an additional benefit, all other messages emitted by the kernel
    during hibernation/thaw should now print cleanly as well.

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

    Bojan Smojver
     
  • Change the behavior of the newly introduced
    /sys/power/pm_print_times attribute so that its initial value
    depends on initcall_debug, but setting it to 0 will cause device
    suspend/resume times not to be printed, even if initcall_debug has
    been set. This way, the people who use initcall_debug for reasons
    other than PM debugging will be able to switch the suspend/resume
    times printing off, if need be.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Srivatsa S. Bhat
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • Added a new knob called /sys/power/pm_print_times. Setting it to 1
    enables printing of time taken by devices to suspend and resume.
    Setting it to 0 disables this printing (unless overridden by
    initcall_debug kernel command line option).

    Signed-off-by: Sameer Nanda
    Acked-by: Greg KH
    Signed-off-by: Rafael J. Wysocki

    Sameer Nanda
     
  • 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


12 May, 2012

2 commits


06 May, 2012

1 commit


02 May, 2012

4 commits

  • Android allows user space to manipulate wakelocks using two
    sysfs file located in /sys/power/, wake_lock and wake_unlock.
    Writing a wakelock name and optionally a timeout to the wake_lock
    file causes the wakelock whose name was written to be acquired (it
    is created before is necessary), optionally with the given timeout.
    Writing the name of a wakelock to wake_unlock causes that wakelock
    to be released.

    Implement an analogous interface for user space using wakeup sources.
    Add the /sys/power/wake_lock and /sys/power/wake_unlock files
    allowing user space to create, activate and deactivate wakeup
    sources, such that writing a name and optionally a timeout to
    wake_lock causes the wakeup source of that name to be activated,
    optionally with the given timeout. If that wakeup source doesn't
    exist, it will be created and then activated. Writing a name to
    wake_unlock causes the wakeup source of that name, if there is one,
    to be deactivated. Wakeup sources created with the help of
    wake_lock that haven't been used for more than 5 minutes are garbage
    collected and destroyed. Moreover, there can be only WL_NUMBER_LIMIT
    wakeup sources created with the help of wake_lock present at a time.

    The data type used to track wakeup sources created by user space is
    called "struct wakelock" to indicate the origins of this feature.

    This version of the patch includes an rbtree manipulation fix from John Stultz.

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

    Rafael J. Wysocki
     
  • Android uses one wakelock statistics that is only necessary for
    opportunistic sleep. Namely, the prevent_suspend_time field
    accumulates the total time the given wakelock has been locked
    while "automatic suspend" was enabled. Add an analogous field,
    prevent_sleep_time, to wakeup sources and make it behave in a similar
    way.

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

    Rafael J. Wysocki
     
  • Introduce a mechanism by which the kernel can trigger global
    transitions to a sleep state chosen by user space if there are no
    active wakeup sources.

    It consists of a new sysfs attribute, /sys/power/autosleep, that
    can be written one of the strings returned by reads from
    /sys/power/state, an ordered workqueue and a work item carrying out
    the "suspend" operations. If a string representing the system's
    sleep state is written to /sys/power/autosleep, the work item
    triggering transitions to that state is queued up and it requeues
    itself after every execution until user space writes "off" to
    /sys/power/autosleep.

    That work item enables the detection of wakeup events using the
    functions already defined in drivers/base/power/wakeup.c (with one
    small modification) and calls either pm_suspend(), or hibernate() to
    put the system into a sleep state. If a wakeup event is reported
    while the transition is in progress, it will abort the transition and
    the "system suspend" work item will be queued up again.

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

    Rafael J. Wysocki
     
  • 1. Do not allocate memory for buffers from emergency pools, unless
    absolutely required. Do not warn about and do not retry non-essential
    failed allocations.

    2. Do not check the amount of free pages left on every single page
    write, but wait until one map is completely populated and then check.

    3. Set maximum number of pages for read buffering consistently, instead
    of inadvertently depending on the size of the sector type.

    4. Fix copyright line, which I missed when I submitted the hibernation
    threading patch.

    5. Dispense with bit shifting arithmetic to improve readability.

    6. Really recalculate the number of pages required to be free after all
    allocations have been done.

    7. Fix calculation of pages required for read buffering. Only count in
    pages that do not belong to high memory.

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

    Bojan Smojver
     

25 Apr, 2012

1 commit

  • Hibernation regression fix, since 3.2.

    Calculate the number of required free pages based on non-high memory
    pages only, because that is where the buffers will come from.

    Commit 081a9d043c983f161b78fdc4671324d1342b86bc introduced a new buffer
    page allocation logic during hibernation, in order to improve the
    performance. The amount of pages allocated was calculated based on total
    amount of pages available, although only non-high memory pages are
    usable for this purpose. This caused hibernation code to attempt to over
    allocate pages on platforms that have high memory, which led to hangs.

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

    Bojan Smojver
     

29 Mar, 2012

4 commits

  • The new API, pm_qos_update_request_timeout() is to provide a timeout
    with pm_qos_update_request.

    For example, pm_qos_update_request_timeout(req, 100, 1000), means that
    QoS request on req with value 100 will be active for 1000 microseconds.
    After 1000 microseconds, the QoS request thru req is reset. If there
    were another pm_qos_update_request(req, x) during the 1000 us, this
    new request with value x will override as this is another request on the
    same req handle. A new request on the same req handle will always
    override the previous request whether it is the conventional request or
    it is the new timeout request.

    Signed-off-by: MyungJoo Ham
    Signed-off-by: Kyungmin Park
    Acked-by: Mark Gross
    Signed-off-by: Rafael J. Wysocki

    MyungJoo Ham
     
  • There is a race condition between the freezer and request_firmware()
    such that if request_firmware() is run on one CPU and
    freeze_processes() is run on another CPU and usermodehelper_disable()
    called by it succeeds to grab umhelper_sem for writing before
    usermodehelper_read_trylock() called from request_firmware()
    acquires it for reading, the request_firmware() will fail and
    trigger a WARN_ON() complaining that it was called at a wrong time.
    However, in fact, it wasn't called at a wrong time and
    freeze_processes() simply happened to be executed simultaneously.

    To avoid this race, at least in some cases, modify
    usermodehelper_read_trylock() so that it doesn't fail if the
    freezing of tasks has just started and hasn't been completed yet.
    Instead, during the freezing of tasks, it will try to freeze the
    task that has called it so that it can wait until user space is
    thawed without triggering the scary warning.

    For this purpose, change usermodehelper_disabled so that it can
    take three different values, UMH_ENABLED (0), UMH_FREEZING and
    UMH_DISABLED. The first one means that usermode helpers are
    enabled, the last one means "hard disable" (i.e. the system is not
    ready for usermode helpers to be used) and the second one
    is reserved for the freezer. Namely, when freeze_processes() is
    started, it sets usermodehelper_disabled to UMH_FREEZING which
    tells usermodehelper_read_trylock() that it shouldn't fail just
    yet and should call try_to_freeze() if woken up and cannot
    return immediately. This way all freezable tasks that happen
    to call request_firmware() right before freeze_processes() is
    started and lose the race for umhelper_sem with it will be
    frozen and will sleep until thaw_processes() unsets
    usermodehelper_disabled. [For the non-freezable callers of
    request_firmware() the race for umhelper_sem against
    freeze_processes() is unfortunately unavoidable.]

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

    Rafael J. Wysocki
     
  • 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
     

22 Mar, 2012

1 commit

  • Pull power management updates for 3.4 from Rafael Wysocki:
    "Assorted extensions and fixes including:

    * Introduction of early/late suspend/hibernation device callbacks.
    * Generic PM domains extensions and fixes.
    * devfreq updates from Axel Lin and MyungJoo Ham.
    * Device PM QoS updates.
    * Fixes of concurrency problems with wakeup sources.
    * System suspend and hibernation fixes."

    * tag 'pm-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (43 commits)
    PM / Domains: Check domain status during hibernation restore of devices
    PM / devfreq: add relation of recommended frequency.
    PM / shmobile: Make MTU2 driver use pm_genpd_dev_always_on()
    PM / shmobile: Make CMT driver use pm_genpd_dev_always_on()
    PM / shmobile: Make TMU driver use pm_genpd_dev_always_on()
    PM / Domains: Introduce "always on" device flag
    PM / Domains: Fix hibernation restore of devices, v2
    PM / Domains: Fix handling of wakeup devices during system resume
    sh_mmcif / PM: Use PM QoS latency constraint
    tmio_mmc / PM: Use PM QoS latency constraint
    PM / QoS: Make it possible to expose PM QoS latency constraints
    PM / Sleep: JBD and JBD2 missing set_freezable()
    PM / Domains: Fix include for PM_GENERIC_DOMAINS=n case
    PM / Freezer: Remove references to TIF_FREEZE in comments
    PM / Sleep: Add more wakeup source initialization routines
    PM / Hibernate: Enable usermodehelpers in hibernate() error path
    PM / Sleep: Make __pm_stay_awake() delete wakeup source timers
    PM / Sleep: Fix race conditions related to wakeup source timer function
    PM / Sleep: Fix possible infinite loop during wakeup source destruction
    PM / Hibernate: print physical addresses consistently with other parts of kernel
    ...

    Linus Torvalds
     

20 Mar, 2012

1 commit


05 Mar, 2012

3 commits

  • * pm-qos:
    PM / QoS: unconditionally build the feature
    PM / QoS: Simplify PM QoS expansion/merge

    Rafael J. Wysocki
     
  • This patch removes all the references in the code about the TIF_FREEZE
    flag removed by commit a3201227f803ad7fd43180c5195dbe5a2bf998aa

    freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE

    There still are some references to TIF_FREEZE in
    Documentation/power/freezing-of-tasks.txt, but it looks like that
    documentation needs more thorough work to reflect how the new
    freezer works, and hence merely removing the references to TIF_FREEZE
    won't really help. So I have not touched that part in this patch.

    Suggested-by: Srivatsa S. Bhat
    Signed-off-by: Marcos Paulo de Souza
    Signed-off-by: Rafael J. Wysocki

    Marcos Paulo de Souza
     
  • If create_basic_memory_bitmaps() fails, usermodehelpers are not re-enabled
    before returning. Fix this. And while at it, reword the goto labels so that
    they look more meaningful.

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

    Srivatsa S. Bhat
     

18 Feb, 2012

4 commits


13 Feb, 2012

4 commits

  • The Finish label in suspend_freeze_processes() is in fact unnecessary
    and makes the function look more complicated than it really is, so
    remove that label (along with a few empty lines).

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

    Rafael J. Wysocki
     
  • Use the observation that it is more efficient to check the wakeup
    variable once before the loop reporting tasks that were not
    frozen in try_to_freeze_tasks() than to do that in every step of that
    loop.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The PM QoS feature originally didn't depend on CONFIG_PM, which was
    mistakenly changed by commit e8db0be1245de16a6cc6365506abc392c3c212d4

    PM QoS: Move and rename the implementation files

    Later, commit d020283dc694c9ec31b410f522252f7a8397e67d

    PM / QoS: CPU C-state breakage with PM Qos change

    partially fixed that by introducing a static inline definition of
    pm_qos_request(), but that still didn't allow user space to use
    the PM QoS interface if CONFIG_PM was unset (which had been possible
    before). For this reason, remove the dependency of PM QoS on
    CONFIG_PM to make it work (as intended) with CONFIG_PM unset.

    [rjw: Replaced the original changelog with a new one.]

    Signed-off-by: Jean Pihet
    Reported-by: Venkatesh Pallipadi
    Signed-off-by: Rafael J. Wysocki

    Jean Pihet
     
  • New material in the pm-qos branch depends on recent power management
    fixes.

    Rafael J. Wysocki
     

10 Feb, 2012

4 commits


05 Feb, 2012

1 commit

  • If freezing of kernel threads fails, we are expected to automatically
    thaw tasks in the error recovery path. However, at times, we encounter
    situations in which we would like the automatic error recovery path
    to thaw only the kernel threads, because we want to be able to do
    some more cleanup before we thaw userspace. Something like:

    error = freeze_kernel_threads();
    if (error) {
    /* Do some cleanup */

    /* Only then thaw userspace tasks*/
    thaw_processes();
    }

    An example of such a situation is where we freeze/thaw filesystems
    during suspend/hibernation. There, if freezing of kernel threads
    fails, we would like to thaw the frozen filesystems before thawing
    the userspace tasks.

    So, modify freeze_kernel_threads() to thaw only kernel threads in
    case of freezing failure. And change suspend_freeze_processes()
    accordingly. (At the same time, let us also get rid of the rather
    cryptic usage of the conditional operator (:?) in that function.)

    [rjw: In fact, this patch fixes a regression introduced during the
    3.3 merge window, because without it thaw_processes() may be called
    before swsusp_free() in some situations and that may lead to massive
    memory allocation failures.]

    Signed-off-by: Srivatsa S. Bhat
    Acked-by: Tejun Heo
    Acked-by: Nigel Cunningham
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat