# i915 GPU hang on FreeBSD 13



## nickednamed (Oct 12, 2021)

Hi all,

My computer freezes during graphical sessions with a "GPU hang" message at least once a day:

```
drmn0: Resetting chip for hang on rcs0
```


First my graphical application freezes, then the mouse freezes, then I get a black screen with a cursor in the middle, and so far have been unable to kill X, run any commands (blindly), get back to TTY, etc. I must press the reset button and reboot.

I'm using:

`uname -a`

```
FreeBSD 13.0-RELEASE-p4 GENERIC
```


`dmesg | grep Intel`

```
Intel i7-2620M with built-in GPU
```

I installed via graphics/drm-kmod (tried both quarterly packages and from ports, nothing changed)


`pkg which /boot/modules/i915kms.ko:`

```
/boot/modules/i915kms.ko was installed by package drm-fbsd13-kmod-5.4.144.g20210908
```


My /etc/rc.conf contains the following:

```
kld_list="i915kms"
```


`kldstat` shows the following are loaded:

```
i915kms.ko
drm.ko
```


`kldstat -h -v -n i915kms` shows that I am loading the following:

```
/boot/modules/i915kms.ko
```


I have tried the advice here: https://lists.freebsd.org/pipermail/freebsd-questions/2021-May/294002.html
I.E. I tried changing kld_list="i915kms" to kld_list="drm" but this left me with a low-resolution console and desktop which I was unable to change with x11/xrandr, for example.


My /boot/loader.conf contains the following, but commenting them out in various combinations made no difference.:

```
drm.i915.enable_rc6=7
compat.linuxkpi.enable_dc=2
compat.linuxkpi.enable_fbc=1
```


The Xorg.0.log doesn't show any helpful entries after restarting, but just in case:








						Xorg.0.log - Pastebin.com
					

Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.




					pastebin.com
				




I believe I am using the "modesetting" driver.
`cat /var/log/Xorg.0.log | grep -i modesetting:`

```
[ 32.807] (==) Matched modesetting as autoconfigured driver 1
[ 32.808] (II) LoadModule: "modesetting"
[ 32.808] (II) Loading /usr/local/lib/xorg/modules/drivers/modesetting_drv.so
[ 32.808] (II) Module modesetting: vendor="X.Org Foundation"
[ 32.810] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
```


Messages show the following:
`cat /var/log/messages | grep -i "Oct 11 15:08:":`

```
Oct 11 15:08:57 laptop devd[56925]: notify_clients: send() failed; dropping unresponsive client
Oct 11 15:08:57 laptop kernel: drmn0: GPU HANG: ecode 6:1:0xc3c3c3c3, in MainThread [100526], hang on rcs0
Oct 11 15:08:57 laptop kernel: drmn0: Resetting chip for hang on rcs0
Oct 11 15:08:57 laptop syslogd: last message repeated 2 times
```


I have read the following but it didn't help me:





						104520 – Intermittent X crashes: GPU HANG: ecode 9:0:0x85dffffb, in Xorg [443], reason: Hang on rcs0, action: reset
					






					bugs.freedesktop.org
				




I have nothing in /usr/local/etc/Xorg/xorg.conf.d/ apart from loading some fonts.

I start my graphical session with startx, and the problem persists with multiple window managers.

I have run out of ideas.
Any suggestions?


----------



## eternal_noob (Oct 12, 2021)

I had the same problem, see https://forums.freebsd.org/threads/how-to-debug-freezing-xorg.78990/
The solution for me was to deinstall the xf86-video-intel driver. Don't know if it works for you.

Or try to use DRI 1 only:

```
Option       "DRI"           "1"
```
in X.Org config


----------



## nickednamed (Oct 12, 2021)

eternal_noob said:


> I had the same problem, see https://forums.freebsd.org/threads/how-to-debug-freezing-xorg.78990/
> The solution was to deinstall the xf86-video-intel driver.


I do not have xf86-video-intel installed.


----------



## bsduck (Oct 12, 2021)

No idea how to solve this, but as a workaround you can try using xf86-video-intel instead of modesetting. That's what I use at the moment because of an other bug affecting drm-kmod.


----------



## eternal_noob (Oct 12, 2021)

> As a workaround to get reliable sleep/resume I use xf86-video-intel instead of drm-kmod.


I think you confuse things a bit here. drm-kmod is the kernel driver while xf86-video-intel is an X.Org driver.
You can't use one or the other. It's drm-kmod AND (xf86-video-intel OR modesetting).


----------



## bsduck (Oct 12, 2021)

You're right, sorry. I don't know if those bugs (the hang mentioned here as well as the suspend/resume one) are imputable to modesetting or rather to drm-kmod, but at least in my case using xf86-video-intel instead of modesetting solved it.


----------



## nickednamed (Oct 14, 2021)

eternal_noob said:


> I had the same problem, see https://forums.freebsd.org/threads/how-to-debug-freezing-xorg.78990/
> The solution for me was to deinstall the xf86-video-intel driver. Don't know if it works for you.
> 
> Or try to use DRI 1 only:
> ...


Thank you. So if I have understood the manual correctly, this is what you mean?

In /usr/local/etc/Xorg/xorg.conf.d/DRI.conf:

```
Section "DRI"
        Option        "DRI"        "1"
EndSection
```


----------



## eternal_noob (Oct 14, 2021)

I never tried this but i believe this is a device option:

```
Section "Device"
    Identifier  "Intel Graphics"
    Driver      "modesetting"
    Option      "DRI"  "1"
EndSection
```


----------



## Alexander88207 (Oct 14, 2021)

I would first try it with DRI 2 since the standard is DRI 3.

If it still does not work, i would create a PR in your place, after all, this problem should be solved because simply switch to older or other things is not the right solution in a long term.

Back when DXVK really was going on we had often gpu hangs which we all have reported fastly.


----------



## nickednamed (Oct 18, 2021)

eternal_noob said:


