Repository navigation
feat(amdsmi): add chip_rev_id and external_rev_id to amdsmi_get_gpu_asic_info - #10446
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
dmitrii-galantsev
left a comment
There was a problem hiding this comment.
claude:
Approving with the WSL fix pushed on top.
ABI checks out: silicon_rev_id is appended at the tail of amdsmi_asic_info_t (offset 824) with reserved[18] shrunk to [17], so the struct is still 896 bytes and no pre-existing field moved. The Rust offset_of! static asserts are updated to 824/828 consistently, the Python struct_amdsmi_asic_info_t matches, and static.py:305 iterates every key of the returned dict, so the field reaches amd-smi static --asic in human-readable, JSON and CSV.
One caveat: no amdsmi build actually completed in this PR's CI — the failures were cancelled builds and unrelated projects. This PR touches C++, so please get a real green amdsmi build before merging.
50f7830 to
7d01e95
Compare
dmitrii-galantsev
left a comment
There was a problem hiding this comment.
claude:
Rebased onto origin/develop (3bbe12e068e) — the branch was 332 commits behind and CONFLICTING. Re-approving after the force-push dismissed the previous approval.
Conflicts resolved: only CHANGELOG.md. develop opened a new ## amd_smi_lib for ROCm 10.1.0 section (#10391) after this branch was cut, so the entry was moved out of the now-closed 10.0.0 section into 10.1.0 / ### Added. No content change to the entry itself. Also converted the new test file to the two-line SPDX header now enforced by the amdsmi-license-headers pre-commit hook.
ABI re-verified on the rebased tree (not assumed to have survived) — develop has not added any field to amdsmi_asic_info_t, so the layout is unchanged from the original claim. Confirmed by compiling a TU of static_asserts against the rebased amdsmi.h:
sizeof(amdsmi_asic_info_t)= 896 (unchanged),alignof= 8offsetof(silicon_rev_id)= 824 (the slotreservedused to start at)offsetof(reserved)= 828,reservedshrunk[18] -> [17](68 bytes)- every pre-existing offset unchanged:
market_name0,vendor_id256,vendor_name260,subvendor_id516,device_id520,rev_id528,asic_serial532,oam_id788,num_of_compute_units792,target_graphics_version800,subsystem_id808,flags816
All three bindings agree on 896 / 824 / 828: the C header, the Rust offset_of! static asserts in rust-interface/src/amdsmi_wrapper.rs, and the Python struct_amdsmi_asic_info_t ctypes layout (evaluated directly out of the generated wrapper, not transcribed).
Other checks: git range-diff against the pre-rebase tip shows only the two intended deltas above — the WSL commit is byte-identical. g++ -fsyntax-only -std=c++17 -DENABLE_WSL_BACKEND clean on amd_smi_wsl_device.cc; clang-format --dry-run --Werror clean on all touched C++; ruff check / ruff format --check / py_compile clean on the test; pre-commit clean on all changed files (the one hook failure is tests/python/unit/gpu/test_topology.py, pre-existing on develop and untouched here).
Caveat unchanged from my earlier review: this touches C++ and I have only syntax-checked it. It needs a real green amdsmi build and a run on hardware before merge — in particular that dev_info.external_rev is what is actually wanted, and that the N/A path reports correctly on WSL.
rev_id was assigned from the device-info structure before the AMDGPU_INFO_DEV_INFO query populated it, so every early return replaced the not-supported value with a zero that reads like a real revision. Reset amdsmi_asic_info_t through one initializer shared by the DRM and WSL backends instead of repeating the field list per backend, and report rev_id as N/A in Python when the library could not supply it. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
amdsmi_get_gpu_asic_info() already issues the AMDGPU_INFO_DEV_INFO query that carries both values but reported neither, leaving callers no way to tell the silicon stepping from the family-scoped revision, and no way to tell either from the PCI config-space rev_id it does report. Both fields come out of the reserved tail, so the structure size and every pre-existing field offset are unchanged. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Pin the struct layout and the not-supported rendering without hardware, cross-check all three revisions against the DRM ioctl on hardware, and assert the shared initializer marks every field not-supported. The layout test gives the two revisions distinct values so a swap between them is caught without a GPU. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
7d01e95 to
82c9f50
Compare
The defaults test never asserted physical_acc_id, so deleting its line from the initializer regressed the field to zero with every test still passing. The CLI test split CSV on bare commas, but vendor_name carries one on the fallback path both backends use, which shifted every column after it and compared the wrong values. Also drop the WSL assignments the shared initializer already covers, so both branches read the same way. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
…ibility claim The changelog said both the Python dictionary and the CLI report 0xFFFFFFFF, but only the C fields carry that value; the bindings render it as N/A. The rev_id entry also credited the DRM early-return paths, which already returned an error, rather than the WSL backend that returned success with a zeroed structure. The seed comment claimed every older library leaves the reserved slots alone, which holds for the DRM path but not for a WSL library that clears the whole structure. Also let a library failure fail the functional test rather than reduce it to a skip, and match the neighbouring hex width in the nodrm example. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
The kernel UAPI names A0 and A1 only as examples and defines no numeric encoding, so mapping them to 0 and 1 asserted a contract the driver does not make and still left every other stepping unexplained. Describe the field as the driver's raw value and leave the interpretation to the caller. Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
TheRock Submodule Bump ActivityNewest first
|
Motivation
amdsmi_get_gpu_asic_info()reportsrev_id, the PCI config-space revision, but nothing about the silicon itself. Consumers that need the ASIC revision (validation and qualification tooling, telemetry exporters tagging metrics per revision) had no in-band source for it.The
AMDGPU_INFO_DEV_INFODRM query this function already issues carries two more revision values, and they answer different questions:rev_idpci_revchip_rev_idchip_revexternal_rev_idexternal_revdevice_idThey are genuinely distinct on real hardware. On a Navi 21 the same part reports
rev_id 0xc3,chip_rev_id 0x00,external_rev_id 0x28, so neither existing field can stand in for the others.Technical Details
Both values are read from the
dev_infostructure the function already fetches, so no additional ioctl or syscall is introduced.ABI: the two
uint32_tfields come out of theamdsmi_asic_info_treserved tail.reservedshrinks from 17 to 15 entries and moves; the struct stays 896 bytes and no pre-existing field offset changes.flagsphysical_acc_id(existing)chip_rev_id(new)external_rev_id(new)reserved[15]Verified three ways: compiler
offsetof, the regenerated ctypes wrapper, and the Rustoffset_of!assertions. Both wrappers were regenerated withtools/update_wrapper.shandtools/update_rust_wrapper.sh.Behavior change to an existing field. Calling this out explicitly so it is not missed in review:
rev_idwas assigned fromdev_infobefore the DRM query populated it, so every early-return path overwrote the not-supported value with a zero that reads like a real revision.rev_idnow reportsN/Aon those paths instead of0x0. Callers that check the return status are unaffected, since those paths already return a non-success status.To support that,
amdsmi_asic_info_tis now reset through a singleinit_asic_info_defaults()shared by the DRM and WSL backends. This is required by the feature, not incidental: the WSL backend previouslymemsetthe struct to zero, which would have reported both new fields as a plausible0x00rather thanN/A.The Python binding seeds both new fields with the not-supported value before the call, so a newer wrapper running against an older
libamd_smi.so(supported via the wheel's system-library fallback) reportsN/Ainstead of the ctypes zero.The three commits are split to be reviewed in order: the shared initializer and
rev_idfix, then the two new fields across the cascade, then the tests.Issue Tracking
JIRA ID: ROCM-28626
Test Plan
0xFFFFFFFFtoN/A,0x0staying a real value, and a library that predates the fields).amdsmi_asic_info_twith garbage, callinit_asic_info_defaults(), assert every field lands on its not-supported value.AMDGPU_INFO_DEV_INFOdirectly, and assert all three revisions match whatamdsmi_get_gpu_asic_info()reports.--json, and that the--csvcolumn values match the JSON values.-DENABLE_WSL_BACKEND=ON.Test Result
All green on a two-GPU Navi system (Navi 21 and Navi 32).
pre-commitpasses on every changed file.rev_idchip_rev_idexternal_rev_id0xc30x000x280xc80x000x20Previously measured on other silicon: MI210
chip_rev 0x01/external_rev 0x3d, MI300A0x01/0x47, MI3500x00/0x50.The swap-detection test was validated by injecting a real
chip_rev_id/external_rev_idswap into the interface: the new assertion failed as intended while the other tests passed, confirming it catches a defect the earlier equal-value test could not.Submission Checklist