Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Make contiguous pinning optional

Enable pinning of VRAM without forcing it to be contiguous. When memory is
already pinned, make sure it's contiguous if requested.

Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Felix Kuehling and committed by
Alex Deucher
eda1068d dcb820d1

+6 -1
+6 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 911 911 912 912 if (bo->tbo.pin_count) { 913 913 uint32_t mem_type = bo->tbo.mem.mem_type; 914 + uint32_t mem_flags = bo->tbo.mem.placement; 914 915 915 916 if (!(domain & amdgpu_mem_type_to_domain(mem_type))) 917 + return -EINVAL; 918 + 919 + if ((bo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS) && 920 + !(mem_flags & TTM_PL_FLAG_CONTIGUOUS)) 916 921 return -EINVAL; 917 922 918 923 ttm_bo_pin(&bo->tbo); ··· 935 930 if (bo->tbo.base.import_attach) 936 931 dma_buf_pin(bo->tbo.base.import_attach); 937 932 938 - bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; 939 933 /* force to pin into visible video ram */ 940 934 if (!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) 941 935 bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; ··· 987 983 */ 988 984 int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain) 989 985 { 986 + bo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; 990 987 return amdgpu_bo_pin_restricted(bo, domain, 0, 0); 991 988 } 992 989