gpu: nvgpu: ALLOC_AS: don't fail on default big page size
Sami Kiminki [Mon, 27 Oct 2014 17:39:46 +0000 (19:39 +0200)]
gk20a_vm_alloc_share() fails when the default big page size is
requested but ops.mm.set_big_page_size is unset. Rework the logic a
bit to allow userspace to explicitly request the default big page
size, too.

Change-Id: I2a28c6d979fbf1dde5559ce9eb5f1310d232e27f
Signed-off-by: Sami Kiminki <skiminki@nvidia.com>
Reviewed-on: http://git-master/r/590456
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/gpu/nvgpu/gk20a/mm_gk20a.c

index c37f790..1cdb2f8 100644 (file)
@@ -2341,6 +2341,7 @@ int gk20a_vm_alloc_share(struct gk20a_as_share *as_share, u32 big_page_size)
        struct vm_gk20a *vm;
        char name[32];
        int err;
+       u32 default_big_page_size;
 
        gk20a_dbg_fn("");
 
@@ -2354,11 +2355,15 @@ int gk20a_vm_alloc_share(struct gk20a_as_share *as_share, u32 big_page_size)
 
        snprintf(name, sizeof(name), "gk20a_as_%d", as_share->id);
 
-       if (big_page_size && !g->ops.mm.set_big_page_size)
-               return -EINVAL;
+       default_big_page_size =
+               gk20a_get_platform(g->dev)->default_big_page_size;
+
        if (big_page_size == 0)
-               big_page_size =
-                       gk20a_get_platform(g->dev)->default_big_page_size;
+               big_page_size = default_big_page_size;
+
+       if (big_page_size != default_big_page_size &&
+           !g->ops.mm.set_big_page_size)
+               return -EINVAL;
 
        err = gk20a_init_vm(mm, vm, big_page_size, big_page_size << 10,
                            mm->channel.size, true, name);