# 5.4.5. Video Cards - should I install graphics/drm-kmod?



## asmar (Apr 21, 2020)

Hello,
I am installing FreeBSD for the first time and I got stuck at 5.4.5. Video Cards in Handbook.

I am now installing on old PC to try it out but I am interested in general steps.

I identified my GPU as Radeon HD 4000 RV730 XT. So I figured I'll need to modify config file accordingly:


```
/usr/local/etc/X11/xorg.conf.d/driver-radeon.conf

Section "Device"
    Identifier "Card0"
    Driver     "radeon"
EndSection
```

However I do not understand how to use graphics/drm-kmod. Am I supposed to run `make install` and it will figure out automatically what to install?

I am sorry if this is obvious. I read the Handbook from the start but I am probably missing some clue on how to figure this out.


----------



## SirDice (Apr 21, 2020)

In addition  to the handbook, read this:  https://wiki.freebsd.org/Graphics#AMD_Graphics


----------



## asmar (Apr 21, 2020)

I followed the guide and set the driver to radeonkms. I also installed drm-kmod. drm-legacy-kmod was installed automatically.

However, startx does not work. In /var/log/Xorg.0.log I found:


```
(WW) Warning, couldn't open module radeonkms
(EE) Failed to load module "radeonkms" (module does not exist, 0)
(EE) No drivers available.
(EE) Fatal server error:
(EE) no screens found(EE)
```

I also modified /etc/rc.conf:

```
kld_list="/boot/modules/radeonkms.ko"
```


----------



## Alain De Vos (Apr 21, 2020)

For RV730 it should be "radeonkms" , "drm-kmod". Try drm-kmod in stead of legacy.
Try to remove drm-legacy-kmod-...
Maybe you should install drm-fbsd...-kmod-...
"For newer Intel and AMD hardware, please use graphics/drm-kmod which will pick an appropriate driver for your system"


----------



## T-Daemon (Apr 21, 2020)

asmar said:


> I followed the guide and set the driver to radeonkms.





asmar said:


> (WW) Warning, couldn't open module radeonkms
> (EE) Failed to load module "radeonkms" (module does not exist, 0)
> (EE) No drivers available.





asmar said:


> I also modified /etc/rc.conf:



Disable /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf by renaming, e.g. driver-radeon.conf.0, or delete it . graphics/drm-legacy-kmod doesn’t need a *[EDIT:*driver*]* config file. Make sure you are in the video group: 5.4.2. User Group for Accelerated Video


----------



## asmar (Apr 22, 2020)

T-Daemon said:


> Disable /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf by renaming, e.g. driver-radeon.conf.0, or delete it . graphics/drm-legacy-kmod doesn’t need a *[EDIT:*driver*]* config file. Make sure you are in the video group: 5.4.2. User Group for Accelerated Video


I renamed the config file. X now starts however the screen gets disconnected and monitor doesn't detect any input. From the /var/log/Xorg.0.log:

```
(WW) Falling back to old probe method for modesetting
(WW) Falling back to old probe method for scfb
...
(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
...
(WW) RADEON(0): 3 ZaphoHeads crtcs unavailable. Some outputs will stay off.
...
(WW) RADEON(0): Failed to set mode on CRTC 0
(EE) RADEON(0): Failed to enable any CRTC
```

I forgot to mention that X works with VESA driver if that's helpful.

I also tried to replace xf86-video-ati with xf86-video-ati-legacy by installing a port. However I got:

```
===>>> Port directory: /usr/ports/x11-drivers/xf86-video-ati-legacy

===>>> This port is marked BROKEN
===>>> does not build with xorg-server 1.20.7
```


----------



## asmar (Apr 22, 2020)

From startx itself:

```
drmn0: error: No GEM object associated to handle 0x00000400 can't create framebuffer
failed to add FB for modeset
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Internal error: Could not resolve keysym XF86FullScreen
```


----------



