Hi Boris,

The v2 patch is causing kernel panic when run glmark2 on NXP i.MX95 board, can 
you please fix the kernel error?

root@imx952evk:~# glmark2-es2-wayland
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    Mali-G310v2 MC1 (Panfrost)
    GL_VERSION:     OpenGL ES 3.1 Mesa 26.2.5 (git-ce3cfa04fd)
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=32 stencil=0 samples=0
    Surface Size:   800x600 windowed
=======================================================
[build] use-vbo=false:[   67.127273] Internal error: Oops: 000000009600004f 
[#1]  SMP
[   67.127437] ------------[ cut here ]------------
[   67.132920] Modules linked in: overlay polyval_ce snd_soc_fsl_asoc_card 
snd_soc_imx_audmux snd_soc_imx_card wave5 mxc_jpeg_encdec coda wave5_ctrl 
v4l2_jpeg snd_soc_fsl_sai snd_soc_fsl_micfil flexcan imx_pcm_dma 
snd_soc_fsl_utils snd_soc_fsl_asrc can_dev snd_soc_wm8962 snd_soc_dmic
[   67.137564] refcount_t: addition on 0; use-after-free.
[   67.137565]  pwm_fan
[   67.137596] WARNING: CPU: 1 PID: 753 at /usr/src/kernel/lib/refcount.c:25 
refcount_warn_saturate+0x120/0x144
[   67.162359]  panthor
[   67.167482] Modules linked in:
[   67.169658]  moal(O)
[   67.179459]  overlay
[   67.181634]  gpu_sched
[   67.184676]  polyval_ce
[   67.186851]  drm_gpuvm
[   67.189027]  snd_soc_fsl_asoc_card
[   67.191376]  mlan(O)
[   67.193811]  snd_soc_imx_audmux
[   67.196159]  drm_exec
[   67.199548]  snd_soc_imx_card
[   67.201723]  fuse
[   67.204852]  wave5
[   67.207114]
[   67.210069]  mxc_jpeg_encdec
[   67.211988] CPU: 3 UID: 0 PID: 49 Comm: kworker/u16:1 Tainted: G        W  O 
       6.18.54-2.2.0-g9ef05b9c96ba #1 PREEMPT
[   67.213987]  coda
[   67.215470] Tainted: [W]=WARN, [O]=OOT_MODULE
[   67.218337]  wave5_ctrl
[   67.229439] Hardware name: NXP i.MX952 EVK board (DT)
[   67.231355]  v4l2_jpeg
[   67.235698] Workqueue: panthor-vm-bind drm_sched_run_job_work [gpu_sched]
[   67.238132]  snd_soc_fsl_sai
[   67.243168]
[   67.245516]  snd_soc_fsl_micfil
[   67.252285] pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.255153]  flexcan
[   67.256635] pc : dma_fence_signal_timestamp_locked+0x60/0x13c
[   67.259766]  imx_pcm_dma
[   67.266706] lr : dma_fence_signal+0x38/0x80
[   67.268881]  snd_soc_fsl_utils
[   67.274610] sp : ffff800080bcbc80
[   67.277132]  snd_soc_fsl_asrc
[   67.281301] x29: ffff800080bcbca0
[   67.284343]  can_dev
[   67.287645]  x28: 0000000000000000
[   67.290600]  snd_soc_wm8962
[   67.293902]  x27: 0000000000000000
[   67.296077]  snd_soc_dmic
[   67.299466]
[   67.302248]  pwm_fan
[   67.305636] x26: ffff00008001c028
[   67.308245]  panthor
[   67.309727]  x25: ffff0000871a5a20
[   67.311903]  moal(O)
[   67.315205]  x24: ffff0000871a5978
[   67.317380]  gpu_sched
[   67.320768]
[   67.322944]  drm_gpuvm
[   67.326332] x23: ffff0000a7b8ccc0
[   67.328681]  mlan(O)
[   67.330163]  x22: ffff00008001c000
[   67.332512]  drm_exec
[   67.335814]  x21: ffff800080bcbc88
[   67.337989]  fuse
[   67.341378]
[   67.343640]
[   67.347028] x20: ffff0000a7b8cd00
[   67.348946] CPU: 1 UID: 0 PID: 753 Comm: glmark2-es2-way Tainted: G        W 
 O        6.18.54-2.2.0-g9ef05b9c96ba #1 PREEMPT
