04 Dec, 2020

4 commits

  • Make it possible to retrieve a copy of the psci_0_1_function_ids struct.
    This is useful for KVM if it is configured to intercept host's PSCI SMCs.

    Signed-off-by: David Brazdil
    Signed-off-by: Marc Zyngier
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20201202184122.26046-7-dbrazdil@google.com

    David Brazdil
     
  • Small refactor that replaces array of v0.1 function IDs indexed by an
    enum of function-name constants with a struct of function IDs "indexed"
    by field names. This is done in preparation for exposing the IDs to
    other parts of the kernel. Exposing a struct avoids the need for
    bounds checking.

    Signed-off-by: David Brazdil
    Signed-off-by: Marc Zyngier
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20201202184122.26046-6-dbrazdil@google.com

    David Brazdil
     
  • Refactor implementation of v0.1+ functions (CPU_SUSPEND, CPU_OFF,
    CPU_ON, MIGRATE) to have two functions psci_0_1_foo / psci_0_2_foo that
    select the function ID and call a common helper __psci_foo.

    This is a small cleanup so that the function ID array is only used for
    v0.1 configurations.

    Signed-off-by: David Brazdil
    Signed-off-by: Marc Zyngier
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20201202184122.26046-5-dbrazdil@google.com

    David Brazdil
     
  • KVM's host PSCI SMC filter needs to be aware of the PSCI version of the
    system but currently it is impossible to distinguish between v0.1 and
    PSCI disabled because both have get_version == NULL.

    Populate get_version for v0.1 with a function that returns a constant.

    psci_opt.get_version is currently unused so this has no effect on
    existing functionality.

    Signed-off-by: David Brazdil
    Signed-off-by: Marc Zyngier
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20201202184122.26046-4-dbrazdil@google.com

    David Brazdil
     

22 Sep, 2020

1 commit

  • The current user (cpuidle-psci) of psci_set_osi_mode() only needs to enable
    the PSCI OSI mode. Although, as subsequent changes shows, there is a need
    to be able to reset back into the PSCI PC mode.

    Therefore, let's extend psci_set_osi_mode() to take a bool as in-parameter,
    to let the user indicate whether to enable OSI or to switch back to PC
    mode.

    Reviewed-by: Sudeep Holla
    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

07 Aug, 2020

1 commit

  • Pull sched/fifo updates from Ingo Molnar:
    "This adds the sched_set_fifo*() encapsulation APIs to remove static
    priority level knowledge from non-scheduler code.

    The three APIs for non-scheduler code to set SCHED_FIFO are:

    - sched_set_fifo()
    - sched_set_fifo_low()
    - sched_set_normal()

    These are two FIFO priority levels: default (high), and a 'low'
    priority level, plus sched_set_normal() to set the policy back to
    non-SCHED_FIFO.

    Since the changes affect a lot of non-scheduler code, we kept this in
    a separate tree"

    * tag 'sched-fifo-2020-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits)
    sched,tracing: Convert to sched_set_fifo()
    sched: Remove sched_set_*() return value
    sched: Remove sched_setscheduler*() EXPORTs
    sched,psi: Convert to sched_set_fifo_low()
    sched,rcutorture: Convert to sched_set_fifo_low()
    sched,rcuperf: Convert to sched_set_fifo_low()
    sched,locktorture: Convert to sched_set_fifo()
    sched,irq: Convert to sched_set_fifo()
    sched,watchdog: Convert to sched_set_fifo()
    sched,serial: Convert to sched_set_fifo()
    sched,powerclamp: Convert to sched_set_fifo()
    sched,ion: Convert to sched_set_normal()
    sched,powercap: Convert to sched_set_fifo*()
    sched,spi: Convert to sched_set_fifo*()
    sched,mmc: Convert to sched_set_fifo*()
    sched,ivtv: Convert to sched_set_fifo*()
    sched,drm/scheduler: Convert to sched_set_fifo*()
    sched,msm: Convert to sched_set_fifo*()
    sched,psci: Convert to sched_set_fifo*()
    sched,drbd: Convert to sched_set_fifo*()
    ...

    Linus Torvalds
     

09 Jul, 2020

