32 Commits

Author SHA1 Message Date
Hareesh Gundu
553b3a31f4 [BACKPORT]msm: kgsl: Add support for KGSL_PROP_VK_DEVICE_ID
Usermode driver expect vulkan device id info from kernel.
Add new KGSL_PROP_VK_DEVICE_ID property support to provide
vk-device-id information.

Change-Id: Ib4f6872fcd3a956caeaad6e7c9f534d7c8e87305
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
2024-07-03 13:14:12 -03:00
Sultan Alsawaf
ec4fee61d7 msm: kgsl: Dispatch commands using a master kthread
Instead of coordinating between a worker when dispatching commands and
abusing a mutex lock for synchronization, it's faster to keep a single
kthread dispatching commands whenever needed. This reduces GPU
processing latency.

[@0ctobot: Adapted for msm-4.9, this reverts commit:
2eb74d7 ("msm: kgsl: Defer issue commands to worker thread")]

Change-Id: I5d3fd2dde07ff641feaf4fdc93e5d2b423bcb23d
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
2024-07-02 11:42:54 -03:00
Matthew Wilcox
cdc42a714c
xarray: add the xa_lock to the radix_tree_root
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: azrim <mirzaspc@gmail.com>
2022-06-30 14:15:40 +00:00
Tim Murray
3bec1c629f
kgsl: add low_prio_worker thread
Adds a new CFS thread for freeing GPU memory. Improves performance
when tearing down processes (eg, via LMK) and not blocking currently
running UI from submitting work to the GPU.

Test: boots, works
Bug: 137140296
Bug: 137927078

Change-Id: I47b42691862b01501a77bce0965d8be7538c1d26
Signed-off-by: Tim Murray <timmurray@google.com>
Signed-off-by: Sean Callanan <spyffe@google.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:39 +07:00
Park Ju Hyung
135de7a5ea
gpu: msm: Disable adreno snapshot, coresight and trace
Co-authored-by: celtare21 <celtare21@gmail.com>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:18:00 +07:00
Sultan Alsawaf
c56590f19f
msm: kgsl: Wake GPU upon receiving an ioctl rather than upon touch input
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: azrim <mirzaspc@gmail.com>
2022-04-06 13:17:31 +07:00
Archana Sriram
b8501b9902 msm: kgsl: Compare pid pointer instead of TGID for a new process
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>
2020-11-17 20:52:48 -08:00
Puranam V G Tejaswi
2fd40f7c71 msm: kgsl: make stats updation atomic
There is a chance of messing up per process stats if something
like a free and allocation happen at the same time for memory
belonging to the same process. Similarly mapsize of memdesc can
also go bad because of concurrent access. So make per process
stats and mapsize of memdesc atomic. Also use scnprintf()
instead of snprintf().

Change-Id: I5da1cf368d523768d0b267b314394612934a620d
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
2019-12-16 11:03:14 +05:30
Harshdeep Dhatt
72e194c4c2 msm: kgsl: Disable deprecated ioctls
Disabling sparse ioctls as they are deprecated.

Change-Id: I5a4c78ec96fad4cda29a61d090e8bfb798123e3f
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
2019-09-19 17:57:52 +05:30
qctecmdr
34f87e89f4 Merge "msm: kgsl: check if state change to suspend succeeds" 2019-06-11 17:40:14 -07:00
Puranam V G Tejaswi
f9602119cf msm: kgsl: check if state change to suspend succeeds
Check the return value of kgsl_pwrctrl_change_state()
when requested state is suspend. This call can fail
and we encounter adverse effects, if we proceed without
checking if the call succeeded. For instance, in case of
_preemption_store(), it is fatal to change ringbuffer,
when state change to suspend fails. Also add a helper
function that changes a given flag safely, only after
successful state change to suspend.

Change-Id: I8a929cc201d127baeaabed194655ac73a8032b2f
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
2019-06-11 18:12:06 +05:30
Thomas (Wonyoung) Yun
38145572bb msm: kgsl: hyp assign secure pages to HLOS during hibernation
Secure memory cannot be preserved during hibernation.
This change is to first check and fail the hibernation
if there is secure context. Then hyp assign kgsl internal
secure buffer to HLOS during hibernation.

