aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-04-18 13:49:11 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-18 13:49:11 -0400
commitac69e973ff0660e455f4ba1ddd4dcce4ae70ed1a (patch)
tree079826480a861b5d02e314248e51d69a9a7b8dfa /drivers
parent102e41fd9dfee357b71e21a38eec3c86ff557bc1 (diff)
parentd253258c80117c2afaa644554e613201992e4ee9 (diff)
Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: drm: Fix further issues in drivers/char/drm/via_irq.c drivers/char/drm/drm_memory.c: possible cleanups drm: deline a few large inlines in DRM code drm: remove master setting from add/remove context drm: drm_pci needs dma-mapping.h [PATCH] drm: Fix issue reported by Coverity in drivers/char/drm/via_irq.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/drm/drmP.h4
-rw-r--r--drivers/char/drm/drm_drv.c4
-rw-r--r--drivers/char/drm/drm_memory.c134
-rw-r--r--drivers/char/drm/drm_memory.h128
-rw-r--r--drivers/char/drm/drm_memory_debug.h2
-rw-r--r--drivers/char/drm/drm_pci.c1
-rw-r--r--drivers/char/drm/via_irq.c12
7 files changed, 152 insertions, 133 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index edc72a6348a7..e1aadae00623 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -815,8 +815,6 @@ extern int drm_mem_info(char *buf, char **start, off_t offset,
815extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); 815extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
816extern void *drm_ioremap(unsigned long offset, unsigned long size, 816extern void *drm_ioremap(unsigned long offset, unsigned long size,
817 drm_device_t * dev); 817 drm_device_t * dev);
818extern void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
819 drm_device_t * dev);
820extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev); 818extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev);
821 819
822extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type); 820extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type);
@@ -1022,11 +1020,13 @@ static __inline__ void drm_core_ioremap(struct drm_map *map,
1022 map->handle = drm_ioremap(map->offset, map->size, dev); 1020 map->handle = drm_ioremap(map->offset, map->size, dev);
1023} 1021}
1024 1022
1023#if 0
1025static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, 1024static __inline__ void drm_core_ioremap_nocache(struct drm_map *map,
1026 struct drm_device *dev) 1025 struct drm_device *dev)
1027{ 1026{
1028 map->handle = drm_ioremap_nocache(map->offset, map->size, dev); 1027 map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
1029} 1028}
1029#endif /* 0 */
1030 1030
1031static __inline__ void drm_core_ioremapfree(struct drm_map *map, 1031static __inline__ void drm_core_ioremapfree(struct drm_map *map,
1032 struct drm_device *dev) 1032 struct drm_device *dev)
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index dc6bbe8a18dc..3c0b882a8e72 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -75,8 +75,8 @@ static drm_ioctl_desc_t drm_ioctls[] = {
75 [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 75 [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
76 [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH}, 76 [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH},
77 77
78 [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 78 [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_ROOT_ONLY},
79 [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 79 [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_ROOT_ONLY},
80 [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 80 [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
81 [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, 81 [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH},
82 [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 82 [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c
index dddf8de66143..7e3318e1d1c6 100644
--- a/drivers/char/drm/drm_memory.c
+++ b/drivers/char/drm/drm_memory.c
@@ -80,6 +80,71 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
80} 80}
81 81
82#if __OS_HAS_AGP 82#if __OS_HAS_AGP
83/*
84 * Find the drm_map that covers the range [offset, offset+size).
85 */
86static drm_map_t *drm_lookup_map(unsigned long offset,
87 unsigned long size, drm_device_t * dev)
88{
89 struct list_head *list;
90 drm_map_list_t *r_list;
91 drm_map_t *map;
92
93 list_for_each(list, &dev->maplist->head) {
94 r_list = (drm_map_list_t *) list;
95 map = r_list->map;
96 if (!map)
97 continue;
98 if (map->offset <= offset
99 && (offset + size) <= (map->offset + map->size))
100 return map;
101 }
102 return NULL;
103}
104
105static void *agp_remap(unsigned long offset, unsigned long size,
106 drm_device_t * dev)
107{
108 unsigned long *phys_addr_map, i, num_pages =
109 PAGE_ALIGN(size) / PAGE_SIZE;
110 struct drm_agp_mem *agpmem;
111 struct page **page_map;
112 void *addr;
113
114 size = PAGE_ALIGN(size);
115
116#ifdef __alpha__
117 offset -= dev->hose->mem_space->start;
118#endif
119
120 for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next)
121 if (agpmem->bound <= offset
122 && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
123 (offset + size))
124 break;
125 if (!agpmem)
126 return NULL;
127
128 /*
129 * OK, we're mapping AGP space on a chipset/platform on which memory accesses by
130 * the CPU do not get remapped by the GART. We fix this by using the kernel's
131 * page-table instead (that's probably faster anyhow...).
132 */
133 /* note: use vmalloc() because num_pages could be large... */
134 page_map = vmalloc(num_pages * sizeof(struct page *));
135 if (!page_map)
136 return NULL;
137
138 phys_addr_map =
139 agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE;
140 for (i = 0; i < num_pages; ++i)
141 page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT);
142 addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP);
143 vfree(page_map);
144
145 return addr;
146}
147
83/** Wrapper around agp_allocate_memory() */ 148/** Wrapper around agp_allocate_memory() */
84DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type) 149DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type)
85{ 150{
@@ -103,5 +168,74 @@ int drm_unbind_agp(DRM_AGP_MEM * handle)
103{ 168{
104 return drm_agp_unbind_memory(handle); 169 return drm_agp_unbind_memory(handle);
105} 170}
171
172#else /* __OS_HAS_AGP */
173
174static inline drm_map_t *drm_lookup_map(unsigned long offset,
175 unsigned long size, drm_device_t * dev)
176{
177 return NULL;
178}
179
180static inline void *agp_remap(unsigned long offset, unsigned long size,
181 drm_device_t * dev)
182{
183 return NULL;
184}
185
106#endif /* agp */ 186#endif /* agp */
187
188void *drm_ioremap(unsigned long offset, unsigned long size,
189 drm_device_t * dev)
190{
191 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
192 drm_map_t *map = drm_lookup_map(offset, size, dev);
193
194 if (map && map->type == _DRM_AGP)
195 return agp_remap(offset, size, dev);
196 }
197 return ioremap(offset, size);
198}
199EXPORT_SYMBOL(drm_ioremap);
200
201#if 0
202void *drm_ioremap_nocache(unsigned long offset,
203 unsigned long size, drm_device_t * dev)
204{
205 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
206 drm_map_t *map = drm_lookup_map(offset, size, dev);
207
208 if (map && map->type == _DRM_AGP)
209 return agp_remap(offset, size, dev);
210 }
211 return ioremap_nocache(offset, size);
212}
213#endif /* 0 */
214
215void drm_ioremapfree(void *pt, unsigned long size,
216 drm_device_t * dev)
217{
218 /*
219 * This is a bit ugly. It would be much cleaner if the DRM API would use separate
220 * routines for handling mappings in the AGP space. Hopefully this can be done in
221 * a future revision of the interface...
222 */
223 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
224 && ((unsigned long)pt >= VMALLOC_START
225 && (unsigned long)pt < VMALLOC_END)) {
226 unsigned long offset;
227 drm_map_t *map;
228
229 offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK);
230 map = drm_lookup_map(offset, size, dev);
231 if (map && map->type == _DRM_AGP) {
232 vunmap(pt);
233 return;
234 }
235 }
236
237 iounmap(pt);
238}
239EXPORT_SYMBOL(drm_ioremapfree);
240
107#endif /* debug_memory */ 241#endif /* debug_memory */
diff --git a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h
index 3732a61c3762..714d9aedcff5 100644
--- a/drivers/char/drm/drm_memory.h
+++ b/drivers/char/drm/drm_memory.h
@@ -57,71 +57,6 @@
57# endif 57# endif
58#endif 58#endif
59 59
60/*
61 * Find the drm_map that covers the range [offset, offset+size).
62 */
63static inline drm_map_t *drm_lookup_map(unsigned long offset,
64 unsigned long size, drm_device_t * dev)
65{
66 struct list_head *list;
67 drm_map_list_t *r_list;
68 drm_map_t *map;
69
70 list_for_each(list, &dev->maplist->head) {
71 r_list = (drm_map_list_t *) list;
72 map = r_list->map;
73 if (!map)
74 continue;
75 if (map->offset <= offset
76 && (offset + size) <= (map->offset + map->size))
77 return map;
78 }
79 return NULL;
80}
81
82static inline void *agp_remap(unsigned long offset, unsigned long size,
83 drm_device_t * dev)
84{
85 unsigned long *phys_addr_map, i, num_pages =
86 PAGE_ALIGN(size) / PAGE_SIZE;
87 struct drm_agp_mem *agpmem;
88 struct page **page_map;
89 void *addr;
90
91 size = PAGE_ALIGN(size);
92
93#ifdef __alpha__
94 offset -= dev->hose->mem_space->start;
95#endif
96
97 for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next)
98 if (agpmem->bound <= offset
99 && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
100 (offset + size))
101 break;
102 if (!agpmem)
103 return NULL;
104
105 /*
106 * OK, we're mapping AGP space on a chipset/platform on which memory accesses by
107 * the CPU do not get remapped by the GART. We fix this by using the kernel's
108 * page-table instead (that's probably faster anyhow...).
109 */
110 /* note: use vmalloc() because num_pages could be large... */
111 page_map = vmalloc(num_pages * sizeof(struct page *));
112 if (!page_map)
113 return NULL;
114
115 phys_addr_map =
116 agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE;
117 for (i = 0; i < num_pages; ++i)
118 page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT);
119 addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP);
120 vfree(page_map);
121
122 return addr;
123}
124
125static inline unsigned long drm_follow_page(void *vaddr) 60static inline unsigned long drm_follow_page(void *vaddr)
126{ 61{
127 pgd_t *pgd = pgd_offset_k((unsigned long)vaddr); 62 pgd_t *pgd = pgd_offset_k((unsigned long)vaddr);
@@ -133,18 +68,6 @@ static inline unsigned long drm_follow_page(void *vaddr)
133 68
134#else /* __OS_HAS_AGP */ 69#else /* __OS_HAS_AGP */
135 70
136static inline drm_map_t *drm_lookup_map(unsigned long offset,
137 unsigned long size, drm_device_t * dev)
138{
139 return NULL;
140}
141
142static inline void *agp_remap(unsigned long offset, unsigned long size,
143 drm_device_t * dev)
144{
145 return NULL;
146}
147
148static inline unsigned long drm_follow_page(void *vaddr) 71static inline unsigned long drm_follow_page(void *vaddr)
149{ 72{
150 return 0; 73 return 0;
@@ -152,51 +75,8 @@ static inline unsigned long drm_follow_page(void *vaddr)
152 75
153#endif 76#endif
154 77
155static inline void *drm_ioremap(unsigned long offset, unsigned long size, 78void *drm_ioremap(unsigned long offset, unsigned long size,
156 drm_device_t * dev) 79 drm_device_t * dev);
157{
158 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
159 drm_map_t *map = drm_lookup_map(offset, size, dev);
160
161 if (map && map->type == _DRM_AGP)
162 return agp_remap(offset, size, dev);
163 }
164 return ioremap(offset, size);
165}
166
167static inline void *drm_ioremap_nocache(unsigned long offset,
168 unsigned long size, drm_device_t * dev)
169{
170 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
171 drm_map_t *map = drm_lookup_map(offset, size, dev);
172
173 if (map && map->type == _DRM_AGP)
174 return agp_remap(offset, size, dev);
175 }
176 return ioremap_nocache(offset, size);
177}
178
179static inline void drm_ioremapfree(void *pt, unsigned long size,
180 drm_device_t * dev)
181{
182 /*
183 * This is a bit ugly. It would be much cleaner if the DRM API would use separate
184 * routines for handling mappings in the AGP space. Hopefully this can be done in
185 * a future revision of the interface...
186 */
187 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
188 && ((unsigned long)pt >= VMALLOC_START
189 && (unsigned long)pt < VMALLOC_END)) {
190 unsigned long offset;
191 drm_map_t *map;
192
193 offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK);
194 map = drm_lookup_map(offset, size, dev);
195 if (map && map->type == _DRM_AGP) {
196 vunmap(pt);
197 return;
198 }
199 }
200 80
201 iounmap(pt); 81void drm_ioremapfree(void *pt, unsigned long size,
202} 82 drm_device_t * dev);
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
index 7868341817da..6543b9a14c42 100644
--- a/drivers/char/drm/drm_memory_debug.h
+++ b/drivers/char/drm/drm_memory_debug.h
@@ -229,6 +229,7 @@ void *drm_ioremap (unsigned long offset, unsigned long size,
229 return pt; 229 return pt;
230} 230}
231 231
232#if 0
232void *drm_ioremap_nocache (unsigned long offset, unsigned long size, 233void *drm_ioremap_nocache (unsigned long offset, unsigned long size,
233 drm_device_t * dev) { 234 drm_device_t * dev) {
234 void *pt; 235 void *pt;
@@ -251,6 +252,7 @@ void *drm_ioremap_nocache (unsigned long offset, unsigned long size,
251 spin_unlock(&drm_mem_lock); 252 spin_unlock(&drm_mem_lock);
252 return pt; 253 return pt;
253} 254}
255#endif /* 0 */
254 256
255void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) { 257void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) {
256 int alloc_count; 258 int alloc_count;
diff --git a/drivers/char/drm/drm_pci.c b/drivers/char/drm/drm_pci.c
index b28ca9cea8a2..86a0f1c22091 100644
--- a/drivers/char/drm/drm_pci.c
+++ b/drivers/char/drm/drm_pci.c
@@ -37,6 +37,7 @@
37 */ 37 */
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/dma-mapping.h>
40#include "drmP.h" 41#include "drmP.h"
41 42
42/**********************************************************************/ 43/**********************************************************************/
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 6152415644e9..c33d068cde19 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -196,9 +196,9 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
196{ 196{
197 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 197 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
198 unsigned int cur_irq_sequence; 198 unsigned int cur_irq_sequence;
199 drm_via_irq_t *cur_irq = dev_priv->via_irqs; 199 drm_via_irq_t *cur_irq;
200 int ret = 0; 200 int ret = 0;
201 maskarray_t *masks = dev_priv->irq_masks; 201 maskarray_t *masks;
202 int real_irq; 202 int real_irq;
203 203
204 DRM_DEBUG("%s\n", __FUNCTION__); 204 DRM_DEBUG("%s\n", __FUNCTION__);
@@ -221,8 +221,9 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
221 __FUNCTION__, irq); 221 __FUNCTION__, irq);
222 return DRM_ERR(EINVAL); 222 return DRM_ERR(EINVAL);
223 } 223 }
224 224
225 cur_irq += real_irq; 225 masks = dev_priv->irq_masks;
226 cur_irq = dev_priv->via_irqs + real_irq;
226 227
227 if (masks[real_irq][2] && !force_sequence) { 228 if (masks[real_irq][2] && !force_sequence) {
228 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, 229 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
@@ -247,11 +248,12 @@ void via_driver_irq_preinstall(drm_device_t * dev)
247{ 248{
248 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 249 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
249 u32 status; 250 u32 status;
250 drm_via_irq_t *cur_irq = dev_priv->via_irqs; 251 drm_via_irq_t *cur_irq;
251 int i; 252 int i;
252 253
253 DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv); 254 DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv);
254 if (dev_priv) { 255 if (dev_priv) {
256 cur_irq = dev_priv->via_irqs;
255 257
256 dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE; 258 dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE;
257 dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING; 259 dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING;