7019 Commits

Author SHA1 Message Date
Tonoxis
820a7dfba0 Pulled in slightly re-worked GPU driver from davidmueller13/Vindicator-flo-aosp. 2021-04-04 16:20:12 -04:00
Jeff Boody
9c7966d444 msm: kgsl: fix race condition setting the event->handle
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>
2013-11-07 17:19:58 -08:00
Jeff Boody
1b3aadfe27 msm: kgsl: protect syncpoint events with a reference count
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>
2013-11-07 17:19:58 -08:00
Jeff Boody
e7e0508ea7 msm: kgsl: update kgsl_cmdbatch_destroy with the tip
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>
2013-11-07 17:19:57 -08:00
Lucille Sylvester
0589351900 msm: kgsl: Run the idle timer while the GPU is not power collapsed
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>
2013-11-04 22:15:48 -08:00
Jeremy Gebben
f6447215c1 msm: kgsl: remove KGSL_IOCTL_WAKE from context destruction
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>
2013-11-04 22:15:48 -08:00
Jeremy Gebben
7823099635 msm: kgsl: manage active count in adreno_ioctl()
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>
2013-11-04 22:15:47 -08:00
Jeremy Gebben
983d37aa17 msm: kgsl: always check kgsl_active_count_get() result
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>
2013-11-04 22:15:46 -08:00
Jordan Crouse
5149a5e2c3 msm: kgsl: Do not take active_cnt for events and waittimestamp
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>
2013-11-04 22:15:46 -08:00
Carter Cooper
ec7e738fc5 msm: kgsl: Add IB submission gate for device suspend
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>
2013-11-04 22:15:45 -08:00
Jeremy Gebben
7a8fee7870 msm: kgsl: consolidate preamble based context switch code
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>
2013-11-04 22:15:45 -08:00
Jordan Crouse
baed9f57c5 msm: kgsl: Allow sync points to be created on the submitter's context
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>
2013-11-04 22:15:44 -08:00
Carter Cooper
dc89b65747 msm: kgsl: Update dispatcher/server-side sync
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>
2013-11-04 22:15:43 -08:00
Jordan Crouse
b0eacf300c msm: kgsl: Re-run the events handler when inflight goes to zero
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>
2013-10-23 17:05:10 -06:00
Jeff Boody
19dc4f121f Revert "msm: kgsl: schedule the event queue after the dispatcher work queue"
This reverts commit 4f36f4e847.

Change-Id: I2d9a7b89aebc7fb548531dbecb791f2b2f5b4526
2013-10-23 17:04:27 -06:00
Harsh Vardhan Dwivedi
5e8779beb4 msm: kgsl: Switch to default pagetables in case of NULL context
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>
2013-10-17 15:43:05 -07:00
Jordan Crouse
18b9ef4640 msm: kgsl: Return an error from kgsl_active_count_wait()
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>
2013-10-17 14:43:00 -07:00
Jordan Crouse
d3bab0eebf msm: kgsl: Fix the return value of kgsl_active_count_wait()
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>
2013-10-17 14:42:54 -07:00
Jeff Boody
5a9b20acf4 msm: kgsl: prevent kgsl_get_pagetable from returning a destroyed pt
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>
2013-10-17 14:42:49 -07:00
Carter Cooper
2170305716 msm: kgsl: Fix error case in kgsl ioctl handler
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>
2013-10-15 17:29:33 -07:00
Carter Cooper
aacc8a6fc3 msm: kgsl: Move logic for deleting the fault timer
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>
2013-10-15 17:29:32 -07:00
Carter Cooper
25a78a3f21 msm: kgsl: Wake up gpu on kgsl_ioctl_timestamp_event only if necessary
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>
2013-10-15 17:29:32 -07:00
Jordan Crouse
f87aae1f87 msm: kgsl: Check if the GPU is idle in the soft hang detection
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>
2013-10-15 17:29:31 -07:00
Jordan Crouse
c24069c12c msm: kgsl: Remove now uneeded GPU event code
_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>
2013-10-10 14:40:49 -07:00
Carter Cooper
e590de4b79 msm: kgsl: Take the device mutex earlier when sending cmds to GPU
Move the device mutex up before we increment the inflight count.

Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-10-10 14:40:49 -07:00
Harsh Vardhan Dwivedi
43c063e913 msm: kgsl: Detect gpu mem entry collisions when using MAP_FIXED flag
When using MAP_FIXED flags, detect collisions with previous gpu memory
entries. Fail mmap() if previous gpu entries exist.