2 commits

  • The return value of down_and_up_cpus() can be assigned to @err directly.
    With that, the useless assignment to @err with zero can be dropped.

    Signed-off-by: Gavin Shan
    Reviewed-by: Sudeep Holla
    Link: https://lore.kernel.org/r/20200630075943.203954-1-gshan@redhat.com
    Signed-off-by: Will Deacon

    Gavin Shan
     
  • The CPU mask (@tmp) should be released on failing to allocate
    @cpu_groups or any of its elements. Otherwise, it leads to memory
    leakage because the CPU mask variable is dynamically allocated
    when CONFIG_CPUMASK_OFFSTACK is enabled.

    Signed-off-by: Gavin Shan
    Reviewed-by: Sudeep Holla
    Link: https://lore.kernel.org/r/20200630075227.199624-1-gshan@redhat.com
    Signed-off-by: Will Deacon

    Gavin Shan
     

15 Jun, 2020

2 commits

  • Ingo suggested that since the new sched_set_*() functions are
    implemented using the 'nocheck' variants, they really shouldn't ever
    fail, so remove the return value.

    Cc: axboe@kernel.dk
    Cc: daniel.lezcano@linaro.org
    Cc: sudeep.holla@arm.com
    Cc: airlied@redhat.com
    Cc: broonie@kernel.org
    Cc: paulmck@kernel.org
    Suggested-by: Ingo Molnar
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Ingo Molnar

    Peter Zijlstra
     
  • Because SCHED_FIFO is a broken scheduler model (see previous patches)
    take away the priority field, the kernel can't possibly make an
    informed decision.

    Effectively changes prio from 99 to 50.

    XXX this thing is horrific, it basically open-codes a stop-machine and
    idle.

    Cc: daniel.lezcano@linaro.org
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Ingo Molnar
    Acked-by: Valentin Schneider
    Tested-by: Sudeep Holla

    Peter Zijlstra
     

21 May, 2020

3 commits

  • Commit f2ae97062a48 ("firmware: smccc: Refactor SMCCC specific bits into
    separate file") introduced the following build warning:

    drivers/firmware/smccc/smccc.c:14:13: warning: no previous prototype for
    function 'arm_smccc_version_init' [-Wmissing-prototypes]
    void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit)
    ^~~~~~~~~~~~~~~~~~~~~~

    Fix the same by adding the missing prototype in arm-smccc.h

    Reported-by: kbuild test robot
    Signed-off-by: Sudeep Holla
    Link: https://lore.kernel.org/r/20200521110836.57252-1-sudeep.holla@arm.com
    Signed-off-by: Will Deacon

    Sudeep Holla
     
  • In order to add newer SMCCC v1.1+ functionality and to avoid cluttering
    PSCI firmware driver with SMCCC bits, let us move the SMCCC specific
    details under drivers/firmware/smccc/smccc.c

    We can also drop conduit and smccc_version from psci_operations structure
    as SMCCC was the sole user and now it maintains those.

    No functionality change in this patch though.

    Signed-off-by: Sudeep Holla
    Tested-by: Etienne Carriere
    Reviewed-by: Etienne Carriere
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20200518091222.27467-6-sudeep.holla@arm.com
    Signed-off-by: Will Deacon

    Sudeep Holla
     
  • Instead of maintaining 2 sets of enums/macros for tracking SMCCC version,
    let us drop smccc_version enum and use ARM_SMCCC_VERSION_1_x directly
    instead.

    This is in preparation to drop smccc_version here and move it separately
    under drivers/firmware/smccc.

    Signed-off-by: Sudeep Holla
    Tested-by: Etienne Carriere
    Reviewed-by: Steven Price
    Reviewed-by: Etienne Carriere
    Acked-by: Mark Rutland
    Link: https://lore.kernel.org/r/20200518091222.27467-5-sudeep.holla@arm.com
    Signed-off-by: Will Deacon

    Sudeep Holla
     

25 Mar, 2020

1 commit

  • The core device API performs extra housekeeping bits that are missing
    from directly calling cpu_up/down().

    See commit a6717c01ddc2 ("powerpc/rtas: use device model APIs and
    serialization during LPM") for an example description of what might go
    wrong.

    This also prepares to make cpu_up/down a private interface of the CPU subsystem.

    Signed-off-by: Qais Yousef
    Signed-off-by: Thomas Gleixner
    Cc: Lorenzo Pieralisi
    Link: https://lkml.kernel.org/r/20200323135110.30522-15-qais.yousef@arm.com

    Qais Yousef
     

02 Jan, 2020

1 commit

  • To allow subsequent changes to implement support for OSI mode through the
    cpuidle-psci driver, export the existing psci_has_osi_support(). Export
    also a new function, psci_set_osi_mode(), that allows its caller to enable
    the OS-initiated CPU-suspend mode in the PSCI FW.

    To deal with backwards compatibility for a kernel started through a kexec
    call, default to set the CPU-suspend mode to the Platform Coordinated mode
    during boot.

    Signed-off-by: Ulf Hansson
    Reviewed-by: Sudeep Holla

    Ulf Hansson
     

14 Oct, 2019

2 commits

  • Now that we have common SMCCC_CONDUIT_* definitions, migrate the PSCI
    code over to them, and kill off the old PSCI_CONDUIT_* definitions.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland
    Acked-by: Lorenzo Pieralisi
    Acked-by: Will Deacon
    Signed-off-by: Catalin Marinas

    Mark Rutland
     
  • SMCCC callers are currently amassing a collection of enums for the SMCCC
    conduit, and are having to dig into the PSCI driver's internals in order
    to figure out what to do.

    Let's clean this up, with common SMCCC_CONDUIT_* definitions, and an
    arm_smccc_1_1_get_conduit() helper that abstracts the PSCI driver's
    internal state.

    We can kill off the PSCI_CONDUIT_* definitions once we've migrated users
    over to the new interface.

    Signed-off-by: Mark Rutland
    Acked-by: Lorenzo Pieralisi
    Acked-by: Will Deacon
    Signed-off-by: Catalin Marinas

    Mark Rutland
     

10 Aug, 2019

3 commits

  • Current PSCI code handles idle state entry through the
    psci_cpu_suspend_enter() API, that takes an idle state index as a
    parameter and convert the index into a previously initialized
    power_state parameter before calling the PSCI.CPU_SUSPEND() with it.

    This is unwieldly, since it forces the PSCI firmware layer to keep track
    of power_state parameter for every idle state so that the
    index->power_state conversion can be made in the PSCI firmware layer
    instead of the CPUidle driver implementations.

    Move the power_state handling out of drivers/firmware/psci
    into the respective ACPI/DT PSCI CPUidle backends and convert
    the psci_cpu_suspend_enter() API to get the power_state
    parameter as input, which makes it closer to its firmware
    interface PSCI.CPU_SUSPEND() API.

    A notable side effect is that the PSCI ACPI/DT CPUidle backends
    now can directly handle (and if needed update) power_state
    parameters before handing them over to the PSCI firmware
    interface to trigger PSCI.CPU_SUSPEND() calls.

    Signed-off-by: Lorenzo Pieralisi
    Acked-by: Daniel Lezcano
    Reviewed-by: Ulf Hansson
    Reviewed-by: Sudeep Holla
    Cc: Will Deacon
    Cc: Ulf Hansson
    Cc: Sudeep Holla
    Cc: Daniel Lezcano
    Cc: Catalin Marinas
    Cc: Mark Rutland
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Will Deacon

    Lorenzo Pieralisi
     
  • Allow selection of the PSCI CPUidle in the kernel by updating
    the respective Kconfig entry.

    Remove PSCI callbacks from ARM/ARM64 generic CPU ops
    to prevent the PSCI idle driver from clashing with the generic
    ARM CPUidle driver initialization, that relies on CPU ops
    to initialize and enter idle states.

    Signed-off-by: Lorenzo Pieralisi
    Reviewed-by: Ulf Hansson
    Cc: Will Deacon
    Cc: Ulf Hansson
    Cc: Sudeep Holla
    Cc: Daniel Lezcano
    Cc: Catalin Marinas
    Cc: Mark Rutland
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Will Deacon

    Lorenzo Pieralisi
     
  • The PSCI checker currently relies on the generic ARM CPUidle
    infrastructure to enter an idle state, which in turn creates
    a dependency that is not really needed.

    The PSCI checker code to test PSCI CPU suspend is built on
    top of the CPUidle framework and can easily reuse the
    struct cpuidle_state.enter() function (previously initialized
    by an idle driver, with a PSCI back-end) to trigger an entry
    into an idle state, decoupling the PSCI checker from the
    generic ARM CPUidle infrastructure and simplyfing the code
    in the process.

    Convert the PSCI checker suspend entry function to use
    the struct cpuidle_state.enter() function callback.

    Signed-off-by: Lorenzo Pieralisi
    Acked-by: Daniel Lezcano
    Reviewed-by: Ulf Hansson
    Reviewed-by: Sudeep Holla
    Cc: Sudeep Holla
    Cc: Mark Rutland
    Signed-off-by: Will Deacon

    Lorenzo Pieralisi
     

17 Jun, 2019

1 commit

  • Since commit 85f1abe0019f ("kthread, sched/wait: Fix kthread_parkme()
    completion issue"), kthreads that are bound to a CPU must be parked
    before being stopped. At the moment the PSCI checker calls
    kthread_stop() directly on the suspend kthread, which triggers the
    following warning:

    [ 6.068288] WARNING: CPU: 1 PID: 1 at kernel/kthread.c:398 __kthread_bind_mask+0x20/0x78
    ...
    [ 6.190151] Call trace:
    [ 6.192566] __kthread_bind_mask+0x20/0x78
    [ 6.196615] kthread_unpark+0x74/0x80
    [ 6.200235] kthread_stop+0x44/0x1d8
    [ 6.203769] psci_checker+0x3bc/0x484
    [ 6.207389] do_one_initcall+0x48/0x260
    [ 6.211180] kernel_init_freeable+0x2c8/0x368
    [ 6.215488] kernel_init+0x10/0x100
    [ 6.218935] ret_from_fork+0x10/0x1c
    [ 6.222467] ---[ end trace e05e22863d043cd3 ]---

    kthread_unpark() tries to bind the thread to its CPU and aborts with a
    WARN() if the thread wasn't in TASK_PARKED state. Park the kthreads
    before stopping them.

    Fixes: 85f1abe0019f ("kthread, sched/wait: Fix kthread_parkme() completion issue")
    Signed-off-by: Jean-Philippe Brucker
    Reviewed-by: Sudeep Holla
    Acked-by: Lorenzo Pieralisi
    Signed-off-by: Olof Johansson

    Jean-Philippe Brucker
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 655 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


17 Apr, 2019

1 commit

  • PSCI v1.1 introduced SYSTEM_RESET2 to allow both architectural resets
    where the semantics are described by the PSCI specification itself as
    well as vendor-specific resets. Currently only system warm reset
    semantics is defined as part of architectural resets by the specification.

    This patch implements support for SYSTEM_RESET2 by making using of
    reboot_mode passed by the reboot infrastructure in the kernel.

    Acked-by: Mark Rutland
    Tested-by: Aaro Koskinen
    Signed-off-by: Sudeep Holla
    Signed-off-by: Rafael J. Wysocki

    Sudeep Holla
     

12 Apr, 2019

4 commits

  • PSCI firmware v1.0+, supports two different modes for CPU_SUSPEND.
    The Platform Coordinated mode, which is the default and mandatory
    mode, while support for the OS initiated (OSI) mode is optional.

    In some cases it's interesting for the user/developer to know if
    the OSI mode is supported by the PSCI FW, so print a message to
    the log if that is the case.

    Co-developed-by: Lina Iyer
    Signed-off-by: Ulf Hansson
    Reviewed-by: Daniel Lezcano
    Acked-by: Mark Rutland
    Acked-by: Lorenzo Pieralisi
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • Instead of having each PSCI init function taking care of the
    of_node_put(), deal with that from psci_dt_init(), as this enables
    a bit simpler error path for each PSCI init function.

    Co-developed-by: Lina Iyer
    Signed-off-by: Ulf Hansson
    Acked-by: Mark Rutland
    Reviewed-by: Daniel Lezcano
    Acked-by: Lorenzo Pieralisi
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • Split the psci_dt_cpu_init_idle() function into two functions. This
    makes the code clearer and provides better re-usability.

    Co-developed-by: Lina Iyer
    Signed-off-by: Ulf Hansson
    Acked-by: Daniel Lezcano
    Acked-by: Mark Rutland
    Acked-by: Lorenzo Pieralisi
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • Some following changes extends the PSCI driver with some additional
    files. Avoid to continue cluttering the toplevel firmware directory
    and first move the PSCI files into a PSCI sub-directory.

    Suggested-by: Mark Rutland
    Signed-off-by: Ulf Hansson
    Acked-by: Daniel Lezcano
    Acked-by: Mark Rutland
    Acked-by: Lorenzo Pieralisi
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson