mmc: queue: scale down the max_segs if memory allocation fails

In low memory conditions at runtime, allocation of max_segs may
fail. Retry with a scaled down max_segs until allocation succeeds.

CRs-fixed: 583267
Change-Id: I072724afa44854dacc58654e6329531c1bb11120
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
msm: kgsl: Fix the api type in adreno drawctxt flags

Adding the missed type field in adreno draw ctxt create
which was giving incorrect data type.

CRs-Fixed: 590103

Signed-off-by: Anoop Kumar Yerukala <ayeruk@codeaurora.org>
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
Change-Id: I6f464a3b6cc1fec3891d1189f85c7fe9ac65764e
msm: kgsl: protect syncpoint events with a reference count

Replace the event spinlock with krefs to avoid the possiblity
of calling a sleeping function while holding the spinlock and
to generally make the whole cmdbatch cancel loop a lot more
stable.

Change-Id: I08ba54fa4c5a11c05e3503dfc6a4ee040733e5a6
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: fix race condition setting the event->handle

A race condition existed for setting the event->handle since the
async event can signal at any time after it has been registered.
When the event signals the reference count for the synclist and
the async callback are decremented causing the event to be freed.
The kgsl_cmdbatch_add_sync_fence function needs to take another
reference to ensure that the handle can be set before the event
is freed.

Change-Id: I0d8a02246e42dce014661d6f14c685415f1704cd
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
msm: mdss: On sharing dma pipe increment pipe ref_cnt

When DMA pipe is being shared and if mdss_mdp_pipe_map is called,
there could be a race condition when the pipe being shared
is unmapped, will lead to map failure as map is used for operations
on pipe which are already having positive ref_cnt.
This can result in potential map failure and attempt to free of
unmapped pipe resulting in crash.

Hence in this scenario of shared pipe usage atomic_inc should
be used instead of mdss_mdp_pipe_map.

CRs-Fixed: 590736
Change-Id: Ibaba20ac96662b5cd8aba3585f10d9cfe6e72d22
Signed-off-by: Justin Philip <jphili@codeaurora.org>
msm: kgsl: Pass the right timeout to adreno_drawctxt_wait()

adreno_drawctxt_wait() expects the passed in timeout to be in
milliseconds and converts it to jiffies.  Unfortunately, so does
the caller so the timeout is shorter than it should be.

Change-Id: Ic0dedbad85d50b32dba0fbf3ebb914335bf55166
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
ARM: dts: msm: Increase OCMEM BW request for video decode

There are framedrops observed on high bitrate clips because
OCMEM BW is not sufficient for these clips. Increase OCMEM BW
to avoid framedrops.

Change-Id: I7f3238036259e43a12899f2f7c73318328ae8eca
CRs-fixed: 571634
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
qseecom: Add support for bus scaling

Add support for scaling bus to various level:
LOW, MEDIUM, HIGH.  Expose IOCTL to user space
clients to enable selecting a specific bus bandwidth
setting.

Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
msm: vidc: add sleep of 100us before clock disable

ARM9 execute following sequence when venus is idle
1. Disable ARM9 watchdog
2. Set bit 30 of A_VENUS_CPU_CS_SCIACMDARG0 register
   to indicate venus is idle
3. Write HFI_MSG_SYS_IDLE to message queue
4. Raise interrupt to host
5. ARM9 execute wait for interrupt instruction to go
   into low power state. This will internally drain the
   ARM9 write buffer which can generate bus transaction.
6. ARM9 in idle

Host clock gate venus based on following sequence
1. Host receive HFI_MSG_SYS_IDLE from the msg queue
2. Host check both cmd / msg queue are empty by
   comparing the queue read/write pointers.
3. Host check bit 30 of A_VENUS_CPU_CS_SCIACMDARG0
   register to confirm it indicate idle
4. Host clock gate whole venus

As the host clock gate venus in step 4, ARM9 is still
in step 5&6. The sleep will ensure that step 5 and 6
are completed before host clock gates venus.

CRs-Fixed: 589417
CRs-Fixed: 595251
Change-Id: Idf1f788718adea2dacceca97afa4ba4fe4562ddd
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Asoc: Add support for codec bulk write for Helicon

Helicon can not use existing bulk_write function
as analog and digital codecs are in different busses.
So implement bulk write accordingly as per the codec interfaces

CRs-Fixed: 593609
Change-Id: Ibc16539cbd795fd998e88b6dc5b9060d70b498ac
Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
radio: iris: Fixed an issue with search stations list.