[   67.350426]  x19: ffff0000a7b8cd00
[   67.351909] Tainted: [W]=WARN, [O]=OOT_MODULE
[   67.355210]  x18: ffff0003fe070940
[   67.366572] Hardware name: NXP i.MX952 EVK board (DT)
[   67.369960]
[   67.374303] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.377691] x17: 015e000000000001
[   67.382727] pc : refcount_warn_saturate+0x120/0x144
[   67.384209]  x16: 015c800000017000
[   67.391150] lr : refcount_warn_saturate+0x120/0x144
[   67.394452]  x15: 0000000000000000
[   67.399314] sp : ffff80008a8039f0
[   67.402703]
[   67.407565] x29: ffff80008a8039f0
[   67.410954] x14: ffff000080488090
[   67.414256]  x28: ffff000087d43540
[   67.415738]  x13: 0000000000000000
[   67.419040]  x27: 0000000000000000
[   67.422342]  x12: 0000000000000001
[   67.425730]
[   67.429119]
[   67.432508] x26: 0000000000000000
[   67.435896] x11: 00000000000000c0
[   67.437378]  x25: 0000000000000000
[   67.438861]  x10: 0000000000000b00
[   67.442162]  x24: 0000000000000001
[   67.445464]  x9 : ffff0000a6c25780
[   67.448853]
[   67.452242]
[   67.455630] x23: ffff000087a5dd00
[   67.459019] x8 : ffff0000a6c257c8
[   67.460501]  x22: ffff0000a7f11900
[   67.461983]  x7 : ffff0003fe067b68
[   67.465285]  x21: ffff80008a803a60
[   67.468587]  x6 : 0000000000020000
[   67.471976]
[   67.475364]
[   67.478753] x20: ffff0000877d9e00
[   67.482142] x5 : ffff000087d25f49
[   67.483624]  x19: ffff0000877d9ee8
[   67.485106]  x4 : ffff000086217df8
[   67.488408]  x18: 0000000000000038
[   67.491710]  x3 : 0000000000011f86
[   67.495098]
[   67.498487]
[   67.501876] x17: 0000000000000000
[   67.505264] x2 : ffff0000a7b8cd30
[   67.506747]  x16: 0000000000000000
[   67.508229]  x1 : 0000000f99956451
[   67.511530]  x15: ffffb1d212ac7018
[   67.514832]  x0 : ffffb1d20f6ef6e0
[   67.518221]
[   67.521610]
[   67.524998] x14: fffffffffffcd0cf
[   67.528388] Call trace:
[   67.529869]  x13: 0a2e656572662d72
[   67.531352]  dma_fence_signal_timestamp_locked+0x60/0x13c (P)
[   67.534653]  x12: 657466612d657375
[   67.537089]  dma_fence_signal+0x38/0x80
[   67.540477]
[   67.546206]  drm_sched_fence_finished+0x18/0x60 [gpu_sched]
[   67.549595] x11: 0000000000000058
[   67.553417]  drm_sched_job_done.isra.0+0x180/0x1a0 [gpu_sched]
[   67.554899]  x10: 0000000000000018
[   67.560454]  drm_sched_run_job_work+0x388/0x3a0 [gpu_sched]
[   67.563756]  x9 : ffffb1d212ac7098
[   67.569571]  process_one_work+0x150/0x298
[   67.572960]
[   67.578515]  worker_thread+0x180/0x2f4
[   67.581904] x8 : 0000000000057fa8
[   67.585899]  kthread+0x12c/0x204
[   67.587381]  x7 : 00000000000002e0
[   67.591116]  ret_from_fork+0x10/0x20
[   67.594418]  x6 : 0000000000000001
[   67.597637] Code: f90007e0 f9000415 f9400e80 f9000be0 (f9000015)
[   67.601022]
[   67.604586] ---[ end trace 0000000000000000 ]---
[   67.607973] x5 : ffff0003fe034408
[   67.614049] note: kworker/u16:1[49] exited with irqs disabled
[   67.615531]  x4 : ffff4e31eb67e000
[   67.620189] note: kworker/u16:1[49] exited with preempt_count 1
[   67.623435]  x3 : ffff000087d43540
[   67.623440] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000087d43540
[   67.623448] Call trace:
[   67.651404]  refcount_warn_saturate+0x120/0x144 (P)
[   67.656274]  dma_resv_add_fence+0x228/0x254
[   67.660450]  dma_buf_ioctl+0x608/0x720
[   67.664194]  __arm64_sys_ioctl+0xa4/0xf4
[   67.668112]  invoke_syscall.constprop.0+0x40/0xe0
[   67.672809]  el0_svc_common.constprop.0+0x38/0xe0
[   67.677506]  do_el0_svc+0x1c/0x28
[   67.680817]  el0_svc+0x38/0x120
[   67.683954]  el0t_64_sync_handler+0xa0/0xe4
[   67.688123]  el0t_64_sync+0x198/0x19c
[   67.691781] ---[ end trace 0000000000000000 ]---

Message from syslogd@imx952evk at Wed Dec  2 03:35:50 2026 ...
kernel: Inte[   67.705983] Unable to handle kernel execute from non-executable 
memory at virtual address ffff800080bcbc88
rnal error: Oops:[   67.710988] ------------[ cut here ]------------
[   67.715864] Mem abort info:
 000000009600004f[   67.715867]   ESR = 0x000000008600000f
[   67.715870]   EC = 0x21: IABT (current EL), IL = 32 bits
[   67.715873]   SET = 0, FnV = 0
[   67.715876]   EA = 0, S1PTW = 0
[   67.715878]   FSC = 0x0f: level 3 permission fault
[   67.715881] swapper pgtable: 4k pages, 48-bit VAs, pgdp=000000009228e000
[   67.715885] [ffff800080bcbc88] pgd=100000010002b403, p4d=100000010002b403, 
pud=100000010002c403, pmd=10000001003f9403, pte=0000000000000000
[   67.715900] Internal error: Oops: 000000008600000f [#2]  SMP
[   67.715904] Modules linked in: overlay
[   67.722053] refcount_t: saturated; leaking memory.
[   67.724740]  polyval_ce snd_soc_fsl_asoc_card snd_soc_imx_audmux 
snd_soc_imx_card wave5 mxc_jpeg_encdec coda
[   67.730016] WARNING: CPU: 0 PID: 739 at /usr/src/kernel/lib/refcount.c:19 
refcount_warn_saturate+0xc8/0x144
[   67.735244]  wave5_ctrl v4l2_jpeg
[   67.738286] Modules linked in:
[   67.741414]  snd_soc_fsl_sai
[   67.746189]  overlay
[   67.752871]  snd_soc_fsl_micfil
[   67.765360]  polyval_ce
[   67.771002]  flexcan
[   67.774738]  snd_soc_fsl_asoc_card
[   67.779513]  imx_pcm_dma
[   67.789315]  snd_soc_imx_audmux
[   67.799030]  snd_soc_fsl_utils
[   67.802332]  snd_soc_imx_card
[   67.805374]  snd_soc_fsl_asrc
[   67.808243]  wave5
[   67.810418]  can_dev
[   67.813547]  mxc_jpeg_encdec
[   67.815982]  snd_soc_wm8962
[   67.818158]  coda
[   67.821546]  snd_soc_dmic
[   67.824068]  wave5_ctrl
[   67.827197]  pwm_fan
[   67.830239]  v4l2_jpeg
[   67.833194]  panthor
[   67.836149]  snd_soc_fsl_sai
[   67.838153]  moal(O)
[   67.840327]  snd_soc_fsl_micfil
[   67.843195]  gpu_sched
[   67.845977]  flexcan
[   67.847893]  drm_gpuvm
[   67.850501]  imx_pcm_dma
[   67.852937]  mlan(O)
[   67.855112]  snd_soc_fsl_utils
[   67.857461]  drm_exec
[   67.859636]  snd_soc_fsl_asrc
[   67.862505]  fuse
[   67.864680]  can_dev
[   67.867809]
[   67.870157]  snd_soc_wm8962
[   67.872337] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Tainted: G      D W  O      
  6.18.54-2.2.0-g9ef05b9c96ba #1 PREEMPT
[   67.874681]  snd_soc_dmic
[   67.877206] Tainted: [D]=DIE, [W]=WARN, [O]=OOT_MODULE
[   67.879379]  pwm_fan
[   67.882421] Hardware name: NXP i.MX952 EVK board (DT)
[   67.884683]  panthor
[   67.887639] pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.889554]  moal(O)
[   67.891729] pc : 0xffff800080bcbc88
[   67.893211]  gpu_sched
[   67.895993] lr : rcu_core+0x260/0x668
[   67.906661]  drm_gpuvm
[   67.909272] sp : ffff80008000bea0
[   67.914392]  mlan(O)
[   67.916567] x29: ffff80008000bee0
[   67.921603]  drm_exec
[   67.923778]  x28: ffff800080bcbc88
[   67.930720]  fuse
[   67.932895]  x27: 0000000000000000
[   67.936370]
[   67.938719]
[   67.942370] CPU: 0 UID: 0 PID: 739 Comm: weston Tainted: G      D W  O       
 6.18.54-2.2.0-g9ef05b9c96ba #1 PREEMPT
[   67.944717] x26: 0000000000000000
[   67.948020] Tainted: [D]=DIE, [W]=WARN, [O]=OOT_MODULE
[   67.950194]  x25: ffffb1d212b37cc0
[   67.953496] Hardware name: NXP i.MX952 EVK board (DT)
[   67.955758]  x24: 000000000000000a
[   67.959147] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.961062]
[   67.964451] pc : refcount_warn_saturate+0xc8/0x144
[   67.965932] x23: ffff0003fe03f780
[   67.967414] lr : refcount_warn_saturate+0xc8/0x144
[   67.977996]  x22: 0000000000000001
[   67.981299] sp : ffff800089dab910
[   67.986420]  x21: ffff80008000bec0
[   67.989809] x29: ffff800089dab910
[   67.994845]
[   67.998233]  x28: ffff0000870eea80
[   68.005175] x20: ffff0003fe03f700
[   68.006657]  x27: 0000000000000000
[   68.011433]  x19: 0000000000000002
[   68.014734]
[   68.019510]  x18: ffff0003fe03e940
[   68.022898] x26: 0000000000000000
[   68.026200]
[   68.029589]  x25: ffff000087a5dd01
[   68.032891] x17: ffff4e31eb67e000
[   68.034373]  x24: ffff000087a5dd00
[   68.037762]  x16: ffff800080008000
[   68.041064]
[   68.044453]  x15: 03c997af0cc49398
[   68.047841] x23: 0000000000000001
[   68.049323]
[   68.052712]  x22: 00000000ffffffff
[   68.056014] x14: 000000000000003a
[   68.057496]  x21: ffff800089dab990
[   68.060885]  x13: 0000000000000000
[   68.064186]
[   68.067575]  x12: 0000000000000003
[   68.070964] x20: 0000000000000001
[   68.072446]
[   68.075834]  x19: ffff800089dab978
[   68.079136] x11: ffffb1d212054f70
[   68.080619]  x18: 000000000000000a
[   68.084008]  x10: 00000000efe4b99a
[   68.087309]
[   68.090698]  x9 : 0000000000000000
[   68.094086] x17: 0000000000000000
[   68.095568]
[   68.098957]  x16: 0000000000000000
[   68.102259] x8 : ffff80008000be40
[   68.103741]  x15: 0000000000000000
[   68.107130]  x7 : 0000000000000000
[   68.110432]
[   68.113820]  x6 : fffffdffc29ee300
[   68.117209] x14: 0000000000000000
[   68.118691]
[   68.122080]  x13: 6630303030303638
[   68.125382] x5 : ffffb1d20f6ef728
[   68.126864]  x12: 3030303030303030
[   68.130253]  x4 : fffffdffc29ee320
[   68.133555]
[   68.136943]  x3 : 0000000000150006
[   68.140332] x11: ffff800089dab4ff
[   68.141814]
[   68.145203]  x10: 000000000000005d
[   68.148504] x2 : ffff0000a7b8c1d0
[   68.149987]  x9 : 0000000000000000
[   68.153375]  x1 : ffff0000a7b8ca10
[   68.156677]
[   68.160066]  x0 : ffff0000a7b8ca10
[   68.163454] x8 : 0000000000000001
[   68.164936]
[   68.168325]  x7 : 205d373638353137
[   68.171628] Call trace:
[   68.173109]  x6 : 0000000000000000
[   68.176499]  0xffff800080bcbc88 (P)
[   68.179800]
[   68.183189]  rcu_core_si+0x10/0x1c
[   68.186577] x5 : ffff0003fe01b408
[   68.188059]  handle_softirqs+0xfc/0x240
[   68.191448]  x4 : 0000000000000001
[   68.194750]  __do_softirq+0x14/0x20
[   68.196232]  x3 : 0000000000000000
[   68.199620]  ____do_softirq+0x10/0x20
[   68.202056]
[   68.205445]  call_on_irq_stack+0x30/0x48
[   68.208920] x2 : 0000000000000000
[   68.210402]  do_softirq_own_stack+0x1c/0x40
[   68.213790]  x1 : 0000000000000000
[   68.217093]  __irq_exit_rcu+0xd4/0x10c
[   68.220914]  x0 : ffff0000870eea80
[   68.224303]  irq_exit_rcu+0x10/0x1c
[   68.227778]
[   68.231167]  el1_interrupt+0x3c/0x60
[   68.234816] Call trace:
[   68.236298]  el1h_64_irq_handler+0x18/0x24
[   68.240207]  refcount_warn_saturate+0xc8/0x144 (P)
[   68.243509]  el1h_64_irq+0x6c/0x70
[   68.247677]  dma_resv_iter_walk_unlocked.part.0+0x1d4/0x1f0
[   68.251066]  cpuidle_enter_state+0xac/0x320 (P)
[   68.254801]  dma_resv_get_fences+0x74/0x328
[   68.258190]  cpuidle_enter+0x34/0x50
[   68.261665]  dma_resv_get_singleton+0x3c/0x198
[   68.263147]  do_idle+0x150/0x2c0
[   68.266709]  dma_buf_ioctl+0x13c/0x720
[   68.269145]  cpu_startup_entry+0x38/0x40
[   68.273227]  __arm64_sys_ioctl+0xa4/0xf4
[   68.278002]  secondary_start_kernel+0x124/0x144
[   68.281391]  invoke_syscall.constprop.0+0x40/0xe0
[   68.286946]  __secondary_switched+0xc0/0xc4
[   68.291461]  el0_svc_common.constprop.0+0x38/0xe0
[   68.295634] Code: 00000002 00000000 80bcbcc0 ffff8000 (a7b8ca10)
[   68.299192]  do_el0_svc+0x1c/0x28
[   68.303623] ---[ end trace 0000000000000000 ]---
[   68.303629] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[   68.303633] SMP: stopping secondary CPUs
[   68.306911] Kernel Offset: 0x31d190a00000 from 0xffff800080000000
[   68.306915] PHYS_OFFSET: 0x80000000
[   68.306917] CPU features: 0x100000,00028000,48046281,0400721b
[   68.306921] Memory Limit: none
[   68.379619] ---[ end Kernel panic - not syncing: Oops: Fatal exception in 
interrupt ]---

