drm/amdgpu: enable freesync for A+A configs
authorChristian König <christian.koenig@amd.com>
Wed, 27 Jan 2021 12:20:40 +0000 (13:20 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 2 Feb 2021 22:36:33 +0000 (17:36 -0500)
Some newer APUs can scanout directly from GTT, that saves us from
allocating another bounce buffer in VRAM and enables freesync in such
configurations.

Without this patch creating a framebuffer from the imported BO will
fail and userspace will fall back to a copy.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Shashank Sharma <shashank.sharma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index f764803c53a4bb2466485d12e0f7c75099bf0e41..48cb33e5b3826caac252debfc011dc6b2c91c322 100644 (file)
@@ -926,8 +926,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
                                       struct drm_file *file_priv,
                                       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-       struct drm_gem_object *obj;
        struct amdgpu_framebuffer *amdgpu_fb;
+       struct drm_gem_object *obj;
+       struct amdgpu_bo *bo;
+       uint32_t domains;
        int ret;
 
        obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -938,7 +940,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
        }
 
        /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-       if (obj->import_attach) {
+       bo = gem_to_amdgpu_bo(obj);
+       domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+       if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
                drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
                return ERR_PTR(-EINVAL);
        }
index 25ec4d57333f6a9786e98551044e2476cb8fc39f..b4c8e5d5c763cd5416b712e60c3a7ec2a10ed44a 100644 (file)
@@ -897,7 +897,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
                return -EINVAL;
 
        /* A shared bo cannot be migrated to VRAM */
-       if (bo->prime_shared_count) {
+       if (bo->prime_shared_count || bo->tbo.base.import_attach) {
                if (domain & AMDGPU_GEM_DOMAIN_GTT)
                        domain = AMDGPU_GEM_DOMAIN_GTT;
                else