Change-Id: I8879294ed357ef09201bd430bdbece84de324fa9
Signed-off-by: Thomas (Wonyoung) Yun <wyun@codeaurora.org>
2019-06-06 12:05:53 -04:00
Thomas Yun
be7b93d834 msm: kgsl: unload/reload zap shader
Unload zap shader during device hibernation and reload it
during resume otherwise scm calls during post hibernation
GPU initialization will fail as there is possibility that
TZ driver is not aware of the hibernation.

Change-Id: I1f62fb97cbc8e6c3e3536d4d5260a543ca15b685
Signed-off-by: Suprith Malligere Shankaregowda <supgow@codeaurora.org>
Signed-off-by: Thomas Yun <wyun@codeaurora.org>
2019-06-06 11:44:09 -04:00
Hareesh Gundu
39aad57546 msm: kgsl: Add per context fault properties
Add per-context properties to count the number of faults
for each context. This will help out to identify faulting
context really faulted on its own command or not.

Change-Id: Ifd74e32f1f95a345645c10c01c33c5ef14bdcbcd
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
2019-05-20 21:53:45 +05:30
qctecmdr
283630173c Merge "msm: kgsl: add kgsl stats to vm_stat and rss_stat counters" 2019-03-29 00:59:14 -07:00
Puranam V G Tejaswi
700518d5eb msm: kgsl: add kgsl stats to vm_stat and rss_stat counters
Update the vm_stat counter NR_UNRECLAIMABLE_PAGES to
account for the total memory allocated. Update the vm_stat
counter NR_INDIRECTLY_RECLAIMABLE_BYTES to account for the
memory held in pools. Update the rss_stat counter
MM_UNRECLAIMABLE to account for the memory allocated and
memory imported per process.

Change-Id: I302834502c21376136d7b5081024812b0cecd150
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
2019-03-27 15:33:49 +05:30
Puranam V G Tejaswi
4541f68e2e msm: kgsl: correct per process stat maintenance
In functions like gpumem_alloc_entry(), per process
stats are updated after kgsl_mem_entry_attach_process()
returns success. But in case of failure, per process
stats are decremented, though they are not incremented.
Fix this by isolating stat updation from
kgsl_mem_entry_detach_process(). Also take into account
the memory from sparse allocations.

Change-Id: I6e2bc1880bdda15aa75d546d0dc3d34c63cd7dba
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
2019-03-26 16:34:17 +05:30
Deepak Kumar
9c5a7a4949 msm: kgsl: Use correct checks for GPMU related functionality
Use "gmu_core_gpmu_isenabled" check for all GPMU related
functionality instead of "gmu_core_isenabled" as later will
return true even when ADRENO_GPMU feature flag is not defined.

Change-Id: Ic577052d8c1cc52965e07c557b178fec444c3613
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
2019-03-25 11:47:34 +05:30
Amit Kushwaha
fba0ca00a8 msm: kgsl: create sysfs entries to expose memory usage
Added sysfs entries to show kgsl memory usage statistics.
gpumem_mapped: kgsl memory mapped in the process address space.
gpumem_unmapped: kgsl allocated memory but not mapped in process.
imported_mem: graphics memory not allocated by the kgsl.

Below is the sysfs path for new entries:
/sys/class/kgsl/kgsl/proc/<pid>/

Change-Id: I08c2014d28dc0ca1e2b54ebf966d00143b303b54
Signed-off-by: Amit Kushwaha <kushwaha@codeaurora.org>
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
2018-10-29 17:32:43 +05:30
qctecmdr Service
26a24a0f11 Merge "msm: kgsl: Log context type in case of GPU faults" 2018-09-22 08:24:11 -07:00
Rajesh Kemisetti
41f4de5bb7 msm: kgsl: Log context type in case of GPU faults
Log context type in case of GPU page faults or GPU faults.
Also add Vulkan context type to distinguish it from GL.

Change-Id: I7b93bf645b80abe82f2d6aa379296b2fffceb684
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
2018-09-19 16:48:24 +05:30
Deepak Kumar
af1062c92e msm: kgsl: Dump both GMU and GPU state for GMU faults
GPU state especially command processor state is important
to debug GMU fault. If GPU is powered ON, dump both GMU
and GPU state for GMU faults to make sure all required
state needed for debug is captured.

