nvhost: kzmalloc small jobs

use kzmalloc for jobs <= PAGE_SIZE, which is faster and lighter
weight than using vzmalloc

bug 1536343 (issue 16040850)

Change-Id: Ia012ea40f6c5bed5b31ca3b75e76e5c09d5c4449
Signed-off-by: Rich Wiley <rwiley@nvidia.com>
Reviewed-on: http://git-master/r/436375
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Tested-by: Krishna Reddy <vdumpa@nvidia.com>
nvmap: use kmap in place of vmalloc

On arm64 systems, kmap will use the static
kernel mapping, which is faster than a
vmalloc allocation.

bug 1536343 (issue 16040850)

On 64 bit systems, kmap can use the linear kernel
mapping, instead of creating a vmalloc allocation.
Change-Id: I0d243fa8e2e1ef5742bc18cbd4d527611e575b75
Signed-off-by: Rich Wiley <rwiley@nvidia.com>
Reviewed-on: http://git-master/r/435940
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
gpu: nvgpu: Initialize ELPG ref-count early.

gk20a_pmu_disable_elpg can be called before the PMU driver has
received and processed the INIT message from the PMU. If change
ensures that the ELPG ref-count has been initialized to zero
before that can happen.

Bug 200016313

Change-Id: Ic80ec1ee69b1eb0499effb1abf556f78cb041f5e
Signed-off-by: Neil Gabriel <ngabriel@nvidia.com>
Reviewed-on: http://git-master/r/431927
Reviewed-on: http://git-master/r/436302
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Tested-by: Thomas Cherry <tcherry@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
media: platform: tegra: support 64 bit user code

Since the user space code may works in either 32 or 64 bit mode,
attentions should be taken while passing pointers from user space to
the kernel. In this case, the p_value of struct nvc_param and
power_on/power_off of struct virtual_device received from the user
space should be handled properly.

The solution is to create a set of 32 bit version of structures
nvc_param and virtual_device along with some dedicated 32 bit mode
ioctl commands, then in the ioctl functions, the 32 bit user mode
access will be handled separately.

bug 1518359

Change-Id: I4cbbeeaef446ab962aaa1f92251ce1fd9d5723aa
Signed-off-by: Charlie Huang <chahuang@nvidia.com>
Reviewed-on: http://git-master/r/437390
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
video: tegra: nvmap: add handle share count to debug stats

handle share count provides info on how many processes are sharing
the handle. IOW, how many processes are holding a ref on handle.
Update the comments for umap/kmap_count.

Bug 1529015

Change-Id: I9f543ebf51842dad6ecd3bfeb7480496c98963be
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/426302
(cherry picked from commit 244c41508be0705cc232942b9403e17611f63e45)
Reviewed-on: http://git-master/r/440564
Tested-by: Maneet Maneet Singh <mmaneetsingh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: nvmap: set handle dmabuf to NULL early

This can allow catching handle dmabuf usage during its free.

Bug 1529015

Change-Id: Ie20c7b860ca5194a190ff7005302bf50602d16ed
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/424329
(cherry picked from commit 10e648c2e2f9760c97ce55a1091d9e7097d2504d)
Reviewed-on: http://git-master/r/440567
Tested-by: Maneet Maneet Singh <mmaneetsingh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: nvmap: don't count shared memory in full

Don't count shared memory in full in iovmm stats.
Add SHARE field to allocations info to show how many
processes are sharing the handle.
Update few comments in the code.
Remove unnecessary iovm_commit accounting.

Bug 1529015

Change-Id: I49650bf081d652dedc7139f639aae6da06965ecd
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/426274
(cherry picked from commit 92d47c10fbf7a315d4c953bafb71ee23032b7f65)
Reviewed-on: http://git-master/r/440573
Tested-by: Maneet Maneet Singh <mmaneetsingh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: dsi: turn off pads after calibration

Turn off mipi bias pads after calibration

Bug 200021693

Change-Id: Idf24d5807abb59228b000cc8301582ac7cc0e777
Signed-off-by: Vineel Kumar Reddy Kovvuri <vineelkumarr@nvidia.com>
Reviewed-on: http://git-master/r/440672
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Animesh Kishore <ankishore@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
video: tegra: nvmap: unify debug stats code

Unify debug stats code for iovmm and carveouts.

Bug 1529015

