aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_bufs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_bufs.c')
-rw-r--r--drivers/gpu/drm/drm_bufs.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 2092e7bb788f..3e257a50bf56 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -39,19 +39,6 @@
39#include <asm/shmparam.h> 39#include <asm/shmparam.h>
40#include "drmP.h" 40#include "drmP.h"
41 41
42resource_size_t drm_get_resource_start(struct drm_device *dev, unsigned int resource)
43{
44 return pci_resource_start(dev->pdev, resource);
45}
46EXPORT_SYMBOL(drm_get_resource_start);
47
48resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resource)
49{
50 return pci_resource_len(dev->pdev, resource);
51}
52
53EXPORT_SYMBOL(drm_get_resource_len);
54
55static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, 42static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
56 struct drm_local_map *map) 43 struct drm_local_map *map)
57{ 44{
@@ -189,7 +176,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
189 switch (map->type) { 176 switch (map->type) {
190 case _DRM_REGISTERS: 177 case _DRM_REGISTERS:
191 case _DRM_FRAME_BUFFER: 178 case _DRM_FRAME_BUFFER:
192#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) 179#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
193 if (map->offset + (map->size-1) < map->offset || 180 if (map->offset + (map->size-1) < map->offset ||
194 map->offset < virt_to_phys(high_memory)) { 181 map->offset < virt_to_phys(high_memory)) {
195 kfree(map); 182 kfree(map);
@@ -341,14 +328,13 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
341 return -EINVAL; 328 return -EINVAL;
342 } 329 }
343 330
344 list = kmalloc(sizeof(*list), GFP_KERNEL); 331 list = kzalloc(sizeof(*list), GFP_KERNEL);
345 if (!list) { 332 if (!list) {
346 if (map->type == _DRM_REGISTERS) 333 if (map->type == _DRM_REGISTERS)
347 iounmap(map->handle); 334 iounmap(map->handle);
348 kfree(map); 335 kfree(map);
349 return -EINVAL; 336 return -EINVAL;
350 } 337 }
351 memset(list, 0, sizeof(*list));
352 list->map = map; 338 list->map = map;
353 339
354 mutex_lock(&dev->struct_mutex); 340 mutex_lock(&dev->struct_mutex);
@@ -691,13 +677,12 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
691 return -EINVAL; 677 return -EINVAL;
692 } 678 }
693 679
694 entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); 680 entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
695 if (!entry->buflist) { 681 if (!entry->buflist) {
696 mutex_unlock(&dev->struct_mutex); 682 mutex_unlock(&dev->struct_mutex);
697 atomic_dec(&dev->buf_alloc); 683 atomic_dec(&dev->buf_alloc);
698 return -ENOMEM; 684 return -ENOMEM;
699 } 685 }
700 memset(entry->buflist, 0, count * sizeof(*entry->buflist));
701 686
702 entry->buf_size = size; 687 entry->buf_size = size;
703 entry->page_order = page_order; 688 entry->page_order = page_order;
@@ -721,7 +706,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
721 buf->file_priv = NULL; 706 buf->file_priv = NULL;
722 707
723 buf->dev_priv_size = dev->driver->dev_priv_size; 708 buf->dev_priv_size = dev->driver->dev_priv_size;
724 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); 709 buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
725 if (!buf->dev_private) { 710 if (!buf->dev_private) {
726 /* Set count correctly so we free the proper amount. */ 711 /* Set count correctly so we free the proper amount. */
727 entry->buf_count = count; 712 entry->buf_count = count;
@@ -730,7 +715,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
730 atomic_dec(&dev->buf_alloc); 715 atomic_dec(&dev->buf_alloc);
731 return -ENOMEM; 716 return -ENOMEM;
732 } 717 }
733 memset(buf->dev_private, 0, buf->dev_priv_size);
734 718
735 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); 719 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
736 720
@@ -845,22 +829,20 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
845 return -EINVAL; 829 return -EINVAL;
846 } 830 }
847 831
848 entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); 832 entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
849 if (!entry->buflist) { 833 if (!entry->buflist) {
850 mutex_unlock(&dev->struct_mutex); 834 mutex_unlock(&dev->struct_mutex);
851 atomic_dec(&dev->buf_alloc); 835 atomic_dec(&dev->buf_alloc);
852 return -ENOMEM; 836 return -ENOMEM;
853 } 837 }
854 memset(entry->buflist, 0, count * sizeof(*entry->buflist));
855 838
856 entry->seglist = kmalloc(count * sizeof(*entry->seglist), GFP_KERNEL); 839 entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
857 if (!entry->seglist) { 840 if (!entry->seglist) {
858 kfree(entry->buflist); 841 kfree(entry->buflist);
859 mutex_unlock(&dev->struct_mutex); 842 mutex_unlock(&dev->struct_mutex);
860 atomic_dec(&dev->buf_alloc); 843 atomic_dec(&dev->buf_alloc);
861 return -ENOMEM; 844 return -ENOMEM;
862 } 845 }
863 memset(entry->seglist, 0, count * sizeof(*entry->seglist));
864 846
865 /* Keep the original pagelist until we know all the allocations 847 /* Keep the original pagelist until we know all the allocations
866 * have succeeded 848 * have succeeded
@@ -924,8 +906,8 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
924 buf->file_priv = NULL; 906 buf->file_priv = NULL;
925 907
926 buf->dev_priv_size = dev->driver->dev_priv_size; 908 buf->dev_priv_size = dev->driver->dev_priv_size;
927 buf->dev_private = kmalloc(buf->dev_priv_size, 909 buf->dev_private = kzalloc(buf->dev_priv_size,
928 GFP_KERNEL); 910 GFP_KERNEL);
929 if (!buf->dev_private) { 911 if (!buf->dev_private) {
930 /* Set count correctly so we free the proper amount. */ 912 /* Set count correctly so we free the proper amount. */
931 entry->buf_count = count; 913 entry->buf_count = count;
@@ -936,7 +918,6 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
936 atomic_dec(&dev->buf_alloc); 918 atomic_dec(&dev->buf_alloc);
937 return -ENOMEM; 919 return -ENOMEM;
938 } 920 }
939 memset(buf->dev_private, 0, buf->dev_priv_size);
940 921
941 DRM_DEBUG("buffer %d @ %p\n", 922 DRM_DEBUG("buffer %d @ %p\n",
942 entry->buf_count, buf->address); 923 entry->buf_count, buf->address);
@@ -1061,14 +1042,13 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1061 return -EINVAL; 1042 return -EINVAL;
1062 } 1043 }
1063 1044
1064 entry->buflist = kmalloc(count * sizeof(*entry->buflist), 1045 entry->buflist = kzalloc(count * sizeof(*entry->buflist),
1065 GFP_KERNEL); 1046 GFP_KERNEL);
1066 if (!entry->buflist) { 1047 if (!entry->buflist) {
1067 mutex_unlock(&dev->struct_mutex); 1048 mutex_unlock(&dev->struct_mutex);
1068 atomic_dec(&dev->buf_alloc); 1049 atomic_dec(&dev->buf_alloc);
1069 return -ENOMEM; 1050 return -ENOMEM;
1070 } 1051 }
1071 memset(entry->buflist, 0, count * sizeof(*entry->buflist));
1072 1052
1073 entry->buf_size = size; 1053 entry->buf_size = size;
1074 entry->page_order = page_order; 1054 entry->page_order = page_order;
@@ -1093,7 +1073,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1093 buf->file_priv = NULL; 1073 buf->file_priv = NULL;
1094 1074
1095 buf->dev_priv_size = dev->driver->dev_priv_size; 1075 buf->dev_priv_size = dev->driver->dev_priv_size;
1096 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); 1076 buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
1097 if (!buf->dev_private) { 1077 if (!buf->dev_private) {
1098 /* Set count correctly so we free the proper amount. */ 1078 /* Set count correctly so we free the proper amount. */
1099 entry->buf_count = count; 1079 entry->buf_count = count;
@@ -1103,8 +1083,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1103 return -ENOMEM; 1083 return -ENOMEM;
1104 } 1084 }
1105 1085
1106 memset(buf->dev_private, 0, buf->dev_priv_size);
1107
1108 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); 1086 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
1109 1087
1110 offset += alignment; 1088 offset += alignment;
@@ -1222,14 +1200,13 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1222 return -EINVAL; 1200 return -EINVAL;
1223 } 1201 }
1224 1202
1225 entry->buflist = kmalloc(count * sizeof(*entry->buflist), 1203 entry->buflist = kzalloc(count * sizeof(*entry->buflist),
1226 GFP_KERNEL); 1204 GFP_KERNEL);
1227 if (!entry->buflist) { 1205 if (!entry->buflist) {
1228 mutex_unlock(&dev->struct_mutex); 1206 mutex_unlock(&dev->struct_mutex);
1229 atomic_dec(&dev->buf_alloc); 1207 atomic_dec(&dev->buf_alloc);
1230 return -ENOMEM; 1208 return -ENOMEM;
1231 } 1209 }
1232 memset(entry->buflist, 0, count * sizeof(*entry->buflist));
1233 1210
1234 entry->buf_size = size; 1211 entry->buf_size = size;
1235 entry->page_order = page_order; 1212 entry->page_order = page_order;
@@ -1253,7 +1230,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1253 buf->file_priv = NULL; 1230 buf->file_priv = NULL;
1254 1231
1255 buf->dev_priv_size = dev->driver->dev_priv_size; 1232 buf->dev_priv_size = dev->driver->dev_priv_size;
1256 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); 1233 buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
1257 if (!buf->dev_private) { 1234 if (!buf->dev_private) {
1258 /* Set count correctly so we free the proper amount. */ 1235 /* Set count correctly so we free the proper amount. */
1259 entry->buf_count = count; 1236 entry->buf_count = count;
@@ -1262,7 +1239,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1262 atomic_dec(&dev->buf_alloc); 1239 atomic_dec(&dev->buf_alloc);
1263 return -ENOMEM; 1240 return -ENOMEM;
1264 } 1241 }
1265 memset(buf->dev_private, 0, buf->dev_priv_size);
1266 1242
1267 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); 1243 DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
1268 1244