Skip to content

Commit ce6dada

Browse files
Release version 1.0.6-legiongo2
Fix two Legion Go 2 (Z2 Extreme) issues found on-device: - gpu_utils: never permanently cache an invalid GPU frequency range. A transient first read with min<=0 wedged BALANCE mode into the manual write path (pinning the GPU at 600 MHz) and made the fixed/range GPU sliders report "Unsupported". Only cache a sane range; re-read (and self-heal) otherwise. - devices/lenovo: skip redundant platform-profile writes. The plugin re-wrote "custom" every poll even when already set, which the Lenovo WMI firmware could intermittently reject with EIO (Errno 5). Read the current value first and only write on change (mirrors the ROG Ally path). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f59b913 commit ce6dada

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎decky.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Some basic migration helpers are available: `migrate_any`, `migrate_settings`, `
1212
A logging facility `logger` is available which writes to the recommended location.
1313
"""
1414

15-
__version__ = '1.0.5'
15+
__version__ = '1.0.6'
1616

1717
import logging
1818

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-decky-tdp",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Hardware Control plugin for PC handhelds, including TDP, GPU, EPP, etc",
55
"type": "module",
66
"scripts": {

‎py_modules/devices/lenovo.py‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,26 @@ def set_platform_profile(profile: str) -> bool:
9393
decky_plugin.logger.error(f"{__name__} Platform profile path not found")
9494
return False
9595
set_profile_path = os.path.join(profile_base, "profile")
96-
if os.path.exists(set_profile_path):
97-
decky_plugin.logger.info(f'setting profile {profile} to path {set_profile_path}')
98-
with open(set_profile_path, "w") as f:
99-
f.write(profile)
100-
return True
101-
else:
96+
if not os.path.exists(set_profile_path):
10297
decky_plugin.logger.error(f"{__name__} Profile path does not exist: {set_profile_path}")
10398
return False
99+
100+
# Skip redundant writes. The plugin re-applies TDP (and thus "custom") every
101+
# poll, but the Lenovo WMI firmware can intermittently return EIO (Errno 5)
102+
# when re-writing the profile value it is already set to. Only write on an
103+
# actual change (mirrors the ROG Ally read-before-write pattern).
104+
try:
105+
with open(set_profile_path, "r") as f:
106+
current_profile = f.read().strip()
107+
if current_profile == profile:
108+
return True
109+
except Exception as e:
110+
decky_plugin.logger.warning(f"{__name__} could not read current platform profile, writing anyway: {e}")
111+
112+
decky_plugin.logger.info(f'setting profile {profile} to path {set_profile_path}')
113+
with open(set_profile_path, "w") as f:
114+
f.write(profile)
115+
return True
104116
except Exception as e:
105117
decky_plugin.logger.error(f"{__name__} Failed to set platform profile {profile}: {e}")
106118
return False

‎py_modules/gpu_utils.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ def get_gpu_frequency_range():
4040

4141
if od_sclk_matches:
4242
frequency_range = [int(od_sclk_matches[0][0]), int(od_sclk_matches[0][1])]
43-
GPU_FREQUENCY_RANGE = frequency_range
43+
# Only cache a sane range. Some devices (e.g. Legion Go 2 / Z2 Extreme)
44+
# can transiently report a bogus range (e.g. min <= 0) before the GPU
45+
# OverDrive table is ready. Caching that permanently wedges BALANCE mode
46+
# into the manual-write path (pinning the GPU) and makes the fixed/range
47+
# sliders show "Unsupported". Return it, but re-read on the next call.
48+
if frequency_range[0] > 0 and frequency_range[1] > frequency_range[0]:
49+
GPU_FREQUENCY_RANGE = frequency_range
4450
return frequency_range
4551
else:
46-
frequency_range = [-2, -2]
47-
GPU_FREQUENCY_RANGE = frequency_range
48-
return frequency_range
52+
# transient/unsupported read: return sentinel but do NOT cache it so we
53+
# retry (and self-heal) on the next poll instead of staying broken.
54+
return [-2, -2]
4955
except Exception as e:
5056
decky_plugin.logger.error(e)
5157

0 commit comments

Comments
 (0)