From aef0f4ec2f00a041bb5fe37b674f782655cc816d Mon Sep 17 00:00:00 2001
From: Zlatko Calusic <zcalusic@bitsync.net>
Date: Sat, 16 Jan 2016 12:15:28 +0100
Subject: [PATCH] Use vzalloc instead of kzalloc in nvkm_ramht_new()

To stop page allocation failures due to fragmented memory.

page allocation failure: order:5, mode:0x240c0c0
Call Trace:
 [<ffffffff812f44c9>] dump_stack+0x4b/0x72
 [<ffffffff8114d2c4>] warn_alloc_failed+0xd4/0x120
 [<ffffffff8114f853>] __alloc_pages_nodemask+0x103/0x780
 [<ffffffff811500d2>] alloc_kmem_pages+0x12/0x20
 [<ffffffff81161a03>] kmalloc_order+0x13/0x40
 [<ffffffff8117a517>] __kmalloc+0xb7/0xf0
 [<ffffffff813e87c0>] nvkm_ramht_new+0x40/0xf0
 [<ffffffff8144ff50>] g84_fifo_chan_ctor+0x140/0x170
 [<ffffffff81451b97>] g84_fifo_gpfifo_new+0xc7/0x300
 [<ffffffff8143c376>] ? nvkm_disp_class_get+0x26/0x60
 [<ffffffff81449d12>] nvkm_fifo_class_new+0x12/0x20
 [<ffffffff8143bb01>] nvkm_udevice_child_new+0x21/0x30
 [<ffffffff813e5f9e>] nvkm_ioctl_new+0x10e/0x260
 [<ffffffff8143bae0>] ? nvkm_udevice_map+0x40/0x40
 [<ffffffff813e6612>] nvkm_ioctl+0x102/0x250
 [<ffffffff8147d91d>] nvkm_client_ioctl+0xd/0x10
 [<ffffffff813e38dc>] nvif_object_ioctl+0x3c/0x50
 [<ffffffff813e3e8d>] nvif_object_init+0xbd/0x130
 [<ffffffff81492876>] nouveau_channel_new+0xa6/0x630
 [<ffffffff813e41a8>] ? nvif_device_init+0x28/0x30
 [<ffffffff81491a3a>] nouveau_abi16_ioctl_channel_alloc+0xda/0x2d0
 [<ffffffff813be0bd>] ? drm_copy_field+0x3d/0x60
 [<ffffffff813bdcae>] drm_ioctl+0x13e/0x510
 [<ffffffff81491960>] ? nouveau_abi16_ioctl_setparam+0x10/0x10
 [<ffffffff8147b6d3>] nouveau_drm_ioctl+0x63/0xc0
 [<ffffffff8118ff33>] do_vfs_ioctl+0x283/0x460
 [<ffffffff811993d2>] ? __fget+0x72/0xa0
 [<ffffffff8119014c>] SyS_ioctl+0x3c/0x70
 [<ffffffff816f6217>] entry_SYSCALL_64_fastpath+0x12/0x66

Signed-off-by: Zlatko Calusic <zcalusic@bitsync.net>
---
 drivers/gpu/drm/nouveau/nvkm/core/ramht.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ramht.c b/drivers/gpu/drm/nouveau/nvkm/core/ramht.c
index 3216e15..8b20d6c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ramht.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ramht.c
@@ -131,7 +131,7 @@ nvkm_ramht_del(struct nvkm_ramht **pramht)
 	struct nvkm_ramht *ramht = *pramht;
 	if (ramht) {
 		nvkm_gpuobj_del(&ramht->gpuobj);
-		kfree(*pramht);
+		vfree(*pramht);
 		*pramht = NULL;
 	}
 }
@@ -143,8 +143,8 @@ nvkm_ramht_new(struct nvkm_device *device, u32 size, u32 align,
 	struct nvkm_ramht *ramht;
 	int ret, i;
 
-	if (!(ramht = *pramht = kzalloc(sizeof(*ramht) + (size >> 3) *
-					sizeof(*ramht->data), GFP_KERNEL)))
+	if (!(ramht = *pramht = vzalloc(sizeof(*ramht) + (size >> 3) *
+					sizeof(*ramht->data))))
 		return -ENOMEM;
 
 	ramht->device = device;
-- 
2.7.0.rc3