Fix weird lag issues with Intel graphics on FreeBSD 14.3 with i915 driver
tl;dr: Disabling PSR fixed a slew of bizarre system responsiveness issues under i915.
I noticed that my laptop’s minimal Xorg environment was suffering from a series of strange lag issues:
- Typing delays: Typed characters would show up only after other characters were typed.
- Screen refresh delays:
- Instead of showing immediately on hover, Openbox’s main menu submenus would only show after the cursor was moved around inside the parent item’s menu a bit.
vimerror messages like “No write since last change” wouldn’t show up until additional keys were pressed after:q<enter>. The computer sat motionless for more than 10 seconds and then only showed the error message after I pressed an arrow key!
These issues happened in MATE and Openbox, and even plagued basic tty consoles. It didn’t make sense, because the system was not under load and is utterly minimal (just plain-old Xorg running lightdm and Openbox with no other programs running). It’s a a Dell E7470 with an i5-6200U Skylake CPU with Intel HD Graphics 520… plenty of power for this DE.
The lag went away when booted into single-user mode, or if I disabled i915 and had Xorg use scfb.
After some hunting around, turns out that PSR (Panel Self Refresh) was to blame. Disabling PSR fixed the lag issues immediately. But, finding out the exact sysctl settings was tricky because they have to go under the compat.linuxkpi section, and they have a unique naming convention that wasn’t immediately apparent from the documentation I could find online.
The fix
In /boot/loader.conf, set:
# Disable PSR (panel self-refresh)
compat.linuxkpi.i915_enable_psr="0"
Reboot and check things out. That fixed it for me!
What’s PSR?
PSR is a power-saving feature that helps put the GPU into a low-power state if it believes nothing on-screen has changed and, thus, the screen doesn’t need a redraw. Apparently, the PSR implementation from Skylake-era systems was immature in hardware and in software, leading to buggy issues like this.
This setting to disable PSR is likely provided by some distros or pre-built environments… but since I’m rolling my own barebones Xorg environment, I had to learn about the setting the hard way!