From 39615ec06e8ca9280b4feefc42e008c9795541bd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 3 Nov 2005 00:38:25 +0000 Subject: Converts the remaining drm_agp_foo functions to be a drm_agp_foo and drm_agp_foo_ioctl pair. Modifies the MGA DRM to use the drm_agp_foo functions instead of the drm_foo_agp functions. The drm_foo_agp functions are no longer exported by drm.ko. Ensures that dma->seg_count and dma->page_count are properly set in drm_addbufs_{agp,sg,fb}. drm_addbufs_pci was already correct. Ensures that mga_do_agp_dma_bootstrap correctly sets agp_buffer_token. At this point PCI DMA is still broken. Xorg bug: #4797 Reviewed by: Dave Airlie, Eric Anholt Signed-off-by: Ian Romanick --- linux-core/drmP.h | 12 ++-- linux-core/drm_agpsupport.c | 130 +++++++++++++++++++++++++++++------------- linux-core/drm_bufs.c | 6 ++ linux-core/drm_core.h | 4 +- linux-core/drm_drv.c | 8 +-- linux-core/drm_memory.c | 4 -- linux-core/drm_memory_debug.c | 4 -- 7 files changed, 109 insertions(+), 59 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 28367139..c0ac922f 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -938,13 +938,17 @@ extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, extern int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info); extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_agp_alloc(struct inode *inode, struct file *filp, +extern int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request); +extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_agp_free(struct inode *inode, struct file *filp, +extern int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request); +extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_agp_unbind(struct inode *inode, struct file *filp, +extern int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request); +extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_agp_bind(struct inode *inode, struct file *filp, +extern int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request); +extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) extern DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type); diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 078c9127..572d7a0d 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -228,29 +228,22 @@ int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, * Verifies the AGP device is present and has been acquired, allocates the * memory via alloc_agp() and creates a drm_agp_mem entry for it. */ -int drm_agp_alloc(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->head->dev; - drm_agp_buffer_t request; drm_agp_mem_t *entry; DRM_AGP_MEM *memory; unsigned long pages; u32 type; - drm_agp_buffer_t __user *argp = (void __user *)arg; if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (copy_from_user(&request, argp, sizeof(request))) - return -EFAULT; if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) return -ENOMEM; memset(entry, 0, sizeof(*entry)); - pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; - type = (u32) request.type; + pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; + type = (u32) request->type; if (!(memory = drm_alloc_agp(dev, pages, type))) { drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return -ENOMEM; @@ -266,16 +259,40 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, dev->agp->memory->prev = entry; dev->agp->memory = entry; - request.handle = entry->handle; - request.physical = memory->physical; + request->handle = entry->handle; + request->physical = memory->physical; + + return 0; +} +EXPORT_SYMBOL(drm_agp_alloc); + + +int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->head->dev; + drm_agp_buffer_t request; + drm_agp_buffer_t __user *argp = (void __user *)arg; + int err; + + if (copy_from_user(&request, argp, sizeof(request))) + return -EFAULT; + + err = drm_agp_alloc(dev, &request); + if (err) + return err; if (copy_to_user(argp, &request, sizeof(request))) { + drm_agp_mem_t *entry = dev->agp->memory; + dev->agp->memory = entry->next; dev->agp->memory->prev = NULL; - drm_free_agp(memory, pages); + drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return -EFAULT; } + return 0; } @@ -312,21 +329,14 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev, * Verifies the AGP device is present and acquired, looks-up the AGP memory * entry and passes it to the unbind_agp() function. */ -int drm_agp_unbind(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->head->dev; - drm_agp_binding_t request; drm_agp_mem_t *entry; int ret; if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (copy_from_user - (&request, (drm_agp_binding_t __user *) arg, sizeof(request))) - return -EFAULT; - if (!(entry = drm_agp_lookup_entry(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request->handle))) return -EINVAL; if (!entry->bound) return -EINVAL; @@ -335,6 +345,23 @@ int drm_agp_unbind(struct inode *inode, struct file *filp, entry->bound = 0; return ret; } +EXPORT_SYMBOL(drm_agp_unbind); + + +int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->head->dev; + drm_agp_binding_t request; + + if (copy_from_user + (&request, (drm_agp_binding_t __user *) arg, sizeof(request))) + return -EFAULT; + + return drm_agp_unbind(dev, &request); +} + /** * Bind AGP memory into the GATT (ioctl) @@ -349,26 +376,19 @@ int drm_agp_unbind(struct inode *inode, struct file *filp, * is currently bound into the GATT. Looks-up the AGP memory entry and passes * it to bind_agp() function. */ -int drm_agp_bind(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->head->dev; - drm_agp_binding_t request; drm_agp_mem_t *entry; int retcode; int page; if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (copy_from_user - (&request, (drm_agp_binding_t __user *) arg, sizeof(request))) - return -EFAULT; - if (!(entry = drm_agp_lookup_entry(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request->handle))) return -EINVAL; if (entry->bound) return -EINVAL; - page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE; + page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; if ((retcode = drm_bind_agp(entry->memory, page))) return retcode; entry->bound = dev->agp->base + (page << PAGE_SHIFT); @@ -376,6 +396,23 @@ int drm_agp_bind(struct inode *inode, struct file *filp, dev->agp->base, entry->bound); return 0; } +EXPORT_SYMBOL(drm_agp_bind); + + +int drm_agp_bind_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->head->dev; + drm_agp_binding_t request; + + if (copy_from_user + (&request, (drm_agp_binding_t __user *) arg, sizeof(request))) + return -EFAULT; + + return drm_agp_bind(dev, &request); +} + /** * Free AGP memory (ioctl). @@ -391,20 +428,13 @@ int drm_agp_bind(struct inode *inode, struct file *filp, * unbind_agp(). Frees it via free_agp() as well as the entry itself * and unlinks from the doubly linked list it's inserted in. */ -int drm_agp_free(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->head->dev; - drm_agp_buffer_t request; drm_agp_mem_t *entry; if (!dev->agp || !dev->agp->acquired) return -EINVAL; - if (copy_from_user - (&request, (drm_agp_buffer_t __user *) arg, sizeof(request))) - return -EFAULT; - if (!(entry = drm_agp_lookup_entry(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request->handle))) return -EINVAL; if (entry->bound) drm_unbind_agp(entry->memory); @@ -421,6 +451,24 @@ int drm_agp_free(struct inode *inode, struct file *filp, drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return 0; } +EXPORT_SYMBOL(drm_agp_free); + + + +int drm_agp_free_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->head->dev; + drm_agp_buffer_t request; + + if (copy_from_user + (&request, (drm_agp_buffer_t __user *) arg, sizeof(request))) + return -EFAULT; + + return drm_agp_free(dev, &request); +} + /** * Initialize the AGP resources. diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index e9e4a356..5e1fca18 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -694,6 +694,8 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) } dma->buf_count += entry->buf_count; + dma->seg_count += entry->seg_count; + dma->page_count += byte_count >> PAGE_SHIFT; dma->byte_count += byte_count; DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); @@ -1077,6 +1079,8 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) } dma->buf_count += entry->buf_count; + dma->seg_count += entry->seg_count; + dma->page_count += byte_count >> PAGE_SHIFT; dma->byte_count += byte_count; DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); @@ -1236,6 +1240,8 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) } dma->buf_count += entry->buf_count; + dma->seg_count += entry->seg_count; + dma->page_count += byte_count >> PAGE_SHIFT; dma->byte_count += byte_count; DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); diff --git a/linux-core/drm_core.h b/linux-core/drm_core.h index ff76497e..a9a851b7 100644 --- a/linux-core/drm_core.h +++ b/linux-core/drm_core.h @@ -27,11 +27,11 @@ #define CORE_NAME "drm" #define CORE_DESC "DRM shared core routines" -#define CORE_DATE "20040925" +#define CORE_DATE "20051102" #define DRM_IF_MAJOR 1 #define DRM_IF_MINOR 2 #define CORE_MAJOR 1 #define CORE_MINOR 0 -#define CORE_PATCHLEVEL 0 +#define CORE_PATCHLEVEL 1 diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index a845ae71..1e711c08 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -109,10 +109,10 @@ drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, #endif [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 69610046..9125cd47 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -162,27 +162,23 @@ DRM_AGP_MEM *drm_alloc_agp(drm_device_t *dev, int pages, u32 type) return drm_agp_allocate_memory(dev->agp->bridge, pages, type); } #endif -EXPORT_SYMBOL(drm_alloc_agp); /** Wrapper around agp_free_memory() */ int drm_free_agp(DRM_AGP_MEM * handle, int pages) { return drm_agp_free_memory(handle) ? 0 : -EINVAL; } -EXPORT_SYMBOL(drm_free_agp); /** Wrapper around agp_bind_memory() */ int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start) { return drm_agp_bind_memory(handle, start); } -EXPORT_SYMBOL(drm_bind_agp); /** Wrapper around agp_unbind_memory() */ int drm_unbind_agp(DRM_AGP_MEM * handle) { return drm_agp_unbind_memory(handle); } -EXPORT_SYMBOL(drm_unbind_agp); #endif /* agp */ #endif /* debug_memory */ diff --git a/linux-core/drm_memory_debug.c b/linux-core/drm_memory_debug.c index 2ce2abcd..2fe7aeaa 100644 --- a/linux-core/drm_memory_debug.c +++ b/linux-core/drm_memory_debug.c @@ -391,7 +391,6 @@ DRM_AGP_MEM *drm_alloc_agp(drm_device_t *dev, int pages, u32 type) spin_unlock(&drm_mem_lock); return NULL; } -EXPORT_SYMBOL(drm_alloc_agp); int drm_free_agp(DRM_AGP_MEM * handle, int pages) { @@ -421,7 +420,6 @@ int drm_free_agp(DRM_AGP_MEM * handle, int pages) } return retval; } -EXPORT_SYMBOL(drm_free_agp); int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start) { @@ -446,7 +444,6 @@ int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start) spin_unlock(&drm_mem_lock); return retcode; } -EXPORT_SYMBOL(drm_bind_agp); int drm_unbind_agp(DRM_AGP_MEM * handle) { @@ -475,7 +472,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) } return retcode; } -EXPORT_SYMBOL(drm_unbind_agp); #endif #endif -- cgit v1.2.3