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

drm/amdgpu: revert "generally allow over-commit during BO allocation"

This reverts commit f9d00a4a8dc8fff951c97b3213f90d6bc7a72175.

This causes problem for KFD because when we overcommit we accidentially
bind the BO to GTT for moving it into VRAM. We also need to make sure
that this is done only as fallback after trying to evict first.

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

authored by

Christian König and committed by
Alex Deucher
47722220 3273f116

+18 -4
+13 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 113 113 bp.resv = resv; 114 114 bp.preferred_domain = initial_domain; 115 115 bp.flags = flags; 116 - bp.domain = initial_domain | AMDGPU_GEM_DOMAIN_CPU; 116 + bp.domain = initial_domain; 117 117 bp.bo_ptr_size = sizeof(struct amdgpu_bo); 118 118 119 119 r = amdgpu_bo_create_user(adev, &bp, &ubo); ··· 332 332 } 333 333 334 334 initial_domain = (u32)(0xffffffff & args->in.domains); 335 + retry: 335 336 r = amdgpu_gem_object_create(adev, size, args->in.alignment, 336 - initial_domain, flags, ttm_bo_type_device, 337 - resv, &gobj); 337 + initial_domain, 338 + flags, ttm_bo_type_device, resv, &gobj); 338 339 if (r && r != -ERESTARTSYS) { 340 + if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) { 341 + flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; 342 + goto retry; 343 + } 344 + 345 + if (initial_domain == AMDGPU_GEM_DOMAIN_VRAM) { 346 + initial_domain |= AMDGPU_GEM_DOMAIN_GTT; 347 + goto retry; 348 + } 339 349 DRM_DEBUG("Failed to allocate GEM object (%llu, %d, %llu, %d)\n", 340 350 size, initial_domain, args->in.alignment, r); 341 351 }
+5 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 580 580 bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE; 581 581 582 582 bo->tbo.bdev = &adev->mman.bdev; 583 - amdgpu_bo_placement_from_domain(bo, bp->domain); 583 + if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA | 584 + AMDGPU_GEM_DOMAIN_GDS)) 585 + amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU); 586 + else 587 + amdgpu_bo_placement_from_domain(bo, bp->domain); 584 588 if (bp->type == ttm_bo_type_kernel) 585 589 bo->tbo.priority = 1; 586 590