]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_object.c
index 15027f751e079d1f2a2d2123506bd7bf5286a462..5c4c3e0d527be64386dcab0951727642f64d73db 100644 (file)
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 
+static bool amdgpu_need_backup(struct amdgpu_device *adev)
+{
+       if (adev->flags & AMD_IS_APU)
+               return false;
+
+       if (amdgpu_gpu_recovery == 0 ||
+           (amdgpu_gpu_recovery == -1  && !amdgpu_sriov_vf(adev)))
+               return false;
+
+       return true;
+}
+
 static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 {
        struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
@@ -327,11 +339,15 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
                               uint64_t init_value,
                               struct amdgpu_bo **bo_ptr)
 {
-       struct ttm_operation_ctx ctx = { !kernel, false };
+       struct ttm_operation_ctx ctx = {
+               .interruptible = !kernel,
+               .no_wait_gpu = false,
+               .allow_reserved_eviction = true,
+               .resv = resv
+       };
        struct amdgpu_bo *bo;
        enum ttm_bo_type type;
        unsigned long page_align;
-       u64 initial_bytes_moved, bytes_moved;
        size_t acc_size;
        int r;
 
@@ -406,22 +422,19 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
        bo->tbo.bdev = &adev->mman.bdev;
        amdgpu_ttm_placement_from_domain(bo, domain);
 
-       initial_bytes_moved = atomic64_read(&adev->num_bytes_moved);
-       /* Kernel allocation are uninterruptible */
        r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
                                 &bo->placement, page_align, &ctx, NULL,
                                 acc_size, sg, resv, &amdgpu_ttm_bo_destroy);
        if (unlikely(r != 0))
                return r;
 
-       bytes_moved = atomic64_read(&adev->num_bytes_moved) -
-                     initial_bytes_moved;
        if (adev->mc.visible_vram_size < adev->mc.real_vram_size &&
            bo->tbo.mem.mem_type == TTM_PL_VRAM &&
            bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT)
-               amdgpu_cs_report_moved_bytes(adev, bytes_moved, bytes_moved);
+               amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved,
+                                            ctx.bytes_moved);
        else
-               amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0);
+               amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
 
        if (kernel)
                bo->tbo.priority = 1;
This page took 0.040398 seconds and 4 git commands to generate.