Interesting.
So I can run:
cat /sys/class/drm/card1/device/power/runtime_status
and get suspended
then
cat /sys/class/drm/card2/device/power/runtime_status
and get active.
This gels as I look at:
cat /sys/class/drm/card2/device/uevent
and
cat /sys/class/drm/card1/device/uevent
Comparing the PCI slot name against the output of lspci VGA output.
This tells me the dGPU is suspended, as I would expect as it’s not being utilized or needing to wake.
Now to the question of an application that does this. I did not have one, so I tossed together a quick and dirty script that “appears” to be working correctly.
1- I ran my script. Idles at empty. Upon launching Steam (flatpak), Fedora 39.
2- Script immediately indicated the card is “awake.”
3- With steam idle, it stopped at two 5 second entries.
4- With it still paused, I launched a game in steam I have set with the command parameters set with DRI_PRIME=1 %command% and sure enough, the card woke up again and the script shows activity.
5- Stopping the game, the script stops its 5 second refresh indicating the card is no longer active.
Still testing this more, but, based on some rough testing, I suspect this should do what the op wants. They could in theory, apply this wherever (at startup, as a service, etc).
Thoughts @Mario_Limonciello ? Seems like it does what op is looking for. You can see where it stops its activity as you described after steam is idle and after I close the game.
#!/bin/bash
# Path for card1
STATUS_FILE="/sys/class/drm/card1/device/power/runtime_status"
# Initial status check
PREV_STATUS=$(cat "$STATUS_FILE")
# Alert if already active
if [ "$PREV_STATUS" = "active" ]; then
echo "ALERT: card1 is already active at script start - $(date)"
fi
while true; do
# Current status check
CURRENT_STATUS=$(cat "$STATUS_FILE")
# Alert if status is active, regardless of previous state
if [ "$CURRENT_STATUS" = "active" ]; then
echo "ALERT: card1 is active - $(date)"
fi
# Update previous status
PREV_STATUS="$CURRENT_STATUS"
# Check interval
sleep 5
done