diff options
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r-- | include/drm/drmP.h | 178 |
1 files changed, 69 insertions, 109 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index b84d8ae35e6f..45b67d9c39c1 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -34,9 +34,6 @@ | |||
34 | #ifndef _DRM_P_H_ | 34 | #ifndef _DRM_P_H_ |
35 | #define _DRM_P_H_ | 35 | #define _DRM_P_H_ |
36 | 36 | ||
37 | /* If you want the memory alloc debug functionality, change define below */ | ||
38 | /* #define DEBUG_MEMORY */ | ||
39 | |||
40 | #ifdef __KERNEL__ | 37 | #ifdef __KERNEL__ |
41 | #ifdef __alpha__ | 38 | #ifdef __alpha__ |
42 | /* add include of current.h so that "current" is defined | 39 | /* add include of current.h so that "current" is defined |
@@ -86,7 +83,17 @@ struct drm_device; | |||
86 | 83 | ||
87 | #include "drm_os_linux.h" | 84 | #include "drm_os_linux.h" |
88 | #include "drm_hashtab.h" | 85 | #include "drm_hashtab.h" |
86 | #include "drm_mm.h" | ||
87 | |||
88 | #define DRM_UT_CORE 0x01 | ||
89 | #define DRM_UT_DRIVER 0x02 | ||
90 | #define DRM_UT_KMS 0x04 | ||
91 | #define DRM_UT_MODE 0x08 | ||
89 | 92 | ||
93 | extern void drm_ut_debug_printk(unsigned int request_level, | ||
94 | const char *prefix, | ||
95 | const char *function_name, | ||
96 | const char *format, ...); | ||
90 | /***********************************************************************/ | 97 | /***********************************************************************/ |
91 | /** \name DRM template customization defaults */ | 98 | /** \name DRM template customization defaults */ |
92 | /*@{*/ | 99 | /*@{*/ |
@@ -123,31 +130,6 @@ struct drm_device; | |||
123 | 130 | ||
124 | #define DRM_FLAG_DEBUG 0x01 | 131 | #define DRM_FLAG_DEBUG 0x01 |
125 | 132 | ||
126 | #define DRM_MEM_DMA 0 | ||
127 | #define DRM_MEM_SAREA 1 | ||
128 | #define DRM_MEM_DRIVER 2 | ||
129 | #define DRM_MEM_MAGIC 3 | ||
130 | #define DRM_MEM_IOCTLS 4 | ||
131 | #define DRM_MEM_MAPS 5 | ||
132 | #define DRM_MEM_VMAS 6 | ||
133 | #define DRM_MEM_BUFS 7 | ||
134 | #define DRM_MEM_SEGS 8 | ||
135 | #define DRM_MEM_PAGES 9 | ||
136 | #define DRM_MEM_FILES 10 | ||
137 | #define DRM_MEM_QUEUES 11 | ||
138 | #define DRM_MEM_CMDS 12 | ||
139 | #define DRM_MEM_MAPPINGS 13 | ||
140 | #define DRM_MEM_BUFLISTS 14 | ||
141 | #define DRM_MEM_AGPLISTS 15 | ||
142 | #define DRM_MEM_TOTALAGP 16 | ||
143 | #define DRM_MEM_BOUNDAGP 17 | ||
144 | #define DRM_MEM_CTXBITMAP 18 | ||
145 | #define DRM_MEM_STUB 19 | ||
146 | #define DRM_MEM_SGLISTS 20 | ||
147 | #define DRM_MEM_CTXLIST 21 | ||
148 | #define DRM_MEM_MM 22 | ||
149 | #define DRM_MEM_HASHTAB 23 | ||
150 | |||
151 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) | 133 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) |
152 | #define DRM_MAP_HASH_OFFSET 0x10000000 | 134 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
153 | 135 | ||
@@ -186,15 +168,57 @@ struct drm_device; | |||
186 | * \param arg arguments | 168 | * \param arg arguments |
187 | */ | 169 | */ |
188 | #if DRM_DEBUG_CODE | 170 | #if DRM_DEBUG_CODE |
189 | #define DRM_DEBUG(fmt, arg...) \ | 171 | #define DRM_DEBUG(fmt, args...) \ |
172 | do { \ | ||
173 | drm_ut_debug_printk(DRM_UT_CORE, DRM_NAME, \ | ||
174 | __func__, fmt, ##args); \ | ||
175 | } while (0) | ||
176 | |||
177 | #define DRM_DEBUG_DRIVER(prefix, fmt, args...) \ | ||
178 | do { \ | ||
179 | drm_ut_debug_printk(DRM_UT_DRIVER, prefix, \ | ||
180 | __func__, fmt, ##args); \ | ||
181 | } while (0) | ||
182 | #define DRM_DEBUG_KMS(prefix, fmt, args...) \ | ||
183 | do { \ | ||
184 | drm_ut_debug_printk(DRM_UT_KMS, prefix, \ | ||
185 | __func__, fmt, ##args); \ | ||
186 | } while (0) | ||
187 | #define DRM_DEBUG_MODE(prefix, fmt, args...) \ | ||
188 | do { \ | ||
189 | drm_ut_debug_printk(DRM_UT_MODE, prefix, \ | ||
190 | __func__, fmt, ##args); \ | ||
191 | } while (0) | ||
192 | #define DRM_LOG(fmt, args...) \ | ||
193 | do { \ | ||
194 | drm_ut_debug_printk(DRM_UT_CORE, NULL, \ | ||
195 | NULL, fmt, ##args); \ | ||
196 | } while (0) | ||
197 | #define DRM_LOG_KMS(fmt, args...) \ | ||
190 | do { \ | 198 | do { \ |
191 | if ( drm_debug ) \ | 199 | drm_ut_debug_printk(DRM_UT_KMS, NULL, \ |
192 | printk(KERN_DEBUG \ | 200 | NULL, fmt, ##args); \ |
193 | "[" DRM_NAME ":%s] " fmt , \ | 201 | } while (0) |
194 | __func__ , ##arg); \ | 202 | #define DRM_LOG_MODE(fmt, args...) \ |
203 | do { \ | ||
204 | drm_ut_debug_printk(DRM_UT_MODE, NULL, \ | ||
205 | NULL, fmt, ##args); \ | ||
206 | } while (0) | ||
207 | #define DRM_LOG_DRIVER(fmt, args...) \ | ||
208 | do { \ | ||
209 | drm_ut_debug_printk(DRM_UT_DRIVER, NULL, \ | ||
210 | NULL, fmt, ##args); \ | ||
195 | } while (0) | 211 | } while (0) |
196 | #else | 212 | #else |
213 | #define DRM_DEBUG_DRIVER(prefix, fmt, args...) do { } while (0) | ||
214 | #define DRM_DEBUG_KMS(prefix, fmt, args...) do { } while (0) | ||
215 | #define DRM_DEBUG_MODE(prefix, fmt, args...) do { } while (0) | ||
197 | #define DRM_DEBUG(fmt, arg...) do { } while (0) | 216 | #define DRM_DEBUG(fmt, arg...) do { } while (0) |
217 | #define DRM_LOG(fmt, arg...) do { } while (0) | ||
218 | #define DRM_LOG_KMS(fmt, args...) do { } while (0) | ||
219 | #define DRM_LOG_MODE(fmt, arg...) do { } while (0) | ||
220 | #define DRM_LOG_DRIVER(fmt, arg...) do { } while (0) | ||
221 | |||
198 | #endif | 222 | #endif |
199 | 223 | ||
200 | #define DRM_PROC_LIMIT (PAGE_SIZE-80) | 224 | #define DRM_PROC_LIMIT (PAGE_SIZE-80) |
@@ -237,15 +261,15 @@ struct drm_device; | |||
237 | * \param dev DRM device. | 261 | * \param dev DRM device. |
238 | * \param filp file pointer of the caller. | 262 | * \param filp file pointer of the caller. |
239 | */ | 263 | */ |
240 | #define LOCK_TEST_WITH_RETURN( dev, file_priv ) \ | 264 | #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \ |
241 | do { \ | 265 | do { \ |
242 | if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock) || \ | 266 | if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \ |
243 | file_priv->master->lock.file_priv != file_priv) { \ | 267 | _file_priv->master->lock.file_priv != _file_priv) { \ |
244 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ | 268 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
245 | __func__, _DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock),\ | 269 | __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\ |
246 | file_priv->master->lock.file_priv, file_priv); \ | 270 | _file_priv->master->lock.file_priv, _file_priv); \ |
247 | return -EINVAL; \ | 271 | return -EINVAL; \ |
248 | } \ | 272 | } \ |
249 | } while (0) | 273 | } while (0) |
250 | 274 | ||
251 | /** | 275 | /** |
@@ -502,26 +526,6 @@ struct drm_sigdata { | |||
502 | }; | 526 | }; |
503 | 527 | ||
504 | 528 | ||
505 | /* | ||
506 | * Generic memory manager structs | ||
507 | */ | ||
508 | |||
509 | struct drm_mm_node { | ||
510 | struct list_head fl_entry; | ||
511 | struct list_head ml_entry; | ||
512 | int free; | ||
513 | unsigned long start; | ||
514 | unsigned long size; | ||
515 | struct drm_mm *mm; | ||
516 | void *private; | ||
517 | }; | ||
518 | |||
519 | struct drm_mm { | ||
520 | struct list_head fl_entry; | ||
521 | struct list_head ml_entry; | ||
522 | }; | ||
523 | |||
524 | |||
525 | /** | 529 | /** |
526 | * Kernel side of a mapping | 530 | * Kernel side of a mapping |
527 | */ | 531 | */ |
@@ -1385,22 +1389,6 @@ extern char *drm_get_connector_status_name(enum drm_connector_status status); | |||
1385 | extern int drm_sysfs_connector_add(struct drm_connector *connector); | 1389 | extern int drm_sysfs_connector_add(struct drm_connector *connector); |
1386 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); | 1390 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
1387 | 1391 | ||
1388 | /* | ||
1389 | * Basic memory manager support (drm_mm.c) | ||
1390 | */ | ||
1391 | extern struct drm_mm_node *drm_mm_get_block(struct drm_mm_node * parent, | ||
1392 | unsigned long size, | ||
1393 | unsigned alignment); | ||
1394 | extern void drm_mm_put_block(struct drm_mm_node * cur); | ||
1395 | extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, unsigned long size, | ||
1396 | unsigned alignment, int best_match); | ||
1397 | extern int drm_mm_init(struct drm_mm *mm, unsigned long start, unsigned long size); | ||
1398 | extern void drm_mm_takedown(struct drm_mm *mm); | ||
1399 | extern int drm_mm_clean(struct drm_mm *mm); | ||
1400 | extern unsigned long drm_mm_tail_space(struct drm_mm *mm); | ||
1401 | extern int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size); | ||
1402 | extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size); | ||
1403 | |||
1404 | /* Graphics Execution Manager library functions (drm_gem.c) */ | 1392 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1405 | int drm_gem_init(struct drm_device *dev); | 1393 | int drm_gem_init(struct drm_device *dev); |
1406 | void drm_gem_destroy(struct drm_device *dev); | 1394 | void drm_gem_destroy(struct drm_device *dev); |
@@ -1501,39 +1489,17 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map) | |||
1501 | { | 1489 | { |
1502 | } | 1490 | } |
1503 | 1491 | ||
1504 | #ifndef DEBUG_MEMORY | ||
1505 | /** Wrapper around kmalloc() */ | ||
1506 | static __inline__ void *drm_alloc(size_t size, int area) | ||
1507 | { | ||
1508 | return kmalloc(size, GFP_KERNEL); | ||
1509 | } | ||
1510 | |||
1511 | /** Wrapper around kfree() */ | ||
1512 | static __inline__ void drm_free(void *pt, size_t size, int area) | ||
1513 | { | ||
1514 | kfree(pt); | ||
1515 | } | ||
1516 | |||
1517 | /** Wrapper around kcalloc() */ | ||
1518 | static __inline__ void *drm_calloc(size_t nmemb, size_t size, int area) | ||
1519 | { | ||
1520 | return kcalloc(nmemb, size, GFP_KERNEL); | ||
1521 | } | ||
1522 | 1492 | ||
1523 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) | 1493 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) |
1524 | { | 1494 | { |
1525 | u8 *addr; | 1495 | if (size * nmemb <= PAGE_SIZE) |
1526 | |||
1527 | if (size <= PAGE_SIZE) | ||
1528 | return kcalloc(nmemb, size, GFP_KERNEL); | 1496 | return kcalloc(nmemb, size, GFP_KERNEL); |
1529 | 1497 | ||
1530 | addr = vmalloc(nmemb * size); | 1498 | if (size != 0 && nmemb > ULONG_MAX / size) |
1531 | if (!addr) | ||
1532 | return NULL; | 1499 | return NULL; |
1533 | 1500 | ||
1534 | memset(addr, 0, nmemb * size); | 1501 | return __vmalloc(size * nmemb, |
1535 | 1502 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); | |
1536 | return addr; | ||
1537 | } | 1503 | } |
1538 | 1504 | ||
1539 | static __inline void drm_free_large(void *ptr) | 1505 | static __inline void drm_free_large(void *ptr) |
@@ -1543,12 +1509,6 @@ static __inline void drm_free_large(void *ptr) | |||
1543 | 1509 | ||
1544 | vfree(ptr); | 1510 | vfree(ptr); |
1545 | } | 1511 | } |
1546 | #else | ||
1547 | extern void *drm_alloc(size_t size, int area); | ||
1548 | extern void drm_free(void *pt, size_t size, int area); | ||
1549 | extern void *drm_calloc(size_t nmemb, size_t size, int area); | ||
1550 | #endif | ||
1551 | |||
1552 | /*@}*/ | 1512 | /*@}*/ |
1553 | 1513 | ||
1554 | #endif /* __KERNEL__ */ | 1514 | #endif /* __KERNEL__ */ |