Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mac68k/dev add fault-protection in sbc_pdma_in() li...



details:   https://anonhg.NetBSD.org/src/rev/3292989f8af0
branches:  trunk
changeset: 587268:3292989f8af0
user:      chs <chs%NetBSD.org@localhost>
date:      Tue Jan 17 16:41:29 2006 +0000

description:
add fault-protection in sbc_pdma_in() like in all the other PDMA functions.
fixes PR 9679.

diffstat:

 sys/arch/mac68k/dev/sbc.c |  20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diffs (57 lines):

diff -r 83c834dfe33e -r 3292989f8af0 sys/arch/mac68k/dev/sbc.c
--- a/sys/arch/mac68k/dev/sbc.c Tue Jan 17 13:23:02 2006 +0000
+++ b/sys/arch/mac68k/dev/sbc.c Tue Jan 17 16:41:29 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbc.c,v 1.48 2005/12/24 23:24:00 perry Exp $   */
+/*     $NetBSD: sbc.c,v 1.49 2006/01/17 16:41:29 chs Exp $     */
 
 /*
  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbc.c,v 1.48 2005/12/24 23:24:00 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbc.c,v 1.49 2006/01/17 16:41:29 chs Exp $");
 
 #include "opt_ddb.h"
 
@@ -246,6 +246,7 @@
        struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
        volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
        volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
+       label_t faultbuf;
        int resid, s;
 
        if (datalen < ncr_sc->sc_min_dma_len ||
@@ -261,9 +262,21 @@
        *ncr_sc->sci_mode |= SCI_MODE_DMA;
        *ncr_sc->sci_irecv = 0;
 
+       resid = datalen;
+
+       /*
+        * Setup for a possible bus error caused by SCSI controller
+        * switching out of DATA OUT before we're done with the
+        * current transfer.  (See comment before sbc_drq_intr().)
+        */
+       nofault = &faultbuf;
+       if (setjmp(nofault)) {
+               goto interrupt;
+       }
+
 #define R4     *((u_int32_t *)data)++ = *long_data
 #define R1     *((u_int8_t *)data)++ = *byte_data
-       for (resid = datalen; resid >= 128; resid -= 128) {
+       for (; resid >= 128; resid -= 128) {
                if (sbc_ready(ncr_sc))
                        goto interrupt;
                R4; R4; R4; R4; R4; R4; R4; R4;
@@ -281,6 +294,7 @@
 #undef R1
 
 interrupt:
+       nofault = NULL;
        SCI_CLR_INTR(ncr_sc);
        *ncr_sc->sci_mode &= ~SCI_MODE_DMA;
        *ncr_sc->sci_icmd = 0;



Home | Main Index | Thread Index | Old Index