Solved Switching between TTY consoles breaks Intel hardware acceleration (i915kms)

Switching between TTY consoles breaks Intel hardware acceleration (i915kms)
The problem began to be noticed on FreeBSD 13, in the spring of 2023.

Other similar discussions on this issue

SOLUTION

FreeBSD 13.2
FreeBSD 14.1
CPU: Intel i7-4770k
GPU: Intel HD Graphics 4600
Kernel module: i915kms
Xorg, sddm
User are member of the video group.

Code:
# pkg info | grep -i drm
drm-61-kmod-6.1.92             DRM drivers modules
libdrm-2.4.123,1               Direct Rendering Manager library and headers

# pkg info | grep -i mesa
mesa-dri-24.1.7_1              OpenGL hardware acceleration drivers for DRI2+
mesa-libs-24.1.7_1             OpenGL libraries that support GLX and EGL clients

# pkg info | grep -iE 'intel|libva|vaapi'
libva-2.22.0                   VAAPI wrapper and dummy driver
libva-intel-driver-2.4.1_3     VAAPI legacy driver for Intel GMA 4500 (Gen4) to UHD 630 (Gen9.5)
libva-intel-hybrid-driver-1.0.2_3 Hybrid VP8 encoder and VP9 decoder for Intel GPUs
libva-utils-2.22.0             Collection of tests and utilities for VAAPI
xf86-video-intel-2.99.917.923_1,1 X.Org legacy driver for Intel integrated graphics chipsets

Code:
kern.vt.suspendswitch=0

After switching from a graphical console to another console via CTRL+ALT+F1 and back CTRL+ALT+F9, hardware graphics acceleration disappears.
Example of vainfo output before and after switching:

Before switching:
Code:
# vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD

After switching:
Code:
# vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.22.0
libva error: vaGetDriverNames() failed with unknown libva error
vaInitialize failed with error code -1 (unknown libva error),exit

Other variations of vainfo after switching, with hardware acceleration not working:
Code:
# vainfo --display drm
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD

# vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD

# vainfo --display drm --device /dev/dri/card0
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD


vainfo in TTY console:
Code:
# vainfo
Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD

Code:
# glxinfo -B
name of display: :0.0
failed to authenticate magic 1
failed to load driver: crocus
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 15.0.7, 256 bits) (0xffffffff)
    Version: 24.1.7
    Accelerated: no
    Video memory: 32768MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 0 MB, largest block: 0 MB
    VBO free aux. memory - total: 29966 MB, largest block: 29966 MB
    Texture free memory - total: 0 MB, largest block: 0 MB
    Texture free aux. memory - total: 29966 MB, largest block: 29966 MB
    Renderbuffer free memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free aux. memory - total: 29966 MB, largest block: 29966 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 0 MB
    Total available memory: 32768 MB
    Currently available dedicated video memory: 0 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 15.0.7, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 24.1.7
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 24.1.7
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.1.7
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

The problem is reproduced both without xorg.conf and with the "intel" driver specified
Code:
# cat /usr/local/etc/X11/xorg.conf.d/xorg.conf

Section "Device"
        Identifier  "Card0"
        Driver      "intel"
        BusID       "PCI:0:2:0"
EndSection

Who knows why this happens?
Is it possible to fix this?
Thanks.
 
Last edited:
Or upgrade to 14.2-RELEASE


But then you wade into the whole DRM mess.

Best to wait a while on Xorg.

Maybe 14.1-RELEASE is best for now.
 
The usual answer: compile the drm package from ports.
Not a solution in this case unfortunately; I experienced this on both 14.1-RELEASE and 14.2-RELEASE (and probably even before, I don't recall since I rarely switch from Xorg to a console) with drm-kmod built from ports. The only way to re-enable hardware acceleration was to restart XDM (if OP doesn't use a login manager maybe restarting Xorg could do, but is pretty impractical in both ways).
 
Or, upgrade to 14.1-RELEASE.
Or upgrade to 14.2-RELEASE
Best to wait a while on Xorg.
The problem began to be noticed on FreeBSD 13, in the spring of 2023.

As Maxnix correctly said, restarting the graphics subsystem helps. I do one of:
1) Start - Logout. Login via user input.
2) or service sddm restart

I experienced this on both 14.1-RELEASE and 14.2-RELEASE (and probably even before)
What processor/video card do you have and what driver are you using?
 
Found a few more similar topics:

amdgpu: Acceleration disabled by VT switch
https://github.com/freebsd/drm-kmod/issues/175
2022-07-07
13.1-RELEASE

Не могу разобраться с графикой в FreeBSD 13.1
https://bsdportal.ru/viewtopic.php?f=11&t=29323
2022-09-29
FreeBSD 13.1

graphics/drm-510-kmod: X11 GL_RENDERER reverts to llvmpipe after waking from suspend
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266745
2022-10-01
Status: Closed DUPLICATE of bug 271995

drm-510-kmod: Linuxulator GL_RENDERER reverts to llvmpipe after waking from suspend
https://github.com/freebsd/drm-kmod/issues/209
2022-10-02
13.1-RELEASE-p2

