sched_avg: add run queue averaging

Add code to calculate the run queue depth of a cpu and iowait
depth of the cpu.

The scheduler calls in to sched_update_nr_prod whenever there
is a runqueue change. This function maintains the runqueue average
and the iowait of that cpu in that time interval.

Whoever wants to know the runqueue average is expected to call
sched_get_nr_running_avg periodically to get the accumulated
runqueue and iowait averages for all the cpus.

Change-Id: Id8cb2ecf0ed479f090a83ccb72dd59c53fa73e0c
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
mach-msm: acpuclock 7627: enabled 98 Mhz
mach-msm: mm: removing huawei debug code
ion: Add dummy msm_ion header file

The msm specific parts of ion.h are being moved into a new header
file. For now, add a dummy header file to get clients transitioned
over.

Change-Id: Iac039678e1c3f15d87e67aa667f7e9883ca16669
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
mach-msm: board-7627a: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I3a1609e57c5156742300706cee698bd6e829c948
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
huawei_hardware_self_adapt: minor changes

- moved a function where it actually belongs to

- made MDP/ADSP sizes determination static again
msm: *removed deprecated PMEM*

msm: board-7627a: Remove pmem from 7627a/8625.

Pmem is defeatured because all the pmem
clients are now supported by ION.

Change-Id: I9b84e92621a13bf0aa9b099f5b2328af88ed4da5
Signed-off-by: Utsab Bose <ubose@codeaurora.org>

msm: Remove ANDROID_PMEM from the Kconfig dependencies

The PMEM driver is completely deprecated. Remove any Kconfig
that is still depending on it.

Change-Id: I3386a7eedf34213f2c644372a719ae00c65b0d6d
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: camera: Remove references to CONFIG_ANDROID_PMEM

CONFIG_ANDROID_PMEM is completely deprecated. Remove
all references to it.

Change-Id: I5033f51458d71fe8afcda3faa937c3da1ba31900
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: qdsp5: *merged updates from* CAF/LNX.LA.3.5.3_RB2.5
msm: audio: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: Ida4e46d0f257e8c27467a8c13f7a0eb710dd3f5c
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: adsp: qdsp5: Allow MOD_READY event in ENABLING state

JPEGTASK is receiving MOD_READY event after it is disabled
which is not expected. When JPEGTASK enable fails with
ETIMEDOUT error, this module is disabled immediately.
But MOD_READY event for this module is sent by RPC to
Apps ADSP Driver even after it is disabled. Ignore this
event incase module state is not in ENABLING state.

CRs-Fixed: 395420
Change-Id: I0bd637f8bee84e811a400ac107f81d3df7a64a07
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>

msm: audio: qdsp5: Add support for MIDI method

Currenly CAD driver only supports VOICE method when setting volume.
For applying dynamic PMIC gain MIDI method is used. Changes are made
to support MIDI method also.

Change-Id: Id2d4868c88ef1fc08bbdbd3757905edc5435923c
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

msm: audio: qdsp5: Fix for wrong device values sent to acdb

Wrong device values are being sent acdb driver callback function.
This is because for a new audio manager session which gets registered,
device info is sent only when there is change in device configuration
or sample rate configuration. Due to this, not all sessions are updated
with the current device info and wrong values are sent to acdb.
Avoid this by maintaining a common device info across all sessions
to send correct device values.

CRs-Fixed: 420467
Change-Id: I1d5555252aa56fddf28f06df5b60df6579f1ed7d
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

qdsp5: audio: Allow audio preprocessing only from acdb driver

audio pp(preprocessing) features enabled via acdb (Audio calibration
database) driver gets disabled by audio pcm encoder driver if audio
record enable acknowledgement comes after applying pp parameter
via acdb.

Fix this by allowing audio pp enable from pcm driver only
if acdb support is not available.

CRs-Fixed: 436891
Change-Id: I2882752f55ac1c3ac3160d28c081dd9940b9f83e
Signed-off-by: Manish Dewangan <manish@codeaurora.org>

msm: audio: qdsp5: Allow postprocessing only from acdb if present

Audio postprocessing(audio pp) features enabled via acdb (Audio calibration
database) driver gets disabled by audio postprocessing driver during
open.
Fix this by allowing legacy audio pp feature enable from postprocessing
driver only if acdb support is not available. Acdb driver maintains wrong
state due to improper update of stream id which is used to maintain
number of active sessions. Due to this postprocessing features are
enabled even before audpp task is enabled in adsp.

