A race condition existed for setting the event->handle since the
async event can signal at any time after it has been registered.
When the event signals the reference count for the synclist and
the async callback are decremented causing the event to be freed.
The kgsl_cmdbatch_add_sync_fence function needs to take another
reference to ensure that the handle can be set before the event
is freed.
Change-Id: I0d8a02246e42dce014661d6f14c685415f1704cd
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Replace the event spinlock with krefs to avoid the possiblity
of calling a sleeping function while holding the spinlock and
to generally make the whole cmdbatch cancel loop a lot more
stable.
Change-Id: I08ba54fa4c5a11c05e3503dfc6a4ee040733e5a6
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
The kgsl_cmdbatch_destroy function is outdated with the tip and
the difference patch cannot be cherry-picked easily.
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
If the GPU is not in its lowest permitted power collapse state,
make sure there is a timer running to get the GPU to that state.
Change-Id: If57aaaf02087036bc4e24725c0cd3de5bc1f1034
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Adreno context destruction never needs the hardware on
to destroy the current context.
For z180, always take an active count while destroying.
Since this is the last ioctl to use KGSL_IOCTL_WAKE, remove
it entirely.
Change-Id: I97368c7f3c28f16538cc5f48b802b681d7af96ef
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Most of the adreno specific ioctls do not need the hardware
on. The few that do are perfcounter related, it may be
better at some point to optimize them further to shadow
the counters when the hardware is not on rather than
forcing the power on.
Change-Id: I9ea83106e0aaf3d3ac8d261bdec4e4c2e21c4659
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Getting an active count can fail if the hardware doesn't
actually wake up. Make active count get functions __mustcheck
to remind people of this and fix existing calls to
handle the error.
Change-Id: I5a0202c824ac7e436b9061da6d8f638e44e8b7f6
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
In the mists of time it was nessesary to take an active count
for waittimestamp and events because we did not want to run
the risk of suspending while the GPU was active. Now that we
have the dispatcher we have much better control over the GPU
so the original risk is diminished.
The problem is that holding active_cnt prevents us from going
into nap and suspend and with server-side-sync a lot of the
events we are waiting for might take a very long time before
they even get dispatched on the GPU so we are essentially
keeping the clocks on waiting for other people.
z180 must take active count on its own.
Change-Id: Ic0dedbadcb608115938b198faebe333d19c6a8f6
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Add IB submission gate to stop the system from making requests
while suspend is requested. This will force users to wait for
the system to resume before making more requests.
Change-Id: I2460ef9b4237b586a31d4cea64b6dd74d30b08d9
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Move logic for handling preamble based context switch
to the core adreno code. This makes it less burdensome
to implement support for newer GPU families that won't
ever support legacy context switching.
Change-Id: Id9ad5936ff91dcdbc9de869baf0d0b9fcf1b5170
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
There are situations where a submitting thread may wish to create a
syncpoint on an already issued timestamp to pause a context until a
previous command has been retired. Relax the restriction against
submitting a sync point against one's own context and only check to
make sure the user isn't submitting a syncpoint against a future
timestamp (which would be an certain deadlock).
Change-Id: Ic0dedbad883fc228da0d94c8416a88504f5d1377
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Refresh the dispatcher/server-side sync code with some general
fixes to functionality, stability and fault tolerance.
Change-Id: Ic0dedbad48161513a2670d3949fccbdbf14b8dff
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
The event code is sensitive to race conditions with the GPU. We just
can't spend all day the event loops waiting for timestamp to expire.
The dispatcher loop on the other hand is far less sensitive to the
race with the GPU so we have a very good idea when the GPU is idle.
When inflight goes to zero re-run re-queue the event handler to catch
any stragglers.
Conflicts:
drivers/gpu/msm/adreno_dispatch.c
CRs-fixed: 551825
Change-Id: Ic0dedbad9d02fca89724bf791d9c7212712a8014
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Switch to default pagetables when context is NULL. This prevents
instances of page faults when switching to default pagetable when
GPU is busy.
CRS-fixed: 550082
Change-Id: I74bab681b823bf50e58b50b6cb819fbf93163bf7
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
kgsl_active_count_wait() returns an error on failure and if it does
that is a great indication that we probably don't want to go to
suspend right now. Pay attention to what the function returns and
do what it says.
Change-Id: Ic0dedbad44cd009e5318eccc567b0c3002e88bb3
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
kgsl_active_count_wait() is very badly crafted. If the active count
is already under the threshold (as it often is - a successful condition)
the conditional at the end of the function returns -ETIMEDOUT instead
of 0. Return the proper error value so the caller can make a wise
decision based on the result.
Change-Id: Ic0dedbadb948820cf64e3131f895fa3d15247cac
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
A race condition exists between kref_get_pagetable and
kref_put_pagetable such that is is possible to put the last
reference to a pagetable slightly before it has been removed
from the list. By checking kref_get_unless_zero we can determine
if the last reference has already been released. This is safe
because the list is protected by a ptlock.
Change-Id: If6a75e9ca0dec6a12bda5739f835c936a4c3a3b4
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
If active_count_get fails, then calling active_count_put will
cause the active count to become unbalanced. Fix the case
in the kgsl ioctl control code that was causing in inbalance.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
To make sure that the fault timer does not fire while the
hardware is in the process of turning off, delete the timer
before doing and active_count_put.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Any call of kgsl_ioctl_timestamp_event wakes up gpu. In some cases
(like retired timestamp) it's not necessary. Wake up gpu only if it's
necessary.
Change-Id: I845faf6e9c6e4c9882a68489b64223919be3d21c
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
The GPU probably isn't hung if the core is idle - check for idle
as part of the soft detection alogrithm.
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
_mark_next_event() stopped being useful when the dispatcher was added.
Remove the last vestiges of the code.
Change-Id: Ic0dedbad7b27122513d93993cad2984989295224
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Fix the idle check to correctly check the active count to see if it
is zero (case got flipped in merge). Add irq_last back to the world
as a way to verify that we are done when think we are done.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Move to using uninterruptible (which will bail if any signal is received)
when waiting on events. A signal was causing the wait to finish
prematurely, freeing memory while the GPU was still using it. This caused
quite a few page faults and the device to become unstable.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
It might not be enough to simply set the dispatcher state to
active after a resume. Set the state to active and schedule
the dispatcher to ensure all pending calls get the attention
they require.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
If context creation fails in the creation function then we need to detach
the context and destroy it and not just destroy it to properly clean
up the resources allocated for the context.
Change-Id: I686b2f3090deae2fc9211acce12234daf063d913
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Add a check to free the kgsl_timeline object only after
destroy flag is set. This is to avoid further references to timeline
from kgsl if it is already freed and also to catch any unbalanced
kref count.
Change-Id: I8017b9a928a26b703eb92b17ab6a361e4b479e5a
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
Acquire an active count before attempting to capture a snapshot.
Doing so prevents instances of not being able to snapshot because of
switched off clocks.
CRs-fixed: 511878
Change-Id: Ib80b57c127566e274d4018001561f4da7ea38265
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Add a counter to count number of times a memory descriptor is
mapped in the kernel and unmap the kernel mapping only when the
count reaches 0. There can be multiple threads using the kernel
mapping at the same time hence a counter is used to make sure
that we do not unmap the mapping before the last thread has
finished using it.
Change-Id: I9c53deb6af12fb1f6ed30e46b386e1cd60dafdda
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Provide a debugging interface to keep power rail permanently
enabled. Setting the force_rail_on sysfs entry will leave the
power rail always on.
Change-Id: I10a69dbf5b8cf2e2673b0fcc5e5fb5500a388904
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
Do not register an event if the timestamp of that event is greater
than the highest timestamp assigned to the context or global in
case of global event
Change-Id: If12ad2dbc579bbcf7e99b3179ab8f911dc9b41aa
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
When reading some counters it was not frozen correctly. Reset the
correct bit to freeze the counters.
Change-Id: I1065adec44fc9c702f9c720f96f444d6476bea7e
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Failure to get pdata for bus is an error condition, ensure that
this failure is indicated to the calling function by returning
invalid error instead of returning success when the failure is
indicated by NULL value in the bus scale table pointer
Change-Id: I1624dd94969eb8f713d64bda169d837451c2f040
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Add return value for adreno_perfcounter_enable function because it can
fail. Also, some perfcounter enable functions were receiving incorrect
parameter, fixed this by passing the right parameter to these enable
functions.
Change-Id: Ia47e9eab7833c44fcc0dc389ac8afce425f0a28e
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Sometimes for debug purposes the GPU regulators can be left
on, make sure we reset the gpu while waking up.
Change-Id: Ie18c9f45d9f5a5a7587a1bea2c7c9bb5ce000316
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
Make sure the GPU clocks are turned on before the control flag
is set, otherwise the clocks can never be turned on afterwards.
Change-Id: I44458e11ae09ae2499c7c2d5334e5acd43261756
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
The adreno_init function initializes things that need to be initialized
only once on the first start up. After that until the device is removed
the adreno_init function does not need to called again. Make changes
to execute this function just once until the device is removed.
Change-Id: I1bd18dd9ec70146dc74da1ee9ad1186576344309
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
The dispatcher is put into pause during suspend to avoid commands coming in
during suspend. Unfortunately the dispatcher never has a chance to unpause
itself on resume so new commands sit there waiting for the GPU to turn on.
Change-Id: Ic0dedbad6c9744b47fa1ae711d1b04735fa2f083
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Make all entries under kgsl/proc inherit its owner's uid/gid.
[ccross]
Reapplid after it was overwritten by another patch.
Bug: 10550827
Signed-off-by: Rom Lemarchand <romlem@google.com>
Signed-off-by: Colin Cross <ccross@google.com>
Signed-off-by: Ed Tam <etam@google.com>
The push_object function that saves an IB in snapshot expects the size
of the IB in dwords. The byte-size of IB2 was passed to this function
instead of dwords. Fix this.
Change-Id: I7619696246129da2037338eec1325b80f0c4f321
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
We don't want to halt the GPU when trying to recover in
production devices. Remove the bit mask that would do that.
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Don't mix the streams of BIT() and set_bit(). When using set_bit(),
just send the bit offset rather than the results of BIT().
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
The driver attempts GPU reset several times if the first attempt
fails. If adreno_start() fails it will clean itself up and turn
off the GPU so there is no reason to call adreno_stop again. In
fact, it is dangerous to do so as adreno_stop makes the assumption
that the GPU is on.
Change-Id: Ic0dedbad00aad38bad6b532f1a3266e0cad22352
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
If kgsl_setup_ion() fails for whatever reason entry->priv_data may
either be NULL or pointing to freed memory. In either case, this
is a disaster when kgsl_destroy_ion() tries to use the unvalidated
pointer. Check for NULL in kgsl_destroy_ion() and make sure that
the entry->priv_data pointer is cleared on error in kgsl_setup_ion.
Change-Id: Ic0dedbad6a13e2d8e15982144102517bc8f4e2e8
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
drawctxt_active is cleared after the old context is removed
during context switch. Unfortunately, the context restore calls
adreno_use_default_setstate() which always returns true if
drawctxt_active is NULL, effectively always forcing us down the
software path.
Remove the check - adreno_use_default_setstate() already checks to see
if the GPU is idle and that is a more reliable verification that the
software path is worth going down.
Change-Id: Ic0dedbad57d7783bc23dd925a277a63cd2d78a7e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>