ROCm / ROCK-Kernel-Driver

AMDGPU Driver with KFD used by the ROCm project. Also contains the current Linux Kernel that matches this base driver
Other
333 stars 101 forks source link

I2C Interface like ATOMbios but through driver/cmdline #32

Closed rbartl closed 5 years ago

rbartl commented 7 years ago

Is it possible to access the I2C Interfaces that control the Voltage Regulator through the i2c-dev interface ?

this should return the ID of the installed VRM on a sapphire nitro+ (43) let a=0; while [ $a -lt 20 ] ; do let a=$a+1 ; i2cget -y $a 0x30 0x92 b ; done but returns 00 (or 27 if used with 2 byte return)

AlainCo commented 7 years ago

I have same problem as you, to detect, dump, read and write the i2c of ROCk. I've found the documentation: https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/blob/master/Documentation/i2c But it refers to i2c-dev that is already used by i2c-tools providing i2cget,i2cdump,i2cdetect...

Maye is is needed to upgrade the i2c-tools according to https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/blob/master/Documentation/i2c/upgrading-clients

Whatever is the solution, it seems possible as some people do use i2c to control the VRM.

REELcoder commented 6 years ago

Whatever is the solution, it seems possible as some people do use i2c to control the VRM.

This people claim that /dev/mem is used, i.e. bypassing all drivers and talking directly to the device. Any idea where to find some documentation on the needed address spaces and registers descriptions?

AlainCo commented 6 years ago

I've analysed amdgpu code, and

my dream would be to reactivate the /dev/i2c which are disabled... hard to make your dream come true.

REELcoder commented 6 years ago

There seems to be old tool for other GPUs: https://github.com/ius/radeonvolt

Where did you find VRM code in amdgpu? I just found the stuff for populating the VR config which is uploaded to the SMU, or the i2c stuff for comunicating with attached monitors (DDC).

AlainCo commented 6 years ago

Right, I only found useless i2c sysfs, and some code to control onitors as you say.

I've found the code where voltage gathered, scaled and send to othe layers, finishing in some write to emory that I don't understand... I did not get enough time to understand, and moreover I just vaguely discovered how it works... I was following that https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/amd-linux/918649-underclocking-undervolting-the-rx-470-with-amdgpu-pro-success I was debugging all, but recently I migrated to v 17.50 and all is to redo... I endedn when I discovered the voltage set in bios where correctly read but ,I know my card don't apply it, so I was in despair... I work cro-magnon style (vi+make; no way to cross compile on eclipse?), ...

Finally the good news on phoronix is maybe that it will be accessible in kernel 4.17 https://www.phoronix.com/forums/forum/phoronix/latest-phoronix-articles/1001523-gpu-voltage-control-support-coming-to-amdgpu-driver

REELcoder commented 6 years ago

We seem to be a the same point. I knew the older phoronix thread. *BTW vi+make rules...

The news sounds interesting. I hope there is unlimited control possible. Now I have tweaked the core voltage in amd/powerplay/smumgr/polaris10_smc.c:

@@ -689,6 +695,7 @@
    struct phm_ppt_v1_information *table_info =
            (struct phm_ppt_v1_information *)(hwmgr->pptable);
    SMU_SclkSetting curr_sclk_setting = { 0 };
+   uint32_t min = 800;

    result = polaris10_calculate_sclk_params(hwmgr, clock, &curr_sclk_setting);

@@ -697,6 +704,11 @@
            table_info->vdd_dep_on_sclk, clock,
            &level->MinVoltage, &mvdd);

+   if(level->MinVoltage > min) {
+       level->MinVoltage = (level->MinVoltage & 0xFFFF0000) + min*VOLTAGE_SCALE;
+       pr_info("polaris10_populate_single_graphic_level(): forcing voltage to %u mV for CR %4u\n", min, clock/100);
+   }
+
    PP_ASSERT_WITH_CODE((0 == result),
            "can not find VDDC voltage value for "
            "VDDC engine clock dependency table",

But even when choosing insanely low values the GPU works robust. I assume there is a range limitation somewhere further downstream...

Direct access to the VRM might still be the preferred approach.

whatwhat-what-zz commented 6 years ago

Maybe someone more adroit can take some cues from this project.

Hope this helps.

jlgreathouse commented 5 years ago

Hi all,

While we may not officially support configuration of our VRMs over I2C, we do now support configuring the DPM tables directly, which will allow you to set a requested voltage level for each of the DPM states. Additionally, you can request that only a particular DPM state (or subset of DPM states) be used, essentially forcing desired frequency/voltages.

For instance, please see this post where I describe how to use rocm-smi to control the DPM states on a GPU. Essentially:

Note that there are rules for how the DPM table must be configured (described in my other post). However, these mechanisms should allow you to set desired voltages that will be associated with desired frequencies.

If you do not want to use rocm-smi, note that it is just a Python script that is built up around accessing sysfs entries that you could also access yourself. The --setslevel and --setmlevel commands are wrappers around the pp_od_clk_voltage files in sysfs.