35281 Commits

Author SHA1 Message Date
Jinfeng Gu
c2ed70f194 BACKPORT: disp: msm: dsi: add null pointer check in dsi_display_dev_remove
This change add display null pointer check in dsi_display_dev_remove.

Change-Id: Ib31756c3b22256d19cbcb508f60de4550e3834e1
Signed-off-by: Jinfeng Gu <quic_gjinfeng@quicinc.com>
2025-06-18 10:53:30 +02:00
Daniel Vetter
0881085b80 drm/vgem: Close use-after-free race in vgem_gem_create
commit 4b848f20eda5974020f043ca14bacf7a7e634fc8 upstream.

There's two references floating around here (for the object reference,
not the handle_count reference, that's a different thing):

- The temporary reference held by vgem_gem_create, acquired by
  creating the object and released by calling
  drm_gem_object_put_unlocked.

- The reference held by the object handle, created by
  drm_gem_handle_create. This one generally outlives the function,
  except if a 2nd thread races with a GEM_CLOSE ioctl call.

So usually everything is correct, except in that race case, where the
access to gem_object->size could be looking at freed data already.
Which again isn't a real problem (userspace shot its feet off already
with the race, we could return garbage), but maybe someone can exploit
this as an information leak.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Hillf Danton <hdanton@sina.com>
Reported-by: syzbot+0dc4444774d419e916c8@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Eric Anholt <eric@anholt.net>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Rob Clark <robdclark@chromium.org>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Change-Id: Ie60eb85499e5fe3cd27118c03829faf9ab67d7bc
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200202132133.1891846-1-daniel.vetter@ffwll.ch
[OP: backport to 4.19: adjusted DRM_DEBUG() -> DRM_DEBUG_DRIVER()]
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[mkbestas: backport to 4.9]
Signed-off-by: Michael Bestas <mkbestas@lineageos.org>
2025-03-02 23:26:35 +01:00
Puranam V G Tejaswi
c39f5c3adb msm: kgsl: Perform cache flush on the pages obtained using get_user_pages()
Consider a scenario where user allocates anonymous memory but does not
write to it. Here the physical pages are not yet allocated. Now when this
memory is requested to be imported, a list of newly allocated zero pages
is obtained using get_user_pages(). Currently cache flush is not done for
these pages and hence GPU sees stale data. Fix this by performing cache
flush on these pages.

Change-Id: Id1e8aa20e8a9de112761732ed92f30c01088840b
Signed-off-by: Puranam V G Tejaswi <quic_pvgtejas@quicinc.com>
2025-03-02 23:26:35 +01:00
Sultan Alsawaf
dd9658622e msm: kgsl: Avoid dynamically allocating small command buffers
Most command buffers here are rather small (fewer than 256 words); it's
a waste of time to dynamically allocate memory for such a small buffer
when it could easily fit on the stack.

Conditionally using an on-stack command buffer when the size is small
enough eliminates the need for using a dynamically-allocated buffer most
of the time, reducing GPU command submission latency.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
2024-08-13 23:40:30 +05:30
Sultan Alsawaf
388342b609 msm: kgsl: Don't allocate memory dynamically for temp command buffers
The temporary command buffer in _set_pagetable_gpu is only the size of a
single page, and _set_pagetable_gpu is never executed concurrently. It
is therefore easy to replace the dynamic command buffer allocation with
a static one to improve performance by avoiding the latency of dynamic
memory allocation.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
2024-08-13 23:40:30 +05:30
Prakash Kamliya
a892b85bfb msm: kgsl: Relax adreno spin idle tight loop
Tight loop of adreno_spin_idle() causing RT throttling.
Relax the tight loop by giving chance to other thread.

Change-Id: Ic23d4551c0cc0b5f2fa7844ca73444d1412d480c
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
2024-08-13 23:40:30 +05:30
Yaroslav Furman
b463d71ac6 drm/sde: sde_fence: don't copy fence names
This is in screen rendering path. Calling snprintf there is unwise.
This also has an advantage of reducing size of struct sde_fence from 152b to 128b.

Change-Id: I26f54537fc13a69a1f726d018a93bde5ef3477ac
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
2024-08-13 23:36:08 +05:30
Sultan Alsawaf
58ceb150b3 msm: kgsl: Use lock-less list for page pools
Page pool additions and removals are very hot during GPU workloads, so
they should be optimized accordingly. We can use a lock-less list for
storing the free pages in order to speed things up. The lock-less list
allows for one llist_del_first() user and unlimited llist_add() users to
run concurrently, so only a spin lock around the llist_del_first() is
needed; everything else is lock-free. The per-pool page count is now an
atomic to make it lock-free as well.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[jjpprrrr: adapted _kgsl_pool_get_page() because k4.9 does not update
vmstat counter for memory held in pools]
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
2024-08-13 23:36:07 +05:30
Sultan Alsawaf
bb2b4a801f msm: kgsl: Don't try to wait for fences that have been signaled
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: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: palaych <palaychm@yandex.ru>
Change-Id: Iea6f84553c4c3d053858021948b18f2421a4d26e
2024-08-13 23:36:07 +05:30
Sultan Alsawaf
ecafe799d0 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.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[0ctobot: Adapted for msm-4.9, this reverts commit:
2eb74d7 ("msm: kgsl: Defer issue commands to worker thread")]
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <raphielscape@outlook.com>
2024-08-13 23:36:07 +05:30
Sultan Alsawaf
4adbb2ba73 msm: kgsl: Remove POPP
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 <sultanxda@gmail.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
(cherry picked from commit b5447fccd96348b0ee0db1d4a4476aeb9b9c0896)
(cherry picked from commit 9c7823e4243eea117c0f8f22e99558a67c8899b0)
Signed-off-by: kdrag0n <dragon@khronodragon.com>
Signed-off-by: Lau <laststandrighthere@gmail.com>
Signed-off-by: Joshua Primero <jprimero155@gmail.com>
Signed-off-by: Jprimero15 <jprimero155@gmail.com>
2024-08-13 23:31:16 +05:30
ctfrommn
3e8ba3b27e msm: kgsl: Increase worker thread priority
Currently, the kgsl worker thread is erroneosly 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 MDSS' kthread (mdss_fb0).

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
2024-08-13 23:28:04 +05:30
Deepak Kumar
4c939ff705 msm: kgsl: Skip state change in idle check, if requested state is NONE
After scheduling the idle work for transitioning to either NAP or SLUMBER
it's possible that requested state can change to NONE if any new workload
comes before kgsl_idle_check is executed or it gets the device mutex.
If this happens, current code calls pwrctrl_change_state which fails as
this is not a legal transition. To prevent this, skip calling
pwrctrl_change_state if requested state is NONE.

Change-Id: Iae535c6e2a3230f9e7e210712990eeb405822f4f
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
2024-08-13 23:26:23 +05:30
Adrian Salido
f843f6283a drm/msm: minimize qos remap updates
Updating qos remap updates requires reading registers to update values,
this adds additional CPU processing when in reality this update is only
needed once.

Bug: 142504774
Change-Id: Iec8d4dfd858b0602db7d2275b6b716dbcffe0d2f
Signed-off-by: Adrian Salido <salidoa@google.com>
2024-08-13 23:26:23 +05:30
Sultan Alsawaf
2df831dfd1 msm: kgsl: Only wake GPU upon ioctl receipt when it isn't awake
The overhead of queuing the power-on worker every time there's an ioctl
received is significant due to the frequency of GPU ioctls. To mitigate
the high overhead, only fire up the power-on worker when the GPU isn't
active.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
2024-08-13 23:25:58 +05:30
Sultan Alsawaf
47a0dce66b 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 <sultanxda@gmail.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
(cherry picked from commit 8e1e3f18f2459f83c9f249b90b6d28eead2bfe0c)
(cherry picked from commit 2b164b3f3d02b423538d71fee1a679a70cabccc6)
Signed-off-by: kdrag0n <dragon@khronodragon.com>
2024-08-13 23:25:58 +05:30
Adrian Salido
6da88c74e1 drm/msm: minimize qos remap updates
Updating qos remap updates requires reading registers to update values,
this adds additional CPU processing when in reality this update is only
needed once.

