Home | History | Annotate | Line # | Download | only in dev
si.c revision 1.60.44.1
      1  1.60.44.1       mjf /*	$NetBSD: si.c,v 1.60.44.1 2008/06/02 13:22:46 mjf Exp $	*/
      2        1.8       cgd 
      3       1.31       gwr /*-
      4       1.31       gwr  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5        1.1     glass  * All rights reserved.
      6        1.1     glass  *
      7       1.31       gwr  * This code is derived from software contributed to The NetBSD Foundation
      8       1.31       gwr  * by Adam Glass, David Jones, and Gordon W. Ross.
      9       1.31       gwr  *
     10        1.1     glass  * Redistribution and use in source and binary forms, with or without
     11        1.1     glass  * modification, are permitted provided that the following conditions
     12        1.1     glass  * are met:
     13        1.1     glass  * 1. Redistributions of source code must retain the above copyright
     14        1.1     glass  *    notice, this list of conditions and the following disclaimer.
     15        1.1     glass  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1     glass  *    notice, this list of conditions and the following disclaimer in the
     17        1.1     glass  *    documentation and/or other materials provided with the distribution.
     18        1.1     glass  *
     19       1.31       gwr  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.31       gwr  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.31       gwr  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.33       gwr  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.33       gwr  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.31       gwr  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.31       gwr  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.31       gwr  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.31       gwr  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.31       gwr  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.31       gwr  * POSSIBILITY OF SUCH DAMAGE.
     30        1.1     glass  */
     31        1.1     glass 
     32       1.24       gwr /*
     33       1.24       gwr  * This file contains only the machine-dependent parts of the
     34       1.24       gwr  * Sun3 SCSI driver.  (Autoconfig stuff and DMA functions.)
     35       1.24       gwr  * The machine-independent parts are in ncr5380sbc.c
     36       1.24       gwr  *
     37       1.24       gwr  * Supported hardware includes:
     38       1.24       gwr  * Sun SCSI-3 on OBIO (Sun3/50,Sun3/60)
     39       1.24       gwr  * Sun SCSI-3 on VME (Sun3/160,Sun3/260)
     40       1.24       gwr  *
     41       1.24       gwr  * Could be made to support the Sun3/E if someone wanted to.
     42       1.24       gwr  *
     43       1.24       gwr  * Note:  Both supported variants of the Sun SCSI-3 adapter have
     44       1.24       gwr  * some really unusual "features" for this driver to deal with,
     45       1.24       gwr  * generally related to the DMA engine.  The OBIO variant will
     46       1.24       gwr  * ignore any attempt to write the FIFO count register while the
     47       1.24       gwr  * SCSI bus is in DATA_IN or DATA_OUT phase.  This is dealt with
     48       1.24       gwr  * by setting the FIFO count early in COMMAND or MSG_IN phase.
     49       1.24       gwr  *
     50       1.24       gwr  * The VME variant has a bit to enable or disable the DMA engine,
     51       1.24       gwr  * but that bit also gates the interrupt line from the NCR5380!
     52       1.24       gwr  * Therefore, in order to get any interrupt from the 5380, (i.e.
     53       1.24       gwr  * for reselect) one must clear the DMA engine transfer count and
     54       1.24       gwr  * then enable DMA.  This has the further complication that you
     55       1.24       gwr  * CAN NOT touch the NCR5380 while the DMA enable bit is set, so
     56       1.24       gwr  * we have to turn DMA back off before we even look at the 5380.
     57       1.24       gwr  *
     58       1.24       gwr  * What wonderfully whacky hardware this is!
     59       1.24       gwr  *
     60       1.24       gwr  * Credits, history:
     61       1.24       gwr  *
     62       1.24       gwr  * David Jones wrote the initial version of this module, which
     63       1.24       gwr  * included support for the VME adapter only. (no reselection).
     64       1.24       gwr  *
     65       1.24       gwr  * Gordon Ross added support for the OBIO adapter, and re-worked
     66       1.24       gwr  * both the VME and OBIO code to support disconnect/reselect.
     67       1.24       gwr  * (Required figuring out the hardware "features" noted above.)
     68       1.24       gwr  *
     69       1.24       gwr  * The autoconfiguration boilerplate came from Adam Glass.
     70       1.24       gwr  */
     71       1.54     lukem 
     72       1.54     lukem #include <sys/cdefs.h>
     73  1.60.44.1       mjf __KERNEL_RCSID(0, "$NetBSD: si.c,v 1.60.44.1 2008/06/02 13:22:46 mjf Exp $");
     74        1.1     glass 
     75        1.1     glass #include <sys/param.h>
     76        1.1     glass #include <sys/systm.h>
     77        1.1     glass #include <sys/errno.h>
     78       1.24       gwr #include <sys/kernel.h>
     79       1.24       gwr #include <sys/malloc.h>
     80       1.24       gwr #include <sys/device.h>
     81        1.1     glass #include <sys/buf.h>
     82        1.1     glass #include <sys/proc.h>
     83        1.1     glass #include <sys/user.h>
     84       1.24       gwr 
     85       1.36    bouyer #include <dev/scsipi/scsi_all.h>
     86       1.36    bouyer #include <dev/scsipi/scsipi_all.h>
     87       1.36    bouyer #include <dev/scsipi/scsipi_debug.h>
     88       1.36    bouyer #include <dev/scsipi/scsiconf.h>
     89        1.1     glass 
     90        1.1     glass #include <machine/autoconf.h>
     91       1.58   tsutsui #include <machine/bus.h>
     92       1.24       gwr #include <machine/dvma.h>
     93        1.1     glass 
     94       1.38       gwr /* #define DEBUG XXX */
     95       1.24       gwr 
     96       1.24       gwr #include <dev/ic/ncr5380reg.h>
     97       1.24       gwr #include <dev/ic/ncr5380var.h>
     98        1.2       gwr 
     99       1.24       gwr #include "sireg.h"
    100       1.24       gwr #include "sivar.h"
    101       1.14       gwr 
    102       1.30       gwr /*
    103       1.30       gwr  * Transfers smaller than this are done using PIO
    104       1.30       gwr  * (on assumption they're not worth DMA overhead)
    105       1.30       gwr  */
    106       1.30       gwr #define	MIN_DMA_LEN 128
    107       1.30       gwr 
    108       1.24       gwr int si_debug = 0;
    109       1.14       gwr #ifdef	DEBUG
    110       1.14       gwr #endif
    111        1.1     glass 
    112       1.24       gwr /* How long to wait for DMA before declaring an error. */
    113       1.24       gwr int si_dma_intr_timo = 500;	/* ticks (sec. X 100) */
    114        1.1     glass 
    115       1.56       chs static void	si_minphys(struct buf *);
    116        1.1     glass 
    117       1.24       gwr /*
    118       1.24       gwr  * New-style autoconfig attachment. The cfattach
    119       1.24       gwr  * structures are in si_obio.c and si_vme.c
    120       1.24       gwr  */
    121        1.1     glass 
    122       1.56       chs void
    123       1.56       chs si_attach(struct si_softc *sc)
    124       1.24       gwr {
    125  1.60.44.1       mjf 	struct ncr5380_softc *ncr_sc = &sc->ncr_sc;
    126       1.24       gwr 	volatile struct si_regs *regs = sc->sc_regs;
    127       1.24       gwr 	int i;
    128       1.30       gwr 
    129       1.30       gwr 	/*
    130       1.30       gwr 	 * Support the "options" (config file flags).
    131       1.34       gwr 	 * Disconnect/reselect is a per-target mask.
    132       1.34       gwr 	 * Interrupts and DMA are per-controller.
    133       1.30       gwr 	 */
    134       1.34       gwr 	ncr_sc->sc_no_disconnect =
    135  1.60.44.1       mjf 	    (sc->sc_options & SI_NO_DISCONNECT);
    136       1.34       gwr 	ncr_sc->sc_parity_disable =
    137  1.60.44.1       mjf 	    (sc->sc_options & SI_NO_PARITY_CHK) >> 8;
    138       1.34       gwr 	if (sc->sc_options & SI_FORCE_POLLING)
    139       1.30       gwr 		ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;
    140       1.34       gwr 
    141       1.30       gwr #if 1	/* XXX - Temporary */
    142       1.30       gwr 	/* XXX - In case we think DMA is completely broken... */
    143       1.34       gwr 	if (sc->sc_options & SI_DISABLE_DMA) {
    144       1.30       gwr 		/* Override this function pointer. */
    145       1.30       gwr 		ncr_sc->sc_dma_alloc = NULL;
    146       1.30       gwr 	}
    147       1.30       gwr #endif
    148       1.30       gwr 	ncr_sc->sc_min_dma_len = MIN_DMA_LEN;
    149       1.16       gwr 
    150       1.24       gwr 	/*
    151       1.24       gwr 	 * Initialize fields used by the MI code
    152       1.24       gwr 	 */
    153       1.24       gwr 	ncr_sc->sci_r0 = &regs->sci.sci_r0;
    154       1.24       gwr 	ncr_sc->sci_r1 = &regs->sci.sci_r1;
    155       1.24       gwr 	ncr_sc->sci_r2 = &regs->sci.sci_r2;
    156       1.24       gwr 	ncr_sc->sci_r3 = &regs->sci.sci_r3;
    157       1.24       gwr 	ncr_sc->sci_r4 = &regs->sci.sci_r4;
    158       1.24       gwr 	ncr_sc->sci_r5 = &regs->sci.sci_r5;
    159       1.24       gwr 	ncr_sc->sci_r6 = &regs->sci.sci_r6;
    160       1.24       gwr 	ncr_sc->sci_r7 = &regs->sci.sci_r7;
    161       1.48   tsutsui 
    162       1.48   tsutsui 	ncr_sc->sc_rev = NCR_VARIANT_NCR5380;
    163       1.12       gwr 
    164       1.24       gwr 	/*
    165       1.24       gwr 	 * Allocate DMA handles.
    166       1.24       gwr 	 */
    167       1.24       gwr 	i = SCI_OPENINGS * sizeof(struct si_dma_handle);
    168       1.24       gwr 	sc->sc_dma = (struct si_dma_handle *)
    169       1.24       gwr 		malloc(i, M_DEVBUF, M_WAITOK);
    170       1.24       gwr 	if (sc->sc_dma == NULL)
    171       1.51    provos 		panic("si: dvma_malloc failed");
    172       1.24       gwr 	for (i = 0; i < SCI_OPENINGS; i++)
    173       1.24       gwr 		sc->sc_dma[i].dh_flags = 0;
    174       1.12       gwr 
    175       1.50    bouyer 	ncr_sc->sc_channel.chan_id = 7;
    176       1.50    bouyer 	ncr_sc->sc_adapter.adapt_minphys = si_minphys;
    177       1.47   mycroft 
    178       1.12       gwr 	/*
    179       1.24       gwr 	 *  Initialize si board itself.
    180       1.12       gwr 	 */
    181       1.47   mycroft 	ncr5380_attach(ncr_sc);
    182        1.1     glass }
    183        1.1     glass 
    184       1.24       gwr static void
    185       1.24       gwr si_minphys(struct buf *bp)
    186        1.1     glass {
    187  1.60.44.1       mjf 
    188       1.24       gwr 	if (bp->b_bcount > MAX_DMA_LEN) {
    189       1.14       gwr #ifdef	DEBUG
    190       1.24       gwr 		if (si_debug) {
    191  1.60.44.1       mjf 			printf("%s len = 0x%x.\n", __func__, bp->b_bcount);
    192       1.24       gwr 			Debugger();
    193        1.1     glass 		}
    194       1.24       gwr #endif
    195       1.24       gwr 		bp->b_bcount = MAX_DMA_LEN;
    196        1.1     glass 	}
    197       1.52  kristerw 	minphys(bp);
    198        1.1     glass }
    199        1.1     glass 
    200        1.1     glass 
    201       1.24       gwr #define CSR_WANT (SI_CSR_SBC_IP | SI_CSR_DMA_IP | \
    202       1.24       gwr 	SI_CSR_DMA_CONFLICT | SI_CSR_DMA_BUS_ERR )
    203       1.24       gwr 
    204       1.24       gwr int
    205       1.24       gwr si_intr(void *arg)
    206        1.1     glass {
    207       1.24       gwr 	struct si_softc *sc = arg;
    208       1.24       gwr 	volatile struct si_regs *si = sc->sc_regs;
    209       1.24       gwr 	int dma_error, claimed;
    210       1.24       gwr 	u_short csr;
    211        1.1     glass 
    212       1.24       gwr 	claimed = 0;
    213       1.24       gwr 	dma_error = 0;
    214       1.24       gwr 
    215       1.24       gwr 	/* SBC interrupt? DMA interrupt? */
    216       1.24       gwr 	csr = si->si_csr;
    217       1.24       gwr 	NCR_TRACE("si_intr: csr=0x%x\n", csr);
    218       1.24       gwr 
    219       1.24       gwr 	if (csr & SI_CSR_DMA_CONFLICT) {
    220       1.24       gwr 		dma_error |= SI_CSR_DMA_CONFLICT;
    221  1.60.44.1       mjf 		printf("%s: DMA conflict\n", __func__);
    222       1.24       gwr 	}
    223       1.24       gwr 	if (csr & SI_CSR_DMA_BUS_ERR) {
    224       1.24       gwr 		dma_error |= SI_CSR_DMA_BUS_ERR;
    225  1.60.44.1       mjf 		printf("%s: DMA bus error\n", __func__);
    226       1.24       gwr 	}
    227       1.24       gwr 	if (dma_error) {
    228       1.24       gwr 		if (sc->ncr_sc.sc_state & NCR_DOINGDMA)
    229       1.24       gwr 			sc->ncr_sc.sc_state |= NCR_ABORTING;
    230       1.24       gwr 		/* Make sure we will call the main isr. */
    231       1.24       gwr 		csr |= SI_CSR_DMA_IP;
    232       1.24       gwr 	}
    233       1.24       gwr 
    234       1.24       gwr 	if (csr & (SI_CSR_SBC_IP | SI_CSR_DMA_IP)) {
    235       1.24       gwr 		claimed = ncr5380_intr(&sc->ncr_sc);
    236       1.24       gwr #ifdef	DEBUG
    237       1.24       gwr 		if (!claimed) {
    238  1.60.44.1       mjf 			printf("%s: spurious from SBC\n", __func__);
    239       1.44  jdolecek 			if (si_debug & 4)
    240       1.24       gwr 				Debugger();	/* XXX */
    241       1.24       gwr 		}
    242        1.2       gwr #endif
    243       1.35       gwr 		/* Yes, we DID cause this interrupt. */
    244       1.35       gwr 		claimed = 1;
    245       1.10       gwr 	}
    246       1.14       gwr 
    247  1.60.44.1       mjf 	return claimed;
    248        1.1     glass }
    249        1.1     glass 
    250       1.14       gwr 
    251       1.24       gwr /*****************************************************************
    252       1.24       gwr  * Common functions for DMA
    253       1.24       gwr  ****************************************************************/
    254        1.1     glass 
    255       1.24       gwr /*
    256       1.24       gwr  * Allocate a DMA handle and put it in sc->sc_dma.  Prepare
    257       1.24       gwr  * for DMA transfer.  On the Sun3, this means mapping the buffer
    258       1.24       gwr  * into DVMA space.  dvma_mapin() flushes the cache for us.
    259       1.24       gwr  */
    260       1.56       chs void
    261       1.56       chs si_dma_alloc(struct ncr5380_softc *ncr_sc)
    262       1.24       gwr {
    263       1.24       gwr 	struct si_softc *sc = (struct si_softc *)ncr_sc;
    264       1.24       gwr 	struct sci_req *sr = ncr_sc->sc_current;
    265       1.36    bouyer 	struct scsipi_xfer *xs = sr->sr_xs;
    266       1.24       gwr 	struct si_dma_handle *dh;
    267       1.24       gwr 	int i, xlen;
    268       1.58   tsutsui 	void *addr;
    269        1.1     glass 
    270       1.14       gwr #ifdef	DIAGNOSTIC
    271       1.24       gwr 	if (sr->sr_dma_hand != NULL)
    272  1.60.44.1       mjf 		panic("%s: already have DMA handle", __func__);
    273       1.14       gwr #endif
    274       1.14       gwr 
    275       1.58   tsutsui 	addr = ncr_sc->sc_dataptr;
    276       1.24       gwr 	xlen = ncr_sc->sc_datalen;
    277       1.13       gwr 
    278       1.24       gwr 	/* If the DMA start addr is misaligned then do PIO */
    279       1.58   tsutsui 	if (((vaddr_t)addr & 1) || (xlen & 1)) {
    280  1.60.44.1       mjf 		printf("%s: misaligned.\n", __func__);
    281       1.24       gwr 		return;
    282        1.1     glass 	}
    283        1.1     glass 
    284       1.24       gwr 	/* Make sure our caller checked sc_min_dma_len. */
    285       1.24       gwr 	if (xlen < MIN_DMA_LEN)
    286  1.60.44.1       mjf 		panic("%s: xlen=0x%x", __func__, xlen);
    287       1.14       gwr 
    288       1.24       gwr 	/*
    289       1.24       gwr 	 * Never attempt single transfers of more than 63k, because
    290       1.24       gwr 	 * our count register may be only 16 bits (an OBIO adapter).
    291       1.24       gwr 	 * This should never happen since already bounded by minphys().
    292       1.24       gwr 	 * XXX - Should just segment these...
    293       1.24       gwr 	 */
    294       1.24       gwr 	if (xlen > MAX_DMA_LEN) {
    295  1.60.44.1       mjf 		printf("%s: excessive xlen=0x%x\n", __func__, xlen);
    296       1.24       gwr 		Debugger();
    297       1.24       gwr 		ncr_sc->sc_datalen = xlen = MAX_DMA_LEN;
    298       1.24       gwr 	}
    299       1.24       gwr 
    300       1.24       gwr 	/* Find free DMA handle.  Guaranteed to find one since we have
    301       1.24       gwr 	   as many DMA handles as the driver has processes. */
    302       1.24       gwr 	for (i = 0; i < SCI_OPENINGS; i++) {
    303       1.24       gwr 		if ((sc->sc_dma[i].dh_flags & SIDH_BUSY) == 0)
    304       1.24       gwr 			goto found;
    305       1.24       gwr 	}
    306       1.24       gwr 	panic("si: no free DMA handles.");
    307       1.24       gwr found:
    308       1.24       gwr 
    309       1.24       gwr 	dh = &sc->sc_dma[i];
    310       1.24       gwr 	dh->dh_flags = SIDH_BUSY;
    311       1.58   tsutsui 
    312       1.58   tsutsui 	if (bus_dmamap_load(sc->sc_dmat, sc->sc_dmap, addr, xlen, NULL,
    313       1.58   tsutsui 	    BUS_DMA_NOWAIT) != 0)
    314  1.60.44.1       mjf 		panic("%s: can't load dmamap", device_xname(ncr_sc->sc_dev));
    315       1.59   tsutsui 	dh->dh_dmaaddr = sc->sc_dmap->dm_segs[0].ds_addr;
    316       1.58   tsutsui 	dh->dh_dmalen  = xlen;
    317       1.24       gwr 
    318       1.24       gwr 	/* Copy the "write" flag for convenience. */
    319       1.45  jdolecek 	if (xs->xs_control & XS_CTL_DATA_OUT)
    320       1.24       gwr 		dh->dh_flags |= SIDH_OUT;
    321       1.17       gwr 
    322       1.58   tsutsui 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dmap, 0, dh->dh_dmalen,
    323       1.58   tsutsui 	    (dh->dh_flags & SIDH_OUT) == 0 ?
    324       1.58   tsutsui 	    BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
    325       1.58   tsutsui 
    326       1.24       gwr #if 0
    327       1.24       gwr 	/*
    328       1.24       gwr 	 * Some machines might not need to remap B_PHYS buffers.
    329       1.24       gwr 	 * The sun3 does not map B_PHYS buffers into DVMA space,
    330       1.24       gwr 	 * (they are mapped into normal KV space) so on the sun3
    331       1.24       gwr 	 * we must always remap to a DVMA address here. Re-map is
    332       1.24       gwr 	 * cheap anyway, because it's done by segments, not pages.
    333       1.24       gwr 	 */
    334       1.24       gwr 	if (xs->bp && (xs->bp->b_flags & B_PHYS))
    335       1.24       gwr 		dh->dh_flags |= SIDH_PHYS;
    336       1.14       gwr #endif
    337       1.17       gwr 
    338       1.24       gwr 	/* success */
    339       1.24       gwr 	sr->sr_dma_hand = dh;
    340        1.1     glass 
    341       1.24       gwr 	return;
    342        1.1     glass }
    343        1.1     glass 
    344        1.1     glass 
    345       1.56       chs void
    346       1.56       chs si_dma_free(struct ncr5380_softc *ncr_sc)
    347        1.1     glass {
    348       1.58   tsutsui 	struct si_softc *sc = (struct si_softc *)ncr_sc;
    349       1.24       gwr 	struct sci_req *sr = ncr_sc->sc_current;
    350       1.24       gwr 	struct si_dma_handle *dh = sr->sr_dma_hand;
    351        1.1     glass 
    352       1.24       gwr #ifdef	DIAGNOSTIC
    353       1.24       gwr 	if (dh == NULL)
    354  1.60.44.1       mjf 		panic("%s: no DMA handle", __func__);
    355       1.24       gwr #endif
    356        1.1     glass 
    357       1.24       gwr 	if (ncr_sc->sc_state & NCR_DOINGDMA)
    358  1.60.44.1       mjf 		panic("%s: free while in progress", __func__);
    359        1.1     glass 
    360       1.24       gwr 	if (dh->dh_flags & SIDH_BUSY) {
    361       1.58   tsutsui 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dmap, 0, dh->dh_dmalen,
    362       1.58   tsutsui 		    (dh->dh_flags & SIDH_OUT) == 0 ?
    363       1.58   tsutsui 		    BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
    364       1.58   tsutsui 		bus_dmamap_unload(sc->sc_dmat, sc->sc_dmap);
    365       1.58   tsutsui 		dh->dh_dmaaddr = 0;
    366       1.24       gwr 		dh->dh_flags = 0;
    367        1.1     glass 	}
    368       1.24       gwr 	sr->sr_dma_hand = NULL;
    369        1.1     glass }
    370        1.1     glass 
    371        1.1     glass 
    372       1.25       gwr #define	CSR_MASK (SI_CSR_SBC_IP | SI_CSR_DMA_IP | \
    373       1.25       gwr 		SI_CSR_DMA_CONFLICT | SI_CSR_DMA_BUS_ERR)
    374       1.25       gwr #define	POLL_TIMO	50000	/* X100 = 5 sec. */
    375       1.25       gwr 
    376       1.24       gwr /*
    377       1.24       gwr  * Poll (spin-wait) for DMA completion.
    378       1.24       gwr  * Called right after xx_dma_start(), and
    379       1.24       gwr  * xx_dma_stop() will be called next.
    380       1.24       gwr  * Same for either VME or OBIO.
    381       1.24       gwr  */
    382       1.56       chs void
    383       1.56       chs si_dma_poll(struct ncr5380_softc *ncr_sc)
    384       1.24       gwr {
    385       1.24       gwr 	struct si_softc *sc = (struct si_softc *)ncr_sc;
    386       1.24       gwr 	struct sci_req *sr = ncr_sc->sc_current;
    387       1.24       gwr 	volatile struct si_regs *si = sc->sc_regs;
    388       1.25       gwr 	int tmo;
    389        1.1     glass 
    390       1.24       gwr 	/* Make sure DMA started successfully. */
    391       1.24       gwr 	if (ncr_sc->sc_state & NCR_ABORTING)
    392       1.24       gwr 		return;
    393        1.1     glass 
    394       1.25       gwr 	/*
    395       1.25       gwr 	 * XXX: The Sun driver waits for ~SI_CSR_DMA_ACTIVE here
    396       1.25       gwr 	 * XXX: (on obio) or even worse (on vme) a 10mS. delay!
    397       1.25       gwr 	 * XXX: I really doubt that is necessary...
    398       1.25       gwr 	 */
    399        1.1     glass 
    400       1.53       wiz 	/* Wait for any "DMA complete" or error bits. */
    401       1.25       gwr 	tmo = POLL_TIMO;
    402       1.24       gwr 	for (;;) {
    403       1.25       gwr 		if (si->si_csr & CSR_MASK)
    404       1.24       gwr 			break;
    405       1.24       gwr 		if (--tmo <= 0) {
    406       1.29  christos 			printf("si: DMA timeout (while polling)\n");
    407       1.24       gwr 			/* Indicate timeout as MI code would. */
    408       1.24       gwr 			sr->sr_flags |= SR_OVERDUE;
    409       1.24       gwr 			break;
    410        1.1     glass 		}
    411       1.24       gwr 		delay(100);
    412        1.1     glass 	}
    413       1.25       gwr 	NCR_TRACE("si_dma_poll: waited %d\n",
    414       1.25       gwr 			  POLL_TIMO - tmo);
    415        1.1     glass 
    416       1.17       gwr #ifdef	DEBUG
    417       1.25       gwr 	if (si_debug & 2) {
    418  1.60.44.1       mjf 		printf("%s: done, csr=0x%x\n", __func__, si->si_csr);
    419       1.17       gwr 	}
    420       1.17       gwr #endif
    421        1.1     glass }
    422