Previously, reading from the `pp_od_clk_voltage` sysfs file would include lots of null bytes between the sections, e.g.:
$ cat -v /sys/class/drm/card0/device/pp_od_clk_voltage OD_SCLK: 0: 500Mhz 1: 2514Mhz OD_MCLK: 0: 97Mhz 1: 1000MHz ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@OD_VDDGFX_OFFSET: 0mV ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@OD_RANGE: SCLK: 500Mhz 3000Mhz MCLK: 674Mhz 1075Mhz The reason for this is that calling `smu_cmn_get_sysfs_buf` aligns the offset used for `sysfs_emit_at` to the current page boundary, and then gets returned from the various `print_clk_levels` implementations to be directly added to the buffer position. Instead, only the relative offset showing how much was written to the buffer should be returned, regardless of how it was changed for alignment purposes. Now, the file is clean without any garbage data: $ cat -v /sys/class/drm/card0/device/pp_od_clk_voltage OD_SCLK: 0: 500Mhz 1: 2519Mhz OD_MCLK: 0: 97Mhz 1: 1000MHz OD_VDDGFX_OFFSET: 0mV OD_RANGE: SCLK: 500Mhz 3000Mhz MCLK: 674Mhz 1075Mhz I have changed this for SMU11, SMU13 and SMU14 as there have been user reports of this issue on all three, and the code is the same between them. However, I only have access to a 6900XT (SMU11), so the newer ones are untested. I've split the change into separate patches for SMU11 (tested) and SMU13/14 (untested), in case you believe that this change is risky and could break something. Sidenote: This is also my first time submitting patches to a mailing list, so please tell me if there are any issues with the patch or email formatting. Signed-off-by: Ilya Zlobintsev <[email protected]> Ilya Zlobintsev (2): drm/amd/pm: Avoid writing nulls into `pp_od_clk_voltage` (SMU11) drm/amd/pm: Avoid writing nulls into `pp_od_clk_voltage` (SMU13/SMU14) drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 5 +++-- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 5 +++-- 8 files changed, 24 insertions(+), 16 deletions(-) -- 2.51.0
