Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UX3402ZA #151

Closed
irvng-wav opened this issue Mar 8, 2024 · 28 comments
Closed

Add support for UX3402ZA #151

irvng-wav opened this issue Mar 8, 2024 · 28 comments
Assignees
Labels
add new device Add support for new device AE_NOT_FOUND Unable to perform a fan ACPI call alternative found A working alternative fan tool was found help wanted Extra attention is needed

Comments

@irvng-wav
Copy link

Environment
AFC Version: 3.15.0
OS version: Arch Linux with Kernel Linux 6.7.9-arch1-1
CPU Name: 12th Gen Intel® Core™ i7-1260P × 16

It does not work
I get the infamous acpi call failed with 'Error: AE_NOT_FOUND'. I know that right now there's no solution for it but I want to keep the conversation going.

Additional context
I found this article on the Arch Wiki about the ASUS Zenbook UM3402YAR, which is basically the same laptop but with an AMD cpu and gpu. There's a tutorial on how to change the fan profiles with a tool called nbfc which looks like it isn't maintained anymore, so I found an up to date Linux fork called nbfc-linux.

In Windows, you get the MyAsus App which lets you choose between three different fan profiles: Quiet, Balanced, and Performance. As I understand, each one of those modes has an hexadecimal value that you can manually set with the nbfc or nbfc-linux tool, that's explained in the Arch Wiki. I'm able to change between those fan modes, and it actually works. When I write the value for the quiet mode, the fans go quiet, and when I write it for the performance mode, the fans do start spinning faster but not as they do with Windows.

That's where I'm at. It kinda works. I installed the DOOM 2016 game both in Windows and Linux. In Windows, when the fan profile is either at Quiet or Balanced, the game runs at around 30 to 40 fps. But then if I engage the performance mode, the fans start working intensely and the game ramps up to a stable 60 fps. That doesn't happen on Linux. Either one of the three modes basically offers the same performance as Quiet or Balanced in Windows, meaning 30 to 40 fps.

Also I do music production as a part time freelance job. There's one piece of software called Vital, which runs perfectly on Windows with the performance mode, but sometimes struggles with the other two fan modes. In Linux I get the same performance with all three modes, and like with DOOM, it doesn't run quite as great as Windows with the performance mode.

Still, Linux is an awesome experience with this machine, and most of my needs are covered in it's current state. But dammit Asus, I want a true performance mode in Linux.

I hope we can get it to that state someday. Thank you @dominiksalvet for your work!

@irvng-wav irvng-wav added the add new device Add support for new device label Mar 8, 2024
@dominiksalvet dominiksalvet added the AE_NOT_FOUND Unable to perform a fan ACPI call label Mar 10, 2024
@dominiksalvet
Copy link
Owner

Hmmm... I think I saw similar behavior somewhere in the AFC issues. Unfortunately, I do not remember where, so I can't point you to the issue. Maybe try searching "max" among all issues.

Should you find something interesting, definitely link this issue with it, so people have more context. I can keep this issue open as long as it is relevant.

@dominiksalvet dominiksalvet added the help wanted Extra attention is needed label Mar 10, 2024
@akvadrako
Copy link

akvadrako commented Jun 4, 2024

I also get this acpi call failed with 'Error: AE_NOT_FOUND' error with my Asus Zenbook UX3404VC with i9-13900H. Same with afc-scout for the recommended ranges.

I gather this is a common issue, but what does it mean? Is there anything I can do to help?

@akvadrako
Copy link

Well I have figured out how to read the fan mode with acpi_call:

echo '\_SB_.PC00.LPCB.H_EC.ECRD "QFAN"'> /proc/acpi/call
cat /proc/acpi/call

To write the fan mode, one can use \.ATKD.FANL 1 (1=silent, 0=default, 2=performance)

@dominiksalvet
Copy link
Owner

@akvadrako Well, I believe that your examination could help someone (at least with the same laptop). 🚀 Maybe you could create a simple script and publish it on GitHub. If so, you can use, just like AFC, GitPack for its distribution since it's completely effortless. Think about it 😃

@akvadrako
Copy link

For now if anyone has this issue they can find it here. And it should be fixed in a near future kernel version so anybody can use the standard /sys/firmware/acpi/platform_profile.

https://lore.kernel.org/platform-driver-x86/[email protected]/T/

@barolo
Copy link

barolo commented Jul 20, 2024

For now if anyone has this issue they can find it here. And it should be fixed in a near future kernel version so anybody can use the standard /sys/firmware/acpi/platform_profile.

https://lore.kernel.org/platform-driver-x86/[email protected]/T/

I have the same laptop as OP but with kernel 6.10, I cannot make it work.

echo '\_SB_.PC00.LPCB.H_EC.ECRD "QFAN"'> /proc/acpi/call
cat /proc/acpi/call

returns 0x0

any hints?

@akvadrako
Copy link

That seems correct. It says your fan mode is Standard.

To set silent mode use echo '\.ATKD.FANL 1' > /proc/acpi/call

@barolo
Copy link

barolo commented Jul 20, 2024

That seems correct. It says your fan mode is Standard.

To set silent mode use echo '\.ATKD.FANL 1' > /proc/acpi/call

It doesn't seem to be doing anything, fan behaves the same
and /proc/acpi/call returns Error: AE_NOT_FOUND after

@akvadrako
Copy link

Then I guess that laptop is different. If you want to try to discover the right call, you have to investigate the ACPI tables. https://wiki.archlinux.org/title/DSDT is a good intro, but it's basically a bunch of guesswork.

@barolo
Copy link

barolo commented Jul 21, 2024

In Windows, you get the MyAsus App which lets you choose between three different fan profiles: Quiet, Balanced, and Performance. As I understand, each one of those modes has an hexadecimal value that you can manually set with the nbfc or nbfc-linux tool, that's explained in the Arch Wiki. I'm able to change between those fan modes, and it actually works. When I write the value for the quiet mode, the fans go quiet, and when I write it for the performance mode, the fans do start spinning faster but not as they do with Windows.

which values have you used? I'm trying ./ec_probe write 0x61 0x1 and it returns invalid argument

@barolo
Copy link

barolo commented Jul 21, 2024

@irvng-wav managed to get it to work, had to add ec_sys.write_support=1 to boot arguments to have a write access.
The relevant values are:

0x61 0x00 #standard mode
0x61 0x01 #whisper mode (yes, counterintuitively)
0x61 0x02 #performance mode

the other relevant register seems to be 0x74 unsure how it corresponds yet as it switches just between two values 0x3A and 0x08, between three profiles. I've set it to 3A. [perhaps max fan speed?]

It definitely works, as the fan in performance mode gets really loud.

@irvng-wav
Copy link
Author

irvng-wav commented Jul 21, 2024

@barolo you got me excited, but unfortunately it's not working the way it's working for you. I have set 0x61 to 0x02 (performance mode) and 0x74 was already set to 3A, but the fans are still wimpy:

[irvng@arch-zenbook ~]$ sudo ec_probe read 0x61
2 (02)
[irvng@arch-zenbook ~]$ sudo ec_probe read 0x74
58 (3A)

But I'm still on Kernel 6.9.10, so that makes me think that maybe they fixed this issue in kernel 6.10. I will have to wait until the Arch Linux team pushes it to the main repo to test it.

I'm so glad you got it working!

@barolo
Copy link

barolo commented Jul 21, 2024

@barolo you got me excited, but unfortunately it's not working the way it's working for you. I have set 0x61 to 0x02 (performance mode) and 0x74 was already set to 3A, but the fans are still wimpy:

[irvng@arch-zenbook ~]$ sudo ec_probe read 0x61
2 (02)
[irvng@arch-zenbook ~]$ sudo ec_probe read 0x74
58 (3A)

But I'm still on Kernel 6.9.10, so that makes me think that maybe they fixed this issue in kernel 6.10. I will have to wait until the Arch Linux team pushes it to the main repo to test it.

I'm so glad you got it working!

It should work, it's the same laptop, I'm on 6.10 though.
BTW, perf fan mode gets me -10 °C on max load.
And it sounds like a hair-dryer.

@barolo
Copy link

barolo commented Jul 21, 2024

@irvng-wav check if you have performance platform profile enabled, it's best to just use tlp for this, you can set it to autotrigger on AC, (plasma desktop alsa has such option in UI for it), plus set charge limit and other stuff.
Also try setting ASPM to performance manually as per https://wiki.archlinux.org/title/Power_management#Active_State_Power_Management

@irvng-wav
Copy link
Author

irvng-wav commented Jul 24, 2024

Hey @barolo I just upgraded my system to kernel 6.10 and followed your advice but for some reason the fan behavior doesn't change. Here are all the steps I did:

  1. Updated my system to kernel 6.10, then restarted the machine to boot into the new kernel.
  2. Changed the fan profile to performance with sudo ec_probe write 0x61 0x02.
  3. Put my pc under a stress test using the s-tui tool to see if anything had changed but the behavior was the same: The CPU usage went up to 100% with (CPU) temps of around 70° C and avg frequency of 2250 MHz. Fan speed didn't change.

So then I followed the advice of your last comment. I use the tool auto-cpufreq to set the CPU governor and EPP to performance when the laptop is connected to the charger. Here's a screenshot of that tool:
imagen
Is EPP the "performance platform profile" you're talking about?

Then I visited the arch wiki article you linked, checked the status of ASPM and it already was enabled:

[irvng@arch-zenbook ~]$ sudo lspci -vv | grep 'ASPM.*abled;'
[sudo] contraseña para irvng: 
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk-
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk-
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk-
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk-
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes, LnkDisable- CommClk+

So I changed the policy to performance with

# echo performance > /sys/module/pcie_aspm/parameters/policy

With all of that done I again engaged the stress test but nothing changes. I even disabled and uninstalled thermald to see if that changed anything but nope.

Note that I'm not using asus-fan-control. I don't have it installed.

Am I missing something? Thanks in advance!

@barolo
Copy link

barolo commented Jul 25, 2024

@irvng-wav the only thing that I'm using is TLP you can change everything that's necessary within it (you might want to scale down stuff you use to reduce variables). Do you notice any changes between 0x02, 0x01and 0x00 while stressing? Also try on AC power.
For me to trigger max perf with max fans the only thing that I need are ec_probe write 0x61 0x02 and echo performance | sudo tee /sys/module/pcie_aspm/parameters/policy.
Probably the most important thing is that you can get sustained 3.8-4.4 GHz on performance cores (when only couple of them are engaged), this way. Average will be 2.1-2.4 when they all are stressed.
Also, I'm pretty sure that I've never changed the governor explicitly.

@barolo
Copy link

barolo commented Jul 25, 2024

3. Put my pc under a stress test using the s-tui tool to see if anything had changed but the behavior was the same: The CPU usage went up to 100% with (CPU) temps of around 70° C and avg frequency of 2250 MHz. Fan speed didn't change.

If they're ALL running 2250GHz at 70°C, that means that you've already running it at max [fans], otherwise that wouldn't be possible.

@barolo
Copy link

barolo commented Jul 25, 2024

@irvng-wav the other thing which you can do is to set some demanding app [possibly game] to perf cores only.
lscpu --all --extended will show you which cores are perf
taskset -c 1-7 someapp will set it to choosen cores
and watch if it stays above 3.6GHz, if it does that means that everything is working as it should and there might be something else impacting the performance under Linux.

@irvng-wav
Copy link
Author

irvng-wav commented Jul 29, 2024

@barolo I just played for a little bit with TLP following your instructions but I still couldn't get it to sound like a hair dryer as you describe. Maybe I'll come back to it again in the following days.

I'm curious, could you do a Geekbench 6 benchmark with your current setup to compare it to the benchmarks I've done with my laptop?

Here's one with Windows using performance fan mode (plugged in to AC):
Windows 11 Pro - 2347 Single-Core Score - 10155 Multi-Core Score

Here's one with my current Linux setup and everything also set to performance (plugged in to AC):
Arch Linux - 2341 Single-Core Score - 8020 Multi-Core Score

@barolo
Copy link

barolo commented Jul 29, 2024

@irvng-wav
Well, now I don't know what to think. Please note that I have a weaker variant of the CPU [i5-1240P]

Linux
Windows

My differences in Multi aren't as big as yours but it's still 1k, and it's actually worse for single-core under Windows.
I've noticed two things during benching, the fan is keep up under Windows, under Linux it doesn't even have time to spin up fully. Possibly due to minimum clocks, it's just 400 MHz under Linux and 1,700+ for Windows.

[it's possible to set minimum clocks with TLP so I'm going to try that next]

Edit. The clocks under Windows behave very differently for whatever reason, no matter which performance or fan level.

@barolo
Copy link

barolo commented Jul 29, 2024

@irvng-wav
Hah! I knew it! Apparently Linux has messed power management slightly atm [under Alderlake].
Setting up higher constraints via RAPL [using powercap] allowed me to bench better than Windows.
Geekbench_1
Geekbench_2
So it's not due to the fans not working, fans work fine [at least for me]

There's something up with reading one thermal zone being borked in the kernel which might be related.

@irvng-wav
Copy link
Author

irvng-wav commented Jul 29, 2024

@barolo Amazing news! It's giving you even better results than Windows. Great job, man! I'll try to do the same later in the day. Can you tell me specifically what you did?

@barolo
Copy link

barolo commented Jul 29, 2024

@barolo Amazing news! It's giving you even better results than Windows. Great job, man! I'll try to do the same later in the day. Can you tell me specifically what you did?

sure, the steps are as follows

  1. sudo ec_probe write 0x61 0x02 #set the fan to performance, just to be safe
  2. sudo cpupower frequency-set -g performance #it's supossed to help with latencies, doesn't really affect freq
  3. sudo cpupower idle-set -d3 and sudo cpupower idle-set -d4 #will turn off the deepest cpu sleep states, ones with highest wakeup latencies too, you can check them via cpupower idle-info. sudo cpupower idle-set -E will reset to defaults.
  4. sudo ./powercap-set intel-rapl --zone=0 --constraint=1 -l 66000000 and sudo ./powercap-set intel-rapl --zone=0 --constraint=2 -l 66000000 #changes power constraints [TDP] for CPU zone, it's still limited by temps, so you cannot overdo it, here its 66W, around ~70W seems to be the sweet spot for some reason [it won't pull that much]. You can check changes an all of the zones and their constraints via powercap-info. Note the defaults before changing.

also, make sure that thermald isn't running, it tries to keep the lowest temp always and will fight these changes

There's actually long winded guide for Framework Laptop which also has Alderlake cpu, for turning the rapl commands into systemd services so they trigger on AC. [towards the end of it]
https://github.com/junaruga/framework-laptop-config/wiki/Improving-thermal-management-with-Intel-Running-Average-Power-Limit-(RAPL)

@irvng-wav
Copy link
Author

irvng-wav commented Jul 29, 2024

@barolo you're the bomb! Take a look at this:
imagen
Now the cpu is clocked way higher than it was before. But I'm kinda worried about the temps. What do you think? (This tool is s-tui)

Edit: Here's the new benchmark:
Arch Linux: 2490 Single Core - 9983 Multi Core

Windows wins by 172 points in multi-core performance but Linux wins by 143 points in single-core. So finally it's leveled out. 🥳

@barolo
Copy link

barolo commented Jul 29, 2024

@irvng-wav the temps are fine IMHO, there's usually one or two cores hitting 90+ then quickly they're throttled down. It's all kept in check. Just make sure that there's space for ventilation under laptop. You can always decrease RAPL constraints slightly until you're satisfied.

You can also run thermald [with --adaptive argument] and see how it affects benches. If not by much then keep it on, to doubly make sure that temps are in check.

Windows wins by 172 points in multi-core performance but Linux wins by 143 points in single-core. So finally it's leveled out. 🥳

What I've noticed is, that the after some threshold, say 74W, multi-core performance [and benches] will get higher, and single core lower, no idea why. You have to strike a balance to get what you want.

Sidenote. It's freaking crazy that I've been using for almost 2 years, a laptop with throttled power, it feels like a brand new hardware now. First it was broken audio, then suspend battery drain, now it's messed up power management. It's always something with this machine...
[I've been doubly-fucked by ASUS, both with laptop and the phone, never again]

[BTW, there's HDR working now too, with the Xe mesa driver, at least under KDE/plasma 6]

@irvng-wav
Copy link
Author

irvng-wav commented Jul 31, 2024

@barolo thank you for helping figuring out this issue! I've seen threads on the internet posted years ago complaining about the CPU performance on Linux with these newer Zenbook laptops and I think some Vivobooks too. I myself started this project of making the best possible Linux experience that this machine can offer, and now virtually everything is working.

As you said, sound didn't work for a while but with kernel 6.7 or 6.8 (can't remember which one) the sound started working without manual patches. The fingerprint works thanks to this (Installed it on my system thanks to this), although that one took me a while to get the hang of. The numpad works even better than on Windows thanks to this project, where I got involved reporting as many bugs and improvements as I could to the developer, and now you helped me solve the CPU throttling issue! Thank you again!

I did some music production tests after raising the power constraints and it performed better than before, but then I launched the software I use (Bitwig Studio) with performance cores only and it got even better performance. I'll compare it to how it behaves on Windows.

The next steps for me are doing more performance tests with this new configuration, and also gaming tests with the new Xe graphics driver that you mentioned. I'm using GNOME and looks like HDR is still an experimental feature but I don't mind, the screen still looks amazing without it and also I need color accuracy for design work.

Would love to keep in touch to further discuss and share our findings about how we can improve the Linux experience on this machine. My discord username is irvng. (dot included) if you want to add me, if anyone else is interested feel free to add me also.

Cheers!

@dominiksalvet
Copy link
Owner

@irvng-wav Can I mark this issue with alternative found label?

@irvng-wav
Copy link
Author

@irvng-wav Can I mark this issue with alternative found label?

Sure! Thank you. 😁

@dominiksalvet dominiksalvet added the alternative found A working alternative fan tool was found label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new device Add support for new device AE_NOT_FOUND Unable to perform a fan ACPI call alternative found A working alternative fan tool was found help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants