Re: [PATCH 6/8] drm/panthor: Explicit expansion of locked VM region

Nicolas Frattaroli
2026-05-06T15:15:22Z

On Tuesday, 5 May 2026 16:05:12 Central European Summer Time Ketil Johnsen wrote:
> Currently the panthor_vm_lock_region() function will implicitly expand
> an already locked VM region. This can be problematic because the caller
> do not reliably know if it needs to call panthor_vm_unlock_region()
> or not.
>
> Worth noting, there is currently no known issues with this as the code
> is written today.
>
> This change introduces panthor_vm_expand_region() which will only work
> if there is already a locked VM region. This again means that the
> original lock and unlock functions can work as a pair. This pairing is
> needed for subsequent protected memory changes.
>
> Signed-off-by: Ketil Johnsen <ketil.johnsen@arm.com>
> ---
> drivers/gpu/drm/panthor/panthor_mmu.c | 69 +++++++++++++++++++--------
> 1 file changed, 50 insertions(+), 19 deletions(-)
>

While trying this series, I attempted my usual
`modprobe -r panthor && modprobe panthor protected_heap_name=default_cma_region`.

Unfortunately, it oopses when attempting to unmap the sg for a bo labeled
"FW section" on panthor module unload, and I bisected it to this patch.

The oops:

[ 598.515550] Unable to handle kernel paging request at virtual address 0000000000400267
[ 598.516864] Mem abort info:
[ 598.517676] ESR = 0x0000000096000004
[ 598.518560] EC = 0x25: DABT (current EL), IL = 32 bits
[ 598.520414] SET = 0, FnV = 0
[ 598.521275] EA = 0, S1PTW = 0
[ 598.522099] FSC = 0x04: level 0 translation fault
[ 598.523069] Data abort info:
[ 598.524311] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 598.525566] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 598.526850] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 598.527905] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000104056000
[ 598.529019] [0000000000400267] pgd=0000000000000000, p4d=0000000000000000
[ 598.530170] Internal error: Oops: 0000000096000004 [#1] SMP
[ 598.531158] Modules linked in: btusb btrtl btmtk btintel btbcm bluetooth ecdh_generic ecc kpp snd_soc_hdmi_codec cfg80211 r8169 rfkill_gpio pwm_fan rfkill snd_soc_es8316 rtc_hym8563 rk805_pwrkey at24 fusb302 tcpm aux_hpd_bridge display_connector snd_soc_simple_card phy_rockchip_samsung_hdptx phy_rockchip_usbdp rockchip_thermal typec phy_rockchip_naneng_combphy rockchip_saradc industrialio_triggered_buffer kfifo_buf rockchipdrm inno_hdmi dw_dp hantro_vpu rockchip_vdec dw_mipi_dsi2 v4l2_jpeg v4l2_vp9 rockchip_rga dw_mipi_dsi v4l2_h264 synopsys_hdmirx v4l2_dv_timings spi_rockchip_sfc videobuf2_dma_contig videobuf2_dma_sg v4l2_mem2mem videobuf2_memops dw_hdmi_qp onboard_usb_dev analogix_dp videobuf2_v4l2 videobuf2_common snd_soc_rockchip_i2s_tdm dw_hdmi videodev mc drm_display_helper nvme cec panthor(-) drm_gpuvm drm_exec gpu_sched drm_dp_aux_bus drm_dma_helper drm_client_lib nvme_core drm_kms_helper drm pci_endpoint_test backlight snd_soc_audio_graph_card snd_soc_simple_card_utils fuse dm_mod
[ 598.541237] CPU: 6 UID: 0 PID: 806 Comm: modprobe Not tainted 7.1.0-rc2-00726-g8ab0a3092b56-dirty #2 PREEMPT
[ 598.542733] Hardware name: Radxa ROCK 5T (DT)
[ 598.543746] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 598.544991] pc : dma_unmap_sg_attrs (kernel/dma/mapping.c:0)
[ 598.546021] lr : panthor_gem_free_object (include/linux/dma-mapping.h:565 drivers/gpu/drm/panthor/panthor_gem.c:308 drivers/gpu/drm/panthor/panthor_gem.c:469) panthor
[ 598.547180] sp : ffff80008835bb90
[ 598.548123] x29: ffff80008835bb90 x28: ffff00012610bf00 x27: 0000000000000000
[ 598.549412] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
[ 598.550696] x23: ffff000127194600 x22: ffff0001271943d0 x21: ffff000118671000
[ 598.551984] x20: ffff000127194200 x19: ffff000127194600 x18: 00000000002ab980
[ 598.553273] x17: 00000000002ab980 x16: ffffa39a6b372a04 x15: 0000000000000000
[ 598.554568] x14: 0000000000000010 x13: 0000000000000000 x12: 000000000000003c
[ 598.555864] x11: 0000000000000002 x10: ffff000100a5d000 x9 : ffff000118671000
[ 598.557164] x8 : ffff000102f8b490 x7 : ffff000149569000 x6 : ffff000149569000
[ 598.558461] x5 : ffff000100faa7e8 x4 : 0000000000000000 x3 : 0000000000000000
[ 598.559763] x2 : 0000000000000010 x1 : ffff000127194000 x0 : 000000000040000f
[ 598.561069] Call trace:
[ 598.561961] dma_unmap_sg_attrs (kernel/dma/mapping.c:0) (P)
[ 598.563038] panthor_gem_free_object (include/linux/dma-mapping.h:565 drivers/gpu/drm/panthor/panthor_gem.c:308 drivers/gpu/drm/panthor/panthor_gem.c:469) panthor
[ 598.564218] drm_gem_object_free (drivers/gpu/drm/drm_gem.c:1148) drm
[ 598.565386] panthor_kernel_bo_destroy (include/linux/kref.h:65 include/drm/drm_gem.h:565 include/drm/drm_gem.h:578 drivers/gpu/drm/panthor/panthor_gem.c:1317) panthor
[ 598.566575] panthor_fw_unplug (drivers/gpu/drm/panthor/panthor_fw.c:1306) panthor
[ 598.567705] panthor_device_unplug (drivers/gpu/drm/panthor/panthor_device.c:103) panthor
[ 598.568878] panthor_remove (drivers/gpu/drm/panthor/panthor_drv.c:1846) panthor
[ 598.569991] platform_remove (drivers/base/platform.c:1435)
[ 598.571029] device_release_driver_internal (drivers/base/dd.c:619 drivers/base/dd.c:1352 drivers/base/dd.c:1375)
[ 598.572209] driver_detach (drivers/base/dd.c:1438)
[ 598.573237] bus_remove_driver (drivers/base/bus.c:825)
[ 598.574304] driver_unregister (drivers/base/driver.c:277)
[ 598.575363] platform_driver_unregister (drivers/base/platform.c:920)
[ 598.576494] cleanup_module (drivers/gpu/drm/panthor/panthor_devfreq.c:134) panthor
[ 598.577617] __arm64_sys_delete_module (kernel/module/main.c:863 kernel/module/main.c:804 kernel/module/main.c:804)
[ 598.578751] invoke_syscall (arch/arm64/kernel/syscall.c:35 arch/arm64/kernel/syscall.c:49)
[ 598.579794] el0_svc_common (arch/arm64/kernel/syscall.c:121)
[ 598.580842] do_el0_svc (arch/arm64/kernel/syscall.c:140)
[ 598.581862] el0_svc (arch/arm64/kernel/entry-common.c:723)
[ 598.582853] el0t_64_sync_handler (arch/arm64/kernel/entry-common.c:742)
[ 598.583949] el0t_64_sync (arch/arm64/kernel/entry.S:594)

Kind regards,
Nicolas Frattaroli