Commit Graph

80 Commits

Author SHA1 Message Date
Chingling Wang
91e187c982 MGS-7915 gpu: Add shader and tiler utilization
Add shader and tiler time in debugfs dvfs_utilization
so that gputop can add shader and tiler utilization in page 4.

Signed-off-by: Chingling Wang <chingling.wang@nxp.com>
Reviewed-by: Jiyu Yang <jiyu.yang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:54 +08:00
Chingling Wang
6a6a1513df MGS-7869 gpu: use u64 for dvfs_utilization output
gputop issue u32 type will make busy_time and idle_time overflow,
which resulting crazy output in kernle debugfs dvfs_utilization output data

Signed-off-by: Chingling Wang <chingling.wang@nxp.com>
Reviewed-by: Jiyu Yang <jiyu.yang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:54 +08:00
Jiyu Yang
451966cce4 MGS-8128 gpu: fix page-isolation/page-free race
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
(cherry picked from commit 425d9bee92e304ec53f53279103223915ac15bc5)
Reviewed-by: Wujian sun <wujian.sun_1@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:53 +08:00
Jiyu Yang
810d42edf3 MGS-8080 gpu: keep flushing MMU addr util no user
Change-Id: I20d207ce5125c2733f6bb6202e916e6e16904ade
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
(cherry picked from commit 71024e54b222ae9f08658c40f32cd84b879e2333)
Reviewed-by: Wujian sun <wujian.sun_1@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:53 +08:00
Jiyu Yang
1b7dfb97b1 MGS-8080 gpu: Unmap the USER_IO pages
Change-Id: I5b1888024550a20800359d86bfb64e5531a2aef2
(cherry picked from commit 2c8e299fef2444c9ef045094434e185113e511ff)
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>

Reviewed-by: Wujian sun <wujian.sun_1@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:53 +08:00
Jiyu Yang
227a52dc69 MGS-8080 gpu: Unmap the USER_IO pages
Change-Id: I5016937b6ed0b266cee1e66788e8ec0a38309eb9
(cherry picked from commit 91553b26b17cd22c4537e9d0a870fd7d42b75b4a)

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Reviewed-by: Wujian sun <wujian.sun_1@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:52 +08:00
Jiyu Yang
a3040a1a76 MGS-7751 gpu: Remove UAF during ctx termination
Remove UAF during ctx termination
Change-Id: I9fb60cae7b576c0836196dc0c64771bd0be229f9
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Signed-off-by: Jessie Hao <juan.hao@nxp.com>
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-06-20 11:26:52 +08:00
Jiyu Yang
1045958fd4 LF-15186-2 gpu: remove IMX_GPU_BLK_CTRL
same as LF-11706 in lf-6.12.y, need use the latest SM dev branch

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Reviewed-by: Jason Liu <jason.hui.liu@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-04-29 11:50:40 +08:00
Jiyu Yang
55018aa9dd LF-15186-1 gpu: remove gpumix block ctrl
same as LF-11706 in lf-6.12.y, add directive for the gpumix reset control,
which has been moved into SM.

Change-Id: Ide9d01e34cd6b9061d177f70c6caacb785732f22
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Signed-off-by: Jessie Hao <juan.hao@nxp.com>
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Reviewed-by: Jason Liu <jason.hui.liu@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-04-29 11:50:40 +08:00
Jiyu Yang
90d64edc8c LF-13187 gpu: extend the fence timeout to 5s
extend the fence timeout to 5s, although it will be cut off to
MAX_TIMEOUT_MS(4500) on host side

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-10-17 17:03:33 +09:00
Jiyu Yang
5ae0bc8914 LF-13489 gpu: enable pm warning check in debug build
fix below kernel panic when printk level is 7.

arm-scmi firmware:scmi: timed out in resp(caller: do_xfer+0xd8/0x1b4)
scmi_protocol scmi_dev.1: Message for 993 type 0 is not expected!
arm-scmi firmware:scmi: timed out in resp(caller: do_xfer+0xd8/0x1b4)
mali 4d900000.gpu: PROTM_PEND: Not waiting
SError Interrupt on CPU2, code 0x00000000be000011 -- SError
CPU: 2 PID: 570 Comm: mali-gpuq-kthre Not tainted 6.6.36-lts-next-gd23d64eea511 #1
Hardware name: NXP i.MX95 19X19 board (DT)
pstate: a04000c9 (NzCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : pm_callback_power_on+0xe4/0x100
lr : pm_callback_power_on+0xdc/0x100
sp : ffff80008554bb90
x29: ffff80008554bb90 x28: ffff80008332d9c0 x27: ffff0000c4f1c200
x26: ffff80008332d9a0 x25: 0000000000000001 x24: 000000000000bbf8
x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000000001
x20: ffff8000833239f8 x19: ffff800083321000 x18: 0000000000000006
x17: 303a646d63203030 x16: 3031386666666664 x15: 6637303030307830
x14: 3a746120342d302d x13: 3330303030303030 x12: 3030303030303232
x11: 78303a646d632030 x10: 3030313866666666 x9 : 3035392d5550473a
x8 : 6575657571203a75 x7 : 205d333937343732 x6 : ffff0000805d5190
x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
Kernel panic - not syncing: Asynchronous SError Interrupt
CPU: 2 PID: 570 Comm: mali-gpuq-kthre Not tainted 6.6.36-lts-next-gd23d64eea511 #1
Hardware name: NXP i.MX95 19X19 board (DT)
Call trace:
 dump_backtrace+0x90/0xe8
 show_stack+0x18/0x24
 dump_stack_lvl+0x48/0x60
 dump_stack+0x18/0x24
 panic+0x324/0x380
 nmi_panic+0x8c/0x90
 arm64_serror_panic+0x6c/0x78
 arm64_is_fatal_ras_serror+0x3c/0xac
 do_serror+0x5c/0x70
 el1h_64_error_handler+0x30/0x48
 el1h_64_error+0x64/0x68
 pm_callback_power_on+0xe4/0x100
 kbase_pm_clock_on+0x90/0x2c8
 kbase_pm_do_poweron+0x20/0x84
 kbase_pm_update_active+0xe0/0x13c
 kbase_hwaccess_pm_gpu_active+0x10/0x1c
 kbase_pm_context_active_handle_suspend_locked+0xa4/0xd0
 scheduler_pm_active_handle_suspend+0x7c/0x110
 scheduler_wakeup+0x74/0x94
 kbase_csf_scheduler_queue_start+0xc0/0x328
 kbase_csf_process_queue_kick+0xac/0x1b0
 kbase_csf_scheduler_kthread+0xa94/0xd28
 kthread+0x110/0x114

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
2024-10-08 12:13:09 +09:00
Jiyu Yang
a366cbc3a1 MGS-7574 gpu: skip the huge fence timeout print
skip the huge fence timeout print by default,
set gpu_fence_print_skip to 0 if necessary

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-10-08 12:13:09 +09:00
Jiyu Yang
85a5c904a9 LF-13276 gpu: get the simple_ondemand data from dts
the upthreshold downdifferential can be updated via dts

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-10-08 12:13:09 +09:00
Jiyu Yang
52040ff196 MA-22754 gpu: enable the power trace
enable the power trace as Android cts required
Revert "MGS-7623 gpu: disable the power trace by default"
This reverts commit 387c0e6dfc.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-10-08 12:13:09 +09:00
Jiyu Yang
ec64aa82d7 LF-12970 gpu: remove the clk initial due to clk notifier change
Revert "LF-12970 gpu: init gpu frequency at 500MHz"
Revert "LF-12971 gpu: gpu_active_counter for debug print"

This reverts commit 8c25e35bf9.
This reverts commit 8b1eec00c2.
2024-10-08 11:28:03 +09:00
Jiyu Yang
1c9d2e28b1 LF-12971 gpu: add gpu clk notifier
add gpu clk notifier based on the CCF(clock control framework) due to
no POST_RATE_CHANGE message from the SCMI protocol

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-10-08 11:08:55 +09:00
Jiyu Yang
73589cf114 LF-13177 gpu: Using Worst-Case Size in Unmapped Area topdown Search
This commit addresses the unmapped area search not ending its loop
operation issue. The change applies the worst-case size to the
Maple-Tree (kernel 6.1.x) search as well, matching the cases with the

GPUCORE-43479

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-08-19 15:20:43 +08:00
Jiyu Yang
964f5d7d32 MGS-7792 gpu: rollback the mali specific unmap
roll back the mali specific unmap to r47p0 although it fix LF-12433,
this unmap function will block the ps command return after the
application run serveral times

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-08-05 16:36:09 +09:00
Jiyu Yang
8c25e35bf9 LF-12971 gpu: gpu_active_counter for debug print
gpu_active_counter for debug print only

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-30 12:38:51 +09:00
Jiyu Yang
8b1eec00c2 LF-12970 gpu: init gpu frequency at 500MHz
init gpu frequency at 500MHz to address the DVFS failure that arises
when the start frequency is 1GHz.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2024-07-29 19:05:10 +09:00
Jiyu Yang
79a10f4312 LF-12971 gpu: print the freq scaling for debug
print the freq scaling for debug only
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-25 17:47:31 +09:00
Jiyu Yang
6af0984c5d MGS-7375 [#nxp] initialize the struct
fix below build error when CONFIG_KASAN=y

drivers/gpu/arm/midgard/mali_kbase_ioctl_helpers.h:77:22: note: ‘param’ declared here
   77 |                 type param;                                                            \
      |                      ^~~~~
drivers/gpu/arm/midgard/mali_kbase_core_linux.c:1666:17: note: in expansion of macro ‘KBASE_HANDLE_IOCTL_INOUT’
 1666 |                 KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_VERSION_CHECK_RESERVED,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
In function ‘instrument_copy_from_user_before’,
    inlined from ‘_copy_from_user’ at ./include/linux/uaccess.h:148:3,
    inlined from ‘copy_from_user’ at ./include/linux/uaccess.h:183:7,
drivers/gpu/arm/midgard/mali_kbase_core_linux.c:1672:3:
./include/linux/kasan-checks.h:38:27: error: ‘param’ may be used uninitialized [-Werror=maybe-uninitialized]
   38 | #define kasan_check_write __kasan_check_write
./include/linux/instrumented.h:129:9: note: in expansion of macro ‘kasan_check_write’
  129 |         kasan_check_write(to, n);
      |         ^~~~~~~~~~~~~~~~~

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-25 17:47:31 +09:00
Jiyu Yang
9df13ee761 MGS-7375 [#nxp] fix build error when kasan enable
fix below build error when CONFIG_KASAN=y

    inlined from ‘int_id_overrides_write’ at drivers/gpu/arm/midgard/mali_kbase_pbha_debugfs.c:96:6:
./include/linux/kasan-checks.h:38:27: error: ‘raw_str’ may be used uninitialized [-Werror=maybe-uninitialized]
   38 | #define kasan_check_write __kasan_check_write
./include/linux/instrumented.h:129:9: note: in expansion of macro ‘kasan_check_write’
  129 |         kasan_check_write(to, n);
      |         ^~~~~~~~~~~~~~~~~

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-25 17:47:31 +09:00
Jiyu Yang
69ecec4cdc MGS-7798 gpu: make the temperature poll thread freezable
make the poll temperature thread freezable, and invoke
the try_to_freeze() in the poll thread

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Tested-by: Xu Yang <xu.yang_2@nxp.com>
2024-07-18 14:55:48 +09:00
Jiyu Yang
636f4e47cf MGS-7798 gpu: print the freq scaling info
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-18 14:55:48 +09:00
Jiyu Yang
9f83ae4960 MGS-7621-2 [#nxp] get the perf domain from dts
get the perf domain from dts

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-10 12:44:57 +09:00
Jiyu Yang
35ab0ec45a MGS-7621-1 [#nxp] change for GPU freq scaling
use PM(Power Management) domain perf API for
GPU freq scaling instead of clk_set_rate
in CCF(Clock Control Framework)

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-10 12:44:57 +09:00
Jiyu Yang
5a6806b531 LF-10864 [#nxp] gpu: get resource by name
mali: get resource by name

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-10 12:44:57 +09:00
Jiyu Yang
c0ca9327ba MGS-7756 gpu: Integrate Mali DDK r50p0
- Reject non-protected allocations containing the BASE_MEM_PROTECTED memory flag.
- Reject allocations containing the BASE_MEM_DONT_NEED memory flag (it is only settable).
- Reject allocations containing the BASE_MEM_UNUSED_BIT_xx memory flags.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
b431f2249c MGS-7751 gpu: Improve handling of page metadata after migration
Handling of page metadata after migration in kbase_mmu_migrate_page()
has been made slightly safer. Only if the page is still in the
ALLOCATED_MAPPED state is it safe to access and update the
metadata. There's no problem if the page became NOT_MOVABLE.
It is an error, instead, if the page has changed to any other
state.

The kbase_set_phy_alloc_page_status() helper must be called
while keeping the region lock to prevent race conditions where
the pages of a GPU VA region could be set to NOT_MOVABLE
while a page migration is in progress.

TI2: 1151297 (page migration tests, ps 7)
TI2: 1151300 (DDK precommit, ps 7)

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
a09dae8b30 MGS-7751 gpu: fix UAF caused by page migration fail
fix the UAF(use after free) caused by page migration fail

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
284a3d13c2 MGS-7751 gpu: fix race between shrinker and map
Race between shrinker and map of GPU memory can lead to use after free

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
ab98d02acf MGS-7702 gpu: Integrate Mali DDK r49p0
- Made the SAME_VA memory flag queryable.

- Re-allow child process to do supported file operations (like mmap, ioctl
  read, poll) on the file descriptor of mali device that was inherited
  from the parent process.

- Implement support for setting GPU Timestamp Offset register.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
dbfa2837c1 MGS-7612 gpu: Integrate Mali DDK r48p0
- Add support for CS_FAULT reporting to userspace
- Made the BASE_MEM_IMPORT_SYNC_ON_MAP_UNMAP and BASE_MEM_KERNEL_SYNC memory
   flags queryable.
- Implement support for HWC block state availability.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:19 +09:00
Jiyu Yang
387c0e6dfc MGS-7623 gpu: disable the power trace by default
gpu: disable the power trace
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:18 +09:00
Jiyu Yang
3bec717542 MGS-7715 no reset glitch from gpu clock
no reset glitch from gpu clock

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:18 +09:00
Jiyu Yang
cbdc09637a MGS-7645-2 update the gpu interrupt name
whose name can be distinguished in the /proc and ftrace.

$ cat /proc/interrupts | grep gpu
253:     809687	0	0	0	0	0     GICv3 321 Level     job-4d900000.gpu
254:          1	0	0	0	0	0     GICv3 322 Level     mmu-4d900000.gpu
255:      92515	0	0	0	0	0     GICv3 320 Level     gpu-4d900000.gpu

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-07-01 16:12:18 +09:00
Jiyu Yang
2dfda55bfa MGS-7686 fix the UAF in KCPU queue
fix the UAF(use after free) in KCPU queue

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-05-07 21:47:46 +08:00
Jiyu Yang
baee9a20b2 MGS-7687 align to 512 entries for MMU page table
align to 512 entries for MMU page table
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-05-06 10:51:33 +09:00
Jiyu Yang
4c23b5a0a8 MGS-7687 invalidate GPU cache when page teardown
invalidate GPU cache when PGD page teardown

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-05-06 10:51:33 +09:00
Jiyu Yang
0994d15bb1 MGS-7687 recovery only when success to alloc
recovery only when success to alloc
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-05-06 10:51:33 +09:00
Jiyu Yang
beedd1af3f MGS-7628 [#arm] fix use-after-free memory handle
fix use-after-free via additional CPU mappings
to pages.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-04-01 14:13:39 +08:00
Jiyu Yang
ed8f075f8d MGS-7343 [#nxp] enable the GPU runtime PM
Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2024-04-01 14:13:39 +08:00
Jiyu Yang
20bdfc9c36 MGS-7531 [#nxp] mali gpu: default plat is imx
mali gpu: default platform is imx, instead of devicetree
remove the tests in linux kernel

Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-27 11:17:25 +08:00
Jiyu Yang
cb5637f13a MGS-7531 [#mali] gpu: Integrate Mali DDK r47p0
1. Disallows changing the sharability on the GPU of imported dma-bufs
to BASE_MEM_COHERENT_SYSTEM using KBASE_IOCTL_MEM_FLAGS_CHANGE.
2. Implement full block state support for hardware counters.
3. add imx platform instead of devicetree

Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-27 11:16:30 +08:00
Jiyu Yang
c72487fafc MGS-7531-2 [#nxp] update the include path
update the cflags in order to build out-of-tree.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-25 15:56:17 +08:00
Jiyu Yang
f832913afb MGS-7531-1 [#nxp] reorder the mali gpu header
move the mali gpu related header into drivers/gpu/arm
in order to build out-of-tree.

Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-25 15:55:47 +08:00
Eric Guo
20ff7c794e MGS-7415 [#nxp] increase DEFAULT_PROGRESS_TIMEOUT
In OpenCL-CTS allocation test, GPU firmware reports Iterator
PROGRESS_TIMER timeout again. Use 5s as default progress timeout
value is not enough for i.MX95 in current situation,
increase it to 10s.

Signed-off-by: Eric Guo <eric.guo@nxp.com>
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-14 18:23:14 +08:00
Jiyu Yang
f403fea487 MGS-7462 [#nxp] mali gpu: fix suspend/resume crash
MGS-7457: implemented GPU suspend/resume feature without Q-channel in A0,
This feature in Mali GPU kernel driver will be dropped in B0 SW releases.

reset the GPUMIX when resume and open, otherwise the CPU will be in WFI.

Reviewed-by: Xianzhong Li <xianzhong.li@nxp.com>
Reviewed-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-12-11 18:17:24 +08:00
Jiyu Yang
031e1f9ec2 MGS-7413 [#mali] VX504X08X-SW-99002-r46p0-01eac0
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-11-27 15:17:01 +08:00