evadot / drm-subtree

WIP drm drivers for FreeBSD
15 stars 9 forks source link

Import the Panfrost kernel driver for FreeBSD. #13

Closed bukinr closed 2 years ago

bukinr commented 3 years ago

Tested on rk3399 with wayland (sway compositor), chromium, firefox and mesa-demos.

jsm222 commented 2 years ago

With this latest non GPL version I get CPU 3: 0.0% user, 0.0% nice, 100% system, 0.0% interrupt, 0.0% idle an an unusable system. It happens when starting Firefox under xfce4 on Pinebook Pro.. and also whens starting sway. The inital PR with the gpl header files works. My current-14 is at c9e023541aefdabf0b602e1fd62f5e21a6f8ffa2 CPU 0: 0.0% user, 0.0% nice, 100% system, 0.0% interrupt, 0.0% idle 1297 root 3 80 0 270M 141M CPU0 0 2:47 100.18% Xorg. I have tested a few times so either my testing is wrong, or a functional change has sneaked in or it simply does not work with current at commit c9e023541aefdabf0b602e1fd62f5e21a6f8ffa2. Thanks.

bukinr commented 2 years ago

there are some other changes, not just GPL ->BSD change. For example panfrost allocates contiguous memory now, try to change this:

-       if (1 == 0)
+       if (1 == 1)
                panfrost_alloc_pages_iommu(bo);
        else
                panfrost_alloc_pages_contig(bo);

in panfrost_gem.c

jsm222 commented 2 years ago

Yes, with that single change it works as well as the earlier version.

bukinr commented 2 years ago

What is your mesa-dri version? I updated locally to latest version (the version used in ports/pkgs) and noticed that new mesa imports panfrost DRM objects into rk3399 DRM, while the rk3399 drm could not do non-contiguous memory because it has no IOMMU implemented in drivers. So if you update mesa and try sway you may see issues in picture

bukinr commented 2 years ago

Sorry it is not a mesa3d issue, since I can run panfrost normally on X even with non-contiguous backed pages. I guess it is the sway issue (or libdrm or other parts of graphical stack)

bukinr commented 2 years ago

@jsm222 I added usage of vm_page_reclaim_contig() to reclaim pages when you have no free memory. Please check latest version without modifications.

jsm222 commented 2 years ago

That crashes in drm_prime_pages_to_sg but does not hang with 100% system cpu It crashes opening webglsamples.org aquarium in firefox. The call stack is root@generic-drm:~ # Fatal data abort: x0: ffffa00006d21bd0 x1: 0 x2: 2 x3: ffff000040238f00 (ucom_cons_softc + 3ee2bfd0) x4: 10 x5: 0 x6: 120 x7: c x8: 1000 x9: ffff0000e6fdb008 ($d.7 + 11ec5a0) x10: 3fff x11: ffffefff x12: 0 x13: 0 x14: 0 x15: 38 x16: ffff0000e5c2a3c8 (__stop_set_modmetadata_set + 440) https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/core/drm_prime.c#L887 x17: ffff0000009525ac (drm_prime_pages_to_sg + 0) x18: ffff0000e54db320 (ucom_cons_softc + e40ce3f0) https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/drmkpi/include/linux/slab.h#L112 x19: ffffa00006d21bd0 x20: 4000 x21: ffff0000e6fdb000 ($d.7 + 11ec598) x22: 0 x23: 1 x24: 200 x25: 1 x26: ffff0000e5c03f81 ($d.2 + 0) x27: ffffa000b9172400 x28: ffffa00006ec3008 x29: ffff0000e54db320 (ucom_cons_softc + e40ce3f0) https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/drmkpi/include/linux/slab.h#L112 sp: ffff0000e54db320 https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/drmkpi/include/linux/slab.h#L112 lr: ffff0000009525e4 (drm_prime_pages_to_sg + 38) https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/drmkpi/include/linux/slab.h#L112 elr: ffff000000952634 (drm_prime_pages_to_sg + 88) https://github.com/CTSRD-CHERI/drm-subtree/blob/f22ff59be6050828f166406d61939f3c34878412/drmkpi/include/linux/scatterlist.h#L301

bukinr commented 2 years ago

How much memory do you have in your machine?

jsm222 commented 2 years ago

4GB I still have 2096M free when crashing. I will try on the rockpro64 to se if it crashes the same way.

jsm222 commented 2 years ago

the rockpro64 crashes the same way (same sd card, new u-boot) Fatal data abort: x0: ffffa00006ad9cf0 x1: 0 x2: 2 x3: ffff000040239f00 (ucom_cons_softc + 3ee2cfd0) x4: 10 x5: 0 x6: 120 x7: c x8: 1000 x9: ffff0000e6cc5008 (stop_set_modmetadata_set + 655250) x10: 3fff x11: ffffefff x12: 0 x13: 0 x14: 0 x15: 38 x16: ffff0000e662a3c8 (__stop_set_modmetadata_set + 440) x17: ffff0000009525ac (drm_prime_pages_to_sg + 0) x18: ffff0000e63af320 (ucom_cons_softc + e4fa23f0) x19: ffffa00006ad9cf0 x20: 4000 x21: ffff0000e6cc5000 (stop_set_modmetadata_set + 655248) x22: 0 x23: 1 x24: 200 x25: 1 x26: ffff0000e6603f81 ($d.2 + 0) x27: ffffa000c1a6ec00 x28: ffffa00006e0c008 x29: ffff0000e63af320 (ucom_cons_softc + e4fa23f0) sp: ffff0000e63af320 lr: ffff0000009525e4 (drm_prime_pages_to_sg + 38) elr: ffff000000952634 (drm_prime_pages_to_sg + 88)

jsm222 commented 2 years ago

How much memory do you have in your machine?

I get allocation error when npages are 16384, i guees I do not have enough free continuous memory.

evadot commented 2 years ago

Merged in 52e081619446bc895cd9903eeffd551c329d61f5