Bug: 142504774
Change-Id: Iec8d4dfd858b0602db7d2275b6b716dbcffe0d2f
Signed-off-by: Adrian Salido <salidoa@google.com>
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
2024-08-13 23:15:23 +05:30
zeroblade1984
dae28bfbbe gpu: Play with throttling a bit
See if this helps reduce lags when GPU is throttling due to temp limitations.

Signed-off-by: zeroblade1984 <zeroblade1984@gmail.com>
Signed-off-by: negrroo <mohammedaelnaggar1@gmail.com>
2024-08-13 23:13:34 +05:30
DhineshCool
e4a7cf9daf gpu/drm: fix more clang 17 Werrors
drivers/gpu/drm/drm_mipi_dsi.c:1125:28: error: converting the result of '<<' to a boolean; did you mean '(payload[0] << 8) != 0'? [-Werror,-Wint-in-bool-context]
                *brightness = payload[0] << 8 || payload[1];
                                         ^

Signed-off-by: DhineshCool <dhineshcool585@gmail.com>
2024-08-13 23:13:34 +05:30
freak07
6f94470db2 drm:msm: use power efficient workingqueues
(cherry picked from commit bfb90386b3c84c659316eed794aeabb6424f4dab)
(cherry picked from commit cee5b9334dae1781ffc0a9a384e41ca6f20a618f)
(cherry picked from commit c5af35d3b6930fb4bcf6c98e3b06ca4b698c44da)
Signed-off-by: Kanishk <kanishkthederp@gmail.com>
2024-08-13 23:12:00 +05:30
freak07
6f33d4d1ed gpu: drm: use power efficient workingqueues
Change-Id: Id6fe0d3ebf7eabb423f2ec64d79075c0e3ba9e14
Signed-off-by: Henrique Pereira <hlcpereira@pixelexperience.org>
Signed-off-by: PainKiller3 <ninadpatil100@gmail.com>
Signed-off-by: MadeOfGreat <ravenklawasd@gmail.com>
Signed-off-by: CloudedQuartz <ravenklawasd@gmail.com>
2024-08-13 23:11:51 +05:30
Sultan Alsawaf
3374509ed5 msm: kgsl: Relax CPU latency requirements to save power
Relaxing the CPU latency requirement by about 500 us won't significantly
hurt graphics performance. On the flip side, most SoCs have many idle
levels just below 1000 us in latency, with deeper idle levels having
latencies in excess of 2000 us. Changing the latency requirement to
1000 us allows most SoCs to use their deepest sub-1000-us idle state
while the GPU is active.

Additionally, since the lpm driver has been updated to allow power
levels with latencies equal to target latencies, change the wakeup
latency from 101 to 100 for clarity.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: sajidshahriar72543 <sazidshahriar39@gmail.com>
2024-08-13 23:10:57 +05:30
Kanishk
ccb9b87fe5 drivers: enable a few debugs
Signed-off-by: Kanishk <kanishkthederp@gmail.com>
2024-08-13 23:08:30 +05:30
celtare21
83509acb28 gpu: msm: kgsl_pwrctrl: Compile out tracing
Same logic as the previously applied commit:
"gpu: msm: Omit debug/tracing drivers when debug is disabled"

Link: 3bddac5f4a
Signed-off-by: TogoFire <togofire@mailfence.com>
Change-Id: Iac42f12fea137818a9edfab62ddfff81a2fe00c0
Signed-off-by: Dmitrii <bankersenator@gmail.com>
2024-08-13 23:08:30 +05:30
Kanishk
4f0b78de6a drivers: enable a few debugs
Signed-off-by: Kanishk <kanishkthederp@gmail.com>
2024-08-13 23:08:27 +05:30
celtare21
4a088cc4df gpu: msm: kgsl_pwrctrl: Compile out tracing
Same logic as the previously applied commit:
"gpu: msm: Omit debug/tracing drivers when debug is disabled"

Link: 3bddac5f4a
Signed-off-by: TogoFire <togofire@mailfence.com>
Change-Id: Iac42f12fea137818a9edfab62ddfff81a2fe00c0
Signed-off-by: Dmitrii <bankersenator@gmail.com>
2024-08-13 23:08:27 +05:30
Nathan Chancellor
cf438c3f8d kgsl: Shut up about not being able to create debugfs
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: engstk <eng.stk@sapo.pt>
Signed-off-by: mcdachpappe <noreference@web.de>
2024-08-13 23:08:16 +05:30
Danny Lin
c312df7314 drm/msm/sde: Cache register values when performing clock control
Remote register I/O amounts to a measurably significant portion of CPU
time due to how frequently this function is used. Cache the value of
each register on-demand and use this value in future invocations to
mitigate the expensive I/O.

Co-authored-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
2024-08-13 23:08:15 +05:30
Park Ju Hyung
b06b7e1f94 drm/msm: skip sde_dbg compilation altogether
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: engstk <eng.stk@sapo.pt>
Signed-off-by: mcdachpappe <noreference@web.de>
2024-08-13 23:08:15 +05:30
Danny Lin
9dc05d014e drm/msm/sde: Remove register write debug logging
Writing to registers is frequent enough that there is a measurably
significant portion of CPU time spent on checking the debug mask for
whether to log. Remove the check and logging call altogether to
eliminate the overhead.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: engstk <eng.stk@sapo.pt>
Signed-off-by: mcdachpappe <noreference@web.de>
2024-08-13 23:08:15 +05:30
Danny Lin
7785ccd07b drm/msm/sde: Omit debug logging code
We're not going to debug the SDE driver in production. Don't compile the
code at all to reduce the measurably significant overhead in frame commit
hotpaths.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: engstk <eng.stk@sapo.pt>
Signed-off-by: mcdachpappe <noreference@web.de>
2024-08-13 23:08:14 +05:30
Danny Lin
f0ae6dabb1 drm/msm: Omit SDE event log and most debugfs code
The SDE event log is not necessary and hogs a substantial amount of CPU
time on logging events in the frame commit path. Omit the code
altogether along with some other debugfs-related code to fix the waste
of CPU.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: engstk <eng.stk@sapo.pt>
Signed-off-by: mcdachpappe <noreference@web.de>
2024-08-13 23:08:14 +05:30
kdrag0n
e362641479 treewide: silence printk spam
Signed-off-by: kdrag0n <dragon@khronodragon.com>
2024-08-13 23:08:13 +05:30
Raphiel Rollerscaperers
5bbf5d70ff gpu: adreno: Increase data processing limit
Change-Id: Id7821e8336b717737524b8133bed803acafbde62
2024-08-13 23:01:35 +05:30
celtare21
2ec70955a7 kgsl/adreno: Properly set GPU timeout
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: kdrag0n <dragon@khronodragon.com>
Signed-off-by: palaych <palaychm@yandex.ru>
Signed-off-by: Santiago Pintos <santiagoopintos@hotmail.com>
2024-08-13 23:01:35 +05:30
Park Ju Hyung
f90e3a230d adreno: hardcode for a630
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Change-Id: Id241663f8bb1c5988553dc15245e40f4d9b8a779
2024-08-13 23:01:35 +05:30
kdrag0n
78cfdde86b gpu: adreno: only compile Adrneo 6xx driver
We won't be using this with an Adreno 3xx/4xx/5xx GPU.

