Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Correct arguments to bus_dmamap_create(), and add a ...



details:   https://anonhg.NetBSD.org/src/rev/ccdf9d44531d
branches:  trunk
changeset: 509903:ccdf9d44531d
user:      ad <ad%NetBSD.org@localhost>
date:      Tue May 15 12:49:37 2001 +0000

description:
Correct arguments to bus_dmamap_create(), and add a reset routine for the v3
interface.

diffstat:

 sys/dev/ic/mlx.c      |  24 ++++++-------------
 sys/dev/pci/mlx_pci.c |  60 +++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 61 insertions(+), 23 deletions(-)

diffs (156 lines):

diff -r c3b20a13937b -r ccdf9d44531d sys/dev/ic/mlx.c
--- a/sys/dev/ic/mlx.c  Tue May 15 11:49:25 2001 +0000
+++ b/sys/dev/ic/mlx.c  Tue May 15 12:49:37 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mlx.c,v 1.8 2001/05/06 19:53:04 ad Exp $       */
+/*     $NetBSD: mlx.c,v 1.9 2001/05/15 12:49:37 ad Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -302,8 +302,8 @@
                return;
        }
 
-       if ((rv = bus_dmamap_create(mlx->mlx_dmat, size, size, 1, 0, 
-           BUS_DMA_NOWAIT, &mlx->mlx_dmamap)) != 0) {
+       if ((rv = bus_dmamap_create(mlx->mlx_dmat, size, 1, size, 0, 
+           BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &mlx->mlx_dmamap)) != 0) {
                printf("%s: unable to create sglist DMA map, rv = %d\n",
                    mlx->mlx_dv.dv_xname, rv);
                return;
@@ -328,7 +328,7 @@
        for (i = 0; i < MLX_MAX_QUEUECNT; i++, mc++) {
                mc->mc_ident = i;
                rv = bus_dmamap_create(mlx->mlx_dmat, MLX_MAX_XFER,
-                   MLX_MAX_SEGS, PAGE_SIZE, 0,
+                   MLX_MAX_SEGS, MLX_MAX_XFER, 0,
                    BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
                    &mc->mc_xfer_map);
                if (rv != 0)
@@ -1537,20 +1537,12 @@
                mlx_ccb_enqueue(mlx, mc);
        } else {
                /* Run the command in either polled or wait mode. */
-               if (waitok) {
-                       if ((rv = mlx_ccb_wait(mlx, mc)) != 0)
-                               goto out;
-               } else {
-                       if ((rv = mlx_ccb_poll(mlx, mc, 5000)) != 0)
-                               goto out;
-               }
-
-               /* Command completed OK? */
-               if (mc->mc_status != 0)
-                       goto out;
+               if (waitok)
+                       rv = mlx_ccb_wait(mlx, mc);
+               else
+                       rv = mlx_ccb_poll(mlx, mc, 5000);
        }
 
-       rv = 0;
  out:
        /* We got a command, but nobody else will free it. */
        if (handler == NULL && mc != NULL) {
diff -r c3b20a13937b -r ccdf9d44531d sys/dev/pci/mlx_pci.c
--- a/sys/dev/pci/mlx_pci.c     Tue May 15 11:49:25 2001 +0000
+++ b/sys/dev/pci/mlx_pci.c     Tue May 15 12:49:37 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mlx_pci.c,v 1.2 2001/02/18 21:02:54 mjacob Exp $       */
+/*     $NetBSD: mlx_pci.c,v 1.3 2001/05/15 12:49:37 ad Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -94,6 +94,9 @@
 static int     mlx_v3_findcomplete(struct mlx_softc *, u_int *, u_int *);
 static void    mlx_v3_intaction(struct mlx_softc *, int);
 static int     mlx_v3_fw_handshake(struct mlx_softc *, int *, int *, int *);
+#ifdef MLX_RESET
+static int     mlx_v3_reset(struct mlx_softc *);
+#endif
 
 static int     mlx_v4_submit(struct mlx_softc *, struct mlx_ccb *);
 static int     mlx_v4_findcomplete(struct mlx_softc *, u_int *, u_int *);
@@ -270,6 +273,9 @@
                mlx->mlx_findcomplete = mlx_v3_findcomplete;
                mlx->mlx_intaction = mlx_v3_intaction;
                mlx->mlx_fw_handshake = mlx_v3_fw_handshake;
+#ifdef MLX_RESET
+               mlx->mlx_reset = mlx_v3_reset;
+#endif
                break;
 
        case 4:
@@ -396,6 +402,48 @@
        return (2);
 }
 
+#ifdef MLX_RESET
+/*
+ * Reset the controller.  Return non-zero on failure.
+ */
+static int 
+mlx_v3_reset(struct mlx_softc *mlx)
+{
+       int i;
+
+       mlx_outb(mlx, MLX_V3REG_IDB, MLX_V3_IDB_SACK);
+       delay(1000000);
+
+       /* Wait up to 2 minutes for the bit to clear. */
+       for (i = 120; i != 0; i--) {
+               delay(1000000);
+               if ((mlx_inb(mlx, MLX_V3REG_IDB) & MLX_V3_IDB_SACK) == 0)
+                       break;
+       }
+       if (i == 0) {
+               /* ZZZ */
+               printf("mlx0: SACK didn't clear\n");
+               return (-1);
+       }
+
+       mlx_outb(mlx, MLX_V3REG_IDB, MLX_V3_IDB_RESET);
+
+       /* Wait up to 5 seconds for the bit to clear. */
+       for (i = 5; i != 0; i--) {
+               delay(1000000);
+               if ((mlx_inb(mlx, MLX_V3REG_IDB) & MLX_V3_IDB_RESET) == 0)
+                       break;
+       }
+       if (i == 0) {
+               /* ZZZ */
+               printf("mlx0: RESET didn't clear\n");
+               return (-1);
+       }
+
+       return (0);
+}
+#endif /* MLX_RESET */
+
 /*
  * ================= V4 interface linkage =================
  */
@@ -413,9 +461,8 @@
        /* Ready for our command? */
        if ((mlx_inl(mlx, MLX_V4REG_IDB) & MLX_V4_IDB_FULL) == 0) {
                /* Copy mailbox data to window. */
-               bus_space_write_region_4(mlx->mlx_iot, mlx->mlx_ioh,
-                   MLX_V4REG_MAILBOX, (const u_int32_t *)mc->mc_mbox,
-                   MLX_V4_MAILBOX_LEN >> 2);
+               bus_space_write_region_1(mlx->mlx_iot, mlx->mlx_ioh,
+                   MLX_V4REG_MAILBOX, mc->mc_mbox, MLX_V4_MAILBOX_LEN);
                bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh,
                    MLX_V4REG_MAILBOX, MLX_V4_MAILBOX_LEN,
                    BUS_SPACE_BARRIER_WRITE);
@@ -525,9 +572,8 @@
        /* Ready for our command? */
        if ((mlx_inb(mlx, MLX_V5REG_IDB) & MLX_V5_IDB_EMPTY) != 0) {
                /* Copy mailbox data to window. */
-               bus_space_write_region_4(mlx->mlx_iot, mlx->mlx_ioh,
-                   MLX_V5REG_MAILBOX, (const u_int32_t *)mc->mc_mbox,
-                   MLX_V5_MAILBOX_LEN >> 2);
+               bus_space_write_region_1(mlx->mlx_iot, mlx->mlx_ioh,
+                   MLX_V5REG_MAILBOX, mc->mc_mbox, MLX_V5_MAILBOX_LEN);
                bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh,
                    MLX_V5REG_MAILBOX, MLX_V5_MAILBOX_LEN,
                    BUS_SPACE_BARRIER_WRITE);



Home | Main Index | Thread Index | Old Index