This kernel will not be used on devices with other GPUs.
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
Change-Id: I205e625dc1520c8baef622bc6fd303f714c6f7d6
The memory allocated dynamically here is just used to store a single
instance of a struct. Allocate both possible structs on the stack
instead of allocating them dynamically to improve performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
Trying to wait for fences that have already been signaled incurs a high
setup cost, since dynamic memory allocation must be used. Avoiding this
overhead when it isn't needed improves performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
Generating a sync fence name by allocating memory dynamically and using
scnprintf in a hot path results in excessive CPU time wasted on unneeded
debug info. Remove the name generation entirely to cut down CPU waste in
the GPU's rendering hot path.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
POPP constantly attempts to lower the GPU's frequency behind the
governor's back in order to save power; however, the GPU governor in use
(msm-adreno-tz) is very good at determining the GPU's load and selecting
an appropriate frequency to run the GPU at.
POPP was created long ago, perhaps when msm-adreno-tz didn't exist or
didn't work so well, so it is clearly deprecated. Remove it.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
Waking the GPU upon touch wastes power when the screen is being touched
in a way that does not induce animation or any actual need for GPU usage.
Instead of preemptively waking the GPU on touch input, wake it up upon
receiving a IOCTL_KGSL_GPU_COMMAND ioctl since it is a sign that the GPU
will soon be needed.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
Currently, the kgsl worker thread is erroneously ranked right below
Android's audio threads in terms of priority.
The kgsl worker thread is in the critical path for rendering frames to
the display, so increase its priority to match the priority of the
display commit threads.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
This results in no change in structure size on 64-bit machines as it
fits in the padding between the gfp_t and the void *. 32-bit machines
will grow the structure from 8 to 12 bytes. Almost all radix trees are
protected with (at least) a spinlock, so as they are converted from
radix trees to xarrays, the data structures will shrink again.
Initialising the spinlock requires a name for the benefit of lockdep, so
RADIX_TREE_INIT() now needs to know the name of the radix tree it's
initialising, and so do IDR_INIT() and IDA_INIT().
Also add the xa_lock() and xa_unlock() family of wrappers to make it
easier to use the lock. If we could rely on -fplan9-extensions in the
compiler, we could avoid all of this syntactic sugar, but that wasn't
added until gcc 4.6.
Link: http://lkml.kernel.org/r/20180313132639.17387-8-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[@RealJohnGalt: adapt to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
In kgsl_mem_entry_create, access map_count only if entry is allocated
successfully to avoid invalid access.
Change-Id: I57bce1aec2da6a27b6d13dbee96ed86a45c9660c
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Use a6x crashdumper register memory end location to know
the crashdumper status completion. This will avoid AHB
traffic while crashdumper was active in snapshot dumping
and fixes the slave timeout issue.
Change-Id: Ic24e75557297c6a1a3f2ad7893f4d8d308f9943c
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Rohan Sethi <rohsethi@codeaurora.org>
When memdesc_sg_virt returns error in kgsl_setup_anon_useraddr function,
the gpu address registered in SVM region will not be deregistered.
This change deregisters the gpu address on memdesc_sg_virt failure.
Change-Id: Ic99167e283a0c6331bb9f5f0b608b6cdb3c918e4
Signed-off-by: Neeraja P <neerp@codeaurora.org>
In kgsl_process_private_new() function there is inconsistency
in the refcount of current process PID. Fix this to avoid
overflowing of reference counter leading to use after free
of this struct.
Change-Id: I6291b9a05e139337e7f8471d0f9409fc839969a3
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
When SVM is being used there can only be one GPU address assigned
to the memory descriptor. Don't allow the GPU address to be changed
after it has been negotiated the first time by a process.
Change-Id: Ic0dedbad2a1b3ccdc2c1598a6c501b2be288d64e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
It shouldn't be illegal for memory descriptors to have multiple virtual
memory mappings under certain circumstances. If that is the case
tracking a single usermem address for each memdesc no longer makes much
sense. Get rid of the memdesc->usermem member and use an atomic counter
to track mappings instead.
Change-Id: Ic0dedbad31bafcd1019ccc8e68657cb7e3c72727
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
There is a possibility of sharing process_private between two unrelated
processes due to PID wrapping. In kgsl_process_private_new(), instead
of checking numeric TGID, compare the unique pid pointer of the current
process with that of the existing processes in kgsl process list to
allow sharing of process_private data judiciously. Also, in all required
functions get TGID/PID of a process from its struct pid.
Change-Id: I0e3d5d79275cdb3f3c304fb36322ad56b0d0b227
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
Don't allow IOCTL_KGSL_MAP_USER_MEM to import user memory that was
already allocated and mapped by KGSL in the first place. Remapping
memory never makes sense and it messes up reference counting in the
pools.
Change-Id: Ic0dedbade96ac6b30dcbbb794bf57a597f1bb351
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Don't allow IOCTL_KGSL_MAP_USER_MEM to import user memory that was
already allocated and mapped by KGSL in the first place. Remapping
memory never makes sense and it messes up reference counting in the
pools.
Change-Id: Ic0dedbade96ac6b30dcbbb794bf57a597f1bb351
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
For GMU fault handling, GX may be off. So do not trigger
GX halt or soft reset if GX is off.
CX halt may still be initiated as GBIF HALT and HALT ACK
registers are powered by CX GDSC.
Change-Id: Ibf00c75802b6c7124821b24ef85076f3e62d4ad2
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
On targets which have GMU, it is recommended to halt GBIF GX
and CX and soft reset the GPU to make recovery more robust.
This sequence also helps to recover successfully in case of
stall-on-fault.
Change-Id: Ie642a8f99aa6f4aca7c31f7e769d1ef14b4b60df
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
Power ctrl_flags will prevent the GPU power collapse when the
user has overwritten the force_rail_on, force_clk_on etc. This
will result into GPU wakeup problems in case power collapse
hasn’t happened during the hang recovery.
Change-Id: Ib1e86bbb70b2b71b8f8820692d13ce3ab6200db0
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
Crashdumper requires its context bank initialized and a valid pagetable
attached. So skip crasdumper if this is not the case during recovery.
This check is required because GMU might leave GX HS ON before we
initialize MMU during GPU wake up which in turn will trigger crashdumper
while collecting snapshot.
Change-Id: I6b3852718139cd2a2241b526755bfc797ac1f76a
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
When VM_MAYWRITE flag is used during mmap(), mprotect()
can be used later to change the protection of memstore
to allow write. Make sure this does not happen by
removing VM_MAYWRITE from the vm_flags of vma.
Change-Id: I6f69f05858ea40611d512cfa796caabeaa88cdb5
Signed-off-by: Indira Biruduraju <ibirudur@codeaurora.org>
User should not be provided address out of SVM region.
Return error for any such requests from user.
Change-Id: If149044039b156f8192f405714f5c1a0571004e7
Signed-off-by: gkiranku <gkiranku@codeaurora.org>
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Mark the scratch buffer as privileged so that it can only be accessed by
GPU through the ringbuffer. To accomplish this, we need to:
1. Move the preemption data out of the scratch buffer.
2. Disable the shadow rptr feature.
3. Trigger RPTR update from GPU using a WHERE_AM_I packet.
4. Add support for the new ucode.
Change-Id: I9b388f55f53b69028b9bbb2306cb43fd1297c52f
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
In kgsl_ioctl_gpuobj_import(), user memory of type KGSL_USER_MEM_TYPE_ADDR
can also lead to setting up a dma buffer. When attaching mem entry to
process fails, dma buffer attachment is cleaned up only in case of
KGSL_USER_MEM_TYPE_DMABUF. Similar situation can arise in case of
kgsl_ioctl_map_user_mem(). Fix this by obtaining user memory type from
the memdesc flags.
Change-Id: I502bd0ae19241802e8f835f20391b2ce67999418
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
When gpu-quirk-cx-gdsc is defined, cx_gdsc will not be disabled from
HLOS, so use regulator_is_enabled api to get the dummy status of cx_gdsc.
Change-Id: Ied2a54687d9438610116bf4a96a4843fdbc05c56
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Reset CM3 during GMU suspend to make sure that CM3
stays in proper state before turning it on.
Change-Id: I6b40a498de261842ca9cedf5eadfea5b689c5073
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Ensure that CM3 configuration is always set to default value
before taking CM3 out of reset. Also make sure that we
read/modify this register when we send NMI to GMU.
Change-Id: Ic9c4506c04c5e7dd1cabf12901fa53636e2ed9c7
Signed-off-by: Oleg Perelet <operelet@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Mark the scratch buffer as privileged so that it can only be accessed by
GPU through the ringbuffer. To accomplish this, we need to:
1. Move the preemption data out of the scratch buffer.
2. Disable the shadow rptr feature.
3. Trigger RPTR update from GPU using a WHERE_AM_I packet.
4. Add support for the new ucode.
Change-Id: I9b388f55f53b69028b9bbb2306cb43fd1297c52f
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Add the interrupt handler to cause a snapshot when the
GPC interrupt is received for A6xx.
Change-Id: I6eabde0f2bdfc3997bf380055246c2cbdada7cdf
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
Consider a scenario where a context is valid when the check is made in
adreno_dispatcher_queue_cmds(), but by the time we reach _track_context(),
context has been detached. We would try to delete the entry from the
active context list as part of detaching the context though the entry is
not added yet. Now in _track_context() the context is actually added. When
the context is finally destroyed, we would be left with invalid entry in
the list. Next time when a context is added, an attempt would be made to
use a freed entry. Fix this by moving the entry deletion part under
drawctxt lock.
Change-Id: Idab7cbf10987598b3e6395b2d50c20d1990d1f02
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
Some targets require bigger secure mapping size
in GPU address space to support multiple instances
of DRM video playback.
Change-Id: I63d507da75b6a7ac87f975ddff6ed4736e3f5df8
Signed-off-by: Hai Li <hali@codeaurora.org>
There could be a situation where GPU comes out of ifpc after a
fenced write transaction but before reading AHB_FENCE_STATUS from
KMD, it goes back to ifpc due to inactivity.
Put a keep alive vote before doing fenced write for CP_RB_WPTR to
avoid such unlikely scenario.
Change-Id: Ibe0391b39cedf64e2dfa78ab0bbcda0fc8746c88
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Add A504 GPUID and initial settings to support
graphics functionality on SDM429.
Change-Id: I3e967cea59cd8d5eb687ba5701a80689a24c0475
Signed-off-by: Amit Kushwaha <kushwaha@codeaurora.org>
We have a situation where the page count value is non-zero but the
pages pointer is pointing to memory that is already freed. We then
go on to access this invalid pages pointer to free the pages that
have already been freed. We now check for the validity of the pages
pointer before attempting to free it. Also set the page count to 0
before freeing pages and set the pages pointer to NULL after freeing
pages.
Change-Id: I2b8e63a5f2ad2245f0068214b8925b147435d5db
Signed-off-by: Raghu Ananya Arabolu <rarabolu@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
The regulator_is_enabled() API doesn't guarantee that CX gdsc has
collapsed at hardware. There could be a vote on the GDSC from another
subsystem like TZ. So poll the CX GDSCR register to ensure that CX has
indeed collapsed.
Change-Id: Id98c5318d5358b16f4277cb5d96027add63ad801
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Currently, we call dma_buf_map_attachment() with dma direction
DMA_TO_DEVICE and DMA_FROM_DEVICE while calling
dma_buf_unmap_attachment(). A mismatch of DMA direction during map,
unmap or sync of a buffer triggers a warning when CONFIG_DMA_API_DEBUG
is enabled like the below one:
[6.994847] CPU: 7 PID: 785 at dma-debug.c:1153 check_unmap+0x664/0xd3c
[6.994852] Kernel panic - not syncing: panic_on_warn set ...
[6.994852]
[6.994859] CPU: 7 PID: 785 Comm: android.hardwar Tainted:
G S O 4.14.117-g3254dd9dae41-ab6213388 #1
[6.994862] Hardware name: Qualcomm Technologies, Inc.
[6.994866] Call trace:
[6.994873] dump_backtrace+0x0/0x1f0
[6.994877] show_stack+0x14/0x1c
[6.994883] dump_stack+0xa8/0xe0
[6.994887] panic+0x1ac/0x3a4
[6.994890] __stack_chk_fail+0x0/0x18
[6.994893] report_bug+0x148/0x184
[6.994896] bug_handler+0x28/0x84
[6.994899] brk_handler+0x80/0x13c
[6.994902] do_debug_exception+0xc4/0x14c
[6.994905] el1_dbg+0x18/0x74
[6.994907] check_unmap+0x664/0xd3c
[6.994911] debug_dma_unmap_sg+0x8c/0x160
[6.994916] ion_unmap_dma_buf+0x1f4/0x270
[6.994920] dma_buf_unmap_attachment+0x24/0x38
[6.994925] kgsl_destroy_ion+0xa8/0xd0
[6.994928] kgsl_mem_entry_destroy+0x8c/0x14c
[6.994932] kgsl_ioctl_gpuobj_free+0x388/0x420
[6.994936] kgsl_ioctl_helper+0x118/0x148
[6.994939] kgsl_ioctl+0x30/0xbc
[6.994942] do_vfs_ioctl+0x5cc/0x910
[6.994945] SyS_ioctl+0x88/0x94
[6.994948] el0_svc_naked+0x34/0x38
We can fix these warnings by using a consistent dma direction during
map, unmap and sync which is DMA_BIDIRECTIONAL because GPU may read
or write from this buffer.
Change-Id: I3f9c7c27418e5e7d0db44761fa68d27560aa8aaf
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
Signed-off-by: Sebanti Das <sebadas@codeaurora.org>
Do not enable Limits Management, Peak Power Detection, And
SP/TP hardware controlled power collapse feature by default.
These features should be enabled by defining in gpulist of
the target.
Without this fix respective sysfs entries will show
incorrect values.
Change-Id: I78b3cd856dc5b684023bad023ad4c96fd2bdd946
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Currently adreno_snapshot() tries to dump remaining IB1 size
if the active IB1 base address is not present in ringbuffer
which is not enough to debug GPU hang.
So, try to calculate the maximum possible size that it can
dump from IB1 base address and add it to snapshot dump.
Change-Id: I029fb8cddab7999001a2934ce49cb5ff884c21bf
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
Currently pages stats NR_INDIRECTLY_RECLAIMABLE_BYTES is
subtracted even though page is not present in the pool. Add
a check to ensure that page stats is subtracted when page is
pulled out from the kgsl pool.
Change-Id: I5823177d7e242db25aeca2da5a9ddf6d1982859b
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Sebanti Das <sebadas@codeaurora.org>
This change retrieves number of macrotiling channels from
device tree, configures the RBBM hardware accordingly, and
passes it to user as a property.
Change-Id: I8dce177451e7e2c0dd29dc9a91e99f0e63895a96
Signed-off-by: Hai Li <hali@codeaurora.org>
Add gpu_frequency trace during SLUMBER entry and exit. This is
needed to track GPU frequency across idle and active state
transitions.
Change-Id: Ib782805a1776e4c0fb879fc34dc2e1cd11cf6791
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Updating the trace log location to prevent NULL pointer
access for adreno_dev->next_rb.
There are chances that interrupt for preemption complete
comes before driver could log this trace, and that will
lead to NULL pointer access, because while handling this
interrupt next_rb would be set to NULL.
Change-Id: I096aeccab72e36eb94608d7d96cef3b72051dd25
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
In the existing code, due to dynamic allocation of SMMU
context banks, gfx3d_secure is allotted CB 0 followed by
gfx3d_user with CB 1. This affects per process pagetable
functionality which uses GPU path which updates TTBR0 of
SMMU CB0 by default. This poses issue for targets which
do not have support for Dynamic GPU Aperture programming
in TZ. Move defaultpagetable creation for user context to
kgsl_iommu_init, prior to securepagetable initialization
so that gfx3d_user is allotted CB 0 and gfx3d_secure with
CB 1.
Change-Id: Idf203502281eb2738032425c0132d325fc412094
Signed-off-by: Amit Kushwaha <kushwaha@codeaurora.org>
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>