Change-Id: I09f456677e7fc81b8bdf1b2f5724569220c7e897
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
2013-10-08 12:26:23 -07:00
Carter Cooper
e6f5212cce msm: kgsl: Fix idle check and add irq_last
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>
2013-10-04 11:45:37 -07:00
Carter Cooper
a220d57b32 msm: kgsl: Ensure signals do not cause waits to end early
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>
2013-10-04 11:45:37 -07:00
Carter Cooper
d99657072a msm: kgsl: Schedule dispatcher after resume
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>
2013-10-04 11:45:36 -07:00
Shubhraprakash Das
cce0ed5b23 msm: kgsl: Detach context when context creation fails in create function
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>
2013-10-04 11:45:36 -07:00
Carter Cooper
bd7bc84679 msm: kgsl: Check return value on waiting for GPU to idle
Use the return value of kgsl_idle to do smart things rather than
just ignoring it.
2013-10-04 11:45:36 -07:00
Rajesh Kemisetti
907003347b msm: kgsl: Add a check to free the kgsl_timeline object.
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>
2013-10-04 11:45:36 -07:00
Harsh Vardhan Dwivedi
84d023fe36 msm: kgsl: Get an active count before snapshotting GPU
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>
2013-10-04 11:45:35 -07:00
Shubhraprakash Das
39318ec8e1 msm: kgsl: Keep track of kernel space mappings to memory
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>
2013-10-04 11:45:35 -07:00
Suman Tatiraju
ee0ebd1643 msm: kgsl: Provide a sysfs interface to force GPU power rail on
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>
2013-10-04 11:45:35 -07:00
Shubhraprakash Das
e57ab7ecc9 msm: kgsl: Do not allow events with bogus timestamp
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>
2013-10-04 11:45:34 -07:00
Shubhraprakash Das
d00cf7d01b msm: kgsl: Fix freezing of counter when reading it
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>
2013-10-04 11:45:34 -07:00
Shubhraprakash Das
4ebd1ae423 msm: kgsl: Return error when getting pdata of bus scale table fails
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>
2013-10-04 11:45:34 -07:00
Shubhraprakash Das
8a7e71b9b5 msm: kgsl: Add return value for perfcounter enable function
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>
2013-10-04 11:45:34 -07:00
Suman Tatiraju
d66d7c0426 msm: kgsl: reset GPU when GDSC is forced on
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>
2013-10-04 11:45:33 -07:00
Suman Tatiraju
48d0211da0 msm: kgsl: Turn on GPU clock before setting the control flag
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>
2013-10-04 11:45:33 -07:00
Shubhraprakash Das
89483ce81c msm: kgsl: Call adreno_init only once on startup
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>
2013-10-04 11:45:33 -07:00
Jordan Crouse
2d43dbf945 msm: kgsl: Activate the dispatcher following a resume
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>
2013-10-04 11:45:32 -07:00
Rom Lemarchand
f6ff2099ab msm: kgsl: inherit owner from kgsl/proc debug directory
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>
2013-10-02 17:00:47 -07:00
Shubhraprakash Das
b469b15c25 msm: kgsl: Pass the size of IB2 in dwords when saving it in snapshot
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>
2013-09-19 20:29:34 -07:00
Carter Cooper
1fd9df8a02 msm: kgsl: Don't halt the GPU, try to recover first
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>
2013-09-19 20:29:33 -07:00
Carter Cooper
266ba0236e msm: kgsl: Use correct bit operations for faults
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>
2013-09-19 20:29:32 -07:00
Jordan Crouse
760b7b8dd6 msm: kgsl: Don't repeatedly call adreno_stop during reset
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>
2013-09-19 20:29:32 -07:00
Jordan Crouse
c58772bde0 msm: kgsl: Validate the meta data pointer in kgsl_destroy_ion()
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>
2013-09-19 20:29:31 -07:00
Jordan Crouse
9dbc420335 msm: kgsl: Remove drawctxt_active from setstate default
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>
2013-09-19 20:29:31 -07:00