r/voidlinux • u/whichpaul • Dec 12 '19
A Quick Guide to Optimizing Intel Graphics on Void Linux
The following is a quick guide based on my experience of optimizing Void Linux for Intel Skylake HD Graphics 520 on a laptop, hopefully it is of help to someone.
One of the things about running a more minimalist OS is that you sometimes need to take responsibility for tweaking certain things to get the most out of it; Intel Graphics is one such thing. After a fairly standard install of Void Linux, plus Xorg, I discovered that I wasn't happy with video playback and browser scrolling. The video playback looked kind of sloppy, with a good amount of tearing (visible redrawing) and Firefox was laggy when scrolling.
So here's what I did about it.
Prerequisites
In addition Xorg, and perhaps a window manager, there's a bunch of packages you probably need installed.
sudo xbps-install -S mesa-intel-dri libva-intel-driver sysfsutilsInstalling Xorg and configuring a window manager is a whole other topic I'm not going to touch.
Configuring Xorg
Assuming you already have Xorg and a window manager installed, you'll need to ensure that Xorg is configured to use the "modesetting" display driver. Kernel Mode Setting (KMS), is part of the Linux kernel that enables it to manage the video card. Under Void, this is the default so NO further configuration is needed.
However, if you have already created an Xorg.conf file then simply either remove it, remove the display device section or update it to include something like the following:
Section "Device"
Identifier "Intel Graphics"
Driver "modesetting"
EndSectionThis also means you won't be using the xf86-video-intel package anymore, which is the Xorg supplied driver. On a simple system with on onboard Intel graphics, this should generally be enough to get your Xorg display working properly. Now for the fun stuff.
Tweaking Your Intel Graphics driver
A word of warning here, the things I'm about to suggest could possibly break on your machine, proceed with all necessary caution.
The Intel Graphics driver on Linux exists primarily in the form of a kernel module called 'i915'. This kernel module comes with a bunch of configurable parameters to help you get the most out of your display.
First, you should probably confirm exactly what model of Intel Graphics the system has:
sudo lspci -v
00:02.0 VGA compatible controller: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07) (prog-if 00 [VGA controller])
DeviceName: Onboard IGD
Flags: bus master, fast devsel, latency 0, IRQ 127
Memory at e0000000 (64-bit, non-prefetchable) [size=16M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000 [size=64]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] Process Address Space ID (PASID)
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] Page Request Interface (PRI)
Kernel driver in use: i915
Kernel modules: i915If you see something like this, most crucially the line that say "Kernel modules: i915", then you're probably right to carry on. The next step is to see what features the kernel module offers for this device:
sudo modinfo i915
filename: /lib/modules/5.3.15_1/kernel/drivers/gpu/drm/i915/i915.ko.gz
license: GPL and additional rights
description: Intel Graphics
author: Intel Corporation
author: Tungsten Graphics, Inc.
firmware: i915/bxt_dmc_ver1_07.bin
...
parm: modeset:Use kernel modesetting [KMS] (0=disable, 1=on, -1=force vga console preference [default]) (int)
parm: enable_dc:Enable power-saving display C-states. (-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6) (int)
parm: enable_fbc:Enable frame buffer compression for power savings (default: -1 (use per-chip default)) (int)
...The lines beginning with "parm:" are the configurable parameters for the i915 kernel module. It's important to understand what these parameters really mean before changing them, as getting them wrong might result in all manner of undesirable results. So, the first step is to carefully read and inquire as to what the parameters actually represent.
There are generally two or three important details on each line:
the default option
the parameter type (eg int, bool etc)
the range of acceptable values (eg 0..4)
Where ...
int - integers (0,1,2,3,4... etc)
bool - boolean values are either "Y" or "N"
charp - strings (eg "/some/path")
It's important to pay attention this information, if get this wrong you may see errors during boot time and things may not work as expected.
Next, take a look and compare the available parameter options with what is currently set on the running i915 kernel module:
sudo systool -m i915 -av
Module = "i915"
Attributes:
coresize = "2232320"
initsize = "0"
initstate = "live"
refcnt = "22"
taint = ""
uevent = <store method only>
Parameters:
alpha_support = "N"
disable_display = "N"
disable_power_well = "1"
dmc_firmware_path = "(null)"
edp_vswing = "0"
enable_dc = "0"
enable_dp_mst = "Y"
enable_dpcd_backlight= "N"
enable_fbc = "0"
enable_guc = "0"
enable_gvt = "N"
enable_hangcheck = "Y"
enable_ips = "1"
enable_psr = "-1"
error_capture = "Y"
fastboot = "0"
force_probe = ""
force_reset_modeset_test= "N"
guc_firmware_path = "(null)"
guc_log_level = "1"
huc_firmware_path = "(null)"
invert_brightness = "0"
load_detect_test = "N"
lvds_channel_mode = "0"
mmio_debug = "0"
modeset = "-1"
nuclear_pageflip = "N"
panel_use_ssc = "-1"
prefault_disable = "N"
reset = "2"
vbt_firmware = "(null)"
vbt_sdvo_panel_type = "-1"
verbose_state_checks= "Y"
...These will probably be set to the defaults previously seen with the modinfo command.
To find out more information about what the various parameter actually mean, try looking through the documentation on the i915 kernel module (https://www.kernel.org/doc/html/v5.3/gpu/i915.html). Make sure you the documentation you're reading is for the version of kernel you're running ('uname -a' to check). Also, the hardware specifications from Intel (https://01.org/linuxgraphics/documentation/hardware-specification-prms) can be useful for defining terms.
To change these parameters, create a conf like the following: /etc/modprobe.d/intel-graphics.conf
Add a line to the file that starts with "options i915" and then append parameters to it as necessary. For example:
options i915 enable_dc=2 enable_fbc=1 fastboot=1In this example, advanced power saving states, frame buffer compression and fast boot optimisations are enabled. Notably, I find frame buffer compression results in smooth video playback on my system.
The next step is to make sure these settings apply when your computer boots. To do this, the initial memory-based filesystem (initramfs), which is used while the kernel is loading, needs to be updated with these changes.
sudo xbps-reconfigure -f linux5.3Make sure the 'linux5.3' part is changed to match the kernel version you'll be booting with.
Once this steps completes successfully, reboot your system, keeping an eye for any errors and use systool as before to ensure that the parameters you set have actually been applied as expected.
If you're interested in optimising your Intel Graphics card for power saving, you might find 'powertop' or 'intel_gpu_top' useful utilities.
Testing
Finally, it's good to do a test and make sure that everything is running smoothly. I prefer to use mpv and youtube-dl for that job (sudo xbps-install -S mpv youtube-dl), so here's how that would work:
mpv --hwdec=auto "https://www.youtube.com/watch?v=dQw4w9WgXcQ"Provided the test video is in h264 format, and not some crusty old music video from the 80s, you should see the following terminal output in addition to silky smooth video playback:
(+) Video --vid=1 (*) (h264 1920x1080 25.000fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
Using hardware decoding (vaapi).
VO: [gpu] 1920x1080 vaapi[nv12]
AV: 00:00:07 / 00:03:32 (3%) A-V: 0.000 Cache: 27s/13MBVideo player software, like mpv, that supports the Intel VA (Video Acceleration) API should use the video decoder built into your Intel Graphics device, providing smooth video playback with no tearing. Sometimes the video player needs to be instructed to use this video acceleration, hence the "--hwdec=auto" in mpv. According to the man page for mpv, "hwdec=auto" will attempt to give you the best hardware decoder, on my system with only Intel Graphics, that option results in the equivalent of calling "mpv --vo=gpu --hwdec=vaapi". To ensure it's always the default option, create ~/.config/mpv/mpv.conf and simply add "hwdec=auto", or whatever default you've chosen.
Finally, give Firefox a little GPU love also. Browse to "about:config" and set "layers.acceleration.force-enabled" to "true", then restart your browser. On my system this results in smoother scrolling and browser-based video playback.
Hopefully this was helpful.
4
u/ink_on_my_face Dec 12 '19
Thank you for this. I was looking for something like this. I am vacationing now and I know I'll forget it when I go back. Please put on the wiki.
2
u/st3r4g Dec 12 '19
The wiki is deprecated. There are the docs now. I agree this is useful and should be documented somewhere.
1
u/whichpaul Dec 12 '19
Yeah, that's why I posted here. Couldn't figure out where it'd fit in the current void docs structure.
Happy to edit / rewrite if there's a home for it.
3
u/st3r4g Dec 14 '19
I'd like to create a new section "Graphics" under "Configuration" where to put the NVIDIA Optimus stuff, you could put this under "Graphics/Intel"
1
u/whichpaul Dec 15 '19
OK, sounds good. When I get time next, I'll look at editing this for a docs PR.
2
u/st3r4g Dec 12 '19 edited Dec 12 '19
why the
-iflag to thexbps-installcommand?drop
libEGL, it changed name and it's not necessary, it is automatically installed as a dependency by the applications that use itIf you installed the full
xorgmetapackage you will havexf86-video-intelby default, which will be used by Xorg by default if installed, unless a custom configuration specifies otherwise (like the one you provided)don't know if
autoalways chooses hw decoding, the recommended options seem--vo=gpu --hwdec=vaapi(according to mpv output)
1
u/whichpaul Dec 12 '19
-i is a typo ... will fix later. My Xorg errored until I installed libegl, was a xorg-minimal install. I'll have to check the point about xf86-video-intel. --hwdec=auto seems right according to manpage and my own use ... happy to reflect otherwise if there's a good reason.
Thanks for the feedback.
2
u/st3r4g Dec 12 '19 edited Dec 12 '19
My Xorg errored until I installed libegl, was a xorg-minimal install.
Hmm never happened to me (I also do xorg-minimal installs), but now that all the GL libs are in
libglvndcan't happen anymore, asxorg-serverpulls inlibglvndthrough the (now virtual)libGLdependency. Maybe it didn't happen because I usually install Wayland first which requires EGL. The thing which must be absolutely installed ismesa-intel-dri.1
u/whichpaul Dec 12 '19
OK, I've had a chance to look at these.
I did originally need libEGL ... I'm sure of it ... for something, maybe mpv; who knows! Whatever the case, it's no longer installed and libglvnd is; just as you said, so that's now removed.
Looked into mpv. In my scenario, mpv will chose vaapi because it's the best available hardware option and is configured properly. I've updated that section accordingly.
2
u/st3r4g Dec 12 '19 edited Dec 12 '19
I opened a PR right now for a new VA-API backend, you might be interested: https://github.com/void-linux/void-packages/pull/17350. It's a new alternative for
libva-intel-driver, and supports newer GPUs, whilelibva-intel-driverstops at Coffee Lake.1
2
u/Rand0m6uy Dec 12 '19
Thanks for all the details, the wiki would be a good place for such of information, indeed..!!!
1
2
u/chmodplusx Dec 12 '19
Thank you for all this information. I switched to modesetting just weeks ago, and video playing is just fine, but I still had some light tearing when scrolling in Firefox with smooth scrolling enabled if Picom was off (if on is OK, I'm in Openbox so no other DE compositor is available). I just tried your suggestion and enabled the Firefox "about:config" option, and now I have zero tearing even without Picom! As I mostly use Firefox (or Netsurf for basically browsing in text mode, so not affected) this is just great, but a similar solution for Chromium (which I use when forced to the Google ecosystem) would be nice. Anyway, as I said, thank you very much! :D
2
u/whichpaul Dec 12 '19
You're welcome! I can highly recommend using mpv + youtube-dl for watching YouTube videos. Two reasons, no ads and uses HEAPS less CPU, mine went from 40% on one core down to 2-4% VAAPI.
3
u/chmodplusx Dec 12 '19
I actually use cvlc, or vlc in cli mode ("cvlc --no-video -I -rc" and you get a command line interface) for playing YT audio (I fetch the links from Netsurf), and I get mostly the same... No ads and it goes a whole lot lighter than playing in Firefox (about 4-5 % CPU from total system load -and this is a very humble Celeron 3350- and a despicable amount of RAM). I'll perhaps will try mpv and compare the load with cvlc, thank you again!
2
1
u/whichpaul Dec 12 '19
BONUS TIP:
For those playing along at home with newer model Intel Graphics (Gen9 Skylake and above) ... have a play with the following:
enable_guc=2It ensures that further video acceleration features are enabled, particularly to assist with H265 HEVC playback.
You'll need the linux-firmware-intel package installed for this, however, I think it's probably a default.
Read more about GuC (Graphics microcontroller) and HuC (HEVC/H.265 microcontroller) if you're interested:
1
u/emacsomancer Dec 12 '19
I wonder if the Intel drivers are still significantly faster for certain operations or not (2017: https://www.phoronix.com/scan.php?page=article&item=intel-modesetting-2017&num=1 )
1
u/whichpaul Dec 12 '19
Interesting thought, but I've no idea. All I know is that with modesetting I get buttery smooth video and low CPU utilisation, so I'm happy. :)
2
u/st3r4g Dec 12 '19
In general the modesetting driver is better suited for newer GPUs
1
u/emacsomancer Dec 12 '19
I'll probably stick to the Intel one for my Ivybridge and older machines then.
1
u/st3r4g Dec 12 '19
just try them both and see which works better for you
1
u/emacsomancer Dec 13 '19 edited Dec 13 '19
I get errors from my WM (stumpwm) when I try the modesetting driver.
Edit: turns out the issue was an
xbacklightone;acpilightworks as a replacement that doesn't crash the xmodesetting driver.
2
u/DNiceM Dec 12 '19
Thanks, hopefully something like this makes it in the wiki. I was in fact messing with these things a few days ago myself.
2
Dec 13 '19
Very interesting! Had no idea of other drivers than the x86-intel...’ driver. Maybe a performance bump on my X230 waiting to happen.
2
2
u/Virus_ST Dec 19 '19
Top quality post!
I will fiddle with this later as I'm having trouble with re-drawing and artifacting when using OpenGL for rendering backend for compositor on Plasma 5. Anyone has any insight/experience with this?
1
u/mysterious7777777 Dec 12 '19 edited Dec 12 '19
Very good information. I have been using xf86-video-intel for many years without problems and am reluctant to change. There is a little configuration needed to get the xf86-video-intel working properly. I now have a new laptop so might try the modesetting driver to compare the graphics primitives. I decided to try the vaapi instead of default gpu setting and get these results with mpv and the xf86-video-intel:
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: STSC entry 1 is invalid (first=1 count=1 id=1)
(+) Video --vid=1 (*) (h264 1280x720 23.976fps)
(+) Audio --aid=1 (*) (aac 6ch 48000Hz)
[vo/vaapi] Warning: this compatibility VO is low quality and may have issues with OSD, scaling, screenshots and more.
[vo/vaapi] vo=gpu is the preferred choice in any case and includes VA-API support via hwdec=vaapi or vaapi-copy.
AO: [alsa] 48000Hz stereo 2ch float
VO: [vaapi] 1280x720 => 1283x720 yuv420p
AV: 00:00:13 / 00:41:45 (0%) A-V: -0.000The first line is the last of thousands of repetitions and very annoying with both vaapi and gpu using both mpv and mplayer. Then finally the video begins and works anyway. Notice the comment about the vaapi. Maybe this is just using the xf86-video-intel driver not modesetting?
1
u/st3r4g Dec 12 '19
what about
--vo=gpu --hwdec=vaapi?1
u/mysterious7777777 Dec 12 '19
Thanks. Here are my results so this is positive for the hardware decoding:
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: STSC entry 1 is invalid (first=1 count=1 id=1) (+) Video --vid=1 (*) (h264 1280x720 23.976fps) (+) Audio --aid=1 (*) (aac 6ch 48000Hz) Using hardware decoding (vaapi). AO: [alsa] 48000Hz stereo 2ch float VO: [gpu] 1280x720 => 1283x720 vaapi[nv12]The first line is repeated except for the counts a total of 117453 times for a 42 minute video!
1
u/st3r4g Dec 12 '19
don't know about that error, if the video works you can just try to silence it. maybe it's something with that specific video?
1
u/mysterious7777777 Dec 12 '19 edited Dec 12 '19
Yes, that is how I work around the mysterious ffmpeg messages. The messages seem to be found in all of the videos I use at least. Here is my new mc file manager mc.ext settings:
include/video Open=( mpv --vo=gpu --hwdec=vaapi %f > /dev/null 2>&1 )
1
u/BUFU1610 May 12 '20
'most crucially the line that say "Kernel modules: i915"' So, what if I don't have that line? Is something wrong with my configuration?
My output:
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07) (prog-if 00 [VGA controller])
DeviceName: Onboard IGD
Subsystem: Dell Device 0810
Flags: bus master, fast devsel, latency 0, IRQ 136
Memory at d0000000 (64-bit, non-prefetchable) [size=16M]
Memory at c0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000 [size=64]
Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] Process Address Space ID (PASID)
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] Page Request Interface (PRI)
Kernel driver in use: i915It stops there, no kernel module afterwards..
1
2
Dec 14 '19 edited Dec 15 '19
[removed] — view removed comment
2
u/vapidegbert Dec 15 '19 edited Dec 15 '19
I'm having the same problem --- I've added the conf file and run
xbps-reconfigurewith the correct kernel version, it seems to run correctly but after a rebootsystoolshows me that the settings are unchangedEDIT: Ok following the instructions from the following link fixed it for me or at least the output from
systoolnow matches my conf file https://www.reddit.com/r/voidlinux/comments/e05yrs/how_do_i_update_the_initramfs/Check the link but the basic process which worked for me was:
create a new
/etc/dracut.conf.d/manual.conf(it didn't exist on my system)make the contents of the above file
hostonly=yesrun
sudo xbps-reconfigure -f linux5.3(5.3 is the correct kernel version for me)reboot
6
u/[deleted] Dec 12 '19
great post