ublue-os / bazzite

Bazzite is a cloud native image built upon Fedora Atomic Desktops that brings the best of Linux gaming to all of your devices - including your favorite handheld.
https://bazzite.gg
Apache License 2.0
3.97k stars 237 forks source link

[Feature Request] Environment variable to prevent Steam from interfering with TDP #1412

Closed Tobe95 closed 1 month ago

Tobe95 commented 3 months ago

On my Steam Deck LCD with a configured TDP of 20W, the power cap gets constantly reset back down to 15W by Steam itself, resulting in reduced performance and stutter.

This happens mid-game, after setting a TDP above 15W with Powertools and confirming the change with cat /sys/class/hwmon/hwmon4/power1_cap.

My temporary solution has been to use ostree admin unlock --hotfix and edit /usr/bin/steamos-polkit-helpers/steamos-priv-write, preventing Steam from writing to power*_cap under /sys/class/hwmon/hwmon4/ by commenting out this whole block:

if MatchFilenamePattern "$WRITE_PATH" "/sys/class/hwmon/hwmon*/power*_cap"; then
      if /usr/libexec/hwsupport/valve-hardware; then
          CommitWrite
      else
          Log "commit: Skipped $WRITE_VALUE -> $WRITE_PATH - Valve Hardware not detected"
      fi
fi

Since this concerns any Steam Deck user running a higher TDP than the default 15W, it would be great to have some feature implemented to make this process easier, maybe in the form of an environment variable?

My current attempt looks like this:

if ! grep -q "^DISABLE_STEAM_TDP_CONTROL=1$" "/etc/environment"; then
  if MatchFilenamePattern "$WRITE_PATH" "/sys/class/hwmon/hwmon*/power*_cap"; then
      if /usr/libexec/hwsupport/valve-hardware; then
          CommitWrite
      else
          Log "commit: Skipped $WRITE_VALUE -> $WRITE_PATH - Valve Hardware not detected"
      fi
  fi
fi

While this only acts similar to an ENV, I could not get if [ ${DISABLE_STEAM_TDP_CONTROL:=0} = "0" ]; then to actually work...

Also I'm unsure if this would even be the best way to handle this, or if there might me a much simpler solution around?

KyleGospo commented 3 months ago

Great idea, I will look into this soon and update this issue

Tobe95 commented 2 months ago

@KyleGospo Sorry to bother... But is there any update on this?

I could make a pull request, if there is no better way to implement this.

KyleGospo commented 2 months ago

@KyleGospo Sorry to bother... But is there any update on this?

I could make a pull request, if there is no better way to implement this.

If you're open to it, that would be great.

Tobe95 commented 1 month ago

Merged with commit be5757f, closing as solved.