[R300-commit] r300_driver/drm/shared-core r300_cmdbuf.c,1.32,1.33
Brought to you by:
volodya
From: Vladimir D. <vo...@us...> - 2005-06-30 16:53:10
|
Update of /cvsroot/r300/r300_driver/drm/shared-core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26458 Modified Files: r300_cmdbuf.c Log Message: Change formatting according to suggestions of DRM module maintainers. Index: r300_cmdbuf.c =================================================================== RCS file: /cvsroot/r300/r300_driver/drm/shared-core/r300_cmdbuf.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- r300_cmdbuf.c 27 Jun 2005 19:46:23 -0000 1.32 +++ r300_cmdbuf.c 30 Jun 2005 16:53:01 -0000 1.33 @@ -101,7 +101,7 @@ OUT_RING( 0 ); OUT_RING( R300_SCISSORS_X_MASK | R300_SCISSORS_Y_MASK ); ADVANCE_RING(); - } else { + } else { /* Why we allow zero cliprect rendering: * There are some commands in a command buffer that must be submitted * even when there are no cliprects, e.g. DMA buffer discard @@ -120,7 +120,7 @@ BEGIN_RING(2); OUT_RING_REG( R300_RE_CLIPRECT_CNTL, 0 ); ADVANCE_RING(); - } + } return 0; } @@ -130,14 +130,16 @@ void r300_init_reg_flags(void) { -int i; -memset(r300_reg_flags, 0, 0x10000>>2); -#define ADD_RANGE_MARK(reg, count,mark) for(i=((reg)>>2);i<((reg)>>2)+(count);i++)r300_reg_flags[i]|=(mark); - -#define MARK_SAFE 1 -#define MARK_CHECK_OFFSET 2 - -#define ADD_RANGE(reg, count) ADD_RANGE_MARK(reg, count, MARK_SAFE) + int i; + memset(r300_reg_flags, 0, 0x10000>>2); + #define ADD_RANGE_MARK(reg, count,mark) \ + for(i=((reg)>>2);i<((reg)>>2)+(count);i++)\ + r300_reg_flags[i]|=(mark); + + #define MARK_SAFE 1 + #define MARK_CHECK_OFFSET 2 + + #define ADD_RANGE(reg, count) ADD_RANGE_MARK(reg, count, MARK_SAFE) /* these match cmducs() command in r300_driver/r300/r300_cmdbuf.c */ ADD_RANGE(R300_SE_VPORT_XSCALE, 6); @@ -224,24 +226,26 @@ static __inline__ int r300_check_range(unsigned reg, int count) { -int i; -if(reg & ~0xffff)return -1; -for(i=(reg>>2);i<(reg>>2)+count;i++) - if(r300_reg_flags[i]!=MARK_SAFE)return 1; -return 0; + int i; + if(reg & ~0xffff)return -1; + for(i=(reg>>2);i<(reg>>2)+count;i++) + if(r300_reg_flags[i]!=MARK_SAFE)return 1; + return 0; } /* we expect offsets passed to the framebuffer to be either within video memory or within AGP space */ static __inline__ int r300_check_offset(drm_radeon_private_t* dev_priv, u32 offset) { - /* we realy want to check against end of video aperture - but this value is not being kept. - This code is correct for now (does the same thing as the - code that sets MC_FB_LOCATION) in radeon_cp.c */ -if((offset>=dev_priv->fb_location) && (offset<dev_priv->gart_vm_start))return 0; -if((offset>=dev_priv->gart_vm_start) && (offset<dev_priv->gart_vm_start+dev_priv->gart_size))return 0; -return 1; + /* we realy want to check against end of video aperture + but this value is not being kept. + This code is correct for now (does the same thing as the + code that sets MC_FB_LOCATION) in radeon_cp.c */ + if((offset>=dev_priv->fb_location) && + (offset<dev_priv->gart_vm_start))return 0; + if((offset>=dev_priv->gart_vm_start) && + (offset<dev_priv->gart_vm_start+dev_priv->gart_size))return 0; + return 1; } static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t* dev_priv, @@ -264,17 +268,17 @@ for(i=0;i<sz;i++){ values[i]=((int __user*)cmdbuf->buf)[i]; switch(r300_reg_flags[(reg>>2)+i]){ - case MARK_SAFE: - break; - case MARK_CHECK_OFFSET: - if(r300_check_offset(dev_priv, (u32)values[i])){ - DRM_ERROR("Offset failed range check (reg=%04x sz=%d)\n", reg, sz); - return DRM_ERR(EINVAL); - } - break; - default: - DRM_ERROR("Register %04x failed check as flag=%02x\n", reg+i*4, r300_reg_flags[(reg>>2)+i]); + case MARK_SAFE: + break; + case MARK_CHECK_OFFSET: + if(r300_check_offset(dev_priv, (u32)values[i])){ + DRM_ERROR("Offset failed range check (reg=%04x sz=%d)\n", reg, sz); return DRM_ERR(EINVAL); + } + break; + default: + DRM_ERROR("Register %04x failed check as flag=%02x\n", reg+i*4, r300_reg_flags[(reg>>2)+i]); + return DRM_ERR(EINVAL); } } @@ -506,7 +510,7 @@ default: DRM_ERROR("Unknown packet3 header (0x%08x)\n", header); return DRM_ERR(EINVAL); - } + } BEGIN_RING(count+2); @@ -546,7 +550,7 @@ cmdbuf->buf = orig_buf; cmdbuf->bufsz = orig_bufsz; - } + } switch(header.packet3.packet) { case R300_CMD_PACKET3_CLEAR: @@ -555,7 +559,7 @@ if (ret) { DRM_ERROR("r300_emit_clear failed\n"); return ret; - } + } break; case R300_CMD_PACKET3_RAW: @@ -564,7 +568,7 @@ if (ret) { DRM_ERROR("r300_emit_raw_packet3 failed\n"); return ret; - } + } break; default: @@ -572,7 +576,7 @@ header.packet3.packet, cmdbuf->buf - sizeof(header)); return DRM_ERR(EINVAL); - } + } n += R300_SIMULTANEOUS_CLIPRECTS; } while(n < cmdbuf->nbox); @@ -651,7 +655,7 @@ ret = r300_emit_cliprects(dev_priv, cmdbuf, 0); if (ret) goto cleanup; - } + } while(cmdbuf->bufsz >= sizeof(drm_r300_cmd_header_t)) { int idx; @@ -669,7 +673,7 @@ if (ret) { DRM_ERROR("r300_emit_packet0 failed\n"); goto cleanup; - } + } break; case R300_CMD_VPU: @@ -678,7 +682,7 @@ if (ret) { DRM_ERROR("r300_emit_vpu failed\n"); goto cleanup; - } + } break; case R300_CMD_PACKET3: @@ -687,7 +691,7 @@ if (ret) { DRM_ERROR("r300_emit_packet3 failed\n"); goto cleanup; - } + } break; case R300_CMD_END3D: @@ -702,7 +706,11 @@ coherence) and so the user space driver does it. Once we are sure which uses prevent lockups the code could be moved - into the kernel */ + into the kernel and the userspace driver will not + need to use this command. + + Note that issuing this command does not hurt anything + except, possibly, performance */ r300_pacify(dev_priv); break; @@ -763,7 +771,7 @@ cmdbuf->buf - sizeof(header)); ret = DRM_ERR(EINVAL); goto cleanup; - } + } } DRM_DEBUG("END\n"); @@ -786,7 +794,7 @@ BEGIN_RING(2); RADEON_DISPATCH_AGE(dev_priv->sarea_priv->last_dispatch); ADVANCE_RING(); - } + } COMMIT_RING(); |