## T-Daemon (Apr 22, 2020)

asmar said:


> I also tried to replace xf86-video-ati


If you are planning to use the x11-drivers/xf86-video-ati driver, then you need to set a driver configuration file:


asmar said:


> ```
> Section "Device"
> Identifier "Card0"
> Driver "radeon"
> ...


Disable radeonkms.ko in /etc/rc.conf, rename /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf.0 to driver-radeon.conf, try again.


----------



## asmar (Apr 22, 2020)

Back at these errors.


asmar said:


> I followed the guide and set the driver to radeonkms. I also installed drm-kmod. drm-legacy-kmod was installed automatically.
> 
> However, startx does not work. In /var/log/Xorg.0.log I found:
> 
> ...


----------



## Alain De Vos (Apr 22, 2020)

If you use drm-kmod it's good to check if there is not more than one video card in the PC with
pciconf -lv.
If there is more than one set the pci id in xorg.conf
And don't specify a driver.


----------



## asmar (Apr 22, 2020)

Alain De Vos said:


> If you use drm-kmod it's good to check if there is not more than one video card in the PC with
> pciconf -lv.
> If there is more than one set the pci id in xorg.conf
> And don't specify a driver.


I found no other video card.
I commented out the driver name but then it results in load of radeon instead of radeonkms and screen goes blank/off.


----------



## Alain De Vos (Apr 22, 2020)

What's the output of :
`cat /var/log/Xorg.0.log | grep -i driver`


----------



## asmar (Apr 22, 2020)

Alain De Vos said:


> What's the output of :
> `cat /var/log/Xorg.0.log | grep -i driver`


What you requested plus error in different part of log file in an image, sorry.


----------



## asmar (Apr 23, 2020)

Ok, I finally managed to connect USB drive and copy it. 


```
[asmar@pent4FBSD ~]$ grep -i drive /var/log/Xorg.0.log
[    61.484]     X.Org Video Driver: 24.1
[    61.484]     X.Org XInput driver : 24.1
[    61.590] (==) Matched ati as autoconfigured driver 0
[    61.590] (==) Matched modesetting as autoconfigured driver 1
[    61.590] (==) Matched scfb as autoconfigured driver 2
[    61.590] (==) Matched vesa as autoconfigured driver 3
[    61.590] (==) Assigned the driver to the xf86ConfigLayout
[    61.591] (II) Loading /usr/local/lib/xorg/modules/drivers/ati_drv.so
[    61.606]     Module class: X.Org Video Driver
[    61.606]     ABI class: X.Org Video Driver, version 24.1
[    61.609] (II) Loading /usr/local/lib/xorg/modules/drivers/radeon_drv.so
[    61.657]     Module class: X.Org Video Driver
[    61.657]     ABI class: X.Org Video Driver, version 24.1
[    61.658] (II) Loading /usr/local/lib/xorg/modules/drivers/modesetting_drv.so
[    61.670]     Module class: X.Org Video Driver
[    61.670]     ABI class: X.Org Video Driver, version 24.1
[    61.670] (II) Loading /usr/local/lib/xorg/modules/drivers/scfb_drv.so
[    61.682]     ABI class: X.Org Video Driver, version 24.1
[    61.682] (II) Loading /usr/local/lib/xorg/modules/drivers/vesa_drv.so
[    61.690]     Module class: X.Org Video Driver
[    61.690]     ABI class: X.Org Video Driver, version 24.1
[    61.690] (II) RADEON: Driver for ATI/AMD Radeon chipsets:
[    61.699] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[    61.699] (II) scfb: driver for wsdisplay framebuffer: scfb
[    61.699] (II) VESA: driver for VESA chipsets: vesa
[    61.699] (--) Using syscons driver with X support (version 2.0)
[    67.020] (II) RADEON(0): [DRI2]   DRI driver: r600
[    67.020] (II) RADEON(0): [DRI2]   VDPAU driver: r600
[    68.119]     Module class: X.Org XInput Driver
[    68.119]     ABI class: X.Org XInput driver, version 24.1
[    68.119] (II) Using input driver 'libinput' for 'System mouse'
[    68.309] (II) Using input driver 'libinput' for 'System keyboard multiplexer'
[    68.467] (II) Using input driver 'libinput' for 'AT keyboard'
```


----------



## T-Daemon (Apr 24, 2020)

asmar said:


> Ok, I finally managed to connect USB drive and copy it.



Please install misc/pastebinit . Use it next time, usage: `cat /var/log/Xorg.0.log | pastebinit`, that will return a URL, post that URL.

Please post the output (URL) of `pciconf -lv | grep -B3 display | pastebinit` , to make sure the correct driver is used. I'm unsure which driver is used at the moment, please clarify.


----------



## Alain De Vos (Apr 24, 2020)

You could try to remove unnecessary drivers.
pkg info | grep -i xf86-video
Remove everything except "scfb" and "vesa"
Try another monitor


----------



## asmar (Apr 25, 2020)

T-Daemon said:


> Please install misc/pastebinit . Use it next time, usage: `cat /var/log/Xorg.0.log | pastebinit`, that will return a URL, post that URL.
> 
> Please post the output (URL) of `pciconf -lv | grep -B3 display | pastebinit` , to make sure the correct driver is used. I'm unsure which driver is used at the moment, please clarify.



Currently, drivers are not selected explicitly and commented out as requested previously. I see I misread name of the graphics card. I apologize for that.

`pciconf -lv | grep -B3 display`: https://pastebin.com/PYbLvw8r

/etc/rc.conf: https://pastebin.com/9FJcpJxD

/usr/local/etc/X11/xorg.conf.d/driver-radeon.conf: https://pastebin.com/nMpfUbwE

`pkg info | grep -i xf86-video`: https://pastebin.com/W0xNCXBS

I switched to a different monitor and connected it using VGA instead of DVI. After `startx`, the screen still goes to sleep on Alt-F9. Switching back to Alt-F1:
`kldstat`: https://pastebin.com/srgyTbgB


----------



## T-Daemon (Apr 25, 2020)

asmar said:


> I see I misread name of the graphics card. I apologize for that.


Don’t worry, no problem.



asmar said:


> Currently, drivers are not selected explicitly and commented out as requested previously.



The output of /etc/rc.conf: https://pastebin.com/9FJcpJxD

```
#kld_list="/boot/modules/radeonkms.ko"
```
and kldstat: https://pastebin.com/srgyTbgB

```
1 0x1ac04000    c9000 radeonkms.ko
1 0x1accd000    4a000 drm2.ko
4 0x1ad17000     7000 iicbus.ko
1 0x1ad1e000     5000 iic.ko
1 0x1ad23000     7000 iicbb.ko
1 0x1ad2a000     4000 radeonkmsfw_RV730_pfp.ko
1 0x1ad2e000     5000 radeonkmsfw_RV730_me.ko
1 0x1ad33000     5000 radeonkmsfw_R700_rlc.ko
```
doesn’t end up. From where is radeonkms.ko loaded? Have you something set in /boot/loader.conf, or did you load it manually?

I believe that x11-drivers/xf86-video-ati is the needed driver. Make sure it’s installed: `pkg info | grep xf86-video-ati` , set in /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf:

```
Section "Device"
    Identifier "Card0"
    Driver     "radeon"
