summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-07-31 13:13:21 +1000
committerDave Airlie <airlied@redhat.com>2008-07-31 13:31:30 +1000
commitd2d7f3069dac4bc5ddd3c8da4d3955f690274276 (patch)
tree7f612edd83232154129fdab69ca87a800e48592f
parent55761b2fe706f8f68ca3a8827b950fd01af1650b (diff)
drm: userspace rip out TTM API
-rw-r--r--libdrm/intel/intel_bufmgr_fake.c2
-rw-r--r--libdrm/xf86drm.c530
-rw-r--r--linux-core/drm_bo.c5
-rw-r--r--linux-core/drm_objects.h17
-rw-r--r--linux-core/drm_vm.c6
-rw-r--r--shared-core/i915_dma.c1
6 files changed, 3 insertions, 558 deletions
diff --git a/libdrm/intel/intel_bufmgr_fake.c b/libdrm/intel/intel_bufmgr_fake.c
index e988eb58..e7ed893f 100644
--- a/libdrm/intel/intel_bufmgr_fake.c
+++ b/libdrm/intel/intel_bufmgr_fake.c
@@ -649,7 +649,7 @@ intel_bo_fake_alloc_static(dri_bufmgr *bufmgr, const char *name,
bo_fake->refcount = 1;
bo_fake->id = ++bufmgr_fake->buf_nr;
bo_fake->name = name;
- bo_fake->flags = BM_PINNED | DRM_BO_FLAG_NO_MOVE;
+ bo_fake->flags = BM_PINNED;
bo_fake->is_static = 1;
DBG("drm_bo_alloc_static: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 4b4d009b..1fd3a697 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2357,165 +2357,6 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
}
-/*
- * Valid flags are
- * DRM_FENCE_FLAG_EMIT
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-int drmFenceCreate(int fd, unsigned flags, int fence_class, unsigned type,
- drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.flags = flags;
- arg.type = type;
- arg.fence_class = fence_class;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_CREATE, &arg))
- return -errno;
- fence->handle = arg.handle;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->flags = arg.flags;
- fence->signaled = 0;
- return 0;
-}
-
-/*
- * Valid flags are
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.flags = flags;
- arg.fence_class = fence_class;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_BUFFERS, &arg))
- return -errno;
- fence->handle = arg.handle;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->flags = arg.flags;
- fence->sequence = arg.sequence;
- fence->signaled = 0;
- return 0;
-}
-
-int drmFenceReference(int fd, unsigned handle, drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = handle;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_REFERENCE, &arg))
- return -errno;
- fence->handle = arg.handle;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->flags = arg.flags;
- fence->signaled = arg.signaled;
- return 0;
-}
-
-int drmFenceUnreference(int fd, const drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = fence->handle;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_UNREFERENCE, &arg))
- return -errno;
- return 0;
-}
-
-int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = fence->handle;
- arg.type = flush_type;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_FLUSH, &arg))
- return -errno;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->signaled = arg.signaled;
- return arg.error;
-}
-
-int drmFenceUpdate(int fd, drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = fence->handle;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_SIGNALED, &arg))
- return -errno;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->signaled = arg.signaled;
- return 0;
-}
-
-int drmFenceSignaled(int fd, drmFence *fence, unsigned fenceType,
- int *signaled)
-{
- if ((fence->flags & DRM_FENCE_FLAG_SHAREABLE) ||
- ((fenceType & fence->signaled) != fenceType)) {
- int ret = drmFenceFlush(fd, fence, fenceType);
- if (ret)
- return ret;
- }
-
- *signaled = ((fenceType & fence->signaled) == fenceType);
-
- return 0;
-}
-
-/*
- * Valid flags are
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-
-int drmFenceEmit(int fd, unsigned flags, drmFence *fence, unsigned emit_type)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.fence_class = fence->fence_class;
- arg.flags = flags;
- arg.handle = fence->handle;
- arg.type = emit_type;
-
- if (drmIoctl(fd, DRM_IOCTL_FENCE_EMIT, &arg))
- return -errno;
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->signaled = arg.signaled;
- fence->sequence = arg.sequence;
- return 0;
-}
-
-/*
- * Valid flags are
- * DRM_FENCE_FLAG_WAIT_LAZY
- * DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS
- */
-
#define DRM_IOCTL_TIMEOUT_USEC 3000000UL
static unsigned long
@@ -2558,377 +2399,6 @@ drmIoctlTimeout(int fd, unsigned long request, void *argp)
-
-int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
-{
- drm_fence_arg_t arg;
- int ret;
-
- if (flush_type == 0) {
- flush_type = fence->type;
- }
-
- if (!(fence->flags & DRM_FENCE_FLAG_SHAREABLE)) {
- if ((flush_type & fence->signaled) == flush_type) {
- return 0;
- }
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = fence->handle;
- arg.type = flush_type;
- arg.flags = flags;
-
-
- ret = drmIoctlTimeout(fd, DRM_IOCTL_FENCE_WAIT, &arg);
- if (ret)
- return ret;
-
- fence->fence_class = arg.fence_class;
- fence->type = arg.type;
- fence->signaled = arg.signaled;
- return arg.error;
-}
-
-static void drmBOCopyReply(const struct drm_bo_info_rep *rep, drmBO *buf)
-{
- buf->handle = rep->handle;
- buf->flags = rep->flags;
- buf->size = rep->size;
- buf->offset = rep->offset;
- buf->mapHandle = rep->arg_handle;
- buf->proposedFlags = rep->proposed_flags;
- buf->start = rep->buffer_start;
- buf->fenceFlags = rep->fence_flags;
- buf->replyFlags = rep->rep_flags;
- buf->pageAlignment = rep->page_alignment;
- buf->tileInfo = rep->tile_info;
- buf->hwTileStride = rep->hw_tile_stride;
- buf->desiredTileStride = rep->desired_tile_stride;
-}
-
-
-
-int drmBOCreate(int fd, unsigned long size,
- unsigned pageAlignment, void *user_buffer,
- uint64_t flags,
- unsigned hint, drmBO *buf)
-{
- struct drm_bo_create_arg arg;
- struct drm_bo_create_req *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
- int ret;
-
- memset(buf, 0, sizeof(*buf));
- memset(&arg, 0, sizeof(arg));
- req->flags = flags;
- req->hint = hint;
- req->size = size;
- req->page_alignment = pageAlignment;
- req->buffer_start = (unsigned long) user_buffer;
-
- buf->virtual = NULL;
-
- ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_CREATE, &arg);
- if (ret)
- return ret;
-
- drmBOCopyReply(rep, buf);
- buf->virtual = user_buffer;
- buf->mapCount = 0;
-
- return 0;
-}
-
-int drmBOReference(int fd, unsigned handle, drmBO *buf)
-{
- struct drm_bo_reference_info_arg arg;
- struct drm_bo_handle_arg *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
-
- memset(&arg, 0, sizeof(arg));
- req->handle = handle;
-
- if (drmIoctl(fd, DRM_IOCTL_BO_REFERENCE, &arg))
- return -errno;
-
- drmBOCopyReply(rep, buf);
- buf->mapVirtual = NULL;
- buf->mapCount = 0;
- buf->virtual = NULL;
-
- return 0;
-}
-
-int drmBOUnreference(int fd, drmBO *buf)
-{
- struct drm_bo_handle_arg arg;
-
- if (buf->mapVirtual && buf->mapHandle) {
- (void) munmap(buf->mapVirtual, buf->start + buf->size);
- buf->mapVirtual = NULL;
- buf->virtual = NULL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = buf->handle;
-
- if (drmIoctl(fd, DRM_IOCTL_BO_UNREFERENCE, &arg))
- return -errno;
-
- buf->handle = 0;
- return 0;
-}
-
-
-/*
- * Flags can be DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE or'ed together
- * Hint currently be DRM_BO_HINT_DONT_BLOCK, which makes the
- * call return an -EBUSY if it can' immediately honor the mapping request.
- */
-
-int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
- void **address)
-{
- struct drm_bo_map_wait_idle_arg arg;
- struct drm_bo_info_req *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
- int ret = 0;
-
- /*
- * Make sure we have a virtual address of the buffer.
- */
-
- if (!buf->virtual) {
- drmAddress virtual;
- virtual = mmap(0, buf->size + buf->start,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, buf->mapHandle);
- if (virtual == MAP_FAILED) {
- ret = -errno;
- }
- if (ret)
- return ret;
- buf->mapVirtual = virtual;
- buf->virtual = ((char *) virtual) + buf->start;
- }
-
- memset(&arg, 0, sizeof(arg));
- req->handle = buf->handle;
- req->mask = mapFlags;
- req->hint = mapHint;
-
- /*
- * May hang if the buffer object is busy.
- * This IOCTL synchronizes the buffer.
- */
-
- ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_MAP, &arg);
- if (ret)
- return ret;
-
- drmBOCopyReply(rep, buf);
- buf->mapFlags = mapFlags;
- ++buf->mapCount;
- *address = buf->virtual;
-
- return 0;
-}
-
-
-int drmBOUnmap(int fd, drmBO *buf)
-{
- struct drm_bo_handle_arg arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = buf->handle;
-
- if (drmIoctl(fd, DRM_IOCTL_BO_UNMAP, &arg)) {
- return -errno;
- }
- buf->mapCount--;
- return 0;
-}
-
-int drmBOSetStatus(int fd, drmBO *buf,
- uint64_t flags, uint64_t mask,
- unsigned int hint,
- unsigned int desired_tile_stride,
- unsigned int tile_info)
-{
-
- struct drm_bo_map_wait_idle_arg arg;
- struct drm_bo_info_req *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
- int ret = 0;
-
- memset(&arg, 0, sizeof(arg));
- req->mask = mask;
- req->flags = flags;
- req->handle = buf->handle;
- req->hint = hint;
- req->desired_tile_stride = desired_tile_stride;
- req->tile_info = tile_info;
-
- ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_SETSTATUS, &arg);
- if (ret)
- return ret;
-
- drmBOCopyReply(rep, buf);
- return 0;
-}
-
-
-int drmBOInfo(int fd, drmBO *buf)
-{
- struct drm_bo_reference_info_arg arg;
- struct drm_bo_handle_arg *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
- int ret = 0;
-
- memset(&arg, 0, sizeof(arg));
- req->handle = buf->handle;
-
- ret = drmIoctl(fd, DRM_IOCTL_BO_INFO, &arg);
- if (ret)
- return -errno;
-
- drmBOCopyReply(rep, buf);
- return 0;
-}
-
-int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
-{
- struct drm_bo_map_wait_idle_arg arg;
- struct drm_bo_info_req *req = &arg.d.req;
- struct drm_bo_info_rep *rep = &arg.d.rep;
- int ret = 0;
-
- if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
- (buf->replyFlags & DRM_BO_REP_BUSY)) {
- memset(&arg, 0, sizeof(arg));
- req->handle = buf->handle;
- req->hint = hint;
-
- ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_WAIT_IDLE, &arg);
- if (ret)
- return ret;
-
- drmBOCopyReply(rep, buf);
- }
- return 0;
-}
-
-int drmBOBusy(int fd, drmBO *buf, int *busy)
-{
- int ret = drmBOInfo(fd, buf);
-
- if (ret)
- return ret;
-
- *busy = (buf->replyFlags & DRM_BO_REP_BUSY);
- return 0;
-}
-
-int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
- unsigned memType)
-{
- struct drm_mm_init_arg arg;
-
- memset(&arg, 0, sizeof(arg));
-
- arg.magic = DRM_BO_INIT_MAGIC;
- arg.major = DRM_BO_INIT_MAJOR;
- arg.minor = DRM_BO_INIT_MINOR;
- arg.p_offset = pOffset;
- arg.p_size = pSize;
- arg.mem_type = memType;
-
- if (drmIoctl(fd, DRM_IOCTL_MM_INIT, &arg))
- return -errno;
- return 0;
-}
-
-int drmMMTakedown(int fd, unsigned memType)
-{
- struct drm_mm_type_arg arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.mem_type = memType;
-
- if (drmIoctl(fd, DRM_IOCTL_MM_TAKEDOWN, &arg))
- return -errno;
- return 0;
-}
-
-/*
- * If this function returns an error, and lockBM was set to 1,
- * the buffer manager is NOT locked.
- */
-
-int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict)
-{
- struct drm_mm_type_arg arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.mem_type = memType;
- arg.lock_flags |= (lockBM) ? DRM_BO_LOCK_UNLOCK_BM : 0;
- arg.lock_flags |= (ignoreNoEvict) ? DRM_BO_LOCK_IGNORE_NO_EVICT : 0;
-
- return drmIoctlTimeout(fd, DRM_IOCTL_MM_LOCK, &arg);
-}
-
-int drmMMUnlock(int fd, unsigned memType, int unlockBM)
-{
- struct drm_mm_type_arg arg;
-
- memset(&arg, 0, sizeof(arg));
-
- arg.mem_type = memType;
- arg.lock_flags |= (unlockBM) ? DRM_BO_LOCK_UNLOCK_BM : 0;
-
- return drmIoctlTimeout(fd, DRM_IOCTL_MM_UNLOCK, &arg);
-}
-
-int drmMMInfo(int fd, unsigned memType, uint64_t *size)
-{
- struct drm_mm_info_arg arg;
-
- memset(&arg, 0, sizeof(arg));
-
- arg.mem_type = memType;
-
- if (drmIoctl(fd, DRM_IOCTL_MM_INFO, &arg))
- return -errno;
-
- *size = arg.p_size;
- return 0;
-}
-
-int drmBOVersion(int fd, unsigned int *major,
- unsigned int *minor,
- unsigned int *patchlevel)
-{
- struct drm_bo_version_arg arg;
- int ret;
-
- memset(&arg, 0, sizeof(arg));
- ret = drmIoctl(fd, DRM_IOCTL_BO_VERSION, &arg);
- if (ret)
- return -errno;
-
- if (major)
- *major = arg.major;
- if (minor)
- *minor = arg.minor;
- if (patchlevel)
- *patchlevel = arg.patchlevel;
-
- return 0;
-}
-
-
-
#define DRM_MAX_FDS 16
static struct {
char *BusID;
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index 84cf69bd..a1c1be89 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -1061,7 +1061,7 @@ static int drm_bo_modify_proposed_flags (struct drm_buffer_object *bo,
* Doesn't do any fence flushing as opposed to the drm_bo_busy function.
*/
-static int drm_bo_quick_busy(struct drm_buffer_object *bo, int check_unfenced)
+int drm_bo_quick_busy(struct drm_buffer_object *bo, int check_unfenced)
{
struct drm_fence_object *fence = bo->fence;
@@ -1712,7 +1712,7 @@ EXPORT_SYMBOL(drm_bo_clean_mm);
*point since we have the hardware lock.
*/
-static int drm_bo_lock_mm(struct drm_device *dev, unsigned mem_type)
+int drm_bo_lock_mm(struct drm_device *dev, unsigned mem_type)
{
int ret;
struct drm_buffer_manager *bm = &dev->bm;
@@ -1861,7 +1861,6 @@ int drm_bo_driver_init(struct drm_device *dev)
int ret = -EINVAL;
bm->dummy_read_page = NULL;
- drm_bo_init_lock(&bm->bm_lock);
mutex_lock(&dev->struct_mutex);
if (!driver)
goto out_unlock;
diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h
index 032687f7..a8aa84db 100644
--- a/linux-core/drm_objects.h
+++ b/linux-core/drm_objects.h
@@ -879,23 +879,6 @@ extern int drm_mem_reg_ioremap(struct drm_device *dev, struct drm_bo_mem_reg * m
void **virtual);
extern void drm_mem_reg_iounmap(struct drm_device *dev, struct drm_bo_mem_reg * mem,
void *virtual);
-/*
- * drm_bo_lock.c
- * Simple replacement for the hardware lock on buffer manager init and clean.
- */
-
-
-extern void drm_bo_init_lock(struct drm_bo_lock *lock);
-extern void drm_bo_read_unlock(struct drm_bo_lock *lock);
-extern int drm_bo_read_lock(struct drm_bo_lock *lock,
- int interruptible);
-extern int drm_bo_write_lock(struct drm_bo_lock *lock,
- int interruptible,
- struct drm_file *file_priv);
-
-extern int drm_bo_write_unlock(struct drm_bo_lock *lock,
- struct drm_file *file_priv);
-
#ifdef CONFIG_DEBUG_MUTEXES
#define DRM_ASSERT_LOCKED(_mutex) \
BUG_ON(!mutex_is_locked(_mutex) || \
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 0d5242d3..9a215161 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -715,13 +715,8 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma,
unsigned long ret = VM_FAULT_NOPAGE;
dev = bo->dev;
- err = drm_bo_read_lock(&dev->bm.bm_lock, 1);
- if (err)
- return VM_FAULT_NOPAGE;
-
err = mutex_lock_interruptible(&bo->mutex);
if (err) {
- drm_bo_read_unlock(&dev->bm.bm_lock);
return VM_FAULT_NOPAGE;
}
@@ -788,7 +783,6 @@ static int drm_bo_vm_fault(struct vm_area_struct *vma,
out_unlock:
BUG_ON(bo->priv_flags & _DRM_BO_FLAG_UNLOCKED);
mutex_unlock(&bo->mutex);
- drm_bo_read_unlock(&dev->bm.bm_lock);
return ret;
}
#endif
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 3e6a6626..bd52a057 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -689,7 +689,6 @@ static void i915_do_dispatch_flip(struct drm_device * dev, int plane, int sync)
void i915_dispatch_flip(struct drm_device * dev, int planes, int sync)
{
- struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
int i;