Bug 203733

Summary: CPU freq stuck at 400Mhz when CPU is fully loaded and video card is used - AMD Ryzen 3550h
Product: Power Management Reporter: Shiko Mstoyan (shiko)
Component: ThermalAssignee: Zhang Rui (rui.zhang)
Status: NEW ---    
Severity: normal CC: albertogomezmarin, djip.perois, haagch.christoph, leonmaxx, nj_Brillus, postix, squallssck, vorpal
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 5.1.3 Subsystem:
Regression: No Bisected commit-id:

Description Shiko Mstoyan 2019-05-27 21:16:16 UTC
I've bougt new notebook with ryzen 3550h onboard (Asus fx705dy) and noticed one thing: whenever the cpu is fully loaded and the gpu is being used the cpu sets its freqeuncy to 400MHz and system works slow untill reboot.

For example:I installed Android Studio. When I open large project in it and open youtube video in browser or start emulator system works on max frequency for couple of seconds and then lowers cpu frequency to 400MHz. If I just compile the project it'll work nice until using gpu.

Another example is I can compile Unreal Engine within 1.5 hours without such problems if I just let notebook do it without browsing internet.

I've tried a lot of things like settings cpufreq mode to performance (sudo cpufreq-set -r -g performance), disabling c6 state etc.

I've already tested it on couple of kernels I believe started with 5.1.1 and now am on 5.1.5, issue still exists.

The only workaround I found for now is disabling boost for cpu by executing
echo 0 > /sys/devices/system/cpu/cpufreq/boost.

Any idea how to work on this system without disabling cpu boost?

Thanks in advance.
Comment 1 nj_Brillus 2019-07-01 21:41:23 UTC
Have the Asus fx505dy (basically the 15 inch version) can confirm the problem. My current Kernel Version in usage: 5.1.7-1-default (OpenSuSE LEAP).
Comment 2 nj_Brillus 2019-07-01 22:17:40 UTC
With 5.1.10-1-default also the same bug.  

And I meant OpenSuSE Tumbleweed, mixed them up each time.  

And also tried it with using the decicated GPU as well as the integrated, happens with both.
Comment 3 djip.perois 2019-09-06 22:39:00 UTC
I had it 1 time. 
The speed of FAN CPU can be change (on Windows only-now... patch is work-in-progress for linux...) 
 There is 3 FAN mode: silence/normal/boost

look like silence mode is not enought for full load. In that mode CPU temp will go up tu 85°C living CPU to passe in protected mode (???) => 400MHz.

may be related to 
https://bugzilla.kernel.org/show_bug.cgi?id=204579
Comment 4 djip.perois 2019-09-06 22:42:31 UTC
FAN speed patch for ASUS Notebook...
https://patchwork.kernel.org/patch/10943639/

But note 100% Working for Asus FX505DY I have...
https://github.com/hackbnw/faustus/issues/3
Comment 5 Alberto 2019-10-20 11:29:52 UTC
(In reply to djip.perois from comment #4)
> FAN speed patch for ASUS Notebook...
> https://patchwork.kernel.org/patch/10943639/
> 
> But note 100% Working for Asus FX505DY I have...
> https://github.com/hackbnw/faustus/issues/3

I have no Linux in asus fx505dy right now, I have returned the older because it has flickering screen. Now is working good, but with Linux the battery drains so much.. until a fix for the battery I will run windows( i am sad.. but the mobility is mandatory) for now
Comment 6 djip.perois 2019-10-21 23:06:19 UTC
Not sure but may be good news:

https://www.phoronix.com/scan.php?page=news_item&px=AMDGPU-DC-PSR-Patches-Ready
Comment 7 Alberto 2019-11-03 03:46:42 UTC
(In reply to djip.perois from comment #6)
> Not sure but may be good news:
> 
> https://www.phoronix.com/scan.php?page=news_item&px=AMDGPU-DC-PSR-Patches-
> Ready

I think it is not related
Comment 8 LeonMaxx 2019-11-03 12:15:39 UTC
(In reply to djip.perois from comment #4)
> But note 100% Working for Asus FX505DY I have...
> https://github.com/hackbnw/faustus/issues/3

Djip are you working on a kernel patch?
I made a patch that adds support for Fan Boost Mode on FX705DY, should I try to post it on ml?

My patch: https://pastebin.com/4bn7mmyr
Comment 9 Gerdoch 2019-11-05 21:07:27 UTC
I can confirm that LeonMaxx's patch also corrects this issue on my Asus FX505DY which is the 15" version of the device in this bug.  Hopefully his patch or something similar can be upstreamed to remove the need to recompile a custom kernel every upgrade.
Comment 10 Alberto 2019-11-10 16:15:14 UTC
hello, the people who have this patch in the build.. when the fan is in normal mode will it stop sometimes or is it running 100 percent of time?
with the official kernel and any change the fan stop sometimes it is the same as normal?
Comment 11 Gerdoch 2019-11-10 16:30:02 UTC
The fan throttles up and down as normal.  With basically no load my fan is silent and CPU temp is at 36c. I am unsure if the fan stops on a non-patched kernel, I didn't check that prior to patching my kernel.
Comment 12 LeonMaxx 2019-11-10 17:21:42 UTC
You can control fan boost mode by pressing Fn+F5 or by writing mode number to /sys/devices/platform/asus_nb_wmi/fan_boost_mode:
0 - Normal
1 - Overboost
2 - Silent
Comment 13 Alberto 2019-11-10 17:43:02 UTC
(In reply to Gerdoch from comment #11)
> The fan throttles up and down as normal.  With basically no load my fan is
> silent and CPU temp is at 36c. I am unsure if the fan stops on a non-patched
> kernel, I didn't check that prior to patching my kernel.

(In reply to LeonMaxx from comment #12)
> You can control fan boost mode by pressing Fn+F5 or by writing mode number
> to /sys/devices/platform/asus_nb_wmi/fan_boost_mode:
> 0 - Normal
> 1 - Overboost
> 2 - Silent

yes, yes, I know that, the question is :
In normal mode the fan stop sometimes for use less power and be more silence when is possible or is it only in silent mode?
Comment 14 Gerdoch 2019-11-12 18:45:20 UTC
Yes, in normal mode the fan is silent when then system is idle.
Comment 15 Alberto 2019-11-13 07:05:59 UTC
Okey. Anda.. if the normal mode power off the fan like the silent does .. what are the differenc between them
Comment 16 Alberto 2019-11-13 07:06:22 UTC
(In reply to Gerdoch from comment #14)
> Yes, in normal mode the fan is silent when then system is idle.

For you, sorry for not mentioning before
Comment 17 Gerdoch 2019-12-13 01:02:42 UTC
So a fix was submitted to LKML at https://lkml.org/lkml/2019/11/24/51 but looked like it needed some revision due to stuff like a missing colon(?) - has there been any progress on this getting merged into the kernel itself?  Searching LKML hasn't found anything since that, so far as I can tell.
Comment 18 Gerdoch 2019-12-13 01:05:32 UTC
Just to be clear, the patch I linked works just fine if the kernel is manually patched and built, so I'm hoping that there's some progress getting them merged so these laptops will be usable without having to compile a new kernel every time there's a distro update.  Thanks!
Comment 19 Christoph Haag 2020-01-28 00:22:43 UTC
Phoronix has reported about this fix https://www.phoronix.com/scan.php?page=news_item&px=ASUS-TUF-Ryzen-Thermal-Fix
and the commits are in git master:
https://github.com/torvalds/linux/commit/a28215844d8db87aadb9bcce040e7897691ff6ba
https://github.com/torvalds/linux/commit/2daa86e78c494d06d0aac231e4533f3dc50fa432


My laptop is the ASUS TUF FX505DY-BQ001T with R5-3550H + RX 560X.

I built linux git and indeed, on AC power it seems the laptop does not throttle anymore, so this seems fixed.

But it looks like there is indeed another issue:
On battery power the CPU is throttled to 400 MHz after running unigine heaven for 4 seconds on the dedicated GPU. The throttling stops when quitting unigine heaven, and it returns to normal frequencies. The throttling is not happening when running unigine heaven on the igpu.

Does this sound like a related issue or is it something completely different?
Comment 20 LeonMaxx 2020-01-29 09:41:29 UTC
This sounds more like a power management issue.
If it is you can try set dGPU to power saving mode, TLP daemon can do this when running on battery. Options to set:

RADEON_POWER_PROFILE_*
RADEON_DPM_STATE_*

If it doesn't helps you can try my asus_fanmode daemon: https://github.com/leonmaxx/asus_fanmode

This may work if acpi switches mode to silent when running on battery.
Comment 21 squallssck 2020-10-09 07:05:43 UTC
ROG Zephyrus G14 with AMD Ryzen 4800HS & Nvidia 2060 maxq came across a similar problem. OS: Ubuntu 20.04 LTS with kernel 5.8.12

when push dGPU with 4 threads of TensorRT Neural Network Inferencing for like 10 seconds, the utilization of dGPU will drop from 99% to under 50% and the whole system and GNOME will be lagging very much.  It seems like 4800HS is throttling and not feding dGPU enough data. No matter how you cool down the system, it will not come back to normal performance until a system reboot.