diff options
author | Christian König <christian.koenig@amd.com> | 2015-06-10 15:20:11 (GMT) |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-06-10 18:16:48 (GMT) |
commit | 4802ce11778664a69b308c5aa9b95350b76793be (patch) | |
tree | 1ebf845ad707425b07a72677d0920549fd4490c3 /drivers/gpu/drm/amd | |
parent | b7a0776949a8f9db835ab652b6fa96b6e7d6972d (diff) | |
download | linux-4802ce11778664a69b308c5aa9b95350b76793be.tar.xz |
drm/amdgpu: fix UVD/VCE VM emulation
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index f6b224a..f09b2cb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -564,21 +564,33 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, return r; if (ring->funcs->parse_cs) { + struct amdgpu_bo_va_mapping *m; struct amdgpu_bo *aobj = NULL; - void *kptr; + uint64_t offset; + uint8_t *kptr; - amdgpu_cs_find_mapping(parser, chunk_ib->va_start, &aobj); + m = amdgpu_cs_find_mapping(parser, chunk_ib->va_start, + &aobj); if (!aobj) { DRM_ERROR("IB va_start is invalid\n"); return -EINVAL; } + if ((chunk_ib->va_start + chunk_ib->ib_bytes) > + (m->it.last + 1) * AMDGPU_GPU_PAGE_SIZE) { + DRM_ERROR("IB va_start+ib_bytes is invalid\n"); + return -EINVAL; + } + /* the IB should be reserved at this point */ - r = amdgpu_bo_kmap(aobj, &kptr); + r = amdgpu_bo_kmap(aobj, (void **)&kptr); if (r) { return r; } + offset = ((uint64_t)m->it.start) * AMDGPU_GPU_PAGE_SIZE; + kptr += chunk_ib->va_start - offset; + r = amdgpu_ib_get(ring, NULL, chunk_ib->ib_bytes, ib); if (r) { DRM_ERROR("Failed to get ib !\n"); |