Change-Id: I71b359cd944a12cb19c419bca0254fd2fa468328
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
2018-09-06 21:46:11 -07:00
Hareesh Gundu
cba91098c3 msm: kgsl: Consolidate some gmu functions
Move some gmu functions to gmu_core so that
those can reusable without reimplementing on
other kind of gmu.

Change-Id: Ie083bd541f716eabf56da8cef4e7606a2595d482
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
2018-07-26 16:02:58 +05:30
qctecmdr Service
7dc59489dc Merge "msm: kgsl: Keep a list of perfcounters per file descriptor" 2018-07-20 15:46:54 -07:00
Urvashi Agrawal
c087b71fa9 msm: kgsl: Add L3 performance hint
Add software path to bump the l3 frequency using a
performance hint from user space in I/O coherence cases.

Change-Id: I559fecf0dbbf79ebe3972db2a65bde6b69063fc9
Signed-off-by: Urvashi Agrawal <urvaagra@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
2018-07-17 11:19:14 +05:30
Harshdeep Dhatt
316528b1ba msm: kgsl: Keep a list of perfcounters per file descriptor
We need a list of perfcounters for each kgsl file descriptor, in
order to gracefully release any perfcounter allocated using that fd
in the event that the process dies unexpectedly or doesn't release
the perfcounters properly. This prevents possible leakage of
perfcounters referenced by a process.

Change-Id: Ib443282f26a0cbdad656fa0f82fb62c6de871fb0
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
2018-07-10 14:29:08 +05:30
Hareesh Gundu
14584cbed5 msm: kgsl: Abstract out GMU from the GMU core
A6xx GPUs have different variants of GMU. Abstract
out current GMU implementation under GMU core,
so that it’s easy to add new code for different
GMU variants.

Change-Id: I0dae15bc6905b869c34bbbdebc0b5e9e2f7ff25b
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
2018-05-03 07:20:55 +05:30
qctecmdr Service
ce313f04e1 Merge "msm: kgsl: Keep dispatcher halted during SUSPEND state" 2018-04-25 03:08:22 -07:00
Deepak Kumar
b210e6e05e msm: kgsl: Correctly limit max number of contexts per process
Read and increment context count atomic variable under a lock
to avoid race condition between read and increment. This is
necessary to make sure no process goes beyond the specified
context limit.

Change-Id: I483e2ac169beaff49e19b8ef1b46541f6eb740b0
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
2018-04-25 00:04:47 -07:00
Deepak Kumar
a6e44af561 msm: kgsl: Keep dispatcher halted during SUSPEND state
Increment GPU halt variable after successful transition
to SUSPEND state to halt dispatcher. This is necessary to
make sure that any pending dispatcher threads don't go
ahead and try to wake up GPU in SUSPEND state.

Change-Id: I806884306549afbef0dfa92ea14903cc7a47d347
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
2018-04-24 23:57:37 -07:00
Kyle Piefer
a1ba2bba1c msm: kgsl: Make snapshot priority configurable
Add a setting and a corresponding sysfs node that
controls whether new snapshots overwrite old
snapshots in case they are unrecoverable. This
prioritization of unrecoverable snapshots already
exists, but we want the option to turn it off.
By default, keep this option on.

Change-Id: Ia7dfa5f0f4bbb45fcd72fe769adb366f00b0fcbc
Signed-off-by: Kyle Piefer <kpiefer@codeaurora.org>
Signed-off-by: Urvashi Agrawal <urvaagra@codeaurora.org>
2018-03-07 11:08:57 -08:00
Urvashi Agrawal
bd1b09b2cc msm: kgsl: Add Qualcomm GPU driver
Snapshot of the Qualcomm Adreno GPU driver (KGSL) as of msm-4.9
commit e023d014d2039d59d0999e73984ccf0cc6e60bc7 (msm: pcie:
fix PCIe L0s and L1 ASPM support).

Fixed compile errors,checkpatch issues and API changes:
	*  Rename function _copy_from_user() to kgsl_copy_from_user()
	*  Fixup vm_fault API
	*  Rename fence API to dma_fence API
	*  Stop using scm_call()
	*  Fixup header includes
	*  Fix IDR API usage
	*  Fix __mutex_owner usage

Change-Id: Ib35ff402b3b0a14a94bc2568b34be6364ef2e882
Signed-off-by: Urvashi Agrawal <urvaagra@codeaurora.org>
2018-02-16 16:15:51 -08:00