diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index 6473aed94..ea5b28374 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c @@ -77,9 +77,13 @@ int nvgpu_dma_alloc_flags(struct gk20a *g, unsigned long flags, size_t size, * the lack of it for vidmem - the user should not care when * using nvgpu_gmmu_alloc_map and it's vidmem, or if there's a * difference, the user should use the flag explicitly anyway. + * + * Incoming flags are ignored here, since bits other than the + * no-kernel-mapping flag are ignored by the vidmem mapping + * functions anyway. */ int err = nvgpu_dma_alloc_flags_vid(g, - flags | NVGPU_DMA_NO_KERNEL_MAPPING, + NVGPU_DMA_NO_KERNEL_MAPPING, size, mem); if (!err) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu.c b/drivers/gpu/nvgpu/common/mm/gmmu.c index 2b579bdde..1be87c85c 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu.c @@ -637,6 +637,8 @@ static int __nvgpu_gmmu_update_page_table(struct vm_gk20a *vm, struct nvgpu_gmmu_attrs *attrs) { struct gk20a *g = gk20a_from_vm(vm); + struct nvgpu_page_alloc *alloc; + u64 phys_addr = 0; u32 page_size; int err; @@ -662,6 +664,15 @@ static int __nvgpu_gmmu_update_page_table(struct vm_gk20a *vm, return err; } + if (sgt) { + if (attrs->aperture == APERTURE_VIDMEM) { + alloc = get_vidmem_page_alloc(sgt->sgl); + + phys_addr = alloc->base; + } else + phys_addr = g->ops.mm.get_iova_addr(g, sgt->sgl, 0); + } + __gmmu_dbg(g, attrs, "vm=%s " "%-5s GPU virt %#-12llx +%#-9llx phys %#-12llx " @@ -671,7 +682,7 @@ static int __nvgpu_gmmu_update_page_table(struct vm_gk20a *vm, sgt ? "MAP" : "UNMAP", virt_addr, length, - sgt ? g->ops.mm.get_iova_addr(g, sgt->sgl, 0) : 0ULL, + phys_addr, space_to_skip, page_size >> 10, nvgpu_gmmu_perm_str(attrs->rw_flag),