Free the allocated memory for level_name to avoid the
memory leak in regsiter_cpu_lpm_stats().
Change-Id: I24f0feff2e05963986eaaf54610a8a5ed079b692
Signed-off-by: Mohammed Khajapasha <mkhaja@codeaurora.org>
Cluster pm notifications without level information increases difficulty
and complexity for the registered drivers to figure out when the last
coherency level is going into power collapse.
Send notifications with level information that allows the registered
drivers to easily determine the cluster level that is going in/out of
power collapse.
There is an issue with this implementation. GIC driver saves and
restores the distributed registers as part of cluster notifications. On
newer platforms there are multiple cluster levels are defined (e.g l2,
cci etc). These cluster level notofications can happen independently.
On MSM platforms GIC is still active while the cluster sleeps in idle,
causing the GIC state to be overwritten with an incorrect previous state
of the interrupts. This leads to a system hang. Do not save and restore
on any L2 and higher cache coherency level sleep entry and exit.
Change-Id: I31918d6383f19e80fe3b064cfaf0b55e16b97eb6
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Add new module lpm-workarounds to support workarounds for
low power modes driver. Add workaround support for unvote
CX turbo vote during exit of rpm assisted power collapse.
On some targets rpm bumps up the CX to turbo while
coming out of power collapse, to reduce the power impact
of this the workaround is necessary.
Change-Id: I11b6e96f02dd3a0dec189ee568a1f7baa3e8894a
Signed-off-by: Srinivas Rao L <lsrao@codeaurora.org>
struct lpm_cluster_level's mode is an array of enum representing
SPM low power modes. The current code compares the values in it
with enum msm_pm_sleep_mode which represents cpu sleep modes.
Fix this by comparing mode with SPM low power modes.
Change-Id: I49ae054298f4f8f71a4a4476c541db3ec69935d0
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
CCI auto hardware clock gating is exercised independent of CCI
SPM. To support auto hardware clock gating, disable CCI SPM when
clock gating lpm level is chosen.
Change-Id: Iec20be34708c85161675c977153ef7198d926346
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
On targets that support auto clock gating, spm needs to be disabled
for the hardware to do auto clock gating. If auto clock gating is not
supported or not used, spm needs to be left enabled when programmed
for clock gating.
Add driver support to keep the spm enabled, and, if qchannel interface
is present then add driver support to enable spm legacy mode. This
would keep the spm enabled for clock gating. Use the dt flag
qcom,use-spm-clock-gating to determine if spm needs to be used for
clock gating.
Also, fix lpm-levels driver to support clock gating and auto clock gating
modes.
Change-Id: I4c796d7e063633e41910e780ee2a05e5205db0bd
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Issue:
System hangs as soon as USB is unplugged from the device.
Cpu pm notifications are to be sent only in the power collapse path,
but it is sent when cpu enters any low power modes. This results in
undesired and unexpected behavior.
Send cpu pm notifications only for power collapse and idle path.
Change-Id: I779152cd05c65b116e9ac88856de729c1212fe16
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
CCI auto hardware clock gating is exercised independent of CCI
SPM. To support auto hardware clock gating, disable CCI SPM when
clock gating lpm level is chosen.
Change-Id: Ice9cfdb9277e8604b9ac02541907caa6d30e160a
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Currently, all the event timers are associated to CPU0. These event
timers are not bind to any of the IRQs and always handled(hrtimer)
by CPU0. This event timers framework make sure event timers are
bound to clients IRQs and when the IRQ affinity has changed event
timer framework will make sure to move associated event timer to
a new CPU based on IRQ affinity.
CRs-fixed: 719258
Change-Id: Idbce3d5195655f558f74c208216f75515d235b8e
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Similar to cpu pm notifications, send cluster notifications whenever a
cluster goes into low power mode. Ensure that cpu pm notifications are
sent out for the all the cpus on the power domain before cluster
notification is sent out.
CRs-fixed: 751893
Change-Id: Ib098d41c4ec750c7af8142bb99977d9b417bf2f0
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
The next event value could be NULL if there is no event
queued. Add a NULL check to avoid wrong calculation of
next wakeup time.
Change-Id: I1ddd8db1803c8f88e99c050e8e40fb6cb5326bda
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
LPM modes can fail if there is a pending IPI interrupt at GIC CPU
interface. On some usecases frequent failure of LPM modes can
cause power and performance degradation. Hence, prevent cluster
low power modes when there is a pending IPI on cluster CPUs.
Change-Id: Id8a0ac24e4867ef824e0a6f11d989f1e1a2b0e93
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
SAW2 3.0 supports RPM handshake using SAW2_SPM_CTL register for the
sleep command in the SPM sequence. This allows a single power collapse
sequence for both cases when we don't want to notify RPM on apps power
down and when we want to.
This implementation is the same across all IPs in the apps processor
subsystem, but only a few SAW modules are allowed to notify RPM and
handshake with RPM when executing the 0x03 sleep command. Disallow and
check incorrect call on SPM, based on the flag provided in the device
tree.
Based on this flag in DT, set the SLP_CMD_MODE bit in SPM_CTL
register. Fail to set the low power mode if we are trying to send
rpm notification for a mode that does not support rpm notification.
Change-Id: I5527bd8da62673d68867842dbd80000d67965e6a
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Currently the cpuidle driver considers the mode selected by menu
governor for trace events. lpm_levels recalculates the cpu and system
modes within the enter_sleep function and overwrites the menu governor
mode selection with its decision. Due to this other modules that are
dependent on these tracepoints collect incorrect low power mode
information.
Move the tracepoint within lpm_levels such that the mode selected within
lpm-levels is correctly reported and traced.
Change-Id: I9059a107da21ceebe11ae83427d36a28cf3f1a8e
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
System level power collapse should only be configured from the last core
entering power collapse. Incorrect input parameters, when configuring
system level cluster power collapse, would result in the system having an
inconsistent view of the lpm status of one or more cores in a cluster.
This race condition would allow multiple cores to program the system level
cluster to enter power collapse. As part of configuring the system level
cluster to enter power collapse several operations are performed. Due to
the race condition these operations can end up being executed on a core
that is not the last core in the cluster. This duplicate execution could
result in a system state that is critical and nonrecoverable.
When configuring system level cluster power collapse, use a child mask that
identifies the current low power mode status of the children, to make sure
that the system level cluster power collapse is only configured by the last
child entering power collapse.
The check to see if the core that is attempting to configure system level
cluster for power collapse is indeed the last core, is a critical section.
Protect this check inside a spinlock.
CRs-fixed: 714779
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Change-Id: Ic44f1e12253ae508aa3a5d4962f77b1408b860f8
The scheduler currently receives the low power mode level that a CPU
is about to enter whereby 0 indicates the shallowest sleep state and
higher numbers indicate deeper sleep states. The scheduler, however,
operates on the notion of C-states whereby 0 indicates an active state
and a higher numbers indicate different sleep states. Due to this
mismatch the scheduler is unable to distinguish between an active CPU
and a CPU in the shallowest sleep state. Fix this by translating the
low power mode level to the appropriate C-state before communicating
it to the scheduler.
Change-Id: I60d985626cb799d436172c00861f05538c2b382a
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
If CPU hotplug is initiated before probe, the L2 of the cluster is not
configured for any low power mode and is not flushed. This results in data
incoherencies in ramdumps in particular, if the system crashed after.
To ensure that L2 is flushed, flush L2 during hotplug until lpm-levels
module is probed
CRs-fixed: 715757
Change-Id: I0fb203da68e78d4f0c4acf96db9e5863268d1f52
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
When selecting a cluster level, if a level can result in sleep set
transition and there are pending rpm acks, then ignore that level in the
search for the best cluster level.
CRs-fixed: 705303
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Change-Id: I915297b0b74c013bdeb69026e69204e7c6dc39b1
The coresight save/restore functions needs to be called when the L2 of the
respective clusters are placed in power collapse/GDHS. On a multi-cluster
system, keeping track of this using a static variable could result in
incorrect save/restore of CTI registers. Fix by using a variable
associated with a cluster.
Change-Id: Ib4ba5790af2a9e3bc245f1ef5010930b5cf4921c
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Scheduler needs to distinguish cpus that are in different C-states.
Having information on C-states, especially the cost of exiting a
particular state will help the scheduler make better task placement
decisions.
This patch extends the msm power management driver to provide required
information to the scheduler.
Change-Id: I569d5f8b3e18b0444e5517be500e82bf27d3d22f
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
When sending sleep-set requests send up 24 requests before reading any
acks. The RX FIFO can hold 24 acks. Increase the threshold to the
max number of acks the FIFO can hold, so as to delay the process of
emptying the FIFO.
Also check and return an err on timeout and propagate that error up the
call chain.
Change-Id: Ic774fad65fbaa1906fcc7c51ab0d8b3766b8a987
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Only cluster_enter events log for default levels causes
inconsistency. Log them only if the any low power mode is selected.
CRs-fixed: 692014
Change-Id: I5c549c1f9139d67a73e288a0393a19e52e9d2412
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Currently we choose power collapse or standalone power collapse
as default mode for hotplug. Instead select deepest mode based
on the least steady state power.
If lpm isn't probed yet, then check for mode availability for
this spm device and select this mode for cpu hotplug.
Change-Id: Ia54994ae4ed65af20318fdbe68095ac7177ad759
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
If atleast one of the core in a cluster is online, the cluster low power
modes should be determined by the idle characteristics. In one scenario,
when the last core to configure the cluster enters the low power modes
as a part of hotlug but the remainder of the cores are online, the
selection of the cluster low power modes should use parameters related
to idle states and not suspend states.
Change-Id: Ia0af8b57f668225736cfe4a7a33436fed6ffcd4a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Do not allow APSS cores to enter system level mode if there
is a pending acknowledge from RPM. At the same time allow
cores to enter individual power collapse as the cpu collapse
overhead time is low as compared to system level modes.
Change-Id: I6bb4048529690b4ceee8555b27444ece6da82e4a
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
The cluster_select() code is used for hotplug as well. When cores are
hotplugged as a result of suspend/resume, the cores in the cluster would
be offline, resulting in the cpumask_and() evaluating to 0, resulting
in the control hitting the incorrect BUG_ON().
Change-Id: Ifa4d7e1ee06384a2e371663294bfbe68bb4d523a
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Use the PM QoS cpu/cupmask variant to provide a mimimum CPU_DMA_LATENCY
for the requesting kernel modules. Kernel modules may specify individual
cpus/cpumask but mostly can set the IRQ affinity for QoS. The PM QoS
framework distils the requirement and can provide the latency
requirement for each cpu or a collection of cpus.
Change-Id: I5f5465653496427d3d40a25ec46570d3c183239e
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Add ftrace events to log entry/exit of cluster and cpu low power modes.
Also, add events to log parameters passed down to secure code during
power collapse.
Change-Id: I76e2faf63a80155509d6e3e610db1daa611c0b6a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
If the next wake up time for a core is less than the
current time then we should not subtract current time
from next event time which results in a large negative
value. In case the earliest event is expired already
then do not enter cluster low power mode.
Change-Id: Iab04ef9fa4a64e76817254f9c6af4af2d80abb26
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
The system can boot with all low power modes disabled by setting
sleep_disabled. In this scenario clock gating would also be disabled.
This could lead to thermal conditions that would result in the cores
being hotplugged. Even in the case where all other low power modes are
disabled allow the system to select clock gating as the default level.
Change-Id: I9460dbb417947987a8519813f98ac68de36ba538
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
In the event where cpu hotplug happens before lpm probe completion,
it fails as the per_cpu cluster variables and the remote spin lock
has not been initialized yet.
There is no need to serialize hotplug before reading all the cluster
levels for the target in the probe. Return the default flag and do
not acquire the remote spin lock in lpm_cpu_pre_pc_cb call.
Change-Id: Idbffa9c3a5ca5b4e8edf280760f26558230eb461
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
When the system enters suspend, this entry is tracked by a variable. Unset
this variable on exiting suspend.
Change-Id: I35a1f2caf38940ef95ad6c9a1627ff107061f0f1
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
When kernel is booted with lesser than max cpus possible, the lpm
levels' cpu mask does not account for hotplugged cores to be able to
enter a cluster/system low power mode. Fix by accounting for offline
cpus in the levels structure.
Change-Id: Icca70bf64d9faa511ce8611507101889051702a7
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Currently num_childs_in_sync does not get initialized as cluster
lookup returns NULL. Initialize the variable after per_cpu cluster
nodes are initialized.
Change-Id: Iae30debe7c52324d6e2cb666ef96ee894144358e
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
By default, the lpm levels are disabled. For debug scenarios, it is
beneficial to start the device with low power modes disabled. Provide a
module parameter to override the default behavior
Change-Id: I79c5fa665fdf2b3d6331e2c51e22a5990ba5bf1f
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Add sysfs interface to allow/disallow low power modes. Every level
specified in the Devicetree for each cpu and cluster will have an
idle_enabled and suspend_enabled option that controls the availability of
the low power mode for CPUIdle and HOTPLUG/Suspend frameworks.
Change-Id: Ic27f3a586eb9992c611411d2a13365b909ae48a3
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
L2 SCU is turned off on L2 PC and L2 GDHS. Save and then restore cpu ctis
on L2 entering PC or GDHS and restore on exit.
Change-Id: I20360f8be213a634b5a4f9aa4cb7e0ef0aa263be
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>