EndSection
```

run `startx`, report back about the result, and please post /var/log/Xorg.0.log.


----------



## asmar (Apr 25, 2020)

T-Daemon said:


> From where is radeonkms.ko loaded?


I believe it is loaded automatically since I didn't modify any other files and didn't load it manually. In /boot/loader.conf is only fuse.

The driver is installed as per: https://pastebin.com/W0xNCXBS



T-Daemon said:


> Section "Device" Identifier "Card0" Driver "radeon" EndSection


I saved the log before any setting and after this setting.

Before: https://pastebin.com/8KAiMRLB
After: https://pastebin.com/7ivBK7zd

Diff between before and after: https://pastebin.com/RAFxupw2

It seems to load the same kernel modules anyway. Just as a side note, on the wiki, it says to use `radeonkms` for similar cards and not `radeon`. Though as demonstrated earlier it doesn't work with either. https://wiki.freebsd.org/Graphics/AMD-GPU-Matrix


----------



## shkhln (Apr 25, 2020)

asmar said:


> It seems to load the same kernel modules anyway.



Xorg never loads kernel modules, it's not a kernel.


----------



## asmar (Apr 25, 2020)

shkhln said:


> Xorg never loads kernel modules, it's not a kernel.


Ok, sorry for the terminology. After I hit `startx`, *something* loads these radeon modules that are displayed in `kldstat`


----------



## shkhln (Apr 25, 2020)

You should actually _read_ /var/log/Xorg.0.log at least once, it's very clear from the log what Xorg calls "module" and what it tries to load.


----------



## asmar (Apr 25, 2020)

shkhln said:


> You should actually _read_ /var/log/Xorg.0.log at least once, it's very clear from the log what Xorg calls "module" and what it tries to load.


Yes, I have read it many, many times by now. And yes, I saw that it loads modules `ati_drv.so` and `radeon_drv.so`. But I also read the man page for `kldstat` which says "The kldstat utility displays the status of any files dynamically linked into the kernel."

And as far as I know .ko stands for "kernel object". Thus I called it kernel module. EDIT: As in radeonkms.ko.


----------



## T-Daemon (Apr 26, 2020)

asmar said:


> It seems to load the same kernel modules anyway. Just as a side note, on the wiki, it says to use `radeonkms` for similar cards and not `radeon`.


Not quite, there are two radeon driver from different packages. The wiki is referring to the radeonkms.ko driver installed by graphics/drm-kmod (graphics/drm-fbsd12.0-kmod actually, run `pkg info -l drm-fbsd12.0-kmod`), whereas radeon_drv.so (aka radeon) is installed by x11-drivers/xf86-video-ati. 

- radeonkms.ko is set in rc.conf(5), loaded by kldload(2)
- radeon_drv.so, aka "radeon”, is set in /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf, loaded by xorg.

Concerning the Xorg.0.logs:

```
[   475.804] failed to add FB for modeset
[   475.804] (WW) RADEON(0): Failed to set mode on CRTC 0
[   475.812] (EE) RADEON(0): Failed to enable any CRTC
```
(https://pastebin.com/8KAiMRLB, https://pastebin.com/7ivBK7zd9 )

There is an older bug report PR 232499 regarding x11-drivers/xf86-video-ati and the error messages. Op is reporting being successful with, x11-drivers/xf86-video-ati-legacy. You could try that driver, but it is currently marked as broken, a patch is available, easy to apply.


----------



## asmar (Apr 26, 2020)

T-Daemon said:


> Not quite, there are two radeon driver from different packages. The wiki is referring to the radeonkms.ko driver installed by graphics/drm-kmod (graphics/drm-fbsd12.0-kmod actually, run `pkg info -l drm-fbsd12.0-kmod`), whereas radeon_drv.so (aka radeon) is installed by x11-drivers/xf86-video-ati.
> 
> - radeonkms.ko is set in rc.conf(5), loaded by kldload(2)
> - radeon_drv.so, aka "radeon”, is set in /usr/local/etc/X11/xorg.conf.d/driver-radeon.conf, loaded by xorg.
> ...


Thank you for investigation and clarification. I ran across this bug report previously but didn't get further than the broken message.

I applied the patch and compiled. Then rebooted and started X. I am not sure what's the take on this: https://pastebin.com/iM7qVx3m

EDIT: I also removed the `xf86-video-ati`.


----------

