[+] tune power management for air 2018

This commit is contained in:
Siarhei Siniak 2025-04-01 12:40:53 +03:00
parent 61584fedac
commit fa732867c3
12 changed files with 184 additions and 15 deletions

@ -83,11 +83,16 @@ dotfiles_put:
#commands install -f -p dotfiles -s dotfiles/ -t ~/.config/
PLATFORM ?= macbook_air_2012
PLATFORM_TMP ?= tmp/platform_dotfiles/$(PLATFORM)
dotfiles_put_platform:
@echo to be installed
find platform_dotfiles/$(PLATFORM);
sudo cp -rp -T platform_dotfiles/$(PLATFORM)/ /
echo remove $(PLATFORM_TMP)'?'; read; sudo rm -fr $(PLATFORM_TMP)
sudo mkdir -p $(PLATFORM_TMP)
sudo cp -rp -T platform_dotfiles/$(PLATFORM)/ $(PLATFORM_TMP)
sudo chown -R root:root $(PLATFORM_TMP)
sudo cp -rp -T $(PLATFORM_TMP) /
sudo udevadm control --reload
sudo systemctl daemon-reload

@ -1 +1 @@
Subproject commit 3e334c5a51c949c79425c14ed3947d5934ea0617
Subproject commit 56af6d17019cef5bd52bd47a64697de7245b7a2d

@ -0,0 +1,26 @@
[Unit]
Description=Disable and Re-Enable Apple BCE Module (and Wi-Fi)
Before=sleep.target
Before=hibernate.target
StopWhenUnneeded=yes
[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/online-fxreader-pr34-suspend-fix-t2 disable_apple_bce
#ExecStart=/usr/bin/modprobe -r apple_bce
#ExecStart=/usr/bin/modprobe -r brcmfmac_wcc
#ExecStart=/usr/bin/modprobe -r brcmfmac
#ExecStart=/usr/bin/rmmod -f apple-bce
ExecStop=/usr/local/bin/online-fxreader-pr34-suspend-fix-t2 enable_apple_bce
#ExecStop=/usr/bin/modprobe -r apple_bce
#ExecStop=/usr/bin/modprobe apple-bce
#ExecStop=/usr/bin/modprobe brcmfmac
#ExecStop=/usr/bin/modprobe brcmfmac_wcc
[Install]
WantedBy=sleep.target
WantedBy=hibernate.target

@ -0,0 +1,113 @@
#!/usr/bin/env python3
# vi: set filetype=python
import sys
import time
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument('mode', choices=[
'disable_apple_bce',
'enable_apple_bce',
])
options = parser.parse_args()
if options.mode == 'disable_apple_bce':
while True:
ret = subprocess.call([
'systemctl', 'stop', 'iwd',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', '-r', 'brcmfmac_wcc',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', '-r', 'brcmfmac',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', '-r', 'applesmc',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'rmmod', '-f', 'apple-bce',
])
#if ret != 0:
# time.sleep(1)
#else:
# break
break
elif options.mode == 'enable_apple_bce':
while True:
ret = subprocess.call([
'modprobe', 'applesmc',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', 'apple-bce',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', 'brcmfmac',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'modprobe', 'brcmfmac_wcc',
])
if ret != 0:
time.sleep(1)
else:
break
while True:
ret = subprocess.call([
'systemctl', 'start', 'iwd',
])
if ret != 0:
time.sleep(1)
else:
break
else:
raise NotImplementedError

@ -34,17 +34,20 @@ def run() -> None:
''',
),
intel_pstate=dict(
devpath='sys/devices/system/cpu/cpu0',
devpath=r'/?sys/devices/system/cpu/cpu0',
node='/sys/devices/system/cpu/intel_pstate/no_turbo',
cmd=r'''
chown root:fan /sys/devices/system/cpu/intel_pstate/no_turbo
chown root:fan /sys/devices/system/cpu/intel_pstate/status
chown root:fan /sys/devices/system/cpu/intel_pstate/max_perf_pct
#chown root:fan /sys/devices/system/cpu/intel_pstate/status
chmod g+w /sys/devices/system/cpu/intel_pstate/no_turbo
chmod g+w /sys/devices/system/cpu/intel_pstate/status
chmod g+w /sys/devices/system/cpu/intel_pstate/max_perf_pct
#chmod g+w /sys/devices/system/cpu/intel_pstate/status
echo passive > /sys/devices/system/cpu/intel_pstate/status
''',
),
governor=dict(
devpath=r'sys/devices/system/cpu/cpu(\d+)',
devpath=r'/?sys/devices/system/cpu/cpu(\d+)',
node=r'/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor',
cmd=r'''
chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor
@ -71,8 +74,9 @@ def run() -> None:
# logger.info(dict(devpath_m=devpath_m, node=node_2))
if not os.path.exists(node_2):
continue
while not os.path.exists(node_2):
#continue
time.sleep(1)
cmd_2 = v['cmd'].format(*devpath_m.groups())

@ -2622,7 +2622,9 @@ echo 2000 > /sys/bus/platform/devices/applesmc.768/fan1_output;
elif cls.profile() == 'intel_pstate':
subprocess.check_call(r'''
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
echo 900000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
''', shell=True)
else:
raise NotImplementedError
@ -2639,7 +2641,9 @@ echo 6500 > /sys/bus/platform/devices/applesmc.768/fan1_output;
elif cls.profile() == 'intel_pstate':
subprocess.check_call(r'''
echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo 60 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
echo 1200000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
''', shell=True)
else:
raise NotImplementedError
@ -2721,12 +2725,14 @@ echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
r'''
exec sh -c 'echo cpufreq, user; whoami;
while [[ -a /proc/{pid} ]]; do
echo passive > /sys/devices/system/cpu/intel_pstate/status;
#echo passive > /sys/devices/system/cpu/intel_pstate/status;
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo;
echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
#echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
for cpu_path in /sys/devices/system/cpu/cpu?; do
echo 900000 > $cpu_path/cpufreq/scaling_max_freq;
echo schedutil > $cpu_path/cpufreq/scaling_governor;
#online-fxreader-pr34-udev --device $cpu_path;
#echo 900000 > $cpu_path/cpufreq/scaling_max_freq;
#echo schedutil > $cpu_path/cpufreq/scaling_governor;
true;
done;
sleep 10;
done;'

@ -1,6 +1,6 @@
[project]
name = 'online.fxreader.pr34'
version = '0.1.5.3'
version = '0.1.5.8'
dependencies = [
#"-r requirements.txt",

BIN
releases/whl/online_fxreader_pr34-0.1.5.4-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
releases/whl/online_fxreader_pr34-0.1.5.5-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
releases/whl/online_fxreader_pr34-0.1.5.6-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
releases/whl/online_fxreader_pr34-0.1.5.7-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
releases/whl/online_fxreader_pr34-0.1.5.8-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.