# Custom kernel with i915kms, radeonkms and all needed firmware files in the kernel image



## Logicien (May 12, 2020)

Hello,

I use FreeBSD 12.1-RELEASE-p3 GENERIC  amd64 in an HP tower with an integrated Intel video card or with an Amd/Ati Pcie card. In /etc/rc.fonf I have the line

kld_list="radeonkms"

to load the radeonkms module at boot time, better to load this module there than in /boot/loader.conf I have read. radeonkms work well for me in the console, I use modesetting with Xorg. It take time before radeonkms load and before this I do not have the native resolution of the screen.

I want to compile a custom kernel who will include i915kms, radeonkms and all the needed firmware files in the kernel image to have KMS available at early boottime. Looking at /usr/src/sys/amd64/conf/GENERIC I see no option who allow me to do that. I have search on Internet without success. Is some of you know if it is possible and if yes which lines I must put in my custom kernel configuration file to do so?

I would like to have KMS support in the kernel image instead of as modules but if you know a faster way than in rc.conf to load radeonkms or i915kms at boot time you can tell me too.

A last question,  which Xorg video driver is better with KMS between xf86-video-amdgpu, xf86-video-ati and the integrated modesetting driver for a

[AMD/ATI] Cedar [Radeon HD 5000/6000/7350/8350 Series]

video card. Only modesetting work. Same thing for a

Intel Corporation 4 Series Chipset Integrated Graphics Controller

video card. Is xf86-video-intel good or modesetting even better?


----------



## zirias@ (May 12, 2020)

You're heading into the wrong direction. DRM/KMS in the kernel is deprecated and will be removed -- in fact, I wonder why it's still there on 12.x. This setting:


Logicien said:


> kld_list="radeonkms"


will load an old deprecated driver, because even if you installed graphics/drm-kmod, /boot/kernel is searched before /boot/modules. So, as long as those deprecated drivers are still part of the kernel, you should explicitly load the newer ones with full path like e.g.

```
kld_list="/boot/modules/radeonkms.ko"
```
The way to load a driver early is to do it from /boot/loader.conf, there's no need to compile it into the kernel image. But as you already know, this is not recommended for the drm kms drivers, as it often triggers strange misbehavior. You can test it on your own risk of course.


----------



## PMc (May 12, 2020)

Logicien said:


> I use FreeBSD 12.1-RELEASE-p3 GENERIC  amd64 in an HP tower with an integrated Intel video card or with an Amd/Ati Pcie card. In /etc/rc.fonf I have the line
> 
> kld_list="radeonkms"
> 
> to load the radeonkms module at boot time, better to load this module there than in /boot/loader.conf I have read.



That depends. When loading from /etc/rc.conf, a module will only be present after going multiuser, but not in single-user (maintenance) mode. When loading from /boot/loader.conf, they will already be present when the kernel takes control.
There are pro's and con's for either approach.



> It take time before radeonkms load and before this I do not have the native resolution of the screen.



See above.



> I want to compile a custom kernel who will include i915kms, radeonkms and all the needed firmware files in the kernel image to have KMS available at early boottime. Looking at /usr/src/sys/amd64/conf/GENERIC I see no option who allow me to do that. I have search on Internet without success. Is some of you know if it is possible and if yes which lines I must put in my custom kernel configuration file to do so?



I am doing this, but with an intel graphics (ivybridge), on 11.3. It is not possible to do this by only changing the kernel configuration; it is necessary to modify a few files in the kernel sources also. And in the future it will no longer be possible at all, because people have decided to move the graphics driver source code out of the kernel source entirely, and deliver it as ports.

So it does currently not make sense to go into that direction.


----------



## Logicien (May 13, 2020)

Thank-you for you answers,

it easy my task, if KMS is going to be retired in the future I will not bet on it and that's make unnecessary for me to have a custum kernel for the moment. I have try to load radeonkms from /boot/loader.conf but it was not loaded when I was in multiuser session. I will try again.


----------



## Logicien (May 13, 2020)

I have install drm-kmod. I succeed to load /boot/modules/radeonkms.ko through rc.conf giving the full path

```
kld_list="/boot/modules/radeonkms.ko"
```
But like the deprecated /boot/kernel/radeonkms.ko it is impossible to load the module through /boot/loader.conf. If someone how to load
/boot/modules/radeonkms.ko through /boot/loader.conf you are welcome.


----------



## gnath (May 13, 2020)

Yes, you can, but why you want to. This may lead to unbootable system. Ref. loader.conf()


----------



## Logicien (May 15, 2020)

The idea is to make load radeonkms the earliest has possible but, it's ok via /etc/rc.conf. I have remark that the radeonkms load earlier when the message 'Loading kernel modules' appear at boot. I have put radeonkms the first in the line

kld_list="/boot/modules/radeonkms.ko autofs ext2fs fuse linux smbfs"


----------