Best Regards,
Xianzhong

NXP Confidential
-----Original Message-----
From: Boris Brezillon <[email protected]>
Sent: Wednesday, December 2, 2026 12:35 AM
To: Steven Price <[email protected]>; Liviu Dudau <[email protected]>; 
Akash Goel <[email protected]>; Karunika Choo <[email protected]>; Lukas 
Zapolskas <[email protected]>; Chris Diamand <[email protected]>
Cc: Maarten Lankhorst <[email protected]>; Maxime Ripard 
<[email protected]>; Thomas Zimmermann <[email protected]>; David Airlie 
<[email protected]>; Simona Vetter <[email protected]>; Sumit Semwal 
<[email protected]>; Christian König <[email protected]>; Philipp 
Stanner <[email protected]>; [email protected]; 
[email protected]; [email protected]; 
[email protected]; Boris Brezillon 
<[email protected]>; Xianzhong Li <[email protected]>
Subject: [PATCH v2] drm/panthor: Explode container fences to optimize pipelining

If a job is passed a dependency that's coming from the same queue the job is 
targeting, we can get rid of the dependency because of the implicit 
serialization provided by the queue. This will allow us benefit from the 
pipelining provided by the ring buffer (no extra MCU <-> CPU round-trip to have 
the job pushed to the ring buffer).

