Skip to content

feat(amdsmi): add chip_rev_id and external_rev_id to amdsmi_get_gpu_asic_info - #10446

Merged
marifamd merged 6 commits into
developfrom
users/marifamd/silicon-rev-id
Sep 2, 2026
Merged

marifamd merged 6 commits into
developfrom
users/marifamd/silicon-rev-id

Conversation

@marifamd

@marifamd marifamd commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

amdsmi_get_gpu_asic_info() reports rev_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_INFO DRM query this function already issues carries two more revision values, and they answer different questions:

Field amdgpu source Meaning
rev_id pci_rev PCI config-space revision (already reported)
chip_rev_id chip_rev Internal chip revision, the silicon stepping. The kernel UAPI annotates it "Internal chip revision: A0, A1, etc."
external_rev_id external_rev Family-scoped revision. The same value recurs across unrelated ASIC families, so it must be paired with device_id

They 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_info structure the function already fetches, so no additional ioctl or syscall is introduced.

ABI: the two uint32_t fields come out of the amdsmi_asic_info_t reserved tail. reserved shrinks from 17 to 15 entries and moves; the struct stays 896 bytes and no pre-existing field offset changes.

Field Offset
flags 816
physical_acc_id (existing) 824
chip_rev_id (new) 828
external_rev_id (new) 832
reserved[15] 836

Verified three ways: compiler offsetof, the regenerated ctypes wrapper, and the Rust offset_of! assertions. Both wrappers were regenerated with tools/update_wrapper.sh and tools/update_rust_wrapper.sh.

Behavior change to an existing field. Calling this out explicitly so it is not missed in review: rev_id was assigned from dev_info before 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_id now reports N/A on those paths instead of 0x0. Callers that check the return status are unaffected, since those paths already return a non-success status.

To support that, amdsmi_asic_info_t is now reset through a single init_asic_info_defaults() shared by the DRM and WSL backends. This is required by the feature, not incidental: the WSL backend previously memset the struct to zero, which would have reported both new fields as a plausible 0x00 rather than N/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) reports N/A instead of the ctypes zero.

The three commits are split to be reviewed in order: the shared initializer and rev_id fix, then the two new fields across the cascade, then the tests.

Issue Tracking

JIRA ID: ROCM-28626

Test Plan

  • Unit, hardware-free: pin struct size and both new offsets, and the reporting contract through the public Python entry point against a stubbed library (value passthrough, two-digit padding, 0xFFFFFFFF to N/A, 0x0 staying a real value, and a library that predates the fields).
  • Unit, C++: fill amdsmi_asic_info_t with garbage, call init_asic_info_defaults(), assert every field lands on its not-supported value.
  • Functional, hardware: resolve each processor's render node, issue AMDGPU_INFO_DEV_INFO directly, and assert all three revisions match what amdsmi_get_gpu_asic_info() reports.
  • CLI: assert both keys reach --json, and that the --csv column values match the JSON values.
  • Build both the default configuration and -DENABLE_WSL_BACKEND=ON.

Test Result

All green on a two-GPU Navi system (Navi 21 and Navi 32).

  • Build: 0 errors in both configurations, no new warnings on touched lines.
  • Tests: 15 Python tests and 2 gtests pass. pre-commit passes on every changed file.
  • Each of the three commits builds independently.
  • Values match the DRM ioctl exactly:
Node ASIC rev_id chip_rev_id external_rev_id vs ioctl
renderD128 Navi 21 0xc3 0x00 0x28 match
renderD129 Navi 32 0xc8 0x00 0x20 match

Previously measured on other silicon: MI210 chip_rev 0x01 / external_rev 0x3d, MI300A 0x01 / 0x47, MI350 0x00 / 0x50.

The swap-detection test was validated by injecting a real chip_rev_id/external_rev_id swap 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

@marifamd
marifamd requested a review from a team August 19, 2026 23:42
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: amdsmi labels Aug 19, 2026
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@dmitrii-galantsev dmitrii-galantsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dmitrii-galantsev
dmitrii-galantsev force-pushed the users/marifamd/silicon-rev-id branch from 50f7830 to 7d01e95 Compare August 28, 2026 16:24

@dmitrii-galantsev dmitrii-galantsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = 8
  • offsetof(silicon_rev_id) = 824 (the slot reserved used to start at)
  • offsetof(reserved) = 828, reserved shrunk [18] -> [17] (68 bytes)
  • every pre-existing offset unchanged: market_name 0, vendor_id 256, vendor_name 260, subvendor_id 516, device_id 520, rev_id 528, asic_serial 532, oam_id 788, num_of_compute_units 792, target_graphics_version 800, subsystem_id 808, flags 816

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>
@marifamd
marifamd force-pushed the users/marifamd/silicon-rev-id branch from 7d01e95 to 82c9f50 Compare September 1, 2026 19:38
@marifamd marifamd changed the title feat(amdsmi): add silicon_rev_id to amdsmi_get_gpu_asic_info feat(amdsmi): add chip_rev_id and external_rev_id to amdsmi_get_gpu_asic_info Sep 1, 2026
@marifamd
marifamd marked this pull request as ready for review September 1, 2026 19:49
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>
@marifamd
marifamd merged commit 103e57a into develop Sep 2, 2026
68 of 69 checks passed
@marifamd
marifamd deleted the users/marifamd/silicon-rev-id branch September 2, 2026 15:01
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants