From 0495c47909dac6b8822f63387f0704bae04ca794 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 9 Jul 2026 20:02:57 +0800 Subject: [PATCH] GPU (Linux): fixes GPU core counting on Asahi Linux --- src/detection/gpu/gpu_drm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_drm.c b/src/detection/gpu/gpu_drm.c index ecc0e28f7..efeb15bfb 100644 --- a/src/detection/gpu/gpu_drm.c +++ b/src/detection/gpu/gpu_drm.c @@ -306,7 +306,11 @@ const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) { .size = sizeof(paramsGlobal), }) >= 0) { // They removed `unstable_uabi_version` from the struct. Hopefully they won't introduce new ABI changes. - gpu->coreCount = (int32_t) (paramsGlobal.num_clusters_total * paramsGlobal.num_cores_per_cluster); + assert(paramsGlobal.num_clusters_total <= DRM_ASAHI_MAX_CLUSTERS); + gpu->coreCount = 0; + for (uint32_t i = 0; i < paramsGlobal.num_clusters_total; i++) { + gpu->coreCount += __builtin_popcountll(paramsGlobal.core_masks[i]); + } gpu->frequency = paramsGlobal.max_frequency_khz / 1000; gpu->deviceId = ffGPUGeneral2Id(paramsGlobal.chip_id);