> I never tried this but i believe this is a device option:
> 
> ```
> Section "Device"
> ...


OK - I will try this (first with "DRI 2" and then "DRI 1") soon and report back.

However, a new version of graphics/drm-kmod (specifically, in my case graphics/drm-fbsd13-kmod and graphics/gpu-firmware-kmod) has recently landed in the quarterly repo, so I will try this for a few days and see how that goes first.

If neither works, I will install x11-drivers/xf86-video-intel and see how that goes and then report back.


----------



## rhsbsd (May 30, 2022)

x11-drivers/xf86-video-intel has been installed on my desktop since FreeBSD 8 or 9? Present configuration:
Operating System: FreeBSD 13.0
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.2
Kernel Version: 13.0-RELEASE-p11 (64-bit)
Graphics Platform: X11
Memory: 15.9 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 3000

This box definitely has some age on it. I build using poudriere. This supposed GPU hang problem has been hanging around since FreeBSD 11.1 and presenting itself in all sorts of manners. You know, 'The hit the power button hang', 'the reboot from console hang' and finally the 'restart plasma5 from vt hang. To further complicate things these hangs sometimes appeared to occur more regularly after some inexplicable sequence or usage if you will. To be honest I feel like an Intel ninja warrior.
Below are the only changes I needed to get rid of this annoyance.
This is in/etc

```
kld_list="/boot/modules/i915kms.ko"
```
As per eternal-noob's post x11-drivers/xf86-video-intel is deleted. Then something amazing happened, on first reboot my plasma5/sddm login page DID NOT FLICKER when mousing over the login rectangle. After checking logs DRI2 was enabled by default and this Sandy Bridge intel HD3000 machine has not had a single hang for a week. That has not happened in a long time.
To conclude it looks as if the newer drivers did not play well with Xorg.


----------



## grahamperrin@ (Jun 16, 2022)

rhsbsd try graphics/drm-510-kmod with FreeBSD 13.1-RELEASE.


----------



## Vull (Jun 16, 2022)

Please notice that OP nickednamed has not posted since October of last year. Having noted that, I too was having similar timing problems and system deadlocks last year, while using older point releases of 13.0-RELEASE, with both the radeonkms and i915kms kernel modesetting drivers.

I suggest first upgrading to 13.0-RELEASE-p11 using `freebsd-update fetch && freebsd-update install`.

If that doesn't work, you might try removing all _graphics configuration_ hints, if you now have any, from /etc/X11/xorg.conf, /etc/X11/xorg.conf.d/, /usr/local/etc/X11/xorg.conf, /usr/local/etc/X11/xorg.conf.d/, and /boot/loader.conf files and directories. I do not have a /usr/local/etc/Xorg/ directory, however, these measures, if I recall correctly, should cause the i915kms kernel modesetting driver and the modesetting video driver to be automatically loaded when X starts.

If that still doesn't work, try removing the `kld_list="i915kms"` directive from /etc/rc.conf, and installing the package xf86-video-intel. This should cause the "intel" video driver to be automatically loaded when X starts, instead of the more generic "modesetting" video driver.

If still no luck, you might consider upgrading to 13.1-RELEASE, especially considering that 13.0 will be end-of-life in just a few more months.


----------



## rhsbsd (Jun 17, 2022)

grahamperrin@ said:


> rhsbsd try graphics/drm-510-kmod with FreeBSD 13.1-RELEASE.


Is this the package that is touted as more intelligent, and sets up the driver stack based on hardware detection? Presently using graphics/drm-fbsd13-kmod-5.4.144.g20220223. Plain text cause port macros just did not work! Just checking cause really my acceleration is better now than its ever been on any version of FBSD. Also I messed up reading my logs and this driver is using 'DRI 1' by default. Three weeks and nary a tear or hang in sight.


----------



## cynwulf (Sep 30, 2022)

rhsbsd said:


> As per eternal-noob's post x11-drivers/xf86-video-intel is deleted. Then something amazing happened, on first reboot my plasma5/sddm login page DID NOT FLICKER when mousing over the login rectangle.


I can confirm this.  Once xf86-video-intel is removed, the flickering on sddm has ceased.


```
% grep -i modesetting /var/log/Xorg.0.log
[   183.511] (==) Matched modesetting as autoconfigured driver 1
[   183.511] (II) LoadModule: "modesetting"
[   183.511] (II) Loading /usr/local/lib/xorg/modules/drivers/modesetting_drv.so
[   183.511] (II) Module modesetting: vendor="X.Org Foundation"
[   183.511] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
```

(I'm sure I've avoided modesetting before on FreeBSD, due to some other problems.)

FreeBSD testing 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC amd64
Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (3192.72-MHz K8-class CPU)
Intel(R) HD Graphics 4600


I upgraded to drm-510-kmod just now as well. I had previously downgraded to drm-45-kmod, due to instant reboots.  With the 5.4 version, at least it was only a GPU hang and I could recover from it by killing Xorg.  in my case it always hangs when the system is inactive over night and on attempting to log in again in the morning.  I've had these problems since around 12.x, so will see how it goes.

Thanks all

Update 03/10/22:  No GPU hangs so far.
Update 04/10/22:  Still no GPU hangs.

To summarise:

With xf86-video-intel _removed_ and drm-510-kmod _installed_ the sddm flickering problem is gone, stability has returned and no more GPU hangs.


```
pkg info drm-510-kmod
drm-510-kmod-5.10.113_7
Name           : drm-510-kmod
Version        : 5.10.113_7
Installed on   : Tue Oct  4 15:43:59 2022 BST
Origin         : graphics/drm-510-kmod
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : kld graphics
Licenses       : MIT and GPLv2 and BSD2CLAUSE
Maintainer     : x11@FreeBSD.org
WWW            : https://github.com/freebsd/drm-kmod/
Comment        : DRM drivers modules
Annotations    :
        FreeBSD_version: 1301000
Flat size      : 12.6MiB
Description    :
amdgpu, i915, and radeon DRM drivers modules.
Currently corresponding to Linux 5.10 DRM.
This version is for FreeBSD 13.1 and above.

WWW: https://github.com/freebsd/drm-kmod/
```


----------

