summaryrefslogtreecommitdiff
path: root/shared/mach64_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/mach64_state.c')
-rw-r--r--shared/mach64_state.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/shared/mach64_state.c b/shared/mach64_state.c
index a2269701..3716102b 100644
--- a/shared/mach64_state.c
+++ b/shared/mach64_state.c
@@ -66,8 +66,8 @@ static void mach64_print_dirty( const char *msg, unsigned int flags )
/* This function returns 0 on success, 1 for no intersection, and
* negative for an error
*/
-static int mach64_emit_cliprect( drm_mach64_private_t *dev_priv,
- drm_clip_rect_t *box )
+static int mach64_emit_cliprect( DRMFILE filp, drm_mach64_private_t *dev_priv,
+ drm_clip_rect_t *box )
{
u32 sc_left_right, sc_top_bottom;
drm_clip_rect_t scissor;
@@ -95,7 +95,7 @@ static int mach64_emit_cliprect( drm_mach64_private_t *dev_priv,
if ( scissor.x1 >= scissor.x2 ) return 1;
if ( scissor.y1 >= scissor.y2 ) return 1;
- DMAGETPTR( dev_priv, 2 ); /* returns on failure to get buffer */
+ DMAGETPTR( filp, dev_priv, 2 ); /* returns on failure to get buffer */
sc_left_right = ( (scissor.x1 << 0) | (scissor.x2 << 16) );
sc_top_bottom = ( (scissor.y1 << 0) | (scissor.y2 << 16) );
@@ -108,7 +108,7 @@ static int mach64_emit_cliprect( drm_mach64_private_t *dev_priv,
return 0;
}
-static inline int mach64_emit_state( drm_mach64_private_t *dev_priv )
+static inline int mach64_emit_state( DRMFILE filp, drm_mach64_private_t *dev_priv )
{
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mach64_context_regs_t *regs = &sarea_priv->context_state;
@@ -122,7 +122,7 @@ static inline int mach64_emit_state( drm_mach64_private_t *dev_priv )
DRM_DEBUG( "%s: dirty=0x%08x\n", __FUNCTION__, dirty );
}
- DMAGETPTR( dev_priv, 17 ); /* returns on failure to get buffer */
+ DMAGETPTR( filp, dev_priv, 17 ); /* returns on failure to get buffer */
if ( dirty & MACH64_UPLOAD_MISC ) {
DMAOUTREG( MACH64_DP_MIX, regs->dp_mix );
@@ -187,11 +187,11 @@ static inline int mach64_emit_state( drm_mach64_private_t *dev_priv )
* DMA command dispatch functions
*/
-static int mach64_dma_dispatch_clear( drm_device_t *dev,
- unsigned int flags,
- int cx, int cy, int cw, int ch,
- unsigned int clear_color,
- unsigned int clear_depth )
+static int mach64_dma_dispatch_clear( DRMFILE filp, drm_device_t *dev,
+ unsigned int flags,
+ int cx, int cy, int cw, int ch,
+ unsigned int clear_color,
+ unsigned int clear_depth )
{
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -229,7 +229,7 @@ static int mach64_dma_dispatch_clear( drm_device_t *dev,
if ( !nbox )
return 0;
- DMAGETPTR( dev_priv, nbox * 31 ); /* returns on failure to get buffer */
+ DMAGETPTR( filp, dev_priv, nbox * 31 ); /* returns on failure to get buffer */
for ( i = 0 ; i < nbox ; i++ ) {
int x = pbox[i].x1;
@@ -337,7 +337,7 @@ static int mach64_dma_dispatch_clear( drm_device_t *dev,
return 0;
}
-static int mach64_dma_dispatch_swap( drm_device_t *dev )
+static int mach64_dma_dispatch_swap( DRMFILE filp, drm_device_t *dev )
{
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -362,7 +362,7 @@ static int mach64_dma_dispatch_swap( drm_device_t *dev )
if ( !nbox )
return 0;
- DMAGETPTR( dev_priv, 13 + nbox * 4 ); /* returns on failure to get buffer */
+ DMAGETPTR( filp, dev_priv, 13 + nbox * 4 ); /* returns on failure to get buffer */
DMAOUTREG( MACH64_Z_CNTL, 0 );
DMAOUTREG( MACH64_SCALE_3D_CNTL, 0 );
@@ -524,7 +524,7 @@ static inline int copy_and_verify_from_user( u32 *to, const u32 *from, unsigned
}
}
-static int mach64_dma_dispatch_vertex( drm_device_t *dev, int prim, void *buf,
+static int mach64_dma_dispatch_vertex( DRMFILE filp, drm_device_t *dev, int prim, void *buf,
unsigned long used, int discard )
{
drm_mach64_private_t *dev_priv = dev->dev_private;
@@ -548,21 +548,23 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, int prim, void *buf,
return DRM_ERR(EAGAIN);
}
- if ( (verify_ret = copy_and_verify_from_user( GETBUFPTR( copy_buf ), buf, used )) == 0 ) {
+ if ( (verify_ret =
+ copy_and_verify_from_user( GETBUFPTR( copy_buf ), buf, used )) == 0 ) {
copy_buf->used = used;
DMASETPTR( copy_buf );
if ( sarea_priv->dirty & ~MACH64_UPLOAD_CLIPRECTS ) {
- ret = mach64_emit_state( dev_priv );
+ ret = mach64_emit_state( filp, dev_priv );
if (ret < 0) return ret;
}
do {
/* Emit the next cliprect */
if ( i < sarea_priv->nbox ) {
- ret = mach64_emit_cliprect(dev_priv, &sarea_priv->boxes[i]);
+ ret = mach64_emit_cliprect(filp, dev_priv,
+ &sarea_priv->boxes[i]);
if ( ret < 0 ) {
/* failed to get buffer */
return ret;
@@ -616,7 +618,7 @@ static int mach64_dma_dispatch_vertex( drm_device_t *dev, int prim, void *buf,
}
-static int mach64_dma_dispatch_blit( drm_device_t *dev,
+static int mach64_dma_dispatch_blit( DRMFILE filp, drm_device_t *dev,
drm_mach64_blit_t *blit )
{
drm_mach64_private_t *dev_priv = dev->dev_private;
@@ -651,9 +653,9 @@ static int mach64_dma_dispatch_blit( drm_device_t *dev,
*/
buf = dma->buflist[blit->idx];
- if ( buf->pid != DRM_CURRENTPID ) {
- DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "process %d (filp %p) using buffer with filp %p\n",
+ DRM_CURRENTPID, filp, buf->filp );
return DRM_ERR(EINVAL);
}
@@ -739,7 +741,7 @@ int mach64_dma_clear( DRM_IOCTL_ARGS )
DRM_DEBUG( "%s: pid=%d\n", __FUNCTION__, DRM_CURRENTPID );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( clear, (drm_mach64_clear_t *)data,
sizeof(clear) );
@@ -749,9 +751,9 @@ int mach64_dma_clear( DRM_IOCTL_ARGS )
if ( sarea_priv->nbox > MACH64_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MACH64_NR_SAREA_CLIPRECTS;
- ret = mach64_dma_dispatch_clear( dev, clear.flags,
- clear.x, clear.y, clear.w, clear.h,
- clear.clear_color, clear.clear_depth );
+ ret = mach64_dma_dispatch_clear( filp, dev, clear.flags,
+ clear.x, clear.y, clear.w, clear.h,
+ clear.clear_color, clear.clear_depth );
/* Make sure we restore the 3D state next time.
*/
@@ -769,14 +771,14 @@ int mach64_dma_swap( DRM_IOCTL_ARGS )
DRM_DEBUG( "%s: pid=%d\n", __FUNCTION__, DRM_CURRENTPID );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
if ( sarea_priv->nbox > MACH64_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MACH64_NR_SAREA_CLIPRECTS;
- ret = mach64_dma_dispatch_swap( dev );
+ ret = mach64_dma_dispatch_swap( filp, dev );
/* Make sure we restore the 3D state next time.
*/
@@ -792,7 +794,7 @@ int mach64_dma_vertex( DRM_IOCTL_ARGS )
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mach64_vertex_t vertex;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -822,7 +824,7 @@ int mach64_dma_vertex( DRM_IOCTL_ARGS )
if ( sarea_priv->nbox > MACH64_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MACH64_NR_SAREA_CLIPRECTS;
- return mach64_dma_dispatch_vertex( dev, vertex.prim, vertex.buf,
+ return mach64_dma_dispatch_vertex( filp, dev, vertex.prim, vertex.buf,
vertex.used, vertex.discard );
}
@@ -835,7 +837,7 @@ int mach64_dma_blit( DRM_IOCTL_ARGS )
drm_mach64_blit_t blit;
int ret;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( blit, (drm_mach64_blit_t *)data,
sizeof(blit) );
@@ -851,7 +853,7 @@ int mach64_dma_blit( DRM_IOCTL_ARGS )
RING_SPACE_TEST_WITH_RETURN( dev_priv );
- ret = mach64_dma_dispatch_blit( dev, &blit );
+ ret = mach64_dma_dispatch_blit( filp, dev, &blit );
/* Make sure we restore the 3D state next time.
*/
@@ -882,7 +884,7 @@ int mach64_get_param( DRM_IOCTL_ARGS )
switch ( param.param ) {
case MACH64_PARAM_FRAMES_QUEUED:
/* Needs lock since it calls mach64_ring_tick() */
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
value = mach64_do_get_frames_queued( dev_priv );
break;
case MACH64_PARAM_IRQ_NR: