|
1 |
| -# ACPI DSDT patch for Acer Swift 3 SF314-43 |
| 1 | +# S3 sleep in Acer Swift 3 SF314-43 |
2 | 2 |
|
3 | 3 | This laptop is designed for Windows and [modern standby](https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/modern-standby),
|
4 | 4 | and the firmware does not advertise S3 sleep state by default:
|
5 | 5 |
|
6 | 6 | ```
|
7 | 7 | # dmesg | grep ACPI | grep supports
|
8 | 8 | kernel: ACPI: PM: (supports S0 S4 S5)
|
9 |
| -``` |
10 |
| -``` |
| 9 | +
|
11 | 10 | # cat /sys/power/mem_sleep
|
12 | 11 | [s2idle]
|
13 | 12 | ```
|
14 | 13 | This means that Linux never uses [suspend-to-RAM](https://www.kernel.org/doc/html/latest/admin-guide/pm/sleep-states.html#suspend-to-ram)
|
15 | 14 | but only [suspend-to-idle](https://www.kernel.org/doc/html/latest/admin-guide/pm/sleep-states.html#suspend-to-idle)
|
16 | 15 | which uses more battery power when sleeping.
|
17 | 16 |
|
| 17 | +There is a way to fix this: booting into an [UEFI program](#is-this-your-program) that exposes all internal AMD PBS/CBS settings from the firmware and allows them to be changed, including choosing between modern sleep and S3. |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +This should theoretically work in any AMD computer, however I have **only** tested it with the following combination: |
| 22 | + |
| 23 | +- Laptop model: Acer Swift 3 SF314-43 |
| 24 | +- Firmware version: [1.06](https://global-download.acer.com/GDFiles/BIOS/BIOS/BIOS_Acer_1.06_A_A.zip?acerid=637998440494605648) (2022-09-27, "Support Win11 SV2") |
| 25 | + |
| 26 | +## Be aware! |
| 27 | + |
| 28 | +- If your system does not match **exactly** the requirements described above, I don't know what will happen and you **may brick your computer**. |
| 29 | +- The UEFI program allows you to change all sorts of other settings which are potentially dangerous and result in malfunctions or **may brick your computer**. Just don't. |
| 30 | +- The UEFI program is not mine, and to my knowledge the source is not available. From a security standpoint, running such unaudited, low-level tool that could potentially do anything is probably not the wisest choice. |
| 31 | +- Acer firmware setup does not allow you to change from modern sleep to S3. By doing so, you are putting the computer into an untested/unsupported state which may expose firmware bugs. |
| 32 | +- If you intend to keep dual booting with Windows 10, Microsoft [claims](https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/modern-standby#:~:text=Switching%20the%20power%20model%20is%20not%20supported%20in%20Windows%20without%20a%20complete%20OS%20re%2Dinstall) that: |
| 33 | + > Switching between S3 and Modern Standby cannot be done by changing a setting in the BIOS. Switching the power model is not supported in Windows without a complete OS re-install. |
| 34 | +
|
| 35 | +It goes without saying, but I am not responsible for anything you do with your own computer. This did work for me but you are on your own. |
| 36 | + |
| 37 | +## Instructions |
| 38 | + |
| 39 | +1. Get the program by cloning this repo, or downloading it from [releases](https://github.com/lbschenkel/acer-sf314_43-acpi-fix/releases/) and uncompressing it. |
| 40 | + |
| 41 | +0. Format a USB stick with FAT32. |
| 42 | + |
| 43 | +0. Copy the files from `copy-to-usb-stick` to the USB stick. |
| 44 | + |
| 45 | +0. Make sure that you have Secure Boot disabled: reboot, press F2 to enter firmware setup, make sure that *Secure Boot* (under *Boot*) is set to *disabled*, then exit and save changes. |
| 46 | + |
| 47 | +0. While booting press F12 to enter the boot menu and choose the USB stick. |
| 48 | + |
| 49 | +0. In the menu that appears, go to *Device Manager* and then *AMD PBS*. |
| 50 | + |
| 51 | +0. Scroll down to *S3/Modern Standby Support* and change it to *S3 Enable*. |
| 52 | + |
| 53 | +0. Make absolutely sure that you did not touch anything else! (In doubt, press Esc, answer *Yes* to *Exist discarding changes?* and try again.) If you are sure, press F10 to save. |
| 54 | + |
| 55 | +0. Press Esc twice to return to the main menu, then choose *Reset*. |
| 56 | + |
| 57 | +0. Re-enable Secure Boot if desired. |
| 58 | + |
| 59 | +If everything worked as it should, after you boot into Linux you will see the following: |
18 | 60 |
|
19 |
| -However, it's possible to patch the firmware's ACPI DSDT table to restore S3 support and |
20 |
| -[instruct Linux to load it at boot](https://www.kernel.org/doc/html/latest/admin-guide/acpi/initrd_table_override.html): |
21 | 61 | ```
|
22 | 62 | # dmesg | grep ACPI | grep supports
|
23 |
| -kernel: ACPI: PM: (supports S0 S3 S4 S5) |
24 |
| -``` |
25 |
| -``` |
| 63 | +ACPI: PM: (supports S0 S3 S4 S5) |
| 64 | +
|
26 | 65 | # cat /sys/power/mem_sleep
|
27 | 66 | s2idle [deep]
|
28 | 67 | ```
|
29 | 68 |
|
30 |
| -This repository contains the [patch to the DSDT](dsdt.patch) and a Makefile to automate the process. |
| 69 | +Now your laptop can enjoy a good night of S3 sleep! |
31 | 70 |
|
32 |
| -## Requirements |
| 71 | +## Known issues |
33 | 72 |
|
34 |
| -- Laptop model: Acer Swift 3 SF314-43 |
35 |
| -- BIOS version: [1.06](https://global-download.acer.com/GDFiles/BIOS/BIOS/BIOS_Acer_1.06_A_A.zip?acerid=637998440494605648) (2022-09-27, "Support Win11 SV2") |
36 |
| - or [1.04](https://global-download.acer.com/GDFiles/BIOS/BIOS/BIOS_Acer_1.04_A_A.zip?acerid=637659969200273816) (2021-08-31, "Enable fTPM support for China") |
37 |
| -- `acpica` package (personally tested only with versions 2021 or higher) |
38 |
| - |
39 |
| -## Building initrd with patched ACPI DSDT |
40 |
| - |
41 |
| -### Automatically |
42 |
| - |
43 |
| -To automatically patch the ACPI DSDT and generate an initrd image, just run `make`. |
44 |
| -If everything goes well, it will end with a "SUCCESS!" message. |
45 |
| - |
46 |
| -### Manually |
47 |
| -1. Install the `acpica` package |
48 |
| -2. Run `acpidump -b` to dump all ACPI tables to `*.dat` files |
49 |
| -3. Run `iasl -we -w3 -e *.dat -d dsdt.dat` to decompile the DSDT to `dsdt.dsl` |
50 |
| - - read next section if you want to try out without `-we` |
51 |
| -4. Patch the DSDT via `patch -F0 -N < dsdt.patch` |
52 |
| - - read next section if you want to try out without `-F0` |
53 |
| -5. Recompile the DSDT via `iasl -ve dsdt.dsl` |
54 |
| -6. Generate initrd image: |
55 |
| - 1. `mkdir -p kernel/firmware/acpi` |
56 |
| - 2. `cp dsdt.aml kernel/firmware/acpi/` |
57 |
| - 3. `find kernel | cpio -H newc --create > /boot/acpi-override.img` |
58 |
| - |
59 |
| -### In case of failure |
60 |
| - |
61 |
| -The process will fail if: |
62 |
| -1. Issues were encountered while decompiling the ACPI tables |
63 |
| -2. the BIOS is not an exact match (check requirements above) |
64 |
| - |
65 |
| -To minimize the chance of issues caused by mismatches, the Makefile and |
66 |
| -instructions are very strict regarding DSDT decompilation and patching: |
67 |
| -1. warnings during decompilation are treated as errors |
68 |
| -2. patching will not allow any "fuzz" (only exact matches) |
69 |
| - |
70 |
| -Depending on the installed version of `acpica`, it may not be able to decompile |
71 |
| -the DSDT without warnings and/or the output might be slightly different which |
72 |
| -would cause failures during patching. |
73 |
| - |
74 |
| -In this case it is possible to try (by changing the Makefile): |
75 |
| -1. decompiling with `iasl` without the `-we` argument |
76 |
| -2. patching with `patch` without the `-F0` argument |
77 |
| - |
78 |
| -When attempting this, then analyze *very carefully* any warnings produced by |
79 |
| -`iasl`. If it looks like the decompilation was only partially successful, then |
80 |
| -do not attempt to proceed even if patching works — the new DSDT may be incorrect |
81 |
| -and cause system instability. |
82 |
| - |
83 |
| -## Configuring boot loader |
84 |
| - |
85 |
| -Two things need to be set up in the boot loader: |
86 |
| -1. Load `/boot/acpi-override.img` as an (additional) initrd.\ |
87 |
| - This will make Linux use the patched ACPI DSDT with S3 support instead of the one from the firmware. |
88 |
| -2. Add `mem_sleep_default=deep` to the |
89 |
| - [kernel's command line parameters](https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html).\ |
90 |
| - This will make Linux use S3 when going to sleep (otherwise it will still default to `s2idle`, suspend-to-idle). |
91 |
| - |
92 |
| -### GRUB |
93 |
| - |
94 |
| -1. Change [`/etc/default/grub`](https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html): |
95 |
| - ``` |
96 |
| - GRUB_CMDLINE_LINUX_DEFAULT = "... mem_sleep_default=deep" |
97 |
| - GRUB_EARLY_INITRD_LINUX_CUSTOM = "... acpi-override.img" |
98 |
| - ``` |
99 |
| -2. Run `update-grub` |
100 |
| - |
101 |
| -### systemd-boot |
102 |
| - |
103 |
| -Change entries in [`/boot/loader/entries/*.conf`](https://www.freedesktop.org/software/systemd/man/loader.conf.html): |
104 |
| -``` |
105 |
| -title ... |
106 |
| -linux ... |
107 |
| -initrd /acpi-override.img |
108 |
| -initrd ... |
109 |
| -options ... mem_sleep_default=deep |
110 |
| -``` |
| 73 | +None so far. |
111 | 74 |
|
112 |
| -### rEFInd |
| 75 | +## FAQs |
113 | 76 |
|
114 |
| -Change [`/boot/refind-linux.conf`](https://www.rodsbooks.com/refind/linux.html#refind_linux): |
115 |
| -``` |
116 |
| -"Boot with standard options" "initrd=acpi-override.img ... mem_sleep_default=deep" |
117 |
| -``` |
118 |
| -Change [manual boot stanzas](https://www.rodsbooks.com/refind/configfile.html#stanzas): |
119 |
| -``` |
120 |
| -menuentry "..." { |
121 |
| - ostype Linux |
122 |
| - loader ... |
123 |
| - initrd ... |
124 |
| - options "initrd=acpi-override.img ... mem_sleep_default=deep" |
125 |
| -} |
126 |
| -``` |
127 |
| -Note that multiple `initrd` entries *do not work*, and any additional initrd files |
128 |
| -must be declared in `options`. |
| 77 | +### Is this your program? |
129 | 78 |
|
130 |
| -## Known issues |
| 79 | +No. I found it at https://github.com/DavidS95/Smokeless_UMAF and I claim no credit. This repository contains a known-good copy of the files from there which I have personally verified that work with my laptop. |
| 80 | +(This also makes sure to have another copy in case that repository disappears.) |
131 | 81 |
|
132 |
| -- If the value of `/sys/power/mem_sleep` is changed after boot then the laptop |
133 |
| - does not successfully wake up from standby: fans, lights and the display backlight turn on but the display remains black. |
134 |
| - - This happens even when `amdgpu.gpu_recovery=1`. |
135 |
| - - Does not apply when `mem_sleep_default` is used, this method works fine. |
136 |
| - - Tested on Linux 5.15, not tested on earlier kernels. |
| 82 | +### Can I safely revert this change? |
137 | 83 |
|
| 84 | +Yes, it looks like it. I have extracted the ACPI tables before trying the change for the first time. I changed the settings, verified that the ACPI tables did change, then changed back and confirmed that the ACPI tables went back to the exact same original ones, byte-for-byte. |
138 | 85 |
|
139 |
| -## FAQs |
| 86 | +### Can't I make Linux load patched ACPI tables? |
| 87 | + |
| 88 | +Yes, that would indeed be better because (1) it wouldn't require doing an unsupported change of firmware settings and (2) does not risk upsetting an existing insallation of Windows. That was my first choice and in fact used to be my previous approach.[^previous] |
| 89 | + |
| 90 | +[^previous]: The previous approach patched the ACPI DSDT table to simply expose the S3 state, without any other changes. However, now that I had the chance to compare the [changes](stock106-and-s3.diff) when S3 is properly exposed in the firmware, there are considerable differences (ironically, the place that the patch changed is not among them). For this reason alone I no longer recommend that route and I moved it into the branch [`old-hack`](https://github.com/lbschenkel/acer-sf314_43-acpi-fix/tree/old-hack). |
| 91 | + |
| 92 | +I did try it and realized that it was not as trivial. An explanation follows, for the technically inclined: |
140 | 93 |
|
141 |
| -**Q: Why not simply providing a `.img` file with the DSDT override?** |
| 94 | +I've decompiled the ACPI tables exposed when S3 is on, bumped their version (required step), recompiled and created an initramfs for Linux to load them. I then reverted the settings to stock and I have confirmed that the kernel was loading the overridden tables, but S3 support was still not exposed. |
142 | 95 |
|
143 |
| -**A:** Because: |
144 |
| -1. Then there's no risk of somebody mistakenly using the DSDT override in a |
145 |
| - machine with a different BIOS version (or worse: a different machine |
146 |
| - altogether) and getting unpredictable results. |
147 |
| -2. This repository avoids redistributing portions of Acer's BIOS, staying |
148 |
| - clear of any potential legal issues. |
| 96 | +By inspecting the [diff](stock106-and-s3.diff) of the tables before and after the change, I realized that the tables were dynamically relying on a number of settings that are not part of the tables themselves, but mapped from a specific region in memory. The settings in that memory region are not captured in the tables themselves, so the overridden tables with a stock environment were not really invoking the same code paths as the ones taken when the UEFI tool is used, because that memory region ends up having different values as well. |
149 | 97 |
|
150 |
| -**Q: Why not including the `.dsl` file with the decompiled DSDT?** |
| 98 | +It may actually be possible to extract the relevant values from that memory region and set the values as constants in the ACPI tables instead. That remains an exercise for the future.[^devmem] |
151 | 99 |
|
152 |
| -**A:** See previous answer. |
| 100 | +[^devmem]: Extracting the necessary values from the memory region requires a custom kernel compiled without `CONFIG_STRICT_DEVMEM` to allow reading `/dev/mem`. Recompiling a custom kernel and going through this experiment required more time than I had in my hands. |
0 commit comments