Enabling CIK support in OpenBSD's amdgpu drm driver

Last modification on 2022-05-14

I originally traded my Nvidia GTX 980 with someone for an AMD R9 390 so I can use it under OpenBSD for better acceleration compared to what I got from my Intel iGPU. However, I've encountered many problems with the radeon driver in Linux and all the major *BSDs with lots of visual glitches which either made my screen unreadable or at least difficult to read with what seems to be synchronization issues.

Using the amdgpu driver under Linux with amdgpu.cik_support=1 in my kernel commandline made it usable, and I found it just werked. Support for this GPU's family is disabled by default in both Linux and OpenBSD because it's supposed to already work with the radeon driver. Unlike on Linux, I didn't see any easy way to enable this in OpenBSD. Disabling radeondrm when running "boot -c" did not work, rather I just didn't get any display at all. Looking at the kernel's source for amdgpu, I saw that there really wasn't such an easy way since the #define's were wrapped in #if 0, indicating that it's just removed/ignored when compiling the kernel.

So, my hacky way of making my GPU work with the amdgpu driver in OpenBSD was to remove the lines in the CIK-related source files that seem to block this. I did notice that the default GENERIC kernel config didn't seem to link properly, and I think this was due to the older radeondrm's cik.c/h file conflicting with amdgpu's cik.c/h. I didn't notice this when disabling radeondrm outright in a custom config though.

The changes I made are in this file. I think about half of these changes aren't necessary, but I am not going to fix this as I don't plan to get this merged upstream since I haven't seen anyone complain about my problem in the openbsd-misc mailing list, and I think this would make pulling newer changes to the amdgpu driver more annoying too. If it ain't broke, don't fix it, and this hacky patch is definitely working for me. :P

If you do apply this patch and recompile your kernel, make sure to run "fw_update amdgpu" before rebooting because the radeondrm firmware doesn't work with this driver (at least without manual intervention).

Side note: I think this should work with Southern Island cards too, but I think the radeon driver should work for those. This fix probably also isn't necessary for the rest of Sea Island GPUs since it seems that the R9 390 (and presumably R9 390x too) was very buggy in Linux when it initially came out and was only usable 3 years after its launch, but the rest weren't.