├── .gitmodules ├── ACKNOWLEDGMENTS ├── LICENSE ├── README.md ├── disable-c6.service.template └── install.sh /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ZenStates-Linux"] 2 | path = lib/ZenStates-Linux 3 | url = https://github.com/r4m0n/ZenStates-Linux.git 4 | -------------------------------------------------------------------------------- /ACKNOWLEDGMENTS: -------------------------------------------------------------------------------- 1 | The following components are used by this project. 2 | 3 | Project: ZenStates-Linux 4 | Author: Thiago Ramon Gonçalves Montoya 5 | License: MIT 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jeff Fredrickson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # disable-c6 2 | 3 | A systemd service to disable the C6 state upon system boot, preventing Ryzen freezes. [Here is some info on the bug](https://bugzilla.kernel.org/show_bug.cgi?id=196683). 4 | 5 | This simply installs `zenstates.py` from [ZenStates-Linux](https://github.com/r4m0n/ZenStates-Linux) and creates a one-shot service based on it. 6 | 7 | ## Prerequisites 8 | 9 | The `zenstates.py` script requires the `msr` kernel module. Ensure that you're either loading the `msr` module at startup or have it compiled into the kernel. If `/dev/cpu/*/msr` exists, then your `msr` module is active. 10 | 11 | Refer to your specific distribution and init system to find out how to load kernel modules. For instance, if you're using systemd, refer to `man modules-load.d`. 12 | 13 | ## Installation 14 | 15 | ### Arch Linux 16 | 17 | This package is available on the AUR as [`disable-c6-systemd`](https://aur.archlinux.org/packages/disable-c6-systemd/). Use your preferred AUR install method. For instance, using [`yay`](https://aur.archlinux.org/packages/yay/) to install: 18 | 19 | ``` 20 | yay -S disable-c6-systemd 21 | sudo systemctl enable disable-c6.service 22 | sudo systemctl start disable-c6.service 23 | ``` 24 | 25 | ### Others 26 | 27 | ``` 28 | git clone https://github.com/jfredrickson/disable-c6.git 29 | cd disable-c6 30 | git submodule init 31 | git submodule update 32 | sudo ./install.sh 33 | ``` 34 | 35 | This will install a systemd unit called `disable-c6` to the default location, `/usr/local/lib/systemd/system/disable-c6.service`, and offer to enable/start the service for you. 36 | 37 | You can also customize the install location. See `./install.sh --help` for options. 38 | -------------------------------------------------------------------------------- /disable-c6.service.template: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Ryzen Disable C6 3 | DefaultDependencies=no 4 | After=sysinit.target local-fs.target suspend.target hibernate.target 5 | Before=basic.target 6 | 7 | [Service] 8 | Type=oneshot 9 | ExecStart=python3 {{PREFIX}}/bin/zenstates.py --c6-disable 10 | 11 | [Install] 12 | WantedBy=basic.target suspend.target hibernate.target 13 | 14 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | PREFIX="/usr/local" 6 | 7 | while [ $# -gt 0 ] ; do 8 | case "$1" in 9 | --prefix=*) 10 | PREFIX="${1#*=}" 11 | ;; 12 | --help) 13 | echo "Installs the disable-c6.service systemd unit." 14 | echo "Usage: `basename $0` [options]" 15 | echo "Options:" 16 | echo " --prefix=PREFIX Installation prefix (default: /usr/local)" 17 | exit 0 18 | ;; 19 | *) 20 | echo "Invalid argument: $1" 21 | exit 1 22 | ;; 23 | esac 24 | shift 25 | done 26 | 27 | BIN_DIR=$PREFIX/bin 28 | LIB_DIR=$PREFIX/lib/systemd/system 29 | 30 | mkdir -p $BIN_DIR 31 | mkdir -p $LIB_DIR 32 | 33 | echo "Installing $LIB_DIR/disable-c6.service" 34 | sed "s@{{PREFIX}}@$PREFIX@" disable-c6.service.template > $LIB_DIR/disable-c6.service 35 | echo "Installing $BIN_DIR/zenstates.py" 36 | install lib/ZenStates-Linux/zenstates.py $BIN_DIR/zenstates.py 37 | 38 | while true ; do 39 | read -p "Would you like to enable and start the service now [y/N]? " YN 40 | case $YN in 41 | [Yy]*) 42 | systemctl enable disable-c6.service 43 | systemctl start disable-c6.service 44 | echo "Enabled disable-c6 service." 45 | exit 0 46 | ;; 47 | *) 48 | echo "To enable and start the service:" 49 | echo " systemctl enable disable-c6.service" 50 | echo " systemctl start disable-c6.service" 51 | exit 0 52 | ;; 53 | esac 54 | done 55 | --------------------------------------------------------------------------------