From 6cc8f7ec13e34070724f6d018134c67cc69d220a Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Tue, 24 Sep 2024 10:39:23 -0400 Subject: [PATCH] rocminfo fails when amdgpu is built into the kernel When amdgpu is built into the kernel, /sys/module/amdgpu/initstate will not be created even when the driver is functional. However, test shows /sys/module/amdgpu will be present. Adding an additional check for /sys/module/amdgpu when /sys/module/amdgpu/instate is not present. Change-Id: Ie5c67c7e1eff8ac1683b211aaec802d0d342aeeb [ROCm/rocminfo commit: c6f7a17c85e0cdd75bf062e7a3490e831c87eb94] --- projects/rocminfo/rocminfo.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/rocminfo/rocminfo.cc b/projects/rocminfo/rocminfo.cc index da18935529..6d7329ad6c 100755 --- a/projects/rocminfo/rocminfo.cc +++ b/projects/rocminfo/rocminfo.cc @@ -1220,9 +1220,14 @@ int CheckInitialState(void) { return -1; } } else { - printf("%sROCk module is NOT loaded, possibly no GPU devices%s\n", - COL_RED, COL_RESET); - return -1; + int module_dir; + module_dir = open("/sys/module/amdgpu", O_DIRECTORY); + if (module_dir < 0) { + printf("%sROCk module is NOT loaded, possibly no GPU devices%s\n", + COL_RED, COL_RESET); + return -1; + } + close(module_dir); } // Check if user belongs to the group for /dev/kfd (e.g. "video" or