12 Oct, 2018

1 commit

  • Dmitry writes:
    "Input updates for v4.19-rc7

    - we added a few scheduling points into various input interfaces to
    ensure that large writes will not cause RCU stalls
    - fixed configuring PS/2 keyboards as wakeup devices on newer
    platforms
    - added a new Xbox gamepad ID."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
    Input: uinput - add a schedule point in uinput_inject_events()
    Input: evdev - add a schedule point in evdev_write()
    Input: mousedev - add a schedule point in mousedev_write()
    Input: i8042 - enable keyboard wakeups by default when s2idle is used
    Input: xpad - add support for Xbox1 PDP Camo series gamepad

    Greg Kroah-Hartman
     

02 Oct, 2018

1 commit

  • Previously, on typical consumer laptops, pressing a key on the keyboard
    when the system is in suspend would cause it to wake up (default or
    unconditional behaviour). This happens because the EC generates a SCI
    interrupt in this scenario.

    That is no longer true on modern laptops based on Intel WhiskeyLake,
    including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
    UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
    design has been modified so that the EC no longer generates a SCI
    in this case; the keyboard controller itself should be used for wakeup.

    In order to retain the standard behaviour of being able to use the
    keyboard to wake up the system, enable serio wakeups by default on
    platforms that are using s2idle.

    Link: https://lkml.kernel.org/r/CAB4CAwfQ0mPMqCLp95TVjw4J0r5zKPWkSvvkK4cpZUGE--w8bQ@mail.gmail.com
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Daniel Drake
    Signed-off-by: Dmitry Torokhov

    Daniel Drake
     

15 Aug, 2018

2 commits

  • Commit ea0212f40c6 (power: auto select CONFIG_SRCU) made the code in
    drivers/base/power/wakeup.c use SRCU instead of RCU, but it forgot to
    select CONFIG_SRCU in Kconfig, which leads to the following build
    error if CONFIG_SRCU is not selected somewhere else:

    drivers/built-in.o: In function `wakeup_source_remove':
    (.text+0x3c6fc): undefined reference to `synchronize_srcu'
    drivers/built-in.o: In function `pm_print_active_wakeup_sources':
    (.text+0x3c7a8): undefined reference to `__srcu_read_lock'
    drivers/built-in.o: In function `pm_print_active_wakeup_sources':
    (.text+0x3c84c): undefined reference to `__srcu_read_unlock'
    drivers/built-in.o: In function `device_wakeup_arm_wake_irqs':
    (.text+0x3d1d8): undefined reference to `__srcu_read_lock'
    drivers/built-in.o: In function `device_wakeup_arm_wake_irqs':
    (.text+0x3d228): undefined reference to `__srcu_read_unlock'
    drivers/built-in.o: In function `device_wakeup_disarm_wake_irqs':
    (.text+0x3d24c): undefined reference to `__srcu_read_lock'
    drivers/built-in.o: In function `device_wakeup_disarm_wake_irqs':
    (.text+0x3d29c): undefined reference to `__srcu_read_unlock'
    drivers/built-in.o:(.data+0x4158): undefined reference to `process_srcu'

    Fix this error by selecting CONFIG_SRCU when PM_SLEEP is enabled.

    Fixes: ea0212f40c6 (power: auto select CONFIG_SRCU)
    Cc: 4.2+ # 4.2+
    Signed-off-by: zhangyi (F)
    [ rjw: Minor subject/changelog fixups ]
    Signed-off-by: Rafael J. Wysocki

    zhangyi (F)
     
  • Pull power management updates from Rafael Wysocki:
    "These add a new framework for CPU idle time injection, to be used by
    all of the idle injection code in the kernel in the future, fix some
    issues and add a number of relatively small extensions in multiple
    places.

    Specifics:

    - Add a new framework for CPU idle time injection (Daniel Lezcano).

    - Add AVS support to the armada-37xx cpufreq driver (Gregory
    CLEMENT).

    - Add support for current CPU frequency reporting to the ACPI CPPC
    cpufreq driver (George Cherian).

    - Rework the cooling device registration in the imx6q/thermal driver
    (Bastian Stender).

    - Make the pcc-cpufreq driver refuse to work with dynamic scaling
    governors on systems with many CPUs to avoid scalability issues
    with it (Rafael Wysocki).

    - Fix the intel_pstate driver to report different maximum CPU
    frequencies on systems where they really are different and to
    ignore the turbo active ratio if hardware-managend P-states (HWP)
    are in use; make it use the match_string() helper (Xie Yisheng,
    Srinivas Pandruvada).

    - Fix a minor deferred probe issue in the qcom-kryo cpufreq driver
    (Niklas Cassel).

    - Add a tracepoint for the tracking of frequency limits changes (from
    Andriod) to the cpufreq core (Ruchi Kandoi).

    - Fix a circular lock dependency between CPU hotplug and sysfs
    locking in the cpufreq core reported by lockdep (Waiman Long).

    - Avoid excessive error reports on driver registration failures in
    the ARM cpuidle driver (Sudeep Holla).

    - Add a new device links flag to the driver core to make links go
    away automatically on supplier driver removal (Vivek Gautam).

    - Eliminate potential race condition between system-wide power
    management transitions and system shutdown (Pingfan Liu).

    - Add a quirk to save NVS memory on system suspend for the ASUS 1025C
    laptop (Willy Tarreau).

    - Make more systems use suspend-to-idle (instead of ACPI S3) by
    default (Tristian Celestin).

    - Get rid of stack VLA usage in the low-level hibernation code on
    64-bit x86 (Kees Cook).

    - Fix error handling in the hibernation core and mark an expected
    fall-through switch in it (Chengguang Xu, Gustavo Silva).

    - Extend the generic power domains (genpd) framework to support
    attaching a device to a power domain by name (Ulf Hansson).

    - Fix device reference counting and user limits initialization in the
    devfreq core (Arvind Yadav, Matthias Kaehlcke).

    - Fix a few issues in the rk3399_dmc devfreq driver and improve its
    documentation (Enric Balletbo i Serra, Lin Huang, Nick Milner).

    - Drop a redundant error message from the exynos-ppmu devfreq driver
    (Markus Elfring)"

    * tag 'pm-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (35 commits)
    PM / reboot: Eliminate race between reboot and suspend
    PM / hibernate: Mark expected switch fall-through
    cpufreq: intel_pstate: Ignore turbo active ratio in HWP
    cpufreq: Fix a circular lock dependency problem
    cpu/hotplug: Add a cpus_read_trylock() function
    x86/power/hibernate_64: Remove VLA usage
    cpufreq: trace frequency limits change
    cpufreq: intel_pstate: Show different max frequency with turbo 3 and HWP
    cpufreq: pcc-cpufreq: Disable dynamic scaling on many-CPU systems
    cpufreq: qcom-kryo: Silently error out on EPROBE_DEFER
    cpufreq / CPPC: Add cpuinfo_cur_freq support for CPPC
    cpufreq: armada-37xx: Add AVS support
    dt-bindings: marvell: Add documentation for the Armada 3700 AVS binding
    PM / devfreq: rk3399_dmc: Fix duplicated opp table on reload.
    PM / devfreq: Init user limits from OPP limits, not viceversa
    PM / devfreq: rk3399_dmc: fix spelling mistakes.
    PM / devfreq: rk3399_dmc: do not print error when get supply and clk defer.
    dt-bindings: devfreq: rk3399_dmc: move interrupts to be optional.
    PM / devfreq: rk3399_dmc: remove wait for dcf irq event.
    dt-bindings: clock: add rk3399 DDR3 standard speed bins.
    ...

    Linus Torvalds
     

06 Aug, 2018

2 commits

  • At present, "systemctl suspend" and "shutdown" can run in parrallel. A
    system can suspend after devices_shutdown(), and resume. Then the shutdown
    task goes on to power off. This causes many devices are not really shut
    off. Hence replacing reboot_mutex with system_transition_mutex (renamed
    from pm_mutex) to achieve the exclusion. The renaming of pm_mutex as
    system_transition_mutex can be better to reflect the purpose of the mutex.

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

    Pingfan Liu
     
  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    This addresses Coverity-ID: 114713 ("Missing break in switch").

    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Gustavo A. R. Silva
     

02 Jul, 2018

1 commit


20 Jun, 2018

1 commit

  • Since swait basically implemented exclusive waits only, make sure
    the API reflects that.

    $ git grep -l -e "\"
    -e "\" | while read file;
    do
    sed -i -e 's/\/&_one/g'
    -e 's/\/&_exclusive/g' $file;
    done

    With a few manual touch-ups.

    Suggested-by: Linus Torvalds
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Thomas Gleixner
    Acked-by: Linus Torvalds
    Cc: bigeasy@linutronix.de
    Cc: oleg@redhat.com
    Cc: paulmck@linux.vnet.ibm.com
    Cc: pbonzini@redhat.com
    Link: https://lkml.kernel.org/r/20180612083909.261946548@infradead.org

    Peter Zijlstra
     

16 Jun, 2018

1 commit


13 Jun, 2018

1 commit

  • The vmalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vmalloc(a * b)

    with:
    vmalloc(array_size(a, b))

    as well as handling cases of:

    vmalloc(a * b * c)

    with:

    vmalloc(array3_size(a, b, c))

    This does, however, attempt to ignore constant size factors like:

    vmalloc(4 * 1024)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    vmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    vmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    vmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    vmalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    vmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    vmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    vmalloc(C1 * C2 * C3, ...)
    |
    vmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vmalloc(C1 * C2, ...)
    |
    vmalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

06 Jun, 2018

1 commit

  • Pull power management updates from Rafael Wysocki:
    "These include a significant update of the generic power domains
    (genpd) and Operating Performance Points (OPP) frameworks, mostly
    related to the introduction of power domain performance levels,
    cpufreq updates (new driver for Qualcomm Kryo processors, updates of
    the existing drivers, some core fixes, schedutil governor
    improvements), PCI power management fixes, ACPI workaround for
    EC-based wakeup events handling on resume from suspend-to-idle, and
    major updates of the turbostat and pm-graph utilities.

    Specifics:

    - Introduce power domain performance levels into the the generic
    power domains (genpd) and Operating Performance Points (OPP)
    frameworks (Viresh Kumar, Rajendra Nayak, Dan Carpenter).

    - Fix two issues in the runtime PM framework related to the
    initialization and removal of devices using device links (Ulf
    Hansson).

    - Clean up the initialization of drivers for devices in PM domains
    (Ulf Hansson, Geert Uytterhoeven).

    - Fix a cpufreq core issue related to the policy sysfs interface
    causing CPU online to fail for CPUs sharing one cpufreq policy in
    some situations (Tao Wang).

    - Make it possible to use platform-specific suspend/resume hooks in
    the cpufreq-dt driver and make the Armada 37xx DVFS use that
    feature (Viresh Kumar, Miquel Raynal).

    - Optimize policy transition notifications in cpufreq (Viresh Kumar).

    - Improve the iowait boost mechanism in the schedutil cpufreq
    governor (Patrick Bellasi).

    - Improve the handling of deferred frequency updates in the schedutil
    cpufreq governor (Joel Fernandes, Dietmar Eggemann, Rafael Wysocki,
    Viresh Kumar).

    - Add a new cpufreq driver for Qualcomm Kryo (Ilia Lin).

    - Fix and clean up some cpufreq drivers (Colin Ian King, Dmitry
    Osipenko, Doug Smythies, Luc Van Oostenryck, Simon Horman, Viresh
    Kumar).

    - Fix the handling of PCI devices with the DPM_SMART_SUSPEND flag set
    and update stale comments in the PCI core PM code (Rafael Wysocki).

    - Work around an issue related to the handling of EC-based wakeup
    events in the ACPI PM core during resume from suspend-to-idle if
    the EC has been put into the low-power mode (Rafael Wysocki).

    - Improve the handling of wakeup source objects in the PM core (Doug
    Berger, Mahendran Ganesh, Rafael Wysocki).

    - Update the driver core to prevent deferred probe from breaking
    suspend/resume ordering (Feng Kan).

    - Clean up the PM core somewhat (Bjorn Helgaas, Ulf Hansson, Rafael
    Wysocki).

    - Make the core suspend/resume code and cpufreq support the RT patch
    (Sebastian Andrzej Siewior, Thomas Gleixner).

    - Consolidate the PM QoS handling in cpuidle governors (Rafael
    Wysocki).

    - Fix a possible crash in the hibernation core (Tetsuo Handa).

    - Update the rockchip-io Adaptive Voltage Scaling (AVS) driver (David
    Wu).

    - Update the turbostat utility (fixes, cleanups, new CPU IDs, new
    command line options, built-in "Low Power Idle" counters support,
    new POLL and POLL% columns) and add an entry for it to MAINTAINERS
    (Len Brown, Artem Bityutskiy, Chen Yu, Laura Abbott, Matt Turner,
    Prarit Bhargava, Srinivas Pandruvada).

    - Update the pm-graph to version 5.1 (Todd Brandt).

    - Update the intel_pstate_tracer utility (Doug Smythies)"

    * tag 'pm-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (128 commits)
    tools/power turbostat: update version number
    tools/power turbostat: Add Node in output
    tools/power turbostat: add node information into turbostat calculations
    tools/power turbostat: remove num_ from cpu_topology struct
    tools/power turbostat: rename num_cores_per_pkg to num_cores_per_node
    tools/power turbostat: track thread ID in cpu_topology
    tools/power turbostat: Calculate additional node information for a package
    tools/power turbostat: Fix node and siblings lookup data
    tools/power turbostat: set max_num_cpus equal to the cpumask length
    tools/power turbostat: if --num_iterations, print for specific number of iterations
    tools/power turbostat: Add Cannon Lake support
    tools/power turbostat: delete duplicate #defines
    x86: msr-index.h: Correct SNB_C1/C3_AUTO_UNDEMOTE defines
    tools/power turbostat: Correct SNB_C1/C3_AUTO_UNDEMOTE defines
    tools/power turbostat: add POLL and POLL% column
    tools/power turbostat: Fix --hide Pk%pc10
    tools/power turbostat: Build-in "Low Power Idle" counters support
    tools/power turbostat: Don't make man pages executable
    tools/power turbostat: remove blank lines
    tools/power turbostat: a small C-states dump readability immprovement
    ...

    Linus Torvalds
     

04 Jun, 2018

2 commits

  • * pm-pci:
    PCI / PM: Clean up outdated comments in pci_target_state()
    PCI / PM: Do not clear state_saved for devices that remain suspended

    * acpi-pm:
    ACPI: EC: Dispatch the EC GPE directly on s2idle wake
    ACPICA: Introduce acpi_dispatch_gpe()

    * pm-sleep:
    PM / hibernate: Fix oops at snapshot_write()
    PM / wakeup: Make s2idle_lock a RAW_SPINLOCK
    PM / s2idle: Make s2idle_wait_head swait based
    PM / wakeup: Make events_lock a RAW_SPINLOCK
    PM / suspend: Prevent might sleep splats

    * pm-avs:
    PM / AVS: rockchip-io: add io selectors and supplies for PX30

    Rafael J. Wysocki
     
  • * pm-qos:
    PM / QoS: Drop redundant declaration of pm_qos_get_value()

    * pm-core:
    PM / runtime: Drop usage count for suppliers at device link removal
    PM / runtime: Fixup reference counting of device link suppliers at probe
    PM: wakeup: Use pr_debug() for the "aborting suspend" message
    PM / core: Drop unused internal inline functions for sysfs
    PM / core: Drop unused internal functions for pm_qos sysfs
    PM / core: Drop unused internal inline functions for wakeirqs
    PM / core: Drop internal unused inline functions for wakeups
    PM / wakeup: Only update last time for active wakeup sources
    PM / wakeup: Use seq_open() to show wakeup stats
    PM / core: Use dev_printk() and symbols in suspend/resume diagnostics
    PM / core: Simplify initcall_debug_report() timing
    PM / core: Remove unused initcall_debug_report() arguments
    PM / core: fix deferred probe breaking suspend resume order

    Rafael J. Wysocki
     

29 May, 2018

1 commit


27 May, 2018

4 commits

  • syzbot is reporting NULL pointer dereference at snapshot_write() [1].
    This is because data->handle is zero-cleared by ioctl(SNAPSHOT_FREE).
    Fix this by checking data_of(data->handle) != NULL before using it.

    [1] https://syzkaller.appspot.com/bug?id=828a3c71bd344a6de8b6a31233d51a72099f27fd

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Signed-off-by: Rafael J. Wysocki

    Tetsuo Handa
     
  • The `s2idle_lock' is acquired during suspend while interrupts are
    disabled even on RT. The lock is acquired for short sections only.
    Make it a RAW lock which avoids "sleeping while atomic" warnings on RT.

    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Rafael J. Wysocki

    Sebastian Andrzej Siewior
     
  • s2idle_wait_head is used during s2idle with interrupts disabled even on
    RT. There is no "custom" wake up function so swait could be used instead
    which is also lower weight compared to the wait_queue.
    Make s2idle_wait_head a swait_queue_head.

    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Rafael J. Wysocki

    Sebastian Andrzej Siewior
     
  • timekeeping suspend/resume calls read_persistent_clock() which takes
    rtc_lock. That results in might sleep warnings because at that point
    we run with interrupts disabled.

    We cannot convert rtc_lock to a raw spinlock as that would trigger
    other might sleep warnings.

    As a workaround we disable the might sleep warnings by setting
    system_state to SYSTEM_SUSPEND before calling sysdev_suspend() and
    restoring it to SYSTEM_RUNNING afer sysdev_resume(). There is no lock
    contention because hibernate / suspend to RAM is single-CPU at this
    point.

    In s2idle's case the system_state is set to SYSTEM_SUSPEND before
    timekeeping_suspend() which is invoked by the last CPU. In the resume
    case it set back to SYSTEM_RUNNING after timekeeping_resume() which is
    invoked by the first CPU in the resume case. The other CPUs will block
    on tick_freeze_lock.

    Signed-off-by: Thomas Gleixner
    [bigeasy: cover s2idle in tick_freeze() / tick_unfreeze()]
    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Rafael J. Wysocki

    Thomas Gleixner
     

14 May, 2018

1 commit


10 May, 2018

1 commit

  • When wakelock support was added, the wakeup_source_add() function
    was updated to set the last_time value of the wakeup source. This
    has the unintended side effect of producing confusing output from
    pm_print_active_wakeup_sources() when a wakeup source is added
    prior to a sleep that is blocked by a different wakeup source.

    The function pm_print_active_wakeup_sources() will search for the
    most recently active wakeup source when no active source is found.
    If a wakeup source is added after a different wakeup source blocks
    the system from going to sleep it may have a later last_time value
    than the blocking source and be output as the last active wakeup
    source even if it has never actually been active.

    It looks to me like the change to wakeup_source_add() was made to
    prevent the wakelock garbage collection from accidentally dropping
    a wakelock during the narrow window between adding the wakelock to
    the wakelock list in wakelock_lookup_add() and the activation of
    the wakeup source in pm_wake_lock().

    This commit changes the behavior so that only the last_time of the
    wakeup source used by a wakelock is initialized prior to adding it
    to the wakeup source list. This preserves the meaning of the
    last_time value as the last time the wakeup source was active and
    allows a wakeup source that has never been active to have a
    last_time value of 0.

    Fixes: b86ff9820fd5 (PM / Sleep: Add user space interface for manipulating wakeup sources, v3)
    Signed-off-by: Doug Berger
    Signed-off-by: Rafael J. Wysocki

    Doug Berger
     

