drm/amdgpu: once more fix amdgpu_bo_create_kernel_at
authorChristian König <christian.koenig@amd.com>
Tue, 24 Sep 2019 11:29:27 +0000 (13:29 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 3 Oct 2019 14:11:03 +0000 (09:11 -0500)
When CPU access is needed we should tell that to
amdgpu_bo_create_reserved() or otherwise the access is denied later on.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Emily Deng <Emily.Deng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 12d2adcdf14e340584656a98c70ea2e7593a7f4b..f10b6175e20cfe79d5d32ab1bf2b87cd69c42a8b 100644 (file)
@@ -369,7 +369,7 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,
        size = ALIGN(size, PAGE_SIZE);
 
        r = amdgpu_bo_create_reserved(adev, size, PAGE_SIZE, domain, bo_ptr,
-                                     NULL, NULL);
+                                     NULL, cpu_addr);
        if (r)
                return r;
 
@@ -377,12 +377,15 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,
         * 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;
        }
-
-       ttm_bo_mem_put(&(*bo_ptr)->tbo, &(*bo_ptr)->tbo.mem);
        r = ttm_bo_mem_space(&(*bo_ptr)->tbo, &(*bo_ptr)->placement,
                             &(*bo_ptr)->tbo.mem, &ctx);
        if (r)