msm: acpuclock-8x60: Drop "slowest" frequency table

The voltage data in this table is not used. It applied only to
a handful of internal part samples that were never distributed.
Remove it, since it is neither maintained nor useful.

CRs-Fixed: 366934
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
(cherry picked from commit 0ac3175b621563ae39c045359647f69e22c79541)

Change-Id: I91ff7f3e8b3d6e75079ae98ad4577ad1ca0efb65
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: acpuclock-8x60: Optimize CPU voltages on 1.7GHz parts

Hardware characterization shows that these parts can operate reliably
at lower voltages than were previously used. Update the tables to
take advantage of the power savings.

CRs-Fixed: 366934
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
(cherry picked from commit 3b492ababfdb1de872ad7386babd25da2cc09336)

Change-Id: Icd0cbffb45040cdd99434b30c31a5d000a157af7
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: pm-8x60: Don't restore ACPU frequency for hotplug cases.

During hotplug if power collapse fails don't try to restore the
ACPU clock frequency. For normal hotplug exit ACPU drivers save
and restore as part of hotplug notifications.

CRs-fixed: 334002
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
(cherry picked from commit 4e025d9b72f771e30e1803871ac21dbf9d1a366f)

Change-Id: Ifcba558b17a72c232c60ed38d7849f196db1ad44
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-charger: fix vbus draw for 0 mA request

A missing equal sign avoids the disabling of the charger
when calling the pm8921_vbus_draw API.

Fix this by adding the equal sign for the 0 mA VBUS request
to ensure that the charger is forced to run off the battery.

CRs-Fixed: 366285
Change-Id: Ie8c926cf41782ddccfb5fc0a896b2cbae4135b49
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
power: pm8921-bms: fix ccadc accuracy

The bms ccadc counters are incremented/decremented every 56 ticks of the
sleep clock not 55. Correct the tick count.

Also sleep clock is derived by dividing the 19.2Mhz clock by 586. Hence
the HZ count of the sleep clock should be 32764 instead of 32768. Fix
this too.

Crs-fixed: 381923
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit b787b29843f63fcb75700cad8e69afcdd5d7da36)

Change-Id: Iac3a21f7a9ac7a544e4fc7ff0d48aca35d896630
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: clock-8960/8660: Support 32/64MHz prng clock frequency plan

Add support for both the 32MHz and the 64MHz prng frequencies.
Some bootloaders configure the PRNG to 32MHz and others choose
64MHz. Support both so that we always vote for the correct
voltage

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 842a1f6b0eb8ecf40f97fa020fa004745ba1ab48)

Conflicts:

	arch/arm/mach-msm/clock-8960.c
	arch/arm/mach-msm/clock-8x60.c

Change-Id: I732aaa78d2019d6fefd90456f67ca27db1be9874
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: rotator: Call S/W reset on AXI bus error interrupts

Call Rotator S/W Reset when AXI bus error interrupts are
seen during a rotate request

CRs-fixed: 341947
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
(cherry picked from commit 30cf3eba95df9c6bf90f77b7f4ce40307d106e5d)

Change-Id: I4e0cd0b58fcf6a54301b875925354f8648cec5fb
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
diag: Fix data corruption.

Diag uses krealloc for allocating memory if number of client exceeds 15 as
krealloc doesn't initialize memory to 0 resulting in corruption of data.
This fix initializes the memory after allocation.

CRs-Fixed: 347675
Change-Id: Ide504a18adc2e1fc282c5543ec77818f346e4015
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
(cherry picked from commit 6bac272ef9b64f0830af50f1537aa18017711022)
mfd: pm8xxx-misc: Add API to control HSED BIAS lines

Qualcomm PMIC's support 3 HSED BIAS lines which as used
as Micrphone bias. The API adds ability to control (enable/disable)
these bias lines.

CRs-Fixed: 359206
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
(cherry picked from commit ba4ea6eccabe48e04a43f5f0da17a33743b24e89)

Conflicts:

	drivers/mfd/pm8xxx-misc.c
	include/linux/mfd/pm8xxx/misc.h

Change-Id: I389fbef57b9c76ab7e8c77e9cd42cce9fa66b3e6
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: cache_erp: Support logging ERP events to system memory

Add the ability to log ERP events to an area of memory that
is preserved across a system reset, to aid in analyzing and
debugging ERP-related problems in the field.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 92e62cbbec5dac266c18f8f67f804b66b5290ac5)

Conflicts:

	arch/arm/mach-msm/Kconfig

Change-Id: I7ffa93555cf8c1ef6d6f7de01988354f7271e809
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
fs: fat: rate limit the kernel messages

If FAT formatted SD card gets removed without unmounting,
FAT file system may throw many kernel error messages which
could too much traffic for console driver and can sometimes
even cause the system to trigger watchdog timeout.

This patch converts the printk to printk_ratelimited to rate
limit the error messages from FAT fs.

CRs-fixed: 368446
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit a872b71069d717ced1a2de642afa0693d1bb9448)

Change-Id: I3ace0ffc5a0119641dff8084adccf7ed780c7900
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
ASoC: msm: Fix mute issue in LPA

In event of an under-run, driver is not able to start again.
Memset the buffer to play silence while userspace recieves the
next set of data and copies it into the mmap buffer.

CRs-Fixed: 356297
CRs-Fixed: 359764
Signed-off-by: Tejas Shikhare <tshikhar@codeaurora.org>
(cherry picked from commit 0c2a7704c764371e63e27d1cbbcfe4646d7ea84f)

Change-Id: I3b01599753f3cbe5fa3f0711f08b90de63e00166
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: qdsp6v2: Reduce the step size of soft volume and soft pause.

With current step size, as there is raise in amplitude levels
abruptly, quality issues are observed. Reduce the step size to
zero to improve the performance.

CRs-fixed: 360715
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>
(cherry picked from commit 623b593810a7c7954d8ef45a5f79bc862b8ac066)

Change-Id: Ib2c3d7972d99450c10b617a81fbd020e0b2b0389
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: smd_pkt: fix wake lock locking race condition

When smd_pkt receives data for a client in userspace, smd_pkt locks a wake
lock to give the userspace client time to lock their own wake lock if
necessary.  Clients using poll() will trigger the unlocking of the wake
lock in smd_pkt, otherwise smd_pkt modifies the wake lock to expire in two
seconds.

Fix a race condition where smd_pkt locks the wake lock, the client reads
their data and triggers the unlocking, and then smd_pkt relocks the wake
lock when it modifies the timeout to two seconds.  This causes suspend to
be unnecessarily delayed.  The fix is to bypass setting the timeout if the
client has already read their data and triggered the unlocking of the wake
lock.

CRs-Fixed: 367001
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
(cherry picked from commit 93476a35471a8ffa926ab4474bf028795db95cca)

Conflicts:

	arch/arm/mach-msm/smd_pkt.c

Change-Id: I561abdf34aacaaecd617b80c1ea476d4b9c373f1
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
tspp: 8960: adding TSPP driver for 8960

Board file changes required for adding TSPP support to 8960
For more information on TSPP, please refer to:
Documentation/arm/msm/tspp.txt

CRs-fixed: 334732
Signed-off-by: Joel Nider <jnider@codeaurora.org>
(cherry picked from commit 266a2648d9828258108c16545e62459149c50323)

Change-Id: Ic8283ec563f5633d1b8d1a164ac105f03c10518a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
blue: adding TSPP driver

For more information on TSPP, please refer to:
Documentation/arm/msm/tspp.txt
ASoC: qdsp6: Fix device crash issue in LPA seek

Accessing buffer pointer before initialization results in device crash.
To memset the buffer using physical address also results in a device crash.
Fixed this by initializing the buffer pointer before it is accessed and
memset the buffer using the virtual address.

CRs-fixed: 359764
Signed-off-by: Amal Paul <amal@codeaurora.org>
(cherry picked from commit 3e0c932acabfeafcef6d06abc801ba8507ccaa46)

Change-Id: I47296fc224d260fa7549afe4d2531af6123b07e6
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
sysfs: handle 'parent deleted before child added'

In scsi at least two cases of the parent device being deleted before the
child is added have been observed.

1/ scsi is performing async scans and the device is removed prior to the
   async can thread running (can happen with an in-opportune / unlikely
   unplug during initial scan).

2/ libsas discovery event running after the parent port has been torn
   down (this is a bug in libsas).

Result in crash signatures like:
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
 IP: [<ffffffff8115e100>] sysfs_create_dir+0x32/0xb6
 ...
 Process scsi_scan_8 (pid: 5417, threadinfo ffff88080bd16000, task ffff880801b8a0b0)
 Stack:
  00000000fffffffe ffff880813470628 ffff88080bd17cd0 ffff88080614b7e8
  ffff88080b45c108 00000000fffffffe ffff88080bd17d20 ffffffff8125e4a8
  ffff88080bd17cf0 ffffffff81075149 ffff88080bd17d30 ffff88080614b7e8
 Call Trace:
  [<ffffffff8125e4a8>] kobject_add_internal+0x120/0x1e3
  [<ffffffff81075149>] ? trace_hardirqs_on+0xd/0xf
  [<ffffffff8125e641>] kobject_add_varg+0x41/0x50
  [<ffffffff8125e70b>] kobject_add+0x64/0x66
  [<ffffffff8131122b>] device_add+0x12d/0x63a

