Made drm_sg_alloc accessible from inside the DRM - drm_sg_alloc_ioctl is the ioctl wrapper
parent
023f7d9c00
commit
04e4922c0c
|
@ -915,6 +915,7 @@ int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
|
|||
|
||||
/* Scatter Gather Support (drm_scatter.c) */
|
||||
void drm_sg_cleanup(drm_sg_mem_t *entry);
|
||||
int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request);
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* sysctl support (drm_sysctl.h) */
|
||||
|
@ -989,7 +990,7 @@ int drm_agp_unbind_ioctl(DRM_IOCTL_ARGS);
|
|||
int drm_agp_bind_ioctl(DRM_IOCTL_ARGS);
|
||||
|
||||
/* Scatter Gather Support (drm_scatter.c) */
|
||||
int drm_sg_alloc(DRM_IOCTL_ARGS);
|
||||
int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS);
|
||||
int drm_sg_free(DRM_IOCTL_ARGS);
|
||||
|
||||
/* consistent PCI memory functions (drm_pci.c) */
|
||||
|
|
|
@ -117,7 +117,7 @@ static drm_ioctl_desc_t drm_ioctls[256] = {
|
|||
[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 },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0 },
|
||||
|
|
|
@ -40,28 +40,20 @@ void drm_sg_cleanup(drm_sg_mem_t *entry)
|
|||
free(entry, M_DRM);
|
||||
}
|
||||
|
||||
int drm_sg_alloc(DRM_IOCTL_ARGS)
|
||||
int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_scatter_gather_t request;
|
||||
drm_sg_mem_t *entry;
|
||||
unsigned long pages;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG( "%s\n", __FUNCTION__ );
|
||||
|
||||
if ( dev->sg )
|
||||
return EINVAL;
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
|
||||
sizeof(request) );
|
||||
|
||||
entry = malloc(sizeof(*entry), M_DRM, M_WAITOK | M_ZERO);
|
||||
if ( !entry )
|
||||
return ENOMEM;
|
||||
|
||||
pages = round_page(request.size) / PAGE_SIZE;
|
||||
DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
|
||||
DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages );
|
||||
|
||||
entry->pages = pages;
|
||||
|
||||
|
@ -86,11 +78,7 @@ int drm_sg_alloc(DRM_IOCTL_ARGS)
|
|||
DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );
|
||||
|
||||
entry->virtual = (void *)entry->handle;
|
||||
request.handle = entry->handle;
|
||||
|
||||
DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data,
|
||||
request,
|
||||
sizeof(request) );
|
||||
request->handle = entry->handle;
|
||||
|
||||
DRM_LOCK();
|
||||
if (dev->sg) {
|
||||
|
@ -101,6 +89,27 @@ int drm_sg_alloc(DRM_IOCTL_ARGS)
|
|||
dev->sg = entry;
|
||||
DRM_UNLOCK();
|
||||
|
||||
}
|
||||
|
||||
int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS)
|
||||
{
|
||||
DRM_DEVICE;
|
||||
drm_scatter_gather_t request;
|
||||
int ret;
|
||||
|
||||
DRM_DEBUG( "%s\n", __FUNCTION__ );
|
||||
|
||||
|
||||
DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
|
||||
sizeof(request) );
|
||||
|
||||
ret = drm_sg_alloc(dev, &request);
|
||||
if ( ret ) return ret;
|
||||
|
||||
DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data,
|
||||
request,
|
||||
sizeof(request) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1129,8 +1129,9 @@ extern int drm_proc_cleanup(int minor,
|
|||
|
||||
/* Scatter Gather Support (drm_scatter.h) */
|
||||
extern void drm_sg_cleanup(drm_sg_mem_t * entry);
|
||||
extern int drm_sg_alloc(struct inode *inode, struct file *filp,
|
||||
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);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ static drm_ioctl_desc_t drm_ioctls[] = {
|
|||
[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},
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0},
|
||||
|
|
|
@ -55,6 +55,7 @@ void drm_sg_cleanup(drm_sg_mem_t * entry)
|
|||
entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES);
|
||||
drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sg_cleanup);
|
||||
|
||||
#ifdef _LP64
|
||||
# define ScatterHandle(x) (unsigned int)((x >> 32) + (x & ((1L << 32) - 1)))
|
||||
|
@ -62,13 +63,8 @@ void drm_sg_cleanup(drm_sg_mem_t * entry)
|
|||
# define ScatterHandle(x) (unsigned int)(x)
|
||||
#endif
|
||||
|
||||
int drm_sg_alloc(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
drm_device_t *dev = priv->head->dev;
|
||||
drm_scatter_gather_t __user *argp = (void __user *)arg;
|
||||
drm_scatter_gather_t request;
|
||||
drm_sg_mem_t *entry;
|
||||
unsigned long pages, i, j;
|
||||
|
||||
|
@ -80,17 +76,13 @@ int drm_sg_alloc(struct inode *inode, struct file *filp,
|
|||
if (dev->sg)
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&request, argp, sizeof(request)))
|
||||
return -EFAULT;
|
||||
|
||||
entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
|
||||
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
DRM_DEBUG("sg size=%ld pages=%ld\n", request.size, pages);
|
||||
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages);
|
||||
|
||||
entry->pages = pages;
|
||||
entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist),
|
||||
|
@ -142,12 +134,7 @@ int drm_sg_alloc(struct inode *inode, struct file *filp,
|
|||
SetPageReserved(entry->pagelist[j]);
|
||||
}
|
||||
|
||||
request.handle = entry->handle;
|
||||
|
||||
if (copy_to_user(argp, &request, sizeof(request))) {
|
||||
drm_sg_cleanup(entry);
|
||||
return -EFAULT;
|
||||
}
|
||||
request->handle = entry->handle;
|
||||
|
||||
dev->sg = entry;
|
||||
|
||||
|
@ -196,6 +183,32 @@ int drm_sg_alloc(struct inode *inode, struct file *filp,
|
|||
failed:
|
||||
drm_sg_cleanup(entry);
|
||||
return -ENOMEM;
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sg_alloc);
|
||||
|
||||
int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
drm_scatter_gather_t __user *argp = (void __user *)arg;
|
||||
drm_scatter_gather_t request;
|
||||
int ret;
|
||||
|
||||
if (copy_from_user(&request, argp, sizeof(request)))
|
||||
return -EFAULT;
|
||||
|
||||
ret = drm_sg_alloc(priv->head->dev, &request);
|
||||
if ( ret ) return ret;
|
||||
|
||||
if (copy_to_user(argp, &request, sizeof(request))) {
|
||||
drm_sg_cleanup(priv->head->dev->sg);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int drm_sg_free(struct inode *inode, struct file *filp,
|
||||
|
|
Loading…
Reference in New Issue