Signed-off-by: kdrag0n <dragon@khronodragon.com>
Change-Id: I4e3ad6042b8017f8f44832d01c0eb3bb5ea143a2
2024-08-13 23:01:35 +05:30
mady51
07d6276bd2 gpu: adreno: Disable Adreno Driver Logging
Signed-off-by: Twisted Prime <36546624+TwistedPrime@users.noreply.github.com>
2024-08-13 23:01:34 +05:30
freak07
175c4b8fc9 KLAPSE: account for recent KCAL changes
(cherry picked from commit d420ca592bb97d7dab779e041ab5b4f05af701d6)
(cherry picked from commit 4b741d0461489676a7938d5ab3cec7491faa2bc1)
2024-08-13 22:58:16 +05:30
freak07
d915327534 KCAL: change safety measures
(cherry picked from commit 4799884d422a92859529e6ebe8fe3ff3d3ea6f37)
(cherry picked from commit c9bcedcda5028171d953047d335c17697df4ccb2)
2024-08-13 22:58:16 +05:30
flar2
188fabab57 hbm: don't start while screen is off 2024-08-13 22:58:16 +05:30
flar2
2d0ff644df hbm: update for Q 2024-08-13 22:58:16 +05:30
kdrag0n
227d63ae99 drm/msm: dsi-staging: bump backlight dimmer min brightness
1 is unusably low. 3 is a usable value that is still extremely dim.

Signed-off-by: kdrag0n <dragon@khronodragon.com>
2024-08-13 22:58:16 +05:30
freak07
81586dd74d drm: msm: make backlight dimmer compatible with Q changes 2024-08-13 22:58:16 +05:30
Francisco Franco
f952a24cef drm: msm: kcal: make the userspace module param vars static and use short instead of integers
Same reasoning as 20461e4aef

There's no point in using integers where a short is big enough.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
(cherry picked from commit 9940e8d83222e9366b9570f2fe909062f4ff5ab0)
(cherry picked from commit adeb04a337d54dac60d2f0b35e20f440b63493d3)
2024-08-13 22:58:16 +05:30
flar2
febaa75b9b KLAPSE: Modernize sysfs to prevent CFI failure
(cherry picked from commit 62d9fd9301eb73d3a0070f65dc66979418004ff9)
(cherry picked from commit 033961e19d21396700a91e97bc895efdccdfa296)
2024-08-13 22:58:16 +05:30
tanish2k09
48cb2c1655 KLAPSE v4.3 : Bug fixes and thread-safe improvements - Fixed the issue where brightness_factor_auto_enable would keep decreasing brightness on repeated switching, thanks to @flar2 for reporting - Fixed the issue with fadeback_minutes not taking into account enable_klapse - Made pretty much all tunables more thread-safe parallel to the kernel-timer by using flush and pulse where applicable
(cherry picked from commit 2178281b6df26bd77ec6dbe17d9e1fcd2ed36b25)
(cherry picked from commit 7c3710ca172fbdd681e77436f4cec1b38ca05971)
2024-08-13 22:58:16 +05:30
tanish2k09
349fb320df KLAPSE : Fix compilation error, undeclared variable
(cherry picked from commit cec3999879f9a7f2ce6bf3a9664b741efeaa6562)
(cherry picked from commit 7974d8a20033cf0dfb681a466fb620e6885d750f)
2024-08-13 22:58:16 +05:30
tanish2k09
4ebc4c83be KLAPSE v4.2 - Modify klapse_scaling_rate to use a minute value instead of a numeric factor, now more intuitive. Suggestion credit to @flar2 - Fix an issue with brightness_factor where increasing the value would dim the colors further until the next pulse. (brightness_factor without pulse fixes it at the cost of a maximum error of 1 RGB value)
(cherry picked from commit 4d6a0a62f9341b815e6205c4bc85206cf30837dd)
(cherry picked from commit 9ced9e9fcfe17454d56cd843961f9f7e1c4b1c6c)
2024-08-13 22:58:16 +05:30
tanish2k09
b190320348 KLAPSE : Allow fadeback_minutes to be greater than 0 instead of 2
(cherry picked from commit c5183b28bc2d9adb8630a7446ca1593ebf2f858f)
(cherry picked from commit cf638a60a436af4b55aa906453742ca355e1f0e9)
2024-08-13 22:58:15 +05:30