# amd vega and radeon series vga card driver for FreeBSD 12.1 and 12.2 tutorial for beginner[update 2020-12-16]



## Raffeale (Feb 1, 2020)

amd apu vga card driver for FreeBSD 12.1  tutorial for beginner

I’m a newbie for freebsd and have some experience for linux.
I have just installed FreeBSD for one week, I met a lot of trouble when I use it.
I just want to tell everyone that how to solve this problem  then you could  save you time .

This article only use for amd ryzen cpu (r3 2300u , r5  3500u, r7 3700u),radeon series , vega series vga card

R5 3500u have been tested


FreeBSD 12.1 can’t  detect your vga card with drm driver , because the driver have bug .


I found this driver in  FreeBSD github after searching a lot.

https://github.com/FreeBSDDesktop/kms-drm/tree/drm-v5.0-fbsd12.1

download it and unzip it
unzip kms-drm-drm-v5.0-fbsd12.1.zip

_*you have to install xorg before you do following steps*_

at first you have to install drm-kmo and gpu-firmware package from ports or pkg , it will install gpu-firmware automaticly

$ sudo pkg install drm-kmod
New packages to be INSTALLED:
        drm-kmod: g20181126 [FreeBSD]
        drm-current-kmod: 4.16.g20190305 [FreeBSD]
Message from drm-current-kmod-4.16.g20190305:

add a line into /etc/rc.conf.

For amdgpu: * kld_list="amdgpu"*
For radeonkms:* kld_list="/boot/modules/radeonkms.ko"

to install xf86 admgpu driver *
$ sudo pkg install xf86-video-amdgpu

restart your computer after above steps .
You will see this kind of infomations:
Feb  1 16:07:58 Raffeale kernel: [drm] amdgpu kernel modesetting enabled.
Feb  1 16:07:58 Raffeale kernel: drmn0: <drmn> on vgapci0
Feb  1 16:07:58 Raffeale kernel: vgapci0: child drmn0 requested pci_enable_io
Feb  1 16:07:58 Raffeale syslogd: last message repeated 1 times
Feb  1 16:07:58 Raffeale kernel: [drm] initializing kernel modesetting (RAVEN 0x1002:0x15D8 0x103C:0x8589 0xD2).
Feb  1 16:07:58 Raffeale kernel: [drm] register mmio base: 0xF0600000
Feb  1 16:07:58 Raffeale kernel: [drm] register mmio size: 524288
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 0 <soc15_common>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 1 <gmc_v9_0>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 2 <vega10_ih>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 3 <psp>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 4 <gfx_v9_0>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 5 <sdma_v4_0>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 6 <powerplay>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 7 <dm>
Feb  1 16:07:58 Raffeale kernel: [drm] add ip block number 8 <vcn_v1_0>
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_sdma.bin
Feb  1 16:07:58 Raffeale kernel: [drm] VCN decode is enabled in VM mode
Feb  1 16:07:58 Raffeale kernel: [drm] VCN encode is enabled in VM mode
Feb  1 16:07:58 Raffeale kernel: [drm] VCN jpeg decode is enabled in VM mode
Feb  1 16:07:58 Raffeale kernel: [drm] vm size is 262144 GB, 4 levels, block size is 9-bit, fragment size is 9-bit
Feb  1 16:07:58 Raffeale kernel: drmn0: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used)
Feb  1 16:07:58 Raffeale kernel: drmn0: GART: 1024M 0x0000000000000000 - 0x000000003FFFFFFF
Feb  1 16:07:58 Raffeale kernel: drmn0: AGP: 267419648M 0x000000F800000000 - 0x0000FFFFFFFFFFFF
Feb  1 16:07:58 Raffeale kernel: Successfully added WC MTRR for [0xc0000000-0xdfffffff]: 0;
Feb  1 16:07:58 Raffeale kernel: [drm] Detected VRAM RAM=512M, BAR=512M
Feb  1 16:07:58 Raffeale kernel: [drm] RAM width 128bits DDR4
Feb  1 16:07:58 Raffeale kernel: [TTM] Zone  kernel: Available graphics memory: 8071804 kiB
Feb  1 16:07:58 Raffeale kernel: [TTM] Zone   dma32: Available graphics memory: 2097152 kiB
Feb  1 16:07:58 Raffeale kernel: [TTM] Initializing pool allocator
Feb  1 16:07:58 Raffeale kernel: [drm] amdgpu: 512M of VRAM memory ready
Feb  1 16:07:58 Raffeale kernel: [drm] amdgpu: 3072M of GTT memory ready.
Feb  1 16:07:58 Raffeale kernel: i_size_write not implemented -- see your local kernel hacker
Feb  1 16:07:58 Raffeale kernel: [drm] GART: num cpu pages 262144, num gpu pages 262144
Feb  1 16:07:58 Raffeale kernel: [drm] PCIE GART of 1024M enabled (table at 0x000000F4007E9000).
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_asd.bin
Feb  1 16:07:58 Raffeale kernel: ugen2.3: <vendor 0x06cb product 0x00b7> at usbus2
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_pfp.bin
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_me.bin
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_ce.bin
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_rlc.bin
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec.bin
Feb  1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec2.bin
…*...*
Feb  1 16:07:58 Raffeale kernel: drmn0: ring vcn_dec uses VM inv eng 1 on hub 1
Feb  1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc0 uses VM inv eng 4 on hub 1
Feb  1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc1 uses VM inv eng 5 on hub 1
Feb  1 16:07:58 Raffeale kernel: drmn0: ring vcn_jpeg uses VM inv eng 6 on hub 1
Feb  1 16:07:58 Raffeale kernel: pm_runtime_mark_last_busy not implemented -- see your local kernel hacker
Feb  1 16:07:58 Raffeale kernel: [drm] Initialized amdgpu 3.27.0 20150101 for drmn0 on minor 0

that means your amdgpu driver is loaded correctly.

add your UID is a member of the "video" group.
$ *sudo pw groupmod video -m $USER


Run startx , go to xwindows, if have some problem with going into xwindows ,
you could find some message in /var/log/Xorg.0.log or run startx will got  "[KMS] drm report modesetting isn't supported "
it maybe the pcids file is missing your device_id,  just put your device_id in it.

You should run pciconf -lv to find vga card
for example:
#pciconf -lv*
iwm0@pci0:2:0:0:        class=0x028000 card=0x00148086 chip=0x25268086 rev=0x29 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Wireless-AC 9260'
    class      = network
vgapci0@pci0:4:0:0:     class=0x030000 card=0x8589103c chip=0x*15d8**1002* rev=0xd2 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Picasso'
    class      = display
    subclass   = *VGA*
there are deivce id and vendor id in chip field.
_*0x15d8*_* is device_id
0x1002 is vendor_id*

find your device_id  in y_ou /usr/local/share/pciids/pci.ids files 
add your device id in AMD group when you can't find it in the file.

And then run startx again , it works fine

if you xorg have VSync problem ,enable TearFree into your xorg.conf_

*Section "Device"

        ### [arg]: arg optional
        #Option     "ShadowFB"                  # [<bool>]
        #Option     "DefaultRefresh"            # [<bool>]
        #Option     "ModeSetClearScreen"        # [<bool>]
        Identifier  "Card0"
        Driver      "amdgpu"
        BusID       "PCI:4:0:0"

Option      "TearFree"  "On"

        Option      "DRI"                       "True"
        Option      "AccelMethod"               "exa"
        Option      "MigrationHeuristic"        "greedy"
EndSection*

for saving power , put this in your loader.conf . the following lines will enable dynamic power management on you gpu
compat.linuxkpi.amdgpu_dpm=1
compat.linuxkpi.amdgpu_bapm=1
compat.linuxkpi.amdgpu_runpm=1
compat.linuxkpi.amdgpu_dc=1


*if you got xorg issue with "No Screen found " , maybe you work on securelevel mode , you can look at your /var/log/Xorg.0.log , you will find these information here *

[ 18393.601] (WW) checkDevMem: *failed to open /dev/mem (Operation not permitted)*
[ 18393.601] (II) "glx" will be loaded. This was enabled by default and also specified in the config file.

solution: turn off securelevel and restart



*#note: 
(1)don’t use any secure level when you start the Xorg first time because /dev/kmem and /dev/memory can't be accessed as you open the secure level,when you start xorg , you can enable securelevel again. it's ok!
(2)mtrr will be not added correctly when your bios setup the video memory to auto , maybe this is drivers bug,because windows10 have not any problem.
(3) you can use "pkg lock drm-fbsd12.0-kmod" for preventing it from upgrading

offical article for vga card
https://freebsddesktop.github.io/2018/12/08/drm-kmod-primer.html

2020-04-06 UPDATE:
add solution for Xorg "No Screen Found"

2020-12-16 UPDATE:
solving laptop suspend and resume  problem for amdgpu drm5.0  , look this thread, i have just posted it.*
https://forums.freebsd.org/threads/...ies-apu-tested-suspending-and-resuming.74451/
*freebsd 12.2 driver compile and installation*
https://forums.freebsd.org/threads/freebsd-12-2-amd-vega-and-radeon-driver-solution-with-drm5.78080/


----------



## zoujiaqing (Feb 22, 2020)

How to build kms-drm-v5.0-fbsd12.1?


----------



## Raffeale (Feb 23, 2020)

cd kms-drm directory and run make and make install, the module will install /boot/module directory


----------



## zoujiaqing (Feb 23, 2020)

Raffeale said:


> cd kms-drm directory and run make and make install, the module will install /boot/module directory


OK! Successed!

```
# make
# sudo make install
# sudo reboot
```


----------



## jardows (Feb 26, 2020)

Thank you.  The 5.0 driver allows my RX590 to work!  I am only having problems now with the fan speed, as it appears the GPU fans are spinning at near full speed, creating too much noise.

A little clean-up for the instructions is needed, as there are some problems with the link.  The direct download for the file is:
https://github.com/FreeBSDDesktop/kms-drm/archive/drm-v5.0-fbsd12.1.zip

You will also need to download the firmware and install it.  
https://github.com/FreeBSDDesktop/kms-firmware/archive/master.zip

A problem with following the instructions above, about installing drm-kmod from packages is that if you later on simply run `pkg upgrade`, it will overwright the updated drivers.


----------



## Raffeale (Feb 26, 2020)

thank you for testing it ,I have already fix the wrong url.


----------



## Raffeale (Feb 29, 2020)

i  added some tuning about saving power  parameter in loader and fix vSync problem   with enabling TearFree in xorg.conf
amdcpu tempture 
https://www.cyberciti.biz/faq/freebsd-determine-processor-cpu-temperature-command/
i wil add some admcpu stuff in this thread!


----------



## jardows (Mar 2, 2020)

I am assuming the power saving options you listed require the linux compatibility configuration? Do you have any documentation on what these options actually do?


----------



## Raffeale (Mar 3, 2020)

The power management options do not Need Linux support,it’s amdgpu drm driver option. You can search them in bing.com.


----------



## jardows (Mar 4, 2020)

Raffeale said:


> The power management options do not Need Linux support,it’s amdgpu drm driver option. You can search them in bing.com.


Thank you.  I have found the documentation for the options.  Hopefully I will have opportunity to try it out later this week.


----------



## Raffeale (Mar 12, 2020)

solving laptop suspend and resume  problem for amdgpu drm5.0  , look this thread, i have just posted it.
https://forums.freebsd.org/threads/...ies-apu-tested-suspending-and-resuming.74451/


----------



## shkhln (Mar 14, 2020)

You know, this is entertaining, but actually quite wrong.  To install drm-v5.0 you need the graphics/drm-devel-kmod port and, of course, you won't be able to build it on 12.1.


----------



## Raffeale (Mar 14, 2020)

yes, you can download it from freebsd github, here is link
https://github.com/FreeBSDDesktop/kms-drm/tree/drm-v5.0-fbsd12.1
this drm 5.0 is for freebsd 12.1


----------



## Raffeale (Mar 14, 2020)

i have already installed drm5.0 on freebsd12.1 ,just use offical github drm5.0 for freebsd12.1  and it works fine


----------



## shkhln (Mar 14, 2020)

Interesting. You still should rather edit the version stuff in the port's makefile instead of all these strange steps.


----------



## Raffeale (Mar 14, 2020)

if you want to resume and suspend works, you should change  linuxkpi makefile.  but  it works fine without suspend and resume when you dont change anything. 
the follow post is for suspending and resuming I made it. 








						A guide is for laptop sleeping  with amd vga card(vega series apu  suspending and resuming tested)
					

yesterday i finnaly finished debuging for amdgpu , i found the suspend and resume function not work for freebsd 12.1 drm5.0 ,because the linuxkpi_register_pci_drm_driver won't get suspend and resume callback . the problem is linuxkpi compilation option is incorrect by default caus linuxkpi.ko...




					forums.freebsd.org


----------



## aht0 (Mar 16, 2020)

Could this thread be moved under Howtos and FAQs (Moderated)?
It's useful for those of us with newer Radeon cards.


----------



## Sevendogsbsd (Apr 3, 2020)

jardows said:


> You will also need to download the firmware and install it.
> https://github.com/FreeBSDDesktop/kms-firmware/archive/master.zip



This confuses me - what firmware? I installed graphics/drm-kmod and * x11-drivers/xf86-video-amdgpu * and the system works perfectly, 3d graphics included. There is some garbling of the FreeBSD boot logo before the AMD driver kicks in but other than that it works fine.

Running this on an RX570 but that shouldn't matter should it?

As a side note, is there any way to get the GPU temperature?


----------



## jardows (Apr 3, 2020)

Sevendogsbsd said:


> This confuses me - what firmware? I installed graphics/drm-kmod and * x11-drivers/xf86-video-amdgpu * and the system works perfectly, 3d graphics included. There is some garbling of the FreeBSD boot logo before the AMD driver kicks in but other than that it works fine.
> 
> Running this on an RX570 but that shouldn't matter should it?
> 
> As a side note, is there any way to get the GPU temperature?


The firmware is part of graphics/drm-kmod.  If you are manually installing the source from github, you will need to also manually install the firmware.  There is no need to install the port if you are manually installing, and as I found out, if it is installed beforehand, running a blanket `pkg upgrade` will overwrite the 5.0 drivers.  If installing the port gives you proper graphics support, then you don't need to install the 5.0 drivers.  In my case, the 4.16 drivers from ports would not work.

I too am hoping to have some way to monitor the GPU temperature and fan speeds, but that may not be doable right now.


----------



## Sevendogsbsd (Apr 4, 2020)

Ah ok, thanks for the clarification. I installed from ports so I should be good to go. Everything works fine: the monitor sleeps and wakes up, 3D works, I can go from fluxbox to terminal with no issues. The only issue is screen jumble after the FreeBSD logo during boot, until the driver kicks in but I can live with that.


----------



## Raffeale (Apr 4, 2020)

Thanks you for testing


----------



## Raffeale (Apr 6, 2020)

*2020-04-06 UPDATE:
add solution for Xorg "No Screen Found"*


----------



## Sevendogsbsd (Apr 6, 2020)

Raffeale said:


> Thanks you for testing


Thank you but I wasn't testing your solution . My system works perfectly just using the standard x11/drm-kmod driver.


----------



## dedi_tom (Jun 23, 2020)

Raffeale said:


> amd apu vga card driver for FreeBSD 12.1  tutorial for beginner
> 
> I’m a newbie for freebsd and have some experience for linux.
> I have just installed FreeBSD for one week, I met a lot of trouble when I use it.
> ...


I can confirm that both solutions amdgpu and  suspend works for me on the Lenovo E595. Thank you. It seems though that the sound doesn't work. Did you manage to get the sound working with your laptop?
Thank you


----------



## cabriofahrer (Aug 7, 2020)

Sevendogsbsd said:


> Thank you but I wasn't testing your solution . My system works perfectly just using the standard x11/drm-kmod driver.



So what is the actual status on this to get vega working (all versions?)? Is it suffice to install x11/drm-kmod or x11/drm-kmod-devel and does it have to be from ports, or do packages work as well? I am asking the latter because on a system I have with an old Radeon the installation with packages gives:


```
$ pkg info | grep drm
drm-fbsd12.0-kmod-4.16.g20200221 DRM modules for the linuxkpi-based KMS components
drm-kmod-g20190710             Metaport of DRM modules for the linuxkpi-based KMS components
libdrm-2.4.102,1               Userspace interface to kernel Direct Rendering Module services
linux-c7-libdrm-2.4.91         Interface to kernel Direct Rendering Module (Linux CentOS 7.6.1810)
$
```


----------



## Sevendogsbsd (Aug 7, 2020)

I just install the drm-kmod package and *xf86-video-amdgpu*. I add the appropriate entry to /etc/rc.conf. I do no other configuration and the system just works. This is a desktop PC though, not a laptop. I only have an RX570 so can't speak to any other models or laptops as I do not use a laptop with FreeBSD.


----------



## cabriofahrer (Aug 7, 2020)

I do not intend to run a laptop either. I am asking because I might be interested in buying a Desktop AMD GPU with vega in the furture.


----------



## zeising@ (Aug 15, 2020)

Be aware that the drm-v5.0-fbsd12.1 branch is not supported, and not guaranteed to work.  There were a couple of regressions with the 5.0 branch, which is why both drm-current-kmod (for current) and drm-fbsd12.0-kmod (for FreeBSD 12.x) are stuck with Linux 4.16 code.  If you need newer drivers, it is probably best to run FreeBSD current and use drm-devel-kmod.


----------



## roper (Sep 12, 2020)

cabriofahrer said:


> I do not intend to run a laptop either. I am asking because I might be interested in buying a Desktop AMD GPU with vega in the furture.


I've purchased a B550 motherboard and am awaiting a Ryzen 7 Pro 4750G ordered from China. I'll let you know how vega works out when it arrives.


----------



## zeising@ (Sep 16, 2020)

roper said:


> I've purchased a B550 motherboard and am awaiting a Ryzen 7 Pro 4750G ordered from China. I'll let you know how vega works out when it arrives.



I believe this should be supported when using a recent FreeBSD CURRENT ant the lastest drm-kmod and gpu-firmware-kmod updates.


----------



## hodong (Oct 2, 2020)

roper said:


> I've purchased a B550 motherboard and am awaiting a Ryzen 7 Pro 4750G ordered from China. I'll let you know how vega works out when it arrives.


I am an AMD 3000G user. I installed FreeBSD 13-CURRENT and graphics/drm-current-kmod, x11-drivers/xf86-video-amdgpu to use X window.


----------



## roper (Oct 3, 2020)

hodong said:


> I am an AMD 3000G user. I installed FreeBSD 13-CURRENT and drm-current-kmod, xf86-video-amdgpu to use X window.


I've received the cpu and assembled the box. I installed FreeBSD 12.1-RELEASE which went very well. I encountered an issue in that the memstick from which I installed wasn't recognized as bootable when plugged into any USB 3.0 port but was recognized from a USB 2.0 port from which I completed the installation. I've been reading about `bectl` and boot environments and intend to try out Xorg with xf86-video-amdgpu when I'm confident that I can roll back to a RELEASE version without error. As of today I'm quite pleased with this cpu even without taking advantage of the gpu cores.


----------



## WCSN (Oct 29, 2020)

This solution work in 12.2 ... but need correct errors (simple) compiling.


----------



## jardows (Nov 9, 2020)

WCSN said:


> This solution work in 12.2 ... but need correct errors (simple) compiling.


Can you give some more details?  I need this driver for my video card on my desktop (I don't want to run -CURRENT and the 4.16 drivers do not work).  I'm running into a compile error, but as I am not that experienced with debugging compilation errors, really don't know what to do next.


----------



## WCSN (Nov 10, 2020)

jardows said:


> Can you give some more details?  I need this driver for my video card on my desktop (I don't want to run -CURRENT and the 4.16 drivers do not work).  I'm running into a compile error, but as I am not that experienced with debugging compilation errors, really don't know what to do next


You need to correct the source code for the errors that the compiler produces - comment out the calls and function declarations in .h .cpp files. Which ones are visible during compilation. Unfortunately, I didn't make a patch.


----------



## jardows (Nov 10, 2020)

WCSN said:


> You need to correct the source code for the errors that the compiler produces - comment out the calls and function declarations in .h .cpp files. Which ones are visible during compilation. Unfortunately, I didn't make a patch.


Yeah, that's getting pretty far outside of my current skill level.  I've never managed to make it much past "Hello World" in any C programming tutorials.  But I have made great strides in learning POSIX shell scripting, so there's hope for me yet!


----------



## WCSN (Nov 10, 2020)

jardows said:


> Yeah, that's getting pretty far outside of my current skill level.  I've never managed to make it much past "Hello World" in any C programming tutorials.  But I have made great strides in learning POSIX shell scripting, so there's hope for me yet!


Ок.
1. Download FreeBSD source. (if not have this...)
`svn checkout http://svn.freebsd.org/base/releng/12.2/ /usr/src`
2. Go first page this theme and make instructions... (if not make...) without download and make drv... kms-drm-drm-v5.0-fbsd12.1.zip
m.b. need install `pkg install linux-c7-7.8.2003` and m.b. need download firmware https://github.com/FreeBSDDesktop/kms-firmware/archive/master.zip)
3. get from attache kms-drm-drm-v5.0-fbsd12.1_modify.tar.xz (my modify).
4. unpack and `make` and `make install` this.
5. `kldload amdgpu`
if you run command`kldstat` must see few amdgpu_*.ko (firmware )
6. reboot ... and load X and DE


----------



## Raffeale (Jan 28, 2021)

look at this thread,up up up.


----------



## Minzord (Feb 23, 2021)

Hello, it's normal that I don't support brightness management ?

I use FreeBSD 13.0-BETA3


> CPU:       Info: 8-Core model: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx bits: 64 type: MCP L2 cache: N/A
> Speed: 2096 MHz min/max: 1400/2100 MHz Core speeds (MHz): No speed data found for 8 cores.





> Graphics:  Message: No Device data found.
> Display: server: X.Org 1.20.9 driver: amdgpu,ati unloaded: modesetting,vesa resolution: 1920x1080~60Hz
> OpenGL: renderer: AMD Radeon Vega 8 Graphics (RAVEN DRM 3.35.0 13.0-BETA3 LLVM 10.0.1) v: 4.6 Mesa 20.2.3



Without xf86-video-ati xorg switched to modesetting.

Have a nice day


----------



## Raffeale (Feb 24, 2021)

Minzord said:


> Hello, it's normal that I don't support brightness management ?
> 
> I use FreeBSD 13.0-BETA3
> 
> ...


it's normal in freebsd 12.2, maybe the driver did not support it. it cant change brightness with shortcut key even if I load acpi_video driver. I use other method change brightness in freebsd 12.2


----------



## Minzord (Feb 24, 2021)

Raffeale said:


> it's normal in freebsd 12.2, maybe the driver did not support it. it cant change brightness with shortcut key even if I load acpi_video driver. I use other method change brightness in freebsd 12.2


I am on FreeBSD 13.0 but I would like to have the method.


----------



## ethoms (Jun 19, 2021)

Hi, thanks to Raffeale I managed to get my Enlightenment session to work with OpenGL + Tearfree rendering.

BUT! There was a couple things wrong with the Device entry in the suggested Xorg conf file. The DRI option expects an integer, the boolean "True" will be rejected. The integer should be either 2 or 3, referring to DRI2 or  DRI3, the later being the default. I found that 3 did not work, but 2 does. Also, the MigrationHeuristic option is not supported, perhaps it's depracated, or amdgpu does not use it.

With no Xorg hint file, Enlightenment would work with no GPU accelerattion (Software instead of OpenGL). But it would leave me with a black screen and just the cursor once rendering engine was set to OpenGL and Tearfree was turned on in Settings->Look->Compositor->Rendering.

I have a Radeon RX 550 (4GT LP OC with 4GB GDDR5), by MSI.
I'm running FreeBSD 12.2-RELEASE.

EDIT: the 12.2-RELEASE drm-kmod packages do work when X is started on boot. This may be just on some monitors (like mine) whereby the correct monitor timings is being set by amdgpu. The kmod-v5.0 works better in this regard. See my post #50 below.

The drm-kmod in 12.2 was not good enough and the screen would go blank on boot, not even console was working. So I downloaded the drm-v5.0-fbsd12.1 tree from Github, used unzip to extract it, `cd` into the source directory and ran `make`. When it failed with errors, I removed the functions from source file mentioned in compiler error message (all were .h files I think) and ran `make` again. After successful build, remove existing drm-kmod packages with `pkg remove drm-fbsd12.0-kmod`, then run `make install clean`.

Then add a Xorg hint file:


```
$EDITOR /usr/local/etc/X11/xorg.conf.d/10-amdgpu.conf
```


```
Section "Device"
    Identifier "Radeon RX 550"
    VendorName "AMD/ATI"
    Driver "amdgpu"
    BusID "PCI:1:0:0"

    Option "TearFree" "On"
    Option "DRI" "2"
    Option "AccelMethod" "exa"
EndSection
```

And of course add `kld_list="/boot/modules/amdgpu.ko"` to /etc/rc.conf.

Enlightenment works well, I can play Youtube at 1080p also works well, I can play a 4K mpeg4 video in SMPlayer which works really well (no noticeable tearing). Why are we moving to Wayland again.... (scratches head). And of course 4K video playback was why I bought this card in the first place. So now I can replace my Ubuntu 18.04 installation on my Mediacentre PC (KODI) with FreeBSD on my home file server / router. So two always running systems in my living room down to one. Sweet!

Huge thanks to all the FreeBSD devs that have worked so hard on the graphics stack (drm/kmod etc.) over the last few years. Living the dream!


----------



## astyle (Jun 19, 2021)

ethoms said:


> Hi, thanks to Raffeale I managed to get my Enlightenment session to work with OpenGL + Tearfree rendering.
> 
> BUT! There was a couple things wrong with the Device entry in the suggested Xorg conf file. The DRI option expects an integer, the boolean "True" will be rejected. The integer should be either 2 or 3, referring to DRI2 or  DRI3, the later being the default. I found that 3 did not work, but 2 does. Also, the MigrationHeuristic option is not supported, perhaps it's depracated, or amdgpu does not use it.
> 
> ...


My card is by Asus, but it's also a Radeon RX 550 4GB. I got everything working just fine (no messing around with xorg.conf. Just followed instructions on this page, nothing else, boom, works! I would advise against mixing new github code into the system without a good way to go back if you mess up. There's a reason we have a ports system.



Wayland actually works for me, too - just waiting on the SDDM project to finish publishing the software on their end of things.


----------



## ethoms (Jun 19, 2021)

astyle said:


> My card is by Asus, but it's also a Radeon RX 550 4GB. I got everything working just fine (no messing around with xorg.conf. Just followed instructions on this page, nothing else, boom, works! I would advise against mixing new github code into the system without a good way to go back if you mess up. There's a reason we have a ports system.



What version of FreeBSD did you use. I tried those instructions and I got a black screen on boot. Nothing to do with Xorg, it was before I installed xorg. I'm on 12.2-RELEASE and booting via BIOS (CSM). The output of dmesg (only accessible via ssh) showed errors from drm about not being able to find some amdgpu resources. The corresponding modules were loaded as per kldstat. Only thing that got it working was swapping kmod 4.16 for kmod 5.0. That's the only thing that changed. I'd like to know what you did differently.


----------



## astyle (Jun 19, 2021)

ethoms said:


> What version of FreeBSD did you use. I tried those instructions and I got a black screen on boot. Nothing to do with Xorg, it was before I installed xorg. I'm on 12.2-RELEASE and booting via BIOS (CSM). The output of dmesg (only accessible via ssh) showed errors from drm about not being able to find some amdgpu resources. The corresponding modules were loaded as per kldstat. Only thing that got it working was swapping kmod 4.16 for kmod 5.0. That's the only thing that changed. I'd like to know what you did differently.


I think I started using those instructions on FreeBSD 11... I would first install everything I want (Xorg, drm-kmod, and KDE), and only afterwards I would go around setting stuff up and modifying the config files as per instructions in the FreeBSD handbook. That worked wonders, even with pre-compiled packages. And I did not go to github for fresh tarballs that were not properly patched for the ports system.

FWIW, I'm on 13-RELEASE right now, and using ports downloaded with portsnap. It's working even better, because .ko files are now loaded much more cleanly than earlier.


----------



## ethoms (Jun 19, 2021)

astyle said:


> I think I started using those instructions on FreeBSD 11... I would first install everything I want (Xorg, drm-kmod, and KDE), and only afterwards I would go around setting stuff up and modifying the config files as per instructions in the FreeBSD handbook. That worked wonders, even with pre-compiled packages. And I did not go to github for fresh tarballs that were not properly patched for the ports system.
> 
> FWIW, I'm on 13-RELEASE right now, and using ports downloaded with portsnap. It's working even better, because .ko files are now loaded much more cleanly than earlier.



I have no doubt that 13-RELEASE is working well from packages or ports, the stack is much more up to date. I've seen a few posts from various users on other threads here that our generation of Radeon cards are working on 12.2-RELEASE without using the git tree version of kmod. I used packages from quarterly, latest and built from ports, none of them worked. I kept getting a black screen, in fact the monitor would say no signal or something similar, but I could ssh in.

Did you try on 12.2-RELEASE specifically? That git tree was created for 12.1-RELEASE because a bug was introduced in 12.1 that  effects the kmod-4.16. Also, are you using BIOS (legacy boot) or UEFI?

I will try again with the pkg version, now that I have SDDM enabled. Maybe I will diff the output of dmesg and post here.


----------



## astyle (Jun 19, 2021)

ethoms said:


> I have no doubt that 13-RELEASE is working well from packages or ports, the stack is much more up to date. I've seen a few posts from various users on other threads here that our generation of Radeon cards are working on 12.2-RELEASE without using the git tree version of kmod. I used packages from quarterly, latest and built from ports, none of them worked. I kept getting a black screen, in fact the monitor would say no signal or something similar, but I could ssh in.
> 
> Did you try on 12.2-RELEASE specifically? That git tree was created for 12.1-RELEASE because a bug was introduced in 12.1 that  effects the kmod-4.16. Also, are you using BIOS (legacy boot) or UEFI?
> 
> I will try again with the pkg version, now that I have SDDM enabled. Maybe I will diff the output of dmesg and post here.


I don't think I tried 12.2-RELEASE specifically... or 12.1, for that matter. I tend to go for .0-RELEASE... and I use UEFI. My rig is completely aftermarket parts, so maybe my SSD's did not get 'contaminated' by a manufacturer who sells pre-assembled PCs.

Black screens can result from not seating the GPU into the motherboard properly, as well as not having the power supply tightly seated into the plugs. There's a few physical places to check.


----------



## ethoms (Jun 19, 2021)

astyle said:


> I don't think I tried 12.2-RELEASE specifically... or 12.1, for that matter. I tend to go for .0-RELEASE... and I use UEFI. My rig is completely aftermarket parts, so maybe my SSD's did not get 'contaminated' by a manufacturer who sells pre-assembled PCs.
> 
> Black screens can result from not seating the GPU into the motherboard properly, as well as not having the power supply tightly seated into the plugs. There's a few physical places to check.



Definetely not physical issue.

Strangely, and promisingly, it now works with the packages from the 12.2-RELEASE repo. But I didn't do anything silly before, I was careful and tried and checked over my steps many times. I'm guessing it's either some files were left behind from the git tree (kmod-5) make install (there is no make uninstall/deinstall), or the Xorg/SDDM does something to make it work. I can even switch to the other TTYs, so the console is  working fine.

I am actually just doing some testing, this is not my production install yet. And I did a `zfs snapshot -r zroot@fresh-install` just after I updated the base to p8. So I can revert to that snapshot and try again, see where it goes right. Will report back with my findings, this is interesting...


----------



## astyle (Jun 19, 2021)

ethoms said:


> Definetely not physical issue.
> 
> Strangely, and promisingly, it now works with the packages from the 12.2-RELEASE repo. But I didn't do anything silly before, I was careful and tried and checked over my steps many times. I'm guessing it's either some files were left behind from the git tree (kmod-5) make install (there is no make uninstall/deinstall), or the Xorg/SDDM does something to make it work. I can even switch to the other TTYs, so the console is  working fine.
> 
> I am actually just doing some testing, this is not my production install yet. And I did a `zfs snapshot -r zroot@fresh-install` just after I updated the base to p8. So I can revert to that snapshot and try again, see where it goes right. Will report back with my findings, this is interesting...


Good for you.  In my case, I was doing things as a fresh install, so that I don't have a mess from a previous install to deal with.


----------



## ethoms (Jun 19, 2021)

OK, all is clear now. The drm-kmod in ports/pkg in 12.2-RELEASE is working now. But only after I actually enable SDDM and therefore X starts by itself.

Without X being started, I get no output on my monitor. The problem becomes clear after reading the message from my Dell monitor (below).



> The current Input timing is not supported by the monitor display. Please change your input timing to 2560x1440, 60Hz or any other monitor listed timing as per the monitor specifications.



So the kmod-v4.16 has problems setting the correct timings for my monitor in console mode (vt). But the git tree kmod-v5.0-fbsd12.1 fixes it. Because I was trying to get amdgpu working before I setup X and a WM/DE I did not notice that it actually works. So if I was using startx from a TTY, I would have a problem, because only after X starts can I see anything on my screen. For my  use case, I will always have SDDM start up at boot, so it is OK. And actually I will be using my TV in production, so it may not have that timing issue anyway. I assume 13-RELEASE and beyond will just work fine in any case.

Thanks astyle for leading me to investigate further.


----------



## Vull (Jun 19, 2021)

I have AMD A6-6310 APU with AMD Radeon R4 Graphics, and UEFI booting. On 13.0-RELEASE all I need to do on first boot after install is `pkg install drm-kmod xf86-video-ati` and I can get MATE, plasma5-plasma, or even the whole kde5 meta-package running without rebooting.

I make no related changes to /boot/loader.conf or /etc/rc.conf. This is a completely different experience than a few years ago when, due to my own shortcomings no doubt, I was unable to get anything better than scfb graphics running on an AMD A9-9420 RADEON R5 CPU with 11.2-RELEASE or 12.0-RELEASE. Have to give 13.0-RELEASE most or all of the credit really, plus some really great advice gleaned from searching through related threads on this forum.


----------



## astyle (Jun 19, 2021)

ethoms said:


> OK, all is clear now. The drm-kmod in ports/pkg in 12.2-RELEASE is working now. But only after I actually enable SDDM and therefore X starts by itself.
> 
> Without X being started, I get no output on my monitor. The problem becomes clear after reading the message from my Dell monitor (below).
> 
> ...


Yeah, once you do things in correct order, they do work. In programming terms, it's a bit comparable to the _queue_ data structure. 
Once you have stuff visible on a monitor, there's nothing to worry about, you can plug in the most expensive 80-inch TV you can find, via HDMI or even DisplayPort, and it will work just fine.


----------

