| 207 | #endif |
| 208 | |
| 209 | static bool sanity_check_npu_stack(bool quiet, bool json_output = false) { |
| 210 | bool print_human = !quiet && !json_output; |
| 211 | #ifndef _WIN32 |
| 212 | nlohmann::json validation_json = { |
| 213 | {"object", "npu_stack_validation"}, |
| 214 | {"platform", "windows"}, |
| 215 | {"kernel_ok", true}, |
| 216 | {"amd_device_found", true}, |
| 217 | {"all_fw_ok", true}, |
| 218 | {"enough_cols", true}, |
| 219 | {"memlock_ok", true}, |
| 220 | {"devices", nlohmann::json::array()}, |
| 221 | {"ready", true} |
| 222 | }; |
| 223 | validation_json["platform"] = "linux"; |
| 224 | // Check kernel version |
| 225 | struct utsname u_name; |
| 226 | if (uname(&u_name) != 0) { |
| 227 | if (print_human) |
| 228 | perror("Failed to get kernel version"); |
| 229 | validation_json["kernel_ok"] = false; |
| 230 | validation_json["ready"] = false; |
| 231 | if (json_output) { |
| 232 | std::cout << validation_json.dump(4) << std::endl; |
| 233 | } |
| 234 | return false; |
| 235 | } |
| 236 | int major, minor; |
| 237 | sscanf(u_name.release, "%d.%d", &major, &minor); |
| 238 | bool kernel_ok = (major > 6) || (major == 6 && minor >= 17); |
| 239 | validation_json["kernel"] = u_name.release; |
| 240 | validation_json["kernel_ok"] = kernel_ok; |
| 241 | if (!kernel_ok) { |
| 242 | if (print_human) { |
| 243 | header_print_r("ERROR", "Kernel version incompatible with this version of FLM. Please update your kernel!"); |
| 244 | } |
| 245 | validation_json["ready"] = false; |
| 246 | if (json_output) { |
| 247 | std::cout << validation_json.dump(4) << std::endl; |
| 248 | } |
| 249 | return false; |
| 250 | } |
| 251 | if (print_human) { |
| 252 | header_print("Linux", "Kernel: " << u_name.release); |
| 253 | } |
| 254 | |
| 255 | // Check firmware version of all AMD devices |
| 256 | bool all_fw_ok = true; |
| 257 | bool enough_cols = true; |
| 258 | bool amd_device_found = false; |
| 259 | bool drm_version_ok = true; |
| 260 | |
| 261 | for (int i = 0; i < 16; ++i) { |
| 262 | std::string dev_name = "/dev/accel/accel" + std::to_string(i); |
| 263 | int fd = open(dev_name.c_str(), O_RDWR); |
| 264 | |
| 265 | if (fd < 0) { |
| 266 | if (errno == ENOENT) |
no test coverage detected