shim: gracefully skip optional telemetry queries when the ioctl is unsupported (#1447 follow-up)#1449
shim: gracefully skip optional telemetry queries when the ioctl is unsupported (#1447 follow-up)#1449Scottcjn wants to merge 1 commit into
Conversation
…supported Follow-up to amd#1447. An older in-tree amdxdna can return EOPNOTSUPP/EINVAL for DRM_AMDXDNA_QUERY_TELEMETRY, and the SHIM currently throws shim_err, aborting the whole xrt-smi report even though basic BO/exec works. Wrap the optional telemetry query handlers so an unsupported ioctl degrades to an empty result plus a one-time warning, while device use continues. Required paths are unchanged; any error other than EOPNOTSUPP/ENOTSUP/EINVAL/ENOTTY is rethrown.
|
ok to test |
There was a problem hiding this comment.
Pull request overview
This PR updates the XDNA SHIM telemetry query path to gracefully handle older kernel drivers that don’t support DRM_AMDXDNA_QUERY_TELEMETRY, preventing xrt-smi from aborting the entire report when optional telemetry ioctls are unsupported.
Changes:
- Add a
telemetry_handler::telemetry_query()helper that treatsEOPNOTSUPP/ENOTSUP/EINVAL/ENOTTYas “telemetry unsupported” and returns an empty telemetry result instead of throwing. - Apply the helper across the telemetry query handlers (AIE2 + AIE4), and value-initialize
misc_telemetryoutputs to support early returns safely. - Add required headers for errno handling,
std::system_error, and one-time logging (std::once_flag).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static std::once_flag warned; | ||
| std::call_once(warned, [] { | ||
| shim_debug("telemetry not supported by this driver version; skipping " | ||
| "(update amdxdna; see amd/xdna-driver#1447)"); | ||
| }); |
maxzhen
left a comment
There was a problem hiding this comment.
It seems that the fix should be in xrt-smi, not in SHIM. The SHIM should faithfully signaling the caller and return whatever error it sees. It is the caller to decide if this is optional or required.
|
You're right, thanks. Moved it out of the shim. The shim goes back to just returning whatever errno the ioctl gives, no swallowing. The optional decision now lives in the caller in XRT: Xilinx/XRT#9907. It skips telemetry only when the driver reports it unsupported (EOPNOTSUPP, or ENOTTY if the ioctl is not registered), which is what aie2_get_info returns from its default case on an older driver. Everything else including EINVAL still surfaces so real errors are not hidden. I gave the preemption path the same handling since it hits the same rtos_telemetry query. That leaves nothing in this shim PR, so closing it in favor of the XRT one. |
Follow-up to #1447 (in-tree
amdxdna≤6.17 missingGET_ARRAY/AIE2 telemetry ioctls).Problem. When the loaded kernel driver predates
DRM_AMDXDNA_QUERY_TELEMETRY, the ioctl returnsEOPNOTSUPP/EINVAL. The SHIM's telemetry query handlers call it unconditionally, soshim_errthrows and the entirexrt-smireport aborts — even though basic BO/exec paths work fine on that driver.Fix. A small helper (
telemetry_handler::telemetry_query) wraps the optional telemetry ioctl: onEOPNOTSUPP/ENOTSUP/EINVAL/ENOTTYit logs a one-time warning and returnsfalse, so the caller returns an empty result and the rest of the report continues. Any other (real) error is rethrown. Applied to all 9 optional telemetry query handlers (aie/misc/opcode/rtos/stream_buffer, incl. the aie4 overrides). Required paths are untouched.This turns #1447 from "this ioctl is missing" into "the SHIM handles it safely on older drivers."
Testing.
-Werrorrelease build (cmake --build ... --target xrt_driver_xdna). The-Werror=maybe-uninitializedcheck caught thatmisc_telemetry's scalar result needed value-initialization on the new early-return path — fixed (result_type output{}).trysucceeds and behavior is unchanged.Surfaced during an open-source XDNA1 (Phoenix) Linux bring-up.