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
     

29 Mar, 2012

1 commit

  • 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
     

10 Feb, 2012

2 commits


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

1 commit

  • 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
     

05 Jan, 2012

1 commit


10 Dec, 2011

1 commit


09 Dec, 2011

1 commit


07 Dec, 2011

3 commits

  • In the snapshot_ioctl() function, under SNAPSHOT_FREEZE, the code below
    freeze_processes() is a bit unintuitive. Improve it by replacing the
    second 'if' condition with an 'else' clause.

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

    Srivatsa S. Bhat
     
  • * 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
     
  • 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
     

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
     

31 Oct, 2011

1 commit

  • These files were implicitly relying on coming in via
    module.h, as without it we get things like:

    kernel/power/suspend.c:100: error: implicit declaration of function ‘usermodehelper_disable’
    kernel/power/suspend.c:109: error: implicit declaration of function ‘usermodehelper_enable’
    kernel/power/user.c:254: error: implicit declaration of function ‘usermodehelper_disable’
    kernel/power/user.c:261: error: implicit declaration of function ‘usermodehelper_enable’

    kernel/sys.c:317: error: implicit declaration of function ‘usermodehelper_disable’
    kernel/sys.c:1816: error: implicit declaration of function ‘call_usermodehelper_setup’
    kernel/sys.c:1822: error: implicit declaration of function ‘call_usermodehelper_setfns’
    kernel/sys.c:1824: error: implicit declaration of function ‘call_usermodehelper_exec’

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

22 Jun, 2011

1 commit

  • When opening /dev/snapshot device, snapshot_open() creates memory
    bitmaps which are freed in snapshot_release(). But if any of the
    callbacks called by pm_notifier_call_chain() returns NOTIFY_BAD, open()
    fails, snapshot_release() is never called and bitmaps are not freed.
    Next attempt to open /dev/snapshot then triggers BUG_ON() check in
    create_basic_memory_bitmaps(). This happens e.g. when vmwatchdog module
    is active on s390x.

    Signed-off-by: Michal Kubecek
    Signed-off-by: Rafael J. Wysocki
    Cc: stable@kernel.org

    Michal Kubecek
     

12 May, 2011

2 commits

  • The SNAPSHOT_S2RAM ioctl used for implementing the feature allowing
    one to suspend to RAM after creating a hibernation image is currently
    broken, because it doesn't clear the "ready" flag in the struct
    snapshot_data object handled by it. As a result, the
    SNAPSHOT_UNFREEZE doesn't work correctly after SNAPSHOT_S2RAM has
    returned and the user space hibernate task cannot thaw the other
    processes as appropriate. Make SNAPSHOT_S2RAM clear data->ready
    to fix this problem.

    Tested-by: Alexandre Felipe Muller de Souza
    Signed-off-by: Rafael J. Wysocki
    Cc: stable@kernel.org

    Rafael J. Wysocki
     
  • If the process using the hibernate user space interface closes
    /dev/snapshot after creating a hibernation image without thawing
    tasks, snapshot_release() should call pm_restore_gfp_mask() to
    restore the GFP mask used before the creation of the image. Make
    that happen.

    Tested-by: Alexandre Felipe Muller de Souza
    Signed-off-by: Rafael J. Wysocki
    Cc: stable@kernel.org

    Rafael J. Wysocki
     

17 Dec, 2010

1 commit


07 Dec, 2010

1 commit

  • There is a problem that swap pages allocated before the creation of
    a hibernation image can be released and used for storing the contents
    of different memory pages while the image is being saved. Since the
    kernel stored in the image doesn't know of that, it causes memory
    corruption to occur after resume from hibernation, especially on
    systems with relatively small RAM that need to swap often.

    This issue can be addressed by keeping the GFP_IOFS bits clear
    in gfp_allowed_mask during the entire hibernation, including the
    saving of the image, until the system is finally turned off or
    the hibernation is aborted. Unfortunately, for this purpose
    it's necessary to rework the way in which the hibernate and
    suspend code manipulates gfp_allowed_mask.

    This change is based on an earlier patch from Hugh Dickins.

    Signed-off-by: Rafael J. Wysocki
    Reported-by: Ondrej Zary
    Acked-by: Hugh Dickins
    Reviewed-by: KAMEZAWA Hiroyuki
    Cc: stable@kernel.org

    Rafael J. Wysocki
     

11 May, 2010

1 commit

  • Remove support of reads with offset. This means snapshot_read/write_next
    now does not accept count parameter. It allows to clean up the functions
    and snapshot handle which no longer needs to care about offsets.

    /dev/snapshot handler is converted to simple_{read_from,write_to}_buffer
    which take care of offsets.

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

    Jiri Slaby
     

11 Apr, 2010

1 commit

  • When CONFIG_DEBUG_BLOCK_EXT_DEVT is set we decode the device
    improperly by old_decode_dev and it results in an error while
    hibernating with s2disk.

    All users already pass the new device number, so switch to
    new_decode_dev().

    Signed-off-by: Jiri Slaby
    Reported-and-tested-by: Jiri Kosina
    Signed-off-by: "Rafael J. Wysocki"

    Jiri Slaby
     

27 Feb, 2010

1 commit

  • They were deprecated and removed from exported headers more than 2
    years ago. Inform users about their removal in the future now.

    (Switch cases needed to be reorderded for an easy fall through.)

    And add an entry to feature-removal-schedule.

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

    Jiri Slaby
     

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
     

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
     

22 Feb, 2009