09 Apr, 2018

1 commit


04 Apr, 2018

1 commit

  • Pull power management updates from Rafael Wysocki:
    "These update the cpuidle poll state definition to reduce excessive
    energy usage related to it, add new CPU ID to the RAPL power capping
    driver, update the ACPI system suspend code to handle some special
    cases better, extend the PM core's device links code slightly, add new
    sysfs attribute for better suspend-to-idle diagnostics and easier
    hibernation handling, update power management tools and clean up
    cpufreq quite a bit.

    Specifics:

    - Modify the cpuidle poll state implementation to prevent CPUs from
    staying in the loop in there for excessive times (Rafael Wysocki).

    - Add Intel Cannon Lake chips support to the RAPL power capping
    driver (Joe Konno).

    - Add reference counting to the device links handling code in the PM
    core (Lukas Wunner).

    - Avoid reconfiguring GPEs on suspend-to-idle in the ACPI system
    suspend code (Rafael Wysocki).

    - Allow devices to be put into deeper low-power states via ACPI if
    both _SxD and _SxW are missing (Daniel Drake).

    - Reorganize the core ACPI suspend-to-idle wakeup code to avoid a
    keyboard wakeup issue on Asus UX331UA (Chris Chiu).

    - Prevent the PCMCIA library code from aborting suspend-to-idle due
    to noirq suspend failures resulting from incorrect assumptions
    (Rafael Wysocki).

    - Add coupled cpuidle supprt to the Exynos3250 platform (Marek
    Szyprowski).

    - Add new sysfs file to make it easier to specify the image storage
    location during hibernation (Mario Limonciello).

    - Add sysfs files for collecting suspend-to-idle usage and time
    statistics for CPU idle states (Rafael Wysocki).

    - Update the pm-graph utilities (Todd Brandt).

    - Reduce the kernel log noise related to reporting Low-power Idle
    constraings by the ACPI system suspend code (Rafael Wysocki).

    - Make it easier to distinguish dedicated wakeup IRQs in the
    /proc/interrupts output (Tony Lindgren).

    - Add the frequency table validation in cpufreq to the core and drop
    it from a number of cpufreq drivers (Viresh Kumar).

    - Drop "cooling-{min|max}-level" for CPU nodes from a couple of DT
    bindings (Viresh Kumar).

    - Clean up the CPU online error code path in the cpufreq core (Viresh
    Kumar).

    - Fix assorted issues in the SCPI, CPPC, mediatek and tegra186
    cpufreq drivers (Arnd Bergmann, Chunyu Hu, George Cherian, Viresh
    Kumar).

    - Drop memory allocation error messages from a few places in cpufreq
    and cpuildle drivers (Markus Elfring)"

    * tag 'pm-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (56 commits)
    ACPI / PM: Fix keyboard wakeup from suspend-to-idle on ASUS UX331UA
    cpufreq: CPPC: Use transition_delay_us depending transition_latency
    PM / hibernate: Change message when writing to /sys/power/resume
    PM / hibernate: Make passing hibernate offsets more friendly
    cpuidle: poll_state: Avoid invoking local_clock() too often
    PM: cpuidle/suspend: Add s2idle usage and time state attributes
    cpuidle: Enable coupled cpuidle support on Exynos3250 platform
    cpuidle: poll_state: Add time limit to poll_idle()
    cpufreq: tegra186: Don't validate the frequency table twice
    cpufreq: speedstep: Don't validate the frequency table twice
    cpufreq: sparc: Don't validate the frequency table twice
    cpufreq: sh: Don't validate the frequency table twice
    cpufreq: sfi: Don't validate the frequency table twice
    cpufreq: scpi: Don't validate the frequency table twice
    cpufreq: sc520: Don't validate the frequency table twice
    cpufreq: s3c24xx: Don't validate the frequency table twice
    cpufreq: qoirq: Don't validate the frequency table twice
    cpufreq: pxa: Don't validate the frequency table twice
    cpufreq: ppc_cbe: Don't validate the frequency table twice
    cpufreq: powernow: Don't validate the frequency table twice
    ...

    Linus Torvalds
     

