The code that dumped the A3XX debug bus wasn't using
the right bitshift for debug bus ID resulting in completely
incorrect data in the snapshot output. Set the ID correctly
and the debug data is full and complete.
Change-Id: Ic0dedbad41ec7267517f4fa16de2c5884ae0d82c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
A3XX GPU hang detection can figure out if the core is
hung and interrupt us if it has. However, the interrupt
seems to be a little unreliable so that isn't of use to
us, but the hang detection has a beneficial side effect
of spewing lots of useful information to debug registers
that can be used on a hang. Enable the hang detection but
disable the hang interrupt.
Change-Id: Ic0dedbadc8492d388729c2eea9b9e1bdc8ac1013
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
GMEM save/restore was never being executed for A3XX due to an
if() statement checking a flag that never gets set. Remove said
if statement and set the flag so that GMEM save/restore gets run
during a context switch if requested from user space.
Additionally, fix a few minor issues with the gmem save/restore
sequence so when the application requests it, it will actually
work.
Change-Id: Ic0dedbad3f8e86b23bbd26051b771514e6518831
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
The stored sizes for the PM4 and PFP microcode in the adreno device
structure were already dword sized, so just store those numbers
directly in the snapshot header. The stored size include an additional
version dword that isn't actually saved as part of the firmware, so
decrement the stored sizes by one when we read the data back from
the GPU.
Change-Id: Ic0dedbad6d4c5612903c7b6d1b626ccd6246f61c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Set the correct GMEM and istore sizes for A320 on APQ8064.
The more GMEM we have the happier we are, so the code will
work with 256K, but it will be better with 512K. For the
instruction store the size is important during GPU snapshot
and postmortem dump. Also, the size of each instruction is
different on A3XX so remove the hard coded constants and
add a GPU specific size variable.
Change-Id: Ic0dedbad01d5a9dc4211a666bc0a065189938841
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
ION clients allocating from a content protection
heap (cp heap) must be able to map the memory to
an IOMMU when IOMMU are being used.
Add callbacks to CP heap to support IOMMU mapping.
Change-Id: I5dd70096edcab4866a436ae4447f9a6e00e2f0ec
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
When restoring to slumber from nap, the irq is kept enabled causing a
power drain. This change ensures that adreno device behaves similar to
z180 device.
Change-Id: I7dd9b8f21ae341c978204b6dbb0162d606168b77
CRs-Fixed: 331847
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
Modify postmortem and GPU snapshot to dump A3XX debug sections
and registers.
Change-Id: Ic0dedbadb28be76d5ad2dcf214bc88b15dd7342e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Add support for the A320, the first of the new generation
of Adreno GPUs.
Change-Id: Ic0dedbadd29fbdff8733cd38824594e757eef42d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Userspace will set a flag in the context if preambles are in use. If
they are, we can safely skip save and restore commands for the
context. GMEM save/restore is still required. To improve performance,
preamble commands are skipped when the context hasn't changed since
the last issueibcmds.
Change-Id: I21bb8996d62651122dbebcf7a79543679109e1f9
Signed-off-by: Vijay Krishnamoorthy <adivarah@codeaurora.org>
FMEM allows ION to release memory for other
purposes when ION clients are not using the
memory.
Add new heap type for fmem that make calls
into fmem API to transition memory from T to
C state and vice versa. Add support for
fmem to content protection heap.
Change-Id: I95f949b57c99949e6eafe6a6f5fd147bdaa264f6
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
commit bf9c05d5b6d19b3e4c9fe21047694e94f48db89b upstream.
The assignment of handle in vmw_framebuffer_create_handle doesn't actually do anything useful and is incorrectly assigning an integer value to a pointer argument. It appears that this is a typo and should be dereferencing handle rather than assigning to it directly. This fixes a bug where an undefined handle value is potentially returned to user-space.
Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Reviewed-by: Jakob Bornecrantz<jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 598781d71119827b454fd75d46f84755bca6f0c6 upstream.
If the master tries to authenticate a client using drm_authmagic and
that client has already closed its drm file descriptor,
either wilfully or because it was terminated, the
call to drm_authmagic will dereference a stale pointer into kmalloc'ed memory
and corrupt it.
Typically this results in a hard system hang.
This patch fixes that problem by removing any authentication tokens
(struct drm_magic_entry) open for a file descriptor when that file
descriptor is closed.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
An ION content protection heap should not allow
cached kernel space mapping for a heap that is
protected. Also, ION should not allow a heap that
has outstanding cached kernel space mappings to
be protected. These checks will ensure that the kernel
doesn't try to access memory that is locked down and
it cannot access.
Change-Id: I1f4a392d94ae8ae59c52978cfd0890e1a13fd39a
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
ION protects the heap when the first secure allocation
is done while unprotecting when the last secure allocation
is freed. In addition ION provides a separate API for protecting
and unprotecting a heap allowing users to better time the
protection of a heap.
The protection/unprotection done during first allocation and
last free is not needed anymore. Clients need better control
and thus use the separate API.
Remove protection of heap that is occuring when the
first secure allocation is done. Remove unprotecting of
the heap when the last secure allocation is freed.
Change-Id: I80254c3a79399cd4900a389dcb535d843d6dfa80
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Modified to use memory management API provided by KGSL. Cleaned up
unused function overrides, and fixed memory leak.
Change-Id: I28c2d5c56b559e0ee5c46d25a2a22d694d3b6b9d
Signed-off-by: Michael Street <mstreet@codeaurora.org>
Consider two threads. Thread 1 has an fd linked to an ion buffer
and Thread 2 has a handle to the same buffer. The two came from
the same client
Thread 1 Thread 2
-----------------------------------------
ion_import_fd
ion_import
mutex_lock(&client->lock)
ion_free
ion_handle_put
ion_handle_destroy
mutex_lock(&client->lock) <--- currently locked
ion_handle_lookup
<return reference to same handle>
mutex_unlock(&client->lock)
acquire client lock
free(handle)
Thread 1 is now holding a reference to an already freed handle.
The issue arises because thread 2 is attempting to destroy the
handle but the handle still exists on the clients list of handles.
This needs to be atomic. Fix this by taking the client lock
around ion_handle_put.
CRs-Fixed: 328348
Change-Id: I3ff5e6c50b5268fd42092bc1f2b99403e5fcd3cd
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Several functions that should not be used outside of
the ion.c file does not have static keyword. In
addition two of the functions should not be exported.
Add static keyword to functions that are local to the
translation unit and remove EXPORT_SYMBOL declarations
that are not needed.
Change-Id: Ia1ef54e3670d361c9a6d684f789be2129facb04d
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
These idles were necessary when the context switch code
preserved PM_OVERRIDE registers. That was removed some time
ago so now the idles are not needed.
CRs-Fixed: 331325
Change-Id: I90d4e1685f213a5720bf6da4e6d4a187d1eb0689
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Use a #define constant instead of a bare constant for the flags
parameter of adreno_ringbuffer_issuecmds.
Change-Id: Ic0dedbadecabe396a51201859a444e68ba64c53d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Add support for snapshotting the state of the GPU in a binary format. The
snapshot can be pulled from sysfs and parsed off-target. The advantage is
that far more information can be encapsulated in a snapshot then can be
printed on the console during a hang. Snapshots are automatically created
during a hang, or can be manually triggered by writing 'trigger'
in /sys/class/kgsl/kgsl-<n>/snapshot where n is either the 2D or 3D device.
Snapshot data can be pulled from 'dump' in the same directory.
Change-Id: Ic0dedbad1c8473b3b109582b95a8771b0d341f05
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Several functions in the ion interface is missing
EXPORT_SYMBOL. This is needed to allow clients to
use these functions from kernel modules.
Add EXPORT_SYMBOL to functions that are supposed
to be exposed.
Change-Id: Ieb2810d85205a7492b8fe28536fb20ea090e830f
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
commit 3df96909b75835d487a9178761622b0cbd7310d4 upstream.
It would previously write basically random bits to PCI configuration space...
Not very surprising that the GPU tended to stop responding completely. The
resulting MCE even froze the whole machine sometimes.
Now resetting the GPU after a lockup has at least a fighting chance of
succeeding.
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
commit 28eebb703e28bc455ba704adb1026f76649b768c upstream.
We often end up missing fences on older asics with
writeback enabled which leads to delays in the userspace
accel code, so just disable it by default on those asics.
Reported-by: Helge Deller <deller@gmx.de>
Reported-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
commit 92db7f6c860b8190571a9dc1fcbc16d003422fe8 upstream.
This change was verified to fix both issues with no video I've
investigated. I've also checked checksum calculation with fglrx on:
RV620, HD54xx, HD5450, HD6310, HD6320.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
strncpy is unsafe because it does not guarantee
that the resultant string is NULL-terminated.
Replace strncpy with strlcpy and remove explicit
NULL-termination. Also correct allocation of
string buffer.
Change-Id: Id5075ef7b04f80e2bf828f52def329b926e9ec3f
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
This reverts a87d51a96c
Patch causes increase in power consumption while playing a video.
CRs-fixed: 331854
Change-Id: Ic21f109ac730167539a78647d51a8051d5c9948f
Signed-off-by: Anoop Kumar Yerukala <ayeruk@codeaurora.org>
kmalloc allocates physically contiguous memory and
may fail for larger allocations due to fragmentation.
The large allocations are caused by the fact that the
scatterlist structure is 24 bytes and the array size
is proportional to the number of pages being mapped.
CRs-fixed: 327066
Change-Id: Ic7d15ca0399aa5c1fa01b7892cff736b3d1e4236
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
The stop_work function releases the device mutex to flush
the workqueue. The requested state may change while the
mutex is held by a different thread. So set the requested
state after stop_work.
Change-Id: I3454e773fd670722ea5776d2c8d960190da24006
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Use the restore_slumber variable at as low a level as possible
to remove confusion from the state machine. Also do not let
restore_slumber impact the function of NAP state.
Change-Id: I1e01dc35c19b3568bad1e6ae4b2399d309147cbd
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
If the core is in SUSPEND or INIT hw access should not be allowed.
Change-Id: I635a68044dc66be643eb73844b0a5a8b43f31b6c
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
The refcount increment actually needs to happen in mmap.
Otherwise it doesn't actually happen.
Change-Id: I1043453c2c828b8658a28acea57181759b2b21f0
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Printing to debugfs is done from a centralized location for
all the heaps managed by ion. This architecture is not
sustainable in the long run since different heaps have different
requirements for what should be printed.
Refactor the debugfs printing for ion so that each heap is
responsible for printing its information.
Change-Id: I1dbe13432a4ab07f27ea4756c3be7fa01ad1df92
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Add error message when allocation from ion fails.
Change-Id: If2efa95c563c9f076b85958a70ea66afa3983325
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
The ion client name used for debugging were being
allocated on the stack for user space clients. This
causes the name to be garbled when later printed.
Instead, allocate the name from the heap.
Change-Id: Id299d224192f127197bef2eeb22d881b3a31795c
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Add decrement of mapping count when mapping fails
and corresponding SMI release region call.
Change-Id: I81fb7eeee9973c770a65f02236c5358ce313e3a0
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Remove duplicate logging message for failure to create
a heap. Add logging message with name, base address, and
size of each heap created.
Change-Id: Id3a3706d914ffa72b0ecd84eb98785a678ceda9a
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
The SCM call message size used to protect and
unprotect memory is incorrect. The interface expects
13 bytes but 16 bytes is sent due to padding of the
message struct.
Pack the message structure to force the size of the
structure to 13 bytes.
Change-Id: Iecb7b40aa7e94454620c19cd70c3106392d2d311
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
ION has to guarantee that two of the heaps are
adjacent to each other. This is due to a limitation
in the hardware. Add code to ensure these heaps
are adjacent.
Change-Id: Icc18437a50e1d872112468d02b61ab47fd70acc9
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
MSM_SLEEP_STATS_DEVICE option is used to compile idle stats device
framework which is needed for GPU DCVS feature.
Change-Id: I9550c90054587aa4fcec40131761eeaf54da8a03
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
Refactor platform data to allow for better
expansion in the future. Add void * for
elements unique to each heap type.
Change-Id: I435679819c67ce917b5798009eff7e71047fd2ea
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>