drm_sched_entity_add_dependency_cb() already has this optimization in place, 
all we need to do is explode the chain/array containers with a
dma_fence_unwrap_for_each() when we add job dependencies.

Signed-off-by: Boris Brezillon <[email protected]>
Cc: Xianzhong Li <[email protected]>
---
Some recent effort to improve job pipelining [1] showed that the MCU <-> CPU 
round-trip that lets us signal job fences adds a non-negligible overhead, and 
this problem seems to be easier and more systematically fixed if it's addressed 
at the KMD side, so here's a patch doing exactly that.

[1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
---
Changes in v2:
- Explode container fences with dma_fence_unwrap_for_each() instead of
  and rely on drm_sched_entity_add_dependency_cb() elimination instead
  of open-coding it
---
 drivers/gpu/drm/panthor/panthor_drv.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_drv.c 
b/drivers/gpu/drm/panthor/panthor_drv.c
index dc8d0191aef4..a527ce86a113 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -7,6 +7,7 @@
 #include <asm/arch_timer.h>
 #endif

+#include <linux/dma-fence-unwrap.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
@@ -612,8 +613,9 @@ panthor_submit_ctx_add_sync_deps_to_job(struct 
panthor_submit_ctx *ctx,
        int ret = 0;

        for (u32 i = 0; i < sync_op_count; i++) {
+               struct dma_fence *fence, *inner_fence;
                struct panthor_sync_signal *sig_sync;
-               struct dma_fence *fence;
+               struct dma_fence_unwrap iter;

                if (!sync_op_is_wait(&sync_ops[i]))
                        continue;
@@ -637,9 +639,16 @@ panthor_submit_ctx_add_sync_deps_to_job(struct 
panthor_submit_ctx *ctx,
                                return ret;
                }

-               ret = drm_sched_job_add_dependency(job, fence);
-               if (ret)
-                       return ret;
+               /* Explode containers so that 
drm_sched_entity_add_dependency_cb() can
+                * eliminate fences that are coming from the same queue.
+                */
+               dma_fence_unwrap_for_each(inner_fence, &iter, fence) {
+                       ret = drm_sched_job_add_dependency(job, inner_fence);
+                       if (ret) {
+                               dma_fence_put(iter.chain);
+                               return ret;
+                       }
+               }
        }

        return 0;

---
base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7

Best regards,
--
Boris Brezillon <[email protected]>

Reply via email to