x11-wm/mutter: after graphics/mesa-* 21.3.8 -> 22.2.3 update OpenGL compositing fails on Intel Iris Pro
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267915
2022-11-22
Status: Open

graphics/drm-{510,515,61}-kmod: VT switch disables hardware acceleration
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271995
2023-06-14
Status: Open

Intermittant bug in 14.0-RELEASE DRI/crocus driver?
https://forums.freebsd.org/threads/intermittant-bug-in-14-0-release-dri-crocus-driver.91824/
2024-01-08

Switching between TTY consoles breaks Intel hardware acceleration (i915kms)
https://forums.freebsd.org/threads/...aks-intel-hardware-acceleration-i915kms.96348
2025-01-06
FreeBSD 13.2
FreeBSD 14.1
FreeBSD 14.2
 
Last edited:
The last drm package that didn't have such problems was 'drm-fbsd13-kmod'. I used it when I was on branch 13. Newer versions of the package worked as described in the topic. I upgraded to branch 14 and found that the problem was still not fixed (I'm currently on version 14.2-RELEASE).

Same problem in FreeBSD 13.1 from September 29, 2022
 
I accidentally found a solution to fix the loss of hardware acceleration.
I enabled dri 3 in xorg.conf:
Code:
Option "DRI" "3"

This configuration for the intel i7-4770k is enough to prevent the problem from reproducing.
/usr/local/etc/X11/xorg.conf.d/xorg.conf
Code:
Section "Device"
        Identifier  "Card0"
        Driver      "intel"
        Option      "DRI" "3"
        BusID       "PCI:0:2:0"
EndSection
Maxnix, JBrown, please check this option xorg.conf

List of installed drivers and other packages can be found in 1 message.

This solution has been tested and works on:
FreeBSD 14.1
FreeBSD 14.2 (build drm-61-kmod from ports)

!!! PROBLEM SOLVED !!! ☑️
 
Last edited:
also added to xorg.conf
Code:
Option "AccelMethod" "sna"
so that after a reboot, my resolution from /boot/loader.conf is set in the SDDM screen
kern.vt.fb.default_mode="1680x1050"

otherwise, SDDM is set to the maximum monitor resolution and the kern.vt.fb.default_mode parameter is ignored (only for SDDM).
For TTY kern.vt.fb.default_mode work.
 
Last edited:
This configuration for the intel i7-4770k is enough to prevent the problem from reproducing.
Section "Device" Identifier "Card0" Driver "intel" Option "DRI" "3" BusID "PCI:0:2:0" EndSectionMaxnix, JBrown, please check this option xorg.conf

Unfortunately, these parameters did not help me...
I tested the changes in /boot/loader.conf too, and didn't help me either. I suspect that what made the difference was only your xorg.conf.
However, as far as I can tell, you instructed Xorg to use the legacy Intel driver instead of the modesetting one this way; so unfortunately it's more a workaround than a real solution.
 
I tested the changes in /boot/loader.conf too, and didn't help me either. I suspect that what made the difference was only your xorg.conf.
Yes, I removed the settings message from /boot/loader.conf.
It only helps
Code:
Driver "intel"
Option "DRI" "3"
Does this configuration solve your problem on Intel HD Graphics 4600?

modesetting does not solve the problem unfortunately.

I want to try to install different other versions of FreeBSD: 13.0, 13.1, 12.* and install those versions of packages that were available at that time and see where modesetting will work correctly. And from this point move on, look for the distorting commit.
 
Is there a way of adding only that option without going back to a full xorg.conf?
Sort of. You add a .conf file in /usr/local/etc/X11/ with the relevant section, and add the option in that section.
here is an example, it gives my Xorg keyboard a Norwegian layout
Code:
root@kg-core2:~ # more /usr/local/etc/X11/xorg.conf.d/keyboard-no.conf
Section "InputClass"
        Identifier "keyboard defaults"
        MatchIsKeyboard "on"
        Option      "XkbLayout" "no"
EndSection
 
Is there a way of adding only that option without going back to a full xorg.conf?
Create 1 xorg.conf file in the catalog /usr/local/etc/X11/xorg.conf.d/
The full path of the file will be /usr/local/etc/X11/xorg.conf.d/xorg.conf
And insert the contents into it:

Code:
Section "Device"
        Identifier  "Card0"
        Driver      "intel"
        Option      "DRI" "3"
        BusID       "PCI:0:2:0"
EndSection

Come out of the system and re -enter or reboot.
Other lines in /usr/local/etc/X11/xorg.conf.d/xorg.conf are not required.
 
Last edited:
After I added the Option "DRI" "3" I have another problem: at an arbitrary moment in time, the monitor screen may become black for a few seconds and then returns to work.

This happens mainly at the time of working with the mouse or keyboard, i.e. Not at moments of downtime.
Sometimes it can be 1-2 times a day, sometimes 5-6 times a day or more often. Absolutely arbitrary.

The logs are empty.

------
Add:
In moments of downtime, a black screen can also appear.
 
Last edited:
Back
Top