Change-Id: Ief800587870845ed6f566cb7afb2c91000d177ca
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/426733
(cherry picked from commit 0c0f7e5a9ef459d7940cc66af0a00321bb54d389)
Reviewed-on: http://git-master/r/440899
GVS: Gerrit_Virtual_Submit
Tested-by: Maneet Maneet Singh <mmaneetsingh@nvidia.com>
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: nvmap: track handle's vma list

Patch includes following nvmap changes:
 - added "pid" field in nvmap_vma_list so now looking at handle's vma list,
   we can say which vma belongs to which process.
 - sorted handle's vma list in ascending order of handle offsets.

Bug 1529015

Change-Id: Ide548e2d97bab8072461c11c9b8865ab4aa01989
Signed-off-by: Maneet Singh <mmaneetsingh@nvidia.com>
Reviewed-on: http://git-master/r/440914
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
arm64: kernel: check mode for get_user in undefinstr

get_user() should be called only for user_mode undef instruction.

Bug 1536343

Change-Id: Ia654783de0cf72abac6847ac9630236f9f0d6ebb
Signed-off-by: Peng Du <pdu@nvidia.com>
Reviewed-on: http://git-master/r/441348
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Reviewed-by: Bo Yan <byan@nvidia.com>
video: tegra: nvmap: remove carveout commit accounting

Remove obsolete carveout commit accounting.

Bug 1529015

Change-Id: If7e25ca2ef43c036558c9c9ead5f67ee8eef6b42
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/426734
(cherry picked from commit c1ddad1b13332386857f9f2964aa8968094e7e8c)
Reviewed-on: http://git-master/r/441551
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
video: tegra: nvmap: track handle's mapped memory

Added new file "maps" for nvmap heaps. In addition to data given by
existing "allocations" file, this also shows the client's virtual
mappings and total amount of handle physical memory that is actually
mapped to a client's virtual address space.

This change will help in tracking nvmap memory usage of processes.

Bug 1529015

Change-Id: I85b5c221c7a7475cbc3585b130fda6a282756662
Signed-off-by: Maneet Singh <mmaneetsingh@nvidia.com>
Reviewed-on: http://git-master/r/440942
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
video: tegra: dc: increase V_REF_TO_SYNC

Increase V_REF_TO_SYNC value to the maximum size. This adjusts where the flip
activation occurs and permits spool up to include more of the front porch
time.

Bug 1528419

Change-Id: I981d3ffca49c694acf0806279bcf87d92084169c
Signed-off-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-on: http://git-master/r/440817
(cherry picked from commit 1c9c042b31735bb1b04780037ba5d7b6aee9fcd2)
Reviewed-on: http://git-master/r/441378
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
Revert "arm64: mm: align copy_*_user accesses"

This reverts commit 275a80309907a687d21a0f6fe991a0710d3a9a10
(arm64: mm: align copy_*_user accesses), which causes the
zeroing loop to write zeroes over all of memory until the
kernel crashes if the unaligned loop faults.  This is caused
by the zeroing loop expecting to find the upper user buffer
boundary in x4, but the newly added loop stores the bottom
bits of the from address there instead.

Change-Id: I56a43fd2a60e0566af783ed79a62d876b9640914
Signed-off-by: Colin Cross <ccross@android.com>
Merge branch 'android-tegra-nv-3.10' into android-tegra-3.10
Revert "Revert "arm64: mm: align copy_*_user accesses""

This reverts commit ea6e1835ed4865eebcd8bf2cbc4404cb4b5f3d89.
The unaligned loop is necessary to support userspace components
that pass Device memory into copy_from_user.  The kernel shouldn't
be giving Device memory to userspace, but until that is fixed
we have to leave this patch in.  The next patch will fix the
issues that caused it to be reverted.

Change-Id: Ifffe453ec9580c6325278d6d5ee9ab5dfd423e8a
Signed-off-by: Colin Cross <ccross@android.com>
ARM64: fix unaligned loop in copy_from_user and copy_to_user

The unaligned loops added in commit
275a80309907a687d21a0f6fe991a0710d3a9a10 (arm64: mm: align
copy_*_user accesses) don't initialize x4, but the fault
handlers expect x4 to be the end address of the copy.
Move the initialization of x4 before the unaligned loop,
and replace the usage of x4 with x5 in the unaligned loop.

Change-Id: Ic1aeaca56a9d45c4f1de9bbf9588cfc072dd5d28
Signed-off-by: Colin Cross <ccross@android.com>