From 14571dc67f8e27818a84a1cbfb6b0fccac677606 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 8 May 2017 22:54:37 +0100 Subject: gpu: nvgpu: Fix mem-API usage bug in ACR The __nvgpu_mem_create_from_pages() API takes a number of pages from which to create a buffer. In the ACR code only 1 page was passed. If the WPR region (what the ACR code creates an nvgpu_mem from) is larger than 1 page then the current code will truncate that region down to only a single page. Change-Id: I11833619c4f35a076f72071cc5b98ae2d192c5d0 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1477672 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gm20b/acr_gm20b.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/gm20b/acr_gm20b.c b/drivers/gpu/nvgpu/gm20b/acr_gm20b.c index 7c56c4cc..98d1a34d 100644 --- a/drivers/gpu/nvgpu/gm20b/acr_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/acr_gm20b.c @@ -383,12 +383,13 @@ int prepare_ucode_blob(struct gk20a *g) int err; struct ls_flcn_mgr lsfm_l, *plsfm; struct pmu_gk20a *pmu = &g->pmu; - phys_addr_t wpr_addr; + phys_addr_t wpr_addr, wpr_page; u32 wprsize; + int i; struct mm_gk20a *mm = &g->mm; struct vm_gk20a *vm = &mm->pmu.vm; struct wpr_carveout_info wpr_inf; - struct page *page; + struct page **pages; if (g->acr.ucode_blob.cpu_va) { /*Recovery case, we do not need to form @@ -412,8 +413,17 @@ int prepare_ucode_blob(struct gk20a *g) gm20b_dbg_pmu("wpr carveout base:%llx\n", wpr_inf.wpr_base); gm20b_dbg_pmu("wpr carveout size :%x\n", wprsize); - page = phys_to_page(wpr_addr); - __nvgpu_mem_create_from_pages(g, &g->pmu.wpr_buf, &page, 1); + pages = nvgpu_kmalloc(g, sizeof(struct page *) * (wprsize / PAGE_SIZE)); + if (!pages) + return -ENOMEM; + + wpr_page = wpr_addr; + for (i = 0; wpr_page < (wpr_addr + wprsize); i++, wpr_page += PAGE_SIZE) + pages[i] = phys_to_page(wpr_page); + __nvgpu_mem_create_from_pages(g, &g->pmu.wpr_buf, pages, + wprsize / PAGE_SIZE); + nvgpu_kfree(g, pages); + g->pmu.wpr_buf.gpu_va = nvgpu_gmmu_map(vm, &g->pmu.wpr_buf, wprsize, 0, gk20a_mem_flag_none, false, APERTURE_SYSMEM); -- cgit v1.2.2