]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/ttm: replace context flags with bools v2
authorChristian König <christian.koenig@amd.com>
Mon, 2 Nov 2020 12:16:13 +0000 (13:16 +0100)
committerChristian König <christian.koenig@amd.com>
Wed, 4 Nov 2020 10:23:25 +0000 (11:23 +0100)
The ttm_operation_ctx structure has a mixture of flags and bools. Drop the
flags and replace them with bools as well.

v2: fix typos, improve comments

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/398686/
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
drivers/gpu/drm/ttm/ttm_memory.c
drivers/gpu/drm/ttm/ttm_resource.c
include/drm/ttm/ttm_bo_api.h

index d50b63a93d37f7c403cb571795f102cfb94d4389..8466558d0d930f7e086533567121ba7e32e3c64e 100644 (file)
@@ -404,8 +404,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
        struct ttm_operation_ctx ctx = {
                .interruptible = true,
                .no_wait_gpu = false,
-               .resv = bo->tbo.base.resv,
-               .flags = 0
+               .resv = bo->tbo.base.resv
        };
        uint32_t domain;
        int r;
index 4e9dfbea31c605a8a6715c26e22860e4b41dd483..e1f64ef8c765807dbd992edb22fe6475e10ba080 100644 (file)
@@ -518,9 +518,8 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                .no_wait_gpu = bp->no_wait_gpu,
                /* We opt to avoid OOM on system pages allocations */
                .gfp_retry_mayfail = true,
-               .resv = bp->resv,
-               .flags = bp->type != ttm_bo_type_kernel ?
-                       TTM_OPT_FLAG_ALLOW_RES_EVICT : 0
+               .allow_res_evict = bp->type != ttm_bo_type_kernel,
+               .resv = bp->resv
        };
        struct amdgpu_bo *bo;
        unsigned long page_align, size = bp->size;
index c63b7ea1cd5d0db6f95486d236272660d16d3cca..e2a124b3affb9f62470e550fecc92b90b213ad5a 100644 (file)
@@ -637,7 +637,7 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
 
        if (bo->base.resv == ctx->resv) {
                dma_resv_assert_held(bo->base.resv);
-               if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT)
+               if (ctx->allow_res_evict)
                        ret = true;
                *locked = false;
                if (busy)
index eeaca5d1efe3943bc37cee351ff3349eae95d9c8..2944fa0af493550e9eac609a7b17ba82a4ff6840 100644 (file)
@@ -315,8 +315,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
                struct ttm_operation_ctx ctx = {
                        .interruptible = false,
                        .no_wait_gpu = false,
-                       .flags = TTM_OPT_FLAG_FORCE_ALLOC
-
+                       .force_alloc = true
                };
 
                ttm = bo->ttm;
index f9a90bfaa3c1a8037590050f40d7c208a2f91716..5ed1fc8f2ace3fdc7097a718ed1a0d23dea5848d 100644 (file)
@@ -542,7 +542,8 @@ ttm_check_under_lowerlimit(struct ttm_mem_global *glob,
 {
        int64_t available;
 
-       if (ctx->flags & TTM_OPT_FLAG_FORCE_ALLOC)
+       /* We allow over commit during suspend */
+       if (ctx->force_alloc)
                return false;
 
        available = get_nr_swap_pages() + si_mem_available();
index 4ebc043e28671b559fdeb007d766d58ece980b2e..b60699bf4816b7a4ded150b45f126e177ed6cd03 100644 (file)
@@ -89,7 +89,7 @@ int ttm_resource_manager_evict_all(struct ttm_bo_device *bdev,
        struct ttm_operation_ctx ctx = {
                .interruptible = false,
                .no_wait_gpu = false,
-               .flags = TTM_OPT_FLAG_FORCE_ALLOC
+               .force_alloc = true
        };
        struct ttm_bo_global *glob = &ttm_bo_glob;
        struct dma_fence *fence;
index 4637357ba856cb8b93fbf51ec26cc7b66d8222da..5ddad88ae6ed9f5fd06818717581c54fbb6bda7a 100644 (file)
@@ -196,8 +196,11 @@ struct ttm_bo_kmap_obj {
  * @interruptible: Sleep interruptible if sleeping.
  * @no_wait_gpu: Return immediately if the GPU is busy.
  * @gfp_retry_mayfail: Set the __GFP_RETRY_MAYFAIL when allocation pages.
+ * @allow_res_evict: Allow eviction of reserved BOs. Can be used when multiple
+ * BOs share the same reservation object.
+ * @force_alloc: Don't check the memory account during suspend or CPU page
+ * faults. Should only be used by TTM internally.
  * @resv: Reservation object to allow reserved evictions with.
- * @flags: Including the following flags
  *
  * Context for TTM operations like changing buffer placement or general memory
  * allocation.
@@ -206,16 +209,12 @@ struct ttm_operation_ctx {
        bool interruptible;
        bool no_wait_gpu;
        bool gfp_retry_mayfail;
+       bool allow_res_evict;
+       bool force_alloc;
        struct dma_resv *resv;
        uint64_t bytes_moved;
-       uint32_t flags;
 };
 
-/* Allow eviction of reserved BOs */
-#define TTM_OPT_FLAG_ALLOW_RES_EVICT           0x1
-/* when serving page fault or suspend, allow alloc anyway */
-#define TTM_OPT_FLAG_FORCE_ALLOC               0x2
-
 /**
  * ttm_bo_get - reference a struct ttm_buffer_object
  *