Bug 271897 - graphics/drm-510-kmod: loading amdgpu and i915kms kernel modules simultaneously causes the system to crash
Summary: graphics/drm-510-kmod: loading amdgpu and i915kms kernel modules simultaneous...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL: https://www.freshports.org/graphics/d...
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2023-06-08 00:26 UTC by Patrick McMunn
Modified: 2024-03-03 22:41 UTC (History)
6 users (show)

See Also:


Attachments
Kernel panic/page fault backtrace (48.34 KB, text/plain)
2023-06-09 00:41 UTC, Patrick McMunn
no flags Details
core dump analysis (99.57 KB, text/plain)
2023-06-13 06:56 UTC, Graham Perrin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick McMunn 2023-06-08 00:26:33 UTC
I have a desktop system with a Radeon RX 240 graphics card and an Intel i7-3770S CPU which has Intel HD 4000 integrated graphics. I did a fresh install of 13.2-RELEASE yesterday with the intention of using OBS studio for content creation. I use the Radeon graphics card to drive my primary display, and I have a second display connected to the integrated graphics port. I also use the integrated GPU for hardware video encoding. As such, I need to use the amdgpu kernel module to provided accelerated graphics on my primary display and i915kms to enable hardware video encoding on the integrated GPU. That's what led me to try loading both kernel modules and to discover that the system crashes, does a kernel dump, and reboots. It would be really nice to get these two modules playing well together for my intended use case.
Comment 1 Mina Galić freebsd_triage 2023-06-08 00:53:48 UTC
can you please attach the crashdump to this bug report?
Comment 2 Patrick McMunn 2023-06-08 01:34:26 UTC
(In reply to Mina Galić from comment #1)
I tried to upload it as an attachment, but I got an error PR_CONNECT_RESET_ERROR when trying to do so. Maybe because it exceeds the attachment file size limit? It says 1000KB is the maximum attachment size, and the dump is 554M in size. Is there another way I can send it to you?
Comment 3 Mina Galić freebsd_triage 2023-06-08 19:57:04 UTC
(In reply to Patrick McMunn from comment #2)
all we want, as a start, is backtrace https://docs.freebsd.org/en/books/developers-handbook/kerneldebug/
Comment 4 Patrick McMunn 2023-06-09 00:41:56 UTC
Created attachment 242696 [details]
Kernel panic/page fault backtrace
Comment 5 Graham Perrin freebsd_committer freebsd_triage 2023-06-10 06:36:15 UTC
Assuming drm-510-kmod.
Comment 6 Patrick McMunn 2023-06-10 14:02:49 UTC
I apologize. I wasn't thinking about the drm package. I still think of drm as part of the base system. I can confirm that the current drm-510-kmod on my system is 5.10.163_7.
Comment 7 sozuba 2023-06-12 11:49:02 UTC
I face the same issue. I have installed drm-kmod, not sure if its drm-510-kmod. But in my case, setting kld_list="i915kms amdgpu" causes the system to not boot/panic/crash. Is there anything I should add to help solve the issue?
Comment 8 rkoberman 2023-06-12 16:02:01 UTC
First, trivial check on version of port installed:
> pkg info drm-\*
drm-515-kmod-5.15.25_3

I'm running head (14), so I'm unsure how or if 5.15 runs on 13.2. I believe I saw the lkpi stuff committed, but no promises.

More important, the drm=510-kmod package will crash on 13.2 a packages for 13.2 ar still built on 13.1 and will be until 13.1 goes EOL. You MUST build the port on a system with full 13.2 kernel sources available. The kernel sources are available on the install media for 13.2.
Comment 9 Graham Perrin freebsd_committer freebsd_triage 2023-06-12 22:33:45 UTC
(In reply to sozuba from comment #7)

> … setting kld_list="i915kms amdgpu" causes the system to 
> not boot/panic/crash. 

Causes the problem, or does 
not cause the problem?
Comment 10 Graham Perrin freebsd_committer freebsd_triage 2023-06-12 22:35:21 UTC
(In reply to rkoberman from comment #8)

> … how or if 5.15 runs on 13.2. …

<https://www.freshports.org/graphics/drm-515-kmod/>

>> This version is for FreeBSD 14.0 and above.
Comment 11 Patrick McMunn 2023-06-13 03:47:41 UTC
I spent ~5 hours after work this evening troubleshooting at the prompting of rkoberman's comments.

First of all, under 13.2-RELEASE, I found that the order in which the modules appear in kld_list does make a difference. If kld_list="amdgpu i915kms", the the kernel panics, dumps core, and reboots. If kld_list="i916kms amdgpu", the the system reboots without dumping core.

I tried building drm-515-kmod under 13.2-RELEASE, but it faild to compile. So I downloaded and installed FreeBSD-14.0-CURRENT-amd64-20230608-653738e895ba-263444. Under 14.0-CURRENT, both modules can appear in kld_list, and the system will continue to boot successfully without panicking. So that's good. But it is still exhibiting undesirable as well as baffling behavior.

Under 14.0-CURRENT, if i915ms either appears first or alone, the system will boot, but SDDM will error with "Failed to read display number from pipe" and "Could not start Display server on vt 9". But if kld_list="amdgpu i915kms", then SDDM will start successfully, and I can log into Plasma 5. But, only my secondary display connected to the integrated Intel graphics will have a graphical display. The boot messages appear on my primary display connected to my Radeon RX 240 until the drm kernel modules load. Then the text on the primary display freezes and continues on my secondary display. So once the drm kernel modules load, only my secondary display is functional.

At least with 13.2-RELEASE, I could load amdgpu alone and my primary display alone would be functional. But under 14.0-CURRENT, amdgpu alone results in a black screen on my primary display as soon as the drm kernel module loads. All I can do at that point is press CTRL-ALT-DEL to reboot. All tests on 14.0-CURRENT were with drm-515-kmod-5.15.25_3. I have not yet tried drm-510-kmod on 14.0-CURRENT.
Comment 12 Patrick McMunn 2023-06-13 05:07:17 UTC
It turns out the black screen with amdgpu was due to the GPU firmware not being installed. Once the firmware was installed, that issue was resolved. But, for some reason, I can currently only get SDDM and X to start if neither i915kms nor amdgpu is loaded (in which case X will use the scfb driver). I'm not sure what changed. In any case, it's not even clear how relevant that is.
Comment 13 Graham Perrin freebsd_committer freebsd_triage 2023-06-13 06:26:14 UTC
(In reply to rkoberman from comment #8)

> … drm=510-kmod package will crash on 13.2 … built on 13.1 …

Maybe true for your hardware, not true here: 

root@fuji:~ # uname -KU
1302001 1302001
root@fuji:~ # pkg info drm-510-kmod | grep FreeBSD_version
        FreeBSD_version: 1301000
root@fuji:~ # kldstat | grep i915
 5    1 0xffffffff82b18000   1858b8 i915kms.ko
root@fuji:~ #
Comment 14 Graham Perrin freebsd_committer freebsd_triage 2023-06-13 06:36:40 UTC
(In reply to Patrick McMunn from comment 11 and comment 12)

Please, let's keep this bug report focused on kernel panics. Thanks.

----

Questions relating to other symptoms can be asked elsewhere. 

Re: <https://www.freebsd.org/community/>, I'm most often in /r/freebsd
Comment 15 Graham Perrin freebsd_committer freebsd_triage 2023-06-13 06:56:33 UTC
Created attachment 242754 [details]
core dump analysis

(In reply to Mina Galić from comment #3)

Kernel panic resulting from: 

kldload amdgpu

Dump header from device: /dev/ada0p2
  Architecture: amd64
  Architecture Version: 2
  Dump Length: 371363840
  Blocksize: 512
  Compression: none
  Dumptime: 2023-06-13 07:05:45 +0100
  Hostname: fuji
  Magic: FreeBSD Kernel Dump
  Version String: FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC
  Panic String: page fault
  Dump Parity: 1984728343
  Bounds: 0
  Dump Status: good

<https://bsd-hardware.info/?probe=f6540a4d85> – whilst this hardware does not include AMD graphics, I assume that we should be able to load the module without the kernel panicking.
Comment 16 sozuba 2023-06-13 08:32:58 UTC
(In reply to Graham Perrin from comment #9)
Causes the problem.
Comment 17 Graham Perrin 2024-03-02 22:13:09 UTC
Also: 

Kernel panic with attempted load of i915kms after amdgpu · Issue #289 · freebsd/drm-kmod
<https://github.com/freebsd/drm-kmod/issues/289>