Multithreaded application note.
parent
6042153968
commit
e3f54ecdd9
|
@ -2750,17 +2750,6 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
|
||||||
drm_bo_arg_reply_t *rep = &arg.rep;
|
drm_bo_arg_reply_t *rep = &arg.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* At the moment, we don't allow recursive mapping of a buffer, since
|
|
||||||
* the first mapping may have to be unmapped before this one to succeed.
|
|
||||||
* This might result in a deadlock. We need a DRM mutex mechanism!!
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (buf->mapCount) {
|
|
||||||
drmMsg("Recursive mapping is currently not allowed.\n");
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we have a virtual address of the buffer.
|
* Make sure we have a virtual address of the buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -2827,8 +2816,6 @@ int drmBOUnmap(int fd, drmBO *buf)
|
||||||
if (rep->ret)
|
if (rep->ret)
|
||||||
return rep->ret;
|
return rep->ret;
|
||||||
|
|
||||||
--buf->mapCount;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2840,11 +2827,6 @@ int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
|
||||||
drm_bo_arg_reply_t *rep = &arg.rep;
|
drm_bo_arg_reply_t *rep = &arg.rep;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (buf->mapCount) {
|
|
||||||
drmMsg("Cannot validate while buffer is mapped.\n");
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
arg.handled = 0;
|
arg.handled = 0;
|
||||||
req->handle = buf->handle;
|
req->handle = buf->handle;
|
||||||
req->mask = flags;
|
req->mask = flags;
|
||||||
|
@ -2853,10 +2835,12 @@ int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
|
||||||
req->op = drm_bo_validate;
|
req->op = drm_bo_validate;
|
||||||
req->next = 0;
|
req->next = 0;
|
||||||
|
|
||||||
|
|
||||||
do{
|
do{
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
||||||
} while (ret && errno == -EAGAIN);
|
} while (ret && errno == -EAGAIN);
|
||||||
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (!arg.handled)
|
if (!arg.handled)
|
||||||
|
@ -3008,11 +2992,6 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
if (prevNext)
|
if (prevNext)
|
||||||
*prevNext = (unsigned long) arg;
|
*prevNext = (unsigned long) arg;
|
||||||
|
|
||||||
if (node->buf->mapCount) {
|
|
||||||
drmMsg("Cannot validate while buffer is mapped.\n");
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
req->next = 0;
|
req->next = 0;
|
||||||
prevNext = &req->next;
|
prevNext = &req->next;
|
||||||
arg->handled = 0;
|
arg->handled = 0;
|
||||||
|
@ -3030,6 +3009,7 @@ int drmBOValidateList(int fd, drmBOList *list)
|
||||||
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
|
||||||
} while (ret && errno == -EAGAIN);
|
} while (ret && errno == -EAGAIN);
|
||||||
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,18 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "drm.h"
|
#include "drm.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note on multithreaded applications using this interface.
|
||||||
|
* Libdrm is not threadsafe, so common buffer, TTM, and fence objects need to
|
||||||
|
* be protected using an external mutex.
|
||||||
|
*
|
||||||
|
* Note: Don't protect the following functions, as it may lead to deadlocks:
|
||||||
|
* drmBOUnmap(), drmFenceBuffers().
|
||||||
|
* The kernel is synchronizing and refcounting buffer maps.
|
||||||
|
* User space only needs to refcount object usage within the same application.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List macros heavily inspired by the Linux kernel
|
* List macros heavily inspired by the Linux kernel
|
||||||
* list handling. No list looping yet.
|
* list handling. No list looping yet.
|
||||||
|
@ -82,6 +94,7 @@ typedef struct _drmMMListHead
|
||||||
((__type *)(((char *) (__item)) - offsetof(__type, __field)))
|
((__type *)(((char *) (__item)) - offsetof(__type, __field)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _drmBO{
|
typedef struct _drmBO{
|
||||||
drm_bo_type_t type;
|
drm_bo_type_t type;
|
||||||
unsigned handle;
|
unsigned handle;
|
||||||
|
|
Loading…
Reference in New Issue