aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/drmP.h5
-rw-r--r--linux-core/drm_scatter.c29
2 files changed, 22 insertions, 12 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 2bbc6200..ebb530bc 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1135,8 +1135,9 @@ extern void drm_sg_cleanup(drm_sg_mem_t * entry);
extern int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_sg_alloc(drm_device_t *dev, drm_scatter_gather_t * request);
-extern int drm_sg_free(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg);
+extern int drm_sg_free(struct drm_device *dev, unsigned long handle);
+extern int drm_sg_free_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
/* ATI PCIGART support (ati_pcigart.h) */
extern int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
diff --git a/linux-core/drm_scatter.c b/linux-core/drm_scatter.c
index c0d6db24..5581dc0b 100644
--- a/linux-core/drm_scatter.c
+++ b/linux-core/drm_scatter.c
@@ -203,6 +203,7 @@ int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
if (copy_to_user(argp, &request, sizeof(request))) {
drm_sg_cleanup(priv->head->dev->sg);
+ priv->head->dev->sg = NULL;
return -EFAULT;
}
@@ -211,26 +212,18 @@ int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
}
-int drm_sg_free(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+int drm_sg_free(struct drm_device *dev, unsigned long handle)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->head->dev;
- drm_scatter_gather_t request;
drm_sg_mem_t *entry;
if (!drm_core_check_feature(dev, DRIVER_SG))
return -EINVAL;
- if (copy_from_user(&request,
- (drm_scatter_gather_t __user *) arg,
- sizeof(request)))
- return -EFAULT;
entry = dev->sg;
dev->sg = NULL;
- if (!entry || entry->handle != request.handle)
+ if (!entry || entry->handle != handle)
return -EINVAL;
DRM_DEBUG("sg free virtual = %p\n", entry->virtual);
@@ -239,3 +232,19 @@ int drm_sg_free(struct inode *inode, struct file *filp,
return 0;
}
+
+EXPORT_SYMBOL(drm_sg_free);
+
+int drm_sg_free_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ struct drm_file *priv = filp->private_data;
+ struct drm_device *dev = priv->head->dev;
+ struct drm_scatter_gather __user *argp = (void __user *)arg;
+ struct drm_scatter_gather request;
+
+ if (copy_from_user(&request, argp, sizeof(request)))
+ return -EFAULT;
+
+ return drm_sg_free(dev, request.handle);
+}