msm: qdsp5: Exit VOIP thread at the end of MVS session

In the MVS open, a thread is created but the same is not getting exited
during the MVS release
Added logic to exit the thread in the release.

CRs-Fixed: 395518
Signed-off-by: Vinay Vaka <vvaka@codeaurora.org>
(cherry picked from commit a8b3a3c5db644a6308dcb0e67b3fe365060f9001)

Change-Id: I39a90f9ba45285d812d23444a2be8802bf171adf
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/qdsp5/audio_mvs.c
msm: qdsp5: Moving initialization of wakelock and mutex to mvs init

Added change to move initialization of wakelock and mutex to mvs init
to reduce the VoIP startup time.

CRs-Fixed: 395518
Signed-off-by: Vinay Vaka <vvaka@codeaurora.org>
(cherry picked from commit 3417fa357f663a00f09e435a70f566e02e10211c)

Change-Id: I3881751c9c694e6f5311cab6f746119705ac0bcf
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
msm: qdsp5: Fix for noise issue during VOIP call

Driver discards the downlink packets when input queue is full.
Added code to block processing of downlink packets in the write()
till a input queue free slot is available for write.

CRs-Fixed: 400514
Signed-off-by: Vinay Vaka <vvaka@codeaurora.org>
(cherry picked from commit 06540bf4476714f6fd4d58aa21ca0cd7cf4f6656)

Change-Id: Ic618f33c28c5ab3463268b9f5458beb521c5501b
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
msm: audio:qdsp5: Initialize wait queue before creating acdb thread.

Uninitialized acdb wait queue is getting accessed in acdb kernel
thread, this results in kernel crash.

To fix this issue initialized wait queue before creating acdb
kernel thread.

CRs-Fixed: 417385

Signed-off-by: Manish Dewangan <manish@codeaurora.org>
(cherry picked from commit cc3f079af111a17ce121e7af3e1b65d79e863022)

Change-Id: Ie939abfdb479d1ba6096b2186dc621889407fd96
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/qdsp5/audio_acdb.c
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: I6fc66f5683e81266f234b3bfb49b5d3d8167acaa
Signed-off-by: Chaithanya Krishna Bacharaju <chaithan@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/qdsp5/snd_cad.c
qdsp5: mvs: Allow only single instance of mvs session

During MVS open, mvs driver calls msm_rpc_connect to establish
rpc connection with modem mvs server without checking for
current state of mvs driver. This causes modem oncrpc memory
pool to exhaust if back to back open is called without closing
the mvs driver.

Added check to call rpc connect only if mvs driver is in
closed state.

(cherry picked from commit 32c4287136ff1dedd396586fd3adb3ce7959fc2c)

Change-Id: I8abbe1fcc9d4d099938bbf7556e32161aaad75a8
CRs-Fixed: 433208
Signed-off-by: Manish Dewangan <manish@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>

Conflicts:
	arch/arm/mach-msm/qdsp5/audpp.c
qdsp5: mvs: Fix kernel panic due to early closure of endpont

MVS driver closes the RPC endpoint while it sends reply to the
RPC read sometimes. The RPC write for this reply results in
crash as endpoint is already closed.
Wait for RPC read and reply to complete before closing the
endpoint.

CRs-Fixed: 443706
Change-Id: Ia1918082118f23ab9aefec1c3a04908d8d8c1199
Signed-off-by: Sriranjan Srikantam <cssrika@codeaurora.org>
msm: adsp: Avoid preemption during driver registration

Prevent the scenario where platform_driver_register(adsp)
is called first but kworker from RPC router preempts it
before it finishes driver register.

CRs-Fixed: 448408
Change-Id: I2022200413fb77a073e10bd19b8fff82a3e3d46e
Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
qdsp5: audio: Fix crash in audpp driver due to invalid state

Change-Id: I5fb0fcfc6c4204d52c75ca8aa77a47df717ef099
qdsp5: memset stack buffer allocation.

This is needed to avoid garbage data in uninitialized variables.

Change-Id: I8a55cd188f8dac86bfafe9c1fc1b4c9e44623776
CRs-Fixed: 553260
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
ASoC:msm:qdsp5: Checks to avoid buffer overflow.

This is needed to avoid buffer over flow, when userspace data in
kernel may go beyond buffer boundary.

Change-Id: Ic56599511ddef8e53808b2dc7e983060c0e104ef
CRs-Fixed: 550177
CRs-Fixed: 550181
CRs-Fixed: 550196
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
msm: qdsp5: Memset stack buffer allocation.

This is needed to avoid garbage data in uninitialized variables.

Change-Id: I2ef43f64b1d31e88bc2435169632c2efc4fb9f88
CRs-Fixed: 553262
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
msm: qdsp5: memset stack buffer allocation.

This is needed to avoid garbage data in uninitialized variables.

Change-Id: Ib3362ae4bc9453e16eb6951a6e2829e4a0decb8e
CRs-Fixed: 554300
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
msm: qdsp5: memset stack buffer allocation.

This is needed to avoid garbage data in uninitialized variables.

Change-Id: I061e7373c05d0239e2c0cb53c71a9ca1cebe6fc8
CRs-Fixed: 554317
CRs-Fixed: 554822
CRs-Fixed: 554844
CRs-Fixed: 556206
CRs-Fixed: 556792
CRs-Fixed: 556786
CRs-Fixed: 556782
CRs-Fixed: 556223
CRs-Fixed: 556219
CRs-Fixed: 556217
CRs-Fixed: 556216
CRs-Fixed: 556212
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
msm: qdsp5: Update code to avoid access userspace data

Copy userspace data to kernel and then access the data
to avoid invalid pointer access issue.
Also, prevent use of uninitialized variables by checking
sscanf return value.

Change-Id: I53c6b0218b26823abfa60fcc015e6c44882b9e5e
CRs-Fixed: 547923
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
msm:qdsp5:Fix to avoid kernel memory disclosure in audio_mvs_ioctl

In audio_mvs_ioctl, msm_audio_mvs_config structre's dtx_mode and
min_max_rate are not initializing, this can lead to a situation
where kernel stack memory is leaked back to user space.
Initializing the strcuture to zero befor using to avoid this situation.

Change-Id: I79a80db4acc3d7b17aeb8ff6b8aa79c562a43c3b
CRs-Fixed: 553259
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>