Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/dev/mscp Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/b8098d181071
branches:  netbsd-6
changeset: 774324:b8098d181071
user:      riz <riz%NetBSD.org@localhost>
date:      Thu Jul 12 17:17:26 2012 +0000

description:
Pull up following revision(s) (requested by abs in ticket #410):
        sys/dev/mscp/mscp.h: revision 1.9
        sys/dev/mscp/mscp.c: revision 1.35
        sys/dev/mscp/mscp_subr.c: revision 1.43
Adjust MSCP attach routines. The current code worked fine on simh-vax, but
unfortunately failed on at least one 'real' SCSI MSCP adaptor.
In the updated code
mscp_dorsp()

diffstat:

 sys/dev/mscp/mscp.c      |   15 ++-
 sys/dev/mscp/mscp.h      |    4 +-
 sys/dev/mscp/mscp_subr.c |  170 ++++++++++++++++++++++++----------------------
 3 files changed, 101 insertions(+), 88 deletions(-)

diffs (278 lines):

diff -r e5aeb9c636d7 -r b8098d181071 sys/dev/mscp/mscp.c
--- a/sys/dev/mscp/mscp.c       Thu Jul 12 17:15:17 2012 +0000
+++ b/sys/dev/mscp/mscp.c       Thu Jul 12 17:17:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp.c,v 1.34 2009/05/12 14:37:59 cegger Exp $ */
+/*     $NetBSD: mscp.c,v 1.34.18.1 2012/07/12 17:17:27 riz Exp $       */
 
 /*
  * Copyright (c) 1988 Regents of the University of California.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mscp.c,v 1.34 2009/05/12 14:37:59 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp.c,v 1.34.18.1 2012/07/12 17:17:27 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -173,7 +173,8 @@
        struct mscp_xi *mxi;
        int nextrsp;
        int st, error;
-       extern struct mscp slavereply;
+       extern struct mscp mscp_cold_reply;
+       extern int mscp_cold_unit;
 
        nextrsp = mi->mi_rsp.mri_next;
 loop:
@@ -287,8 +288,12 @@
                 * to set it up, otherwise it's just a "normal" unit
                 * status.
                 */
-               if (cold)
-                       memcpy(&slavereply, mp, sizeof(struct mscp));
+               if (cold) {
+                       memcpy(&mscp_cold_reply, mp, sizeof(struct mscp));
+                       /* Detect that we've reached the end of all units */
+                       if (mp->mscp_unit < mscp_cold_unit)
+                               break;
+               }
 
                if (mp->mscp_status == (M_ST_OFFLINE|M_OFFLINE_UNKNOWN))
                        break;
diff -r e5aeb9c636d7 -r b8098d181071 sys/dev/mscp/mscp.h
--- a/sys/dev/mscp/mscp.h       Thu Jul 12 17:15:17 2012 +0000
+++ b/sys/dev/mscp/mscp.h       Thu Jul 12 17:17:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp.h,v 1.8 2005/12/11 12:22:47 christos Exp $        */
+/*     $NetBSD: mscp.h,v 1.8.116.1 2012/07/12 17:17:26 riz Exp $       */
 
 /*
  * Copyright (c) 1988 Regents of the University of California.
@@ -40,6 +40,8 @@
  * IF DEC SOLD DOCUMENTATION FOR THEIR OWN CONTROLLERS.
  */
 
+#define MSCP_MAX_UNIT  4095
+
 /*
  * Control message opcodes
  */
diff -r e5aeb9c636d7 -r b8098d181071 sys/dev/mscp/mscp_subr.c
--- a/sys/dev/mscp/mscp_subr.c  Thu Jul 12 17:15:17 2012 +0000
+++ b/sys/dev/mscp/mscp_subr.c  Thu Jul 12 17:17:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mscp_subr.c,v 1.41.18.1 2012/07/04 20:41:47 jdc Exp $  */
+/*     $NetBSD: mscp_subr.c,v 1.41.18.2 2012/07/12 17:17:27 riz Exp $  */
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mscp_subr.c,v 1.41.18.1 2012/07/04 20:41:47 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_subr.c,v 1.41.18.2 2012/07/12 17:17:27 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -112,7 +112,8 @@
 #define        WRITE_IP(x)     bus_space_write_2(mi->mi_iot, mi->mi_iph, 0, (x))
 #define        WRITE_SW(x)     bus_space_write_2(mi->mi_iot, mi->mi_swh, 0, (x))
 
-struct mscp slavereply;
+struct mscp mscp_cold_reply;
+int         mscp_cold_unit;
 
 #define NITEMS         4
 
@@ -178,7 +179,7 @@
        struct mscp *mp2;
        volatile struct mscp *mp;
        volatile int i;
-       int     timeout, error, next = 0;
+       int     timeout, error, unit;
 
        mi->mi_mc = ma->ma_mc;
        mi->mi_me = NULL;
@@ -263,96 +264,101 @@
         * Go out and search for sub-units on this MSCP bus,
         * and call config_found for each found.
         */
-findunit:
-       mp = mscp_getcp(mi, MSCP_DONTWAIT);
-       if (mp == NULL)
-               panic("mscpattach: no packets");
-       mp->mscp_opcode = M_OP_GETUNITST;
-       mp->mscp_unit = next;
-       mp->mscp_modifier = M_GUM_NEXTUNIT;
-       *mp->mscp_addr |= MSCP_OWN | MSCP_INT;
-       slavereply.mscp_opcode = 0;
+       for (unit = 0; unit <= MSCP_MAX_UNIT; ++unit) {
+               mp = mscp_getcp(mi, MSCP_DONTWAIT);
+               if (mp == NULL)
+                       panic("mscpattach: no packets");
+               mp->mscp_opcode = M_OP_GETUNITST;
+               mp->mscp_unit = unit;
+               mp->mscp_modifier = M_GUM_NEXTUNIT;
+               *mp->mscp_addr |= MSCP_OWN | MSCP_INT;
+               mscp_cold_reply.mscp_opcode = 0;
+               mscp_cold_unit = mp->mscp_unit;
+
+               i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0);
+               mp = &mscp_cold_reply;
+               timeout = 1000;
 
-       i = bus_space_read_2(mi->mi_iot, mi->mi_iph, 0);
-       mp = &slavereply;
-       timeout = 1000;
-       while (timeout-- > 0) {
-               DELAY(10000);
-               if (mp->mscp_opcode)
-                       goto gotit;
-       }
-       printf("%s: no response to Get Unit Status request\n",
-           device_xname(&mi->mi_dev));
-       return;
+               while (!mp->mscp_opcode) {
+                       if ( --timeout == 0) {
+                               printf("%s: no Get Unit Status response\n",
+                                   device_xname(&mi->mi_dev));
+                               return;
+                       }
+                       DELAY(10000);
+               }
+
+               /*
+                * Got a slave response.  If the unit is there, use it.
+                */
 
-gotit: /*
-        * Got a slave response.  If the unit is there, use it.
-        */
-       switch (mp->mscp_status & M_ST_MASK) {
+               /*
+                * If we get a lower number, we have circulated around all
+                * devices and are finished, otherwise try to find next unit.
+                */
+               if (mp->mscp_unit < unit)
+                       return;
+               /*
+                * If a higher number, use it to skip non-present devices
+                */
+               if (mp->mscp_unit > unit)
+                       unit = mp->mscp_unit;
+
+               switch (mp->mscp_status & M_ST_MASK) {
 
-       case M_ST_SUCCESS:      /* worked */
-       case M_ST_AVAILABLE:    /* found another drive */
-               break;          /* use it */
+               case M_ST_SUCCESS:      /* worked */
+               case M_ST_AVAILABLE:    /* found another drive */
+                       break;          /* use it */
 
-       case M_ST_OFFLINE:
-               /*
-                * Figure out why it is off line.  It may be because
-                * it is nonexistent, or because it is spun down, or
-                * for some other reason.
-                */
-               switch (mp->mscp_status & ~M_ST_MASK) {
-
-               case M_OFFLINE_UNKNOWN:
+               case M_ST_OFFLINE:
                        /*
-                        * No such drive, and there are none with
-                        * higher unit numbers either, if we are
-                        * using M_GUM_NEXTUNIT.
+                        * Figure out why it is off line.  It may be because
+                        * it is nonexistent, or because it is spun down, or
+                        * for some other reason.
                         */
-                       mi->mi_ierr = 3;
-                       return;
+                       switch (mp->mscp_status & ~M_ST_MASK) {
+
+                       case M_OFFLINE_UNKNOWN:
+                               /*
+                                * No such drive, and there are none with
+                                * higher unit numbers either, if we are
+                                * using M_GUM_NEXTUNIT.
+                                */
+                               mi->mi_ierr = 3;
+                               break; /* return */
 
-               case M_OFFLINE_UNMOUNTED:
-                       /*
-                        * The drive is not spun up.  Use it anyway.
-                        *
-                        * N.B.: this seems to be a common occurrance
-                        * after a power failure.  The first attempt
-                        * to bring it on line seems to spin it up
-                        * (and thus takes several minutes).  Perhaps
-                        * we should note here that the on-line may
-                        * take longer than usual.
-                        */
+                       case M_OFFLINE_UNMOUNTED:
+                               /*
+                                * The drive is not spun up.  Use it anyway.
+                                *
+                                * N.B.: this seems to be a common occurrance
+                                * after a power failure.  The first attempt
+                                * to bring it on line seems to spin it up
+                                * (and thus takes several minutes).  Perhaps
+                                * we should note here that the on-line may
+                                * take longer than usual.
+                                */
+                               break;
+
+                       default:
+                               /*
+                                * In service, or something else unusable.
+                                */
+                               printf("%s: unit %d off line: ",
+                                   device_xname(&mi->mi_dev), mp->mscp_unit);
+                               mp2 = __UNVOLATILE(mp);
+                               mscp_printevent(mp2);
+                               break;
+                       }
                        break;
 
                default:
-                       /*
-                        * In service, or something else equally unusable.
-                        */
-                       printf("%s: unit %d off line: ", device_xname(&mi->mi_dev),
-                               mp->mscp_unit);
-                       mp2 = __UNVOLATILE(mp);
-                       mscp_printevent(mp2);
-                       next++;
-                       goto findunit;
+                       aprint_error_dev(&mi->mi_dev,
+                           "unable to get unit status: ");
+                       mscp_printevent(__UNVOLATILE(mp));
+                       return;
                }
-               break;
-
-       default:
-               aprint_error_dev(&mi->mi_dev, "unable to get unit status: ");
-               mscp_printevent(__UNVOLATILE(mp));
-               return;
        }
-
-       /*
-        * If we get a lower number, we have circulated around all
-        * devices and are finished, otherwise try to find next unit.
-        * We shouldn't ever get this, it's a workaround.
-        */
-       if (mp->mscp_unit < next)
-               return;
-
-       next = mp->mscp_unit + 1;
-       goto findunit;
 }
 
 



Home | Main Index | Thread Index | Old Index