Bug 259019 - kld_list="radeonkms" in /etc/rc.conf -> kernel panic
Summary: kld_list="radeonkms" in /etc/rc.conf -> kernel panic
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-09 01:17 UTC by donaldcallen
Modified: 2022-03-15 14:08 UTC (History)
2 users (show)

See Also:


Attachments
dmesg (51.62 KB, text/plain)
2021-10-09 01:17 UTC, donaldcallen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description donaldcallen 2021-10-09 01:17:56 UTC
Created attachment 228531 [details]
dmesg

In trying to run a newly installed copy of FreeBSD 13 on the machine described in the attached dmesg, I need to load radeonkms kernel module in order to obtain full resolution when running X. Following the man page for rc.conf, which says:

kld_list	 (str) A whitespace-separated list of kernel modules to	load
		 right after the local disks are mounted, without any .ko ex-
		 tension or path.  Loading modules at this point in the	boot
		 process is much faster	than doing it via /boot/loader.conf
		 for those modules not necessary for mounting local disks.

Noting "without any .ko extension or path", I added the line

kld_list="radeonkms"

Prior to doing so, the system would boot normally and I could run 'startx' and X would come up, but with VGA resolution. After adding the line above, the system would crash while booting. I found the following in /var/log/messages:

Oct  8 11:03:09 giovanni kernel: Fatal trap 12: page fault while in kernel mode
Oct  8 11:03:09 giovanni kernel: cpuid = 3; apic id = 03
Oct  8 11:03:09 giovanni kernel: fault virtual address  = 0x0
Oct  8 11:03:09 giovanni kernel: fault code     = supervisor read data, page not present
Oct  8 11:03:09 giovanni kernel: instruction pointer    = 0x20:0xffffffff80853b62
Oct  8 11:03:09 giovanni kernel: stack pointer          = 0x28:0xfffffe011604f4d0
Oct  8 11:03:09 giovanni kernel: frame pointer          = 0x28:0xfffffe011604f500
Oct  8 11:03:09 giovanni kernel: code segment       = base rx0, limit 0xfffff, type 0x1b
Oct  8 11:03:09 giovanni kernel:            = DPL 0, pres 1, long 1, def32 0, gran 1
Oct  8 11:03:09 giovanni kernel: processor eflags   = interrupt enabled, resume, IOPL = 0
Oct  8 11:03:09 giovanni kernel: current process        = 70998 (kldload)
Oct  8 11:03:09 giovanni kernel: trap number        = 12
Oct  8 11:03:09 giovanni kernel: panic: page fault
Oct  8 11:03:09 giovanni kernel: cpuid = 3
Oct  8 11:03:09 giovanni kernel: time = 1633705330
Oct  8 11:03:09 giovanni kernel: KDB: stack backtrace:
Oct  8 11:03:09 giovanni kernel: #0 0xffffffff80c57345 at kdb_backtrace+0x65
Oct  8 11:03:09 giovanni kernel: #1 0xffffffff80c09d21 at vpanic+0x181
Oct  8 11:03:09 giovanni kernel: #2 0xffffffff80c09b93 at panic+0x43
Oct  8 11:03:09 giovanni kernel: #3 0xffffffff8108b187 at trap_fatal+0x387
Oct  8 11:03:09 giovanni kernel: #4 0xffffffff8108b1df at trap_pfault+0x4f
Oct  8 11:03:09 giovanni kernel: #5 0xffffffff8108a83d at trap+0x27d
Oct  8 11:03:09 giovanni kernel: #6 0xffffffff810617a8 at calltrap+0x8
Oct  8 11:03:09 giovanni kernel: #7 0xffffffff82371f76 at evergreen_fix_pci_max_read_req_size+0x176
Oct  8 11:03:09 giovanni kernel: #8 0xffffffff823795fc at evergreen_startup+0x87c
Oct  8 11:03:09 giovanni kernel: #9 0xffffffff8237b7cc at evergreen_init+0x28c
Oct  8 11:03:09 giovanni kernel: #10 0xffffffff823d0980 at radeon_device_init+0xde0
Oct  8 11:03:09 giovanni kernel: #11 0xffffffff823e1009 at radeon_driver_load_kms+0x139
Oct  8 11:03:09 giovanni kernel: #12 0xffffffff824ae7b6 at drm_dev_register+0xc6
Oct  8 11:03:09 giovanni kernel: #13 0xffffffff823d7830 at radeon_pci_probe+0x230
Oct  8 11:03:09 giovanni kernel: #14 0xffffffff80e4301b at linux_pci_attach_device+0x30b
Oct  8 11:03:09 giovanni kernel: #15 0xffffffff80c4653d at device_attach+0x3dd
Oct  8 11:03:09 giovanni kernel: #16 0xffffffff80c48196 at bus_generic_driver_added+0xb6
Oct  8 11:03:09 giovanni kernel: ---<<BOOT>>---

