Commit 030d5b97 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: use amdgpu_device_vram_access in amdgpu_ttm_vram_read

This speeds up the access quite a bit from 2.2 MB/s to
2.9 MB/s on 32bit and 12,8 MB/s on 64bit.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: default avatarJonathan Kim <Jonathan.Kim@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c12b84d6
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
#include "amdgpu_ras.h" #include "amdgpu_ras.h"
#include "bif/bif_4_1_d.h" #include "bif/bif_4_1_d.h"
#define AMDGPU_TTM_VRAM_MAX_DW_READ (size_t)128
static int amdgpu_map_buffer(struct ttm_buffer_object *bo, static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
struct ttm_mem_reg *mem, unsigned num_pages, struct ttm_mem_reg *mem, unsigned num_pages,
uint64_t offset, unsigned window, uint64_t offset, unsigned window,
...@@ -2288,27 +2290,20 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, ...@@ -2288,27 +2290,20 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
if (*pos >= adev->gmc.mc_vram_size) if (*pos >= adev->gmc.mc_vram_size)
return -ENXIO; return -ENXIO;
size = min(size, (size_t)(adev->gmc.mc_vram_size - *pos));
while (size) { while (size) {
unsigned long flags; size_t bytes = min(size, AMDGPU_TTM_VRAM_MAX_DW_READ * 4);
uint32_t value; uint32_t value[AMDGPU_TTM_VRAM_MAX_DW_READ];
if (*pos >= adev->gmc.mc_vram_size)
return result;
spin_lock_irqsave(&adev->mmio_idx_lock, flags); amdgpu_device_vram_access(adev, *pos, value, bytes, false);
WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)*pos) | 0x80000000); r = copy_to_user(buf, value, bytes);
WREG32_NO_KIQ(mmMM_INDEX_HI, *pos >> 31);
value = RREG32_NO_KIQ(mmMM_DATA);
spin_unlock_irqrestore(&adev->mmio_idx_lock, flags);
r = put_user(value, (uint32_t *)buf);
if (r) if (r)
return r; return r;
result += 4; result += bytes;
buf += 4; buf += bytes;
*pos += 4; *pos += bytes;
size -= 4; size -= bytes;
} }
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment