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
     

02 Feb, 2012

1 commit

  • In the SNAPSHOT_CREATE_IMAGE ioctl, if the call to hibernation_snapshot()
    fails, the frozen tasks are not thawed.

    And in the case of success, if we happen to exit due to a successful freezer
    test, all tasks (including those of userspace) are thawed, whereas actually
    we should have thawed only the kernel threads at that point. Fix both these
    issues.

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

    Srivatsa S. Bhat
     

30 Jan, 2012

3 commits

  • - Replace class ID #define with enumeration
    - Loop through PM QoS objects during initialization (rather than
    initializing them one-by-one)

    Signed-off-by: Alex Frid
    Reviewed-by: Antti Miettinen
    Reviewed-by: Diwakar Tundlam
    Reviewed-by: Scott Williams
    Reviewed-by: Yu-Huan Hsu
    Acked-by: markgross
    Signed-off-by: Rafael J. Wysocki

    Alex Frid
     
  • 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
     
  • Commit 2aede851ddf08666f68ffc17be446420e9d2a056

    PM / Hibernate: Freeze kernel threads after preallocating memory

    introduced a mechanism by which kernel threads were frozen after
    the preallocation of hibernate image memory to avoid problems with
    frozen kernel threads not responding to memory freeing requests.
    However, it overlooked the s2disk code path in which the
    SNAPSHOT_CREATE_IMAGE ioctl was run directly after SNAPSHOT_FREE,
    which caused freeze_workqueues_begin() to BUG(), because it saw
    that worqueues had been already frozen.

    Although in principle this issue might be addressed by removing
    the relevant BUG_ON() from freeze_workqueues_begin(), that would
    reintroduce the very problem that commit 2aede851ddf08666f68ffc17be4
    attempted to avoid into that particular code path. For this reason,
    to fix the issue at hand, introduce thaw_kernel_threads() and make
    the SNAPSHOT_FREE ioctl execute it.

    Special thanks to Srivatsa S. Bhat for detailed analysis of the
    problem.

    Reported-and-tested-by: Jiri Slaby
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Srivatsa S. Bhat
    Cc: stable@kernel.org

    Rafael J. Wysocki
     

20 Jan, 2012

1 commit


14 Jan, 2012

1 commit


11 Jan, 2012

1 commit

  • When debugging with CONFIG_DEBUG_PAGEALLOC and debug_guardpage_minorder >
    0, we have lot of free pages that are not marked so. Snapshot code
    account them as savable, what cause hibernate memory preallocation
    failure.

    It is pretty hard to make hibernate allocation succeed with
    debug_guardpage_minorder=1. This change at least make it possible when
    system has relatively big amount of RAM.

    Signed-off-by: Stanislaw Gruszka
    Acked-by: Rafael J. Wysocki
    Cc: Andrea Arcangeli
    Cc: Christoph Lameter
    Cc: Mel Gorman
    Cc: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stanislaw Gruszka
     

09 Jan, 2012

1 commit

  • * 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (76 commits)
    PM / Hibernate: Implement compat_ioctl for /dev/snapshot
    PM / Freezer: fix return value of freezable_schedule_timeout_killable()
    PM / shmobile: Allow the A4R domain to be turned off at run time
    PM / input / touchscreen: Make st1232 use device PM QoS constraints
    PM / QoS: Introduce dev_pm_qos_add_ancestor_request()
    PM / shmobile: Remove the stay_on flag from SH7372's PM domains
    PM / shmobile: Don't include SH7372's INTCS in syscore suspend/resume
    PM / shmobile: Add support for the sh7372 A4S power domain / sleep mode
    PM: Drop generic_subsys_pm_ops
    PM / Sleep: Remove forward-only callbacks from AMBA bus type
    PM / Sleep: Remove forward-only callbacks from platform bus type
    PM: Run the driver callback directly if the subsystem one is not there
    PM / Sleep: Make pm_op() and pm_noirq_op() return callback pointers
    PM/Devfreq: Add Exynos4-bus device DVFS driver for Exynos4210/4212/4412.
    PM / Sleep: Merge internal functions in generic_ops.c
    PM / Sleep: Simplify generic system suspend callbacks
    PM / Hibernate: Remove deprecated hibernation snapshot ioctls
    PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled()
    ARM: S3C64XX: Implement basic power domain support
    PM / shmobile: Use common always on power domain governor
    ...

    Fix up trivial conflict in fs/xfs/xfs_buf.c due to removal of unused
    XBT_FORCE_SLEEP bit

    Linus Torvalds
     

05 Jan, 2012

1 commit