Oddly, and contrary to what the man page says, changing the added line in rc.conf to

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

allows the system to boot and the radeonkms driver is apparently loaded, as the resolution in X is now correct.
Comment 1 donaldcallen 2021-10-09 13:01:04 UTC
Things have changed this morning. I shut my system down last night. This morning, I attempted to reboot it. It took three tries to get the system up, the first two attempts resulted in crashes. This is with the full path to radeonkms.ko in the kld_list entry in rc.conf. I prematurely reached a conclusion about the syntax of the line in rc.conf being causal from too few samples in a probabilistic situation. My experience this morning demonstrates that the syntax used in rc.conf is not the causal factor. There is clearly a timing bug in the process by which the radeonkms driver is installed and initialized.
Comment 2 donaldcallen 2021-10-10 12:31:47 UTC
This is changing again, as more experience is gathered.

At the suggestion of a couple of people who have contributed to a thread about this issue, I installed the xf86-video-ati X driver. That driver was not installed on my system when the crashes I have described here occurred. There is no mention in the documentation that this is required, nor is the X driver a dependency of the drm-kmod port or package.

Since doing this, I have rebooted my system several times without incident and with correct resolution in X. The radeonkms kernel module is also installed, loaded by kld_list="radeonkms" in rc.conf.

Given the crash free performance of my system through multiple reboots, it's beginning to look like the bug is that installation of drm-kmod, either as a port or a package, does not depend upon the corresponding X drivers (xf86-video-intel, -ati, -amd) and should.
Comment 3 Ed Maste freebsd_committer freebsd_triage 2022-03-03 15:36:56 UTC
If you have a panic with
  kld_list="radeonkms"
and success with
  kld_list="/boot/modules/radeonkms.ko"
it sounds to me like there are at least two copies of radeonkms on this system (one in /boot/modules/ perhaps?), one of which is old/broken/incompatible.

radeonkms should not panic regardless of whether xf86-video-ati is installed or not - it is perfectly reasonable to install the KMS drivers to have a high-resolution console and so that suspend/resume works, even if X is not in use.
Comment 4 donaldcallen 2022-03-15 14:00:52 UTC
@Ed Maste -- This has nothing to do with the syntax used to specify the syntax used to specify the kernel module in rc.conf. Read on.

I have revisited this, as I am now using FreeBSD more widely than was the case when I originally reported this. So I need it working reliably on the machine with which I had the problem originally reported.

Reinstalling FreeBSD 13 on that machine, I found that with the line
KLD_LIST="radeonkms"
in rc.conf, the system would crash while booting, as I originally reported.

Installing xf86-video-ati made the situation slightly better. The system would occasionally boot, but more often than not, it would crash while booting.

Additionally installing xf86-video-amdgpu solves the problem. Now the system boots reliably.

I think the fix is either to make both of the xf86-video-* drivers dependencies of the drm-kms package, or at the very least, fix the documentation to note that if you are going to try to use the radeonkms driver on an old AMD-based system, you need to install the two X drivers or you will have the serious problem I encountered.
Comment 5 donaldcallen 2022-03-15 14:08:37 UTC
(In reply to donaldcallen from comment #4)
Well, I can't edit or delete my own comment after posting (I note that there is a bug submission from a few years about the lack of this capability in bugzilla and it seems not to have been acted upon; yes, I realize programming resources are limited) and I noticed an editing error. 

The first lines of the previous comment should be

@Ed Maste -- This has nothing to do with the syntax used to specify the kernel module in rc.conf. Read on.