Skip to content

Commit f9d00a4

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: generally allow over-commit during BO allocation
We already fallback to a dummy BO with no backing store when we allocate GDS,GWS and OA resources and to GTT when we allocate VRAM. Drop all those workarounds and generalize this for GTT as well. This fixes ENOMEM issues with runaway applications which try to allocate/free GTT in a loop and are otherwise only limited by the CPU speed. The CS will wait for the cleanup of freed up BOs to satisfy the various domain specific limits and so effectively throttle those buggy applications down to a sane allocation behavior again. Signed-off-by: Christian König <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Reviewed-by: Arunpravin Paneer Selvam <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6ee31b3 commit f9d00a4

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
113113
bp.resv = resv;
114114
bp.preferred_domain = initial_domain;
115115
bp.flags = flags;
116-
bp.domain = initial_domain;
116+
bp.domain = initial_domain | AMDGPU_GEM_DOMAIN_CPU;
117117
bp.bo_ptr_size = sizeof(struct amdgpu_bo);
118118

119119
r = amdgpu_bo_create_user(adev, &bp, &ubo);
@@ -332,20 +332,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
332332
}
333333

334334
initial_domain = (u32)(0xffffffff & args->in.domains);
335-
retry:
336335
r = amdgpu_gem_object_create(adev, size, args->in.alignment,
337-
initial_domain,
338-
flags, ttm_bo_type_device, resv, &gobj);
336+
initial_domain, flags, ttm_bo_type_device,
337+
resv, &gobj);
339338
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-
}
349339
DRM_DEBUG("Failed to allocate GEM object (%llu, %d, %llu, %d)\n",
350340
size, initial_domain, args->in.alignment, r);
351341
}

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
581581
bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
582582

583583
bo->tbo.bdev = &adev->mman.bdev;
584-
if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA |
585-
AMDGPU_GEM_DOMAIN_GDS))
586-
amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
587-
else
588-
amdgpu_bo_placement_from_domain(bo, bp->domain);
584+
amdgpu_bo_placement_from_domain(bo, bp->domain);
589585
if (bp->type == ttm_bo_type_kernel)
590586
bo->tbo.priority = 1;
591587

0 commit comments

Comments
 (0)