1 commit

  • Snapshot device is opened with O_RDONLY during suspend and O_WRONLY durig
    resume. Make sure we also call notifiers with correct parameter telling
    them what we are really doing.

    Signed-off-by: Andrey Borzenkov
    Signed-off-by: Rafael J. Wysocki
    Cc: Len Brown
    Cc: Greg KH
    Acked-by: Pavel Machek
    Signed-off-by: Linus Torvalds

    Andrey Borzenkov
     

17 Oct, 2008

1 commit

  • We currently use a PM notifier to disable user mode helpers before suspend
    and hibernation and to re-enable them during resume. However, this is not
    an ideal solution, because if any drivers want to upload firmware into
    memory before suspend, they have to use a PM notifier for this purpose and
    there is no guarantee that the ordering of PM notifiers will be as
    expected (ie. the notifier that disables user mode helpers has to be run
    after the driver's notifier used for uploading the firmware).

    For this reason, it seems better to move the disabling and enabling of
    user mode helpers to separate functions that will be called by the PM core
    as necessary.

    [akpm@linux-foundation.org: remove unneeded ifdefs]
    Signed-off-by: Rafael J. Wysocki
    Cc: Alan Stern
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

17 Jul, 2008

2 commits

  • We can avoid taking the BKL in snapshot_ioctl() if pm_mutex is used to prevent
    the ioctls from being executed concurrently.

    In addition, although it is only possible to open /dev/snapshot once, the task
    which has done that may spawn a child that will inherit the open descriptor,
    so in theory they can call snapshot_write(), snapshot_read() and
    snapshot_release() concurrently. pm_mutex can also be used for mutual
    exclusion in such cases.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Andi Kleen
    Acked-by: Pavel Machek
    Signed-off-by: Len Brown

    Rafael J. Wysocki
     
  • Push BKL down into ioctl handlers - snapshot device.

    Signed-off-by: Alan Cox
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Len Brown
    Signed-off-by: Andi Kleen

    Alan Cox
     

02 Feb, 2008

5 commits

  • Add PM_RESTORE_PREPARE and PM_POST_RESTORE notifiers to the PM core, to be used
    in analogy with the existing PM_HIBERNATION_PREPARE and PM_POST_HIBERNATION
    notifiers.

    Signed-off-by: Alan Stern
    Acked-by: Pavel Machek
    Signed-off-by: "Rafael J. Wysocki"
    Signed-off-by: Len Brown

    Alan Stern
     
  • Three ioctl numbers belonging to the hibernation userland interface,
    SNAPSHOT_ATOMIC_SNAPSHOT, SNAPSHOT_AVAIL_SWAP, SNAPSHOT_GET_SWAP_PAGE,
    are defined in a wrong way (eg. not portable). Provide new ioctl numbers for
    these ioctls and mark the existing ones as deprecated.

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

    Rafael J. Wysocki
     
  • Mark the SNAPSHOT_SET_SWAP_FILE ioctl belonging to the hibernation userland
    interface as deprecated.

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

    Rafael J. Wysocki
     
  • Modify the hibernation userland interface by adding two new ioctls to it,
    SNAPSHOT_PLATFORM_SUPPORT and SNAPSHOT_POWER_OFF, that can be used,
    respectively, to switch the hibernation platform support on/off and to make the
    kernel transition the system to the hibernation state (eg. ACPI S4) using the
    platform (eg. ACPI) driver.

    These ioctls are intended to replace the misdesigned SNAPSHOT_PMOPS ioctl,
    which from now is regarded as obsolete and will be removed in the future.

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

    Rafael J. Wysocki
     
  • Add a new ioctl, SNAPSHOT_GET_IMAGE_SIZE, returning the size of the (just
    created) hibernation image, to the hibernation userland interface.

    This ioctl is necessary so that the userland utilities using the interface need
    not access the hibernation image header, owned by the kernel, in order to obtain
    the size of the image.

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

    Rafael J. Wysocki
     

19 Oct, 2007

1 commit

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

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

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

    Rafael J. Wysocki
     

20 Jul, 2007

5 commits

  • The SNAPSHOT_S2RAM ioctl code is outdated and it should not duplicate the
    suspend code in kernel/power/main.c. Fix that.

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

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

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

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

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

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

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

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

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

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

    Rafael J. Wysocki
     
  • In the face of the recent change of suspend code ordering (cf.
    http://marc.info/?l=linux-acpi&m=117938245931603&w=2) we should also modify
    the code ordering in swsusp so that hibernation_ops->prepare() is executed
    after device_suspend().

    However, for this purpose it seems reasonable to eliminate the code
    duplication between kernel/power/disk.c and kernel/power/user.c first. By
    eliminating it we can reduce the size of user.c quite substantially and remove
    the maintenance difficulty with making essentially the same changes in two
    different places.

    Moreover, we should also remove the calls to "platform" functions from the
    restore code path, since it doesn't carry out any power transition of the
    system, but we generally need to disable the GPEs before the restore if the
    'platform' hibernation mode has been used. To do this, we can introduce two
    new hibernation_ops to be used in the restore code.

    This patch:

    Make the code hibernation code in kernel/power/user.c be functionally
    equivalent to the corresponding code in kernel/power/disk.c , as it should be.

    The calls to the platform functions removed by this patch are incorrect. They
    should be replaced with some other "platform" invocations that will be
    introduced in one of the subsequent patches.

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

    Rafael J. Wysocki
     

17 Jun, 2007

1 commit

  • Fix oops caused by 'cat /dev/snapshot', reported by Arkadiusz Miskiewicz,
    and make it impossible to thaw tasks with the help of the swsusp userland
    interface while there is a snapshot image ready to save.

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

    Rafael J. Wysocki