Commit graph

6612 commits

Author SHA1 Message Date
Ajay Dudani
5f63a32adc msm: kgsl: improved bounds checking on user-specified parameters
Verify that the user specified length for a PMEM region is smaller than the
size of the entire region as reported by the kernel APIs.

Change-Id: Ic0dedbad0127bdaed70eafc00238b44f982b093b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:47:11 -08:00
Devin Kim
f3fe5ec66c msm: kgsl: Hold the pm_qos vote at all times when ACTIVE
The GPU needs access to the L2 cache while running.  If the
CPU is not also active using the cache can lead to stability
issues.  Keep the CPU out of idle power collapse at all times
while the GPU is running.

CRs-Fixed: 397489
Change-Id: Iab2d8c601e903aadc4060f7c6d67bc128840edbf
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2013-03-04 12:46:42 -08:00
Ajay Dudani
dfa642feb4 gpu: ion: Fix race between ion_import and ion_free
If preemted during ion_free after the refcount is updated but
before the handle can be removed from the rb_tree, import
might find that handle in the tree and try to reuse it
when execution returns to free, the handle will be cleaned
up leaving the caller of import with a corrupt handle.
This patch modifies the locking to protect agains this race.

Change-Id: I31d18cc6398f0ca18e05cd919e2bcf86fa18d568
CRs-Fixed: 385283
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
[lauraa@codeaurora.org: Whitespace change and move unlock]
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2013-03-04 12:46:20 -08:00
Jeff Boody
f73cd6b4d2 msm: kgsl: remove unnecessary definitions for dup and has_signaled
The dup and has_signaled functions are not called outside kgsl_sync.c

Change-Id: I69d746f4e4acae9b4f5a3a2cac79ac812e5eff5c
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
2013-03-04 12:46:12 -08:00
Jeff Boody
8c2947df3f msm: kgsl: implement sync compare callback
The compare callback is required to test the order that
sync pts will signal. Failing to implement the compare
callback results in kernel panics for some use cases.

Change-Id: Ibea1497c12fd8cc66087ff52d3709a07793f215f
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
2013-03-04 12:46:12 -08:00
Jeff Boody
855ae3da46 msm: kgsl: Add support for Android's sync point framework
The Android sync point framework will replace the synchronization
previously implemented by genlock. This change implements the KGSL
component of the sync point framework by creating a fence that is
automatically signaled by KGSL when it's timestamp expires. The
fence FD is returned to the user driver so that another process
can wait for the sync point.

Change-Id: Ifee38dfde00e551f3524f7a37833938dcdb64905
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
2013-03-04 12:46:04 -08:00
Iliyan Malchev
30a5199be3 [ARM] msm: kgsl: replace vmalloc with kmalloc
There is no point using vmalloc for small temporary allocations.  kmalloc will
allocate more quickly and will not fragment the vmalloc space.

Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:43:03 -08:00
Shubhraprakash Das
04f620de39 msm: kgsl: Map ebi memory to kernel
Implement the function to map ebi memory to the kernel.
This function is used when from postmortem or snapshot
when there is a hang and we are allocating memory from
kernel ebi space

Change-Id: I4f3e8b3fcb8c0107599ce3d3636c0ed33ace725a
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:21:37 -08:00
Suman Tatiraju
eb44f614d6 msm: kgsl: Add GPU clock statistics.
The GPU clock statistics show the amount of time the
GPU was busy in the last one second and the time spent
at each individual clock level while it was busy.

Change-Id: I16f8973ca0c683d55406a1f37c1395cdfe43ef5a
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
2013-02-27 18:21:24 -08:00
Shubhraprakash Das
96fcb09d25 msm: kgsl: Fix address range checking with no MMU
Fix the address range checked with no MMU by always
returning true for no MMU as there is no particular
address range when MMU is not used

Change-Id: I522681d13b2281d482bad91dd00d34ec0f440a1f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Alex Wong <waiw@codeaurora.org>
2013-02-27 18:21:07 -08:00
Jordan Crouse
1c152d4571 msm: kgsl: Allow the wait_timeout to be disabled
With the improved hang detection we don't technically need a upper
timeout bound for a process to wait in waitfortimestamp().  Allow
for a idle_timestamp of '0' to allow the loop to wait for ever.
The infrastructure for changing the idle_timeout still exists
so it can be changed to whatever value is appropriate for debugging
or testing.

