So one of the weird errors I got was EEXIST. Where it'd try to init /dev/kfd, but it would already exist or try to init twice causing it to return EEXIST, but becuse linuxkpi wasnt passing in the flag to stop the kernel from panicing, it would panic. Leading to well, a panic.
To fix this I just modified the kernel to also return whatever error code got returned. This got it to init w/o panicking, but would say that KFD Module failed to initalise. BUT THERE WERE NO LOGs. If you tried to use the /dev/kfd viarocr-runtime it'd also panic. A quick check would confirm that the work_queue and event queue were not being init'd. Found out that I was missing the v11 code for my RDNA3 gpu, added that in and yup!
Then it stopped panicing, but came at the cost of nothing working and no error logs. So then I started adding in hundreds of printf/pr_err statements with the phrase "sex" in them so that I would know when a error comes out and can easily search via vim. So yeah!
Funniest error in there was "sex interrupted 1"
If you pass register_chrdev as the major number, the os/kernel will dynamically find you a major number and return it, use it, etc. But FreeBSD's linuxkpi does not do that, it kinda just doesn't care and will use whatever major number you supplied. Now 0 is special, so when amdkfd supplies 0, it tries to use 0, fails to allocate the minors, then dies. Took a LONGG time to figure this out.
For a good 1-2 hours I thought it was an issue of strictness. Anyways got that issue fixed by setting some arbitrary major number (241) right now. I will make a linuxkpi patch and submit it to make this dynamically allocated when 0 is passed
So it still errored out, but I confirmed it runs so ima just ignore it, also the functions which depend upon its side effects seem fine.
Also, you can't be using register_chardev(), you need to use register_chardev_p which is a special function???
Code which works simply??? Impossible, not allowed here. I forgot to include kfd_crat.c which is required to init the crat images, which is required for topology discovery. It's also dying because of NUMA stuff, but I can stub that out by returning basline 10 lol