Skip to content

Commit be580ab

Browse files
fxkamdgregkh
authored andcommitted
drm/ttm: fix offset in VMAs with a pg_offs in ttm_bo_vm_access
[ Upstream commit c000121 ] VMAs with a pg_offs that's offset from the start of the vma_node need to adjust the offset within the BO accordingly. This matches the offset calculation in ttm_bo_vm_fault_reserved. Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Tested-by: Laurent Morichetti <laurent.morichetti@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/381169/ Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d5e8507 commit be580ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpu/drm/ttm/ttm_bo_vm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,10 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
505505
int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
506506
void *buf, int len, int write)
507507
{
508-
unsigned long offset = (addr) - vma->vm_start;
509508
struct ttm_buffer_object *bo = vma->vm_private_data;
509+
unsigned long offset = (addr) - vma->vm_start +
510+
((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
511+
<< PAGE_SHIFT);
510512
int ret;
511513

512514
if (len < 1 || (offset + len) >> PAGE_SHIFT > bo->num_pages)

0 commit comments

Comments
 (0)