RDS search, search station list were getting excluded
while checking bounds for allowed search types. Fixed
check to include them.

CRs-fixed: 597996
Change-Id: Ia2d7cc8a1bbf8e861a0e23dfc8ca56181b42b810
Signed-off-by: Satish Kodishala <skodisha@codeaurora.org>
ARM: dts: msm: Add panel dimension details for HX8394A 720p panel

Explicitly setting the physical dimensions of the panel helps
in correctly computing the DPI (dots per inch) settings. Add
this information for the HX8394A 720p panel based on the data
provided in the panel specification.

Change-Id: I502c763b64eae17912f476ac31895f82253f0ae0
Signed-off-by: Diego Wilson <dwilson@codeaurora.org>
msm: camera2: add api for set actuator for manual af

this is to support fr18291 manually set focus position

Change-Id: Idec86177abc265c38fd48e18d1320c5ae40b7f03
Signed-off-by: Yongui Mao <yongguim@codeaurora.org>
ASoC: msm: Add support for AAC decode in ADTS format

- Set AAC format based on the format value set in
  compress params
- Default is RAW AAC

Change-Id: I4815fdfa0bc0716a44cde0c4440eaa15180c03fc
Signed-off-by: ApurupaPattapu <apurupa@codeaurora.org>
sd: call blk_pm_runtime_init before add_disk

Sujit has found a race condition that would make q->nr_pending
unbalanced, it occurs as Sujit explained:

"
sd_probe_async() ->
	add_disk() ->
		disk_add_event() ->
			schedule(disk_events_workfn)
	sd_revalidate_disk()
	blk_pm_runtime_init()
return;

Let's say the disk_events_workfn() calls sd_check_events() which tries
to send test_unit_ready() and because of sd_revalidate_disk() trying to
send another commands the test_unit_ready() might be re-queued as the
tagged command queuing is disabled.

So the race condition is -

Thread 1 			  |		Thread 2
sd_revalidate_disk()		  |	sd_check_events()
...nr_pending = 0 as q->dev = NULL|	scsi_queue_insert()
blk_runtime_pm_init()		  | 	blk_pm_requeue_request() ->
				  |	nr_pending = -1 since
				  |	q->dev != NULL
"

The problem is, the test_unit_ready request doesn't get counted the
first time it is queued, so the later decrement of q->nr_pending in
blk_pm_requeue_request makes it unbalanced.

Fix this by calling blk_pm_runtime_init before add_disk so that all
requests initiated there will all be counted.

Change-Id: I44ebe0693baf3adf3eccf4d5da9834e151c593fb
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Reported-and-tested-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: stable@vger.kernel.org
Patch-mainline: linux-scsi @ 10/10/13, 01:22
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
scsi: Allow auto suspend override by low-level driver

Until now the scsi mid-layer forbids runtime suspend till userspace
enables it. This is mainly to quarantine some disks with broken
runtime power management or have high latencies executing suspend
resume callbacks. If the userspace doesn't enable the runtime suspend
the underlying hardware will be always on even when it is not doing
any useful work and thus wasting power.

Some low-level drivers for the controllers can efficiently use runtime
power management to reduce power consumption and improve battery life.
Allow runtime suspend parameters override within the LLD itself
instead of waiting for userspace to control the power management.

Change-Id: I03e96a89d19c174deeb5bd4f94136c77073eb009
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
usb: storage: enable scsi auto-suspend for USB UICC devices

The USB UICC devices have storage interface along with smart card
interface.  These devices will be always present.  Enable scsi
auto-suspend for these devices.  The smart card class driver
enables the auto-suspend of the USB device.

Change-Id: I372a53b83ab61cbf2b2a21d203bf9fa56441c64a
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
msm: camera: Add retry mechanism to detect camera sensor

When device power up, probe happens where camera sensors
connected in each slot are detected by reading its chip id. Add
retry mechanism to try 3 times to read chip id for detecting
camera sensors.

Change-Id: Id2788f32fd7255eb9ca748ddce6e92267a1326ef
Signed-off-by: Wei Ding <weiding@codeaurora.org>
ARM: dts: msm: Add cpu clock device for 8610

Replace the device which controls the cpu frequency with a new
version. Add the cpubw device to manage DDR bandwidth.

Change-Id: Icc377f4ddab1cc0a9a80f344887adeec629e62b3
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
msm: thermal: Update thermal sysfs nodes permission

Update the permissions of the sysfs nodes exposed
by the kernel thermal monitor.

Change-Id: Ib211852e8af74d17fd5e40585af2f03aa3ae7920
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>