summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2015-03-31 16:15:58 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-04-04 22:17:38 -0400
commit10e97dccc54d4bd271c2de82dfce26b2c161bf94 (patch)
tree5027e800b31cb8ac9f3e2e9f91bf561b6fafbab1 /drivers/gpu/nvgpu/gk20a/mm_gk20a.c
parentc2a7d0304c317195ac1cdbb7e35f46da26120c58 (diff)
gpu: nvgpu: Check alignment of fixed allocs
When mapping buffer on a fixed address, ensure that the alignment of buffer and the address are compabile. When freeing, retrieve page size from the VA instead of choosing it again. Bug 1605769 Change-Id: I4f73453996cd53a912b6a414caa41563cde28da7 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/725764
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index d8dacad8..43758712 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -1312,16 +1312,25 @@ u64 gk20a_vm_map(struct vm_gk20a *vm,
1312 bfr.pgsz_idx = -1; 1312 bfr.pgsz_idx = -1;
1313 mapping_size = mapping_size ? mapping_size : bfr.size; 1313 mapping_size = mapping_size ? mapping_size : bfr.size;
1314 1314
1315 /* If FIX_OFFSET is set, pgsz is determined. Otherwise, select 1315 if (vm->big_pages)
1316 * page size according to memory alignment */ 1316 gmmu_select_page_size(vm, &bfr);
1317 else
1318 bfr.pgsz_idx = gmmu_page_size_small;
1319
1320 /* If FIX_OFFSET is set, pgsz is determined at address allocation
1321 * time. The alignment at address alloc time must be the same as
1322 * the alignment determined by gmmu_select_page_size().
1323 */
1317 if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { 1324 if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) {
1318 bfr.pgsz_idx = NV_GMMU_VA_IS_UPPER(offset_align) ? 1325 int pgsz_idx = NV_GMMU_VA_IS_UPPER(offset_align) ?
1319 gmmu_page_size_big : gmmu_page_size_small; 1326 gmmu_page_size_big : gmmu_page_size_small;
1320 } else { 1327 if (pgsz_idx > bfr.pgsz_idx) {
1321 if (vm->big_pages) 1328 gk20a_err(d, "%llx buffer pgsz %d, VA pgsz %d",
1322 gmmu_select_page_size(vm, &bfr); 1329 offset_align, bfr.pgsz_idx, pgsz_idx);
1323 else 1330 err = -EINVAL;
1324 bfr.pgsz_idx = gmmu_page_size_small; 1331 goto clean_up;
1332 }
1333 bfr.pgsz_idx = min(bfr.pgsz_idx, pgsz_idx);
1325 } 1334 }
1326 1335
1327 /* validate/adjust bfr attributes */ 1336 /* validate/adjust bfr attributes */
@@ -2495,17 +2504,8 @@ int gk20a_vm_free_space(struct gk20a_as_share *as_share,
2495 args->pages, args->offset); 2504 args->pages, args->offset);
2496 2505
2497 /* determine pagesz idx */ 2506 /* determine pagesz idx */
2498 for (pgsz_idx = gmmu_page_size_small; 2507 pgsz_idx = NV_GMMU_VA_IS_UPPER(args->offset) ?
2499 pgsz_idx < gmmu_nr_page_sizes; 2508 gmmu_page_size_big : gmmu_page_size_small;
2500 pgsz_idx++) {
2501 if (vm->gmmu_page_sizes[pgsz_idx] == args->page_size)
2502 break;
2503 }
2504
2505 if (pgsz_idx >= gmmu_nr_page_sizes) {
2506 err = -EINVAL;
2507 goto clean_up;
2508 }
2509 2509
2510 start_page_nr = (u32)(args->offset >> 2510 start_page_nr = (u32)(args->offset >>
2511 ilog2(vm->gmmu_page_sizes[pgsz_idx])); 2511 ilog2(vm->gmmu_page_sizes[pgsz_idx]));