Added a new DRM map type _DRM_CONSISTENT for consistent PCI memory. It uses
drm_pci_alloc/free for allocating/freeing the memory. Only implemented in the Linux DRM so far.main
parent
fe4ade81bb
commit
ed165a2529
|
@ -104,7 +104,8 @@ typedef enum {
|
||||||
DRM_REGISTERS = 1, /**< no caching, no core dump */
|
DRM_REGISTERS = 1, /**< no caching, no core dump */
|
||||||
DRM_SHM = 2, /**< shared, cached */
|
DRM_SHM = 2, /**< shared, cached */
|
||||||
DRM_AGP = 3, /**< AGP/GART */
|
DRM_AGP = 3, /**< AGP/GART */
|
||||||
DRM_SCATTER_GATHER = 4 /**< PCI scatter/gather */
|
DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
|
||||||
|
DRM_CONSISTENT = 5 /**< PCI consistent */
|
||||||
} drmMapType;
|
} drmMapType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -244,7 +244,21 @@ int drm_addmap(struct inode *inode, struct file *filp,
|
||||||
}
|
}
|
||||||
map->offset += dev->sg->handle;
|
map->offset += dev->sg->handle;
|
||||||
break;
|
break;
|
||||||
|
case _DRM_CONSISTENT: {
|
||||||
|
/* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G.
|
||||||
|
* As we're limiting the address to 2^32-1 (or less),
|
||||||
|
* casting it down to 32 bits is no problem, but we
|
||||||
|
* need to point to a 64bit variable first. */
|
||||||
|
dma_addr_t bus_addr;
|
||||||
|
map->handle = drm_pci_alloc(dev, map->size, map->size,
|
||||||
|
0xffffffffUL, &bus_addr);
|
||||||
|
map->offset = (unsigned long)bus_addr;
|
||||||
|
if (!map->handle) {
|
||||||
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -348,6 +362,9 @@ int drm_rmmap(struct inode *inode, struct file *filp,
|
||||||
case _DRM_AGP:
|
case _DRM_AGP:
|
||||||
case _DRM_SCATTER_GATHER:
|
case _DRM_SCATTER_GATHER:
|
||||||
break;
|
break;
|
||||||
|
case _DRM_CONSISTENT:
|
||||||
|
drm_pci_free(dev, map->size, map->handle, map->offset);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,10 @@ int drm_takedown(drm_device_t * dev)
|
||||||
dev->sg = NULL;
|
dev->sg = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case _DRM_CONSISTENT:
|
||||||
|
drm_pci_free(dev, map->size,
|
||||||
|
map->handle, map->offset);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
}
|
}
|
||||||
|
@ -396,6 +400,7 @@ static void __exit drm_cleanup(drm_device_t * dev)
|
||||||
case _DRM_SHM:
|
case _DRM_SHM:
|
||||||
case _DRM_AGP:
|
case _DRM_AGP:
|
||||||
case _DRM_SCATTER_GATHER:
|
case _DRM_SCATTER_GATHER:
|
||||||
|
case _DRM_CONSISTENT:
|
||||||
DRM_DEBUG("Extra maplist item\n");
|
DRM_DEBUG("Extra maplist item\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* \warning These interfaces aren't stable yet.
|
* \warning These interfaces aren't stable yet.
|
||||||
*
|
*
|
||||||
* \todo Implement the remaining ioctl's for the PCI pools.
|
* \todo Implement the remaining ioctl's for the PCI pools.
|
||||||
* \todo Add support to map these buffers.
|
|
||||||
* \todo The wrappers here are so thin that they would be better off inlined..
|
* \todo The wrappers here are so thin that they would be better off inlined..
|
||||||
*
|
*
|
||||||
* \author Jose Fonseca <jrfonseca@tungstengraphics.com>
|
* \author Jose Fonseca <jrfonseca@tungstengraphics.com>
|
||||||
|
|
|
@ -211,9 +211,9 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
|
||||||
struct list_head *list;
|
struct list_head *list;
|
||||||
|
|
||||||
/* Hardcoded from _DRM_FRAME_BUFFER,
|
/* Hardcoded from _DRM_FRAME_BUFFER,
|
||||||
_DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
|
_DRM_REGISTERS, _DRM_SHM, _DRM_AGP,
|
||||||
_DRM_SCATTER_GATHER. */
|
_DRM_SCATTER_GATHER, and _DRM_CONSISTENT. */
|
||||||
const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" };
|
const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
|
||||||
const char *type;
|
const char *type;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
|
||||||
map = r_list->map;
|
map = r_list->map;
|
||||||
if (!map)
|
if (!map)
|
||||||
continue;
|
continue;
|
||||||
if (map->type < 0 || map->type > 4)
|
if (map->type < 0 || map->type > 5)
|
||||||
type = "??";
|
type = "??";
|
||||||
else
|
else
|
||||||
type = types[map->type];
|
type = types[map->type];
|
||||||
|
|
|
@ -232,6 +232,10 @@ void drm_vm_shm_close(struct vm_area_struct *vma)
|
||||||
case _DRM_AGP:
|
case _DRM_AGP:
|
||||||
case _DRM_SCATTER_GATHER:
|
case _DRM_SCATTER_GATHER:
|
||||||
break;
|
break;
|
||||||
|
case _DRM_CONSISTENT:
|
||||||
|
drm_pci_free(dev, map->size, map->handle,
|
||||||
|
map->offset);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
}
|
}
|
||||||
|
@ -658,6 +662,9 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||||
vma->vm_ops = &drm_vm_ops;
|
vma->vm_ops = &drm_vm_ops;
|
||||||
break;
|
break;
|
||||||
case _DRM_SHM:
|
case _DRM_SHM:
|
||||||
|
case _DRM_CONSISTENT:
|
||||||
|
/* Consistent memory is really like shared memory. It's only
|
||||||
|
* allocated in a different way. */
|
||||||
vma->vm_ops = &drm_vm_shm_ops;
|
vma->vm_ops = &drm_vm_shm_ops;
|
||||||
vma->vm_private_data = (void *)map;
|
vma->vm_private_data = (void *)map;
|
||||||
/* Don't let this area swap. Change when
|
/* Don't let this area swap. Change when
|
||||||
|
|
|
@ -246,7 +246,8 @@ typedef enum drm_map_type {
|
||||||
_DRM_REGISTERS = 1, /**< no caching, no core dump */
|
_DRM_REGISTERS = 1, /**< no caching, no core dump */
|
||||||
_DRM_SHM = 2, /**< shared, cached */
|
_DRM_SHM = 2, /**< shared, cached */
|
||||||
_DRM_AGP = 3, /**< AGP/GART */
|
_DRM_AGP = 3, /**< AGP/GART */
|
||||||
_DRM_SCATTER_GATHER = 4 /**< Scatter/gather memory for PCI DMA */
|
_DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */
|
||||||
|
_DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */
|
||||||
} drm_map_type_t;
|
} drm_map_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue