From c835bfc52a4f28911f6d399801ae58add49ef289 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Tue, 20 Apr 2021 02:29:22 +0200 Subject: [PATCH] amd/common: Use cap to test kernel modifier support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out both kernel v5.10 and v5.11 have the same amdgpu driver version and only one has modifiers ... In addition the version check is kinda annoying for backports. So lets use the cap. Since the cap is technically about ADDFB2 I tested that this works on rendernodes (and reading the code there is no distinction from what kind of node this is called). Fixes: 9a937330efb ("radeonsi: Only set modifier creation function for GFX9+ & with kernel support.") Reviewed-by: Marek Olšák Part-of: (cherry picked from commit 9da4590df8b7d08d51464874987313d230adfee8) --- .pick_status.json | 2 +- src/amd/common/ac_gpu_info.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 56c6fe69c70..84222a82364 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -94,7 +94,7 @@ "description": "amd/common: Use cap to test kernel modifier support.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "9a937330efbc21de64a85a4e80d1e3e92ef2a750" }, diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c index b1b950d1d15..ec574bd854d 100644 --- a/src/amd/common/ac_gpu_info.c +++ b/src/amd/common/ac_gpu_info.c @@ -34,6 +34,7 @@ #include #ifdef _WIN32 +#define DRM_CAP_ADDFB2_MODIFIERS 0x10 #define DRM_CAP_SYNCOBJ 0x13 #define DRM_CAP_SYNCOBJ_TIMELINE 0x14 #define AMDGPU_GEM_DOMAIN_GTT 0x2 @@ -278,6 +279,14 @@ static bool has_timeline_syncobj(int fd) return value ? true : false; } +static bool has_modifiers(int fd) +{ + uint64_t value; + if (drmGetCap(fd, DRM_CAP_ADDFB2_MODIFIERS, &value)) + return false; + return value ? true : false; +} + static uint64_t fix_vram_size(uint64_t size) { /* The VRAM size is underreported, so we need to fix it, because @@ -705,7 +714,7 @@ bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info, info->has_scheduled_fence_dependency = info->drm_minor >= 28; info->mid_command_buffer_preemption_enabled = amdinfo->ids_flags & AMDGPU_IDS_FLAGS_PREEMPTION; info->has_tmz_support = has_tmz_support(dev, info, amdinfo); - info->kernel_has_modifiers = info->chip_class >= GFX9 && info->drm_minor >= 40; + info->kernel_has_modifiers = has_modifiers(fd); info->has_graphics = gfx.available_rings > 0; info->pa_sc_tile_steering_override = device_info.pa_sc_tile_steering_override;