Change-Id: I817263b0134f0302e64093148bafbe559cbc100a
CRs-Fixed: 409488
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

msm: audio: qdsp5: Add wake up in audio manager callback

Audio manager enable is failing on timeout in few cases.
In audio manager callback for codec config, wake up is missing
in cases where CAD(Common Application Device) is not present.
Due to this timeout happens in enable call while waiting on
above condition. Add wake up in such case to avoid issues.

CRs-Fixed: 439047
Change-Id: I2c176513dd2aadf17190228e60bf042a794d8daf
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

qdsp5: audio: Avoid race condition by using mutex lock

There is chance of race condtion if audpp(audio postprocessing)
callback registration function is called concurrently
by more than one clients.

Avoid this by serializing audpp callback function using
mutex lock.

CRs-Fixed: 441525
Change-Id: Ic7524d83b32d54b09ba77648a266585957f49648
Signed-off-by: Manish Dewangan <manish@codeaurora.org>

msm: audio: qdsp5: Add support of dynamic re-enable of post proc

DSP can disable the post processing features due to unavailability
of MIPS during video playback. As a result difference in audio
quality is observed after video playback. Add support to re-enable
the post processing features once video playback ends and MIPS are
available.
DSP sends a message whenever post processing features are disabled
due to unavailability of MIPS and sends another message once the
MIPS are available. AUDPP driver broadcasts these messages to all
the relavant clients which keeps track of disabled features and
re-enables them when re-enable message is received from DSP.

Change-Id: Ic4cad4e7b0afe4377006055417ba193b01cce930
Signed-off-by: Sriranjan Srikantam <cssrika@codeaurora.org>

qdsp5: audio: Release wake_lock resources at exit

Wake_lock resources acquired during module init are not
released during exit. This leads to corruption in list
maintained by wake_lock driver and cause crash.
Release the resources before exiting the module.

CRs-Fixed: 405797
Change-Id: I6340fff390af677c47c59264e01f6cd723fea357
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

qdsp5: audio: Check for earlysuspend support.

Declaration of audac3_post_event is not currently
guarded by an ifdef check for CONFIG_HAS_EARLYSUSPEND
(the function's definition is), causing builds without
early suspend to fail. Use the ifdef check for the
declaration to avoid this.

Change-Id: I5a5758df6b543d100351644b20795b30f74e556b
Signed-off-by: Anurag Singh <anursing@codeaurora.org>

msm: Remove all references to pmem from audio files

PMEM is no longer supported. Remove all references to it.

Change-Id: If68c41901b8fb0b9382650c3123a68958f769761
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

qdsp5: memset stack buffer allocation.

This is needed to avoid garbage data in uninitialized variables.

Change-Id: I3a043a4ce4e14d8e0c24b434181dff484eddac72
CRs-Fixed: 551548
CRs-Fixed: 551542
CRs-Fixed: 551555
CRs-Fixed: 551563
CRs-Fixed: 551566
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
Makefile: changing flags
msm: platsmp-8625: cleanup macro names

All the macros defined for 8625 secondary core indicates dual
core. Cleanup macros to be more generic to fit for multi core.

Change-Id: Ia21b2fe6e4a980ae1d60729ceb4085d1a72a16d3
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: board-qrd7627a: Enabling RTB for 7627a and 8625.

Enabling RTB(Register Trace Buffer) will help in taking RTB logs. RTB
implements uncached logging of particular events (like readl/writel,
printk, hotplug etc). RTB is useful because it provides a
rough indication of the last events that occured on each core prior to
a crash/reset.

Change-Id: I7b26e2c2b8d012028beaa3d1ed36f85603ad411f
Signed-off-by: Utsab Bose <ubose@codeaurora.org>
board: 7627a: Update the GDFS residency values to optimal value.

The current residency setting of 6msec for GDFS is way too high to be
entered during active test cases like video, gfx. We profiled this setting
for optimal value on Strider and found 500usec is large enough without
sacrificing the power savings. Hence this change updates the setting to
500usec.

Change-Id: I62bd5431745462e6fdd373cea1d50ccd74b8152d
Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>
kernel: sched: enabled ARCH_POWER
mach-msm: board-7x27a: *code cleanup*
msm: devices msm7627a: *GPU overclock*

- slightly overclock from 300 MHz to 320 Mhz

We could go higher, but 1st i need to achieve, that the
default clock stays @ 300 Mhz, without having to set it
during the init.rc process.