drm/radeon: only allocate necessary size for vm bo list
authorChristian König <christian.koenig@amd.com>
Wed, 28 May 2014 10:24:17 +0000 (12:24 +0200)
committerChristian König <christian.koenig@amd.com>
Fri, 30 May 2014 12:21:54 +0000 (14:21 +0200)
No need to always allocate the theoretical maximum here.

Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/radeon/radeon_vm.c

index d9ab99f47612743bb41361a8cca8114999e52fca..1f426696de36e200453af920ea8fb7256d5151b1 100644 (file)
@@ -130,10 +130,10 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev,
                                          struct list_head *head)
 {
        struct radeon_cs_reloc *list;
-       unsigned i, idx, size;
+       unsigned i, idx;
 
-       size = (radeon_vm_num_pdes(rdev) + 1) * sizeof(struct radeon_cs_reloc);
-       list = kmalloc(size, GFP_KERNEL);
+       list = kmalloc_array(vm->max_pde_used + 1,
+                            sizeof(struct radeon_cs_reloc), GFP_KERNEL);
        if (!list)
                return NULL;