Commit graph

59 commits

Author SHA1 Message Date
Carter Cooper
1011c608ab msm: kgsl: send ringbuffer NOP padding with the next command
If there isn't enough room at the bottom of the ringbuffer for a
whole command, the remaining space is filled with NOPs and
the command starts again at the top of the ringbuffer, the write
pointer of the ringbuffer shall update accordingly; the existing
implementation sends out in-complete NOP command which may potentially
cause GPU hang. This fix submits the NOP command along with the next
command instead of submitting them separately to have GPU read both
commands in the same fetch.

Change-Id: Ia3c9933c11d986c6743d8026b809bbcb1eaf54bf
Signed-off-by: Zhong Liu <zhongl@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:45 -07:00
Carter Cooper
f182b2677d msm: kgsl: Setup a3xx protection in its start function
Setup the protection registers for a3xx towards the end of its
start function instead of doing it in generic ringbuffer start

Change-Id: I66df496afa5d1fdf7dea790306f5358c2098674d
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:43 -07:00
Carter Cooper
b30b6596a3 msm: kgsl: Use a standard function for register access
There were dual functions for reading and writing registers for
adreno devices. Stop the use of one of these dual functions as
it makes the code more uniform.

Change-Id: I703d27d1674a85a6c2d7a9fe6dc49f13005a3410
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:37 -07:00
Carter Cooper
94cb03cf46 msm: kgsl: Define register offset array
Different adreno cores have different offsets for same register.
These registers are referenced in code areas which are common to
all adreno cores. Hence, they should be referenced with a variable
instead of using a constant to make things more generic. This makes
the code more suitable for accomodating future cores.

Change-Id: Ie3d387d7cf767d46eea90e0fecdbba88dad97860
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:36 -07:00
Carter Cooper
91c74a4d97 msm: kgsl: don't store rptr in struct adreno_ringbuffer
Since the rptr is written by the GPU, there's no point
in keeping a copy in the ringbuffer struct where it will
likely be out of date. If you need to look at the ringbuffer,
read it into a local variable with adreno_get_rptr().

Change-Id: Ibf1ba0b9c71a93f65a5c85a58328b2202a27af3f
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:35 -07:00
Carter Cooper
5aa6d0eb25 msm: kgsl: Do not hold memory spinlock when calling find region function
The function kgsl_sharedmem_find_region holds the memory spinlock
at the beginning of the function so we do not need to hold the lock
before calling the function

Change-Id: I20ee32e0ed6aee6ed61cdd4fb7a9cc08a876fc84
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:34 -07:00
Carter Cooper
2a85e2978d msm: kgsl: Make cff capture a device specific property
Make CFF capture a device specific property. This allows the control
of CFF for a particular device without CFF interferance from another
device. This will be useful when we have a virtual device and need to
only capture CFF for the virtual device. CFF capture can only be
turned on for one device at a time.

Change-Id: I14c5a4442ad05327de1413d98bf795dbd196119d
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:32 -07:00
Carter Cooper
be838c9d36 msm: kgsl: Avoid dereferencing NULL pointers
It is possible to drop to the bottom of adreno_ringbuffer_issuecmds
with either context or drawctxt set to NULL. Avoid dereferencing these
variables in the trace call at the bottom of the function.

Change-Id: Ic0dedbadbc7e2c0c4ef85e0d7103e04485ed3e69
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:14 -07:00
Carter Cooper
634371ec69 msm: kgsl: Add support for A305C GPU for MSM8x10
Add new GPU ID, macros and VBIF settings for new GPU revision A305C.

Change-Id: Idcea9ac902a605bc1fc4a38f7ad491b98e39a387
Signed-off-by: Lokesh Batra <lbatra@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:10 -07:00
Carter Cooper
77784f7f8e msm: kgsl: Resize the CP ROQ for a330/a305b
The ROQ for the CP block has the instruction
prefetch space partitioned evenly between
RB, ST, IB1, and IB2. As we don't normally
use ST, and RB is used minimally, we can
reappropriate some of that space to be used
for prefetching more IB1/IB2 instructions.

