# Ryzen 5 strange frequency states

## dumi

Hi, a bought new acer Nitro 5 notebook with Ryzen CPU (see below).

```

AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx

```

I'm using gentoo linux for more than ten years, bud now i'm in corner.

I try to use kernel gentoo-sources-4.9.x, it works fine (but it has no support for VEGA graphics), CPU reports frequency 2.0Ghz (right), when i disconnect AC adaptor frequency falls down ti 1.6Ghz, it;s ok, when i plugin AC adaptor back frequency returns to 2.0Ghz and remain stable.

Because of missing vega support i try to build kernel gentoo-sources-4.16.9, vega works fine, but cpu frequency behaves strange.

It is not stable on 2.0GHz bud every core has different frequency at freq fluctuate between about 1300 - 3800 MHz. When i disconnect AC adapter freq falls down to 399MHz on all cores and remain here stable until reboot.  After connection AC adapter back nothning changes. Frequency realy falls down, i try some test with compiling software and procesing power is enormly low.

I try lot of settings in kernel, but without success. 

Any ideas what to do?

Thank.

----------

## Ant P.

Can you install/run "cpupower frequency-info" and post the output before and after unplugging the AC? It sounds like some power management script is setting the cpu to powersave, which is more or less useless on a modern system.

----------

## dumi

Thanks for reply. 

i'm not having notebook with me, i will post output later.

But kernel is without cpufreq drivers, cpupower reports no frequency info.

i tried install all kernel cpufreq drivers with no change, without the drivers too. I think cpufrequency scaling is not the problem. With older kernel it works fine with same software installed.

----------

## dumi

cpupower output before disconnection AC adapter

```

dumidek ~ # cpupower frequency-info

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  hardware limits: 1.60 GHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 1.70 GHz, 1.60 GHz

  available cpufreq governors: performance

  current policy: frequency should be within 1.60 GHz and 2.00 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  boost state support:

    Supported: no

    Active: no

    Boost States: 0

    Total States: 3

    Pstate-P0:  2600MHz

    Pstate-P1:  2700MHz

    Pstate-P2:  2400MHz

```

Cpu frequency reported by /proc/cpuinfo

```

dumidek ~ # cat /proc/cpuinfo |grep MHz

cpu MHz      : 3089.260

cpu MHz      : 3090.212

cpu MHz      : 3133.338

cpu MHz      : 3133.347

cpu MHz      : 3142.518

cpu MHz      : 3142.525

cpu MHz      : 3102.502

cpu MHz      : 3102.623

```

After disconection and reconection AC adapter:

```

dumidek ~ # cpupower frequency-info

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  hardware limits: 1.60 GHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 1.70 GHz, 1.60 GHz

  available cpufreq governors: performance

  current policy: frequency should be within 1.60 GHz and 2.00 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  boost state support:

    Supported: no

    Active: no

    Boost States: 0

    Total States: 3

    Pstate-P0:  2600MHz

    Pstate-P1:  2700MHz

    Pstate-P2:  2400MHz

```

```

dumidek ~ # cat /proc/cpuinfo |grep MHz

cpu MHz      : 399.263

cpu MHz      : 399.265

cpu MHz      : 399.263

cpu MHz      : 399.264

cpu MHz      : 399.265

cpu MHz      : 399.263

cpu MHz      : 399.263

cpu MHz      : 399.262

```

Computer realy slow down, so freq is realy changed...

I don't know what to do with this, only restart help.[/code]

----------

## dumi

I have new information.

On first boot (after pressing power button, notebook in off state), system boots with low frequency (no matter if adapter is connected). I need to reboot it to get full frequency, Power off and turn on doesnt help. Only reset.

Strange is, that is not needed to boot the system, reset on grub loader screen help too.

Summary:

1] turn On PC

2] booting system

3] frequency low

4] reboot

5] booting system

6[ frequency high (but floating)

OR 

1] turn on PC

2] pres ctrl+alt+delete (reboot) on grub screen

3] booting system

4] frequency high (but floating)

