Skip to content

Instantly share code, notes, and snippets.

@m1st0
Last active February 24, 2025 21:52
Show Gist options
  • Save m1st0/2805f5467af0d5b90923f624235f12db to your computer and use it in GitHub Desktop.
Save m1st0/2805f5467af0d5b90923f624235f12db to your computer and use it in GitHub Desktop.
Fix CPU pipe B FIFO underrun (screen goes black for a few seconds).
#!/usr/bin/env bash
# Fix CPU pipe B FIFO underrun (screen goes black for a few seconds).
# Reference: https://gitlab.freedesktop.org/drm/intel/-/issues/5455
#
# Author: Maulik Mistry
# Please share support: https://www.paypal.com/paypalme/m1st0
# License: BSD License 2.0
# Copyright (c) 2023–2025, Maulik Mistry
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the <organization> nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Define color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Desired new values
new_values=(25 39 48 52 83 97 103 120)
# Loop through each DRI file
for file in /sys/kernel/debug/dri/*/i915_pri_wm_latency; do
# Initial read
initial_read=$(cat "$file")
# Extract numerical values from the initial read
initial_values=()
while read -r line; do
for part in $line; do
if [[ $part =~ ^[0-9]+$ ]]; then
initial_values+=("$part")
fi
done
done <<< "$initial_read"
# Set new values
echo "${new_values[@]}" | sudo tee "$file" > /dev/null
# Read back values
read_back=$(cat "$file")
# Extract only the numerical values from the read_back
returned_values=()
while read -r line; do
for part in $line; do
if [[ $part =~ ^[0-9]+$ ]]; then
returned_values+=("$part")
fi
done
done <<< "$read_back"
# Display matches in a table format
printf "%-10s %-10s %-10s %-10s\n" "Index" "Initial" "Set Value" "Returned Value"
printf "%-10s %-10s %-10s %-10s\n" "-----" "-------" "----------" "--------------"
for i in "${!new_values[@]}"; do
# Use default if initial value is not set
initial_value="${initial_values[i]:-0}"
printf "%-10s %-10s " "WM$i" "$initial_value"
# Compare returned values with the set values
if [[ "${returned_values[$i]}" == "${new_values[$i]}" ]]; then
printf "${GREEN}%-10s${NC} ${GREEN}%-10s (Match)${NC}\n" "${new_values[$i]}" "${returned_values[$i]}"
else
printf "${RED}%-10s${NC} ${RED}%-10s (Mismatch)${NC}\n" "${new_values[$i]}" "${returned_values[$i]}"
fi
done
printf "\n"
done
[Unit]
Description=Run fix for FIFO underrun as root after KDE login
After=systemd-modules-load.service
Wants=systemd-modules-load.service
[Service]
Type=oneshot
ExecStart=/home/mistry/my_builds/i915_underrun/i915_pri_wm_latency.sh
RemainAfterExit=yes
[Install]
WantedBy=graphical.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment