android_kernel_google_msm/drivers/gpu/msm/adreno_ringbuffer.c

1123 lines
30 KiB
C
Raw Normal View History

/* Copyright (c) 2002,2007-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/log2.h>
#include <linux/time.h>
#include <linux/delay.h>
#include "kgsl.h"
#include "kgsl_sharedmem.h"
#include "kgsl_cffdump.h"
#include "adreno.h"
#include "adreno_pm4types.h"
#include "adreno_ringbuffer.h"
#include "a2xx_reg.h"
#include "a3xx_reg.h"
#define GSL_RB_NOP_SIZEDWORDS 2
/*
* CP DEBUG settings for all cores:
* DYNAMIC_CLK_DISABLE [27] - turn off the dynamic clock control
* PROG_END_PTR_ENABLE [25] - Allow 128 bit writes to the VBIF
*/
#define CP_DEBUG_DEFAULT ((1 << 27) | (1 << 25))
void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
BUG_ON(rb->wptr == 0);
/* Let the pwrscale policy know that new commands have
been submitted. */
kgsl_pwrscale_busy(rb->device);
/*synchronize memory before informing the hardware of the
*new commands.
*/
mb();
adreno_writereg(adreno_dev, ADRENO_REG_CP_RB_WPTR, rb->wptr);
}
static int
adreno_ringbuffer_waitspace(struct adreno_ringbuffer *rb,
struct adreno_context *context,
unsigned int numcmds, int wptr_ahead)
{
int nopcount;
unsigned int freecmds;
unsigned int *cmds;
uint cmds_gpu;
unsigned long wait_time;
unsigned long wait_timeout = msecs_to_jiffies(ADRENO_IDLE_TIMEOUT);
unsigned long wait_time_part;
unsigned int rptr;
/* if wptr ahead, fill the remaining with NOPs */
if (wptr_ahead) {
/* -1 for header */
nopcount = rb->sizedwords - rb->wptr - 1;
cmds = (unsigned int *)rb->buffer_desc.hostptr + rb->wptr;
cmds_gpu = rb->buffer_desc.gpuaddr + sizeof(uint)*rb->wptr;
GSL_RB_WRITE(rb->device, cmds, cmds_gpu,
cp_nop_packet(nopcount));
/* Make sure that rptr is not 0 before submitting
* commands at the end of ringbuffer. We do not
* want the rptr and wptr to become equal when
* the ringbuffer is not empty */
do {
rptr = adreno_get_rptr(rb);
} while (!rptr);
rb->wptr = 0;
}
wait_time = jiffies + wait_timeout;
wait_time_part = jiffies + msecs_to_jiffies(KGSL_TIMEOUT_PART);
/* wait for space in ringbuffer */
while (1) {
rptr = adreno_get_rptr(rb);
freecmds = rptr - rb->wptr;
if (freecmds == 0 || freecmds > numcmds)
break;
if (time_after(jiffies, wait_time)) {
KGSL_DRV_ERR(rb->device,
"Timed out while waiting for freespace in ringbuffer "
"rptr: 0x%x, wptr: 0x%x\n", rptr, rb->wptr);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
return -ETIMEDOUT;
}
}
return 0;
}
unsigned int *adreno_ringbuffer_allocspace(struct adreno_ringbuffer *rb,
struct adreno_context *context,
unsigned int numcmds)
{
unsigned int *ptr = NULL;
int ret = 0;
unsigned int rptr;
BUG_ON(numcmds >= rb->sizedwords);
rptr = adreno_get_rptr(rb);
/* check for available space */
if (rb->wptr >= rptr) {
/* wptr ahead or equal to rptr */
/* reserve dwords for nop packet */
if ((rb->wptr + numcmds) > (rb->sizedwords -
GSL_RB_NOP_SIZEDWORDS))
ret = adreno_ringbuffer_waitspace(rb, context,
numcmds, 1);
} else {
/* wptr behind rptr */
if ((rb->wptr + numcmds) >= rptr)
ret = adreno_ringbuffer_waitspace(rb, context,
numcmds, 0);
/* check for remaining space */
/* reserve dwords for nop packet */
if (!ret && (rb->wptr + numcmds) > (rb->sizedwords -
GSL_RB_NOP_SIZEDWORDS))
ret = adreno_ringbuffer_waitspace(rb, context,
numcmds, 1);
}
if (!ret) {
ptr = (unsigned int *)rb->buffer_desc.hostptr + rb->wptr;
rb->wptr += numcmds;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
} else
ptr = ERR_PTR(ret);
return ptr;
}
static int _load_firmware(struct kgsl_device *device, const char *fwfile,
void **data, int *len)
{
const struct firmware *fw = NULL;
int ret;
ret = request_firmware(&fw, fwfile, device->dev);
if (ret) {
KGSL_DRV_ERR(device, "request_firmware(%s) failed: %d\n",
fwfile, ret);
return ret;
}
*data = kmalloc(fw->size, GFP_KERNEL);
if (*data) {
memcpy(*data, fw->data, fw->size);
*len = fw->size;
} else
KGSL_MEM_ERR(device, "kmalloc(%d) failed\n", fw->size);
release_firmware(fw);
return (*data != NULL) ? 0 : -ENOMEM;
}
int adreno_ringbuffer_read_pm4_ucode(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int ret = 0;
if (adreno_dev->pm4_fw == NULL) {
int len;
void *ptr;
ret = _load_firmware(device, adreno_dev->pm4_fwfile,
&ptr, &len);
if (ret)
goto err;
/* PM4 size is 3 dword aligned plus 1 dword of version */
if (len % ((sizeof(uint32_t) * 3)) != sizeof(uint32_t)) {
KGSL_DRV_ERR(device, "Bad firmware size: %d\n", len);
ret = -EINVAL;
kfree(ptr);
goto err;
}
adreno_dev->pm4_fw_size = len / sizeof(uint32_t);
adreno_dev->pm4_fw = ptr;
adreno_dev->pm4_fw_version = adreno_dev->pm4_fw[1];
}
err:
return ret;
}
/**
* adreno_ringbuffer_load_pm4_ucode() - Load pm4 ucode
* @device: Pointer to a KGSL device
* @start: Starting index in pm4 ucode to load
* @addr: Address to load the pm4 ucode
*
* Load the pm4 ucode from @start at @addr.
*/
int adreno_ringbuffer_load_pm4_ucode(struct kgsl_device *device,
unsigned int start, unsigned int addr)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int i;
if (adreno_dev->pm4_fw == NULL) {
int ret = adreno_ringbuffer_read_pm4_ucode(device);
if (ret)
return ret;
}
KGSL_DRV_INFO(device, "loading pm4 ucode version: %d\n",
adreno_dev->pm4_fw_version);
adreno_writereg(adreno_dev, ADRENO_REG_CP_DEBUG, CP_DEBUG_DEFAULT);
adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_RAM_WADDR, addr);
for (i = 1; i < adreno_dev->pm4_fw_size; i++)
adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_RAM_DATA,
adreno_dev->pm4_fw[i]);
return 0;
}
int adreno_ringbuffer_read_pfp_ucode(struct kgsl_device *device)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int ret = 0;
if (adreno_dev->pfp_fw == NULL) {
int len;
void *ptr;
ret = _load_firmware(device, adreno_dev->pfp_fwfile,
&ptr, &len);
if (ret)
goto err;
/* PFP size shold be dword aligned */
if (len % sizeof(uint32_t) != 0) {
KGSL_DRV_ERR(device, "Bad firmware size: %d\n", len);
ret = -EINVAL;
kfree(ptr);
goto err;
}
adreno_dev->pfp_fw_size = len / sizeof(uint32_t);
adreno_dev->pfp_fw = ptr;
adreno_dev->pfp_fw_version = adreno_dev->pfp_fw[5];
}
err:
return ret;
}
/**
* adreno_ringbuffer_load_pfp_ucode() - Load pfp ucode
* @device: Pointer to a KGSL device
* @start: Starting index in pfp ucode to load
* @addr: Address to load the pfp ucode
*
* Load the pfp ucode from @start at @addr.
*/
int adreno_ringbuffer_load_pfp_ucode(struct kgsl_device *device,
unsigned int start, unsigned int addr)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int i;
if (adreno_dev->pfp_fw == NULL) {
int ret = adreno_ringbuffer_read_pfp_ucode(device);
if (ret)
return ret;
}
KGSL_DRV_INFO(device, "loading pfp ucode version: %d\n",
adreno_dev->pfp_fw_version);
adreno_writereg(adreno_dev, ADRENO_REG_CP_PFP_UCODE_ADDR, addr);
for (i = 1; i < adreno_dev->pfp_fw_size; i++)
adreno_writereg(adreno_dev, ADRENO_REG_CP_PFP_UCODE_DATA,
adreno_dev->pfp_fw[i]);
return 0;
}
/**
* _ringbuffer_start_common() - Ringbuffer start
* @rb: Pointer to adreno ringbuffer
*
* Setup ringbuffer for GPU.
*/
int _ringbuffer_start_common(struct adreno_ringbuffer *rb)
{
int status;
struct kgsl_device *device = rb->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
if (rb->flags & KGSL_FLAGS_STARTED)
return 0;
kgsl_sharedmem_set(rb->device, &rb->buffer_desc, 0, 0xAA,
(rb->sizedwords << 2));
/*
* The size of the ringbuffer in the hardware is the log2
* representation of the size in quadwords (sizedwords / 2).
* Also disable the host RPTR shadow register as it might be unreliable
* in certain circumstances.
*/
adreno_writereg(adreno_dev, ADRENO_REG_CP_RB_CNTL,
(ilog2(rb->sizedwords >> 1) & 0x3F) |
(1 << 27));
adreno_writereg(adreno_dev, ADRENO_REG_CP_RB_BASE,
rb->buffer_desc.gpuaddr);
if (adreno_is_a2xx(adreno_dev)) {
/* explicitly clear all cp interrupts */
kgsl_regwrite(device, REG_CP_INT_ACK, 0xFFFFFFFF);
}
/* setup scratch/timestamp */
adreno_writereg(adreno_dev, ADRENO_REG_SCRATCH_ADDR,
device->memstore.gpuaddr +
KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
soptimestamp));
adreno_writereg(adreno_dev, ADRENO_REG_SCRATCH_UMSK,
GSL_RB_MEMPTRS_SCRATCH_MASK);
/* CP ROQ queue sizes (bytes) - RB:16, ST:16, IB1:32, IB2:64 */
if (adreno_is_a305(adreno_dev) || adreno_is_a305c(adreno_dev) ||
adreno_is_a320(adreno_dev))
kgsl_regwrite(device, REG_CP_QUEUE_THRESHOLDS, 0x000E0602);
else if (adreno_is_a330(adreno_dev) || adreno_is_a305b(adreno_dev))
kgsl_regwrite(device, REG_CP_QUEUE_THRESHOLDS, 0x003E2008);
rb->wptr = 0;
/* clear ME_HALT to start micro engine */
adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_CNTL, 0);
/* ME init is GPU specific, so jump into the sub-function */
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
status = adreno_dev->gpudev->rb_init(adreno_dev, rb);
if (status)
return status;
/* idle device to validate ME INIT */
status = adreno_idle(device);
if (status == 0)
rb->flags |= KGSL_FLAGS_STARTED;
return status;
}
/**
* adreno_ringbuffer_warm_start() - Ringbuffer warm start
* @rb: Pointer to adreno ringbuffer
*
* Start the ringbuffer but load only jump tables part of the
* microcode.
*/
int adreno_ringbuffer_warm_start(struct adreno_ringbuffer *rb)
{
int status;
struct kgsl_device *device = rb->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
/* load the CP ucode */
status = adreno_ringbuffer_load_pm4_ucode(device,
adreno_dev->pm4_jt_idx, adreno_dev->pm4_jt_addr);
if (status != 0)
return status;
/* load the prefetch parser ucode */
status = adreno_ringbuffer_load_pfp_ucode(device,
adreno_dev->pfp_jt_idx, adreno_dev->pfp_jt_addr);
if (status != 0)
return status;
return _ringbuffer_start_common(rb);
}
int adreno_ringbuffer_start(struct adreno_ringbuffer *rb)
{
int status;
if (rb->flags & KGSL_FLAGS_STARTED)
return 0;
/* load the CP ucode */
status = adreno_ringbuffer_load_pm4_ucode(rb->device, 1, 0);
if (status != 0)
return status;
/* load the prefetch parser ucode */
status = adreno_ringbuffer_load_pfp_ucode(rb->device, 1, 0);
if (status != 0)
return status;
return _ringbuffer_start_common(rb);
}
void adreno_ringbuffer_stop(struct adreno_ringbuffer *rb)
{
struct kgsl_device *device = rb->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
if (rb->flags & KGSL_FLAGS_STARTED) {
if (adreno_is_a200(adreno_dev))
kgsl_regwrite(rb->device, REG_CP_ME_CNTL, 0x10000000);
rb->flags &= ~KGSL_FLAGS_STARTED;
}
}
int adreno_ringbuffer_init(struct kgsl_device *device)
{
int status;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer;
rb->device = device;
/*
* It is silly to convert this to words and then back to bytes
* immediately below, but most of the rest of the code deals
* in words, so we might as well only do the math once
*/
rb->sizedwords = KGSL_RB_SIZE >> 2;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
rb->buffer_desc.flags = KGSL_MEMFLAGS_GPUREADONLY;
/* allocate memory for ringbuffer */
status = kgsl_allocate_contiguous(&rb->buffer_desc,
(rb->sizedwords << 2));
if (status != 0) {
adreno_ringbuffer_close(rb);
return status;
}
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
rb->global_ts = 0;
return 0;
}
void adreno_ringbuffer_close(struct adreno_ringbuffer *rb)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
kgsl_sharedmem_free(&rb->buffer_desc);
kfree(adreno_dev->pfp_fw);
kfree(adreno_dev->pm4_fw);
adreno_dev->pfp_fw = NULL;
adreno_dev->pm4_fw = NULL;
memset(rb, 0, sizeof(struct adreno_ringbuffer));
}
static int
adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
struct adreno_context *drawctxt,
unsigned int flags, unsigned int *cmds,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
int sizedwords, uint32_t timestamp)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
unsigned int *ringcmds;
unsigned int total_sizedwords = sizedwords;
unsigned int i;
unsigned int rcmd_gpu;
unsigned int context_id;
unsigned int gpuaddr = rb->device->memstore.gpuaddr;
if (drawctxt != NULL && kgsl_context_detached(&drawctxt->base))
return -EINVAL;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
rb->global_ts++;
/* If this is a internal IB, use the global timestamp for it */
if (!drawctxt || (flags & KGSL_CMD_FLAGS_INTERNAL_ISSUE)) {
timestamp = rb->global_ts;
context_id = KGSL_MEMSTORE_GLOBAL;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
} else {
context_id = drawctxt->base.id;
}
/*
* Note that we cannot safely take drawctxt->mutex here without
* potential mutex inversion with device->mutex which is held
* here. As a result, any other code that accesses this variable
* must also use device->mutex.
*/
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (drawctxt)
drawctxt->internal_timestamp = rb->global_ts;
/* reserve space to temporarily turn off protected mode
* error checking if needed
*/
total_sizedwords += flags & KGSL_CMD_FLAGS_PMODE ? 4 : 0;
/* 2 dwords to store the start of command sequence */
total_sizedwords += 2;
/* internal ib command identifier for the ringbuffer */
total_sizedwords += (flags & KGSL_CMD_FLAGS_INTERNAL_ISSUE) ? 2 : 0;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/* Add two dwords for the CP_INTERRUPT */
total_sizedwords +=
(drawctxt || (flags & KGSL_CMD_FLAGS_INTERNAL_ISSUE)) ? 2 : 0;
/* context rollover */
if (adreno_is_a3xx(adreno_dev))
total_sizedwords += 3;
/* For HLSQ updates below */
if (adreno_is_a4xx(adreno_dev) || adreno_is_a3xx(adreno_dev))
total_sizedwords += 4;
if (adreno_is_a2xx(adreno_dev))
total_sizedwords += 2; /* CP_WAIT_FOR_IDLE */
total_sizedwords += 3; /* sop timestamp */
total_sizedwords += 4; /* eop timestamp */
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (drawctxt) {
total_sizedwords += 3; /* global timestamp without cache
* flush for non-zero context */
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
}
if (adreno_is_a20x(adreno_dev))
total_sizedwords += 2; /* CACHE_FLUSH */
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (flags & KGSL_CMD_FLAGS_WFI)
total_sizedwords += 2; /* WFI */
/* Add space for the power on shader fixup if we need it */
if (flags & KGSL_CMD_FLAGS_PWRON_FIXUP)
total_sizedwords += 5;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ringcmds = adreno_ringbuffer_allocspace(rb, drawctxt, total_sizedwords);
if (IS_ERR(ringcmds))
return PTR_ERR(ringcmds);
if (ringcmds == NULL)
return -ENOSPC;
rcmd_gpu = rb->buffer_desc.gpuaddr
+ sizeof(uint)*(rb->wptr-total_sizedwords);
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, cp_nop_packet(1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, KGSL_CMD_IDENTIFIER);
if (flags & KGSL_CMD_FLAGS_INTERNAL_ISSUE) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, cp_nop_packet(1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
KGSL_CMD_INTERNAL_IDENTIFIER);
}
if (flags & KGSL_CMD_FLAGS_PWRON_FIXUP) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, cp_nop_packet(1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
KGSL_PWRON_FIXUP_IDENTIFIER);
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
CP_HDR_INDIRECT_BUFFER_PFD);
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
adreno_dev->pwron_fixup.gpuaddr);
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
adreno_dev->pwron_fixup_dwords);
}
/* start-of-pipeline timestamp */
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_MEM_WRITE, 2));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, (gpuaddr +
KGSL_MEMSTORE_OFFSET(context_id, soptimestamp)));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, timestamp);
if (flags & KGSL_CMD_FLAGS_PMODE) {
/* disable protected mode error checking */
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_SET_PROTECTED_MODE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 0);
}
for (i = 0; i < sizedwords; i++) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, *cmds);
cmds++;
}
if (flags & KGSL_CMD_FLAGS_PMODE) {
/* re-enable protected mode error checking */
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_SET_PROTECTED_MODE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 1);
}
/* HW Workaround for MMU Page fault
* due to memory getting free early before
* GPU completes it.
*/
if (adreno_is_a2xx(adreno_dev)) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_WAIT_FOR_IDLE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 0x00);
}
if (adreno_is_a3xx(adreno_dev) || adreno_is_a4xx(adreno_dev)) {
/*
* Flush HLSQ lazy updates to make sure there are no
* resources pending for indirect loads after the timestamp
*/
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_EVENT_WRITE, 1));
GSL_RB_WRITE(rb->device, ringcmds,
rcmd_gpu, 0x07); /* HLSQ_FLUSH */
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_WAIT_FOR_IDLE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 0x00);
}
/*
* end-of-pipeline timestamp. If per context timestamps is not
* enabled, then context_id will be KGSL_MEMSTORE_GLOBAL so all
* eop timestamps will work out.
*/
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_EVENT_WRITE, 3));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, CACHE_FLUSH_TS);
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, (gpuaddr +
KGSL_MEMSTORE_OFFSET(context_id, eoptimestamp)));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, timestamp);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (drawctxt) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_MEM_WRITE, 2));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, (gpuaddr +
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
eoptimestamp)));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, rb->global_ts);
}
if (adreno_is_a20x(adreno_dev)) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_EVENT_WRITE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, CACHE_FLUSH);
}
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (drawctxt || (flags & KGSL_CMD_FLAGS_INTERNAL_ISSUE)) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_INTERRUPT, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
CP_INT_CNTL__RB_INT_MASK);
}
if (adreno_is_a3xx(adreno_dev)) {
/* Dummy set-constant to trigger context rollover */
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
cp_type3_packet(CP_SET_CONSTANT, 2));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
(0x4<<16)|(A3XX_HLSQ_CL_KERNEL_GROUP_X_REG - 0x2000));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 0);
}
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (flags & KGSL_CMD_FLAGS_WFI) {
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
cp_type3_packet(CP_WAIT_FOR_IDLE, 1));
GSL_RB_WRITE(rb->device, ringcmds, rcmd_gpu, 0x00000000);
}
adreno_ringbuffer_submit(rb);
return 0;
}
unsigned int
adreno_ringbuffer_issuecmds(struct kgsl_device *device,
struct adreno_context *drawctxt,
unsigned int flags,
unsigned int *cmds,
int sizedwords)
{
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer;
flags |= KGSL_CMD_FLAGS_INTERNAL_ISSUE;
return adreno_ringbuffer_addcmds(rb, drawctxt, flags, cmds,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
sizedwords, 0);
}
static bool _parse_ibs(struct kgsl_device_private *dev_priv, uint gpuaddr,
int sizedwords);
static bool
_handle_type3(struct kgsl_device_private *dev_priv, uint *hostaddr)
{
unsigned int opcode = cp_type3_opcode(*hostaddr);
switch (opcode) {
case CP_INDIRECT_BUFFER_PFD:
case CP_INDIRECT_BUFFER_PFE:
case CP_COND_INDIRECT_BUFFER_PFE:
case CP_COND_INDIRECT_BUFFER_PFD:
return _parse_ibs(dev_priv, hostaddr[1], hostaddr[2]);
case CP_NOP:
case CP_WAIT_FOR_IDLE:
case CP_WAIT_REG_MEM:
case CP_WAIT_REG_EQ:
case CP_WAT_REG_GTE:
case CP_WAIT_UNTIL_READ:
case CP_WAIT_IB_PFD_COMPLETE:
case CP_REG_RMW:
case CP_REG_TO_MEM:
case CP_MEM_WRITE:
case CP_MEM_WRITE_CNTR:
case CP_COND_EXEC:
case CP_COND_WRITE:
case CP_EVENT_WRITE:
case CP_EVENT_WRITE_SHD:
case CP_EVENT_WRITE_CFL:
case CP_EVENT_WRITE_ZPD:
case CP_DRAW_INDX:
case CP_DRAW_INDX_2:
case CP_DRAW_INDX_BIN:
case CP_DRAW_INDX_2_BIN:
case CP_VIZ_QUERY:
case CP_SET_STATE:
case CP_SET_CONSTANT:
case CP_IM_LOAD:
case CP_IM_LOAD_IMMEDIATE:
case CP_LOAD_CONSTANT_CONTEXT:
case CP_INVALIDATE_STATE:
case CP_SET_SHADER_BASES:
case CP_SET_BIN_MASK:
case CP_SET_BIN_SELECT:
case CP_SET_BIN_BASE_OFFSET:
case CP_SET_BIN_DATA:
case CP_CONTEXT_UPDATE:
case CP_INTERRUPT:
case CP_IM_STORE:
case CP_LOAD_STATE:
break;
/* these shouldn't come from userspace */
case CP_ME_INIT:
case CP_SET_PROTECTED_MODE:
default:
KGSL_CMD_ERR(dev_priv->device, "bad CP opcode %0x\n", opcode);
return false;
break;
}
return true;
}
static bool
_handle_type0(struct kgsl_device_private *dev_priv, uint *hostaddr)
{
unsigned int reg = type0_pkt_offset(*hostaddr);
unsigned int cnt = type0_pkt_size(*hostaddr);
if (reg < 0x0192 || (reg + cnt) >= 0x8000) {
KGSL_CMD_ERR(dev_priv->device, "bad type0 reg: 0x%0x cnt: %d\n",
reg, cnt);
return false;
}
return true;
}
/*
* Traverse IBs and dump them to test vector. Detect swap by inspecting
* register writes, keeping note of the current state, and dump
* framebuffer config to test vector
*/
static bool _parse_ibs(struct kgsl_device_private *dev_priv,
uint gpuaddr, int sizedwords)
{
static uint level; /* recursion level */
bool ret = false;
uint *hostaddr, *hoststart;
int dwords_left = sizedwords; /* dwords left in the current command
buffer */
struct kgsl_mem_entry *entry;
entry = kgsl_sharedmem_find_region(dev_priv->process_priv,
gpuaddr, sizedwords * sizeof(uint));
if (entry == NULL) {
KGSL_CMD_ERR(dev_priv->device,
"no mapping for gpuaddr: 0x%08x\n", gpuaddr);
return false;
}
hostaddr = (uint *)kgsl_gpuaddr_to_vaddr(&entry->memdesc, gpuaddr);
if (hostaddr == NULL) {
KGSL_CMD_ERR(dev_priv->device,
"no mapping for gpuaddr: 0x%08x\n", gpuaddr);
return false;
}
hoststart = hostaddr;
level++;
KGSL_CMD_INFO(dev_priv->device, "ib: gpuaddr:0x%08x, wc:%d, hptr:%p\n",
gpuaddr, sizedwords, hostaddr);
mb();
while (dwords_left > 0) {
bool cur_ret = true;
int count = 0; /* dword count including packet header */
switch (*hostaddr >> 30) {
case 0x0: /* type-0 */
count = (*hostaddr >> 16)+2;
cur_ret = _handle_type0(dev_priv, hostaddr);
break;
case 0x1: /* type-1 */
count = 2;
break;
case 0x3: /* type-3 */
count = ((*hostaddr >> 16) & 0x3fff) + 2;
cur_ret = _handle_type3(dev_priv, hostaddr);
break;
default:
KGSL_CMD_ERR(dev_priv->device, "unexpected type: "
"type:%d, word:0x%08x @ 0x%p, gpu:0x%08x\n",
*hostaddr >> 30, *hostaddr, hostaddr,
gpuaddr+4*(sizedwords-dwords_left));
cur_ret = false;
count = dwords_left;
break;
}
if (!cur_ret) {
KGSL_CMD_ERR(dev_priv->device,
"bad sub-type: #:%d/%d, v:0x%08x"
" @ 0x%p[gb:0x%08x], level:%d\n",
sizedwords-dwords_left, sizedwords, *hostaddr,
hostaddr, gpuaddr+4*(sizedwords-dwords_left),
level);
if (ADRENO_DEVICE(dev_priv->device)->ib_check_level
>= 2)
print_hex_dump(KERN_ERR,
level == 1 ? "IB1:" : "IB2:",
DUMP_PREFIX_OFFSET, 32, 4, hoststart,
sizedwords*4, 0);
goto done;
}
/* jump to next packet */
dwords_left -= count;
hostaddr += count;
if (dwords_left < 0) {
KGSL_CMD_ERR(dev_priv->device,
"bad count: c:%d, #:%d/%d, "
"v:0x%08x @ 0x%p[gb:0x%08x], level:%d\n",
count, sizedwords-(dwords_left+count),
sizedwords, *(hostaddr-count), hostaddr-count,
gpuaddr+4*(sizedwords-(dwords_left+count)),
level);
if (ADRENO_DEVICE(dev_priv->device)->ib_check_level
>= 2)
print_hex_dump(KERN_ERR,
level == 1 ? "IB1:" : "IB2:",
DUMP_PREFIX_OFFSET, 32, 4, hoststart,
sizedwords*4, 0);
goto done;
}
}
ret = true;
done:
if (!ret)
KGSL_DRV_ERR(dev_priv->device,
"parsing failed: gpuaddr:0x%08x, "
"host:0x%p, wc:%d\n", gpuaddr, hoststart, sizedwords);
level--;
return ret;
}
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/**
* _ringbuffer_verify_ib() - parse an IB and verify that it is correct
* @dev_priv: Pointer to the process struct
* @ibdesc: Pointer to the IB descriptor
*
* This function only gets called if debugging is enabled - it walks the IB and
* does additional level parsing and verification above and beyond what KGSL
* core does
*/
static inline bool _ringbuffer_verify_ib(struct kgsl_device_private *dev_priv,
struct kgsl_ibdesc *ibdesc)
{
struct kgsl_device *device = dev_priv->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
/* Check that the size of the IBs is under the allowable limit */
if (ibdesc->sizedwords == 0 || ibdesc->sizedwords > 0xFFFFF) {
KGSL_DRV_ERR(device, "Invalid IB size 0x%X\n",
ibdesc->sizedwords);
return false;
}
if (unlikely(adreno_dev->ib_check_level >= 1) &&
!_parse_ibs(dev_priv, ibdesc->gpuaddr, ibdesc->sizedwords)) {
KGSL_DRV_ERR(device, "Could not verify the IBs\n");
return false;
}
return true;
}
int
adreno_ringbuffer_issueibcmds(struct kgsl_device_private *dev_priv,
struct kgsl_context *context,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
struct kgsl_cmdbatch *cmdbatch,
uint32_t *timestamp)
{
struct kgsl_device *device = dev_priv->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
int i, ret;
if (drawctxt->state == ADRENO_CONTEXT_STATE_INVALID)
return -EDEADLK;
/* Verify the IBs before they get queued */
for (i = 0; i < cmdbatch->ibcount; i++) {
if (!_ringbuffer_verify_ib(dev_priv, &cmdbatch->ibdesc[i]))
return -EINVAL;
}
/* For now everybody has the same priority */
cmdbatch->priority = ADRENO_CONTEXT_DEFAULT_PRIORITY;
/* wait for the suspend gate */
wait_for_completion(&device->cmdbatch_gate);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/* Queue the command in the ringbuffer */
ret = adreno_dispatcher_queue_cmd(adreno_dev, drawctxt, cmdbatch,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
timestamp);
if (ret)
KGSL_DRV_ERR(device, "adreno_dispatcher_queue_cmd returned %d\n",
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ret);
else {
/*
* only call trace_gpu_job_enqueue for actual commands - dummy
* sync command batches won't get scheduled on the GPU
*/
if (!(cmdbatch->flags & KGSL_CONTEXT_SYNC)) {
const char *str = "3D";
if (drawctxt->type == KGSL_CONTEXT_TYPE_CL ||
drawctxt->type == KGSL_CONTEXT_TYPE_RS)
str = "compute";
kgsl_trace_gpu_job_enqueue(drawctxt->base.id,
cmdbatch->timestamp, str);
}
}
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
return ret;
}
/* adreno_rindbuffer_submitcmd - submit userspace IBs to the GPU */
int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev,
struct kgsl_cmdbatch *cmdbatch)
{
struct kgsl_device *device = &adreno_dev->dev;
struct kgsl_ibdesc *ibdesc;
unsigned int numibs;
unsigned int *link;
unsigned int *cmds;
unsigned int i;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
struct kgsl_context *context;
struct adreno_context *drawctxt;
unsigned int start_index = 0;
int flags = KGSL_CMD_FLAGS_NONE;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
int ret;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
context = cmdbatch->context;
drawctxt = ADRENO_CONTEXT(context);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ibdesc = cmdbatch->ibdesc;
numibs = cmdbatch->ibcount;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/*When preamble is enabled, the preamble buffer with state restoration
commands are stored in the first node of the IB chain. We can skip that
if a context switch hasn't occured */
if ((drawctxt->flags & CTXT_FLAGS_PREAMBLE) &&
!test_bit(CMDBATCH_FLAG_FORCE_PREAMBLE, &cmdbatch->priv) &&
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
(adreno_dev->drawctxt_active == drawctxt))
start_index = 1;
/*
* In skip mode don't issue the draw IBs but keep all the other
* accoutrements of a submision (including the interrupt) to keep
* the accounting sane. Set start_index and numibs to 0 to just
* generate the start and end markers and skip everything else
*/
if (test_bit(CMDBATCH_FLAG_SKIP, &cmdbatch->priv)) {
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
start_index = 0;
numibs = 0;
}
cmds = link = kzalloc(sizeof(unsigned int) * (numibs * 3 + 4),
GFP_KERNEL);
if (!link) {
ret = -ENOMEM;
goto done;
}
if (!start_index) {
*cmds++ = cp_nop_packet(1);
*cmds++ = KGSL_START_OF_IB_IDENTIFIER;
} else {
*cmds++ = cp_nop_packet(4);
*cmds++ = KGSL_START_OF_IB_IDENTIFIER;
*cmds++ = CP_HDR_INDIRECT_BUFFER_PFD;
*cmds++ = ibdesc[0].gpuaddr;
*cmds++ = ibdesc[0].sizedwords;
}
for (i = start_index; i < numibs; i++) {
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/*
* Skip 0 sized IBs - these are presumed to have been removed
* from consideration by the FT policy
*/
if (ibdesc[i].sizedwords == 0)
*cmds++ = cp_nop_packet(2);
else
*cmds++ = CP_HDR_INDIRECT_BUFFER_PFD;
*cmds++ = ibdesc[i].gpuaddr;
*cmds++ = ibdesc[i].sizedwords;
}
*cmds++ = cp_nop_packet(1);
*cmds++ = KGSL_END_OF_IB_IDENTIFIER;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ret = kgsl_setstate(&device->mmu, context->id,
kgsl_mmu_pt_get_flags(device->mmu.hwpagetable,
device->id));
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
if (ret)
goto done;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ret = adreno_drawctxt_switch(adreno_dev, drawctxt, cmdbatch->flags);
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
/*
* In the unlikely event of an error in the drawctxt switch,
* treat it like a hang
*/
if (ret)
goto done;
if (test_bit(CMDBATCH_FLAG_WFI, &cmdbatch->priv))
flags = KGSL_CMD_FLAGS_WFI;
/*
* For some targets, we need to execute a dummy shader operation after a
* power collapse
*/
if (test_and_clear_bit(ADRENO_DEVICE_PWRON, &adreno_dev->priv) &&
test_bit(ADRENO_DEVICE_PWRON_FIXUP, &adreno_dev->priv))
flags |= KGSL_CMD_FLAGS_PWRON_FIXUP;
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
ret = adreno_ringbuffer_addcmds(&adreno_dev->ringbuffer,
drawctxt,
flags,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
&link[0], (cmds - link),
cmdbatch->timestamp);
#ifdef CONFIG_MSM_KGSL_CFF_DUMP
if (ret)
goto done;
/*
* insert wait for idle after every IB1
* this is conservative but works reliably and is ok
* even for performance simulations
*/
ret = adreno_idle(device);
#endif
done:
device->pwrctrl.irq_last = 0;
kgsl_trace_issueibcmds(device, context->id, cmdbatch,
msm: kgsl: implement server-side waits msm: kgsl: Add device init function Some device specific parameters need to be setup only once during device initialization. Create an init function for this purpose rather than re-doing this init everytime the device is started. Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 2nd commit message: msm: kgsl: improve active_cnt and ACTIVE state management Require any code path which intends to touch the hardware to take a reference on active_cnt with kgsl_active_count_get() and release it with kgsl_active_count_put() when finished. These functions now do the wake / sleep steps that were previously handled by kgsl_check_suspended() and kgsl_check_idle(). Additionally, kgsl_pre_hwaccess() will no longer turn on the clocks, it just enforces via BUG_ON that the clocks are enabled before a register is touched. Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 3rd commit message: msm: kgsl: Sync memory with CFF from places where it was missing Before submitting any indirect buffer to GPU via the ringbuffer, the indirect buffer memory should be synced with CFF so that the CFF capture will be complete. Add the syncing of memory with CFF in places where this was missing Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 4th commit message: msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS Export some functions in the KGSL core driver so they can be seen by the leaf drivers. Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 5th commit message: msm: kgsl: Send the right IB size to adreno_find_ctxtmem adreno_find_ctxtmem expects byte lengths and we were sending it dword lengths which was about as effective as you would expect. Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 6th commit message: msm: kgsl: Add 8974 default GPR0 & clk gating values Add correct clock gating values for A330, A305 and A320. Add generic function to return the correct default clock gating values for the respective gpu. Add default GPR0 value for A330. Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 7th commit message: msm: kgsl: Move A3XX VBIF settings decision to a table The vbif selection code is turning into a long series of if/else clauses. Move the decision to a look up table that will be easier to update and maintain when when we have eleventy A3XX GPUs. Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 8th commit message: msm: kgsl: Update settings for the A330v2 GPU in 8972v2 The new GPU spin in 8974v2 has some slightly different settings then the 8974v1: add support for identifying a v2 spin, add a new table of VBIF register settings and update the clock gating registers. Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 9th commit message: msm: kgsl: Fix compilation errors when CFF is turned on Fix the compilation errors when option MSM_KGSL_CFF_DUMP option is turned on. Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 10th commit message: msm: kgsl: Convert the Adreno GPU cycle counters to run free In anticipation of allowing multiple entities to share access to the performance counters; make the few performance counters that KGSL uses run free. Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 11th commit message: msm: kgsl: Handle a possible ringbuffer allocspace error In the GPU specific start functions, account for the possibility that ringbuffer allocation routine might return NULL. Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 12th commit message: msm: kgsl: Add a new API to allow sharing of GPU performance counters Adreno uses programmable performance counters, meaning that while there are a limited number of physical counters each counter can be programmed to count a vast number of different measurements (we refer to these as countables). This could cause problems if multiple apps want to use the performance counters, so this API and infrastructure allows the counters to be safely shared. The kernel tracks which countable is selected for each of the physical counters for each counter group (where groups closely match hardware blocks). If the desired countable is already in use, or there is an open physical counter, then the process is allowed to use the counter. The get ioctl reserves the counter and returns the dword offset of the register associated with that physical counter. The put ioctl releases the physical counter. The query ioctl gets the countables used for all of the counters in the block - up to 8 values can be returned. The read ioctl gets the current hardware value in the counter Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Carter Cooper <ccooper@codeaurora.org> # This is the 13th commit message: msm: kgsl: Print the nearest active GPU buffers to a faulting address Print the two active GPU memory entries that bracket a faulting GPU address. This will help diagnose premature frees and buffer ovverruns. Check if the faulting GPU address was freed by the same process. Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org> # This is the 14th commit message: msm: kgsl: Remove an uneeded register write for A3XX GPUs A3XX doesn't have the MH block and so the register at 0x40 points somewhere else. Luckily the write was harmless but remove it anyway. Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 15th commit message: msm: kgsl: clean up iommu/gpummu protflag handling Make kgsl_memdesc_protflags() return the correct type of flags for the type of mmu being used. Query the memdesc with this function in kgsl_mmu_map(), rather than passing in the protflags. This prevents translation at multiple layers of the code and makes it easier to enforce that the mapping matches the allocation flags. Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 16th commit message: msm: kgsl: remove kgsl_mem_entry.flags The two flags fields in kgsl_memdesc should be enough for anyone. Move the only flag using kgsl_mem_entry, the FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv. Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 17th commit message: msm: kgsl: map the guard page readonly on the iommu The guard page needs to be readable by the GPU, due to a prefetch range issue, but it should never be writable. Change the page fault message to indicate if nearby buffers have a guard page. Change-Id: I3955de1409cbf4ccdde92def894945267efa044d Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 18th commit message: msm: kgsl: Add support for VBIF and VBIF_PWR performance counters These 2 counter groups are also "special cases" that require different programming sequences. Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 19th commit message: msm: kgsl: Only allow two counters for VBIF performance counters There are only two VBIF counter groups so validate that the user doesn't pass in > 1 and clean up the if/else clause. Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 20th commit message: msm: kgsl: Avoid an array overrun in the perfcounter API Make sure the passed group is less than the size of the list of performance counters. Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 21st commit message: msm: kgsl: Don't go to slumber if active_count is non zero If active_cnt happens to be set when we go into kgsl_early_suspend_driver() then don't go to SLUMBER. This avoids trouble if we come back and and try to access the hardware while it is off. Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 22nd commit message: msm: kgsl: Enable HLSQ registers in snapshot when available Reading the HLSQ registers during a GPU hang recovery might cause the device to hang depending on the state of the HLSQ block. Enable the HLSQ register reads when we know that they will succeed. Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad Signed-off-by: Carter Cooper <ccooper@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 23rd commit message: msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure Stop parsing an indirect buffer if an error is encountered (such as a missing buffer). This is a pretty good indication that the buffers are not reliable and the further the parser goes with a unreliable buffer the more likely it is to get confused. Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 24th commit message: msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space Some IB1 buffers have hundreds of little IB2 buffers and only one of them will actually be interesting enough to push into the static space. Only push the last executed IB1 and IB2 into the static space. Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 25th commit message: msm: kgsl: Save the last active context in snapshot Save the last active context that was executing when the hang happened in snapshot. Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 26th commit message: msm: kgsl: In snapshot track a larger object size if address is same If the object being tracked has the same address as a previously tracked object then only track a single object with larger size as the smaller object will be a part of the larger one anyway. Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 27th commit message: msm: kgsl: Track memory address from 2 additional registers Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG registers in snapshot. This makes snapshot more complete in terms of tracking data that is used by the GPU at the time of hang. Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 28th commit message: msm: kgsl: Loop till correct index on type0 packets When searching for memory addresses in type0 packet we were looping from start of the type0 packet till it's end, but the first DWORD is a header so we only need to loop till packet_size - 1. Fix this. Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 29th commit message: msm: kgsl: Add global timestamp information to snapshot Make sure that we always add global timestamp information to snapshot. This is needed in playbacks for searching whereabouts of last executed IB. Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 30th commit message: msm: kgsl: Skip cff dump for certain functions when its disabled Certain functions were generating CFF when CFF was disabled. Make sure these functions do not dump CFF when it is disabled. Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 31st commit message: msm: kgsl: Fix searching of memory object Make sure that at least a size of 1 byte is searched when locating the memory entry of a region. If size is 0 then a memory region whose last address is equal to the start address of the memory being searched will be returned which is wrong. Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 32nd commit message: msm: kgsl: If adreno start fails then restore state of device Restore the state of the device back to what it was at the start of the adreno_start function if this function fails to execute successfully. Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 33rd commit message: msm: kgsl: Fix early exit condition in ringbuffer drain The ringbuffer drain function can be called when the ringbuffer start flag is not set. This happens on startup. Hence, exiting the function early based on start flag is incorrect. Simply execute this function regardless of the start flag. Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49 Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 34th commit message: msm: kgsl: Do not return an error on NULL gpu address If a NULL gpu address is passed to snapshot object tracking function then do not treat this as an error and return 0. NULL objects may be present in an IB so just skip over these objects instead of exiting due to an error. Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 35th commit message: msm: kgsl: Don't hold process list global mutex in process private create Don't hold process list global mutex for long. Instead make use of process specific spin_lock() to serialize access to process private structure while creating it. Holding process list global mutex could lead to deadlocks as other functions depend on it. CRs-fixed: 480732 Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680 Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org> Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 36th commit message: msm: kgsl: Use CPU path to program pagetable when active count is 0 When active count is 0 then we should use the CPU path to program pagetables because the GPU path requires event registration. Events can only be queued when active count is valid. Hence, if the active count is NULL then use the CPU path. Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82 CRs-fixed: 481887 Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 37th commit message: iommu: msm: prevent partial mappings on error If msm_iommu_map_range() fails mid way through the va range with an error, clean up the PTEs that have already been created so they are not leaked. Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 38th commit message: msm: kgsl: better handling of virtual address fragmentation When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address must try to match the GPU alignment requirements of the buffer, as well as include space in the mapping for the guard page. This can cause -ENOMEM to be returned from get_unmapped_area() when there are a large number of mappings. When this happens, fall back to page alignment and retry to avoid failure. Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 39th commit message: iommu: msm: Don't treat address 0 as an error case Currently, the iommu page table code treats a scattergather list with physical address 0 as an error. This may not be correct in all cases. Physical address 0 is a valid part of the system and may be used for valid page allocations. Nothing else in the system checks for physical address 0 for error so don't treat it as an error. Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0 CRs-Fixed: 478304 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 40th commit message: msm: kgsl: prevent race between mmap() and free on timestamp When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the address from get_unmapped_area() is not used as part of a mapping that is present only in the GPU pagetable and not the CPU pagetable. These mappings can occur because when a buffer is freed on timestamp, the CPU mapping is destroyed immediately but the GPU mapping is not destroyed until the GPU timestamp has passed. Because kgsl_mem_entry_detach_process() removed the rbtree entry before removing the iommu mapping, there was a window of time where kgsl thought the address was available even though it was still present in the iommu pagetable. This could cause the address to get assigned to a new buffer, which would cause iommu_map_range() to fail since the old mapping was still in the pagetable. Prevent this race by removing the iommu mapping before removing the rbtree entry tracking the address. Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a CRs-Fixed: 480222 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 41st commit message: msm: kgsl: add guard page support for imported memory Imported memory buffers sometimes do not have enough padding to prevent page faults due to overzealous GPU prefetch. Attach guard pages to their mappings to prevent these faults. Because we don't create the scatterlist for some types of imported memory, such as ion, the guard page is no longer included as the last entry in the scatterlist. Instead, it is handled by size ajustments and a separate iommu_map() call in the kgsl_mmu_map() and kgsl_mmu_unmap() paths. Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 42nd commit message: msm: kgsl: fix kgsl_mem_entry refcounting Make kgsl_sharedmem_find* return a reference to the entry that was found. This makes using an entry without the mem_lock held less race prone. Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 43rd commit message: msm: kgsl: add ftrace for cache operations Add the event kgsl_mem_sync_cache. This event is emitted when only a cache operation is actually performed. Attempts to flush uncached memory, which do nothing, do not cause this event. Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 44th commit message: msm: kgsl: Add support for bulk cache operations Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used to sync a number of memory ids at once. This gives the driver an opportunity to optimize the cache operations based on the total working set of memory that needs to be managed. Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 45th commit message: msm: kgsl: flush the entire cache when the bulk batch is large On 8064 and 8974, flushing more than 16mb of virtual address space is slower than flushing the entire cache. So flush the entire cache when the working set is larger than this. The threshold for full cache flush can be tuned at runtime via the full_cache_threshold sysfs file. Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 46th commit message: msm: kgsl: Use a read/lock for the context idr Everybody loves a rcu but in this case we are dangerously mixing rcus and atomic operations. Add a read/write lock to explicitly protect the idr. Also fix a few spots where the idr was used without protection. Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 47th commit message: msm: kgsl: embed kgsl_context struct in adreno_context struct Having a separate allocated struct for the device specific context makes ownership unclear, which could lead to reference counting problems or invalid pointers. Also, duplicate members were starting to appear in adreno_context because there wasn't a safe way to reach the kgsl_context from some parts of the adreno code. This can now be done via container_of(). This change alters the lifecycle of the context->id, which is now freed when the context reference count hits zero rather than in kgsl_context_detach(). It also changes the context creation and destruction sequence. The device specific code must allocate a structure containing a struct kgsl_context and passes a pointer it to kgsl_init_context() before doing any device specific initialization. There is also a separate drawctxt_detach() callback for doing device specific cleanup. This is separate from freeing memory, which is done by the drawctxt_destroy() callback. Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 48th commit message: msm: kgsl: Take a reference count on the active adreno draw context Take a reference count on the currently active draw context to keep it from going away while we are maintaining a pointer to it in the adreno device. Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 49th commit message: msm: kgsl: Add a command dispatcher to manage the ringbuffer Implements a centralized dispatcher for sending user commands to the ringbuffer. Incoming commands are queued by context and sent to the hardware on a round robin basis ensuring each context a small burst of commands at a time. Each command is tracked throughout the pipeline giving the dispatcher better knowledge of how the hardware is being used. This will be the basis for future per-context and cross context enhancements as priority queuing and server-side syncronization. Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 50th commit message: msm: kgsl: Only turn on the idle timer when active_cnt is 0 Only turn on the idle timer when the GPU expected to be quiet. Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 51st commit message: msm: kgsl: Add a ftrace event for active_cnt Add a new ftrace event for watching the rise and fall of active_cnt: echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable This will give you the current active count and the caller of the function: kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 52nd commit message: msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher Implement the KGSL fault tolerance policy for faults in the dispatcher. Replay (or skip) the inflight command batches as dictated by the policy, iterating progressively through the various behaviors. Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 53rd commit message: msm: kgsl: Don't process events if the timestamp hasn't changed Keep track of the global timestamp every time the event code runs. If the timestamp hasn't changed then we are caught up and we can politely bow out. This avoids the situation where multiple interrupts queue the work queue multiple times: IRQ -> process events IRQ IRQ -> process events The actual retired timestamp in the first work item might be well ahead of the delivered interrupts. The event loop will end up processing every event that has been retired by the hardware at that point. If the work item gets re-queued by a subesquent interrupt then we might have already addressed all the pending timestamps. Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 54th commit message: msm: kgsl: Make active_cnt an atomic variable In kgsl_active_cnt_light() the mutex was needed just to check and increment the active_cnt value. Move active_cnt to an atomic to begin the task of freeing ourselves from the grip of the device mutex if we can avoid it. Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 55th commit message: msm: kgsl: Add a new command submission API Add an new ioctl entry point for submitting commands to the GPU called IOCTL_KGSL_SUBMIT_COMMANDS. As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of indirect buffers, flags and optionally a user specified timestamp. The old way of passing a list of indirect buffers is no longer supported. IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a list of sync points for the command. Sync points are dependencies on events that need to be satisfied before the command will be issued to the hardware. Events are designed to be flexible. To start with the only events that are supported are GPU events for a given context/ timestamp pair. Pending events are stored in a list in the command batch. As each event is expired it is deleted from the list. The adreno dispatcher won't send the command until the list is empty. Sync points are not supported for Z180. CRs-Fixed: 468770 Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 56th commit message: msm: kgsl: add kgsl_sync_fence_waiter for server side sync For server side sync the KGSL kernel module needs to perform an asynchronous wait for a fence object prior to issuing subsequent commands. Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 57th commit message: msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE Allow command batches to wait for external fence sync events. Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05 Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 58th commit message: msm: kgsl: fix potential double free of the kwaiter Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4 Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> # This is the 59th commit message: msm: kgsl: free an event only after canceling successfully Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b Signed-off-by: Jeff Boody <jboody@codeaurora.org> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-24 17:40:20 +00:00
cmdbatch->timestamp, cmdbatch->flags, ret,
drawctxt ? drawctxt->type : 0);
kfree(link);
return ret;
}