CRs-fixed: 382366
CRs-fixed: 383999
Change-Id: Ic0dedbadf2c100eb56ed2338914575061776e725
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-02-27 18:20:48 -08:00
Jordan Crouse
0303adb2b1 msm: kgsl: Don't use 'wait_timeout' in the idle functions
There are two distinct parts of the code that may need to loop waiting
for the GPU to complete a task: waiting for a timestamp and waiting
for the entire core to go idle. Waiting for a timestamp technically
doesn't need a timeout since the only downside is a process that sleeps
forever with an interruptible timeout. Waiting for the core to go idle
is more problematic because it is a busy wait and it is the last point
we can safely detect a GPU hang.

Beacuse we can (and will) not use a timeout in wait for timestamp, we
need to institute a new timeout value to be used in idle. Nowhere the
idle function is called uses a custom value for the timeout, so remove
that parameter from the calls and use a static timeout value in the
core specific functions.

Change-Id: Ic0dedbad9ecd2044c34e4cec551dc7f53b253f3d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-02-27 18:20:48 -08:00
Lucille Sylvester
4864243afb msm: kgsl: Hold pm_qos vote for active rendering
Differentiate between the screen off case where kgsl shouldn't
hold a pm_qos vote and the screen on case where power rails
may be turned off after a long idle.  restore_slumber now
corresponds to the screen on/off while strtstp_sleepwake covers
the power rail collapse.

CRs-Fixed: 386956
Change-Id: Id4318f1aa87d6ad0653fe5db18c5d33bda1cc8bb
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2013-02-27 18:20:11 -08:00
Jordan Crouse
eac5afc020 msm: kgsl: Detect and avoid malformed ioctl codes
Because we were using _IO_NR, one could construct a malformed ioctl
code that would avoid allocating memory yet go to a function that
expected that memory. Still use _IO_NR to index the array of ioctls,
but check that the full values match before jumping to the helper
function.

CRs-fixed: 385592
Change-Id: Ic0dedbaded469035bd0a2bb0f20fecb2a3045ca5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-02-27 18:20:00 -08:00
Harsh Vardhan Dwivedi
83febe078a msm: kgsl: Add postmortem dump for 2D (z180) cores
Add ringbuffer and register dump as part of postmortem dump for z180
cores. Also, add kgsl_postmortem_dump as a preparatory general function
for postmortem dump for both types of kgsl devices, adreno and z180.

Change-Id: I8b538771bfa8f6bfdfe0b1b993afa3c53f8eb8cf
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
2013-02-27 18:19:54 -08:00
Anoop Kumar Yerukala
4ac8c8718d msm: kgsl: disable gpummu pagefault interrupts when iommu is enabled
GPU MMU is used to control access to IOMMU registers on msm8960.
When pagefaults occurs, accessing mmu_pagefault which is NULL
causes kernel panic. Disable gpummu pagefault interrupts, since
pagefaults are handled through iommu fault handler.

CRs-Fixed: 380470
Change-Id: I9717f4af10b9722b0a14ba5995ee2293ae1de09f
Signed-off-by: Anoop Kumar Yerukala <ayeruk@codeaurora.org>
2013-02-27 18:19:10 -08:00
liu zhong
8cf7900981 msm: kgsl: Add support for OCMEM
OCMEM is a on-chip memory bank which is shared by all Multimedia
components. KGSL needs to request space for GMEM usage for platforms
that support OCMEM.

Change-Id: Ic3ff501d7a444a71f75244806af95c62c8a08ed8
Signed-off-by: liu zhong <zhongl@codeaurora.org>
2013-02-27 18:19:04 -08:00
liu zhong
8de251c1a0 msm: kgsl: Support A330 GPU
Add GPU ID and VBIF configuration for the A330 GPU

Change-Id: I02f1d6aab60233d0205f930e1813f14a685dd89c
Signed-off-by: liu zhong <zhongl@codeaurora.org>
2013-02-27 18:19:04 -08:00
Pu Chen
ddd9660ccb msm: kgsl: Change vdd_dig to vddcx
Change GPU digital circuit head switch name to vddcx to match
devicetree property name convention.

Change-Id: If17b47125f08873106f74fdb21a29c58dbf1496a
Signed-off-by: Pu Chen <puchen@codeaurora.org>
2013-02-27 18:19:03 -08:00
Lokesh Batra
18198ff8f2 msm: kgsl: Add support for device tree in kgsl
Populate the platform_data structure by reading from the Device Tree
Source file.

Change-Id: Ic8c83d3918510448b76559b095ad414d2f22c7bd
Signed-off-by: Lokesh Batra <lbatra@codeaurora.org>
2013-02-27 18:19:02 -08:00
Olav Haugan
c7fafd3b29 gpu: ion: Add support for device tree.
Add device tree parsing to common msm ion code
to allow new targets to specify ION heap configuration
in device tree.

Document the device tree bindings for ION.

Change-Id: I40b7f4b1fbb3ca4ad1d6dc06a33b647f6af1d669
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
2013-02-27 18:19:01 -08:00
Suman Tatiraju
21551379fe msm: kgsl: Add MPDCVS trace events
These trace events help in detecting whether we are reporting the
right events(busy/idle) to the mpdcvs driver, effectively improving
debugging capabilities. The mpdcvs driver should get a busy event
when the gpu is active and an idle event whenever gpu goes idle.

Change-Id: Ie227343e764e5c7bce1c95f75668bf6326d62e7a
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
2013-02-27 18:18:58 -08:00
Carter Cooper
59b22483bf msm: kgsl: Fix conditional GPU interrupts to fire only for waiting context
Conditional interrupts were not getting fired at the correct time when
using per context timestamps.  When a context was waiting on a timestamp,
the interrupt was being fired on the global timestamp rather than the per
context timestamp.  Now the interrupt is fired on the per context
timestamp.

Change-Id: Ib683c846f0639a1e44f5b39bb81ca2751b306ea1
CRs-Fixed: 340620
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-02-27 18:18:57 -08:00
Lucille Sylvester
04226935d7 msm: kgsl: No need to write registers on _stop
After a _stop, _start must be called to write the correct
values to these registers before the device can be used
again.  No reason to write an additional value on _stop.

Change-Id: If78bfd2ca81cce9d3320419c997a8d48af96fe13
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2013-02-27 18:18:53 -08:00
Laura Abbott
2f4bb0e8da gpu: ion: Don't call ion_buffer_put on error path
If dma_buf_fd fails, the dma_buf needs to be cleaned up by
calling dma_buf_put. dma_buf_put will call ion_dma_buf_release
which in turn calls ion_buffer_put to clean up the buffer
reference. Calling ion_buffer_put after dma_buf_put drops the
reference count by one more which is incorrect. Fix this by
getting rid of the extra ion_buffer_put call.

Change-Id: Ieb3a7b781bf2dc299c45384dbf0a12d186adeb22
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
2013-02-27 18:18:45 -08:00
Rajesh Kemisetti
d129f21acc msm: kgsl: Increase REG_RBBM_CNTL value to 0xFFFF for A203
Increase number of clocks that RBBM will wait before de-asserting
the Register Clock Active signal. This fixes kernel panics during
stability tests on multiple devices.

Change-Id: Id8791e0f691be09d96cfd4ad8438baed51347293
CRs-fixed: 372793
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
2013-02-27 18:18:40 -08:00
Suman Tatiraju
1b6967f9ec msm: kgsl: fix idle reporting for the msm pwrscale policy
Report idle whenever we go to nap and sleep for the msm policy

Change-Id: I490d76812b6833acd1fe7394129ce2f42483d8c2
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
2013-02-27 18:18:39 -08:00
Shubhraprakash Das
96be649682 msm: kgsl: Use the gpuaddr to decide whether to map memstore
Use the gpuaddr to determine whether memstore is being mapped in
mmap or a normal memory allocation is mapped instead of physical
address. gpuaddr of the memstore will always be unique but the
physaddr may be equal to the gpuaddr of another memory allocation
and that will cause the memory allocation to be mapped as memstore
which is wrong.

