summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdrm/xf86drm.c14
-rw-r--r--linux-core/drm_bo.c45
-rw-r--r--shared-core/via_dma.c6
3 files changed, 28 insertions, 37 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index a815ed7a..2473162b 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2814,7 +2814,7 @@ int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
} while (ret != 0 && errno == EAGAIN);
if (ret)
- return ret;
+ return -errno;
if (!arg.handled)
return -EFAULT;
if (rep->ret)
@@ -2870,7 +2870,7 @@ int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask,
} while (ret && errno == EAGAIN);
if (ret)
- return ret;
+ return -errno;
if (!arg.handled)
return -EFAULT;
if (rep->ret)
@@ -2897,7 +2897,7 @@ int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle)
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
if (ret)
- return ret;
+ return -errno;
if (!arg.handled)
return -EFAULT;
if (rep->ret)
@@ -2919,7 +2919,7 @@ int drmBOInfo(int fd, drmBO *buf)
ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
if (ret)
- return ret;
+ return -errno;
if (!arg.handled)
return -EFAULT;
if (rep->ret)
@@ -2947,7 +2947,7 @@ int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
} while (ret && errno == EAGAIN);
if (ret)
- return ret;
+ return -errno;
if (!arg.handled)
return -EFAULT;
if (rep->ret)
@@ -3199,7 +3199,7 @@ int drmMMLock(int fd, unsigned memType)
ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
} while (ret && errno == EAGAIN);
- return ret;
+ return -errno;
}
int drmMMUnlock(int fd, unsigned memType)
@@ -3215,7 +3215,7 @@ int drmMMUnlock(int fd, unsigned memType)
ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
} while (ret && errno == EAGAIN);
- return ret;
+ return -errno;
}
#define DRM_MAX_FDS 16
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index d6dce10a..27016d8c 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -1039,30 +1039,23 @@ static int drm_bo_wait_unfenced(drm_buffer_object_t * bo, int no_wait,
int eagain_if_wait)
{
int ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED);
- unsigned long _end = jiffies + 3 * DRM_HZ;
if (ret && no_wait)
return -EBUSY;
else if (!ret)
return 0;
- do {
- mutex_unlock(&bo->mutex);
- DRM_WAIT_ON(ret, bo->event_queue, 3 * DRM_HZ,
- !drm_bo_check_unfenced(bo));
- mutex_lock(&bo->mutex);
- if (ret == -EINTR)
- return -EAGAIN;
- if (ret) {
- DRM_ERROR
- ("Error waiting for buffer to become fenced\n");
- return ret;
- }
- ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED);
- } while (ret && !time_after_eq(jiffies, _end));
+ ret = 0;
+ mutex_unlock(&bo->mutex);
+ DRM_WAIT_ON(ret, bo->event_queue, 3 * DRM_HZ,
+ !drm_bo_check_unfenced(bo));
+ mutex_lock(&bo->mutex);
+ if (ret == -EINTR)
+ return -EAGAIN;
+ ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED);
if (ret) {
DRM_ERROR("Timeout waiting for buffer to become fenced\n");
- return ret;
+ return -EBUSY;
}
if (eagain_if_wait)
return -EAGAIN;
@@ -1421,7 +1414,10 @@ static int drm_buffer_object_validate(drm_buffer_object_t * bo,
} else if (bo->pinned_node != NULL) {
mutex_lock(&dev->struct_mutex);
- drm_mm_put_block(bo->pinned_node);
+
+ if (bo->pinned_node != bo->mem.mm_node)
+ drm_mm_put_block(bo->pinned_node);
+
list_del_init(&bo->pinned_lru);
bo->pinned_node = NULL;
mutex_unlock(&dev->struct_mutex);
@@ -1684,6 +1680,9 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
rep.ret = 0;
switch (req->op) {
case drm_bo_create:
+ rep.ret = drm_bo_lock_test(dev, filp);
+ if (rep.ret)
+ break;
rep.ret =
drm_buffer_object_create(priv->head->dev,
req->size,
@@ -1735,17 +1734,7 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS)
drm_buffer_type, &uo);
if (rep.ret)
break;
- mutex_lock(&dev->struct_mutex);
- uo = drm_lookup_user_object(priv, req->handle);
- entry =
- drm_user_object_entry(uo, drm_buffer_object_t,
- base);
- /* I don't think this is needed - D.A. */
- // atomic_dec(&entry->usage);
- mutex_unlock(&dev->struct_mutex);
- mutex_lock(&entry->mutex);
- drm_bo_fill_rep_arg(entry, &rep);
- mutex_unlock(&entry->mutex);
+ rep.ret = drm_bo_handle_info(priv, req->handle, &rep);
break;
case drm_bo_unreference:
rep.ret = drm_user_object_unref(priv, req->handle,
diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c
index 8c5a5c64..c73634e4 100644
--- a/shared-core/via_dma.c
+++ b/shared-core/via_dma.c
@@ -430,8 +430,10 @@ static int via_hook_segment(drm_via_private_t *dev_priv,
paused = 0;
via_flush_write_combine();
- *dev_priv->last_pause_ptr = pause_addr_lo;
+ (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1);
+ *paused_at = pause_addr_lo;
via_flush_write_combine();
+ (void) *paused_at;
reader = *(dev_priv->hw_addr_ptr);
ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) +
dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
@@ -536,7 +538,7 @@ static void via_cmdbuf_start(drm_via_private_t * dev_priv)
&pause_addr_hi, & pause_addr_lo, 1) - 1;
via_flush_write_combine();
- while(! *dev_priv->last_pause_ptr);
+ (void) *(volatile uint32_t *)dev_priv->last_pause_ptr;
VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16));
VIA_WRITE(VIA_REG_TRANSPACE, command);