kevinlekiller / amdctl

Set P-State voltages and clock speeds on recent AMD CPUs on Linux.
GNU General Public License v3.0
244 stars 22 forks source link

AMD Cesanne 5800H voltage control #40

Open weter11 opened 2 years ago

weter11 commented 2 years ago

Hi! After some time of investigating problems, I found a way to coltrol frequency. So changing boost by echo command not working, so I use Tuxedo control centre to do that and also for fan settings. Don't know is it a program limitation, but I can't set CPUFid more than 127, so currently I change power states by:

**amdctl -p 0 -v 60 -d 4 -f 74

Detected CPU model 50h, from family 19h with 16 CPU cores (REFCLK = 100MHz ; Voltage ID Encodings: SVI (serial)).
Preview mode OFF.

Core 0 | P-State Limits (non-turbo): Highest: 0 ; Lowest 2 | Current P-State: 0
 Pstate Status CpuFid CpuDid CpuVid  CpuMult     CpuFreq CpuVolt IddVal IddDiv CpuCurr CpuPower
      0      1     74      4     60   37.00x  3700.00MHz  1175mV     32     10  42.00A   49.35W**

sysbench report that performance was changed compared to default 3200MHz max w/o boost, so values was accepted. ryzen_monitor report

 CPU Model │         AMD Ryzen 7 5800H with Radeon Graphics │
│                           Processor Code Name │                                        Cezanne │
│                                         Cores │                                              8 │
│                                     Core CCDs │                                              0 │
│                                 Cores Per CCD │                                              8 │
│                                SMU FW Version │                                       v64.45.0 │
│                                MP1 IF Version │                                            v12 │

This program also report 3.7 GHz, but changing CpuVid has no effect at all, program always report Voltage from Core VRM 1.22-1.24V and power consumption 35-36W. I always tried set it to 4.0GHz at 0.8V, so it really don't change voltage for CPU. So is it my settings incorrect, or there are other ways to change voltage on power states?

kevinlekiller commented 2 years ago

Don't know is it a program limitation, but I can't set CPUFid more than 127

The program limits the fid up to 192: https://github.com/kevinlekiller/amdctl/blob/master/amdctl.c#L304

but changing CpuVid has no effect at all

This seems to be a common issue with some mobile zen, I'm guessing the manufacturer ignores the vid value?

weter11 commented 2 years ago

Ok. So first some report from ryzen_monitor for cpu bench at 3200MHz:

