|
@@ -191,10 +191,10 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
|
|
int r;
|
|
int r;
|
|
|
|
|
|
if (!*bo_ptr) {
|
|
if (!*bo_ptr) {
|
|
- r = amdgpu_bo_create(adev, size, align, true, domain,
|
|
|
|
|
|
+ r = amdgpu_bo_create(adev, size, align, domain,
|
|
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
|
|
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
|
|
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
|
|
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
|
|
- NULL, NULL, bo_ptr);
|
|
|
|
|
|
+ ttm_bo_type_kernel, NULL, bo_ptr);
|
|
if (r) {
|
|
if (r) {
|
|
dev_err(adev->dev, "(%d) failed to allocate kernel bo\n",
|
|
dev_err(adev->dev, "(%d) failed to allocate kernel bo\n",
|
|
r);
|
|
r);
|
|
@@ -335,21 +335,19 @@ fail:
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-static int amdgpu_bo_do_create(struct amdgpu_device *adev,
|
|
|
|
- unsigned long size, int byte_align,
|
|
|
|
- bool kernel, u32 domain, u64 flags,
|
|
|
|
- struct sg_table *sg,
|
|
|
|
|
|
+static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size,
|
|
|
|
+ int byte_align, u32 domain,
|
|
|
|
+ u64 flags, enum ttm_bo_type type,
|
|
struct reservation_object *resv,
|
|
struct reservation_object *resv,
|
|
struct amdgpu_bo **bo_ptr)
|
|
struct amdgpu_bo **bo_ptr)
|
|
{
|
|
{
|
|
struct ttm_operation_ctx ctx = {
|
|
struct ttm_operation_ctx ctx = {
|
|
- .interruptible = !kernel,
|
|
|
|
|
|
+ .interruptible = (type != ttm_bo_type_kernel),
|
|
.no_wait_gpu = false,
|
|
.no_wait_gpu = false,
|
|
.resv = resv,
|
|
.resv = resv,
|
|
.flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
|
|
.flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
|
|
};
|
|
};
|
|
struct amdgpu_bo *bo;
|
|
struct amdgpu_bo *bo;
|
|
- enum ttm_bo_type type;
|
|
|
|
unsigned long page_align;
|
|
unsigned long page_align;
|
|
size_t acc_size;
|
|
size_t acc_size;
|
|
int r;
|
|
int r;
|
|
@@ -360,13 +358,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
|
|
if (!amdgpu_bo_validate_size(adev, size, domain))
|
|
if (!amdgpu_bo_validate_size(adev, size, domain))
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
- if (kernel) {
|
|
|
|
- type = ttm_bo_type_kernel;
|
|
|
|
- } else if (sg) {
|
|
|
|
- type = ttm_bo_type_sg;
|
|
|
|
- } else {
|
|
|
|
- type = ttm_bo_type_device;
|
|
|
|
- }
|
|
|
|
*bo_ptr = NULL;
|
|
*bo_ptr = NULL;
|
|
|
|
|
|
acc_size = ttm_bo_dma_acc_size(&adev->mman.bdev, size,
|
|
acc_size = ttm_bo_dma_acc_size(&adev->mman.bdev, size,
|
|
@@ -385,7 +376,8 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
|
|
AMDGPU_GEM_DOMAIN_GWS |
|
|
AMDGPU_GEM_DOMAIN_GWS |
|
|
AMDGPU_GEM_DOMAIN_OA);
|
|
AMDGPU_GEM_DOMAIN_OA);
|
|
bo->allowed_domains = bo->preferred_domains;
|
|
bo->allowed_domains = bo->preferred_domains;
|
|
- if (!kernel && bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
|
|
|
|
|
|
+ if (type != ttm_bo_type_kernel &&
|
|
|
|
+ bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
|
|
bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
|
|
bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
|
|
|
|
|
|
bo->flags = flags;
|
|
bo->flags = flags;
|
|
@@ -423,7 +415,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
|
|
|
|
|
|
r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
|
|
r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
|
|
&bo->placement, page_align, &ctx, acc_size,
|
|
&bo->placement, page_align, &ctx, acc_size,
|
|
- sg, resv, &amdgpu_ttm_bo_destroy);
|
|
|
|
|
|
+ NULL, resv, &amdgpu_ttm_bo_destroy);
|
|
if (unlikely(r != 0))
|
|
if (unlikely(r != 0))
|
|
return r;
|
|
return r;
|
|
|
|
|
|
@@ -435,7 +427,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
|
|
else
|
|
else
|
|
amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
|
|
amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
|
|
|
|
|
|
- if (kernel)
|
|
|
|
|
|
+ if (type == ttm_bo_type_kernel)
|
|
bo->tbo.priority = 1;
|
|
bo->tbo.priority = 1;
|
|
|
|
|
|
if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
|
|
if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
|
|
@@ -479,12 +471,11 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
|
|
if (bo->shadow)
|
|
if (bo->shadow)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
- r = amdgpu_bo_do_create(adev, size, byte_align, true,
|
|
|
|
- AMDGPU_GEM_DOMAIN_GTT,
|
|
|
|
|
|
+ r = amdgpu_bo_do_create(adev, size, byte_align, AMDGPU_GEM_DOMAIN_GTT,
|
|
AMDGPU_GEM_CREATE_CPU_GTT_USWC |
|
|
AMDGPU_GEM_CREATE_CPU_GTT_USWC |
|
|
AMDGPU_GEM_CREATE_SHADOW,
|
|
AMDGPU_GEM_CREATE_SHADOW,
|
|
- NULL, bo->tbo.resv,
|
|
|
|
- &bo->shadow);
|
|
|
|
|
|
+ ttm_bo_type_kernel,
|
|
|
|
+ bo->tbo.resv, &bo->shadow);
|
|
if (!r) {
|
|
if (!r) {
|
|
bo->shadow->parent = amdgpu_bo_ref(bo);
|
|
bo->shadow->parent = amdgpu_bo_ref(bo);
|
|
mutex_lock(&adev->shadow_list_lock);
|
|
mutex_lock(&adev->shadow_list_lock);
|
|
@@ -495,18 +486,17 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
|
|
return r;
|
|
return r;
|
|
}
|
|
}
|
|
|
|
|
|
-int amdgpu_bo_create(struct amdgpu_device *adev,
|
|
|
|
- unsigned long size, int byte_align,
|
|
|
|
- bool kernel, u32 domain, u64 flags,
|
|
|
|
- struct sg_table *sg,
|
|
|
|
|
|
+int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size,
|
|
|
|
+ int byte_align, u32 domain,
|
|
|
|
+ u64 flags, enum ttm_bo_type type,
|
|
struct reservation_object *resv,
|
|
struct reservation_object *resv,
|
|
struct amdgpu_bo **bo_ptr)
|
|
struct amdgpu_bo **bo_ptr)
|
|
{
|
|
{
|
|
uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW;
|
|
uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW;
|
|
int r;
|
|
int r;
|
|
|
|
|
|
- r = amdgpu_bo_do_create(adev, size, byte_align, kernel, domain,
|
|
|
|
- parent_flags, sg, resv, bo_ptr);
|
|
|
|
|
|
+ r = amdgpu_bo_do_create(adev, size, byte_align, domain,
|
|
|
|
+ parent_flags, type, resv, bo_ptr);
|
|
if (r)
|
|
if (r)
|
|
return r;
|
|
return r;
|
|
|
|
|