-
Notifications
You must be signed in to change notification settings - Fork 48
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 Ryzen 4000 APUs #31
Comments
As commented on ocerman/zenmonitor#27 I seem to get all the relevant data on my 4800H, probably through MSR (I didn't install your zenpower module ATM, I just discovered it). |
(As a follow-up question, is there anything I need zenpower for, that's not already covered by ACPI/P-states, MSR and friends?) |
@ocerman Have you figured out the SVI2 addresses on Renoir? ########################################################
SVI2: PCI Range
########################################################
0x0005A000: 0x00000000
0x0005A004: 0x00000000
0x0005A008: 0x00000000
0x0005A00C: 0x00000000
0x0005A010: 0x00000000
0x0005A014: 0x00000000
0x0005A018: 0x00000000
0x0005A01C: 0x00000000
0x0005A020: 0x00000000
0x0005A024: 0x00000000
0x0005A028: 0x00000000
0x0005A02C: 0x00000000
0x0005A030: 0x00000000
0x0005A034: 0x00000000
0x0005A038: 0x00000000
0x0005A03C: 0x00000000
0x0005A040: 0x00000000
0x0005A044: 0x00000000
0x0005A048: 0x00000000
0x0005A04C: 0x00000000
0x0005A050: 0x00000000
0x0005A054: 0x00000000
0x0005A058: 0x00000000
0x0005A05C: 0x00000000
0x0005A060: 0x00000000
0x0005A064: 0x00000000
0x0005A068: 0x00000000
0x0005A06C: 0x00000000
0x0005A070: 0x00000000
0x0005A074: 0x00000000
0x0005A078: 0x00000000
0x0005A07C: 0x00000000
0x0005A080: 0x00000000
0x0005A084: 0x00000000
0x0005A088: 0x00000000
0x0005A08C: 0x00000008
0x0005A090: 0x00000000
0x0005A094: 0x00000000
0x0005A098: 0x00000000
0x0005A09C: 0x00000000
0x0005A0A0: 0x00000000
0x0005A0A4: 0x00000000
0x0005A0A8: 0x00000000
0x0005A0AC: 0x00000000
0x0005A0B0: 0x00000000
0x0005A0B4: 0x00000000
0x0005A0B8: 0x00000000
0x0005A0BC: 0x00000000
0x0005A0C0: 0x00000000
0x0005A0C4: 0x00000000
0x0005A0C8: 0x00000000
0x0005A0CC: 0x00000000
0x0005A0D0: 0x00000000
0x0005A0D4: 0x00000000
0x0005A0D8: 0x00000000
0x0005A0DC: 0x00000000
0x0005A0E0: 0x00000000
0x0005A0E4: 0x00000000
0x0005A0E8: 0x00000000
0x0005A0EC: 0x00000000
0x0005A0F0: 0x00000000
0x0005A0F4: 0x00000000
0x0005A0F8: 0x00000000
0x0005A0FC: 0x00000000 As for SMU PowerTable, that's what I've figured out so far for the needs of my app (not 100% sure, but seems to work): [Serializable]
[StructLayout(LayoutKind.Explicit)]
private struct PowerTableAPU1
{
[FieldOffset(0x144)] public uint Fclk;
[FieldOffset(0x154)] public uint Uclk;
[FieldOffset(0x164)] public uint Mclk;
[FieldOffset(0x198)] public uint VddcrSoc;
}; |
SVI2 for Renoir seems to be public const uint F17H_M02H_SVI = 0x0006F000;
public const uint F17H_M60H_SVI_TEL_PLANE0 = (F17H_M02H_SVI + 0x38);
public const uint F17H_M60H_SVI_TEL_PLANE1 = (F17H_M02H_SVI + 0x3C); I'm not 100% in the naming of the register base (F17H_M02H_SVI), because I made it up, but a deeper PCI register scan dump from users reveals this is the base address and offsets. Again, not completely sure about offsets, but at least the VSOC seems to work. |
Is that your own code? Also from what I found, the ZEN SVI register ( base ) is always 0x0005A000. Server/TR parts:
Ryzen Desktop, APU Desktop, APU Mobile:
ZEN1/ZEN+ seems to have the PLANE0/1 swapped, but ZEN1 is a mess anyway. I don't have any Renoir box to test that, but if someone is willing to test, a patch could be added to zenpower to play around. |
@abucodonosor I'm the author of ZenTimings and reading VSOC seems to be working fine for Renoir. Not completely sure about the other plane, but it can be found experimentally. Sample dump from desktop Renoir system, but I think it is the same for mobile. ######################################################
SVI2: PCI Range
######################################################
0x0006F000: 0x00000000
0x0006F004: 0x00000010
0x0006F008: 0x00000010
0x0006F00C: 0x000186A0
0x0006F010: 0x00000010
0x0006F014: 0x000186A0
0x0006F018: 0x0000003C
0x0006F01C: 0x00000000
0x0006F020: 0x00000000
0x0006F024: 0x0000010E
0x0006F028: 0x0000000E
0x0006F02C: 0x00000000
0x0006F030: 0x00730001
0x0006F034: 0x00000002
0x0006F038: 0x012A001F
0x0006F03C: 0x0172001D
0x0006F040: 0x00000000
0x0006F044: 0x00000100
0x0006F048: 0x0000FF00
0x0006F04C: 0x00000000
0x0006F050: 0x00000000
0x0006F054: 0x00000000
0x0006F058: 0x00000000
0x0006F05C: 0x2B000000
0x0006F060: 0x73000000
0x0006F064: 0x00000000
0x0006F068: 0x00000000
0x0006F06C: 0x00000303
0x0006F070: 0x00000003
0x0006F074: 0x00000000
0x0006F078: 0x80000002
0x0006F07C: 0x80000002
0x0006F080: 0x80000041
0x0006F084: 0x00000000
0x0006F088: 0x00000000
0x0006F08C: 0x00000000
0x0006F090: 0x00000000
0x0006F094: 0x00000000
0x0006F098: 0x00000000
0x0006F09C: 0x00000000
0x0006F0A0: 0x00000000
0x0006F0A4: 0x01FF00FF
0x0006F0A8: 0x00000000
0x0006F0AC: 0x00000000
0x0006F0B0: 0x00000000
0x0006F0B4: 0x00000000
0x0006F0B8: 0x01FF00FF
0x0006F0BC: 0x00000000
0x0006F0C0: 0x00000001
0x0006F0C4: 0x00000001
0x0006F0C8: 0x00000000
0x0006F0CC: 0x00000000
0x0006F0D0: 0x00000000
0x0006F0D4: 0x00000000
0x0006F0D8: 0x00000000
0x0006F0DC: 0x00000000
0x0006F0E0: 0x00000000
0x0006F0E4: 0x00000000
0x0006F0E8: 0x00000000
0x0006F0EC: 0x00000000
0x0006F0F0: 0x00000000
0x0006F0F4: 0x00000000
0x0006F0F8: 0x00000000
0x0006F0FC: 0x00000000 PS: Actually that's a mobile CPU, so yes - it works on both desktop and mobile SKUs.
|
Duh, I suck, how did I miss that ?:) Looks like you are correct about the base address, and yes we could experiment with the PLANEs to figure out, @Cheaterman maybe you? |
I still have a Ryzen 7 4800H laptop I can test with, yes! Do tell which
branch of which repo to clone and I'll give it a try! :-)
|
There isn't a git branch yet, but I've made a patch with the values @irusanov found. Pull the zenpower git repo and apply : https://crazy.dev.frugalware.org/Zen2-Renoir-test.patch To change the PLANE address is easy, in zenpower.c there will be this:
Say we want to test Desktop offsets then we just need to change PLANE0 from 0x38 to 0x10 Thank you for doing that :) |
Thanks, the offsets make sense given I'm on non-server! Just to be clear,
what am I supposed to expect if it does/doesn't work? Testing tonight :-)
|
Well, is about the SVI base address in the first place, looks to be different from any other generation/model. If that works as is you should be able to see SVI2 Core/SoC voltage etc. |
@abucodonosor The offsets on the desktop are the same. I have dumps from both desktop and mobile Renoir. |
OK. I've made the first patch with your findings, so we'll see if that works as soon BTW, are all Renoir SKUs model 0x60? |
Yes, family 0x17, model 0x60. They only differ in package type, I think. |
Hi, sorry for the delay! Holidays 😄 I'm again not quite clear as to what I'm looking for - you'll see I have SVI2 power and current files in sysfs in both cases (logs attached). If anything, the values seem more correct with 0x38 + 0x3C, unless the units are different? (EDIT: That's actually a very bold assumption, I have no idea what correct values should look like...) Keep me in touch if you need more values tested 😄 (note the sanity check 😅 17h == 23, right?) |
Just stress the CPU a bit, and run sensors command in a terminal. That should give us some better idea. |
Great idea indeed - seems to confirm 0x10 and 0x0C give bogus data, as I suspected above:
This is permanent - regardless of load. On the other hand, if I'm using 0x38 + 0x3C, this is what I get when idling:
And under load:
So, looks like 0x38 and 0x3C work better than 0x10 and 0x0C. If you have thoughts, please let me know 😄 I hope the testing was satisfactory! |
Hey, quick question:
I recently managed to reverse engineer the PM table for Ryzen 5000. Values in there are already scaled to SI units and of higher resolution. Now I'm trying to correlate those values to what zenpower reports, to get that one working as well. Maybe a simmilar approach is possible for Ryzen 4000 as well? For reference, I attached a screenshot of what information I could pull from the PM table of my system. I found the reported values to be very stable, reproducible and could confirm they match the values I got from measuring individual power planes & currents on my mainboad. So I'm very confident those values are reasonable accurate and could be a solid base for verifying zenpower readings, given we manage to find the corresponding fields in the PM table of the 4000 APUs. |
SMUDebugTool (actually much more than just the communication with the SMU coprocessor) was a tool I've quickly coded to help me debug and poke the black box that Ryzen is. Eventually it got much more features over time, so it now has several "subtools" inside.
For example, here's a running and auto-refreshing power table of the CPU currently installed in my motherboard - 3000G. |
There is an SMU kernel module for Linux on gitlab. https://gitlab.com/leogx9r/ryzen_smu They have an issue open about RN PM table too: Also, there is this: If you ask me, we should all somehow join to one big project, even if is just one to share data and findings, no matter the operating system bc the data/register etc used are the same. As for Linux probably all those random all over the place driver should be merged in one or two working ones. |
@abucodonosor Joining forces: Yes, absolutely. I'm working on documenting what I did during the past days. Hopefully I did not only redo what somebode else with more knowledge has already done somewhere else... @irusanov |
I don't really know what to recommend. I'm working for a year and half on that stuff and most of it had been trial and error, especially in the beginning. Don't think there's another way of refreshing the table. All software tools I've seen send the command for refresh (transfer table to DRAM) on a given interval in order to get the current data. RyzenMaster, Hwinfo, ZenTimings, Asus Tool, perhaps many more. |
Regarding the access to any method, I don't think that matter on Linux. A kernel module will add files to sysfs, updating these all I tested, that ryzen_smu on 4 boxes here and it worked on exactly no one :-). |
Did the kernel module not work at all? Or just the userspace tool (monitor_cpu)? |
On 3750H and 3700U is loads but all I get is garbage since SMU version is not supported or alike and I have to use the tool with force. |
Same for 5900X. By saying "I had to reverse engineer the PM table" I meant that I had to find out what is at which index. Took me some time but was doable after all. |
Ok :). I'll try to see what I can do next week, I have more CPUs here to test but I'm in the wrong place at the moment, I can try it on a 2600,2700X,3600,3950X, and on a Threadripper 1950X next week and see what I get with these. TBH, I like the SMU modules output, but it looks like it needs a lot of work. |
OK, I created an isse over at ryzen_smu sharing the code I've got right now: https://gitlab.com/leogx9r/ryzen_smu/-/issues/5 I agree, especially the monitor_cpu tool needs work done. Originally, I wanted to keep the support for the 3700X table in there but then had a between-the-ears-error and didn't see how one would easily do that without a rewrite. If there is interest from the project, I'd be willing to do that. |
It's not that easy to support all possible CPUs. It's a little bit easier now with the information we have, but it was much harder 1 year ago. Every generation has different SMU commands and several versions of the PM table. Some versions differ slightly, some are completely incompatible. Everything depends on AGESA as well and the SMU Firmware in the bios. One recent example - two Picasso desktop APUs on different motherboards. My motherboard uses Zen SVI2 addresses and Raven SMU Firmware, while the other motherboard uses specific Picasso Firmware and switched SVI2 addresses (same as Naples and Whitehaven). Joined forces would be good, I also have a linux project (ZenStates-Linux, a fork of the original abandoned one), but it's on Python :)
You can't reuse tables between different generations. Usually the first part is somewhat consistent, but the rest isn't. |
Hello buddiez :-) I was just wondering if you guys want me to test more values, or if we're settling on that 0x38/0x3C thing? Cheers! EDIT: Also Happy New Year :-) hope y'all enjoying your holidays! |
Hello, I'm using the APU addresses given in your posts, may I ask you to give a try to CoreFreq for Renoir ? For testing, code is in the make
# as root
insmod corefreqk.ko
./corefreqd -q &
# as User
./corefreq-cli -t voltage The output should show the In advance, thank you for any help. |
original problem: ocerman/zenmonitor#27
The text was updated successfully, but these errors were encountered: