evadot / drm-subtree

WIP drm drivers for FreeBSD
15 stars 9 forks source link

panfrost pinebook pro panics. #14

Closed jsm222 closed 2 years ago

jsm222 commented 3 years ago

FreeBSD 14.0-CURRENT #129 main-n249013-5b27a505a13 pinebook pro. Applying the pull request #10 #12 #13 , and adding this diff:

diff --git a/panfrost/panfrost_drv.c b/panfrost/panfrost_drv.c
index 6dc2362..29e81f8 100644
--- a/panfrost/panfrost_drv.c
+++ b/panfrost/panfrost_drv.c
@@ -748,7 +748,7 @@ panfrost_attach(device_t dev)
                return (ENXIO);
        }

-       if (bus_setup_intr(dev, sc->res[1],
+       if (bus_setup_intr(dev, sc->res[3],
            INTR_TYPE_MISC | INTR_MPSAFE, NULL, panfrost_job_intr, sc,
            &sc->intrhand[0])) {
                device_printf(dev, "cannot setup interrupt handler\n");
@@ -762,7 +762,7 @@ panfrost_attach(device_t dev)
                return (ENXIO);
        }

-       if (bus_setup_intr(dev, sc->res[3],
+       if (bus_setup_intr(dev, sc->res[1],
            INTR_TYPE_MISC | INTR_MPSAFE, NULL, panfrost_gpu_intr, sc,
            &sc->intrhand[2])) {
                device_printf(dev, "cannot setup interrupt handler\n");

I get:

rk_drm0: port found
rk_drm0: Cannot find port with phandle 10
rk_drm_fb_preinit
<6>[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
<6>[drm] No driver support for vblank timestamp query.
rk_drm0: Cannot initialize frame buffer -22
<7>[drm: 0xffff000000861084] 
<7>[drm: 0xffff000000861084] 
<7>[drm: 0xffff0000008887c8] new device created dri/card%d0
<7>[drm: 0xffff000000861138] new minor registered 0
<6>[drm] Initialized rockchip 1.0.0 20201113 for rk_drm on minor 0
rk805_pmu0: registered as a time-of-day clock, resolution 1.000000s
panfrost0: panfrost_gpu_intr: pending 100
panfrost0: GPU revision 2000, id 860
panfrost0: Mali 860, major 2, minor 0, status 0
panfrost0: Features: L2 7120206, Shader 0, Tiler 809, Mem 1, MMU 2830, AS ff, JS 7
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: GPU is powered on
panfrost0: panfrost_gpu_intr: pending 20000
Bad malloc flags: 0
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
malloc_dbg() at malloc_dbg+0x70
malloc() at malloc+0x2c
drm_sched_init() at drm_sched_init+0x1ac
panfrost_job_init() at panfrost_job_init+0xfc
panfrost_irq_hook() at panfrost_irq_hook+0x68
config_intrhook_oneshot_func() at config_intrhook_oneshot_func+0x14
run_interrupt_driven_config_hooks() at run_interrupt_driven_config_hooks+0x90
boot_run_interrupt_driven_config_hooks() at boot_run_interrupt_driven_config_hooks+0x2c
mi_startup() at mi_startup+0x12c
virtdone() at virtdone+0x6c
<7>[drm: 0xffff000000861084] 
<7>[drm: 0xffff0000008887c8] new device created dri/renderD%d128
<7>[drm: 0xffff000000861138] new minor registered 128
<7>[drm: 0xffff000000861084] 
<7>[drm: 0xffff0000008887c8] new device created dri/card%d1
<7>[drm: 0xffff000000861138] new minor registered 1
<6>[drm] Initialized panfrost 1.1.0 20201124 for panfrost on minor 1
ugen0.1: <Generic EHCI root HUB> at usbus0
ugen1.1: <Generic OHCI root HUB> at usbus1
uhub0 on usbus1
uhub0: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
uhub1 on usbus0
uhub1: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
usbus2: 480Mbps High Speed USB v2.0
usbus3: 12Mbps Full Speed USB v1.0
ugen2.1: <Generic EHCI root HUB> at usbus2
uhub2 on usbus2
uhub2: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2
ugen3.1: <Generic OHCI root HUB> at usbus3
uhub3 on usbus3
uhub3: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
usbus4: 5.0Gbps Super Speed USB v3.0
usbus5: 5.0Gbps Super Speed USB v3.0
uhub0: 1 port with 1 removable, self powered
ugen4.1: <Synopsys XHCI root HUB> at usbus4
uhub4 on usbus4
uhub4: <Synopsys XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus4
ugen5.1: <Synopsys XHCI root HUB> at usbus5
uhub5 on usbus5
uhub5: <Synopsys XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus5
Kernel page fault with the following non-sleepable locks held:
uhub3: 1 port with 1 removable, self powered
exclusive sleep mutex process lock (process lock) r = 0 (0xffff000000e74498) locked @ /usr/src/sys/compat/linuxkpi/common/src/linux_current.c:109
stack backtrace:
#0 0xffff0000004e5810 at witness_debugger+0x64
#1 0xffff0000004e69a4 at witness_warn+0x400
#2 0xffff000000791c44 at data_abort+0xa4
#3 0xffff000000770078 at handle_el1h_sync+0x78
uhub4: 2 ports with 2 removable, self powered
uhub1: 1 port with 1 removable, self powered
#4 0xffff0000004541e4 at __mtx_lock_flags+0xa8
#5 0xffff0000006820d8 at linux_alloc_current+0xac
#6 0xffff00000068fd9c at linux_irq_work_init_fn+0x38
#7 0xffff0000004d86dc at taskqueue_run_locked+0x188
#8 0xffff0000004d95f0 at taskqueue_thread_loop+0xc8
#9 0xffff000000431104 at fork_exit+0x74
#10 0xffff000000790d4c at fork_trampoline+0x14
  x0:                1
  x1:                4
  x2: ffff000000985c65
  x3:               3b
  x4:                0
  x5:                7
  x6:                0
  x7:              501
  x8: ffffa0000747f000
  x9: ffff000000c19000
 x10:                1
 x11:               10
 x12:                0
 x13:                0
 x14:            10000
 x15:                1
 x16:            10000
 x17:                0
 x18: ffff0000403e0810
 x19: ffff000000e74370
 x20: ffffa000008bb498
 x21: ffff000000e744b0
 x22:                2
 x23:              102
 x24: ffff000000e74370
 x25: ffff000000c1a000
 x26:                0
 x27:                0
 x28:                0
 x29: ffff0000403e0810
  sp: ffff0000403e0810
  lr: ffff000000682264
 elr: ffff0000006822e4
spsr:         60000045
 far:                d
 esr:         96000004
panic: data abort in critical section or under mutex
cpuid = 0
time = 3
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
vpanic() at vpanic+0x184
panic() at panic+0x44
data_abort() at data_abort+0x27c
handle_el1h_sync() at handle_el1h_sync+0x78
--- exception, esr 0x96000004
find_other_mm() at find_other_mm+0xa8
linux_alloc_current() at linux_alloc_current+0xb4
linux_irq_work_init_fn() at linux_irq_work_init_fn+0x38
taskqueue_run_locked() at taskqueue_run_locked+0x188
taskqueue_thread_loop() at taskqueue_thread_loop+0xc8
fork_exit() at fork_exit+0x74
fork_trampoline() at fork_trampoline+0x14
KDB: enter: panic
[ thread pid 0 tid 100031 ]
Stopped at      kdb_enter+0x44: undefined       f905011
evadot commented 3 years ago

https://cgit.freebsd.org/src/diff/src/arm64/rockchip/rk3399.dtsi?id=5df7ea339a6ba20ce6c2a001807a43a7cc1e9fe8

This changed the order of the interrupts so that might be the cause. @bukinr ?

bukinr commented 3 years ago

@jsm222 it seems your fix is not correct. Based ont @evadot note, It should be: 1 - job, 2 - mmu, 3 - gpu

jsm222 commented 3 years ago

I had an old dtb file from u-boot-ports, it had the older interrupt order. I changed my dtb to match the driver code, i.e 1 - job, 2 - mmu, 3 - gpu but i still get


rk_drm0: port found
rk_drm0: Cannot find port with phandle 10
rk_drm_fb_preinit
<6>[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
<6>[drm] No driver support for vblank timestamp query.
rk_drm0: Cannot initialize frame buffer -22
<6>[drm] Initialized rockchip 1.0.0 20201113 for rk_drm on minor 0
rk805_pmu0: registered as a time-of-day clock, resolution 1.000000s
panfrost0: GPU revision 2000, id 860
panfrost0: Mali 860, major 2, minor 0, status 0
panfrost0: Features: L2 7120206, Shader 0, Tiler 809, Mem 1, MMU 2830, AS ff, JS 7
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: GPU is powered on
panfrost0: panfrost_gpu_intr: pending 20000
Bad malloc flags: 0
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
malloc_dbg() at malloc_dbg+0x70
malloc() at malloc+0x2c
drm_sched_init() at drm_sched_init+0x1ac
panfrost_job_init() at panfrost_job_init+0xfc
panfrost_irq_hook() at panfrost_irq_hook+0x68
config_intrhook_oneshot_func() at config_intrhook_oneshot_func+0x14
run_interrupt_driven_config_hooks() at run_interrupt_driven_config_hooks+0x90
boot_run_interrupt_driven_config_hooks() at boot_run_interrupt_driven_config_hooks+0x2c
mi_startup() at mi_startup+0x12c
virtdone() at virtdone+0x6c
<6>[drm] Initialized panfrost 1.1.0 20201124 for panfrost on minor 1
ugen0.1: <Generic EHCI root HUB> at usbus0
ugen1.1: <Generic OHCI root HUB> at usbus1
uhub0 on usbus1
uhub0: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
uhub1 on usbus0
uhub1: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
usbus2: 480Mbps High Speed USB v2.0
usbus3: 12Mbps Full Speed USB v1.0
ugen2.1: <Generic EHCI root HUB> at usbus2
uhub2 on usbus2
uhub2: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2
ugen3.1: <Generic OHCI root HUB> at usbus3
uhub3 on usbus3
uhub3: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
usbus4: 5.0Gbps Super Speed USB v3.0
usbus5: 5.0Gbps Super Speed USB v3.0
uhub0: 1 port with 1 removable, self powered
ugen4.1: <Synopsys XHCI root HUB> at usbus4
uhub4 on usbus4
uhub4: <Synopsys XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus4
ugen5.1: <Synopsys XHCI root HUB> at usbus5
uhub5 on usbus5
uhub5: <Synopsys XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus5
Kernel page fault with the following non-sleepable locks held:
uhub3: 1 port with 1 removable, self powered
exclusive sleep mutex process lock (process lock) r = 0 (0xffff000000e74498) locked @ /usr/src/sys/compat/linuxkpi/common/src/linux_current.c:109
stack backtrace:
#0 0xffff0000004e5810 at witness_debugger+0x64
#1 0xffff0000004e69a4 at witness_warn+0x400
#2 0xffff000000791c44 at data_abort+0xa4
#3 0xffff000000770078 at handle_el1h_sync+0x78
uhub1: 1 port with 1 removable, self powered
uhub4: 2 ports with 2 removable, self powered
#4 0xffff0000004541e4 at __mtx_lock_flags+0xa8
#5 0xffff0000006820d8 at linux_alloc_current+0xac
#6 0xffff00000068fd9c at linux_irq_work_init_fn+0x38
#7 0xffff0000004d86dc at taskqueue_run_locked+0x188
#8 0xffff0000004d95f0 at taskqueue_thread_loop+0xc8
#9 0xffff000000431104 at fork_exit+0x74
#10 0xffff000000790d4c at fork_trampoline+0x14
  x0:                1
  x1:                4
  x2: ffff000000985c65
  x3:               3b
  x4:                0
  x5:                7
  x6:                0
  x7:              501
  x8: ffffa0000747f000
  x9: ffff000000c19000
 x10:                1
 x11:               10
 x12:                0
 x13:                0
 x14:            10000
 x15:                1
 x16:            10000
 x17:                0
 x18: ffff0000403e0810
 x19: ffff000000e74370
 x20: ffffa000008bb498
 x21: ffff000000e744b0
 x22:                2
 x23:              102
 x24: ffff000000e74370
 x25: ffff000000c1a000
 x26:                0
 x27:                0
 x28:                0
 x29: ffff0000403e0810
  sp: ffff0000403e0810
  lr: ffff000000682264
 elr: ffff0000006822e4
spsr:         60000045
 far:                d
 esr:         96000004
panic: data abort in critical section or under mutex
cpuid = 0
time = 3
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
vpanic() at vpanic+0x184
panic() at panic+0x44
data_abort() at data_abort+0x27c
handle_el1h_sync() at handle_el1h_sync+0x78
--- exception, esr 0x96000004
find_other_mm() at find_other_mm+0xa8
linux_alloc_current() at linux_alloc_current+0xb4
linux_irq_work_init_fn() at linux_irq_work_init_fn+0x38
taskqueue_run_locked() at taskqueue_run_locked+0x188
taskqueue_thread_loop() at taskqueue_thread_loop+0xc8
fork_exit() at fork_exit+0x74
fork_trampoline() at fork_trampoline+0x14
KDB: enter: panic
[ thread pid 0 tid 100031 ]
Stopped at      kdb_enter+0x44: undefined       f905011f
` ``
jsm222 commented 2 years ago

I compiled it as a module, it loads without issues. I have not tested mesa or X yet.

jsm222 commented 2 years ago

I tried today on the ROCKPro64 4GB board. Compiled as a device.

I get trying to start sway with dev.drm.debug=9

panfrost0: GPU revision 2000, id 860
panfrost0: Mali 860, major 2, minor 0, status 0
panfrost0: Features: L2 7120206, Shader 0, Tiler 809, Mem 1, MMU 2830, AS ff, JS 7
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: panfrost_gpu_intr: pending 600
panfrost0: GPU is powered on
panfrost0: panfrost_gpu_intr: pending 20000

[drm: 0xffff000000869b04] 
[drm: 0xffff000000891248] new device created dri/renderD%d128
[drm: 0xffff000000869bb8] new minor registered 128
[drm: 0xffff000000869b04] 
[drm: 0xffff000000891248] new device created dri/card%d1
[drm: 0xffff000000869bb8] new minor registered 1
[drm] Initialized panfrost 1.1.0 20201124 for panfrost on minor 1

[drm: 0xffff00000088a830] disabling vblank on crtc 0
dwc0: link state changed to UP
dwc0: link state changed to DOWN
dwc0: link state changed to UP
[drm: 0xffff0000008912d0] 
[drm: 0xffff000000874ecc] pid = 100175, minor = 1
[drm: 0xffff00000087510c] open_count = 1
[drm: 0xffff0000008751c0] 
[drm: 0xffff0000008751e4] driver lastclose completed
[drm: 0xffff0000008912d0] 
[drm: 0xffff000000874ecc] pid = 100175, minor = 1
[drm: 0xffff00000087510c] open_count = 1
[drm: 0xffff0000008751c0] 
[drm: 0xffff0000008751e4] driver lastclose completed
[drm: 0xffff0000008912d0] 
[drm: 0xffff000000874ecc] pid = 100175, minor = 0
[drm: 0xffff00000087510c] open_count = 1
[drm: 0xffff0000008751c0] 
[drm: 0xffff00000087d42c] OBJ ID: 37 (2)
[drm: 0xffff00000087d42c] OBJ ID: 38 (1)
[drm: 0xffff00000087d42c] OBJ ID: 37 (3)
[drm: 0xffff00000087d384] OBJ ID: 37 (4)
[drm: 0xffff00000087d42c] OBJ ID: 35 (5)
[drm: 0xffff00000087d42c] OBJ ID: 35 (6)
[drm: 0xffff00000087d384] OBJ ID: 35 (6)
[drm: 0xffff00000087d42c] OBJ ID: 35 (5)
[drm: 0xffff00000088a9c4] crtc 33: hwmode: htotal 2200, vtotal 1125, vdisplay 1080
[drm: 0xffff00000085a85c] crtc 33: clock 148500 kHz framedur 16666666 linedur 14814
[drm: 0xffff00000088bfdc] enabling vblank on crtc 0, ret: 0
[drm: 0xffff00000088d314] vblank event on 331, current 331
[drm: 0xffff00000087d384] OBJ ID: 35 (6)
[drm: 0xffff00000087d384] OBJ ID: 35 (5)
[drm: 0xffff00000087d384] OBJ ID: 38 (2)
[drm: 0xffff00000087d384] OBJ ID: 37 (3)
[drm: 0xffff0000008751e4] driver lastclose completed
[drm: 0xffff00000088a830] disabling vblank on crtc 0
$ cat messages
Nov  1 16:34:04 generic seatd[2338]: 00:00:05.761 [ERROR] [seatd/seat.c:239] /dev/dri/card0 is not a supported device type 
Nov  1 16:34:04 generic seatd[2338]: 00:00:05.761 [ERROR] [seatd/client.c:210] Could not open device: No such file or directory
Nov  1 16:34:04 generic seatd[2338]: 00:00:05.779 [ERROR] [seatd/seat.c:239] /dev/dri/card1 is not a supported device type 
Nov  1 16:34:04 generic seatd[2338]: 00:00:05.779 [ERROR] [seatd/client.c:210] Could not open device: No such file or directory
Nov  1 16:35:04 generic devd[715]: check_clients:  dropping disconnected client
jsm222 commented 2 years ago

I got it to work today. Thanks.