ASoC: msm: qdsp6: Add support to configure ISO and ARIB coefficients

Add support for configuring ISO or ARIB stereo mixing
coefficients. This change introduces a function with which,
AAC multi-channel driver can configure ISO or ARIB coefficients
according to configuration done by the client.

CRs-Fixed: 623127
Change-Id: I00845bdef075631f93a0c65a335b7edb5d10497b
Signed-off-by: Amit Shekhar <ashekhar@codeaurora.org>
msm: camera: exit camera incase axi gets timeout

AXI hits timeout while stopping due to sensor not streaming.
Simply returning error from here puts AXI and camif in still
running state whereas userspace proceeds with releasing the
buffers. This fix ensures we halt AXi and stop camif in sensor
not streaming case. Thus avoid page faults and a delay in
stopping camera.

Change-Id: I4159ac7b21d2a22a5684d7b4a614b0dfd8f06e46
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
SELinux: Fix kernel BUG on empty security contexts.

Setting an empty security context (length=0) on a file will
lead to incorrectly dereferencing the type and other fields
of the security context structure, yielding a kernel BUG.
As a zero-length security context is never valid, just reject
all such security contexts whether coming from userspace
via setxattr or coming from the filesystem upon a getxattr
request by SELinux.

Setting a security context value (empty or otherwise) unknown to
SELinux in the first place is only possible for a root process
(CAP_MAC_ADMIN), and, if running SELinux in enforcing mode, only
if the corresponding SELinux mac_admin permission is also granted
to the domain by policy.  In Fedora policies, this is only allowed for
specific domains such as livecd for setting down security contexts
that are not defined in the build host policy.

[On Android, this can only be set by root/CAP_MAC_ADMIN processes,
and if running SELinux in enforcing mode, only if mac_admin permission
is granted in policy.  In Android 4.4, this would only be allowed for
root/CAP_MAC_ADMIN processes that are also in unconfined domains. In current
AOSP master, mac_admin is not allowed for any domains except the recovery
console which has a legitimate need for it.  The other potential vector
is mounting a maliciously crafted filesystem for which SELinux fetches
xattrs (e.g. an ext4 filesystem on a SDcard).  However, the end result is
only a local denial-of-service (DOS) due to kernel BUG.  This fix is
queued for 3.14.]

Reproducer:
su
setenforce 0
touch foo
setfattr -n security.selinux foo

Caveat:
Relabeling or removing foo after doing the above may not be possible
without booting with SELinux disabled.  Any subsequent access to foo
after doing the above will also trigger the BUG.

BUG output from Matthew Thode:
[  473.893141] ------------[ cut here ]------------
[  473.962110] kernel BUG at security/selinux/ss/services.c:654!
[  473.995314] invalid opcode: 0000 [#6] SMP
[  474.027196] Modules linked in:
[  474.058118] CPU: 0 PID: 8138 Comm: ls Tainted: G      D   I
3.13.0-grsec #1
[  474.116637] Hardware name: Supermicro X8ST3/X8ST3, BIOS 2.0
07/29/10
[  474.149768] task: ffff8805f50cd010 ti: ffff8805f50cd488 task.ti:
ffff8805f50cd488
[  474.183707] RIP: 0010:[<ffffffff814681c7>]  [<ffffffff814681c7>]
context_struct_compute_av+0xce/0x308
[  474.219954] RSP: 0018:ffff8805c0ac3c38  EFLAGS: 00010246
[  474.252253] RAX: 0000000000000000 RBX: ffff8805c0ac3d94 RCX:
0000000000000100
[  474.287018] RDX: ffff8805e8aac000 RSI: 00000000ffffffff RDI:
ffff8805e8aaa000
[  474.321199] RBP: ffff8805c0ac3cb8 R08: 0000000000000010 R09:
0000000000000006
[  474.357446] R10: 0000000000000000 R11: ffff8805c567a000 R12:
0000000000000006
[  474.419191] R13: ffff8805c2b74e88 R14: 00000000000001da R15:
0000000000000000
[  474.453816] FS:  00007f2e75220800(0000) GS:ffff88061fc00000(0000)
knlGS:0000000000000000
[  474.489254] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  474.522215] CR2: 00007f2e74716090 CR3: 00000005c085e000 CR4:
00000000000207f0
[  474.556058] Stack:
[  474.584325]  ffff8805c0ac3c98 ffffffff811b549b ffff8805c0ac3c98
ffff8805f1190a40
[  474.618913]  ffff8805a6202f08 ffff8805c2b74e88 00068800d0464990
ffff8805e8aac860
[  474.653955]  ffff8805c0ac3cb8 000700068113833a ffff880606c75060
ffff8805c0ac3d94
[  474.690461] Call Trace:
[  474.723779]  [<ffffffff811b549b>] ? lookup_fast+0x1cd/0x22a
[  474.778049]  [<ffffffff81468824>] security_compute_av+0xf4/0x20b
[  474.811398]  [<ffffffff8196f419>] avc_compute_av+0x2a/0x179
[  474.843813]  [<ffffffff8145727b>] avc_has_perm+0x45/0xf4
[  474.875694]  [<ffffffff81457d0e>] inode_has_perm+0x2a/0x31
[  474.907370]  [<ffffffff81457e76>] selinux_inode_getattr+0x3c/0x3e
[  474.938726]  [<ffffffff81455cf6>] security_inode_getattr+0x1b/0x22
[  474.970036]  [<ffffffff811b057d>] vfs_getattr+0x19/0x2d
[  475.000618]  [<ffffffff811b05e5>] vfs_fstatat+0x54/0x91
[  475.030402]  [<ffffffff811b063b>] vfs_lstat+0x19/0x1b
[  475.061097]  [<ffffffff811b077e>] SyS_newlstat+0x15/0x30
[  475.094595]  [<ffffffff8113c5c1>] ? __audit_syscall_entry+0xa1/0xc3
[  475.148405]  [<ffffffff8197791e>] system_call_fastpath+0x16/0x1b
[  475.179201] Code: 00 48 85 c0 48 89 45 b8 75 02 0f 0b 48 8b 45 a0 48
8b 3d 45 d0 b6 00 8b 40 08 89 c6 ff ce e8 d1 b0 06 00 48 85 c0 49 89 c7
75 02 <0f> 0b 48 8b 45 b8 4c 8b 28 eb 1e 49 8d 7d 08 be 80 01 00 00 e8
[  475.255884] RIP  [<ffffffff814681c7>]
context_struct_compute_av+0xce/0x308
[  475.296120]  RSP <ffff8805c0ac3c38>
[  475.328734] ---[ end trace f076482e9d754adc ]---

[sds:  commit message edited to note Android implications and
to generate a unique Change-Id for gerrit]

Change-Id: I4d5389f0cfa72b5f59dada45081fa47e03805413
Reported-by:  Matthew Thode <mthode@mthode.org>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Cc: stable@vger.kernel.org
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
msm-camera: Dividing unified buffer in proportion to the image size

Write masters writing large images require large latency buffers in
unified buffer whereas write masters writing smaller images don't,
Allocating latency buffer in proportion to image size will reduce
buf overflows

Change-Id: I54d3b4389eb616b9684d5b62caaed029c83299ab
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
msm-camera: Enable proportional slicing of unified buffer

To enable proportional slicing

Change-Id: I8a21c8808085f527b9536edc51ccdcfa1de4e179
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
ASoC: Fix the sync problem after SSR

After SSR default registers needs to be restored. Then
we need to sync all the registers with cache values. This
fixes the problem where register values got changed
after SSR causing AAC clip playback failure.

CRs-Fixed: 579574
Change-Id: Ibb99d69425dcb16ba09cfb131b5059f666f75012
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Signed-off-by: Fred Oh <fred@codeaurora.org>
ARM: dts: Change the vertical back porch value for nt33590 panel

Currently the vertical back porch of this panel is very low,
and causes performance related issues,hence increase the vbp of
this panel properly with correct dsi panel sequence to accommodate
this vbp.

Change-Id: I4f0771fa4f827adca1f52b6e71cb968cc6602112
Signed-off-by: Anusha Koduru <kanusha@codeaurora.org>
ARM: dts: msm: Add clk-ctrl-xfer flag to control clocks

Add support for configuration of clock
control event. Now the clock's state may
be set by power management suspend/resume
calls (as before) or by a transfer's begining
and ending.

CRs-Fixed: 592435
Change-Id: I68db02798cb06b74ea7c89dfae74e8a03b9cf722
Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org>
ARM: dts: set ab fudge factor to 1

Since there is a single DDR port on 8226,
fudge factor should be 1 on ab.

Change-Id: I24adb31a9579ecf3c9cb780b40aceacd62443163
Signed-off-by: Anusha Koduru <kanusha@codeaurora.org>
ARM: dts: decrease max BW cap for low kbps to 1.1 Ghz on 8226

Decrease the max BW check to 1.1 Ghz from 1.66 Ghz as recommended
based on the new set of bandwidth calculations.

Change-Id: I409c778ceb857560c25eb71e0fb875108e8725b1
Signed-off-by: Anusha Koduru <kanusha@codeaurora.org>
msm: ultrasound: add support for aDSP Sub-System Restart

Add handling of RESET_EVENTS message from APR, which indicates
aDSP sub-system restart has begun.

Add a new internal state, USF_ADSP_RESTART_STATE, for this
scenario.

Change-Id: Ic1178f8fb4e659abc29947fac4079ba088e51447
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
mdss: mdp3: Remove extra call to clk_prepare

clk_prepare got moved inside mdp3_clk_update. Prior to this patch
unprepare would never be called successfully.

Change-Id: I28ab035b42d433f379d63748ac4f506a8575ea66
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
rtc: alarm: Proper handling of spinlock

In alarm_shutdown hook, taking interruptible mutex
lock in interrupt disabled context. This patch fixes
alarm_shutdown function to call rtc_read_time and
rtc_set_alarm APIs in interrupt enabled context.

Change-Id: I9392d8908c19365993dccc22504f4b6f83ae8f72
CRs-Fixed: 619657
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
msm: mdss: remove panel type check for split display case.

Split display flag is derived from dsi controller configuration
specified at dtsi. Therefore no need to add checking panel
type at FB registration.

Change-Id: I5b60656c1f5724bdc358d743b8d7600d5beba0b3
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: smd_tty: Fix client notification issue in suspend state

SMD_TTY driver holds a wakeup source for 500ms to provide enough time
to notify the user client waiting for data. However, when system is in
suspend state the 500ms timer may not be sufficient to notify the
user clients because in some cases system resume of devices and tasks
is taking more time and this causes delay in client notification.

Register for PM_SUSPEND_PREPARE and PM_POST_SUSPEND events to track
system suspend and resume state and then notify the clients after system
resume completes.

CRs-Fixed: 613589
Change-Id: Iffb2ecb1c58f46e0c4a745cdcce2fb717ea2ece8
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
msm: mdss: prevent dereferencing of user space pointer

We were dereferencing a userspace pointer in kernel.

Change-Id: I128455904cd396690350fc6b784a8844d594539c
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
power: qpnp-bms: do not adjust when shutdown soc is being applied

When the shutdown SOC is being applied, do not adjust the SOC before
using it for reporting. This is to prevent situations where the SOC can
be adjusted upwards when discharging, or adjusted downwards when
charging, but before the monotonic filtering can apply.

This change will ensure SoC monotonicity during discharge across power
cycles.

Change-Id: I23c95ddb941e0544920eb5c4cac3b1ba8d2752d6
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: fix coulomb counter selection

There is a bug in the BMS code right now where reading the coulomb
counter actually reads the shadow coulomb counter and vice versa. Fix
this by correctly specifying the coulomb counter to be read.

Change-Id: Ica703d1e426e595e9ff6cd9fc45bade743740238
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: always release output locks in bms driver

If a SPMI read error occurs, there can be a situation where the
BMS_HOLD_OREG bit is not set and the bms param lock is never released.
This can cause deadlocks and battery SoC to never move. Fix this by
releasing the locks after handling an error.

Change-Id: I880b8e1ed2ff1ec3ce701f1e9922c9aac353766a
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: use consistent IAVG for raw SOC calculation

Currently the BMS uses the instantaneous current for the raw SOC
calculation. However, this current can be very high because of the boot
tiime power draw. This can bias the UUC to unreasonably levels (100% of
the battery when at cold temperatures) and cause the saved shutdown SOC
to be needlessly discarded.

Use the more realistic IAVG of 250 mA when doing this initial raw SOC
calculation as well in other places where iavg is being reset to avoid
skewing the results. Also, do not save the percent UUC when doing the raw
SOC calculation. Rather, use the loaded shutdown IAVG if there is one.

Change-Id: I426b824a50568b01bae442a3154e7c68c42409f8
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>