]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu: set f_mapping on exported DMA-bufs
authorChristian König <christian.koenig@amd.com>
Mon, 13 Nov 2017 16:20:50 +0000 (17:20 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 14 Nov 2017 16:35:43 +0000 (11:35 -0500)
Otherwise we can't correctly CPU map TTM buffers.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c

index 90af8e82b16af3f97990b7e71bb672de4b6d0b72..ae9c106979d7de51ce3ec1027593d80d7a897e34 100644 (file)
@@ -169,10 +169,14 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,
                                        int flags)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj);
+       struct dma_buf *buf;
 
        if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) ||
            bo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID)
                return ERR_PTR(-EPERM);
 
-       return drm_gem_prime_export(dev, gobj, flags);
+       buf = drm_gem_prime_export(dev, gobj, flags);
+       if (!IS_ERR(buf))
+               buf->file->f_mapping = dev->anon_inode->i_mapping;
+       return buf;
 }