]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
Merge branch 'asoc-5.5' into asoc-linus
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_object.c
index 7289e1b4fb600e6728765167327c13e193a1b18a..e3f16b49e970826023c52e8fa474d27414d0c5e7 100644 (file)
@@ -342,6 +342,70 @@ int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
        return 0;
 }
 
+/**
+ * amdgpu_bo_create_kernel_at - create BO for kernel use at specific location
+ *
+ * @adev: amdgpu device object
+ * @offset: offset of the BO
+ * @size: size of the BO
+ * @domain: where to place it
+ * @bo_ptr:  used to initialize BOs in structures
+ * @cpu_addr: optional CPU address mapping
+ *
+ * Creates a kernel BO at a specific offset in the address space of the domain.
+ *
+ * Returns:
+ * 0 on success, negative error code otherwise.
+ */
+int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,
+                              uint64_t offset, uint64_t size, uint32_t domain,
+                              struct amdgpu_bo **bo_ptr, void **cpu_addr)
+{
+       struct ttm_operation_ctx ctx = { false, false };
+       unsigned int i;
+       int r;
+
+       offset &= PAGE_MASK;
+       size = ALIGN(size, PAGE_SIZE);
+
+       r = amdgpu_bo_create_reserved(adev, size, PAGE_SIZE, domain, bo_ptr,
+                                     NULL, cpu_addr);
+       if (r)
+               return r;
+
+       /*
+        * Remove the original mem node and create a new one at the request
+        * position.
+        */
+       if (cpu_addr)
+               amdgpu_bo_kunmap(*bo_ptr);
+
+       ttm_bo_mem_put(&(*bo_ptr)->tbo, &(*bo_ptr)->tbo.mem);
+
+       for (i = 0; i < (*bo_ptr)->placement.num_placement; ++i) {
+               (*bo_ptr)->placements[i].fpfn = offset >> PAGE_SHIFT;
+               (*bo_ptr)->placements[i].lpfn = (offset + size) >> PAGE_SHIFT;
+       }
+       r = ttm_bo_mem_space(&(*bo_ptr)->tbo, &(*bo_ptr)->placement,
+                            &(*bo_ptr)->tbo.mem, &ctx);
+       if (r)
+               goto error;
+
+       if (cpu_addr) {
+               r = amdgpu_bo_kmap(*bo_ptr, cpu_addr);
+               if (r)
+                       goto error;
+       }
+
+       amdgpu_bo_unreserve(*bo_ptr);
+       return 0;
+
+error:
+       amdgpu_bo_unreserve(*bo_ptr);
+       amdgpu_bo_unref(bo_ptr);
+       return r;
+}
+
 /**
  * amdgpu_bo_free_kernel - free BO for kernel use
  *
@@ -451,7 +515,7 @@ 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 = false,
+               .no_wait_gpu = bp->no_wait_gpu,
                .resv = bp->resv,
                .flags = bp->type != ttm_bo_type_kernel ?
                        TTM_OPT_FLAG_ALLOW_RES_EVICT : 0
@@ -1059,7 +1123,10 @@ void amdgpu_bo_fini(struct amdgpu_device *adev)
 int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
                             struct vm_area_struct *vma)
 {
-       return ttm_fbdev_mmap(vma, &bo->tbo);
+       if (vma->vm_pgoff != 0)
+               return -EACCES;
+
+       return ttm_bo_mmap_obj(vma, &bo->tbo);
 }
 
 /**
This page took 0.037664 seconds and 4 git commands to generate.