╭─────────┬────────────┬──────────┬─────────┬──────────┬─────────────┬─────────────┬─────────────╮
│  Core 0 │   3200 MHz |  2.877 W | 1.059 V |  60.81 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 1 │   3200 MHz |  2.797 W | 1.059 V |  58.43 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 2 │   3200 MHz |  2.911 W | 1.059 V |  66.71 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 3 │   3200 MHz |  2.845 W | 1.059 V |  60.08 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 4 │   3200 MHz |  2.886 W | 1.059 V |  66.70 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 5 │   3200 MHz |  2.857 W | 1.059 V |  60.47 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 6 │   3200 MHz |  2.853 W | 1.059 V |  61.58 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 7 │   3200 MHz |  2.783 W | 1.059 V |  58.31 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
╰─────────┴────────────┴──────────┴─────────┴──────────┴─────────────┴─────────────┴─────────────╯
╭── Core Statistics (Calculated) ───────────────┬────────────────────────────────────────────────╮
│              Highest Effective Core Frequency │                                       3200 MHz │
│                      Highest Core Temperature │                                        66.71 C │
│                          Highest Core Voltage │                                        1.059 V │
│                          Average Core Voltage │                                          inf V │
│                              Average Core CC6 │                                         -nan % │
│                          Total Core Power Sum │                                       22.809 W │
├── Reported by SMU ────────────────────────────┼────────────────────────────────────────────────┤
│                             Peak Core Voltage │                                        1.059 V │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Electrical & Thermal Constraints ───────────┬────────────────────────────────────────────────╮
│                              Peak Temperature │                                        68.25 C │
│                               GFX Temperature │                                        52.34 C │
│                         Voltage from Core VRM │               1.070 V |   1.450 V |    73.79 % │
│                                           PPT │              15.229 W |      54 W |    28.20 % │
│                                       PPT APU │              15.229 W |      54 W |    28.20 % │
│                                     TDC Value │              14.258 A |      58 A |    24.58 % │
│                           TDC Value, SoC only │               1.558 A |      15 A |    10.39 % │
│                                           EDC │              64.638 A |     110 A |    58.76 % │
│                                 EDC, SoC only │               0.000 A |      20 A |     0.00 % │
│                                           THM │               66.87 C |      98 C |    68.24 % │
│                                       THM SoC │               54.47 C |      98 C |    55.58 % │
│                                       THM GFX │               52.34 C |      98 C |    53.41 % │
│                                           FIT │                   0   |     260   |     0.00 % │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Memory Interface ───────────────────────────┬────────────────────────────────────────────────╮
│                                  Coupled Mode │                                             ON │
│                        Fabric Clock (Average) │                                       1600 MHz │
│                                  Fabric Clock │                                       1600 MHz │
│                                  Uncore Clock │                                       1600 MHz │
│                                  Memory Clock │                                       1600 MHz │
│                                     cLDO_VDDM │                                       0.9027 V │
│                                     cLDO_VDDP │                                       0.7514 V │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Graphics Subsystem──────────────────────────┬────────────────────────────────────────────────╮
│                       GFX Voltage | ROC Power │                          0.7107 V |    0.657 W │
│                               GFX Temperature │                                        52.34 C │
│                    GFX Clock Real | Effective │                           443 MHz |     88 MHz │
│                                      GFX Busy │                                       159.66 % │
│                     GFX EDC Limit | Residency │                          68.720 A |     0.00 % │
│                           Display Count | FPS │                                 1 |     0.00   │
│               DGPU Power | Freq Target | Busy │               0.000 W |     0 MHz |     0.00 % │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Power Consumption ──────────────────────────┬────────────────────────────────────────────────╮
│                          Total Core Power Sum │                                       22.809 W │
│                               VDDCR_SOC Power │                                        1.459 W │
│                                     ROC Power │                                        0.657 W │
│                                L3 Logic Power │                                        0.338 W │
│                                 L3 VDDM Power │                                        0.291 W │
│                                               │                                                │
│                               VDDIO_MEM Power │                                        1.922 W │
│                           IOD_VDDIO_MEM Power │                                        0.517 W │
│                                 DDR Phy Power │                                        1.115 W │
│                                   VDD18 Power │                                        0.239 W │
│                          CPU Display IO Power │                                        0.060 W │
│                              CPU USB IO Power │                                        0.109 W │
├── Additional Reports ─────────────────────────┼────────────────────────────────────────────────┤
│                              SoC Power (SVI2) │               0.944 V |   1.545 A |    1.459 W │
│                             Core Power (SVI2) │               1.059 V |  14.316 A |   15.156 W │
│                              Core Power (SMU) │                                       15.156 W │
│                            Socket Power (SMU) │                                       19.194 W │
│                           Package Power (SMU) │                                       19.194 W │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯

And this report is not on par with amdctl:

Detected CPU model 50h, from family 19h with 16 CPU cores (REFCLK = 100MHz ; Voltage ID Encodings: SVI (serial)).

Core 0 | P-State Limits (non-turbo): Highest: 0 ; Lowest 2 | Current P-State: 0
 Pstate Status CpuFid CpuDid CpuVid  CpuMult     CpuFreq CpuVolt IddVal IddDiv CpuCurr CpuPower
      0      1    128      8     53   32.00x  3200.00MHz  1218mV     32     10  42.00A   51.16W
      1      1     91     14     96   13.00x  1300.00MHz   950mV     13     10  23.00A   21.85W
      2      1     96     16    102   12.00x  1200.00MHz   912mV     12     10  22.00A   20.06W

So difference is huge, 1218mV by amdctl and 1070mv(I think it's actual value from VRM and 1059mV is target I think) by ryzen_monitor. Also when I try to set Fid more than 127:

'/home/wer/Apps/amdctl-master/amdctl' -v 100 -f 128
ERROR: Option -f must be a number 0 to 192.

Overall, looks like voltage controlled by another interface or in another way (idk), because frequency in pstates changed. This report after changed values:

'/home/wer/Apps/amdctl-master/amdctl' -p 0 -v 100 -d 4 -f 74
Detected CPU model 50h, from family 19h with 16 CPU cores (REFCLK = 100MHz ; Voltage ID Encodings: SVI (serial)).
Preview mode OFF.

Core 0 | P-State Limits (non-turbo): Highest: 0 ; Lowest 2 | Current P-State: 0
 Pstate Status CpuFid CpuDid CpuVid  CpuMult     CpuFreq CpuVolt IddVal IddDiv CpuCurr CpuPower
      0      1     74      4    100   37.00x  3700.00MHz   925mV     32     10  42.00A   38.85W
╭─────────┬────────────┬──────────┬─────────┬──────────┬─────────────┬─────────────┬─────────────╮
│  Core 0 │   3700 MHz |  4.706 W | 1.226 V |  82.08 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 1 │   3700 MHz |  4.515 W | 1.226 V |  77.51 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 2 │   3700 MHz |  4.946 W | 1.226 V |  94.22 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 3 │   3700 MHz |  4.632 W | 1.226 V |  80.64 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 4 │   3700 MHz |  4.973 W | 1.226 V |  95.32 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 5 │   3700 MHz |  4.602 W | 1.226 V |  81.20 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 6 │   3700 MHz |  4.737 W | 1.226 V |  86.00 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
│  Core 7 │   3700 MHz |  4.518 W | 1.226 V |  77.58 C | C0: 100.0 % | C1:   0.0 % | C6:   0.0 % │
╰─────────┴────────────┴──────────┴─────────┴──────────┴─────────────┴─────────────┴─────────────╯
╭── Core Statistics (Calculated) ───────────────┬────────────────────────────────────────────────╮
│              Highest Effective Core Frequency │                                       3700 MHz │
│                      Highest Core Temperature │                                        95.32 C │
│                          Highest Core Voltage │                                        1.226 V │
│                          Average Core Voltage │                                          inf V │
│                              Average Core CC6 │                                         -nan % │
│                          Total Core Power Sum │                                       37.629 W │
├── Reported by SMU ────────────────────────────┼────────────────────────────────────────────────┤
│                             Peak Core Voltage │                                        1.226 V │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Electrical & Thermal Constraints ───────────┬────────────────────────────────────────────────╮
│                              Peak Temperature │                                       101.50 C │
│                               GFX Temperature │                                        67.46 C │
│                         Voltage from Core VRM │               1.245 V |   1.397 V |    89.07 % │
│                                           PPT │              26.385 W |      54 W |    48.86 % │
│                                       PPT APU │              26.385 W |      54 W |    48.86 % │
│                                     TDC Value │              21.295 A |      58 A |    36.71 % │
│                           TDC Value, SoC only │               1.629 A |      15 A |    10.86 % │
│                                           EDC │              91.013 A |     110 A |    82.74 % │
│                                 EDC, SoC only │               0.000 A |      20 A |     0.00 % │
│                                           THM │               95.34 C |      98 C |    97.29 % │
│                                       THM SoC │               70.65 C |      98 C |    72.09 % │
│                                       THM GFX │               67.46 C |      98 C |    68.83 % │
│                                           FIT │                  15   |     260   |     5.87 % │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Memory Interface ───────────────────────────┬────────────────────────────────────────────────╮
│                                  Coupled Mode │                                             ON │
│                        Fabric Clock (Average) │                                       1600 MHz │
│                                  Fabric Clock │                                       1600 MHz │
│                                  Uncore Clock │                                       1600 MHz │
│                                  Memory Clock │                                       1600 MHz │
│                                     cLDO_VDDM │                                       0.9027 V │
│                                     cLDO_VDDP │                                       0.7514 V │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Graphics Subsystem──────────────────────────┬────────────────────────────────────────────────╮
│                       GFX Voltage | ROC Power │                          0.7249 V |    0.677 W │
│                               GFX Temperature │                                        67.46 C │
│                    GFX Clock Real | Effective │                           509 MHz |    197 MHz │
│                                      GFX Busy │                                       241.84 % │
│                     GFX EDC Limit | Residency │                          66.475 A |     0.00 % │
│                           Display Count | FPS │                                 1 |     0.00   │
│               DGPU Power | Freq Target | Busy │               0.000 W |     0 MHz |     0.00 % │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
╭── Power Consumption ──────────────────────────┬────────────────────────────────────────────────╮
│                          Total Core Power Sum │                                       37.629 W │
│                               VDDCR_SOC Power │                                        1.531 W │
│                                     ROC Power │                                        0.677 W │
│                                L3 Logic Power │                                        0.756 W │
│                                 L3 VDDM Power │                                        0.317 W │
│                                               │                                                │
│                               VDDIO_MEM Power │                                        2.298 W │
│                           IOD_VDDIO_MEM Power │                                        0.786 W │
│                                 DDR Phy Power │                                        1.195 W │
│                                   VDD18 Power │                                        0.259 W │
│                          CPU Display IO Power │                                        0.060 W │
│                              CPU USB IO Power │                                        0.109 W │
├── Additional Reports ─────────────────────────┼────────────────────────────────────────────────┤
│                              SoC Power (SVI2) │               0.944 V |   1.622 A |    1.531 W │
│                             Core Power (SVI2) │               1.226 V |  21.146 A |   25.915 W │
│                              Core Power (SMU) │                                       25.915 W │
│                            Socket Power (SMU) │                                       30.422 W │
│                           Package Power (SMU) │                                       30.422 W │
╰───────────────────────────────────────────────┴────────────────────────────────────────────────╯
kevinlekiller commented 2 years ago

Also when I try to set Fid more than 127

Ah! I see the issue, data type is signed, so it's limited to 127.

Will push a fix, thanks for the output!