Reserve the highest priority for the kernel, and choose a balanced value
as userspace default. Userspace is intended to be able to modify these
later to mark buffers as important/unimportant.

Signed-off-by: Friedrich Vock <friedrich.v...@gmx.de>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index aea3770d3ea2e..5ca13e2e50f50 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -114,6 +114,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
        bp.type = type;
        bp.resv = resv;
        bp.preferred_domain = initial_domain;
+       bp.priority = 4;
        bp.flags = flags;
        bp.domain = initial_domain;
        bp.bo_ptr_size = sizeof(struct amdgpu_bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 9978b85ed6f40..0e9ea11a873ef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -621,9 +621,9 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
        else
                amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
        if (bp->type == ttm_bo_type_kernel)
-               bo->tbo.priority = 2;
+               bo->tbo.priority = AMDGPU_BO_PRIORITY_KERNEL;
        else if (!(bp->flags & AMDGPU_GEM_CREATE_DISCARDABLE))
-               bo->tbo.priority = 1;
+               bo->tbo.priority = bp->priority;

        if (!bp->destroy)
                bp->destroy = &amdgpu_bo_destroy;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 0f277bc6a2e32..36513da0ec767 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -42,6 +42,9 @@
 /* BO flag to indicate a KFD userptr BO */
 #define AMDGPU_AMDKFD_CREATE_USERPTR_BO        (1ULL << 63)

+#define AMDGPU_BO_PRIORITY_KERNEL    (TTM_MAX_BO_PRIORITY - 1)
+#define AMDGPU_BO_PRIORITY_MAX_USER  (TTM_MAX_BO_PRIORITY - 2)
+
 #define to_amdgpu_bo_user(abo) container_of((abo), struct amdgpu_bo_user, bo)
 #define to_amdgpu_bo_vm(abo) container_of((abo), struct amdgpu_bo_vm, bo)

@@ -52,6 +55,7 @@ struct amdgpu_bo_param {
        u32                             domain;
        u32                             preferred_domain;
        u64                             flags;
+       unsigned int                    priority;
        enum ttm_bo_type                type;
        bool                            no_wait_gpu;
        struct dma_resv                 *resv;
--
2.44.0

Reply via email to