summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-11 13:40:35 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-11 13:40:35 +0200
commitf2db76e2f206d2017f710eaddc4b33add4498898 (patch)
treea245512bc51f70c4458af047507605a27fae5d02 /libdrm
parentc58574c60505a699e19e1ed59e1b441be2594e53 (diff)
Big update:
Adapt for new functions in the 2.6.19 kernel. Remove the ability to have multiple regions in one TTM. This simplifies a lot of code. Remove the ability to access TTMs from user space. We don't need it anymore without ttm regions. Don't change caching policy for evicted buffers. Instead change it only when the buffer is accessed by the CPU (on the first page fault). This tremendously speeds up eviction rates. Current code is safe for kernels <= 2.6.14. Should also be OK with 2.6.19 and above.
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drm.c82
-rw-r--r--libdrm/xf86mm.h23
2 files changed, 6 insertions, 99 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index bce913d3..a083ca23 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2462,74 +2462,6 @@ int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
return 0;
}
-int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
-{
- drm_ttm_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.op = drm_ttm_create;
- arg.flags = flags;
- arg.size = size;
-
- if (ioctl(fd, DRM_IOCTL_TTM, &arg))
- return -errno;
-
- ttm->handle = arg.handle;
- ttm->user_token = (drm_handle_t) arg.user_token;
- ttm->flags = arg.flags;
- ttm->size = arg.size;
- ttm->virtual = NULL;
- ttm->mapCount = 0;
- return 0;
-}
-
-int drmTTMDestroy(int fd, const drmTTM *ttm)
-{
- drm_ttm_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.op = drm_ttm_destroy;
- arg.handle = ttm->handle;
- if (ioctl(fd, DRM_IOCTL_TTM, &arg))
- return -errno;
- return 0;
-}
-
-
-int drmTTMReference(int fd, unsigned handle, drmTTM *ttm)
-{
- drm_ttm_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = handle;
- arg.op = drm_ttm_reference;
- if (ioctl(fd, DRM_IOCTL_TTM, &arg))
- return -errno;
- ttm->handle = arg.handle;
- ttm->user_token = (drm_handle_t) arg.user_token;
- ttm->flags = arg.flags;
- ttm->size = arg.size;
- return 0;
-}
-
-int drmTTMUnreference(int fd, const drmTTM *ttm)
-{
- drm_ttm_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.op = drm_ttm_destroy;
- arg.handle = ttm->handle;
- if (ioctl(fd, DRM_IOCTL_TTM, &arg))
- return -errno;
- return 0;
-}
-
-drm_handle_t drmTTMMapHandle(int fd, const drmTTM *ttm)
-{
- (void) fd;
- return ttm->user_token;
-}
-
static int drmAdjustListNodes(drmBOList *list)
{
drmBONode *node;
@@ -2685,7 +2617,7 @@ static void drmBOCopyReply(const drm_bo_arg_reply_t *rep,
-int drmBOCreate(int fd, drmTTM *ttm, unsigned long start, unsigned long size,
+int drmBOCreate(int fd, void *ttm, unsigned long start, unsigned long size,
void *user_buffer, drm_bo_type_t type, unsigned mask,
unsigned hint, drmBO *buf)
{
@@ -2700,15 +2632,9 @@ int drmBOCreate(int fd, drmTTM *ttm, unsigned long start, unsigned long size,
req->size = size;
req->type = type;
- buf->ttm = NULL;
buf->virtual = NULL;
switch(type) {
- case drm_bo_type_ttm:
- req->arg_handle = ttm->handle;
- req->buffer_start = start;
- buf->ttm = ttm;
- break;
case drm_bo_type_dc:
req->buffer_start = start;
break;
@@ -2727,10 +2653,10 @@ int drmBOCreate(int fd, drmTTM *ttm, unsigned long start, unsigned long size,
if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
return -errno;
if (!arg.handled) {
- fprintf(stderr, "Not handled\n");
return -EFAULT;
}
if (rep->ret) {
+ fprintf(stderr, "Error %d\n", rep->ret);
return rep->ret;
}
@@ -2853,8 +2779,10 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
virtual = mmap(0, buf->size + buf->start,
PROT_READ | PROT_WRITE, MAP_SHARED,
fd, buf->mapHandle);
- if (virtual == MAP_FAILED)
+ if (virtual == MAP_FAILED) {
ret = -errno;
+ fprintf(stderr, "Map error 0x%016llx\n", buf->mapHandle);
+ }
if (ret)
return ret;
buf->mapVirtual = virtual;
diff --git a/libdrm/xf86mm.h b/libdrm/xf86mm.h
index c0e4f1b6..78df37c3 100644
--- a/libdrm/xf86mm.h
+++ b/libdrm/xf86mm.h
@@ -101,15 +101,6 @@ typedef struct _drmFence{
unsigned signaled;
} drmFence;
-typedef struct _drmTTM{
- unsigned handle;
- drm_u64_t user_token;
- unsigned flags;
- unsigned long size;
- void *virtual;
- int mapCount;
-} drmTTM;
-
typedef struct _drmBO{
drm_bo_type_t type;
unsigned handle;
@@ -125,7 +116,6 @@ typedef struct _drmBO{
void *virtual;
void *mapVirtual;
int mapCount;
- drmTTM *ttm;
} drmBO;
@@ -164,17 +154,6 @@ extern int drmFenceBuffers(int fd, unsigned flags, drmFence *fence);
/*
- * TTM functions.
- */
-
-extern int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size,
- unsigned flags);
-extern int drmTTMDestroy(int fd, const drmTTM *ttm);
-extern int drmTTMReference(int fd, unsigned handle, drmTTM *ttm);
-extern int drmTTMUnreference(int fd, const drmTTM *ttm);
-extern drm_handle_t drmTTMMapHandle(int fd, const drmTTM *ttm);
-
-/*
* Buffer object list functions.
*/
@@ -189,7 +168,7 @@ extern int drmBOCreateList(int numTarget, drmBOList *list);
* Buffer object functions.
*/
-extern int drmBOCreate(int fd, drmTTM *ttm, unsigned long start, unsigned long size,
+extern int drmBOCreate(int fd, void *ttm, unsigned long start, unsigned long size,
void *user_buffer, drm_bo_type_t type, unsigned mask,
unsigned hint, drmBO *buf);
extern int drmBODestroy(int fd, drmBO *buf);