Source-Changes-HG archive

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

[src/netbsd-3-0]: src/sys/dev Pull up following revision(s) (requested by tro...



details:   https://anonhg.NetBSD.org/src/rev/be0344d7d019
branches:  netbsd-3-0
changeset: 579452:be0344d7d019
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Oct 04 18:33:21 2007 +0000

description:
Pull up following revision(s) (requested by tron in ticket #1822):
        sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
        sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
        sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
        sys/dev/ic/mpt.h: revision 1.6 via patch
        sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
        sys/dev/ic/mpt_debug.c: patch
        sys/dev/pci/mpt_pci.c: revision 1.11 via patch
        sys/dev/pci/pcidevs: patch
        sys/dev/pci/pcidevs.h: patch
        sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.

diffstat:

 sys/dev/ic/mpt.c        |  129 +++++++++++++++-------------
 sys/dev/ic/mpt.h        |    5 +-
 sys/dev/ic/mpt_debug.c  |    8 +-
 sys/dev/ic/mpt_mpilib.h |   35 +++++++-
 sys/dev/ic/mpt_netbsd.c |   73 +++++++++++----
 sys/dev/ic/mpt_netbsd.h |   13 +-
 sys/dev/pci/mpt_pci.c   |  220 ++++++++---------------------------------------
 sys/dev/pci/pcidevs     |   17 +++-
 8 files changed, 225 insertions(+), 275 deletions(-)

diffs (truncated from 904 to 300 lines):

diff -r 13ae45152d87 -r be0344d7d019 sys/dev/ic/mpt.c
--- a/sys/dev/ic/mpt.c  Mon Sep 17 20:16:09 2007 +0000
+++ b/sys/dev/ic/mpt.c  Thu Oct 04 18:33:21 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpt.c,v 1.5 2005/02/27 00:27:02 perry Exp $    */
+/*     $NetBSD: mpt.c,v 1.5.12.1 2007/10/04 18:33:21 bouyer Exp $      */
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -28,6 +28,7 @@
  * Additional Copyright (c) 2002 by Matthew Jacob under same license.
  */
 
+
 /*
  * mpt.c:
  *
@@ -35,10 +36,12 @@
  *
  * Adapted from the FreeBSD "mpt" driver by Jason R. Thorpe for
  * Wasabi Systems, Inc.
+ *
+ * Additional contributions by Garrett D'Amore on behalf of TELES AG.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.5 2005/02/27 00:27:02 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.5.12.1 2007/10/04 18:33:21 bouyer Exp $");
 
 #include <dev/ic/mpt.h>
 
@@ -49,13 +52,13 @@
 static int maxwait_int = 0;
 static int maxwait_state = 0;
 
-static __inline u_int32_t
+static inline u_int32_t
 mpt_rd_db(mpt_softc_t *mpt)
 {
        return mpt_read(mpt, MPT_OFFSET_DOORBELL);
 }
 
-static __inline u_int32_t
+static inline u_int32_t
 mpt_rd_intr(mpt_softc_t *mpt)
 {
        return mpt_read(mpt, MPT_OFFSET_INTR_STATUS);
@@ -167,13 +170,10 @@
 void
 mpt_hard_reset(mpt_softc_t *mpt)
 {
-       /* This extra read comes for the Linux source
-        * released by LSI. It's function is undocumented!
-        */
        if (mpt->verbose) {
                mpt_prt(mpt, "hard reset");
        }
-       mpt_read(mpt, MPT_OFFSET_FUBAR);
+       mpt_write(mpt, MPT_OFFSET_SEQUENCE, 0xff);
 
        /* Enable diagnostic registers */
        mpt_write(mpt, MPT_OFFSET_SEQUENCE, MPT_DIAG_SEQUENCE_1);
@@ -189,17 +189,6 @@
 
        /* Disable Diagnostic Register */
        mpt_write(mpt, MPT_OFFSET_SEQUENCE, 0xFF);
-
-       /* Restore the config register values */
-       /*   Hard resets are known to screw up the BAR for diagnostic
-            memory accesses (Mem1). */
-       mpt_set_config_regs(mpt);
-       if (mpt->mpt2 != NULL) {
-               mpt_set_config_regs(mpt->mpt2);
-       }
-
-       /* Note that if there is no valid firmware to run, the doorbell will
-          remain in the reset state (0x00000000) */
 }
 
 /*
@@ -487,11 +476,7 @@
        bzero(&init, sizeof init);
        init.WhoInit = who;
        init.Function = MPI_FUNCTION_IOC_INIT;
-       if (mpt->is_fc) {
-               init.MaxDevices = 255;
-       } else {
-               init.MaxDevices = 16;
-       }
+       init.MaxDevices = mpt->mpt_max_devices;
        init.MaxBuses = 1;
        init.ReplyFrameSize = MPT_REPLY_SIZE;
        init.MsgContext = 0x12071941;
@@ -632,7 +617,7 @@
            cfgp->Header.PageNumber == 1) {
                amt = sizeof (fCONFIG_PAGE_SCSI_DEVICE_1);
        }
-       bcopy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, amt);
+       memcpy(hdr, (char *)req->req_vbuf + CFG_DATA_OFF, amt);
        mpt_free_request(mpt, req);
        return (0);
 }
@@ -692,7 +677,7 @@
            cfgp->Header.PageNumber == 1) {
                amt = sizeof (fCONFIG_PAGE_SCSI_DEVICE_1);
        }
-       bcopy(hdr, ((caddr_t)req->req_vbuf)+CFG_DATA_OFF, amt);
+       memcpy((char *)req->req_vbuf + CFG_DATA_OFF, hdr, amt);
        /* Restore stripped out attributes */
        hdr->PageType |= hdr_attr;
 
@@ -1022,6 +1007,40 @@
 
 /* (Re)Initialize the chip for use */
 int
+mpt_hw_init(mpt_softc_t *mpt)
+{
+       u_int32_t       db;
+       int             try;
+
+       /*
+        * Start by making sure we're not at FAULT or RESET state
+        */
+       for (try = 0; try < MPT_MAX_TRYS; try++) {
+
+               db = mpt_rd_db(mpt);
+
+               switch (MPT_STATE(db)) {
+               case MPT_DB_STATE_READY:
+                       return (0);
+
+               default:
+                       /* if peer has already reset us, don't do it again! */
+                       if (MPT_WHO(db) == MPT_DB_INIT_PCIPEER)
+                               return (0);
+                       /*FALLTHRU*/
+               case MPT_DB_STATE_RESET:
+               case MPT_DB_STATE_FAULT:
+                       if (mpt_reset(mpt) != MPT_OK) {
+                               DELAY(10000);
+                               continue;
+                       }
+                       break;
+               }
+       }
+       return (EIO);
+}
+
+int
 mpt_init(mpt_softc_t *mpt, u_int32_t who)
 {
         int try;
@@ -1044,33 +1063,13 @@
        /*
         * Start by making sure we're not at FAULT or RESET state
         */
-       switch (mpt_rd_db(mpt) & MPT_DB_STATE_MASK) {
-       case MPT_DB_STATE_RESET:
-       case MPT_DB_STATE_FAULT:
-               if (mpt_reset(mpt) != MPT_OK) {
-                       return (EIO);
-               }
-       default:
-               break;
-       }
+       if (mpt_hw_init(mpt) != 0)
+               return (EIO);
 
        for (try = 0; try < MPT_MAX_TRYS; try++) {
                /*
                 * No need to reset if the IOC is already in the READY state.
-                *
-                * Force reset if initialization failed previously.
-                * Note that a hard_reset of the second channel of a '929
-                * will stop operation of the first channel.  Hopefully, if the
-                * first channel is ok, the second will not require a hard
-                * reset.
                 */
-               if ((mpt_rd_db(mpt) & MPT_DB_STATE_MASK) !=
-                   MPT_DB_STATE_READY) {
-                       if (mpt_reset(mpt) != MPT_OK) {
-                               DELAY(10000);
-                               continue;
-                       }
-               }
 
                if (mpt_get_iocfacts(mpt, &facts) != MPT_OK) {
                        mpt_prt(mpt, "mpt_get_iocfacts failed");
@@ -1083,6 +1082,7 @@
                            "Request Frame Size %u\n", facts.GlobalCredits,
                            facts.BlockSize, facts.RequestFrameSize);
                }
+               mpt->mpt_max_devices = facts.MaxDevices;
                mpt->mpt_global_credits = facts.GlobalCredits;
                mpt->request_frame_size = facts.RequestFrameSize;
 
@@ -1098,21 +1098,30 @@
                            pfp.MaxDevices);
                }
 
-               if (pfp.PortType != MPI_PORTFACTS_PORTTYPE_SCSI &&
-                   pfp.PortType != MPI_PORTFACTS_PORTTYPE_FC) {
+               if (!(pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR)) {
+                       mpt_prt(mpt, "initiator role unsupported");
+                       return (ENXIO);
+               }
+
+               switch (pfp.PortType) {
+               case MPI_PORTFACTS_PORTTYPE_FC:
+                       mpt->is_fc = 1;
+                       mpt->mpt_max_devices = 255;
+                       break;
+               case MPI_PORTFACTS_PORTTYPE_SCSI:
+                       mpt->is_scsi = 1;
+                       /* some SPI controllers (VMWare, Sun) lie */
+                       mpt->mpt_max_devices = 16;
+                       break;
+               case MPI_PORTFACTS_PORTTYPE_SAS:
+                       mpt->is_sas = 1;
+                       break;
+               default:
                        mpt_prt(mpt, "Unsupported Port Type (%x)",
                            pfp.PortType);
                        return (ENXIO);
                }
-               if (!(pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR)) {
-                       mpt_prt(mpt, "initiator role unsupported");
-                       return (ENXIO);
-               }
-               if (pfp.PortType == MPI_PORTFACTS_PORTTYPE_FC) {
-                       mpt->is_fc = 1;
-               } else {
-                       mpt->is_fc = 0;
-               }
+
                mpt->mpt_ini_id = pfp.PortSCSIID;
 
                if (mpt_send_ioc_init(mpt, who) != MPT_OK) {
@@ -1156,7 +1165,7 @@
                 * (SPI only for now)
                 */
 
-               if (mpt->is_fc == 0) {
+               if (mpt->is_scsi) {
                        if (mpt_read_config_info_spi(mpt)) {
                                return (EIO);
                        }
diff -r 13ae45152d87 -r be0344d7d019 sys/dev/ic/mpt.h
--- a/sys/dev/ic/mpt.h  Mon Sep 17 20:16:09 2007 +0000
+++ b/sys/dev/ic/mpt.h  Thu Oct 04 18:33:21 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpt.h,v 1.3 2005/02/27 00:27:02 perry Exp $    */
+/*     $NetBSD: mpt.h,v 1.3.4.1 2007/10/04 18:33:21 bouyer Exp $       */
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -164,6 +164,7 @@
 void mpt_enable_ints(mpt_softc_t *);
 void mpt_disable_ints(mpt_softc_t *);
 u_int32_t mpt_pop_reply_queue(mpt_softc_t *);
+int mpt_hw_init(mpt_softc_t *);
 int mpt_init(mpt_softc_t *, u_int32_t);
 int mpt_reset(mpt_softc_t *);
 int mpt_send_handshake_cmd(mpt_softc_t *, size_t, void *);
@@ -180,7 +181,7 @@
 void mpt_print_db(u_int32_t);
 void mpt_print_config_reply(void *);
 char *mpt_ioc_diag(u_int32_t);
-char *mpt_req_state(enum mpt_req_state);
+const char *mpt_req_state(enum mpt_req_state);
 void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *);
 void mpt_print_config_request(void *);
 void mpt_print_request(void *);
diff -r 13ae45152d87 -r be0344d7d019 sys/dev/ic/mpt_debug.c
--- a/sys/dev/ic/mpt_debug.c    Mon Sep 17 20:16:09 2007 +0000
+++ b/sys/dev/ic/mpt_debug.c    Thu Oct 04 18:33:21 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpt_debug.c,v 1.2 2003/07/14 15:47:11 lukem Exp $      */
+/*     $NetBSD: mpt_debug.c,v 1.2.18.1 2007/10/04 18:33:21 bouyer Exp $        */
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt_debug.c,v 1.2 2003/07/14 15:47:11 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_debug.c,v 1.2.18.1 2007/10/04 18:33:21 bouyer Exp $");
 
 #include <dev/ic/mpt.h>
 
@@ -533,10 +533,10 @@
        }
 }
 
-char *
+const char *
 mpt_req_state(enum mpt_req_state state)
 {
-       char *text;



Home | Main Index | Thread Index | Old Index