adjust requlator voltage range for overclock
trim 1.6 and 1.7 GHz again
conclusion: >1.5GHz is very unreliable
don't compile in a3xx part of msm/kgsl, eliminate unnecessary code
backporting msm/kgsl updates from codeaurora msm-3.4 - part 1
__________

msm: kgsl: return correct error code for unknown ioctls

Unknown ioctl code errors are supposed to be ENOIOCTLCMD,
not EINVAL.

Change-Id: Id38529e4ec70d63091a9273a780585aea6ae9d9a
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
_____________

msm: kgsl: fix size checking in adreno_find_region

This function is supposed to return the memdesc that
contains the range gpuaddr to gpuaddr + size. One of the
lookups was using sizeof(unsigned int) instead of size,
which could cause false positive results from this function
and possibly kernel panics in the snapshot or postmortem
code, which rely on it to do bounds checking for them.

Change-Id: I65dc48108f2010887e620a252a6afbd88473ac6e
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
________________

msm: kgsl: Make sure kmemleak tool does not report incorrect mem leak.

Certain memory allocations are not properly tracked by kmemleak tool,
which makes it to incorrectly detect memory leak. Notify the tool by using
kmemleak_not_leak() to ignore the memory allocation so that incorrect leaks
report are avoided.

Change-Id: Id3beea7d99aedc10d9d8d74e5dad384e03abf4f2
CRs-Fixed: 334294
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
__________________

msm: kgsl: Remove DRM specific gpu cache flush

DRM specific gpu cache flushing was causing kernel
crashes (NULL dereferences) and is no longer necessary.

Change-Id: I47d82baa9454a29e7f21b9ac5365921379bfb09d
Signed-off-by: Michael Street <mstreet@codeaurora.org>
_________________

msm: kgsl: Cleanup header file macros

Remove macro logic for macros that are always defined.

Change-Id: Iecbc8418102205559aa551af96b79579d1b3aa4d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
__________________

msm: kgsl: Add GMEM size configuration in gpu list

To avoid msm or gpu specific code in the driver, added
GMEM size configuration parameter as a part of gpu list.

Change-Id: I3a0c4efdfbc607f3a0a87fc2350e7b40864f9f73
Signed-off-by: Sudhakara Rao Tentu <srtentu@codeaurora.org>
____________________

msm: kgsl: Remove unused debugfs files

istore, sx_debug, cp_debug and mh_debug have been deprecated. Remove
them.

Change-Id: I34364f8987a74e68244015992af39842342d0489
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
fix "HTC FIXME" that HTC didn't fix
backport mach-msm/idle_stats_device.c from codeaurora msm-3.4
msm: kgsl: Use highest perf level on wake-up from sleep

Allowing gpu to operate on highest perf level on
wake-up for better performance.

Change-Id: I0fd678359bd29a27fb218a506d1b307544ec5aae
Signed-off-by: Nilesh Shah <nsshah@codeaurora.org>
msm: kgsl: Ensure glitch free changing of the GPU frequency

If there are requests to skip levels while the clocks are on
be sure to hit the intermediate frequencies.

Change-Id: Ib69bcbc7eb87532c090b4ede28d967e4cd0f08ec
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 2
_________

msm: kgsl: Fix when GMEM is saved for A2xx

Saving GMEM is set when doing context switching and should not
be set when creating the gmem shadow.

Change-Id: I743a7287f105dd50955727c4f0dcaf8de363a1dc
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
_____________

msm: kgsl: Write the retired timestamp on resume

Write the retired timestamp into the expected location. This fixes
userspace crashes after resume when the retired timestamp is read
as 0 instead of the expected last timestamp.

CRs-Fixed: 350556
Change-Id: Iaa487ba8be427c29b9f7e9b30b251cf26fcff95a
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
______________

msm: kgsl: Do not take spinlock when mapping to IOMMU

The IOMMU driver takes a spinlock internally when mapping, so
do not take an additional spinlock when mapping to IOMMU table.

Change-Id: I772ffb09af95ed15dc2c3495affa9efd48e4af5b
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Resolve conflicts in state changes

Only check requested state once, and fully transition to that
specific state.  This will resolve any conflicts arising from
changes to the requested_state as the state transition occurs.

Change-Id: I0836877d7d93d469158f7bfba5556fc082ebfe2a
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 3
__________

msm: kgsl: Properly assign the physical address

Correctly assign the physical address to be used as gpu address
when no MMU is used.

Change-Id: Ie824cadc7c8c85203f81c9c5961b6f8a5d1cd449
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
____________

msm: kgsl: Allow SLEEP/SLUMBER/SUSPEND states to wake to nominal voltage

Waking in turbo drains power while the high nominal frequency of 300MHz is
generally enough to handle rapid requests.

Change-Id: I01a8261b6431556b483e59d1c2ae539ff094c751
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
____________________

msm: kgsl: Allocate setstate memory when no MMU is used

Setstate memory should be allocated even when no MMU is used
because it is used when submitting workaround commands.

Change-Id: Ia8217cec9507bff82680e737b4328c2611f5f917
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
_____________
backporting msm/kgsl updates from codeaurora msm-3.4 - part 4
___________

msm: kgsl: Call the function to setup global mappings

Call kgsl_setup_pt function to setup the gpuaddr mappings for
global allocations when no MMU is used

Change-Id: I062de3b52fd4d48717bd9d6b074deca9ffcb85de
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
___________

msm: kgsl: disable early suspend and late resume for 2d cores.

The powerrail off during slumber is causing a GPU hang

Change-Id: Ie28d80c56df9bb789fdf22d94589e94fc154a452
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
_____________

msm: kgsl: Jump to turbo on late resume without DCVS

Without this change it may happen that gpu will
never go to turbo on late resume in absence of
gpu dcvs. This change will ensure that it will
go to turbo.

Change-Id: I89a367a0a5360f78210921baaab49029e1726f7d
Signed-off-by: Nilesh Shah <nsshah@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 5
______________
msm: kgsl: Assign a valid context only after one has been restored

Assign a context active context only after that context has been
restored. This is required because Code section to change
pagetables or flush tlb in stream require a valid context to be
active.

Change-Id: I513cf235adf2bde04af47944950d58ba1af1f61f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
____________

msm: kgsl: Make tlb flags common for all MMU types

Remove tlb flags variable from gpu MMU specific structure and
declare it in common MMU structure since it can be used by both
MMU types i.e GPUMMU and IOMMU

Change-Id: Ia8bea65bc9acf257dc1277c98cd358963c291fd7
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
_______________

msm: kgsl: Change the prototype of MMU function pointers

Change the prototype of the MMU function pointers to take the mmu
pointer as an argument instead of the device pointer.

Change-Id: I4ecafefcc8f755c23dac6e3a15a1a74a74e3db00
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 6
__________
msm: kgsl: Cleanup a superfluous structure in kgsl_device.h

struct kgsl_memregion was used to store the MMIO and GMEM
addressing for KGSL and adreno but it didn't serve much
purpose other than another level of redirection in the
structures.  Remove it and add the necessary pointer and
size members directly to the KGSL and adreno structs.

Change-Id: Ic0dedbad8ec3f0a2c63383fa451cc39a25cab087
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
___________

msm: kgsl: Fix incorrect parameter when calling calc_gmemsize.

While calculating GMEM size, passing gmem_base for gmem_size
causes rendering problems. Pass gmem_size for correct
rendering.

Change-Id: I1ecec9ab5928d9d205d1d312298da813337c2053
Signed-off-by: Anoop Kumar Yerukala <ayeruk@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 7
___________

msm: kgsl: Declare some mmu functions as static inline

Declare those functions that simply call the mmu-specific function
pointer as static inline functions in the mmu header file. Also,
change the return type of the mmu stop function to void.

Change-Id: I4efd7901858c768eec16886c8410d362b918489b
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
________________

msm: kgsl: Increase the virtual GPU range for the IOMMU

Instead of a fixed 256MB virtual range for both the GPUMMU and IOMMU, make
the virtual range a property of the MMU engine and set the IOMMU range to
2GB.  Technically we could go all the way up to 4G, but even 2G is far out
of the realm of possiblity in the current generation, and we wanted to
reserve some of the space for future enhancements.

Change-Id: Ic0dedbad2987beb162b6a1878dd65ffae8a78522
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
backporting msm/kgsl updates from codeaurora msm-3.4 - part 8
___________
msm: kgsl: Remove some uneeded debug output

Remove a block of code that dumped the ringbuffer contents after they
were extracted.  The dump is no longer needed and the longer we
stick around dumping things to the console with the mutexes locked,
the better the chance that the watchdog will come bite us.

