diff options
author | seshendra Gadagottu <sgadagottu@nvidia.com> | 2017-10-02 14:03:05 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-13 18:19:11 -0400 |
commit | 017a9f57756f120cb492fc6c66d8588a2c1626d8 (patch) | |
tree | 1215d9baee83f293c23ebfe56beb030b1c8b3e22 /drivers/gpu/nvgpu/common | |
parent | ceaab0595c0af8dfe4b71ca4014a9b44a862a0ef (diff) |
gpu: nvgpu: add API to create nvgpu_mem from phys
Added new memory API _nvgpu_mem_create_from_phys for
creating nvgpu_mem from physical memory aperture.
With this new API, avoided usage of linux specific
"struct page" in general code and moved this code to
common linux code. This API internally uses
__nvgpu_mem_create_from_pages for creating nvgpu_mem
from physical pages.
JIRA GPUT19X-2
Change-Id: Iaf0193a7c33e71422e4ddabde01edf46f5a81794
Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1571073
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/nvgpu_mem.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c index 9b9f58e1..eb51676c 100644 --- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c | |||
@@ -472,6 +472,25 @@ int __nvgpu_mem_create_from_pages(struct gk20a *g, struct nvgpu_mem *dest, | |||
472 | return 0; | 472 | return 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | int __nvgpu_mem_create_from_phys(struct gk20a *g, struct nvgpu_mem *dest, | ||
476 | u64 src_phys, int nr_pages) | ||
477 | { | ||
478 | struct page **pages = | ||
479 | nvgpu_kmalloc(g, sizeof(struct page *) * nr_pages); | ||
480 | int i, ret = 0; | ||
481 | |||
482 | if (!pages) | ||
483 | return -ENOMEM; | ||
484 | |||
485 | for (i = 0; i < nr_pages; i++) | ||
486 | pages[i] = phys_to_page(src_phys + PAGE_SIZE * i); | ||
487 | |||
488 | ret = __nvgpu_mem_create_from_pages(g, dest, pages, nr_pages); | ||
489 | nvgpu_kfree(g, pages); | ||
490 | |||
491 | return ret; | ||
492 | } | ||
493 | |||
475 | static void *nvgpu_mem_linux_sgl_next(void *sgl) | 494 | static void *nvgpu_mem_linux_sgl_next(void *sgl) |
476 | { | 495 | { |
477 | return sg_next((struct scatterlist *)sgl); | 496 | return sg_next((struct scatterlist *)sgl); |