03 Apr, 2018

1 commit

  • Using this helper allows us to avoid the in-kernel calls to the
    sys_sync() syscall. The ksys_ prefix denotes that this function
    is meant as a drop-in replacement for the syscall. In particular, it
    uses the same calling convention as sys_sync().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Alexander Viro
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     

30 Mar, 2018

2 commits


03 Feb, 2018

1 commit

  • The declaration for swsusp_arch_resume marks it as 'asmlinkage', but the
    definition in x86-32 does not, and it fails to include the header with the
    declaration. This leads to a warning when building with
    link-time-optimizations:

    kernel/power/power.h:108:23: error: type of 'swsusp_arch_resume' does not match original declaration [-Werror=lto-type-mismatch]
    extern asmlinkage int swsusp_arch_resume(void);
    ^
    arch/x86/power/hibernate_32.c:148:0: note: 'swsusp_arch_resume' was previously declared here
    int swsusp_arch_resume(void)

    This moves the declaration into a globally visible header file and fixes up
    both x86 definitions to match it.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Thomas Gleixner
    Cc: Len Brown
    Cc: Andi Kleen
    Cc: Nicolas Pitre
    Cc: linux-pm@vger.kernel.org
    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Cc: Bart Van Assche
    Link: https://lkml.kernel.org/r/20180202145634.200291-2-arnd@arndb.de

    Arnd Bergmann
     

