From 9f17295edb5176040f63c0e7eb5c2e053a2192b9 Mon Sep 17 00:00:00 2001 From: mesutoezdil Date: Sun, 11 Oct 2026 14:03:27 +0200 Subject: [PATCH] fix(amdgpu): parse the SMC debugfs line that carries a program field Newer kernels print "SMC feature version: 0, program: 7, firmware version: 0x07551300" in amdgpu_firmware_info. The regex required the firmware field right after the feature field, so SMC was dropped and TestFirmwareVersionConsistent compared the ioctl value against zero. Signed-off-by: mesutoezdil --- internal/pkg/amdgpu/amdgpu.go | 3 ++- internal/pkg/amdgpu/amdgpu_test.go | 15 +++++++++++++++ .../debugfs-parsing/amdgpu_firmware_info_mi325x | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 testdata/debugfs-parsing/amdgpu_firmware_info_mi325x diff --git a/internal/pkg/amdgpu/amdgpu.go b/internal/pkg/amdgpu/amdgpu.go index 5992623e..e0a46b23 100644 --- a/internal/pkg/amdgpu/amdgpu.go +++ b/internal/pkg/amdgpu/amdgpu.go @@ -552,7 +552,8 @@ func ParseTopologyProperties(path string, re *regexp.Regexp) (int64, error) { return 0, errors.New("Topology property not found. Regex: " + re.String()) } -var fwVersionRe = regexp.MustCompile(`(\w+) feature version: (\d+), firmware version: (0x[0-9a-fA-F]+)`) +// Newer kernels print an extra "program: N," field on the SMC line. +var fwVersionRe = regexp.MustCompile(`(\w+) feature version: (\d+),(?: program: \d+,)? firmware version: (0x[0-9a-fA-F]+)`) func parseDebugFSFirmwareInfo(path string) (map[string]uint32, map[string]uint32) { feat := make(map[string]uint32) diff --git a/internal/pkg/amdgpu/amdgpu_test.go b/internal/pkg/amdgpu/amdgpu_test.go index c07b837b..24e46fa6 100644 --- a/internal/pkg/amdgpu/amdgpu_test.go +++ b/internal/pkg/amdgpu/amdgpu_test.go @@ -221,6 +221,21 @@ func TestParseDebugFSFirmwareInfo(t *testing.T) { } } +// Kernel 7.0 on an MI325X prints "program: N," between the SMC feature and +// firmware versions; the SMC entry must still parse. +func TestParseDebugFSFirmwareInfoSMCProgram(t *testing.T) { + feat, fw := parseDebugFSFirmwareInfo("../../../testdata/debugfs-parsing/amdgpu_firmware_info_mi325x") + if v, ok := fw["SMC"]; !ok || v != 0x07551300 { + t.Errorf("SMC firmware = %#x (present %v), want 0x07551300", v, ok) + } + if v, ok := feat["SMC"]; !ok || v != 0 { + t.Errorf("SMC feature = %d (present %v), want 0", v, ok) + } + if v := fw["MEC"]; v != 0x000080c2 { + t.Errorf("MEC firmware = %#x, want 0x80c2 (a line without program must still parse)", v) + } +} + func TestRenderDevIdsFromTopology(t *testing.T) { renderDevIds := GetDevIdsFromTopology("../../../testdata/topology-parsing-mi308") diff --git a/testdata/debugfs-parsing/amdgpu_firmware_info_mi325x b/testdata/debugfs-parsing/amdgpu_firmware_info_mi325x new file mode 100644 index 00000000..a9c87aaa --- /dev/null +++ b/testdata/debugfs-parsing/amdgpu_firmware_info_mi325x @@ -0,0 +1,5 @@ +RLC feature version: 1, firmware version: 0x00000046 +MEC feature version: 50, firmware version: 0x000080c2 +SMC feature version: 0, program: 7, firmware version: 0x07551300 (85.19.0) +SDMA0 feature version: 44, firmware version: 0x0000001b +VCN feature version: 0, firmware version: 0x09118022