android_kernel_google_msm/include/linux/msm_kgsl.h

925 lines
28 KiB
C
Raw Permalink Normal View History

#ifndef _MSM_KGSL_H
#define _MSM_KGSL_H
/*
* The KGSL version has proven not to be very useful in userspace if features
* are cherry picked into other trees out of order so it is frozen as of 3.14.
* It is left here for backwards compatabilty and as a reminder that
* software releases are never linear. Also, I like pie.
*/
#define KGSL_VERSION_MAJOR 3
#define KGSL_VERSION_MINOR 14
/*context 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
#define KGSL_CONTEXT_SAVE_GMEM 0x00000001
#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002
#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004
#define KGSL_CONTEXT_CTX_SWITCH 0x00000008
#define KGSL_CONTEXT_PREAMBLE 0x00000010
#define KGSL_CONTEXT_TRASH_STATE 0x00000020
#define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040
#define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080
#define KGSL_CONTEXT_END_OF_FRAME 0x00000100
#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
#define KGSL_CONTEXT_SYNC 0x00000400
#define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800
/* bits [12:15] are reserved for future use */
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
#define KGSL_CONTEXT_TYPE_MASK 0x01F00000
#define KGSL_CONTEXT_TYPE_SHIFT 20
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
#define KGSL_CONTEXT_TYPE_ANY 0
#define KGSL_CONTEXT_TYPE_GL 1
#define KGSL_CONTEXT_TYPE_CL 2
#define KGSL_CONTEXT_TYPE_C2D 3
#define KGSL_CONTEXT_TYPE_RS 4
#define KGSL_CONTEXT_INVALID 0xffffffff
/* --- Memory allocation flags --- */
/* General allocation hints */
#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000
#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000
/* Memory caching hints */
#define KGSL_CACHEMODE_MASK 0x0C000000
#define KGSL_CACHEMODE_SHIFT 26
#define KGSL_CACHEMODE_WRITECOMBINE 0
#define KGSL_CACHEMODE_UNCACHED 1
#define KGSL_CACHEMODE_WRITETHROUGH 2
#define KGSL_CACHEMODE_WRITEBACK 3
/* Memory types for which allocations are made */
#define KGSL_MEMTYPE_MASK 0x0000FF00
#define KGSL_MEMTYPE_SHIFT 8
#define KGSL_MEMTYPE_OBJECTANY 0
#define KGSL_MEMTYPE_FRAMEBUFFER 1
#define KGSL_MEMTYPE_RENDERBUFFER 2
#define KGSL_MEMTYPE_ARRAYBUFFER 3
#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4
#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5
#define KGSL_MEMTYPE_TEXTURE 6
#define KGSL_MEMTYPE_SURFACE 7
#define KGSL_MEMTYPE_EGL_SURFACE 8
#define KGSL_MEMTYPE_GL 9
#define KGSL_MEMTYPE_CL 10
#define KGSL_MEMTYPE_CL_BUFFER_MAP 11
#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12
#define KGSL_MEMTYPE_CL_IMAGE_MAP 13
#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14
#define KGSL_MEMTYPE_CL_KERNEL_STACK 15
#define KGSL_MEMTYPE_COMMAND 16
#define KGSL_MEMTYPE_2D 17
#define KGSL_MEMTYPE_EGL_IMAGE 18
#define KGSL_MEMTYPE_EGL_SHADOW 19
#define KGSL_MEMTYPE_MULTISAMPLE 20
#define KGSL_MEMTYPE_KERNEL 255
/*
* Alignment hint, passed as the power of 2 exponent.
* i.e 4k (2^12) would be 12, 64k (2^16)would be 16.
*/
#define KGSL_MEMALIGN_MASK 0x00FF0000
#define KGSL_MEMALIGN_SHIFT 16
/* --- generic KGSL flag values --- */
#define KGSL_FLAGS_NORMALMODE 0x00000000
#define KGSL_FLAGS_SAFEMODE 0x00000001
#define KGSL_FLAGS_INITIALIZED0 0x00000002
#define KGSL_FLAGS_INITIALIZED 0x00000004
#define KGSL_FLAGS_STARTED 0x00000008
#define KGSL_FLAGS_ACTIVE 0x00000010
#define KGSL_FLAGS_RESERVED0 0x00000020
#define KGSL_FLAGS_RESERVED1 0x00000040
#define KGSL_FLAGS_RESERVED2 0x00000080
#define KGSL_FLAGS_SOFT_RESET 0x00000100
#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200
/* Clock flags to show which clocks should be controled by a given platform */
#define KGSL_CLK_SRC 0x00000001
#define KGSL_CLK_CORE 0x00000002
#define KGSL_CLK_IFACE 0x00000004
#define KGSL_CLK_MEM 0x00000008
#define KGSL_CLK_MEM_IFACE 0x00000010
#define KGSL_CLK_AXI 0x00000020
/* Server Side Sync Timeout in milliseconds */
#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000
/*
* Reset status values for context
*/
enum kgsl_ctx_reset_stat {
KGSL_CTX_STAT_NO_ERROR = 0x00000000,
KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001,
KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002,
KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003
};
#define KGSL_CONVERT_TO_MBPS(val) \
(val*1000*1000U)
/* device id */
enum kgsl_deviceid {
KGSL_DEVICE_3D0 = 0x00000000,
KGSL_DEVICE_2D0 = 0x00000001,
KGSL_DEVICE_2D1 = 0x00000002,
KGSL_DEVICE_MAX = 0x00000003
};
enum kgsl_user_mem_type {
KGSL_USER_MEM_TYPE_PMEM = 0x00000000,
KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,
KGSL_USER_MEM_TYPE_ADDR = 0x00000002,
KGSL_USER_MEM_TYPE_ION = 0x00000003,
KGSL_USER_MEM_TYPE_MAX = 0x00000004,
};
struct kgsl_devinfo {
unsigned int device_id;
/* chip revision id
* coreid:8 majorrev:8 minorrev:8 patch:8
*/
unsigned int chip_id;
unsigned int mmu_enabled;
unsigned int gmem_gpubaseaddr;
/*
* This field contains the adreno revision
* number 200, 205, 220, etc...
*/
unsigned int gpu_id;
unsigned int gmem_sizebytes;
};
/* this structure defines the region of memory that can be mmap()ed from this
driver. The timestamp fields are volatile because they are written by the
GPU
*/
struct kgsl_devmemstore {
volatile unsigned int soptimestamp;
unsigned int sbz;
volatile unsigned int eoptimestamp;
unsigned int sbz2;
volatile unsigned int ts_cmp_enable;
unsigned int sbz3;
volatile unsigned int ref_wait_ts;
unsigned int sbz4;
unsigned int current_context;
unsigned int sbz5;
};
#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \
((ctxt_id)*sizeof(struct kgsl_devmemstore) + \
offsetof(struct kgsl_devmemstore, field))
/* timestamp id*/
enum kgsl_timestamp_type {
KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */
KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/
KGSL_TIMESTAMP_QUEUED = 0x00000003,
};
/* property types - used with kgsl_device_getproperty */
enum kgsl_property_type {
KGSL_PROP_DEVICE_INFO = 0x00000001,
KGSL_PROP_DEVICE_SHADOW = 0x00000002,
KGSL_PROP_DEVICE_POWER = 0x00000003,
KGSL_PROP_SHMEM = 0x00000004,
KGSL_PROP_SHMEM_APERTURES = 0x00000005,
KGSL_PROP_MMU_ENABLE = 0x00000006,
KGSL_PROP_INTERRUPT_WAITS = 0x00000007,
KGSL_PROP_VERSION = 0x00000008,
KGSL_PROP_GPU_RESET_STAT = 0x00000009,
KGSL_PROP_PWRCTRL = 0x0000000E,
KGSL_PROP_PWR_CONSTRAINT = 0x00000012,
};
struct kgsl_shadowprop {
unsigned int gpuaddr;
unsigned int size;
unsigned int flags; /* contains KGSL_FLAGS_ values */
};
struct kgsl_version {
unsigned int drv_major;
unsigned int drv_minor;
unsigned int dev_major;
unsigned int dev_minor;
};
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
/* Performance counter groups */
#define KGSL_PERFCOUNTER_GROUP_CP 0x0
#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1
#define KGSL_PERFCOUNTER_GROUP_PC 0x2
#define KGSL_PERFCOUNTER_GROUP_VFD 0x3
#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4
#define KGSL_PERFCOUNTER_GROUP_VPC 0x5
#define KGSL_PERFCOUNTER_GROUP_TSE 0x6
#define KGSL_PERFCOUNTER_GROUP_RAS 0x7
#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8
#define KGSL_PERFCOUNTER_GROUP_TP 0x9
#define KGSL_PERFCOUNTER_GROUP_SP 0xA
#define KGSL_PERFCOUNTER_GROUP_RB 0xB
#define KGSL_PERFCOUNTER_GROUP_PWR 0xC
#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD
#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE
#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF
#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE
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
/* structure holds list of ibs */
struct kgsl_ibdesc {
unsigned int gpuaddr;
void *hostptr;
unsigned int sizedwords;
unsigned int ctrl;
};
/* ioctls */
#define KGSL_IOC_TYPE 0x09
/* get misc info about the GPU
type should be a value from enum kgsl_property_type
value points to a structure that varies based on type
sizebytes is sizeof() that structure
for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo
this structure contaings hardware versioning info.
for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop
this is used to find mmap() offset and sizes for mapping
struct kgsl_memstore into userspace.
*/
struct kgsl_device_getproperty {
unsigned int type;
void *value;
unsigned int sizebytes;
};
#define IOCTL_KGSL_DEVICE_GETPROPERTY \
_IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty)
/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012
*/
/* block until the GPU has executed past a given timestamp
* timeout is in milliseconds.
*/
struct kgsl_device_waittimestamp {
unsigned int timestamp;
unsigned int timeout;
};
#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \
_IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp)
struct kgsl_device_waittimestamp_ctxtid {
unsigned int context_id;
unsigned int timestamp;
unsigned int timeout;
};
#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \
_IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)
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
/* DEPRECATED: issue indirect commands to the GPU.
* drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE
* ibaddr and sizedwords must specify a subset of a buffer created
* with IOCTL_KGSL_SHAREDMEM_FROM_PMEM
* flags may be a mask of KGSL_CONTEXT_ values
* timestamp is a returned counter value which can be passed to
* other ioctls to determine when the commands have been executed by
* the 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
*
* This fucntion is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS
* instead
*/
struct kgsl_ringbuffer_issueibcmds {
unsigned int drawctxt_id;
unsigned int ibdesc_addr;
unsigned int numibs;
unsigned int timestamp; /*output param */
unsigned int flags;
};
#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \
_IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds)
/* read the most recently executed timestamp value
* type should be a value from enum kgsl_timestamp_type
*/
struct kgsl_cmdstream_readtimestamp {
unsigned int type;
unsigned int timestamp; /*output param */
};
#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \
_IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \
_IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
/* free memory when the GPU reaches a given timestamp.
* gpuaddr specify a memory region created by a
* IOCTL_KGSL_SHAREDMEM_FROM_PMEM call
* type should be a value from enum kgsl_timestamp_type
*/
struct kgsl_cmdstream_freememontimestamp {
unsigned int gpuaddr;
unsigned int type;
unsigned int timestamp;
};
#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \
_IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
/* Previous versions of this header had incorrectly defined
IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead
of a write only ioctl. To ensure binary compatability, the following
#define will be used to intercept the incorrect ioctl
*/
#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \
_IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
/* create a draw context, which is used to preserve GPU state.
* The flags field may contain a mask KGSL_CONTEXT_* values
*/
struct kgsl_drawctxt_create {
unsigned int flags;
unsigned int drawctxt_id; /*output param */
};
#define IOCTL_KGSL_DRAWCTXT_CREATE \
_IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
/* destroy a draw context */
struct kgsl_drawctxt_destroy {
unsigned int drawctxt_id;
};
#define IOCTL_KGSL_DRAWCTXT_DESTROY \
_IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
/* add a block of pmem, fb, ashmem or user allocated address
* into the GPU address space */
struct kgsl_map_user_mem {
int fd;
unsigned int gpuaddr; /*output param */
unsigned int len;
unsigned int offset;
unsigned int hostptr; /*input param */
enum kgsl_user_mem_type memtype;
unsigned int flags;
};
#define IOCTL_KGSL_MAP_USER_MEM \
_IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)
struct kgsl_cmdstream_readtimestamp_ctxtid {
unsigned int context_id;
unsigned int type;
unsigned int timestamp; /*output param */
};
#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \
_IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)
struct kgsl_cmdstream_freememontimestamp_ctxtid {
unsigned int context_id;
unsigned int gpuaddr;
unsigned int type;
unsigned int timestamp;
};
#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \
_IOW(KGSL_IOC_TYPE, 0x17, \
struct kgsl_cmdstream_freememontimestamp_ctxtid)
/* add a block of pmem or fb into the GPU address space */
struct kgsl_sharedmem_from_pmem {
int pmem_fd;
unsigned int gpuaddr; /*output param */
unsigned int len;
unsigned int offset;
};
#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \
_IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem)
/* remove memory from the GPU's address space */
struct kgsl_sharedmem_free {
unsigned int gpuaddr;
};
#define IOCTL_KGSL_SHAREDMEM_FREE \
_IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)
struct kgsl_cff_user_event {
unsigned char cff_opcode;
unsigned int op1;
unsigned int op2;
unsigned int op3;
unsigned int op4;
unsigned int op5;
unsigned int __pad[2];
};
#define IOCTL_KGSL_CFF_USER_EVENT \
_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event)
struct kgsl_gmem_desc {
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
unsigned int pitch;
};
struct kgsl_buffer_desc {
void *hostptr;
unsigned int gpuaddr;
int size;
unsigned int format;
unsigned int pitch;
unsigned int enabled;
};
struct kgsl_bind_gmem_shadow {
unsigned int drawctxt_id;
struct kgsl_gmem_desc gmem_desc;
unsigned int shadow_x;
unsigned int shadow_y;
struct kgsl_buffer_desc shadow_buffer;
unsigned int buffer_id;
};
#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \
_IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow)
/* add a block of memory into the GPU address space */
/*
* IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012
* use IOCTL_KGSL_GPUMEM_ALLOC instead
*/
struct kgsl_sharedmem_from_vmalloc {
unsigned int gpuaddr; /*output param */
unsigned int hostptr;
unsigned int flags;
};
#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \
_IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc)
/*
* This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which
* supports both directions (flush and invalidate). This code will still
* work, but by definition it will do a flush of the cache which might not be
* what you want to have happen on a buffer following a GPU operation. It is
* safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC
*/
#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \
_IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free)
struct kgsl_drawctxt_set_bin_base_offset {
unsigned int drawctxt_id;
unsigned int offset;
};
#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \
_IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset)
enum kgsl_cmdwindow_type {
KGSL_CMDWINDOW_MIN = 0x00000000,
KGSL_CMDWINDOW_2D = 0x00000000,
KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */
KGSL_CMDWINDOW_MMU = 0x00000002,
KGSL_CMDWINDOW_ARBITER = 0x000000FF,
KGSL_CMDWINDOW_MAX = 0x000000FF,
};
/* write to the command window */
struct kgsl_cmdwindow_write {
enum kgsl_cmdwindow_type target;
unsigned int addr;
unsigned int data;
};
#define IOCTL_KGSL_CMDWINDOW_WRITE \
_IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write)
struct kgsl_gpumem_alloc {
unsigned long gpuaddr;
size_t size;
unsigned int flags;
};
#define IOCTL_KGSL_GPUMEM_ALLOC \
_IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)
struct kgsl_cff_syncmem {
unsigned int gpuaddr;
unsigned int len;
unsigned int __pad[2]; /* For future binary compatibility */
};
#define IOCTL_KGSL_CFF_SYNCMEM \
_IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem)
/*
* A timestamp event allows the user space to register an action following an
* expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to
* _IOWR to support fences which need to return a fd for the priv parameter.
*/
struct kgsl_timestamp_event {
int type; /* Type of event (see list below) */
unsigned int timestamp; /* Timestamp to trigger event on */
unsigned int context_id; /* Context for the timestamp */
void *priv; /* Pointer to the event specific blob */
size_t len; /* Size of the event specific blob */
};
#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \
_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event)
/* A genlock timestamp event releases an existing lock on timestamp expire */
#define KGSL_TIMESTAMP_EVENT_GENLOCK 1
struct kgsl_timestamp_event_genlock {
int handle; /* Handle of the genlock lock to release */
};
/* A fence timestamp event releases an existing lock on timestamp expire */
#define KGSL_TIMESTAMP_EVENT_FENCE 2
struct kgsl_timestamp_event_fence {
int fence_fd; /* Fence to signal */
};
/*
* Set a property within the kernel. Uses the same structure as
* IOCTL_KGSL_GETPROPERTY
*/
#define IOCTL_KGSL_SETPROPERTY \
_IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty)
#define IOCTL_KGSL_TIMESTAMP_EVENT \
_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
/**
* struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID
* @id: returned id value for this allocation.
* @flags: mask of KGSL_MEM* values requested and actual flags on return.
* @size: requested size of the allocation and actual size on return.
* @mmapsize: returned size to pass to mmap() which may be larger than 'size'
* @gpuaddr: returned GPU address for the allocation
*
* Allocate memory for access by the GPU. The flags and size fields are echoed
* back by the kernel, so that the caller can know if the request was
* adjusted.
*
* Supported flags:
* KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer
* KGSL_MEMTYPE*: usage hint for debugging aid
* KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel.
* KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU
* address will be 0. Calling mmap() will set the GPU address.
*/
struct kgsl_gpumem_alloc_id {
unsigned int id;
unsigned int flags;
unsigned int size;
unsigned int mmapsize;
unsigned long gpuaddr;
/* private: reserved for future use*/
unsigned int __pad[2];
};
#define IOCTL_KGSL_GPUMEM_ALLOC_ID \
_IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)
/**
* struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID
* @id: GPU allocation id to free
*
* Free an allocation by id, in case a GPU address has not been assigned or
* is unknown. Freeing an allocation by id with this ioctl or by GPU address
* with IOCTL_KGSL_SHAREDMEM_FREE are equivalent.
*/
struct kgsl_gpumem_free_id {
unsigned int id;
/* private: reserved for future use*/
unsigned int __pad;
};
#define IOCTL_KGSL_GPUMEM_FREE_ID \
_IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id)
/**
* struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO
* @gpuaddr: GPU address to query. Also set on return.
* @id: GPU allocation id to query. Also set on return.
* @flags: returned mask of KGSL_MEM* values.
* @size: returned size of the allocation.
* @mmapsize: returned size to pass mmap(), which may be larger than 'size'
* @useraddr: returned address of the userspace mapping for this buffer
*
* This ioctl allows querying of all user visible attributes of an existing
* allocation, by either the GPU address or the id returned by a previous
* call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not
* return all attributes so this ioctl can be used to look them up if needed.
*
*/
struct kgsl_gpumem_get_info {
unsigned long gpuaddr;
unsigned int id;
unsigned int flags;
unsigned int size;
unsigned int mmapsize;
unsigned long useraddr;
/* private: reserved for future use*/
unsigned int __pad[4];
};
#define IOCTL_KGSL_GPUMEM_GET_INFO\
_IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)
/**
* struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE
* @gpuaddr: GPU address of the buffer to sync.
* @id: id of the buffer to sync. Either gpuaddr or id is sufficient.
* @op: a mask of KGSL_GPUMEM_CACHE_* values
*
* Sync the L2 cache for memory headed to and from the GPU - this replaces
* KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both
* directions
*
*/
struct kgsl_gpumem_sync_cache {
unsigned int gpuaddr;
unsigned int id;
unsigned int op;
/* private: reserved for future use*/
unsigned int __pad[2]; /* For future binary compatibility */
};
#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0)
#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN
#define KGSL_GPUMEM_CACHE_INV (1 << 1)
#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV
#define KGSL_GPUMEM_CACHE_FLUSH \
(KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV)
#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \
_IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache)
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_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET
* @groupid: Performance counter group ID
* @countable: Countable to select within the group
* @offset: Return offset of the reserved LO counter
* @offset_hi: Return offset of the reserved HI counter
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
*
* Get an available performance counter from a specified groupid. The offset
* of the performance counter will be returned after successfully assigning
* the countable to the counter for the specified group. An error will be
* returned and an offset of 0 if the groupid is invalid or there are no
* more counters left. After successfully getting a perfcounter, the user
* must call kgsl_perfcounter_put(groupid, contable) when finished with
* the perfcounter to clear up perfcounter resources.
*
*/
struct kgsl_perfcounter_get {
unsigned int groupid;
unsigned int countable;
unsigned int offset;
unsigned int offset_hi;
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
/* private: reserved for future use */
unsigned int __pad; /* For future binary compatibility */
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
};
#define IOCTL_KGSL_PERFCOUNTER_GET \
_IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get)
/**
* struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT
* @groupid: Performance counter group ID
* @countable: Countable to release within the group
*
* Put an allocated performance counter to allow others to have access to the
* resource that was previously taken. This is only to be called after
* successfully getting a performance counter from kgsl_perfcounter_get().
*
*/
struct kgsl_perfcounter_put {
unsigned int groupid;
unsigned int countable;
/* private: reserved for future use */
unsigned int __pad[2]; /* For future binary compatibility */
};
#define IOCTL_KGSL_PERFCOUNTER_PUT \
_IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put)
/**
* struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
* @groupid: Performance counter group ID
* @countable: Return active countables array
* @size: Size of active countables array
* @max_counters: Return total number counters for the group ID
*
* Query the available performance counters given a groupid. The array
* *countables is used to return the current active countables in counters.
* The size of the array is passed in so the kernel will only write at most
* size or counter->size for the group id. The total number of available
* counters for the group ID is returned in max_counters.
* If the array or size passed in are invalid, then only the maximum number
* of counters will be returned, no data will be written to *countables.
* If the groupid is invalid an error code will be returned.
*
*/
struct kgsl_perfcounter_query {
unsigned int groupid;
/* Array to return the current countable for up to size counters */
unsigned int *countables;
unsigned int count;
unsigned int max_counters;
/* private: reserved for future use */
unsigned int __pad[2]; /* For future binary compatibility */
};
#define IOCTL_KGSL_PERFCOUNTER_QUERY \
_IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query)
/**
* struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
* @groupid: Performance counter group IDs
* @countable: Performance counter countable IDs
* @value: Return performance counter reads
* @size: Size of all arrays (groupid/countable pair and return value)
*
* Read in the current value of a performance counter given by the groupid
* and countable.
*
*/
struct kgsl_perfcounter_read_group {
unsigned int groupid;
unsigned int countable;
unsigned long long value;
};
struct kgsl_perfcounter_read {
struct kgsl_perfcounter_read_group *reads;
unsigned int count;
/* private: reserved for future use */
unsigned int __pad[2]; /* For future binary compatibility */
};
#define IOCTL_KGSL_PERFCOUNTER_READ \
_IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read)
/*
* struct kgsl_gpumem_sync_cache_bulk - argument to
* IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK
* @id_list: list of GPU buffer ids of the buffers to sync
* @count: number of GPU buffer ids in id_list
* @op: a mask of KGSL_GPUMEM_CACHE_* values
*
* Sync the cache for memory headed to and from the GPU. Certain
* optimizations can be made on the cache operation based on the total
* size of the working set of memory to be managed.
*/
struct kgsl_gpumem_sync_cache_bulk {
unsigned int *id_list;
unsigned int count;
unsigned int op;
/* private: reserved for future use */
unsigned int __pad[2]; /* For future binary compatibility */
};
#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \
_IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk)
/*
* struct kgsl_cmd_syncpoint_timestamp
* @context_id: ID of a KGSL context
* @timestamp: GPU timestamp
*
* This structure defines a syncpoint comprising a context/timestamp pair. A
* list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define
* dependencies that must be met before the command can be submitted to the
* hardware
*/
struct kgsl_cmd_syncpoint_timestamp {
unsigned int context_id;
unsigned int timestamp;
};
#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0
struct kgsl_cmd_syncpoint_fence {
int fd;
};
#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1
/**
* struct kgsl_cmd_syncpoint - Define a sync point for a command batch
* @type: type of sync point defined here
* @priv: Pointer to the type specific buffer
* @size: Size of the type specific buffer
*
* This structure contains pointers defining a specific command sync point.
* The pointer and size should point to a type appropriate structure.
*/
struct kgsl_cmd_syncpoint {
int type;
void __user *priv;
unsigned int size;
};
/**
* struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS
* @context_id: KGSL context ID that owns the commands
* @flags:
* @cmdlist: User pointer to a list of kgsl_ibdesc structures
* @numcmds: Number of commands listed in cmdlist
* @synclist: User pointer to a list of kgsl_cmd_syncpoint structures
* @numsyncs: Number of sync points listed in synclist
* @timestamp: On entry the a user defined timestamp, on exist the timestamp
* assigned to the command batch
*
* This structure specifies a command to send to the GPU hardware. This is
* similar to kgsl_issueibcmds expect that it doesn't support the legacy way to
* submit IB lists and it adds sync points to block the IB until the
* dependencies are satisified. This entry point is the new and preferred way
* to submit commands to the GPU.
*/
struct kgsl_submit_commands {
unsigned int context_id;
unsigned int flags;
struct kgsl_ibdesc __user *cmdlist;
unsigned int numcmds;
struct kgsl_cmd_syncpoint __user *synclist;
unsigned int numsyncs;
unsigned int timestamp;
/* private: reserved for future use */
unsigned int __pad[4];
};
#define IOCTL_KGSL_SUBMIT_COMMANDS \
_IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands)
/**
* struct kgsl_device_constraint - device constraint argument
* @context_id: KGSL context ID
* @type: type of constraint i.e pwrlevel/none
* @data: constraint data
* @size: size of the constraint data
*/
struct kgsl_device_constraint {
unsigned int type;
unsigned int context_id;
void __user *data;
size_t size;
};
/* Constraint Type*/
#define KGSL_CONSTRAINT_NONE 0
#define KGSL_CONSTRAINT_PWRLEVEL 1
/* PWRLEVEL constraint level*/
/* set to min frequency */
#define KGSL_CONSTRAINT_PWR_MIN 0
/* set to max frequency */
#define KGSL_CONSTRAINT_PWR_MAX 1
struct kgsl_device_constraint_pwrlevel {
unsigned int level;
};
#ifdef __KERNEL__
#ifdef CONFIG_MSM_KGSL_DRM
int kgsl_gem_obj_addr(int drm_fd, int handle, unsigned long *start,
unsigned long *len);
#else
#define kgsl_gem_obj_addr(...) 0
#endif
#endif
#endif /* _MSM_KGSL_H */