Change-Id: I6aadb3ad94885d660401f3999051eb0b0283a38e
Signed-off-by: Kevin Matlage <kmatlage@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:00 -07:00
Carter Cooper
2a616d4e82 msm: kgsl: Add cache flush for A20x
Adding extra cache flush command to make sure that CP block
gets event from RB all the time to avoid race conditions because of
clock switches. this is to improve stability on 8x25 target.

Change-Id: Ie411be46fa166864073d35c50085a8f2506d0eb8
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:40:49 -07:00
Jordan Crouse
26ec3b0af3 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-28 18:40:41 +00:00
Sakshi Agrawal
0f03fb6810 msm: kgsl: Always fire an interupt if requested
Even if the event code specifies a dummy interupt it might still
get wrapped with the conditional check.  Make sure that all forced
interrupts from the event code get fired.

Change-Id: Ic0dedbadc4599efcbca65ad93cc27943bad2ca79
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:29 -07:00
Sakshi Agrawal
dd44f17342 msm: kgsl: Update required timestamps during command submission
Update all the required timestamps when submitting commands to the
GPU ringbuffer for execution. The global timestamp was not being
updated in all the required cases. Now the global timestamp and
per context timestamp are updated if following conditions are met:
	1. A valid non global context is passed
	2. The context passed supports per context timestamps
	3. The command submission is not from kgsl
If 3 conditions above are not met then only the global timestamp is
updated.

Change-Id: Ib4fe6fbd2ac57fbc5306377f09072f9e4c09d442
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:29 -07:00
Sakshi Agrawal
c503756ca3 msm: kgsl: Move timestamps inside the context structure
Store the timestamps inside the context rather than in a
list stored in the ringbuffer.  This allows for easier
maintanability as well as keeping all context data
centralized.

Change-Id: I0467d07be6c8bb9f062a81a40629c0288be7e868
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:28 -07:00
Sakshi Agrawal
bb10a9c55d msm: kgsl: Fix context reference counting
Get rid of kgsl_find_context. Use instead kgsl_context_get that does
correct RCU read locking around the itr_find and increases the
reference count on the context before returning it.  This eliminates
the chance that a context will be destroyed while somebody is still
using it.  Of course increased use of kgsl_context_get is accompanied
by kgsl_context_put in all the right places.

Change-Id: Ic0dedbad73d497fd9b451aefad8e5b28d33b829d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:28 -07:00
Sakshi Agrawal
efe7e4749a msm: kgsl: Add a type field to the adreno draw context flags
Allow the user space to pass in a type field to indicate the
type of upper level library that owns the context. The type
field is added to all the appropriate ftrace output for easier
debugging.

Change-Id: Ic0dedbadd42fc5ccfffd89738affd4794a6ab85e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:28 -07:00
Sakshi Agrawal
80d1516513 msm: kgsl: Remove an uneeded log message that pre-dates tracing
Before we started using tracepoints this log message was used for
debugging the critical loop. Now that we are smarter remove the
unneeded log message.

Change-Id: Ic0dedbad57d97294cf2cb3865cf25f698aaea778
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:27 -07:00
Sakshi Agrawal
b654d7af17 msm: kgsl: Resolve a potential race in the interrupt handler
In the GPU interrupt handler we attempt to clear the ts_cmp_enable
for the active context so that future interrupts are skipped until
someone needs one again. If for some reason the interrupt handler
is delayed then there is a possiblity that the "current" context in
the GPU isn't the one that fired the interrupt. In that case we
could be accidently clearing a ts_cmp_enable for a context that
needs it. Instead of clearing in the interrupt handler clear it
from the GPU so we can be sure we got the right context.

As a bonus pushing this logic to the GPU side lets us get rid of
some extra register reads/writes in the interrupt handlers.

Change-Id: Ic0dedbadbf350f7c4866092fa0686f9b42f3cd33
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:26 -07:00
Sakshi Agrawal
bd640bd03a msm: kgsl: Verify the user doesn't accidentally submit a zero length IB
Indirect buffers to be executed will not be (and cannot be) zero length.
Check and reject.

Change-Id: Ic0dedbadea429c4f7bd386c5e64603b51ea8af61
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:26 -07:00
Sakshi Agrawal
944d45c635 msm: kgsl: Return correct timestamp for consumed timestamp reads
adreno_readtimestamp() would return a register value when asked to
get the KGSL_TIMESTAMP_CONSUMED value.  With per-context timestamps
this no longer holds valid since the value in the register could
correspond to a different contexts timestamp.  Return the start of
packet timestamp for the specified context now that the start of
timestamp values are correctly submitted.

CRs-fixed: 382888
Change-Id: Iad56d07eb4a2973a5906d989c96dd117ff902cea
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:25 -07:00
Sakshi Agrawal
8eb620a570 msm: kgsl: Add CP_WAIT_FOR_IDLE packet before updating timestamp
HW workaround to resolve MMU pagefault caused by memory
freeing early before GPU completes it.

This is race condition where timestamp is getting updated
and the event handler runs before the GPU actually got done
with the timestamp, hence freeing the buffer early while GPU
still not completed with it.

Change-Id: I6d338d7dca680f57f2c39ed5a14381b261bf8bce
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:25 -07:00
Sakshi Agrawal
0be3577fee msm: kgsl: Add identifier for internal command submissions
Add an identifier to label internal commands being sent to the
ringbuffer.  This will be used to further enable debugging
and hang recovery.

Change-Id: I4b3c10f0c3d290ae092182cbb450abe65e9dda80
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:25 -07:00
Carter Cooper
d17e14ca3b msm: kgsl: Remove duplicate code for checking timestamps
Event based as well as interruptible based timestamp checks
use the same code, they differ on if the mutex is held or not.
Separate the common code out to avoid confusion.

Change-Id: Ie2ee01d7a07ff2ba7755ab8d327796345f9ca9ea
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-15 17:08:33 -07:00
Tarun Karra
28767dbabf msm: kgsl: Detect long running IBs
When expired global timestamp is not progressing,
check if an IB is talking more than 2 seconds
with no update in GPU read pointer, IB1 base
IB1 size, IB2 base, IB2 size and detect it as a
long running IB. Invalidate the context of the IB
and do not attempt fault tolerance on this context.

Change-Id: I7e9780f5aed73a5c8807069aa506bec16a1576b4
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
2013-03-15 17:08:05 -07:00
Tarun Karra
8219f340d5 msm: kgsl: Renaming recovery to fault tolerance
Renaming recovery to fault tolerance and modifying
the functions and log messages accordingly.

Change-Id: I5f249806026ac514c4aff7da45c3a4e8cc2f8c34
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
2013-03-15 17:08:03 -07:00
Tarun Karra
a78783f9cd msm: kgsl: Recovery policy change
Recovery algorithm is changed to
step 1: retry the same commands that hung the GPU
step 2: if step 1 fails, nop just the IB that hung the GPU
	and retry
step 3: if step 2 fails, skip commands in current context
        till end of frame and retry
step 4: if step 3 fails mark context as bad and execute
        the remaining commands from good contexts.

Previously we used to return -EDEADLK when recovery succeeds,
this is the same error code if the context is not recoverable.
With new policy if recovery succeeds we return -EAGAIN so that
userspace treats recovered context differently from the ones
that are not recoverable. If recovery fails we mark the context
as bad and return -EDEADLK.

Change-Id: I9fa3c40801964186866b6002e62f19cf6aa41361
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
2013-03-15 17:08:03 -07:00
Shubhraprakash Das
e4628a042a msm: kgsl: Locate index of recovery during initialization
When a hang happens locate the index in ringbuffer from where replay
of recovery needs to be re-tried during initialization of recevery.
If the hang detection is false then hang reported by postmortem and
snapshot may be different, but recovery will always start from the
index obtained during initialization. Also, this allows us to capture
data into the snapshot that is in line with the point from where
recovery occurred.

Change-Id: Ie3877f0c81dad2ede888db7cb7d3ff13e2761763
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
2013-03-15 17:08:02 -07:00
Duy Truong
04e554807c Update copyright to The Linux Foundation
Change-Id: Ibead64ce2e901dede2ddd1b86088b88f2350ce92
Signed-off-by: Duy Truong <dtruong@codeaurora.org>
2013-03-15 17:07:39 -07:00
Carter Cooper
30a3967af0 msm: kgsl: Ensure context pointer exists before dereferencing
When trying to add commands to the ringbuffer command stream, ensure
that the context point is not NULL before dereferencing it.

Change-Id: I6d8217ed4b180454eb43f2db161c10e86bc207da
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-03-07 15:24:39 -08:00
Rajeev Kulkarni
1ddd0948c3 msm: kgsl: Issue conditional interrupts on internal submissions
Due to some mismatch in applying patches, one patch was overriding
the changes added  by commit bd5c9fcbf79d326817312138cf03298adf09df27.
This patch restores the changes.

Change-Id: I43223f01653c53df00682e8489b89e8978989944
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:24:12 -08:00
Vijay Krishnamoorthy
64c28c80d2 msm: kgsl: Add support to use timestamps from userspace for an issue
Use timestamp from userspace instead of incrementing context's last
issued timestamp. This allows userspace to defer submissions to KGSL.

Change-Id: I2a104f97420f73dac3bbd23464e92e6ea9d92869
Signed-off-by: Vijay Krishnamoorthy <adivarah@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:23:45 -08:00
Carter Cooper
b928cba153 msm: kgsl: Check for valid pointer before dereferencing
Check to make sure that there is a valid context pointer before
dereferencing it when adding commands to the ringbuffer.

Change-Id: Icf9824de8f62a28cdeeef4378246d9fb334d39fa
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-03-07 15:23:45 -08:00
Tarun Karra
6601ef91c5 msm: kgsl: Synchronize access to IOMMU cfg port
Add a software based spinlock between CPU and GPU.
This spinlock is used to grant mutually exclusive access to
SMMU configuration between CPU and GPU. This mutual exclusion
is required to prevent deadlock in the system.

CRs-Fixed: 409198
Change-Id: Ic375beaaf4c5505b41d3fabc4adf15965d71b13a
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rajeev Kulkarnie <krajeev@codeaurora.org>
2013-03-07 15:23:38 -08:00
Carter Cooper
fe851d33bd msm: kgsl: Issue conditional interrupts on internal submissions
Waittimestamp calls require interrupts to check if a timestamp
has passed.  The lack of these interrupts was causing waittimestamp
to wait longer than expected since the interrupts were less frequent.
Cause the conditional interrupts to be issued faster by allowing
internal command submissions to issue them.

CRs-fixed: 417577
Change-Id: Idb6f18261b3dd6fcbea5607d449d70ca54136e81
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:23:09 -08:00
Jordan Crouse
da34678534 msm: kgsl: Turn off the CP_DEBUG dynamic clock
The CP dynamic clock seems to be glitchy when the CP clocks are turned
back on after a power event. Turn off said dynamic clock control at
init time. The impact of leaving the dynamic clock control off is
negligible since the CP clock is only on when the CP is actually in
use.

CRs-fixed: 402119
CRs-fixed: 409253
CRs-fixed: 413224
Change-Id: Ic0dedbad783f8b911d9b57d1602d9b3976af1b3b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:23:08 -08:00
Shubhraprakash Das
edc43d003f msm: kgsl: Do not allocate space in ringbuffer for hung context
If a hang is detected when allocating space in ringbuffer and
if the context for which the space is being allocated is hung
then do not allocate space at all.

Change-Id: Ia5ade2341fe5016119d8c140413860420c5c3a3d
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:22:00 -08:00
Rajeev Kulkarni
0250bd0e01 msm: kgsl: Need to explicitly halt the ME on stop
it seems even if gpu requests for power rail off, modem might not
process this request as it leads to turn off power rail for mdp in
the case of 7x27a/8x25. This issue specific to 7x27a, since we do
soft reset the GPU on sleep/wake. In the case of suspend/resume,
the powerail is effectively off across the device.

Change-Id: Iad898da67b34e265b2447013c4250ba04a59c0cd
Signed-off-by: Rammohan Basavaraju <rammoh@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
2013-03-07 15:20:30 -08:00
Jordan Crouse
1c152d4571 msm: kgsl: Allow the wait_timeout to be disabled
With the improved hang detection we don't technically need a upper
timeout bound for a process to wait in waitfortimestamp().  Allow
for a idle_timestamp of '0' to allow the loop to wait for ever.
The infrastructure for changing the idle_timeout still exists
so it can be changed to whatever value is appropriate for debugging
or testing.

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: Icffe34821c1b70ca1a8c1a8e13a0b7e23d0ec193
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
2013-02-27 18:16:33 -08:00