Change-Id: I6a803e82e0a9d3713ebb3f15ea46d450f69d8ac7
CRs-fixed: 379019
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:18:30 -08:00
Shubhraprakash Das
d76281c676 msm: kgsl: After timeout check if timestamp has retired
When a thread times out while waiting for a timestamp, check once
whether the timestamp which it was waiting for has expired or not
before treating it as an error

Change-Id: Iffba7955de58974a8d990a589b926e10f6c6a481
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:18:26 -08:00
Wei Zou
985df205dc msm: kgsl: Fix a logical error in the gpu hang detection code
Change the GPU hang detection code to avoid the normal case is
mistakely treated as GPU hang scenario.

CRs-Fixed: 378488
Change-Id: Ie79a8d91e35c51ba043e7a845c9a56266277f1a0
Signed-off-by: Wei Zou <wzou@codeaurora.org>
2013-02-27 18:17:59 -08:00
Shubhraprakash Das
a8fdfa0347 msm: kgsl: Remove the use of asid
Remove the use of asid(application space ID) from the kgsl driver
for IOMMU since it's known to cause to stability issues on the
2D core

Change-Id: I92f82ebb0941296c7ad625dd833822dd918fe386
CRs-fixed: 379439
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:17:58 -08:00
Jordan Crouse
3b35a43a0e msm: kgsl: Do bounds checking on user supplied GPU addresses
Add bounds checking to kgsl_sharedmem_find_region to ensure that GPU
addresses supplied by the user via KGSL_IOCTL_SHAREMEM_FREE and
KGSL_IOCTL_CFF_SYNCMEM are within a valid range for the MMU scheme of
choice.

CRs-Fixed: 380296
Change-Id: Ic0dedbadf40fca4a9e04ba075e67e08e617806b5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-02-27 18:17:26 -08:00
Jordan Crouse
fedf5b0389 msm: kgsl: Limit the number of indirect buffers per submission
Put a reasonable upper limit on the number of indirect buffers allowed
per submission via IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS.

CRs-Fixed: 380267
Change-Id: Ic0dedbadd78a0ad3f09f67660f34b2fba421007f
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-02-27 18:17:25 -08:00
Shubhraprakash Das
b9bd1d3317 msm: kgsl: In recovery switch IOMMU clocks on/off
Turn on the IOMMU clocks in recovery as the recovered command
stream may have commands that read and write to IOMMU registers.

Change-Id: I6a8d9fa17a57b0c4f8564fc62d019b2e150b8399
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:17:24 -08:00
Tarun Karra
013b2e8f46 msm: kgsl: Allow non-default timeout values in adreno_idle
In adreno_idle the default timeout value was always used,
even if the caller specified something different. The caller
can now specify a non default timeout value to be used
in adreno_idle.

Change-Id: Ibb6bcc094521d4a660d8385b32bf8c6ac68acbd9
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
2013-02-27 18:17:17 -08:00
Lucille Sylvester
eb91c6c0eb msm: kgsl: Don't let thermal control use invalid GPU frequencies
The lowest non-zero GPU frequency is only meant to be set when
the device enters SLEEP and the clocks are off.  Do not permit it
to be used as a thermal level.

Change-Id: I6eedf39849ec5211977f824148883e3694cae50b
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2013-02-27 18:16:40 -08:00
Shubhraprakash Das
6c84e45301 msm: kgsl: In recovery search for command stream after global eop
In recovery search for the timestamp of the command stream after
global eop instead of searching for the command stream of the
global eop and then moving the pointer forward till the start of
the command stream following global eop. This is because if the
ringbuffer is full then the global eop timestamp may have been
overwritten, so its more reliable to search for the timestamp
that occurs after global eop.

Change-Id: Ide272fd653bcba411f0c4b92b3dc2ac2fa8326a9
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:36 -08:00
Shubhraprakash Das
6a8347c7b6 msm: kgsl: Try to replay commands from bad context in recovery
Replay the all the commands that have not been executed by the GPU
in recovery with preamble turned on for the first command to see
if that succeeds. If it does then we have recovered all contexts.
If that fails then replay commands only from contexts that are
in a good state.

Change-Id: Ia2a5c9b0de5556c5182cfab3bd6ae576d15b53eb
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:36 -08:00
Shubhraprakash Das
6920455ad7 msm: kgsl: Expire timestamps after recovery
Expire the global timestamp and timestamps of contexts that have
cause at the end of recovery. This will prevent any users waiting
on timestamps of hung contexts to return without waiting.

Change-Id: I373de7211edd09646cdb0fb11d67b562a1ab2966
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:35 -08:00
Shubhraprakash Das
f32e14bc7c msm: kgsl: Mark the hung context in recovery before extraction
Mark the context that has caused a hang in recovery before
calling the extraction function. This updates the context
state correctly early in recovery.

Change-Id: I68cbe5cc6f867c8d32dd0115eed6f1c65c54f796
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:35 -08:00
Shubhraprakash Das
40c0c3435f msm: kgsl: Write a separate function to set the reset status
Write a separate function that sets the reset status of each
context after recovery.

Change-Id: I0fbd6578625637373beb9a565024043ece186e6d
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:35 -08:00
Shubhraprakash Das
6576fe3a30 msm: kgsl: Do not restore per context timestamp states
We do not have to restore the per context timestamp states during
recovery as this data is irrelevant after recovery.

Change-Id: I3f0350afda4b4ecbdd60027720b7e4832adf04a3
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:34 -08:00
Shubhraprakash Das
88b7a616de msm: kgsl: Turn on preamble to enable replay of commands
Turn on the preamble of the IB sequence in which hang is assumed
to have happened so that the bad sequence can be replayed.

Change-Id: I7123f6b5152a530c38999d6ef4aa5476d64960a7
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:34 -08:00
Shubhraprakash Das
e7409f23fc msm: kgsl: Separate function to detect last command in recovery
Make the code more readable by writing a separate function to
detect the end of last command that is assumed to be successfully
executed by the GPU

Change-Id: Icab1f4e563ea533c48aba9c57afb548501e19552
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:33 -08:00
Shubhraprakash Das
d70af9c9a4 msm: kgsl: Create a separate function to extract valid commands
Create a separate function that extracts valid commands from good
contexts and invalid commands from bad contexts during recovery

Change-Id: Icffe34821c1b70ca1a8c1a8e13a0b7e23d0ec193
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:33 -08:00
Shubhraprakash Das
84c11008a6 msm: kgsl: Use recovery data structure to extract valid commands
Use the data set in the recovery structure when extracting
valid commands from the ringbuffer instead of reading
it from the device/memory.

Change-Id: I9cbcc09b1ce95313c2d3cf59fbb649dad2cb9d99
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:32 -08:00
Shubhraprakash Das
f787bdf4cb msm: kgsl: Introduce recovery data structure for hang recovery
Create a new data structure that holds all the information required
for recovering from hangs. This data structure is initialized as soon
as hang is detected because if the GPU is under DOS attack then by
the time we start recovery the recovery data may have changed.

Change-Id: I862787267c582b9ca95bb191fb3503ceba1faa8c
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:32 -08:00
Shubhraprakash Das
15bb6b641d msm: kgsl: Always add a start identifier to a command sequence
Add command sequence start identifier for commands submitted from
kgsl as well since this will be used during recovery. We will just
try recovery and not try to differentiate between commands from
kgsl or from user space.

Change-Id: I433e9f2786268c6c51a446e3c7cf9eb5fd429197
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:31 -08:00
Shubhraprakash Das
0145b4df7d msm: kgsl: During postmortem check for IOMMU table change
When performing postmortem, check for IOMMU pagetable change commands
which will allow us to find the IB from the correct pagetable.

Change-Id: I411f4c78632d1673d49d5557da435e2a9d31d420
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:31 -08:00
Shubhraprakash Das
9562544cb0 msm: kgsl: Start the sleep timer after recovery has completed
Start the sleep timer if recovery from hang is successful.
This prevents GPU from entering low power states during
recovery.

Change-Id: Icb021f1b1bfae7876394fa572acd156115372ac3
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:31 -08:00