si.c revision 1.24 1 1.24 gwr /* $NetBSD: si.c,v 1.24 1996/03/26 15:01:10 gwr Exp $ */
2 1.8 cgd
3 1.1 glass /*
4 1.24 gwr * Copyright (c) 1995 David Jones, Gordon W. Ross
5 1.24 gwr * Copyright (c) 1994 Adam Glass
6 1.1 glass * All rights reserved.
7 1.1 glass *
8 1.1 glass * Redistribution and use in source and binary forms, with or without
9 1.1 glass * modification, are permitted provided that the following conditions
10 1.1 glass * are met:
11 1.1 glass * 1. Redistributions of source code must retain the above copyright
12 1.1 glass * notice, this list of conditions and the following disclaimer.
13 1.1 glass * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 glass * notice, this list of conditions and the following disclaimer in the
15 1.1 glass * documentation and/or other materials provided with the distribution.
16 1.24 gwr * 3. The name of the authors may not be used to endorse or promote products
17 1.24 gwr * derived from this software without specific prior written permission.
18 1.24 gwr * 4. All advertising materials mentioning features or use of this software
19 1.1 glass * must display the following acknowledgement:
20 1.24 gwr * This product includes software developed by
21 1.24 gwr * Adam Glass, David Jones, and Gordon Ross
22 1.1 glass *
23 1.24 gwr * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
24 1.1 glass * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1 glass * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.24 gwr * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1 glass * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1 glass * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1 glass * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1 glass * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.24 gwr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.24 gwr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1 glass */
34 1.1 glass
35 1.24 gwr /*
36 1.24 gwr * This file contains only the machine-dependent parts of the
37 1.24 gwr * Sun3 SCSI driver. (Autoconfig stuff and DMA functions.)
38 1.24 gwr * The machine-independent parts are in ncr5380sbc.c
39 1.24 gwr *
40 1.24 gwr * Supported hardware includes:
41 1.24 gwr * Sun SCSI-3 on OBIO (Sun3/50,Sun3/60)
42 1.24 gwr * Sun SCSI-3 on VME (Sun3/160,Sun3/260)
43 1.24 gwr *
44 1.24 gwr * Could be made to support the Sun3/E if someone wanted to.
45 1.24 gwr *
46 1.24 gwr * Note: Both supported variants of the Sun SCSI-3 adapter have
47 1.24 gwr * some really unusual "features" for this driver to deal with,
48 1.24 gwr * generally related to the DMA engine. The OBIO variant will
49 1.24 gwr * ignore any attempt to write the FIFO count register while the
50 1.24 gwr * SCSI bus is in DATA_IN or DATA_OUT phase. This is dealt with
51 1.24 gwr * by setting the FIFO count early in COMMAND or MSG_IN phase.
52 1.24 gwr *
53 1.24 gwr * The VME variant has a bit to enable or disable the DMA engine,
54 1.24 gwr * but that bit also gates the interrupt line from the NCR5380!
55 1.24 gwr * Therefore, in order to get any interrupt from the 5380, (i.e.
56 1.24 gwr * for reselect) one must clear the DMA engine transfer count and
57 1.24 gwr * then enable DMA. This has the further complication that you
58 1.24 gwr * CAN NOT touch the NCR5380 while the DMA enable bit is set, so
59 1.24 gwr * we have to turn DMA back off before we even look at the 5380.
60 1.24 gwr *
61 1.24 gwr * What wonderfully whacky hardware this is!
62 1.24 gwr *
63 1.24 gwr * Credits, history:
64 1.24 gwr *
65 1.24 gwr * David Jones wrote the initial version of this module, which
66 1.24 gwr * included support for the VME adapter only. (no reselection).
67 1.24 gwr *
68 1.24 gwr * Gordon Ross added support for the OBIO adapter, and re-worked
69 1.24 gwr * both the VME and OBIO code to support disconnect/reselect.
70 1.24 gwr * (Required figuring out the hardware "features" noted above.)
71 1.24 gwr *
72 1.24 gwr * The autoconfiguration boilerplate came from Adam Glass.
73 1.24 gwr */
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.24 gwr #include <scsi/scsi_all.h>
86 1.24 gwr #include <scsi/scsi_debug.h>
87 1.24 gwr #include <scsi/scsiconf.h>
88 1.1 glass
89 1.1 glass #include <machine/autoconf.h>
90 1.1 glass #include <machine/isr.h>
91 1.1 glass #include <machine/obio.h>
92 1.24 gwr #include <machine/dvma.h>
93 1.1 glass
94 1.24 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.24 gwr int si_debug = 0;
103 1.14 gwr #ifdef DEBUG
104 1.24 gwr static int si_link_flags = 0 /* | SDEV_DB2 */ ;
105 1.14 gwr #endif
106 1.1 glass
107 1.24 gwr /* How long to wait for DMA before declaring an error. */
108 1.24 gwr int si_dma_intr_timo = 500; /* ticks (sec. X 100) */
109 1.1 glass
110 1.24 gwr static void si_minphys __P((struct buf *));
111 1.24 gwr static int si_print __P((void *, char *));
112 1.1 glass
113 1.24 gwr static struct scsi_adapter si_ops = {
114 1.1 glass ncr5380_scsi_cmd, /* scsi_cmd() */
115 1.24 gwr si_minphys, /* scsi_minphys() */
116 1.12 gwr NULL, /* open_target_lu() */
117 1.12 gwr NULL, /* close_target_lu() */
118 1.1 glass };
119 1.1 glass
120 1.1 glass /* This is copied from julian's bt driver */
121 1.1 glass /* "so we have a default dev struct for our link struct." */
122 1.24 gwr static struct scsi_device si_dev = {
123 1.1 glass NULL, /* Use default error handler. */
124 1.2 gwr NULL, /* Use default start handler. */
125 1.2 gwr NULL, /* Use default async handler. */
126 1.1 glass NULL, /* Use default "done" routine. */
127 1.1 glass };
128 1.1 glass
129 1.24 gwr /*
130 1.24 gwr * New-style autoconfig attachment. The cfattach
131 1.24 gwr * structures are in si_obio.c and si_vme.c
132 1.24 gwr */
133 1.1 glass
134 1.24 gwr struct cfdriver si_cd = {
135 1.24 gwr NULL, "si", DV_DULL
136 1.2 gwr };
137 1.1 glass
138 1.1 glass
139 1.24 gwr void
140 1.24 gwr si_attach(sc)
141 1.24 gwr struct si_softc *sc;
142 1.24 gwr {
143 1.24 gwr struct ncr5380_softc *ncr_sc = (void *)sc;
144 1.24 gwr volatile struct si_regs *regs = sc->sc_regs;
145 1.24 gwr int i;
146 1.16 gwr
147 1.16 gwr /*
148 1.24 gwr * Fill in the prototype scsi_link.
149 1.16 gwr */
150 1.24 gwr ncr_sc->sc_link.adapter_softc = sc;
151 1.24 gwr ncr_sc->sc_link.adapter_target = 7;
152 1.24 gwr ncr_sc->sc_link.adapter = &si_ops;
153 1.24 gwr ncr_sc->sc_link.device = &si_dev;
154 1.13 gwr
155 1.24 gwr #ifdef DEBUG
156 1.24 gwr if (si_debug)
157 1.24 gwr printf("si: Set TheSoftC=%x TheRegs=%x\n", sc, regs);
158 1.24 gwr ncr_sc->sc_link.flags |= si_link_flags;
159 1.24 gwr #endif
160 1.1 glass
161 1.24 gwr /*
162 1.24 gwr * Initialize fields used by the MI code
163 1.24 gwr */
164 1.24 gwr ncr_sc->sci_r0 = ®s->sci.sci_r0;
165 1.24 gwr ncr_sc->sci_r1 = ®s->sci.sci_r1;
166 1.24 gwr ncr_sc->sci_r2 = ®s->sci.sci_r2;
167 1.24 gwr ncr_sc->sci_r3 = ®s->sci.sci_r3;
168 1.24 gwr ncr_sc->sci_r4 = ®s->sci.sci_r4;
169 1.24 gwr ncr_sc->sci_r5 = ®s->sci.sci_r5;
170 1.24 gwr ncr_sc->sci_r6 = ®s->sci.sci_r6;
171 1.24 gwr ncr_sc->sci_r7 = ®s->sci.sci_r7;
172 1.12 gwr
173 1.24 gwr /*
174 1.24 gwr * Allocate DMA handles.
175 1.24 gwr */
176 1.24 gwr i = SCI_OPENINGS * sizeof(struct si_dma_handle);
177 1.24 gwr sc->sc_dma = (struct si_dma_handle *)
178 1.24 gwr malloc(i, M_DEVBUF, M_WAITOK);
179 1.24 gwr if (sc->sc_dma == NULL)
180 1.24 gwr panic("si: dvma_malloc failed\n");
181 1.24 gwr for (i = 0; i < SCI_OPENINGS; i++)
182 1.24 gwr sc->sc_dma[i].dh_flags = 0;
183 1.12 gwr
184 1.12 gwr /*
185 1.24 gwr * Initialize si board itself.
186 1.12 gwr */
187 1.24 gwr si_reset_adapter(ncr_sc);
188 1.24 gwr ncr5380_init(ncr_sc);
189 1.24 gwr ncr5380_reset_scsibus(ncr_sc);
190 1.24 gwr config_found(&(ncr_sc->sc_dev), &(ncr_sc->sc_link), si_print);
191 1.1 glass }
192 1.1 glass
193 1.24 gwr static int
194 1.24 gwr si_print(aux, name)
195 1.24 gwr void *aux;
196 1.24 gwr char *name;
197 1.1 glass {
198 1.24 gwr if (name != NULL)
199 1.24 gwr printf("%s: scsibus ", name);
200 1.24 gwr return UNCONF;
201 1.1 glass }
202 1.1 glass
203 1.24 gwr static void
204 1.24 gwr si_minphys(struct buf *bp)
205 1.1 glass {
206 1.24 gwr if (bp->b_bcount > MAX_DMA_LEN) {
207 1.14 gwr #ifdef DEBUG
208 1.24 gwr if (si_debug) {
209 1.24 gwr printf("si_minphys len = 0x%x.\n", bp->b_bcount);
210 1.24 gwr Debugger();
211 1.1 glass }
212 1.24 gwr #endif
213 1.24 gwr bp->b_bcount = MAX_DMA_LEN;
214 1.1 glass }
215 1.24 gwr return (minphys(bp));
216 1.1 glass }
217 1.1 glass
218 1.1 glass
219 1.24 gwr #define CSR_WANT (SI_CSR_SBC_IP | SI_CSR_DMA_IP | \
220 1.24 gwr SI_CSR_DMA_CONFLICT | SI_CSR_DMA_BUS_ERR )
221 1.24 gwr
222 1.24 gwr int
223 1.24 gwr si_intr(void *arg)
224 1.1 glass {
225 1.24 gwr struct si_softc *sc = arg;
226 1.24 gwr volatile struct si_regs *si = sc->sc_regs;
227 1.24 gwr int dma_error, claimed;
228 1.24 gwr u_short csr;
229 1.1 glass
230 1.24 gwr claimed = 0;
231 1.24 gwr dma_error = 0;
232 1.24 gwr
233 1.24 gwr /* SBC interrupt? DMA interrupt? */
234 1.24 gwr csr = si->si_csr;
235 1.24 gwr NCR_TRACE("si_intr: csr=0x%x\n", csr);
236 1.24 gwr
237 1.24 gwr if (csr & SI_CSR_DMA_CONFLICT) {
238 1.24 gwr dma_error |= SI_CSR_DMA_CONFLICT;
239 1.24 gwr printf("si_intr: DMA conflict\n");
240 1.24 gwr }
241 1.24 gwr if (csr & SI_CSR_DMA_BUS_ERR) {
242 1.24 gwr dma_error |= SI_CSR_DMA_BUS_ERR;
243 1.24 gwr printf("si_intr: DMA bus error\n");
244 1.24 gwr }
245 1.24 gwr if (dma_error) {
246 1.24 gwr if (sc->ncr_sc.sc_state & NCR_DOINGDMA)
247 1.24 gwr sc->ncr_sc.sc_state |= NCR_ABORTING;
248 1.24 gwr /* Make sure we will call the main isr. */
249 1.24 gwr csr |= SI_CSR_DMA_IP;
250 1.24 gwr }
251 1.24 gwr
252 1.24 gwr if (csr & (SI_CSR_SBC_IP | SI_CSR_DMA_IP)) {
253 1.24 gwr claimed = ncr5380_intr(&sc->ncr_sc);
254 1.24 gwr #ifdef DEBUG
255 1.24 gwr if (!claimed) {
256 1.24 gwr printf("si_intr: spurious from SBC\n");
257 1.24 gwr if (si_debug & 4) {
258 1.24 gwr Debugger(); /* XXX */
259 1.24 gwr }
260 1.24 gwr }
261 1.2 gwr #endif
262 1.10 gwr }
263 1.14 gwr
264 1.24 gwr return (claimed);
265 1.1 glass }
266 1.1 glass
267 1.14 gwr
268 1.24 gwr void
269 1.24 gwr si_reset_adapter(struct ncr5380_softc *ncr_sc)
270 1.14 gwr {
271 1.24 gwr struct si_softc *sc = (struct si_softc *)ncr_sc;
272 1.17 gwr volatile struct si_regs *si = sc->sc_regs;
273 1.14 gwr
274 1.14 gwr #ifdef DEBUG
275 1.14 gwr if (si_debug) {
276 1.14 gwr printf("si_reset_adapter\n");
277 1.14 gwr }
278 1.2 gwr #endif
279 1.14 gwr
280 1.24 gwr /*
281 1.24 gwr * The SCSI3 controller has an 8K FIFO to buffer data between the
282 1.24 gwr * 5380 and the DMA. Make sure it starts out empty.
283 1.24 gwr *
284 1.24 gwr * The reset bits in the CSR are active low.
285 1.24 gwr */
286 1.14 gwr si->si_csr = 0;
287 1.24 gwr delay(10);
288 1.24 gwr si->si_csr = SI_CSR_FIFO_RES | SI_CSR_SCSI_RES | SI_CSR_INTR_EN;
289 1.24 gwr delay(10);
290 1.17 gwr si->fifo_count = 0;
291 1.24 gwr
292 1.17 gwr if (sc->sc_adapter_type == BUS_VME16) {
293 1.17 gwr si->dma_addrh = 0;
294 1.17 gwr si->dma_addrl = 0;
295 1.17 gwr si->dma_counth = 0;
296 1.17 gwr si->dma_countl = 0;
297 1.24 gwr si->si_iv_am = sc->sc_adapter_iv_am;
298 1.24 gwr si->fifo_cnt_hi = 0;
299 1.17 gwr }
300 1.24 gwr
301 1.24 gwr SCI_CLR_INTR(ncr_sc);
302 1.1 glass }
303 1.1 glass
304 1.2 gwr
305 1.24 gwr /*****************************************************************
306 1.24 gwr * Common functions for DMA
307 1.24 gwr ****************************************************************/
308 1.1 glass
309 1.24 gwr /*
310 1.24 gwr * Allocate a DMA handle and put it in sc->sc_dma. Prepare
311 1.24 gwr * for DMA transfer. On the Sun3, this means mapping the buffer
312 1.24 gwr * into DVMA space. dvma_mapin() flushes the cache for us.
313 1.24 gwr */
314 1.24 gwr void
315 1.24 gwr si_dma_alloc(ncr_sc)
316 1.24 gwr struct ncr5380_softc *ncr_sc;
317 1.24 gwr {
318 1.24 gwr struct si_softc *sc = (struct si_softc *)ncr_sc;
319 1.24 gwr struct sci_req *sr = ncr_sc->sc_current;
320 1.24 gwr struct scsi_xfer *xs = sr->sr_xs;
321 1.24 gwr struct si_dma_handle *dh;
322 1.24 gwr int i, xlen;
323 1.24 gwr u_long addr;
324 1.1 glass
325 1.14 gwr #ifdef DIAGNOSTIC
326 1.24 gwr if (sr->sr_dma_hand != NULL)
327 1.24 gwr panic("si_dma_alloc: already have DMA handle");
328 1.14 gwr #endif
329 1.14 gwr
330 1.24 gwr addr = (u_long) ncr_sc->sc_dataptr;
331 1.24 gwr xlen = ncr_sc->sc_datalen;
332 1.13 gwr
333 1.24 gwr /* If the DMA start addr is misaligned then do PIO */
334 1.24 gwr if ((addr & 1) || (xlen & 1)) {
335 1.24 gwr printf("si_dma_alloc: misaligned.\n");
336 1.24 gwr return;
337 1.1 glass }
338 1.1 glass
339 1.24 gwr /* Make sure our caller checked sc_min_dma_len. */
340 1.24 gwr if (xlen < MIN_DMA_LEN)
341 1.24 gwr panic("si_dma_alloc: xlen=0x%x\n", xlen);
342 1.14 gwr
343 1.24 gwr /*
344 1.24 gwr * Never attempt single transfers of more than 63k, because
345 1.24 gwr * our count register may be only 16 bits (an OBIO adapter).
346 1.24 gwr * This should never happen since already bounded by minphys().
347 1.24 gwr * XXX - Should just segment these...
348 1.24 gwr */
349 1.24 gwr if (xlen > MAX_DMA_LEN) {
350 1.24 gwr printf("si_dma_alloc: excessive xlen=0x%x\n", xlen);
351 1.24 gwr Debugger();
352 1.24 gwr ncr_sc->sc_datalen = xlen = MAX_DMA_LEN;
353 1.24 gwr }
354 1.24 gwr
355 1.24 gwr /* Find free DMA handle. Guaranteed to find one since we have
356 1.24 gwr as many DMA handles as the driver has processes. */
357 1.24 gwr for (i = 0; i < SCI_OPENINGS; i++) {
358 1.24 gwr if ((sc->sc_dma[i].dh_flags & SIDH_BUSY) == 0)
359 1.24 gwr goto found;
360 1.24 gwr }
361 1.24 gwr panic("si: no free DMA handles.");
362 1.24 gwr found:
363 1.24 gwr
364 1.24 gwr dh = &sc->sc_dma[i];
365 1.24 gwr dh->dh_flags = SIDH_BUSY;
366 1.24 gwr dh->dh_addr = (u_char*) addr;
367 1.24 gwr dh->dh_maplen = xlen;
368 1.24 gwr dh->dh_dvma = 0;
369 1.24 gwr
370 1.24 gwr /* Copy the "write" flag for convenience. */
371 1.24 gwr if (xs->flags & SCSI_DATA_OUT)
372 1.24 gwr dh->dh_flags |= SIDH_OUT;
373 1.17 gwr
374 1.24 gwr #if 0
375 1.24 gwr /*
376 1.24 gwr * Some machines might not need to remap B_PHYS buffers.
377 1.24 gwr * The sun3 does not map B_PHYS buffers into DVMA space,
378 1.24 gwr * (they are mapped into normal KV space) so on the sun3
379 1.24 gwr * we must always remap to a DVMA address here. Re-map is
380 1.24 gwr * cheap anyway, because it's done by segments, not pages.
381 1.24 gwr */
382 1.24 gwr if (xs->bp && (xs->bp->b_flags & B_PHYS))
383 1.24 gwr dh->dh_flags |= SIDH_PHYS;
384 1.14 gwr #endif
385 1.17 gwr
386 1.24 gwr dh->dh_dvma = (u_long) dvma_mapin((char *)addr, xlen);
387 1.24 gwr if (!dh->dh_dvma) {
388 1.24 gwr /* Can't remap segment */
389 1.24 gwr printf("si_dma_alloc: can't remap %x/%x\n",
390 1.24 gwr dh->dh_addr, dh->dh_maplen);
391 1.24 gwr dh->dh_flags = 0;
392 1.24 gwr return;
393 1.14 gwr }
394 1.1 glass
395 1.24 gwr /* success */
396 1.24 gwr sr->sr_dma_hand = dh;
397 1.1 glass
398 1.24 gwr return;
399 1.1 glass }
400 1.1 glass
401 1.1 glass
402 1.24 gwr void
403 1.24 gwr si_dma_free(ncr_sc)
404 1.24 gwr struct ncr5380_softc *ncr_sc;
405 1.1 glass {
406 1.24 gwr struct sci_req *sr = ncr_sc->sc_current;
407 1.24 gwr struct si_dma_handle *dh = sr->sr_dma_hand;
408 1.1 glass
409 1.24 gwr #ifdef DIAGNOSTIC
410 1.24 gwr if (dh == NULL)
411 1.24 gwr panic("si_dma_free: no DMA handle");
412 1.24 gwr #endif
413 1.1 glass
414 1.24 gwr if (ncr_sc->sc_state & NCR_DOINGDMA)
415 1.24 gwr panic("si_dma_free: free while in progress");
416 1.1 glass
417 1.24 gwr if (dh->dh_flags & SIDH_BUSY) {
418 1.24 gwr /* XXX - Should separate allocation and mapping. */
419 1.24 gwr /* Give back the DVMA space. */
420 1.24 gwr dvma_mapout((caddr_t)dh->dh_dvma, dh->dh_maplen);
421 1.24 gwr dh->dh_dvma = 0;
422 1.24 gwr dh->dh_flags = 0;
423 1.1 glass }
424 1.24 gwr sr->sr_dma_hand = NULL;
425 1.1 glass }
426 1.1 glass
427 1.1 glass
428 1.24 gwr /*
429 1.24 gwr * Poll (spin-wait) for DMA completion.
430 1.24 gwr * Called right after xx_dma_start(), and
431 1.24 gwr * xx_dma_stop() will be called next.
432 1.24 gwr * Same for either VME or OBIO.
433 1.24 gwr */
434 1.24 gwr void
435 1.24 gwr si_dma_poll(ncr_sc)
436 1.24 gwr struct ncr5380_softc *ncr_sc;
437 1.24 gwr {
438 1.24 gwr struct si_softc *sc = (struct si_softc *)ncr_sc;
439 1.24 gwr struct sci_req *sr = ncr_sc->sc_current;
440 1.24 gwr struct si_dma_handle *dh = sr->sr_dma_hand;
441 1.24 gwr volatile struct si_regs *si = sc->sc_regs;
442 1.24 gwr int tmo, csr_mask;
443 1.1 glass
444 1.24 gwr /* Make sure DMA started successfully. */
445 1.24 gwr if (ncr_sc->sc_state & NCR_ABORTING)
446 1.24 gwr return;
447 1.1 glass
448 1.24 gwr csr_mask = SI_CSR_SBC_IP | SI_CSR_DMA_IP |
449 1.24 gwr SI_CSR_DMA_CONFLICT | SI_CSR_DMA_BUS_ERR;
450 1.1 glass
451 1.24 gwr tmo = 50000; /* X100 = 5 sec. */
452 1.24 gwr for (;;) {
453 1.24 gwr if (si->si_csr & csr_mask)
454 1.24 gwr break;
455 1.24 gwr if (--tmo <= 0) {
456 1.24 gwr printf("si: DMA timeout (while polling)\n");
457 1.24 gwr /* Indicate timeout as MI code would. */
458 1.24 gwr sr->sr_flags |= SR_OVERDUE;
459 1.24 gwr break;
460 1.1 glass }
461 1.24 gwr delay(100);
462 1.1 glass }
463 1.1 glass
464 1.17 gwr #ifdef DEBUG
465 1.17 gwr if (si_debug) {
466 1.24 gwr printf("si_dma_poll: done, csr=0x%x\n", si->si_csr);
467 1.17 gwr }
468 1.17 gwr #endif
469 1.1 glass }
470 1.1 glass
471