03 Nov, 2009

3 commits

  • Finish a line by \n when load_image fails in the middle of loading.

    Signed-off-by: Jiri Slaby
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • There are too many retval variables in save_image(). Thus error return
    value from snapshot_read_next() may be ignored and only part of the
    snapshot (successfully) written.

    Remove 'error' variable, invert the condition in the do-while loop
    and convert the loop to use only 'ret' variable.

    Switch the rest of the function to consider only 'ret'.

    Also make sure we end printed line by \n if an error occurs.

    Signed-off-by: Jiri Slaby
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • While cruising through the swsusp code I found few blkdev reference
    leaks of resume_bdev.

    swsusp_read: remove blkdev_put altogether. Some fail paths do
    not do that.
    swsusp_check: make sure we always put a reference on fail paths
    software_resume: all fail paths between swsusp_check and swsusp_read
    omit swsusp_close. Add it in those cases. And since
    swsusp_read doesn't drop the reference anymore, do
    it here unconditionally.

    [rjw: Fixed a small coding style issue.]

    Signed-off-by: Jiri Slaby
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     

22 Oct, 2009

1 commit

  • Increase TEST_SUSPEND_SECONDS to 10 so the warning in
    suspend_test_finish() doesn't annoy the users of slower systems so much.

    Also, make the warning print the suspend-resume cycle time, so that we
    know why the warning actually triggered.

    Patch prepared during the hacking session at the Kernel Summit in Tokyo.

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

    Rafael J. Wysocki
     

24 Sep, 2009

1 commit

  • * remove asm/atomic.h inclusion from linux/utsname.h --
    not needed after kref conversion
    * remove linux/utsname.h inclusion from files which do not need it

    NOTE: it looks like fs/binfmt_elf.c do not need utsname.h, however
    due to some personality stuff it _is_ needed -- cowardly leave ELF-related
    headers and files alone.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

22 Sep, 2009

2 commits

  • Signed-off-by: Alexey Dobriyan
    Acked-by: David Rientjes
    Reviewed-by: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • Since alloc_bootmem() will never return inaccessible (via virtual
    addressing) memory anyway, using the ..._low() variant only makes sense
    when the physical address range of the allocated memory must fulfill
    further constraints, espacially since on 64-bits (or more generally in all
    cases where the pools the two variants allocate from are than the full
    available range.

    Probably the use in alloc_tce_table() could also be eliminated (based on
    code inspection of pci-calgary_64.c), but that seems too risky given I
    know nothing about that hardware and have no way to test it.

    Signed-off-by: Jan Beulich
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     

20 Sep, 2009

1 commit

  • In the past someone gratuitiously borrowed chunks of kernel internal vt
    code and dumped them in kernel/power. They have all sorts of deep relations
    with the vt code so put them in the vt tree instead

    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Alan Cox
     

15 Sep, 2009

6 commits

  • Fix the definition of BM_BITS_PER_BLOCK and kerneldoc
    description of create_bm_block_list().

    [rjw: Added changelog.]

    Signed-off-by: Wu Fengguang
    Signed-off-by: Rafael J. Wysocki

    Wu Fengguang
     
  • Use for_each_populated_zone() instead of for_each_zone() in hibernation
    code. This fixes a bug on s390, where we allow both config options
    HIBERNATION and MEMORY_HOTPLUG, so that we also have a ZONE_MOVABLE
    here. We only allow hibernation if no memory hotplug operation was
    performed, so in fact both features can only be used exclusively, but
    this way we don't need 2 differently configured (distribution) kernels.

    If we have an unpopulated ZONE_MOVABLE, we allow hibernation but run
    into a BUG_ON() in memory_bm_test/set/clear_bit() because hibernation
    code iterates through all zones, not only the populated zones, in
    several places. For example, swsusp_free() does for_each_zone() and
    then checks for pfn_valid(), which is true even if the zone is not
    populated, resulting in a BUG_ON() later because the pfn cannot be
    found in the memory bitmap.

    Replacing all occurences of for_each_zone() in hibernation code with
    for_each_populated_zone() would fix this issue.

    [rjw: Rebased on top of linux-next hibernation patches.]

    Signed-off-by: Gerald Schaefer
    Acked-by: KOSAKI Motohiro
    Signed-off-by: Rafael J. Wysocki

    Gerald Schaefer
     
  • We want to avoid attempting to free too much memory too hard during
    hibernation, so estimate the minimum size of the image to use as the
    lower limit for preallocating memory.

    The approach here is based on the (experimental) observation that we
    can't free more page frames than the sum of:

    * global_page_state(NR_SLAB_RECLAIMABLE)
    * global_page_state(NR_ACTIVE_ANON)
    * global_page_state(NR_INACTIVE_ANON)
    * global_page_state(NR_ACTIVE_FILE)
    * global_page_state(NR_INACTIVE_FILE)

    minus

    * global_page_state(NR_FILE_MAPPED)

    Namely, if this number is subtracted from the number of saveable
    pages in the system, we get a good estimate of the minimum reasonable
    size of a hibernation image.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Wu Fengguang

    Rafael J. Wysocki
     
  • Since the hibernation code is now going to use allocations of memory
    to make enough room for the image, it can also use the page frames
    allocated at this stage as image page frames. The low-level
    hibernation code needs to be rearranged for this purpose, but it
    allows us to avoid freeing a great number of pages and allocating
    these same pages once again later, so it generally is worth doing.

    [rev. 2: Take highmem into account correctly.]

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Rework swsusp_shrink_memory() so that it calls shrink_all_memory()
    just once to make some room for the image and then allocates memory
    to apply more pressure to the memory management subsystem, if
    necessary.

    Unfortunately, we don't seem to be able to drop shrink_all_memory()
    entirely just yet, because that would lead to huge performance
    regressions in some test cases.

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

    Rafael J. Wysocki
     
  • Although the same label name is used somewhere else in the file, this
    particular label was consistently typoed in all of its uses.

    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Rafael J. Wysocki

    Thadeu Lima de Souza Cascardo
     

23 Aug, 2009

1 commit

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

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

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

    Rafael J. Wysocki
     

13 Jul, 2009

1 commit

  • * Remove smp_lock.h from files which don't need it (including some headers!)
    * Add smp_lock.h to files which do need it
    * Make smp_lock.h include conditional in hardirq.h
    It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

    This will make hardirq.h inclusion cheaper for every PREEMPT=n config
    (which includes allmodconfig/allyesconfig, BTW)

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

17 Jun, 2009

1 commit

  • Currently, the following scenario appears to be possible in theory:

    * Tasks are frozen for hibernation or suspend.
    * Free pages are almost exhausted.
    * Certain piece of code in the suspend code path attempts to allocate
    some memory using GFP_KERNEL and allocation order less than or
    equal to PAGE_ALLOC_COSTLY_ORDER.
    * __alloc_pages_internal() cannot find a free page so it invokes the
    OOM killer.
    * The OOM killer attempts to kill a task, but the task is frozen, so
    it doesn't die immediately.
    * __alloc_pages_internal() jumps to 'restart', unsuccessfully tries
    to find a free page and invokes the OOM killer.
    * No progress can be made.

    Although it is now hard to trigger during hibernation due to the memory
    shrinking carried out by the hibernation code, it is theoretically
    possible to trigger during suspend after the memory shrinking has been
    removed from that code path. Moreover, since memory allocations are
    going to be used for the hibernation memory shrinking, it will be even
    more likely to happen during hibernation.

    To prevent it from happening, introduce the oom_killer_disabled switch
    that will cause __alloc_pages_internal() to fail in the situations in
    which the OOM killer would have been called and make the freezer set
    this switch after tasks have been successfully frozen.

    [akpm@linux-foundation.org: be nicer to the namespace]
    Signed-off-by: Rafael J. Wysocki
    Cc: Fengguang Wu
    Cc: David Rientjes
    Acked-by: Pavel Machek
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

15 Jun, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (31 commits)
    trivial: remove the trivial patch monkey's name from SubmittingPatches
    trivial: Fix a typo in comment of addrconf_dad_start()
    trivial: usb: fix missing space typo in doc
    trivial: pci hotplug: adding __init/__exit macros to sgi_hotplug
    trivial: Remove the hyphen from git commands
    trivial: fix ETIMEOUT -> ETIMEDOUT typos
    trivial: Kconfig: .ko is normally not included in module names
    trivial: SubmittingPatches: fix typo
    trivial: Documentation/dell_rbu.txt: fix typos
    trivial: Fix Pavel's address in MAINTAINERS
    trivial: ftrace:fix description of trace directory
    trivial: unnecessary (void*) cast removal in sound/oss/msnd.c
    trivial: input/misc: Fix typo in Kconfig
    trivial: fix grammo in bus_for_each_dev() kerneldoc
    trivial: rbtree.txt: fix rb_entry() parameters in sample code
    trivial: spelling fix in ppc code comments
    trivial: fix typo in bio_alloc kernel doc
    trivial: Documentation/rbtree.txt: cleanup kerneldoc of rbtree.txt
    trivial: Miscellaneous documentation typo fixes
    trivial: fix typo milisecond/millisecond for documentation and source comments.
    ...

    Linus Torvalds
     

13 Jun, 2009

8 commits

  • The *_nvs_* routines in swsusp.c make use of the io*map()
    functions, which are only provided for HAS_IOMEM, thus
    breaking compilation if HAS_IOMEM is not set. Fix this
    by moving the *_nvs_* routines into hibernate_nvs.c, which
    is only compiled if HAS_IOMEM is set.

    [rjw: Change the name of the new file to hibernate_nvs.c, add the
    license line to the header comment.]

    Signed-off-by: Cornelia Huck
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Cornelia Huck
     
  • Change the name of kernel/power/disk.c to kernel/power/hibernate.c
    in analogy with the file names introduced by the changes that
    separated the suspend to RAM and standby funtionality from the
    common PM functions.

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

    Rafael J. Wysocki
     
  • Move the suspend to RAM and standby code from kernel/power/main.c
    to two separate files, kernel/power/suspend.c containing the basic
    functions and kernel/power/suspend_test.c containing the automatic
    suspend test facility based on the RTC clock alarm.

    There are no changes in functionality related to these modifications.

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

    Rafael J. Wysocki
     
  • A future patch is going to modify the memory shrinking code so that
    it will make memory allocations to free memory instead of using an
    artificial memory shrinking mechanism for that. For this purpose it
    is convenient to move swsusp_shrink_memory() from
    kernel/power/swsusp.c to kernel/power/snapshot.c, because the new
    memory-shrinking code is going to use things that are local to
    kernel/power/snapshot.c .

    [rev. 2: Make some functions static and remove their headers from
    kernel/power/power.h]

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Acked-by: Wu Fengguang

    Rafael J. Wysocki
     
  • Remove the shrinking of memory from the suspend-to-RAM code, where
    it is not really necessary.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Nigel Cunningham
    Acked-by: Wu Fengguang

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

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

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

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

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

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

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

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

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

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

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

    Magnus Damm
     
  • Fix coding style whitespace fixes. Patch compile tested
    Before :-
    total: 1 errors, 0 warnings, 46 lines checked
    After
    total: 0 errors, 0 warnings, 46 lines checked

    Before :-
    text data bss dec hex filename
    107 48 0 155 9b kernel/power/poweroff.o
    After
    text data bss dec hex filename
    107 48 0 155 9b kernel/power/poweroff.o

    Signed-off-by: Manish Katiyar
    Signed-off-by: Jiri Kosina

    Manish Katiyar
     

25 May, 2009

1 commit

  • We shouldn't hold dpm_list_mtx while executing
    [disable|enable]_nonboot_cpus(), because theoretically this may lead
    to a deadlock as shown by the following example (provided by Johannes
    Berg):

    CPU 3 CPU 2 CPU 1
    suspend/hibernate
    something:
    rtnl_lock() device_pm_lock()
    -> mutex_lock(&dpm_list_mtx)

    mutex_lock(&dpm_list_mtx)

    linkwatch_work
    -> rtnl_lock()
    disable_nonboot_cpus()
    -> flush CPU 3 workqueue

    Fortunately, device drivers are supposed to stop any activities that
    might lead to the registration of new device objects way before
    disable_nonboot_cpus() is called, so it shouldn't be necessary to
    hold dpm_list_mtx over the entire late part of device suspend and
    early part of device resume.

    Thus, during the late suspend and the early resume of devices acquire
    dpm_list_mtx only when dpm_list is going to be traversed and release
    it right after that.

    This patch is reported to fix the regressions tracked as
    http://bugzilla.kernel.org/show_bug.cgi?id=13245.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Alan Stern
    Reported-by: Miles Lane
    Tested-by: Ming Lei

    Rafael J. Wysocki
     

16 May, 2009

1 commit

  • Check the return value of sysdev_suspend(). I think this was a typo.
    Without this change, the following "if" check is always false.
    I also changed the error message so it's distinguishable from the
    similar message a few lines above.

    Signed-off-by: Bjorn Helgaas
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Bjorn Helgaas
     

25 Apr, 2009

1 commit

  • Commit c751085943362143f84346d274e0011419c84202 ("PM/Hibernate: Wait for
    SCSI devices scan to complete during resume") added a call to
    scsi_complete_async_scans() to software_resume(), so that it waited for
    the SCSI scanning to complete, but the call was added at a wrong place.

    Namely, it should have been added after wait_for_device_probe(), which
    is called only if the image partition hasn't been specified yet. Also,
    it's reasonable to check if the image partition is present and only wait
    for the device probing and SCSI scanning to complete if it is not the
    case.

    Additionally, since noresume is checked right at the beginning of
    software_resume() and the function returns immediately if it's set, it
    doesn't make sense to check it once again later.

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

    Rafael J. Wysocki
     

20 Apr, 2009

1 commit

  • Commit 900af0d973856d6feb6fc088c2d0d3fde57707d3 (PM: Change suspend
    code ordering) changed the ordering of suspend code in such a way
    that the platform .prepare() callback is now executed after the
    device drivers' late suspend callbacks have run. Unfortunately, this
    turns out to break ARM platforms that need to talk via I2C to power
    control devices during the .prepare() callback.

    For this reason introduce two new platform suspend callbacks,
    .prepare_late() and .wake(), that will be called just prior to
    disabling non-boot CPUs and right after bringing them back on line,
    respectively, and use them instead of .prepare() and .finish() for
    ACPI suspend. Make the PM core execute the .prepare() and .finish()
    platform suspend callbacks where they were executed previously (that
    is, right after calling the regular suspend methods provided by
    device drivers and right before executing their regular resume
    methods, respectively).

    It is not necessary to make analogous changes to the hibernation
    code and data structures at the moment, because they are only used
    by ACPI platforms.

    Signed-off-by: Rafael J. Wysocki
    Reported-by: Russell King
    Acked-by: Len Brown

    Rafael J. Wysocki
     

15 Apr, 2009

1 commit


14 Apr, 2009

1 commit

  • There is a race between resume from hibernation and the asynchronous
    scanning of SCSI devices and to prevent it from happening we need to
    call scsi_complete_async_scans() during resume from hibernation.

    In addition, if the resume from hibernation is userland-driven, it's
    better to wait for all device probes in the kernel to complete before
    attempting to open the resume device.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Arjan van de Ven
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

04 Apr, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (28 commits)
    trivial: Update my email address
    trivial: NULL noise: drivers/mtd/tests/mtd_*test.c
    trivial: NULL noise: drivers/media/dvb/frontends/drx397xD_fw.h
    trivial: Fix misspelling of "Celsius".
    trivial: remove unused variable 'path' in alloc_file()
    trivial: fix a pdlfush -> pdflush typo in comment
    trivial: jbd header comment typo fix for JBD_PARANOID_IOFAIL
    trivial: wusb: Storage class should be before const qualifier
    trivial: drivers/char/bsr.c: Storage class should be before const qualifier
    trivial: h8300: Storage class should be before const qualifier
    trivial: fix where cgroup documentation is not correctly referred to
    trivial: Give the right path in Documentation example
    trivial: MTD: remove EOL from MODULE_DESCRIPTION
    trivial: Fix typo in bio_split()'s documentation
    trivial: PWM: fix of #endif comment
    trivial: fix typos/grammar errors in Kconfig texts
    trivial: Fix misspelling of firmware
    trivial: cgroups: documentation typo and spelling corrections
    trivial: Update contact info for Jochen Hein
    trivial: fix typo "resgister" -> "register"
    ...

    Linus Torvalds
     

01 Apr, 2009

2 commits

  • Make the following header file changes:

    - remove arch ifdefs and asm/suspend.h from linux/suspend.h
    - add asm/suspend.h to disk.c (for arch_prepare_suspend())
    - add linux/io.h to swsusp.c (for ioremap())
    - x86 32/64 bit compile fixes

    Signed-off-by: Magnus Damm
    Cc: Paul Mundt
    Acked-by: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     
  • Impact: cleanup

    In almost cases, for_each_zone() is used with populated_zone(). It's
    because almost function doesn't need memoryless node information.
    Therefore, for_each_populated_zone() can help to make code simplify.

    This patch has no functional change.

    [akpm@linux-foundation.org: small cleanup]
    Signed-off-by: KOSAKI Motohiro
    Cc: KAMEZAWA Hiroyuki
    Cc: Mel Gorman
    Reviewed-by: Johannes Weiner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     

31 Mar, 2009

3 commits

  • Change the ordering of the hibernation core code so that the platform
    "prepare" callbacks are executed and the nonboot CPUs are disabled
    after calling device drivers' "late suspend" methods.

    This change (along with the previous analogous change of the suspend
    core code) will allow us to rework the PCI PM core so that the power
    state of devices is changed in the "late" phase of suspend (and
    analogously in the "early" phase of resume), which in turn will allow
    us to avoid the race condition where a device using shared interrupts
    is put into a low power state with interrupts enabled and then an
    interrupt (for another device) comes in and confuses its driver.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Ingo Molnar

    Rafael J. Wysocki
     
  • Change the ordering of the suspend core code so that the platform
    "prepare" callback is executed and the nonboot CPUs are disabled
    after calling device drivers' "late suspend" methods.

    This change will allow us to rework the PCI PM core so that the power
    state of devices is changed in the "late" phase of suspend (and
    analogously in the "early" phase of resume), which in turn will allow
    us to avoid the race condition where a device using shared interrupts
    is put into a low power state with interrupts enabled and then an
    interrupt (for another device) comes in and confuses its driver.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Ingo Molnar

    Rafael J. Wysocki
     
  • Use the functions introduced in by the previous patch,
    suspend_device_irqs(), resume_device_irqs() and check_wakeup_irqs(),
    to rework the handling of interrupts during suspend (hibernation) and
    resume. Namely, interrupts will only be disabled on the CPU right
    before suspending sysdevs, while device drivers will be prevented
    from receiving interrupts, with the help of the new helper function,
    before their "late" suspend callbacks run (and analogously during
    resume).

    In addition, since the device interrups are now disabled before the
    CPU has turned all interrupts off and the CPU will ACK the interrupts
    setting the IRQ_PENDING bit for them, check in sysdev_suspend() if
    any wake-up interrupts are pending and abort suspend if that's the
    case.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Ingo Molnar

    Rafael J. Wysocki
     

30 Mar, 2009

1 commit


23 Feb, 2009

1 commit