summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jrfonseca@users.sourceforge.net>2002-11-10 15:53:45 +0000
committerJose Fonseca <jrfonseca@users.sourceforge.net>2002-11-10 15:53:45 +0000
commit21414dc1e194e3ba3f7ecc51db8b09dd8744ff65 (patch)
treea18011919383afaaf92ead9f698d65b485ff9d67
parent4e4cf3dd5c8e997d748005c0d8f6ae96b421b331 (diff)
Use userspace memory for the vertex buffers - DRM bits. Note that the old
IOCTL interface has been abused for this end.
-rw-r--r--linux/mach64_state.c117
1 files changed, 35 insertions, 82 deletions
diff --git a/linux/mach64_state.c b/linux/mach64_state.c
index 5c03754a..b0311c05 100644
--- a/linux/mach64_state.c
+++ b/linux/mach64_state.c
@@ -462,8 +462,6 @@ static int mach64_do_get_frames_queued( drm_mach64_private_t *dev_priv )
return sarea_priv->frames_queued;
}
-/* #define MACH64_COPY_BUF */
-
/* Copy and verify a client submited buffer.
* FIXME: Make an assembly optimized version
*/
@@ -471,12 +469,7 @@ unsigned long copy_and_verify_from_user( u32 *to, const u32 *from, unsigned long
{
unsigned long copied = 0;
-#if 0
if ( access_ok( VERIFY_READ, from, n ) ) {
-#else
- /* FIXME: Don't verify the area while we're reading from DMA buffers. */
- {
-#endif
n >>= 2;
while ( n ) {
@@ -514,7 +507,7 @@ unsigned long copy_and_verify_from_user( u32 *to, const u32 *from, unsigned long
return copied;
}
-static int mach64_dma_dispatch_vertex( drm_device_t *dev, drm_buf_t *buf,
+static int mach64_dma_dispatch_vertex( drm_device_t *dev, void *buf, unsigned long used,
int prim, int discard )
{
drm_mach64_private_t *dev_priv = dev->dev_private;
@@ -523,14 +516,13 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, drm_buf_t *buf,
int done = 0;
DMALOCALS;
- DRM_DEBUG( "%s: buf=%d nbox=%d\n",
- __FUNCTION__, buf->idx, sarea_priv->nbox );
+ DRM_DEBUG( "%s: buf=%p used=%d nbox=%d\n",
+ __FUNCTION__, buf, used, sarea_priv->nbox );
- if ( buf->used ) {
+ if ( used ) {
int ret = 0;
int i = 0;
-#ifdef MACH64_COPY_BUF
copy_buf = mach64_freelist_get( dev_priv );
if (copy_buf == NULL) {
DRM_ERROR("%s: couldn't get buffer in DMAGETPTR\n",
@@ -538,13 +530,9 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, drm_buf_t *buf,
return -EAGAIN;
}
- /* FIXME: This should be done from a client space buffer and not from a DMA buffer. */
- copy_buf->used = copy_and_verify_from_user( GETBUFPTR( copy_buf ), GETBUFPTR( buf ), buf->used );
+ copy_buf->used = copy_and_verify_from_user( GETBUFPTR( copy_buf ), buf, used );
DMASETPTR( copy_buf );
-#else
- DMASETPTR( buf );
-#endif
if ( sarea_priv->dirty & ~MACH64_UPLOAD_CLIPRECTS ) {
ret = mach64_emit_state( dev_priv );
@@ -563,11 +551,7 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, drm_buf_t *buf,
continue;
}
}
-#ifdef MACH64_COPY_BUF
if ((i >= sarea_priv->nbox - 1))
-#else
- if ((i >= sarea_priv->nbox - 1) && discard)
-#endif
done = 1;
/* Add the buffer to the DMA queue */
@@ -575,71 +559,33 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, drm_buf_t *buf,
} while ( ++i < sarea_priv->nbox );
-#ifdef MACH64_COPY_BUF
- if (copy_buf->pending && !done) {
- DMADISCARDBUF();
- } else if (!done) {
- /* This buffer wasn't used (no cliprects), so place it back
- * on the free list
- */
- struct list_head *ptr;
- drm_mach64_freelist_t *entry;
+ if (copy_buf->pending && !done) {
+ DMADISCARDBUF();
+ } else if (!done) {
+ /* This buffer wasn't used (no cliprects), so place it back
+ * on the free list
+ */
+ struct list_head *ptr;
+ drm_mach64_freelist_t *entry;
#if MACH64_EXTRA_CHECKING
- list_for_each(ptr, &dev_priv->pending) {
- entry = list_entry(ptr, drm_mach64_freelist_t, list);
- if (copy_buf == entry->buf) {
- DRM_ERROR( "%s: Trying to release a pending buf\n",
- __FUNCTION__ );
- return -EFAULT;
+ list_for_each(ptr, &dev_priv->pending) {
+ entry = list_entry(ptr, drm_mach64_freelist_t, list);
+ if (copy_buf == entry->buf) {
+ DRM_ERROR( "%s: Trying to release a pending buf\n",
+ __FUNCTION__ );
+ return -EFAULT;
+ }
}
- }
-#endif
- ptr = dev_priv->placeholders.next;
- entry = list_entry(ptr, drm_mach64_freelist_t, list);
- copy_buf->pending = 0;
- copy_buf->used = 0;
- entry->buf = copy_buf;
- entry->discard = 1;
- list_del(ptr);
- list_add_tail(ptr, &dev_priv->free_list);
- }
-#endif
- }
-
- /* If this is a reused buffer and we're discarding it,
- * make sure the discard flag gets set so the buffer
- * is reclaimed when it finishes processing
- */
-#ifdef MACH64_COPY_BUF
- if (discard) {
-#else
- if (buf->pending && discard && !done) {
- DMADISCARDBUF();
- } else if (discard && !done) {
#endif
- /* This buffer wasn't used (no cliprects), so place it back
- * on the free list
- */
- struct list_head *ptr;
- drm_mach64_freelist_t *entry;
-#if MACH64_EXTRA_CHECKING
- list_for_each(ptr, &dev_priv->pending) {
+ ptr = dev_priv->placeholders.next;
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- if (buf == entry->buf) {
- DRM_ERROR( "%s: Trying to release a pending buf\n",
- __FUNCTION__ );
- return -EFAULT;
- }
+ copy_buf->pending = 0;
+ copy_buf->used = 0;
+ entry->buf = copy_buf;
+ entry->discard = 1;
+ list_del(ptr);
+ list_add_tail(ptr, &dev_priv->free_list);
}
-#endif
- ptr = dev_priv->placeholders.next;
- entry = list_entry(ptr, drm_mach64_freelist_t, list);
- buf->pending = 0;
- buf->used = 0;
- entry->buf = buf;
- entry->discard = 1;
- list_del(ptr);
- list_add_tail(ptr, &dev_priv->free_list);
}
sarea_priv->dirty &= ~MACH64_UPLOAD_CLIPRECTS;
@@ -831,7 +777,9 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
+#if 0
drm_buf_t *buf;
+#endif
drm_mach64_vertex_t vertex;
LOCK_TEST_WITH_RETURN( dev );
@@ -849,11 +797,13 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
__FUNCTION__, current->pid,
vertex.idx, vertex.count, vertex.discard );
+#if 0
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
return -EINVAL;
}
+#endif
if ( vertex.prim < 0 ||
vertex.prim > MACH64_PRIM_POLYGON ) {
@@ -866,6 +816,7 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
if ( sarea_priv->nbox > MACH64_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MACH64_NR_SAREA_CLIPRECTS;
+#if 0
buf = dma->buflist[vertex.idx];
if ( buf->pid != current->pid ) {
@@ -875,8 +826,10 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
}
buf->used = vertex.count;
+#endif
- return mach64_dma_dispatch_vertex( dev, buf, vertex.prim, vertex.discard );
+ /* FIXME: Update the IOCTL interface */
+ return mach64_dma_dispatch_vertex( dev, vertex.idx, vertex.count, vertex.prim, vertex.discard );
}
int mach64_dma_blit( struct inode *inode, struct file *filp,