gpu: nvgpu: fix remap page size flag handling

When destroying a virtual memory pool the associated page size must
be set in the nvgpu_vm_remap_op structure.

This patch adds a new nvgpu_vm_remap_page_size_flag() routine that
converts the page size derived from the vm/vm_area structs to the
corresponding NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE bit.

Bug 3669908

Change-Id: Idca77cc36d353777b399c872f68a1f5231ddb8dd
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2734822
Tested-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Scott Long
2022-06-16 12:46:42 -07:00
committed by mobile promotions
parent e212271d56
commit 868b723b16
2 changed files with 23 additions and 4 deletions

View File

@@ -778,6 +778,8 @@ void nvgpu_vm_remap_vpool_destroy(struct vm_gk20a *vm,
u32 num_ops = 1; u32 num_ops = 1;
int err; int err;
op.flags = nvgpu_vm_remap_page_size_flag(
vm->gmmu_page_sizes[vm_area->pgsz_idx]);
op.virt_offset_in_pages = vpool->base_offset_in_pages; op.virt_offset_in_pages = vpool->base_offset_in_pages;
op.num_pages = vpool->num_pages; op.num_pages = vpool->num_pages;

View File

@@ -155,18 +155,35 @@ static inline u64 nvgpu_vm_remap_page_size(struct nvgpu_vm_remap_op *op)
{ {
u64 pagesize = 0; u64 pagesize = 0;
/* validate_map/unmap_op ensures a single pagesize flag */ /* validate map/unmap_op ensures a single pagesize flag */
if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_4K) if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_4K) {
pagesize = SZ_4K; pagesize = SZ_4K;
if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_64K) } else if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_64K) {
pagesize = SZ_64K; pagesize = SZ_64K;
if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_128K) } else if (op->flags & NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_128K) {
pagesize = SZ_128K; pagesize = SZ_128K;
}
nvgpu_assert(pagesize); nvgpu_assert(pagesize);
return pagesize; return pagesize;
} }
static inline u32 nvgpu_vm_remap_page_size_flag(u64 pagesize)
{
u32 flag = 0;
if (pagesize == SZ_4K) {
flag = NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_4K;
} else if (pagesize == SZ_64K) {
flag = NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_64K;
} else if (pagesize == SZ_128K) {
flag = NVGPU_VM_REMAP_OP_FLAGS_PAGESIZE_128K;
}
nvgpu_assert(flag);
return flag;
}
/** /**
* This structure describes a virtual memory pool. * This structure describes a virtual memory pool.
* There is one virtual memory pool for each sparse VM area allocation. * There is one virtual memory pool for each sparse VM area allocation.