Very strange for me. It's look like it is a hardware issue, and the old kernel can fix it, but old kernel does not suppor VEGA so it is unusable for me  :Sad: 

----------

## Goshanecr

Maybe there is a BIOS update for Your laptop?

----------

## dumi

I didnt found anything about bios update on this model :-/

Today i will test this on debian live CD.

----------

## Anon-E-moose

I've noticed screwy frequency results being posted since I've upgraded to 4.14 kernel.

I don't think the cpu is behaving badly, it's the reporting (from the kernel) that's screwy.

Not sure if that is what's going on with your system.

----------

## dumi

screwy frequency isnt problem, computing power is good. But iuf i disconnect AC adapter frequency drop tro 398MHz and computer works very slowly, so frequency realy drops to this value.  :Sad: 

----------

## Anon-E-moose

why are you using the performance governor instead of either ondemand or conservative ?

The drop in cpu freq drop may be bios related, because that cpu isn't supposed to run at that low frequency.

--> hardware limits: 1.60 GHz - 2.00 GHz <--

or it's some screwy bug between the governors, cpupower and the bios.

Edit to add: the only thing I can recommend is to not use cpupower to change things and see if the problem persists.

----------

## dumi

performance governor isnt problem, same happens if i use userspace, ondemand etc.

I try to install all of them, disable cpufreq support, no change. i think problem isn't in frequency scaling. With complete disabled cpu scaling problem persist. May the bios/efi relatet problem as you said. But kernel version matter becaus on 4.9.x all works perfect  :Sad: 

----------

## dumi

new information:

on kernel 4.19. /proc/cpuinfo returns:

[code] address sizes: 43 bits physical, 48 bits virtual[/code]

onkernel 4.9 returns

[code]address sizes: 48 bits physical, 48 bits virtual[/code]

maybe it can help to discover where is problem...

----------

## krinn

For what is it worth (maybe just to know you are not alone?) see https://forums.gentoo.org/viewtopic-t-1076990.html

why that link?

ryzen 5

work with 4.9

fail with 4.15 (and you 4.19)

Must be a regression then

----------

## Anon-E-moose

I would check the bios settings and see if one of them isn't causing the problem.

I have an acer and there isn't much that can be changed in the bios, BUT I did glance at asus swift 3 and it does have some settings for powersaving, etc. 

Play around with them.

----------

## dumi

There is nothing about power saving, frequency changing in bios. :-/

----------

## dumi

Yesterday i tried kernels 4.14.33 and 4.14.44 from gentoo-sources and git-sources-4.17.0-rc6. same problem. 

Seems to kernel 4.9 is last in gentoo portage which works as expected, but without vega support is useless for me.

----------

## virtguru

have you tried using maxcstate option on kernel command line ? 

Vaguely remember earlier issues with ryzen and cstates.

----------

## dumi

thank for suggestion.

i tried 

```

processor.max_cstate=1 intel_idle.max_cstate=0

```

and

```

processor.max_cstate=0

```

Nothing helps. but on first try, CPU fan was going on 100% (temperature was normal).

 :Sad:   :Sad:   :Sad: 

----------

## theotherjoe

dumi,

I had some strange things going on with a new ryzen 5 1600 cpu which 

could be narrowed down to the age of my PSU and the C6 power state.

during the process of chasing the error I came across the following

python script. maybe it can be of help for you too:

https://github.com/r4m0n/ZenStates-Linux

----------

## dumi

theotherjoe

thanks for link. i tried to disable all states except P0, no change, after unpluging AC adaptor frequency drops to 399MHz, setting every P state that is enabled didnt help :-/

very strange think..

----------

## dumi

i do some test:

last kernel that work fine is 4.14

4.15-rc1 behaves as descripted above, after disconnecting adapter CPU freq drops down and reboot is needed..

----------

## dumi

amazing....

i reset bios settings do default and press button to disconnect notebook battery and after new boot frequency behaves correctly  :Sad: 

maybe some bad was stuck somewhere in computer memory which persist power off and reboots, bios is set exactly the same as was...

----------