In this scenario the parent is still valid (because we have a
reference), but it has been device_del()'d which means its kobj->sd
pointer is NULL'd via:

 device_del()->kobject_del()->sysfs_remove_dir()

...and then sysfs_create_dir() (without this fix) goes ahead and
de-references parent_sd via sysfs_ns_type():

 return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;

This scenario is being fixed in scsi/libsas, but if other subsystems
present the same ordering the system need not immediately crash.

Change-Id: If035179fdb716c0690abea5b4d8480ba1af1b871
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: James Bottomley <JBottomley@parallels.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
diag: Add missing SSID range

OEMs use SSID in a specific range. Recently DIAG changed the mask
update algorithm and this range was missed as its not used internally.
This change adds it back.

CRs-fixed: 359379
Change-Id: Ib7249f157e4e37294b6da6580fcf19995afeef8f
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
(cherry picked from commit 44b79b7bb5aeeaa2c956ce0fd1e605d840c55a73)

Conflicts:

	include/linux/diagchar.h

Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
cpufreq: Fix sysfs deadlock with concurrent hotplug/frequency switch

Running one program that continuously hotplugs and replugs a cpu
concurrently with another program that continuously writes to the
scaling_set_speed node eventually deadlocks with:

=============================================
[ INFO: possible recursive locking detected ]
3.4.0 #37 Tainted: G        W
---------------------------------------------
filemonkey/122 is trying to acquire lock:
 (s_active#13){++++.+}, at: [<c01a3d28>] sysfs_remove_dir+0x9c/0xb4

but task is already holding lock:
 (s_active#13){++++.+}, at: [<c01a22f0>] sysfs_write_file+0xe8/0x140

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(s_active#13);
  lock(s_active#13);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by filemonkey/122:
 #0:  (&buffer->mutex){+.+.+.}, at: [<c01a2230>] sysfs_write_file+0x28/0x140
 #1:  (s_active#13){++++.+}, at: [<c01a22f0>] sysfs_write_file+0xe8/0x140

stack backtrace:
[<c0014fcc>] (unwind_backtrace+0x0/0x120) from [<c00ca600>] (validate_chain+0x6f8/0x1054)
[<c00ca600>] (validate_chain+0x6f8/0x1054) from [<c00cb778>] (__lock_acquire+0x81c/0x8d8)
[<c00cb778>] (__lock_acquire+0x81c/0x8d8) from [<c00cb9c0>] (lock_acquire+0x18c/0x1e8)
[<c00cb9c0>] (lock_acquire+0x18c/0x1e8) from [<c01a3ba8>] (sysfs_addrm_finish+0xd0/0x180)
[<c01a3ba8>] (sysfs_addrm_finish+0xd0/0x180) from [<c01a3d28>] (sysfs_remove_dir+0x9c/0xb4)
[<c01a3d28>] (sysfs_remove_dir+0x9c/0xb4) from [<c02d0e5c>] (kobject_del+0x10/0x38)
[<c02d0e5c>] (kobject_del+0x10/0x38) from [<c02d0f74>] (kobject_release+0xf0/0x194)
[<c02d0f74>] (kobject_release+0xf0/0x194) from [<c0565a98>] (cpufreq_cpu_put+0xc/0x24)
[<c0565a98>] (cpufreq_cpu_put+0xc/0x24) from [<c05683f0>] (store+0x6c/0x74)
[<c05683f0>] (store+0x6c/0x74) from [<c01a2314>] (sysfs_write_file+0x10c/0x140)
[<c01a2314>] (sysfs_write_file+0x10c/0x140) from [<c014af44>] (vfs_write+0xb0/0x128)
[<c014af44>] (vfs_write+0xb0/0x128) from [<c014b06c>] (sys_write+0x3c/0x68)
[<c014b06c>] (sys_write+0x3c/0x68) from [<c000e0e0>] (ret_fast_syscall+0x0/0x3c)

This is because store() in cpufreq.c indirectly grabs a kobject
with kobject_get() and is the last one to call kobject_put()
indirectly via cpufreq_cpu_put().

Fix this deadlock by introducing two new functions,
cpufreq_cpu_get_sysfs() and cpufreq_cpu_put_sysfs() which do the
same thing as cpufreq_cpu_{get,put}() but don't grab the kobject.

CRs-fixed: 366560
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit f82ef51be26b44b83d86afa56b3cd9c743023470)

Change-Id: Ia692e64dc3ce40f0ff3e209025a346f7d9b569da
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>