mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-04-28 21:50:43 +02:00
Move the excitingly named DRM(flush_block_and_flush) and friends to
gamma-specific code. Fix templates so i8x0 drivers don't have to define __HAVE_DMA_WAITLIST.
This commit is contained in:
parent
aba6bf7eb3
commit
928c25d14f
9 changed files with 32 additions and 243 deletions
|
|
@ -768,12 +768,11 @@ extern int DRM(getmagic)(struct inode *inode, struct file *filp,
|
|||
extern int DRM(authmagic)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* Placeholder for ioctls past */
|
||||
extern int DRM(noop)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* Locking IOCTL support (drm_lock.h) */
|
||||
extern int DRM(block)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int DRM(unblock)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int DRM(lock_take)(__volatile__ unsigned int *lock,
|
||||
unsigned int context);
|
||||
extern int DRM(lock_transfer)(drm_device_t *dev,
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
|
|||
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
|
||||
|
|
@ -187,7 +187,13 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
|
|||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 },
|
||||
|
||||
#if __HAVE_DMA_FLUSH
|
||||
/* Gamma only, really */
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 },
|
||||
#else
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
|
||||
#endif
|
||||
|
||||
#if __HAVE_DMA
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
|
||||
|
|
@ -470,7 +476,9 @@ static int DRM(takedown)( drm_device_t *dev )
|
|||
#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
|
||||
if ( dev->queuelist ) {
|
||||
for ( i = 0 ; i < dev->queue_count ; i++ ) {
|
||||
#if __HAVE_DMA_WAITLIST
|
||||
DRM(waitlist_destroy)( &dev->queuelist[i]->waitlist );
|
||||
#endif
|
||||
if ( dev->queuelist[i] ) {
|
||||
DRM(free)( dev->queuelist[i],
|
||||
sizeof(*dev->queuelist[0]),
|
||||
|
|
|
|||
|
|
@ -32,19 +32,13 @@
|
|||
#define __NO_VERSION__
|
||||
#include "drmP.h"
|
||||
|
||||
int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
DRM_DEBUG("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
DRM_DEBUG("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
|
||||
{
|
||||
|
|
@ -109,113 +103,6 @@ int DRM(lock_free)(drm_device_t *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int DRM(flush_queue)(drm_device_t *dev, int context)
|
||||
{
|
||||
DECLARE_WAITQUEUE(entry, current);
|
||||
int ret = 0;
|
||||
drm_queue_t *q = dev->queuelist[context];
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
atomic_inc(&q->use_count);
|
||||
if (atomic_read(&q->use_count) > 1) {
|
||||
atomic_inc(&q->block_write);
|
||||
add_wait_queue(&q->flush_queue, &entry);
|
||||
atomic_inc(&q->block_count);
|
||||
for (;;) {
|
||||
current->state = TASK_INTERRUPTIBLE;
|
||||
if (!DRM_BUFCOUNT(&q->waitlist)) break;
|
||||
schedule();
|
||||
if (signal_pending(current)) {
|
||||
ret = -EINTR; /* Can't restart */
|
||||
break;
|
||||
}
|
||||
}
|
||||
atomic_dec(&q->block_count);
|
||||
current->state = TASK_RUNNING;
|
||||
remove_wait_queue(&q->flush_queue, &entry);
|
||||
}
|
||||
atomic_dec(&q->use_count);
|
||||
|
||||
/* NOTE: block_write is still incremented!
|
||||
Use drm_flush_unlock_queue to decrement. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int DRM(flush_unblock_queue)(drm_device_t *dev, int context)
|
||||
{
|
||||
drm_queue_t *q = dev->queuelist[context];
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
atomic_inc(&q->use_count);
|
||||
if (atomic_read(&q->use_count) > 1) {
|
||||
if (atomic_read(&q->block_write)) {
|
||||
atomic_dec(&q->block_write);
|
||||
wake_up_interruptible(&q->write_queue);
|
||||
}
|
||||
}
|
||||
atomic_dec(&q->use_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
|
||||
drm_lock_flags_t flags)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (flags & _DRM_LOCK_FLUSH) {
|
||||
ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT);
|
||||
if (!ret) ret = DRM(flush_queue)(dev, context);
|
||||
}
|
||||
if (flags & _DRM_LOCK_FLUSH_ALL) {
|
||||
for (i = 0; !ret && i < dev->queue_count; i++) {
|
||||
ret = DRM(flush_queue)(dev, i);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (flags & _DRM_LOCK_FLUSH) {
|
||||
ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT);
|
||||
if (!ret) ret = DRM(flush_unblock_queue)(dev, context);
|
||||
}
|
||||
if (flags & _DRM_LOCK_FLUSH_ALL) {
|
||||
for (i = 0; !ret && i < dev->queue_count; i++) {
|
||||
ret = DRM(flush_unblock_queue)(dev, i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
drm_device_t *dev = priv->dev;
|
||||
int ret = 0;
|
||||
drm_lock_t lock;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
|
||||
return -EFAULT;
|
||||
ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags);
|
||||
DRM(flush_unblock)(dev, lock.context, lock.flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* If we get here, it means that the process has called DRM_IOCTL_LOCK
|
||||
without calling DRM_IOCTL_UNLOCK.
|
||||
|
||||
|
|
|
|||
|
|
@ -768,12 +768,11 @@ extern int DRM(getmagic)(struct inode *inode, struct file *filp,
|
|||
extern int DRM(authmagic)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* Placeholder for ioctls past */
|
||||
extern int DRM(noop)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* Locking IOCTL support (drm_lock.h) */
|
||||
extern int DRM(block)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int DRM(unblock)(struct inode *inode, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern int DRM(lock_take)(__volatile__ unsigned int *lock,
|
||||
unsigned int context);
|
||||
extern int DRM(lock_transfer)(drm_device_t *dev,
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
|
|||
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 },
|
||||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
|
||||
|
|
@ -187,7 +187,13 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
|
|||
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 },
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 },
|
||||
|
||||
#if __HAVE_DMA_FLUSH
|
||||
/* Gamma only, really */
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 },
|
||||
#else
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
|
||||
#endif
|
||||
|
||||
#if __HAVE_DMA
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
|
||||
|
|
@ -470,7 +476,9 @@ static int DRM(takedown)( drm_device_t *dev )
|
|||
#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
|
||||
if ( dev->queuelist ) {
|
||||
for ( i = 0 ; i < dev->queue_count ; i++ ) {
|
||||
#if __HAVE_DMA_WAITLIST
|
||||
DRM(waitlist_destroy)( &dev->queuelist[i]->waitlist );
|
||||
#endif
|
||||
if ( dev->queuelist[i] ) {
|
||||
DRM(free)( dev->queuelist[i],
|
||||
sizeof(*dev->queuelist[0]),
|
||||
|
|
|
|||
115
linux/drm_lock.h
115
linux/drm_lock.h
|
|
@ -32,19 +32,13 @@
|
|||
#define __NO_VERSION__
|
||||
#include "drmP.h"
|
||||
|
||||
int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
DRM_DEBUG("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
DRM_DEBUG("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
|
||||
{
|
||||
|
|
@ -109,113 +103,6 @@ int DRM(lock_free)(drm_device_t *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int DRM(flush_queue)(drm_device_t *dev, int context)
|
||||
{
|
||||
DECLARE_WAITQUEUE(entry, current);
|
||||
int ret = 0;
|
||||
drm_queue_t *q = dev->queuelist[context];
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
atomic_inc(&q->use_count);
|
||||
if (atomic_read(&q->use_count) > 1) {
|
||||
atomic_inc(&q->block_write);
|
||||
add_wait_queue(&q->flush_queue, &entry);
|
||||
atomic_inc(&q->block_count);
|
||||
for (;;) {
|
||||
current->state = TASK_INTERRUPTIBLE;
|
||||
if (!DRM_BUFCOUNT(&q->waitlist)) break;
|
||||
schedule();
|
||||
if (signal_pending(current)) {
|
||||
ret = -EINTR; /* Can't restart */
|
||||
break;
|
||||
}
|
||||
}
|
||||
atomic_dec(&q->block_count);
|
||||
current->state = TASK_RUNNING;
|
||||
remove_wait_queue(&q->flush_queue, &entry);
|
||||
}
|
||||
atomic_dec(&q->use_count);
|
||||
|
||||
/* NOTE: block_write is still incremented!
|
||||
Use drm_flush_unlock_queue to decrement. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int DRM(flush_unblock_queue)(drm_device_t *dev, int context)
|
||||
{
|
||||
drm_queue_t *q = dev->queuelist[context];
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
atomic_inc(&q->use_count);
|
||||
if (atomic_read(&q->use_count) > 1) {
|
||||
if (atomic_read(&q->block_write)) {
|
||||
atomic_dec(&q->block_write);
|
||||
wake_up_interruptible(&q->write_queue);
|
||||
}
|
||||
}
|
||||
atomic_dec(&q->use_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
|
||||
drm_lock_flags_t flags)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (flags & _DRM_LOCK_FLUSH) {
|
||||
ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT);
|
||||
if (!ret) ret = DRM(flush_queue)(dev, context);
|
||||
}
|
||||
if (flags & _DRM_LOCK_FLUSH_ALL) {
|
||||
for (i = 0; !ret && i < dev->queue_count; i++) {
|
||||
ret = DRM(flush_queue)(dev, i);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (flags & _DRM_LOCK_FLUSH) {
|
||||
ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT);
|
||||
if (!ret) ret = DRM(flush_unblock_queue)(dev, context);
|
||||
}
|
||||
if (flags & _DRM_LOCK_FLUSH_ALL) {
|
||||
for (i = 0; !ret && i < dev->queue_count; i++) {
|
||||
ret = DRM(flush_unblock_queue)(dev, i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
drm_device_t *dev = priv->dev;
|
||||
int ret = 0;
|
||||
drm_lock_t lock;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
|
||||
return -EFAULT;
|
||||
ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags);
|
||||
DRM(flush_unblock)(dev, lock.context, lock.flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* If we get here, it means that the process has called DRM_IOCTL_LOCK
|
||||
without calling DRM_IOCTL_UNLOCK.
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
#include "drm_bufs.h"
|
||||
#include "gamma_context.h" /* NOTE! */
|
||||
#include "drm_dma.h"
|
||||
#include "gamma_old_dma.h"
|
||||
#include "gamma_old_dma.h" /* NOTE */
|
||||
#include "drm_drawable.h"
|
||||
#include "drm_drv.h"
|
||||
|
||||
|
|
@ -50,6 +50,7 @@
|
|||
#include "drm_ioctl.h"
|
||||
#include "drm_lists.h"
|
||||
#include "drm_lock.h"
|
||||
#include "gamma_lock.h" /* NOTE */
|
||||
#include "drm_memory.h"
|
||||
#include "drm_proc.h"
|
||||
#include "drm_vm.h"
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
*/
|
||||
#define __HAVE_DMA 1
|
||||
#define __HAVE_DMA_QUEUE 1
|
||||
#define __HAVE_DMA_WAITLIST 1
|
||||
#define __HAVE_DMA_WAITLIST 0
|
||||
#define __HAVE_DMA_RECLAIM 1
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
*/
|
||||
#define __HAVE_DMA 1
|
||||
#define __HAVE_DMA_QUEUE 1
|
||||
#define __HAVE_DMA_WAITLIST 1
|
||||
#define __HAVE_DMA_WAITLIST 0
|
||||
#define __HAVE_DMA_RECLAIM 1
|
||||
|
||||
#define __HAVE_DMA_QUIESCENT 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue