24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

04 Mar, 2020

1 commit

  • The target_value field in struct pm_qos_constraints is used for
    lockless access to the effective constraint value of a given QoS
    list, so the readers of it cannot expect it to always reflect the
    most recent effective constraint value. However, they can and do
    expect it to be equal to a valid effective constraint value computed
    at a certain time in the past (event though it may not be the most
    recent one), so add READ|WRITE_ONCE() annotations around the
    target_value accesses to prevent the compiler from possibly causing
    that expectation to be unmet by generating code in an exceptionally
    convoluted way.

    Signed-off-by: Qian Cai
    [ rjw: Changelog ]
    Signed-off-by: Rafael J. Wysocki

    Qian Cai
     

14 Feb, 2020

3 commits

  • Because cpuidle is the only user of the effective constraint coming
    from the CPU latency QoS, add #ifdef CONFIG_CPU_IDLE around that code
    to avoid building it unnecessarily.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Update the file information comments in include/linux/pm_qos.h
    and kernel/power/qos.c by adding titles along with copyright and
    authors information to them and changing the qos.c description to
    better reflect its contents (outdated information is dropped from
    it in particular).

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Drop the PM QoS classes enum including PM_QOS_CPU_DMA_LATENCY,
    drop the wrappers around pm_qos_request(), pm_qos_request_active(),
    and pm_qos_add/update/remove_request() introduced previously, rename
    these functions, respectively, to cpu_latency_qos_limit(),
    cpu_latency_qos_request_active(), and
    cpu_latency_qos_add/update/remove_request(), and update their
    kerneldoc comments. [While at it, drop some useless comments from
    these functions.]

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     

13 Feb, 2020

11 commits

  • Change the return type of pm_qos_request() to be the same as the
    one of pm_qos_read_value() called by it internally and stop exporting
    it to modules (because its only caller, cpuidle, is not modular).

    Also move the pm_qos_read_value() header away from the CPU latency
    QoS API function headers in pm_qos.h (because it technically does
    not belong to that API).

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Modify the definitions of the CPU latency QoS trace events to take
    one argument (since PM_QOS_CPU_DMA_LATENCY is always passed as the
    pm_qos_class argument to them) and update the documentation of them
    accordingly (while at it, make it explicitly mention CPU latency QoS
    and relocate it after the device PM QoS trace events documentation).

    The names and output format of the trace events do not change to
    preserve user space compatibility.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • First, rename PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE to
    PM_QOS_CPU_LATENCY_DEFAULT_VALUE and update all of the code
    referring to it accordingly.

    Next, rename cpu_dma_constraints to cpu_latency_constraints, move
    the definition of it closer to the functions referring to it and
    update all of them accordingly. [While at it, add a comment to mark
    the start of the code related to the CPU latency QoS.]

    Finally, rename the pm_qos_power_*() family of functions and
    pm_qos_power_fops to cpu_latency_qos_*() and cpu_latency_qos_fops,
    respectively, and update the definition of cpu_latency_qos_miscdev.
    [While at it, update the miscdev interface code start comment.]

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Notice that pm_qos_remove_notifier() is not used at all and the only
    caller of pm_qos_add_notifier() is the cpuidle core, which only needs
    the PM_QOS_CPU_DMA_LATENCY notifier to invoke wake_up_all_idle_cpus()
    upon changes of the PM_QOS_CPU_DMA_LATENCY target value.

    First, to ensure that wake_up_all_idle_cpus() will be called
    whenever the PM_QOS_CPU_DMA_LATENCY target value changes, modify the
    pm_qos_add/update/remove_request() family of functions to check if
    the effective constraint for the PM_QOS_CPU_DMA_LATENCY has changed
    and call wake_up_all_idle_cpus() directly in that case.

    Next, drop the PM_QOS_CPU_DMA_LATENCY notifier from cpuidle as it is
    not necessary any more.

    Finally, drop both pm_qos_add_notifier() and pm_qos_remove_notifier(),
    as they have no callers now, along with cpu_dma_lat_notifier which is
    only used by them.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • First, change the definition of struct pm_qos_request so that it
    contains a struct pm_qos_constraints pointer (called "qos") instead
    of a PM QoS class number (in preparation for dropping the PM QoS
    classes concept altogether going forward) and move its definition
    (along with the definition of struct pm_qos_flags_request that does
    not change) after the definition of struct pm_qos_constraints.

    Next, drop the definition of struct pm_qos_object and the null_pm_qos
    and cpu_dma_pm_qos variables of that type along with pm_qos_array[]
    holding pointers to them and change the code to refer to the
    pm_qos_constraints structure directly or to use the new qos pointer
    in struct pm_qos_request for that instead of going through
    pm_qos_array[] to access it. Also update kerneldoc comments that
    mention pm_qos_class to refer to PM_QOS_CPU_DMA_LATENCY directly
    instead.

    Finally, drop register_pm_qos_misc(), introduce cpu_latency_qos_miscdev
    (with the name field set to "cpu_dma_latency") to implement the
    CPU latency QoS interface in /dev/ and register it directly from
    pm_qos_power_init().

    After these changes the notion of PM QoS classes remains only in the
    API (in the form of redundant function parameters that are ignored)
    and in the definitions of PM QoS trace events.

    While at it, some redundant local variables are dropped etc.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Reorder the code to avoid using extra function header declarations
    for the pm_qos_power_*() family of functions and drop those
    declarations.

    Also clean up the internals of those functions to consolidate checks,
    avoid using redundant local variables and similar.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • After commit c3082a674f46 ("PM: QoS: Get rid of unused flags") the
    only global PM QoS class in use is PM_QOS_CPU_DMA_LATENCY, so it
    does not really make sense to iterate over global QoS classes
    anywhere, since there is only one.

    Remove iterations over global QoS classes from the code and use
    PM_QOS_CPU_DMA_LATENCY as the target class directly where needed.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Move the definition of pm_qos_read_value() before the one of
    pm_qos_get_value() and add a kerneldoc comment to it (as it is
    not static).

    Also replace the BUG() in pm_qos_get_value() with WARN() (to
    prevent the kernel from crashing if an unknown PM QoS type is
    used by mistake) and drop the comment next to it that is not
    necessary any more.

    Additionally, drop the unnecessary inline modifier from the header
    of pm_qos_set_value().

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • Clean up the pm_qos_update_target() function:
    * Update its kerneldoc comment.
    * Drop the redundant ret local variable from it.
    * Reorder definitions of local variables in it.
    * Update a comment in it.

    Also update the kerneldoc comment of pm_qos_update_flags() (e.g.
    notifiers are not called by it any more) and add one emtpy line
    to its body (for more visual clarity).

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • The PM_QOS_SUM QoS type is not used, so drop it along with the
    code referring to it in pm_qos_get_value() and the related local
    variables in there.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     
  • The pm_qos_update_request_timeout() function is not called from
    anywhere, so drop it along with the work member in struct
    pm_qos_request needed by it.

    Also drop the useless pm_qos_update_request_timeout trace event
    that is only triggered by that function (so it never triggers at
    all) and update the trace events documentation accordingly.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Reviewed-by: Amit Kucheria
    Tested-by: Amit Kucheria

    Rafael J. Wysocki
     

12 Feb, 2020

1 commit

  • After commit c3082a674f46 ("PM: QoS: Get rid of unused flags") the
    only global PM QoS class in use is PM_QOS_CPU_DMA_LATENCY and the
    existing PM QoS debugfs interface has become overly complicated (as
    it takes other potentially possible PM QoS classes that are not there
    any more into account). It is also not particularly useful (the
    "type" of the PM_QOS_CPU_DMA_LATENCY is known, its aggregate value
    can be read from /dev/cpu_dma_latency and the number of requests in
    the queue does not really matter) and there are no known users
    depending on it. Moreover, there are dedicated trace events that
    can be used for tracking PM QoS usage with much higher precision.

    For these reasons, drop the PM QoS debugfs interface altogether.

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

    Rafael J. Wysocki
     

29 Nov, 2019

1 commit

  • Support for adding per-device frequency limits was removed in
    commit 2aac8bdf7a0f ("PM: QoS: Drop frequency QoS types from device PM QoS")
    after cpufreq switched to use a new "freq_constraints" construct.

    Restore support for per-device freq limits but base this upon
    freq_constraints. This is primarily meant to be used by the devfreq
    subsystem.

    This removes the "static" marking on freq_qos_apply but does not export
    it for modules.

    Signed-off-by: Leonard Crestez
    Reviewed-by: Matthias Kaehlcke
    Tested-by: Matthias Kaehlcke
    Signed-off-by: Rafael J. Wysocki

    Leonard Crestez
     

20 Nov, 2019

1 commit

  • Switching cpufreq drivers (or switching operation modes of the
    intel_pstate driver from "active" to "passive" and vice versa)
    does not work on some x86 systems with ACPI after commit
    3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS"), because
    the ACPI _PPC and thermal code uses the same frequency QoS request
    object for a given CPU every time a cpufreq driver is registered
    and freq_qos_remove_request() does not invalidate the request after
    removing it from its QoS list, so freq_qos_add_request() complains
    and fails when that request is passed to it again.

    Fix the issue by modifying freq_qos_remove_request() to clear the qos
    and type fields of the frequency request pointed to by its argument
    after removing it from its QoS list so as to invalidate it.

    Fixes: 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS")
    Reported-and-tested-by: Doug Smythies
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Viresh Kumar

    Rafael J. Wysocki
     

21 Oct, 2019

1 commit

  • Introduce frequency QoS, based on the "raw" low-level PM QoS, to
    represent min and max frequency requests and aggregate constraints.

    The min and max frequency requests are to be represented by
    struct freq_qos_request objects and the aggregate constraints are to
    be represented by struct freq_constraints objects. The latter are
    expected to be initialized with the help of freq_constraints_init().

    The freq_qos_read_value() helper is defined to retrieve the aggregate
    constraints values from a given struct freq_constraints object and
    there are the freq_qos_add_request(), freq_qos_update_request() and
    freq_qos_remove_request() helpers to manipulate the min and max
    frequency requests. It is assumed that the the helpers will not
    run concurrently with each other for the same struct freq_qos_request
    object, so if that may be the case, their uses must ensure proper
    synchronization between them (e.g. through locking).

    In addition, freq_qos_add_notifier() and freq_qos_remove_notifier()
    are provided to add and remove notifiers that will trigger on aggregate
    constraint changes to and from a given struct freq_constraints object,
    respectively.

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

    Rafael J. Wysocki
     

21 Aug, 2019

1 commit

  • The network_latency and network_throughput flags for PM-QoS have not
    found much use in drivers or in userspace since they were introduced.

    Commit 4a733ef1bea7 ("mac80211: remove PM-QoS listener") removed the
    only user PM_QOS_NETWORK_LATENCY in the kernel a while ago and there
    don't seem to be any userspace tools using the character device files
    either.

    PM_QOS_MEMORY_BANDWIDTH was never even added to the trace events.

    Remove all the flags except cpu_dma_latency.

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

    Amit Kucheria
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
    initial scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

23 Jan, 2019

1 commit


30 Nov, 2018

1 commit


29 May, 2018

1 commit


09 Apr, 2018

1 commit


03 Oct, 2017

1 commit

  • 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
     

18 Sep, 2016

1 commit


05 Sep, 2016

1 commit

  • of_clk_init() ends up calling into pm_qos_update_request() very early
    during boot where irq is expected to stay disabled.
    pm_qos_update_request() uses cancel_delayed_work_sync() which
    correctly assumes that irq is enabled on invocation and
    unconditionally disables and re-enables it.

    Gate cancel_delayed_work_sync() invocation with kevented_up() to avoid
    enabling irq unexpectedly during early boot.

    Signed-off-by: Tejun Heo
    Reported-and-tested-by: Qiao Zhou
    Link: http://lkml.kernel.org/r/d2501c4c-8e7b-bea3-1b01-000b36b5dfe9@asrmicro.com
    Signed-off-by: Rafael J. Wysocki

    Tejun Heo
     

24 Jan, 2015

1 commit

  • PM QoS requests are notoriously hard to debug and made even
    more so due to their highly dynamic nature. Having visibility
    into the internal data representation per constraint allows
    us to have much better appreciation of potential issues or
    bad usage by drivers in the system.

    So introduce for all classes of PM QoS, an entry in
    /sys/kernel/debug/pm_qos that shall show all the current
    requests as well as the snapshot of the value these requests
    boil down to. For example:
    ==> /sys/kernel/debug/pm_qos/cpu_dma_latency /sys/kernel/debug/pm_qos/memory_bandwidth
    Signed-off-by: Dave Gerlach
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Nishanth Menon
     

25 Sep, 2014

1 commit

  • Also adds a class type PM_QOS_SUM that aggregates the values by summing them.

    It can be used by memory controllers to calculate the optimum clock frequency
    based on the bandwidth needs of the different memory clients.

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

    Tomeu Vizoso
     

11 Feb, 2014

2 commits

  • Add a new latency tolerance device PM QoS type to be use for
    specifying active state (RPM_ACTIVE) memory access (DMA) latency
    tolerance requirements for devices. It may be used to prevent
    hardware from choosing overly aggressive energy-saving operation
    modes (causing too much latency to appear) for the whole platform.

    This feature reqiures hardware support, so it only will be
    available for devices having a new .set_latency_tolerance()
    callback in struct dev_pm_info populated, in which case the
    routine pointed to by it should implement whatever is necessary
    to transfer the effective requirement value to the hardware.

    Whenever the effective latency tolerance changes for the device,
    its .set_latency_tolerance() callback will be executed and the
    effective value will be passed to it. If that value is negative,
    which means that the list of latency tolerance requirements for
    the device is empty, the callback is expected to switch the
    underlying hardware latency tolerance control mechanism to an
    autonomous mode if available. If that value is PM_QOS_LATENCY_ANY,
    in turn, and the hardware supports a special "no requirement"
    setting, the callback is expected to use it. That allows software
    to prevent the hardware from automatically updating the device's
    latency tolerance in response to its power state changes (e.g. during
    transitions from D3cold to D0), which generally may be done in the
    autonomous latency tolerance control mode.

    If .set_latency_tolerance() is present for the device, a new
    pm_qos_latency_tolerance_us attribute will be present in the
    devivce's power directory in sysfs. Then, user space can use
    that attribute to specify its latency tolerance requirement for
    the device, if any. Writing "any" to it means "no requirement, but
    do not let the hardware control latency tolerance" and writing
    "auto" to it allows the hardware to be switched to the autonomous
    mode if there are no other requirements from the kernel side in the
    device's list.

    This changeset includes a fix from Mika Westerberg.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Add a new field, no_constraints_value, to struct pm_qos_constraints
    representing a list of PM QoS constraint requests to be returned by
    pm_qos_get_value() when that list of requests is empty.

    That field will be equal to default_value for all of the existing
    global PM QoS classes and for the resume latency device PM QoS type,
    but it will be different from default_value for the new latency
    tolerance device PM QoS type introduced by the next changeset.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

18 Oct, 2013

1 commit


14 Aug, 2013

1 commit

  • pm_qos_update_request_timeout() updates a qos and then schedules
    a delayed work item to bring the qos back down to the default
    after the timeout. When the work item runs, pm_qos_work_fn() will
    call pm_qos_update_request() and deadlock because it tries to
    cancel itself via cancel_delayed_work_sync(). Future callers of
    that qos will also hang waiting to cancel the work that is
    canceling itself. Let's extract the little bit of code that does
    the real work of pm_qos_update_request() and call it from the
    work function so that we don't deadlock.

    Before ed1ac6e (PM: don't use [delayed_]work_pending()) this didn't
    happen because the work function wouldn't try to cancel itself.

    Signed-off-by: Stephen Boyd
    Reviewed-by: Tejun Heo
    Cc: 3.9+ # 3.9+
    Signed-off-by: Rafael J. Wysocki

    Stephen Boyd
     

24 Jun, 2013

2 commits


21 Jun, 2013

1 commit

  • The valid start index for pm_qos_array is not 0, but
    PM_QOS_CPU_DMA_LATENCY. There is a null_pm_qos at index 0 of
    pm_qos_array. However, null_pm_qos is not created as misc device so
    that inclusion of 0 index for checking pm_qos_class especially for
    file operations is not proper here.

    [rjw: Changelog, a bit]
    Signed-off-by: Sahara
    Signed-off-by: Rafael J. Wysocki

    Sahara
     

26 Jan, 2013

1 commit


30 Nov, 2012

1 commit

  • * pm-sleep:
    PM / Freezer: Fixup compile error of try_to_freeze_nowarn()
    driver core / PM: move the calling to device_pm_remove behind the calling to bus_remove_device
    PM / Hibernate: use rb_entry
    PM / sysfs: replace strict_str* with kstrto*

    Rafael J. Wysocki