Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic It's not safe to access the SCNTL1 register while...



details:   https://anonhg.NetBSD.org/src/rev/70ffb70ef642
branches:  trunk
changeset: 526115:70ffb70ef642
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Apr 25 20:05:10 2002 +0000

description:
It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.

diffstat:

 sys/dev/ic/esiop.c       |  14 ++++++++++----
 sys/dev/ic/siop.c        |  21 +++++++++++++++++----
 sys/dev/ic/siop_common.c |  21 +++++++++------------
 3 files changed, 36 insertions(+), 20 deletions(-)

diffs (164 lines):

diff -r 1ecd5d5adf74 -r 70ffb70ef642 sys/dev/ic/esiop.c
--- a/sys/dev/ic/esiop.c        Thu Apr 25 19:47:52 2002 +0000
+++ b/sys/dev/ic/esiop.c        Thu Apr 25 20:05:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: esiop.c,v 1.9 2002/04/25 19:34:02 bouyer Exp $ */
+/*     $NetBSD: esiop.c,v 1.10 2002/04/25 20:05:10 bouyer Exp $        */
 
 /*
  * Copyright (c) 2002 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esiop.c,v 1.9 2002/04/25 19:34:02 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esiop.c,v 1.10 2002/04/25 20:05:10 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -396,6 +396,7 @@
 
        if ((istat &(ISTAT_DIP | ISTAT_SIP | ISTAT_ABRT)) == 
            (ISTAT_DIP | ISTAT_ABRT)) {
+               /* clear abort */
                bus_space_write_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
                    SIOP_ISTAT, 0);
        }
@@ -457,6 +458,12 @@
        if (istat & ISTAT_DIP) {
                dstat = bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
                    SIOP_DSTAT);
+               if (dstat & DSTAT_ABRT) {
+                       /* was probably generated by a bus reset IOCTL */
+                       if ((dstat & DSTAT_DFE) == 0)
+                               siop_clearfifo(&sc->sc_c);
+                       goto reset;
+               }
                if (dstat & DSTAT_SSI) {
                        printf("single step dsp 0x%08x dsa 0x08%x\n",
                            (int)(bus_space_read_4(sc->sc_c.sc_rt,
@@ -473,12 +480,11 @@
                        }
                        return 1;
                }
+
                if (dstat & ~(DSTAT_SIR | DSTAT_DFE | DSTAT_SSI)) {
                printf("%s: DMA IRQ:", sc->sc_c.sc_dev.dv_xname);
                if (dstat & DSTAT_IID)
                        printf(" Illegal instruction");
-               if (dstat & DSTAT_ABRT)
-                       printf(" abort");
                if (dstat & DSTAT_BF)
                        printf(" bus fault");
                if (dstat & DSTAT_MDPE)
diff -r 1ecd5d5adf74 -r 70ffb70ef642 sys/dev/ic/siop.c
--- a/sys/dev/ic/siop.c Thu Apr 25 19:47:52 2002 +0000
+++ b/sys/dev/ic/siop.c Thu Apr 25 20:05:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop.c,v 1.59 2002/04/23 20:41:15 bouyer Exp $ */
+/*     $NetBSD: siop.c,v 1.60 2002/04/25 20:05:10 bouyer Exp $ */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.59 2002/04/23 20:41:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.60 2002/04/25 20:05:10 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -332,6 +332,12 @@
                bus_space_write_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
                    SIOP_ISTAT, ISTAT_INTF);
        }
+       if ((istat &(ISTAT_DIP | ISTAT_SIP | ISTAT_ABRT)) ==
+           (ISTAT_DIP | ISTAT_ABRT)) {
+               /* clear abort */
+               bus_space_write_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
+                   SIOP_ISTAT, 0);
+       }
        /* use DSA to find the current siop_cmd */
        dsa = bus_space_read_4(sc->sc_c.sc_rt, sc->sc_c.sc_rh, SIOP_DSA);
        for (cbdp = TAILQ_FIRST(&sc->cmds); cbdp != NULL;
@@ -384,6 +390,12 @@
        if (istat & ISTAT_DIP) {
                dstat = bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
                    SIOP_DSTAT);
+               if (dstat & DSTAT_ABRT) {
+                       /* was probably generated by a bus reset IOCTL */
+                       if ((dstat & DSTAT_DFE) == 0)
+                               siop_clearfifo(&sc->sc_c);
+                       goto reset;
+               }
                if (dstat & DSTAT_SSI) {
                        printf("single step dsp 0x%08x dsa 0x08%x\n",
                            (int)(bus_space_read_4(sc->sc_c.sc_rt,
@@ -400,18 +412,19 @@
                        }
                        return 1;
                }
+
                if (dstat & ~(DSTAT_SIR | DSTAT_DFE | DSTAT_SSI)) {
                printf("DMA IRQ:");
                if (dstat & DSTAT_IID)
                        printf(" Illegal instruction");
-               if (dstat & DSTAT_ABRT)
-                       printf(" abort");
                if (dstat & DSTAT_BF)
                        printf(" bus fault");
                if (dstat & DSTAT_MDPE)
                        printf(" parity");
                if (dstat & DSTAT_DFE)
                        printf(" dma fifo empty");
+               else
+                       siop_clearfifo(&sc->sc_c);
                printf(", DSP=0x%x DSA=0x%x: ",
                    (int)(bus_space_read_4(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
                        SIOP_DSP) - sc->sc_c.sc_scriptaddr),
diff -r 1ecd5d5adf74 -r 70ffb70ef642 sys/dev/ic/siop_common.c
--- a/sys/dev/ic/siop_common.c  Thu Apr 25 19:47:52 2002 +0000
+++ b/sys/dev/ic/siop_common.c  Thu Apr 25 20:05:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop_common.c,v 1.23 2002/04/23 20:41:15 bouyer Exp $  */
+/*     $NetBSD: siop_common.c,v 1.24 2002/04/25 20:05:10 bouyer Exp $  */
 
 /*
  * Copyright (c) 2000, 2002 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siop_common.c,v 1.23 2002/04/23 20:41:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siop_common.c,v 1.24 2002/04/25 20:05:10 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -687,19 +687,16 @@
        struct proc *p;
 {
        struct siop_common_softc *sc = (void *)chan->chan_adapter->adapt_dev;
-       u_int8_t scntl1;
-       int s;
 
        switch (cmd) {
        case SCBUSIORESET:
-               s = splbio();
-               scntl1 = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL1);
-               bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL1,
-                   scntl1 | SCNTL1_RST);
-               /* minimum 25 us, more time won't hurt */
-               delay(100);
-               bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL1, scntl1);
-               splx(s);
+               /*
+                * abort the script. This will trigger an interrupt, which will
+                * trigger a bus reset.
+                * We can't safely trigger the reset here as we can't access
+                * the required register while the script is running.
+                */
+               bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_ISTAT, ISTAT_ABRT);
                return (0);
        default:
                return (ENOTTY);



Home | Main Index | Thread Index | Old Index