Change-Id: Ic0dedbadd22993f0f1646841f481cdc6713d38e8
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
__________

msm: kgsl: Do not BUG in GPU recovery if a valid context can't be found

Don't BUG() if we can't find a valid context to recover to; just fail and
go into a zombie state. This usually happens after a first hang goes bad
and the system keeps hanging while trying to find its way. The problem with
a BUG() in this case is that the system goes down and we can't recover the
snapshot or other debug information.

Change-Id: Ic0dedbad424067ca67799487ee7a7de48a2f42b0
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
______________

msm: kgsl: Change iommu structure to better represent the hardware

Change the iommu structures to properly represent the iommu hardware
which makes the code more readable.

Change-Id: I61cf988998da3fc4f62ca020e4240cf50ddd20f0
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer

Vaguely based on upstream commit 574c4866e33d 'consolidate kernel-side
struct sigaction declarations'.

flush_signal_handlers() needs to know whether sigaction::sa_restorer
is defined, not whether SA_RESTORER is defined.  Define the
__ARCH_HAS_SA_RESTORER macro to indicate this.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER

commit 522cff142d7d2f9230839c9e1f21a4d8bcc22a4a upstream.

__ARCH_HAS_SA_RESTORER is the preferred conditional for use in 3.9 and
later kernels, per Kees.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Julien Tinnes <jln@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked

commit 1166fde6a923c30f4351515b6a9a1efc513e7d00 upstream.

We need to be careful when testing task->tk_waitqueue in
rpc_wake_up_task_queue_locked, because it can be changed while we
are holding the queue->lock.
By adding appropriate memory barriers, we can ensure that it is safe to
test task->tk_waitqueue for equality if the RPC_TASK_QUEUED bit is set.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bluetooth: Fix not closing SCO sockets in the BT_CONNECT2 state

commit eb20ff9c91ddcb2d55c1849a87d3db85af5e88a9 upstream.

With deferred setup for SCO, it is possible that userspace closes the
socket when it is in the BT_CONNECT2 state, after the Connect Request is
received but before the Accept Synchonous Connection is sent.

If this happens the following crash was observed, when the connection is
terminated:

