From 542f729aa9ea9c5eb845c35d855e3925f45ab24f Mon Sep 17 00:00:00 2001 From: Arto Merilainen Date: Wed, 9 Apr 2014 21:15:32 +0300 Subject: gpu: nvgpu: Allow mapping backing store Backing store sgt needs to be mapped to gpuva to enable CDE swizzling. This patch adds necessary code to create sgt during initialisation so that the sgt is available when needed. Bug 1409151 Change-Id: I9d4671386fe9204d780c2e286b5f9b2dd87af35a Signed-off-by: Arto Merilainen --- drivers/gpu/nvgpu/gk20a/ltc_common.c | 12 ++++++++++-- drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/gk20a/ltc_common.c b/drivers/gpu/nvgpu/gk20a/ltc_common.c index 2d2516d9..8f9bd8c2 100644 --- a/drivers/gpu/nvgpu/gk20a/ltc_common.c +++ b/drivers/gpu/nvgpu/gk20a/ltc_common.c @@ -220,8 +220,7 @@ static int gk20a_ltc_alloc_phys_cbc(struct gk20a *g, *gr->compbit_store.pages = pages; gr->compbit_store.base_iova = sg_phys(sgt->sgl); gr->compbit_store.size = compbit_backing_size; - - kfree(sgt); + gr->compbit_store.sgt = sgt; return 0; @@ -241,6 +240,7 @@ static int gk20a_ltc_alloc_virt_cbc(struct gk20a *g, struct gr_gk20a *gr = &g->gr; DEFINE_DMA_ATTRS(attrs); dma_addr_t iova; + int err; dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs); @@ -255,6 +255,14 @@ static int gk20a_ltc_alloc_virt_cbc(struct gk20a *g, gr->compbit_store.base_iova = iova; gr->compbit_store.size = compbit_backing_size; + err = gk20a_get_sgtable_from_pages(d, + &gr->compbit_store.sgt, + gr->compbit_store.pages, iova, + compbit_backing_size); + if (err) { + gk20a_err(dev_from_gk20a(g), "failed to allocate sgt for backing store"); + return err; + } return 0; } diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index d583849d..e5d76f8f 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h @@ -157,6 +157,7 @@ struct gr_ctx_desc { struct compbit_store_desc { struct page **pages; + struct sg_table *sgt; size_t size; u64 base_iova; }; -- cgit v1.2.2