aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-07-10 00:34:13 -0400
committerDave Airlie <airlied@linux.ie>2005-07-10 00:34:13 -0400
commit2d0f9eaff8e1d08b9707f5d24fe6b0ac95d231e3 (patch)
tree6602c6a936254ae1175073fdd3f800ed67730c17 /drivers/char
parentf179bc77d09b9087bfc559d0368bba350342ac76 (diff)
drm: add _DRM_CONSISTENT map type
Added a new DRM map type _DRM_CONSISTENT for consistent PCI memory. It uses drm_pci_alloc/free for allocating/freeing the memory. From: Felix Kuhling <fxkuehl@gmx.de> Signed-off-by: David Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/drm.h3
-rw-r--r--drivers/char/drm/drm_bufs.c20
-rw-r--r--drivers/char/drm/drm_drv.c4
-rw-r--r--drivers/char/drm/drm_proc.c13
-rw-r--r--drivers/char/drm/drm_vm.c7
5 files changed, 40 insertions, 7 deletions
diff --git a/drivers/char/drm/drm.h b/drivers/char/drm/drm.h
index e8371dd87fbc..50c4d981c497 100644
--- a/drivers/char/drm/drm.h
+++ b/drivers/char/drm/drm.h
@@ -209,7 +209,8 @@ typedef enum drm_map_type {
209 _DRM_REGISTERS = 1, /**< no caching, no core dump */ 209 _DRM_REGISTERS = 1, /**< no caching, no core dump */
210 _DRM_SHM = 2, /**< shared, cached */ 210 _DRM_SHM = 2, /**< shared, cached */
211 _DRM_AGP = 3, /**< AGP/GART */ 211 _DRM_AGP = 3, /**< AGP/GART */
212 _DRM_SCATTER_GATHER = 4 /**< Scatter/gather memory for PCI DMA */ 212 _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */
213 _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */
213} drm_map_type_t; 214} drm_map_type_t;
214 215
215 216
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 4c6191d231b8..89f301ffd97e 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -180,7 +180,22 @@ int drm_addmap( struct inode *inode, struct file *filp,
180 } 180 }
181 map->offset += dev->sg->handle; 181 map->offset += dev->sg->handle;
182 break; 182 break;
183 183 case _DRM_CONSISTENT:
184 {
185 /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G,
186 * As we're limit the address to 2^32-1 (or lses),
187 * casting it down to 32 bits is no problem, but we
188 * need to point to a 64bit variable first. */
189 dma_addr_t bus_addr;
190 map->handle = drm_pci_alloc(dev, map->size, map->size,
191 0xffffffffUL, &bus_addr);
192 map->offset = (unsigned long)bus_addr;
193 if (!map->handle) {
194 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
195 return -ENOMEM;
196 }
197 break;
198 }
184 default: 199 default:
185 drm_free( map, sizeof(*map), DRM_MEM_MAPS ); 200 drm_free( map, sizeof(*map), DRM_MEM_MAPS );
186 return -EINVAL; 201 return -EINVAL;
@@ -291,6 +306,9 @@ int drm_rmmap(struct inode *inode, struct file *filp,
291 case _DRM_AGP: 306 case _DRM_AGP:
292 case _DRM_SCATTER_GATHER: 307 case _DRM_SCATTER_GATHER:
293 break; 308 break;
309 case _DRM_CONSISTENT:
310 drm_pci_free(dev, map->size, map->handle, map->offset);
311 break;
294 } 312 }
295 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 313 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
296 } 314 }
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 3333c250c4d9..f4046c8c70b5 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -228,6 +228,10 @@ int drm_takedown( drm_device_t *dev )
228 dev->sg = NULL; 228 dev->sg = NULL;
229 } 229 }
230 break; 230 break;
231 case _DRM_CONSISTENT:
232 drm_pci_free(dev, map->size,
233 map->handle, map->offset);
234 break;
231 } 235 }
232 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 236 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
233 } 237 }
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 4774087d2e9e..f4154cc71abb 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -210,8 +210,8 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
210 210
211 /* Hardcoded from _DRM_FRAME_BUFFER, 211 /* Hardcoded from _DRM_FRAME_BUFFER,
212 _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and 212 _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
213 _DRM_SCATTER_GATHER. */ 213 _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
214 const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" }; 214 const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
215 const char *type; 215 const char *type;
216 int i; 216 int i;
217 217
@@ -229,9 +229,12 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
229 if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) { 229 if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) {
230 r_list = list_entry(list, drm_map_list_t, head); 230 r_list = list_entry(list, drm_map_list_t, head);
231 map = r_list->map; 231 map = r_list->map;
232 if(!map) continue; 232 if(!map)
233 if (map->type < 0 || map->type > 4) type = "??"; 233 continue;
234 else type = types[map->type]; 234 if (map->type < 0 || map->type > 5)
235 type = "??";
236 else
237 type = types[map->type];
235 DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ", 238 DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
236 i, 239 i,
237 map->offset, 240 map->offset,
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 621220f3f372..644ec9dadc05 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -228,6 +228,10 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
228 case _DRM_AGP: 228 case _DRM_AGP:
229 case _DRM_SCATTER_GATHER: 229 case _DRM_SCATTER_GATHER:
230 break; 230 break;
231 case _DRM_CONSISTENT:
232 drm_pci_free(dev, map->size, map->handle,
233 map->offset);
234 break;
231 } 235 }
232 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 236 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
233 } 237 }
@@ -645,6 +649,9 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
645 vma->vm_ops = &drm_vm_ops; 649 vma->vm_ops = &drm_vm_ops;
646 break; 650 break;
647 case _DRM_SHM: 651 case _DRM_SHM:
652 case _DRM_CONSISTENT:
653 /* Consistent memory is really like shared memory. It's only
654 * allocate in a different way */
648 vma->vm_ops = &drm_vm_shm_ops; 655 vma->vm_ops = &drm_vm_shm_ops;
649 vma->vm_private_data = (void *)map; 656 vma->vm_private_data = (void *)map;
650 /* Don't let this area swap. Change when 657 /* Don't let this area swap. Change when