30 Jan, 2018

1 commit

  • Pull block updates from Jens Axboe:
    "This is the main pull request for block IO related changes for the
    4.16 kernel. Nothing major in this pull request, but a good amount of
    improvements and fixes all over the map. This contains:

    - BFQ improvements, fixes, and cleanups from Angelo, Chiara, and
    Paolo.

    - Support for SMR zones for deadline and mq-deadline from Damien and
    Christoph.

    - Set of fixes for bcache by way of Michael Lyle, including fixes
    from himself, Kent, Rui, Tang, and Coly.

    - Series from Matias for lightnvm with fixes from Hans Holmberg,
    Javier, and Matias. Mostly centered around pblk, and the removing
    rrpc 1.2 in preparation for supporting 2.0.

    - A couple of NVMe pull requests from Christoph. Nothing major in
    here, just fixes and cleanups, and support for command tracing from
    Johannes.

    - Support for blk-throttle for tracking reads and writes separately.
    From Joseph Qi. A few cleanups/fixes also for blk-throttle from
    Weiping.

    - Series from Mike Snitzer that enables dm to register its queue more
    logically, something that's alwways been problematic on dm since
    it's a stacked device.

    - Series from Ming cleaning up some of the bio accessor use, in
    preparation for supporting multipage bvecs.

    - Various fixes from Ming closing up holes around queue mapping and
    quiescing.

    - BSD partition fix from Richard Narron, fixing a problem where we
    can't mount newer (10/11) FreeBSD partitions.

    - Series from Tejun reworking blk-mq timeout handling. The previous
    scheme relied on atomic bits, but it had races where we would think
    a request had timed out if it to reused at the wrong time.

    - null_blk now supports faking timeouts, to enable us to better
    exercise and test that functionality separately. From me.

    - Kill the separate atomic poll bit in the request struct. After
    this, we don't use the atomic bits on blk-mq anymore at all. From
    me.

    - sgl_alloc/free helpers from Bart.

    - Heavily contended tag case scalability improvement from me.

    - Various little fixes and cleanups from Arnd, Bart, Corentin,
    Douglas, Eryu, Goldwyn, and myself"

    * 'for-4.16/block' of git://git.kernel.dk/linux-block: (186 commits)
    block: remove smart1,2.h
    nvme: add tracepoint for nvme_complete_rq
    nvme: add tracepoint for nvme_setup_cmd
    nvme-pci: introduce RECONNECTING state to mark initializing procedure
    nvme-rdma: remove redundant boolean for inline_data
    nvme: don't free uuid pointer before printing it
    nvme-pci: Suspend queues after deleting them
    bsg: use pr_debug instead of hand crafted macros
    blk-mq-debugfs: don't allow write on attributes with seq_operations set
    nvme-pci: Fix queue double allocations
    block: Set BIO_TRACE_COMPLETION on new bio during split
    blk-throttle: use queue_is_rq_based
    block: Remove kblockd_schedule_delayed_work{,_on}()
    blk-mq: Avoid that blk_mq_delay_run_hw_queue() introduces unintended delays
    blk-mq: Rename blk_mq_request_direct_issue() into blk_mq_request_issue_directly()
    lib/scatterlist: Fix chaining support in sgl_alloc_order()
    blk-throttle: track read and write request individually
    block: add bdev_read_only() checks to common helpers
    block: fail op_is_write() requests to read-only partitions
    blk-throttle: export io_serviced_recursive, io_service_bytes_recursive
    ...

    Linus Torvalds
     

17 Jan, 2018

1 commit


10 Jan, 2018

1 commit


07 Jan, 2018

1 commit


05 Jan, 2018

1 commit

  • s2disk/s2both may fail unnecessarily and erratically if NR_FILE_MAPPED
    is high - for instance when using VMs with VirtualBox and perhaps VMware
    Player. In those situations s2disk becomes unreliable and therefore
    unusable.

    A typical scenario is: user issues a s2disk and it fails. User issues
    a second s2disk immediately after that and it succeeds. And user
    wonders why.

    The problem is caused by minimum_image_size() in snapshot.c. The
    value it returns is roughly 100% too high because NR_FILE_MAPPED is
    subtracted in its calculation. Eventually the number of preallocated
    image pages is falsely too low.

    This doesn't matter as long as NR_FILE_MAPPED-values are in a normal
    range or in 32bit-environments as the code allows for allocation of
    additional pages from highmem.

    But with the high values generated by VirtualBox-VMs (a 2-GB-VM causes
    NR_FILE_MAPPED go up by 2 GB) it may lead to failure in 64bit-systems.

    Not subtracting NR_FILE_MAPPED in minimum_image_size() solves the
    problem.

    I've done at least hundreds of successful s2both/s2disk now on an
    x86_64 system (with and without VirtualBox) which gives me some
    confidence that this is right. It has turned s2disk/s2both from
    unusable into 100% reliable.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=97201
    Signed-off-by: Rainer Fiebig
    Signed-off-by: Rafael J. Wysocki

    Rainer Fiebig
     

16 Nov, 2017

1 commit

  • As the page free path makes no distinction between cache hot and cold
    pages, there is no real useful ordering of pages in the free list that
    allocation requests can take advantage of. Juding from the users of
    __GFP_COLD, it is likely that a number of them are the result of copying
    other sites instead of actually measuring the impact. Remove the
    __GFP_COLD parameter which simplifies a number of paths in the page
    allocator.

    This is potentially controversial but bear in mind that the size of the
    per-cpu pagelists versus modern cache sizes means that the whole per-cpu
    list can often fit in the L3 cache. Hence, there is only a potential
    benefit for microbenchmarks that alloc/free pages in a tight loop. It's
    even worse when THP is taken into account which has little or no chance
    of getting a cache-hot page as the per-cpu list is bypassed and the
    zeroing of multiple pages will thrash the cache anyway.

    The truncate microbenchmarks are not shown as this patch affects the
    allocation path and not the free path. A page fault microbenchmark was
    tested but it showed no sigificant difference which is not surprising
    given that the __GFP_COLD branches are a miniscule percentage of the
    fault path.

    Link: http://lkml.kernel.org/r/20171018075952.10627-9-mgorman@techsingularity.net
    Signed-off-by: Mel Gorman
    Acked-by: Vlastimil Babka
    Cc: Andi Kleen
    Cc: Dave Chinner
    Cc: Dave Hansen
    Cc: Jan Kara
    Cc: Johannes Weiner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     

13 Nov, 2017

2 commits

  • * pm-sleep:
    freezer: Fix typo in freezable_schedule_timeout() comment
    PM / s2idle: Clear the events_check_enabled flag
    PM / sleep: Remove pm_complete_with_resume_check()
    PM: ARM: locomo: Drop suspend and resume bus type callbacks
    PM: Use a more common logging style
    PM: Document rules on using pm_runtime_resume() in system suspend callbacks

    Rafael J. Wysocki
     
  • * pm-cpufreq-sched:
    cpufreq: schedutil: Reset cached_raw_freq when not in sync with next_freq

    * pm-opp:
    PM / OPP: Add dev_pm_opp_{un}register_get_pstate_helper()
    PM / OPP: Support updating performance state of device's power domain
    PM / OPP: add missing of_node_put() for of_get_cpu_node()
    PM / OPP: Rename dev_pm_opp_register_put_opp_helper()
    PM / OPP: Add missing of_node_put(np)
    PM / OPP: Move error message to debug level
    PM / OPP: Use snprintf() to avoid kasprintf() and kfree()
    PM / OPP: Move the OPP directory out of power/

    Rafael J. Wysocki
     

09 Nov, 2017

1 commit

  • Problem: This flag does not get cleared currently in the suspend or
    resume path in the following cases:

    * In case some driver's suspend routine returns an error.
    * Successful s2idle case
    * etc?

    Why is this a problem: What happens is that the next suspend attempt
    could fail even though the user did not enable the flag by writing to
    /sys/power/wakeup_count. This is 1 use case how the issue can be seen
    (but similar use case with driver suspend failure can be thought of):

    1. Read /sys/power/wakeup_count
    2. echo count > /sys/power/wakeup_count
    3. echo freeze > /sys/power/wakeup_count
    4. Let the system suspend, and wakeup the system using some wake source
    that calls pm_wakeup_event() e.g. power button or something.
    5. Note that the combined wakeup count would be incremented due
    to the pm_wakeup_event() in the resume path.
    6. After resuming the events_check_enabled flag is still set.

    At this point if the user attempts to freeze again (without writing to
    /sys/power/wakeup_count), the suspend would fail even though there has
    been no wake event since the past resume.

    Address that by clearing the flag just before a resume is completed,
    so that it is always cleared for the corner cases mentioned above.

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

    Rajat Jain
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

14 Oct, 2017

1 commit


09 Oct, 2017

1 commit


03 Oct, 2017

2 commits

  • Convert printks to pr_.

    Miscellanea:

    o Use pr_fmt with "PM:" and remove "PM: " from format strings
    o Coalesce format strings and realign format arguments
    o Convert an embedded incorrect function name to "%s: ", __func__
    o Convert a couple multi-line formats to multiple pr_ calls

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

    Joe Perches
     
  • The drivers/base/power/ directory is special and contains code related
    to power management core like system suspend/resume, hibernation, etc.
    It was fine to keep the OPP code inside it when we had just one file for
    it, but it is growing now and already has a directory for itself.

    Lets move it directly under drivers/ directory, just like cpufreq and
    cpuidle.

    Signed-off-by: Viresh Kumar
    Acked-by: Stephen Boyd
    Signed-off-by: Rafael J. Wysocki

    Viresh Kumar