drm: drop drm bo list handling code
parent
efc4fd7c4d
commit
3f1aa15503
317
libdrm/xf86drm.c
317
libdrm/xf86drm.c
|
@ -2529,144 +2529,6 @@ int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int drmAdjustListNodes(drmBOList *list)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l;
|
||||
int ret = 0;
|
||||
|
||||
while(list->numCurrent < list->numTarget) {
|
||||
node = (drmBONode *) malloc(sizeof(*node));
|
||||
if (!node) {
|
||||
ret = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
list->numCurrent++;
|
||||
DRMLISTADD(&node->head, &list->free);
|
||||
}
|
||||
|
||||
while(list->numCurrent > list->numTarget) {
|
||||
l = list->free.next;
|
||||
if (l == &list->free)
|
||||
break;
|
||||
DRMLISTDEL(l);
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
free(node);
|
||||
list->numCurrent--;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void drmBOFreeList(drmBOList *list)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l;
|
||||
|
||||
l = list->list.next;
|
||||
while(l != &list->list) {
|
||||
DRMLISTDEL(l);
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
free(node);
|
||||
l = list->list.next;
|
||||
list->numCurrent--;
|
||||
list->numOnList--;
|
||||
}
|
||||
|
||||
l = list->free.next;
|
||||
while(l != &list->free) {
|
||||
DRMLISTDEL(l);
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
free(node);
|
||||
l = list->free.next;
|
||||
list->numCurrent--;
|
||||
}
|
||||
}
|
||||
|
||||
int drmBOResetList(drmBOList *list)
|
||||
{
|
||||
drmMMListHead *l;
|
||||
int ret;
|
||||
|
||||
ret = drmAdjustListNodes(list);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
l = list->list.next;
|
||||
while (l != &list->list) {
|
||||
DRMLISTDEL(l);
|
||||
DRMLISTADD(l, &list->free);
|
||||
list->numOnList--;
|
||||
l = list->list.next;
|
||||
}
|
||||
return drmAdjustListNodes(list);
|
||||
}
|
||||
|
||||
static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
|
||||
unsigned long arg0,
|
||||
unsigned long arg1)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l;
|
||||
|
||||
l = list->free.next;
|
||||
if (l == &list->free) {
|
||||
node = (drmBONode *) malloc(sizeof(*node));
|
||||
if (!node) {
|
||||
return NULL;
|
||||
}
|
||||
list->numCurrent++;
|
||||
}
|
||||
else {
|
||||
DRMLISTDEL(l);
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
}
|
||||
node->buf = item;
|
||||
node->arg0 = arg0;
|
||||
node->arg1 = arg1;
|
||||
DRMLISTADD(&node->head, &list->list);
|
||||
list->numOnList++;
|
||||
return node;
|
||||
}
|
||||
|
||||
void *drmBOListIterator(drmBOList *list)
|
||||
{
|
||||
void *ret = list->list.next;
|
||||
|
||||
if (ret == &list->list)
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *drmBOListNext(drmBOList *list, void *iterator)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
drmMMListHead *l = (drmMMListHead *) iterator;
|
||||
ret = l->next;
|
||||
if (ret == &list->list)
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
drmBO *drmBOListBuf(void *iterator)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l = (drmMMListHead *) iterator;
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
return node->buf;
|
||||
}
|
||||
|
||||
|
||||
int drmBOCreateList(int numTarget, drmBOList *list)
|
||||
{
|
||||
DRMINITLISTHEAD(&list->list);
|
||||
DRMINITLISTHEAD(&list->free);
|
||||
list->numTarget = numTarget;
|
||||
list->numCurrent = 0;
|
||||
list->numOnList = 0;
|
||||
return drmAdjustListNodes(list);
|
||||
}
|
||||
|
||||
static void drmBOCopyReply(const struct drm_bo_info_rep *rep, drmBO *buf)
|
||||
{
|
||||
buf->handle = rep->handle;
|
||||
|
@ -2971,185 +2833,6 @@ int drmBOBusy(int fd, drmBO *buf, int *busy)
|
|||
}
|
||||
}
|
||||
|
||||
int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
|
||||
unsigned mask,
|
||||
int *newItem)
|
||||
{
|
||||
drmBONode *node, *cur;
|
||||
drmMMListHead *l;
|
||||
|
||||
*newItem = 0;
|
||||
cur = NULL;
|
||||
|
||||
for (l = list->list.next; l != &list->list; l = l->next) {
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
if (node->buf == buf) {
|
||||
cur = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cur) {
|
||||
cur = drmAddListItem(list, buf, flags, mask);
|
||||
if (!cur) {
|
||||
drmMsg("Out of memory creating validate list node.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
*newItem = 1;
|
||||
cur->arg0 = flags;
|
||||
cur->arg1 = mask;
|
||||
}
|
||||
else {
|
||||
unsigned memMask = (cur->arg1 | mask) & DRM_BO_MASK_MEM;
|
||||
unsigned memFlags = cur->arg0 & flags & memMask;
|
||||
|
||||
if (!memFlags) {
|
||||
drmMsg("Incompatible memory location requests "
|
||||
"on validate list.\n");
|
||||
drmMsg("Previous flag: 0x%08lx, mask: 0x%08lx\n",
|
||||
cur->arg0, cur->arg1);
|
||||
drmMsg("Current flag: 0x%08lx, mask: 0x%08lx\n",
|
||||
flags, mask);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (mask & cur->arg1 & ~DRM_BO_MASK_MEM & (cur->arg0 ^ flags)) {
|
||||
drmMsg("Incompatible buffer flag requests "
|
||||
"on validate list.\n");
|
||||
drmMsg("Previous flag: 0x%08lx, mask: 0x%08lx\n",
|
||||
cur->arg0, cur->arg1);
|
||||
drmMsg("Current flag: 0x%08lx, mask: 0x%08lx\n",
|
||||
flags, mask);
|
||||
return -EINVAL;
|
||||
}
|
||||
cur->arg1 |= mask;
|
||||
cur->arg0 = memFlags | ((cur->arg0 | flags) &
|
||||
cur->arg1 & ~DRM_BO_MASK_MEM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int drmBOValidateList(int fd, drmBOList *list)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l;
|
||||
struct drm_bo_op_arg *arg, *first;
|
||||
struct drm_bo_op_req *req;
|
||||
struct drm_bo_arg_rep *rep;
|
||||
uint64_t *prevNext = NULL;
|
||||
drmBO *buf;
|
||||
int ret;
|
||||
|
||||
first = NULL;
|
||||
|
||||
for (l = list->list.next; l != &list->list; l = l->next) {
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
|
||||
arg = &node->bo_arg;
|
||||
req = &arg->d.req;
|
||||
|
||||
if (!first)
|
||||
first = arg;
|
||||
|
||||
if (prevNext)
|
||||
*prevNext = (unsigned long) arg;
|
||||
|
||||
memset(arg, 0, sizeof(*arg));
|
||||
prevNext = &arg->next;
|
||||
req->bo_req.handle = node->buf->handle;
|
||||
req->op = drm_bo_validate;
|
||||
req->bo_req.flags = node->arg0;
|
||||
req->bo_req.hint = 0;
|
||||
req->bo_req.mask = node->arg1;
|
||||
req->bo_req.fence_class = 0; /* Backwards compat. */
|
||||
}
|
||||
|
||||
if (!first)
|
||||
return 0;
|
||||
|
||||
do{
|
||||
ret = ioctl(fd, DRM_IOCTL_BO_OP, first);
|
||||
} while (ret && errno == EAGAIN);
|
||||
|
||||
if (ret)
|
||||
return -errno;
|
||||
|
||||
for (l = list->list.next; l != &list->list; l = l->next) {
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
arg = &node->bo_arg;
|
||||
rep = &arg->d.rep;
|
||||
|
||||
if (!arg->handled) {
|
||||
drmMsg("Unhandled request\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
if (rep->ret)
|
||||
return rep->ret;
|
||||
|
||||
buf = node->buf;
|
||||
drmBOCopyReply(&rep->bo_info, buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle)
|
||||
{
|
||||
drmBONode *node;
|
||||
drmMMListHead *l;
|
||||
struct drm_bo_op_arg *arg, *first;
|
||||
struct drm_bo_op_req *req;
|
||||
struct drm_bo_arg_rep *rep;
|
||||
uint64_t *prevNext = NULL;
|
||||
drmBO *buf;
|
||||
unsigned fence_flags;
|
||||
int ret;
|
||||
|
||||
first = NULL;
|
||||
|
||||
for (l = list->list.next; l != &list->list; l = l->next) {
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
|
||||
arg = &node->bo_arg;
|
||||
req = &arg->d.req;
|
||||
|
||||
if (!first)
|
||||
first = arg;
|
||||
|
||||
if (prevNext)
|
||||
*prevNext = (unsigned long) arg;
|
||||
|
||||
memset(arg, 0, sizeof(*arg));
|
||||
prevNext = &arg->next;
|
||||
req->bo_req.handle = node->buf->handle;
|
||||
req->op = drm_bo_fence;
|
||||
req->bo_req.mask = node->arg0;
|
||||
req->arg_handle = fenceHandle;
|
||||
}
|
||||
|
||||
if (!first)
|
||||
return 0;
|
||||
|
||||
ret = ioctl(fd, DRM_IOCTL_BO_OP, first);
|
||||
|
||||
if (ret)
|
||||
return -errno;
|
||||
|
||||
for (l = list->list.next; l != &list->list; l = l->next) {
|
||||
node = DRMLISTENTRY(drmBONode, l, head);
|
||||
|
||||
arg = &node->bo_arg;
|
||||
rep = &arg->d.rep;
|
||||
|
||||
if (!arg->handled)
|
||||
return -EFAULT;
|
||||
if (rep->ret)
|
||||
return rep->ret;
|
||||
drmBOCopyReply(&rep->bo_info, node->buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
|
||||
unsigned memType)
|
||||
{
|
||||
|
|
|
@ -126,24 +126,6 @@ typedef struct _drmBO
|
|||
unsigned pad[8]; /* for future expansion */
|
||||
} drmBO;
|
||||
|
||||
typedef struct _drmBONode
|
||||
{
|
||||
drmMMListHead head;
|
||||
drmBO *buf;
|
||||
struct drm_bo_op_arg bo_arg;
|
||||
unsigned long arg0;
|
||||
unsigned long arg1;
|
||||
} drmBONode;
|
||||
|
||||
typedef struct _drmBOList {
|
||||
unsigned numTarget;
|
||||
unsigned numCurrent;
|
||||
unsigned numOnList;
|
||||
drmMMListHead list;
|
||||
drmMMListHead free;
|
||||
} drmBOList;
|
||||
|
||||
|
||||
/*
|
||||
* Fence functions.
|
||||
*/
|
||||
|
@ -162,17 +144,6 @@ extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence,
|
|||
extern int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence);
|
||||
|
||||
|
||||
/*
|
||||
* Buffer object list functions.
|
||||
*/
|
||||
|
||||
extern void drmBOFreeList(drmBOList *list);
|
||||
extern int drmBOResetList(drmBOList *list);
|
||||
extern void *drmBOListIterator(drmBOList *list);
|
||||
extern void *drmBOListNext(drmBOList *list, void *iterator);
|
||||
extern drmBO *drmBOListBuf(void *iterator);
|
||||
extern int drmBOCreateList(int numTarget, drmBOList *list);
|
||||
|
||||
/*
|
||||
* Buffer object functions.
|
||||
*/
|
||||
|
@ -192,11 +163,6 @@ extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle);
|
|||
extern int drmBOInfo(int fd, drmBO *buf);
|
||||
extern int drmBOBusy(int fd, drmBO *buf, int *busy);
|
||||
|
||||
extern int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags,
|
||||
unsigned mask,
|
||||
int *newItem);
|
||||
extern int drmBOValidateList(int fd, drmBOList *list);
|
||||
extern int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle);
|
||||
extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint);
|
||||
int drmBOSetPin(int fd, drmBO *buf, int pin);
|
||||
|
||||
|
|
Loading…
Reference in New Issue