]> nv-tegra.nvidia Code Review - linux-3.10.git/commitdiff
video: tegra: host: gk20a address space alloc
authorKen Adams <kadams@nvidia.com>
Mon, 17 Jun 2013 13:37:30 +0000 (09:37 -0400)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:27:24 +0000 (13:27 -0700)
Alloc address space for mapping into later.
Basically reserves a section so no further allocation
attempts can hit the region.

Bug 1240060

Change-Id: Ic90544546b95dc463cfea561fd5f975480b3cd39
Signed-off-by: Ken Adams <kadams@nvidia.com>
Reviewed-on: http://git-master/r/240248
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Kevin Huang (Eng-SW) <kevinh@nvidia.com>
Tested-by: Kevin Huang (Eng-SW) <kevinh@nvidia.com>
drivers/video/tegra/host/gk20a/mm_gk20a.c
include/linux/nvhost_as_ioctl.h

index b8586508c17efdd9a0e4654bd6177386ece92e67..2bdd42a4b2e52583ada900aa85f0c24e6b93b66e 100644 (file)
@@ -1439,13 +1439,43 @@ static int gk20a_as_release_share(struct nvhost_as_share *as_share)
        return 0;
 }
 
+
 static int gk20a_as_alloc_space(struct nvhost_as_share *as_share,
                                struct nvhost_as_alloc_space_args *args)
 
 {      int err = -ENOMEM;
-       /*struct vm_gk20a *vm = (struct vm_gk20a *)as_share->priv;*/
+       int pgsz_idx;
+       u32 start_page_nr;
+       struct nvhost_allocator *vma;
+       struct vm_gk20a *vm = (struct vm_gk20a *)as_share->priv;
 
-       nvhost_dbg_fn("");
+       nvhost_dbg_fn("flags=0x%x pgsz=0x%x nr_pages=0x%x o/a=0x%llx",
+                       args->flags, args->page_size, args->pages,
+                       args->o_a.offset);
+
+       /* determine pagesz idx */
+       for (pgsz_idx = gmmu_page_size_small;
+            pgsz_idx < gmmu_nr_page_sizes;
+            pgsz_idx++) {
+               if (gmmu_page_sizes[pgsz_idx] == args->page_size)
+                       break;
+       }
+
+       if (pgsz_idx >= gmmu_nr_page_sizes) {
+               err = -EINVAL;
+               goto clean_up;
+       }
+
+       start_page_nr = ~(u32)0;
+       if (args->flags & NVHOST_AS_ALLOC_SPACE_FLAGS_FIXED_OFFSET)
+               start_page_nr = (u32)(args->o_a.offset >>
+                                     gmmu_page_shifts[pgsz_idx]);
+
+       vma = &vm->vma[pgsz_idx];
+       err = vma->alloc(vma, &start_page_nr, args->pages);
+       args->o_a.offset = start_page_nr;
+
+ clean_up:
        return err;
 }
 
@@ -1453,11 +1483,35 @@ static int gk20a_as_free_space(struct nvhost_as_share *as_share,
                               struct nvhost_as_free_space_args *args)
 {
        int err = -ENOMEM;
-       /*struct vm_gk20a *vm = (struct vm_gk20a *)as_share->priv;*/
-       nvhost_dbg_fn("");
+       int pgsz_idx;
+       u32 start_page_nr;
+       struct nvhost_allocator *vma;
+       struct vm_gk20a *vm = (struct vm_gk20a *)as_share->priv;
 
-       return err;
+       nvhost_dbg_fn("pgsz=0x%x nr_pages=0x%x o/a=0x%llx", args->page_size,
+                       args->pages, args->offset);
+
+       /* determine pagesz idx */
+       for (pgsz_idx = gmmu_page_size_small;
+            pgsz_idx < gmmu_nr_page_sizes;
+            pgsz_idx++) {
+               if (gmmu_page_sizes[pgsz_idx] == args->page_size)
+                       break;
+       }
+
+       if (pgsz_idx >= gmmu_nr_page_sizes) {
+               err = -EINVAL;
+               goto clean_up;
+       }
+
+       start_page_nr = (u32)(args->offset >>
+                             gmmu_page_shifts[pgsz_idx]);
 
+       vma = &vm->vma[pgsz_idx];
+       err = vma->free(vma, start_page_nr, args->pages);
+
+clean_up:
+       return err;
 }
 
 static int gk20a_as_bind_hwctx(struct nvhost_as_share *as_share,
index ff1552c967edccf6b86c6790d7bdaee3ef0af755..c30dafc3570856244090dbc3aa8790e60b25aafd 100644 (file)
@@ -78,6 +78,8 @@ struct nvhost_as_alloc_space_args {
  */
 struct nvhost_as_free_space_args {
        __u64 offset; /* in, byte address */
+       __u32 pages;     /* in, pages */
+       __u32 page_size; /* in, bytes */
 };
 
 /*