]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
Merge tag 'time-namespace-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_object.c
index 1aa516429c80a7d7598507a6966dd459c8e70078..25ec4d57333f6a9786e98551044e2476cb8fc39f 100644 (file)
@@ -516,9 +516,10 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
        struct ttm_operation_ctx ctx = {
                .interruptible = (bp->type != ttm_bo_type_kernel),
                .no_wait_gpu = bp->no_wait_gpu,
-               .resv = bp->resv,
-               .flags = bp->type != ttm_bo_type_kernel ?
-                       TTM_OPT_FLAG_ALLOW_RES_EVICT : 0
+               /* We opt to avoid OOM on system pages allocations */
+               .gfp_retry_mayfail = true,
+               .allow_res_evict = bp->type != ttm_bo_type_kernel,
+               .resv = bp->resv
        };
        struct amdgpu_bo *bo;
        unsigned long page_align, size = bp->size;
@@ -1044,6 +1045,7 @@ static const char *amdgpu_vram_names[] = {
        "DDR3",
        "DDR4",
        "GDDR6",
+       "DDR5"
 };
 
 /**
@@ -1072,23 +1074,6 @@ int amdgpu_bo_init(struct amdgpu_device *adev)
        return amdgpu_ttm_init(adev);
 }
 
-/**
- * amdgpu_bo_late_init - late init
- * @adev: amdgpu device object
- *
- * Calls amdgpu_ttm_late_init() to free resources used earlier during
- * initialization.
- *
- * Returns:
- * 0 for success or a negative error code on failure.
- */
-int amdgpu_bo_late_init(struct amdgpu_device *adev)
-{
-       amdgpu_ttm_late_init(adev);
-
-       return 0;
-}
-
 /**
  * amdgpu_bo_fini - tear down memory manager
  * @adev: amdgpu device object
@@ -1506,3 +1491,77 @@ uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
        }
        return domain;
 }
+
+#if defined(CONFIG_DEBUG_FS)
+#define amdgpu_bo_print_flag(m, bo, flag)                      \
+       do {                                                    \
+               if (bo->flags & (AMDGPU_GEM_CREATE_ ## flag)) { \
+                       seq_printf((m), " " #flag);             \
+               }                                               \
+       } while (0)
+
+/**
+ * amdgpu_bo_print_info - print BO info in debugfs file
+ *
+ * @id: Index or Id of the BO
+ * @bo: Requested BO for printing info
+ * @m: debugfs file
+ *
+ * Print BO information in debugfs file
+ *
+ * Returns:
+ * Size of the BO in bytes.
+ */
+u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m)
+{
+       struct dma_buf_attachment *attachment;
+       struct dma_buf *dma_buf;
+       unsigned int domain;
+       const char *placement;
+       unsigned int pin_count;
+       u64 size;
+
+       domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
+       switch (domain) {
+       case AMDGPU_GEM_DOMAIN_VRAM:
+               placement = "VRAM";
+               break;
+       case AMDGPU_GEM_DOMAIN_GTT:
+               placement = " GTT";
+               break;
+       case AMDGPU_GEM_DOMAIN_CPU:
+       default:
+               placement = " CPU";
+               break;
+       }
+
+       size = amdgpu_bo_size(bo);
+       seq_printf(m, "\t\t0x%08x: %12lld byte %s",
+                       id, size, placement);
+
+       pin_count = READ_ONCE(bo->tbo.pin_count);
+       if (pin_count)
+               seq_printf(m, " pin count %d", pin_count);
+
+       dma_buf = READ_ONCE(bo->tbo.base.dma_buf);
+       attachment = READ_ONCE(bo->tbo.base.import_attach);
+
+       if (attachment)
+               seq_printf(m, " imported from %p", dma_buf);
+       else if (dma_buf)
+               seq_printf(m, " exported as %p", dma_buf);
+
+       amdgpu_bo_print_flag(m, bo, CPU_ACCESS_REQUIRED);
+       amdgpu_bo_print_flag(m, bo, NO_CPU_ACCESS);
+       amdgpu_bo_print_flag(m, bo, CPU_GTT_USWC);
+       amdgpu_bo_print_flag(m, bo, VRAM_CLEARED);
+       amdgpu_bo_print_flag(m, bo, SHADOW);
+       amdgpu_bo_print_flag(m, bo, VRAM_CONTIGUOUS);
+       amdgpu_bo_print_flag(m, bo, VM_ALWAYS_VALID);
+       amdgpu_bo_print_flag(m, bo, EXPLICIT_SYNC);
+
+       seq_puts(m, "\n");
+
+       return size;
+}
+#endif
This page took 0.036514 seconds and 4 git commands to generate.