[  +0.000003] hci_sync_conn_complete_evt: hci0 status 0x10
[  +0.000005] sco_connect_cfm: hcon ffff88003d1bd800 bdaddr 40:98:4e:32:d7:39 status 16
[  +0.000003] sco_conn_del: hcon ffff88003d1bd800 conn ffff88003cc8e300, err 110
[  +0.000015] BUG: unable to handle kernel NULL pointer dereference at 0000000000000199
[  +0.000906] IP: [<ffffffff810620dd>] __lock_acquire+0xed/0xe82
[  +0.000000] PGD 3d21f067 PUD 3d291067 PMD 0
[  +0.000000] Oops: 0002 [#1] SMP
[  +0.000000] Modules linked in: rfcomm bnep btusb bluetooth
[  +0.000000] CPU 0
[  +0.000000] Pid: 1481, comm: kworker/u:2H Not tainted 3.9.0-rc1-25019-gad82cdd #1 Bochs Bochs
[  +0.000000] RIP: 0010:[<ffffffff810620dd>]  [<ffffffff810620dd>] __lock_acquire+0xed/0xe82
[  +0.000000] RSP: 0018:ffff88003c3c19d8  EFLAGS: 00010002
[  +0.000000] RAX: 0000000000000001 RBX: 0000000000000246 RCX: 0000000000000000
[  +0.000000] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88003d1be868
[  +0.000000] RBP: ffff88003c3c1a98 R08: 0000000000000002 R09: 0000000000000000
[  +0.000000] R10: ffff88003d1be868 R11: ffff88003e20b000 R12: 0000000000000002
[  +0.000000] R13: ffff88003aaa8000 R14: 000000000000006e R15: ffff88003d1be850
[  +0.000000] FS:  0000000000000000(0000) GS:ffff88003e200000(0000) knlGS:0000000000000000
[  +0.000000] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  +0.000000] CR2: 0000000000000199 CR3: 000000003c1cb000 CR4: 00000000000006b0
[  +0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  +0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  +0.000000] Process kworker/u:2H (pid: 1481, threadinfo ffff88003c3c0000, task ffff88003aaa8000)
[  +0.000000] Stack:
[  +0.000000]  ffffffff81b16342 0000000000000000 0000000000000000 ffff88003d1be868
[  +0.000000]  ffffffff00000000 00018c0c7863e367 000000003c3c1a28 ffffffff8101efbd
[  +0.000000]  0000000000000000 ffff88003e3d2400 ffff88003c3c1a38 ffffffff81007c7a
[  +0.000000] Call Trace:
[  +0.000000]  [<ffffffff8101efbd>] ? kvm_clock_read+0x34/0x3b
[  +0.000000]  [<ffffffff81007c7a>] ? paravirt_sched_clock+0x9/0xd
[  +0.000000]  [<ffffffff81007fd4>] ? sched_clock+0x9/0xb
[  +0.000000]  [<ffffffff8104fd7a>] ? sched_clock_local+0x12/0x75
[  +0.000000]  [<ffffffff810632d1>] lock_acquire+0x93/0xb1
[  +0.000000]  [<ffffffffa0022339>] ? spin_lock+0x9/0xb [bluetooth]
[  +0.000000]  [<ffffffff8105f3d8>] ? lock_release_holdtime.part.22+0x4e/0x55
[  +0.000000]  [<ffffffff814f6038>] _raw_spin_lock+0x40/0x74
[  +0.000000]  [<ffffffffa0022339>] ? spin_lock+0x9/0xb [bluetooth]
[  +0.000000]  [<ffffffff814f6936>] ? _raw_spin_unlock+0x23/0x36
[  +0.000000]  [<ffffffffa0022339>] spin_lock+0x9/0xb [bluetooth]
[  +0.000000]  [<ffffffffa00230cc>] sco_conn_del+0x76/0xbb [bluetooth]
[  +0.000000]  [<ffffffffa002391d>] sco_connect_cfm+0x2da/0x2e9 [bluetooth]
[  +0.000000]  [<ffffffffa000862a>] hci_proto_connect_cfm+0x38/0x65 [bluetooth]
[  +0.000000]  [<ffffffffa0008d30>] hci_sync_conn_complete_evt.isra.79+0x11a/0x13e [bluetooth]
[  +0.000000]  [<ffffffffa000cd96>] hci_event_packet+0x153b/0x239d [bluetooth]
[  +0.000000]  [<ffffffff814f68ff>] ? _raw_spin_unlock_irqrestore+0x48/0x5c
[  +0.000000]  [<ffffffffa00025f6>] hci_rx_work+0xf3/0x2e3 [bluetooth]
[  +0.000000]  [<ffffffff8103efed>] process_one_work+0x1dc/0x30b
[  +0.000000]  [<ffffffff8103ef83>] ? process_one_work+0x172/0x30b
[  +0.000000]  [<ffffffff8103e07f>] ? spin_lock_irq+0x9/0xb
[  +0.000000]  [<ffffffff8103fc8d>] worker_thread+0x123/0x1d2
[  +0.000000]  [<ffffffff8103fb6a>] ? manage_workers+0x240/0x240
[  +0.000000]  [<ffffffff81044211>] kthread+0x9d/0xa5
[  +0.000000]  [<ffffffff81044174>] ? __kthread_parkme+0x60/0x60
[  +0.000000]  [<ffffffff814f75bc>] ret_from_fork+0x7c/0xb0
[  +0.000000]  [<ffffffff81044174>] ? __kthread_parkme+0x60/0x60
[  +0.000000] Code: d7 44 89 8d 50 ff ff ff 4c 89 95 58 ff ff ff e8 44 fc ff ff 44 8b 8d 50 ff ff ff 48 85 c0 4c 8b 95 58 ff ff ff 0f 84 7a 04 00 00 <f0> ff 80 98 01 00 00 83 3d 25 41 a7 00 00 45 8b b5 e8 05 00 00
[  +0.000000] RIP  [<ffffffff810620dd>] __lock_acquire+0xed/0xe82
[  +0.000000]  RSP <ffff88003c3c19d8>
[  +0.000000] CR2: 0000000000000199
[  +0.000000] ---[ end trace e73cd3b52352dd34 ]---

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Tested-by: Frederic Dalleau <frederic.dalleau@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bluetooth: Add support for Dell[QCA 0cf3:0036]

commit d66629c1325399cf080ba8b2fb086c10e5439cdd upstream.

Add support for the AR9462 chip

T:  Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=0036 Rev= 0.02
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>