sr->sr_ipdvint = STIC_INT_P_WE | (j & STIC_INT_P_EN); #if 0 px_mb(); #endif  v = sr->sr_sticsr;   for (i = STAMP_RETRIES; i != 0; i--) { if (*poll == STAMP_OK) break; for (j = 0; j < 100; j++) v = j;
if (i == 0) { pxPacketReset(sp, "pxPacketFlush: queue wedged"); return;
pxPacketFlush(pxScreenPrivPtr sp, pxPacketPtr pp){	volatile u_int32_t *poll;	volatile struct stic_xcomm *sxc;	volatile struct stic_regs *sr;	u_int32_t *pb;	u_long v;	u_int i, j;	PX_TRACE("pxPacketFlush");	pb = pp->head;	if (pp->primcnt != 0)		pb[1] = (pb[1] & 0xffffff) | pp->primcnt << 24;	if ((pb[1] & 0xff000000) == 0)		return;	sxc = sp->sxc;#ifdef notyet	if (sp->queueing) {#ifdef notyet		/*		 * See if we can "glom" the primatives from this packet		 * together with one already in the queue.  Only do this if		 * there are at least 8 packets in the queue (one currently		 * executing).		 */		i = sxc->sxc_head;		while (pxPacketTailDistance(sp, i) > 7) {			/*			 * Don't glom primatives that use image buffers.			 */			if ((pb[0] & 7) == STAMP_CMD_READSPANS ||			    (pb[0] & 7) == STAMP_CMD_WRITESPANS)				break;			/*			 * Don't bother if there's a per-packet XYMASK,			 * since it will take time to compare and is not			 * likely to match.			 */			if ((pb[0] & STAMP_XY_PERPACKET) != 0)				break;			opb = sp->buf + i *			    (STIC_PACKET_SIZE / sizeof(u_int32_t));			if (pxPacketTryGlom(sp, pp, opb, i))				return;			if (--i < 0)				i = sp->nbuf - 1;		}#endif		/*		 * Wait for the STIC to catch up if the queue is full.		 */		for (;;) {			i = (sxc->sxc_head + 1) % sp->nbuf;			if (i != sxc->sxc_tail)				break;			if (!sxc->sxc_busy)				v = sxc->sxc_tail * STIC_PACKET_SIZE +				    STIC_XCOMM_SIZE + sp->buf_pa;				v = ((v & 0xffff8000) << 3) | (v & 0x7fff);				poll = (volatile u_int32_t *)((u_long)sp->poll + (v >> 9));				sxc->sxc_busy = 1;				if (*poll != STAMP_OK) {					ErrorF("pxPacketFlush: poll failed\n");					sxc->sxc_busy = 0;				}			}			if ((sp->stic->sr_ipdvint & STIC_INT_P_EN) == 0)				ErrorF("packet done intr not enabled!");		}	}#endif	v = (u_long)pb - (u_long)sp->sxc + sp->buf_pa;	v = ((v & 0xffff8000) << 3) | (v & 0x7fff);	poll = (volatile u_int32_t *)((u_long)sp->poll + (v >> 9));#ifdef notyet	if (!sp->queueing) {#endif		sr = sp->stic;		/* Wait for the previous command to complete. */		for (i = 1000000; i != 0; i--) {			j = sr->sr_ipdvint;			if ((j & STIC_INT_P) != 0)				break;		}		sr->sr_ipdvint = STIC_INT_P_WE | (j & STIC_INT_P_EN);#if 0		px_mb();#endif		/* Flush the write to sr_ipdvint. */		v = sr->sr_sticsr;		/* Try to start DMA. */		for (i = STAMP_RETRIES; i != 0; i--) {			if (*poll == STAMP_OK)				break;			for (j = 0; j < 100; j++)				v = j;		}		if (i == 0)			pxPacketResetStic(sp, "pxPacketFlush");#ifdef notyet	} else {		sxc->sxc_head = (sxc->sxc_head + 1) % sp->nbuf;		/*		 * If the queue is not running, try to start the packet ONCE		 * only, as we may have interrupted and as a result the		 * kernel may have also tried to submit the packet.  (Over		 * eager use of the poll registers can cause the STIC to		 * go ballistic.)		 */		if (sxc->sxc_busy == 0) {			sxc->sxc_busy = 1;			if (*poll != STAMP_OK) {				ErrorF("pxPacketFlush: poll failed\n");				sxc->sxc_busy = 0;			}					}	}#endif}