Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic - Fix a command accounting bug.
details: https://anonhg.NetBSD.org/src/rev/086e6b62faf2
branches: trunk
changeset: 536823:086e6b62faf2
user: ad <ad%NetBSD.org@localhost>
date: Sun Sep 22 18:59:00 2002 +0000
description:
- Fix a command accounting bug.
- Don't use ID 0, since 1.x firmware may not like it.
diffstat:
sys/dev/ic/mlx.c | 34 +++++++++++++++++++---------------
sys/dev/ic/mlxvar.h | 11 ++++++-----
2 files changed, 25 insertions(+), 20 deletions(-)
diffs (154 lines):
diff -r eaa0f892b9ad -r 086e6b62faf2 sys/dev/ic/mlx.c
--- a/sys/dev/ic/mlx.c Sun Sep 22 18:13:38 2002 +0000
+++ b/sys/dev/ic/mlx.c Sun Sep 22 18:59:00 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mlx.c,v 1.20 2002/09/06 13:18:43 gehenna Exp $ */
+/* $NetBSD: mlx.c,v 1.21 2002/09/22 18:59:00 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.20 2002/09/06 13:18:43 gehenna Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.21 2002/09/22 18:59:00 ad Exp $");
#include "ld.h"
@@ -495,9 +495,9 @@
/* Set maximum number of queued commands for `regular' operations. */
mlx->mlx_max_queuecnt =
min(ci->ci_max_commands, MLX_MAX_QUEUECNT) -
- MLX_NCCBS_RESERVE;
+ MLX_NCCBS_CONTROL;
#ifdef DIAGNOSTIC
- if (mlx->mlx_max_queuecnt < MLX_NCCBS_RESERVE + MLX_MAX_DRIVES)
+ if (mlx->mlx_max_queuecnt < MLX_NCCBS_CONTROL + MLX_MAX_DRIVES)
printf("%s: WARNING: few CCBs available\n",
mlx->mlx_dv.dv_xname);
if (ci->ci_max_sg < MLX_MAX_SEGS) {
@@ -983,7 +983,7 @@
int rv;
rv = kthread_create1(mlx_periodic_thread, NULL, &mlx_periodic_proc,
- "mlxmonitor");
+ "mlxtask");
if (rv == 0)
return;
@@ -1002,7 +1002,7 @@
if (mlx->mlx_ci.ci_iftype > 1)
mlx_periodic(mlx);
- tsleep(mlx_periodic_thread, PWAIT, "mlxzzz", hz);
+ tsleep(mlx_periodic_thread, PWAIT, "mlxzzz", hz * 2);
}
}
@@ -1886,21 +1886,23 @@
* Allocate and initialise a CCB.
*/
int
-mlx_ccb_alloc(struct mlx_softc *mlx, struct mlx_ccb **mcp, int special)
+mlx_ccb_alloc(struct mlx_softc *mlx, struct mlx_ccb **mcp, int control)
{
struct mlx_ccb *mc;
int s;
s = splbio();
- if ((!special && mlx->mlx_nccbs_free < MLX_NCCBS_RESERVE) ||
- SLIST_FIRST(&mlx->mlx_ccb_freelist) == NULL) {
- splx(s);
- *mcp = NULL;
- return (EAGAIN);
+ if (control) {
+ if (mlx->mlx_nccbs_ctrl >= MLX_NCCBS_CONTROL) {
+ splx(s);
+ *mcp = NULL;
+ return (EAGAIN);
+ }
+ mc->mc_flags |= MC_CONTROL;
+ mlx->mlx_nccbs_ctrl++;
}
mc = SLIST_FIRST(&mlx->mlx_ccb_freelist);
SLIST_REMOVE_HEAD(&mlx->mlx_ccb_freelist, mc_chain.slist);
- mlx->mlx_nccbs_free--;
splx(s);
*mcp = mc;
@@ -1916,9 +1918,10 @@
int s;
s = splbio();
+ if ((mc->mc_flags & MC_CONTROL) != 0)
+ mlx->mlx_nccbs_ctrl--;
mc->mc_flags = 0;
SLIST_INSERT_HEAD(&mlx->mlx_ccb_freelist, mc, mc_chain.slist);
- mlx->mlx_nccbs_free++;
splx(s);
}
@@ -2091,7 +2094,7 @@
int i, s, r;
/* Save the ident so we can handle this command when complete. */
- mc->mc_mbox[1] = (u_int8_t)mc->mc_ident;
+ mc->mc_mbox[1] = (u_int8_t)(mc->mc_ident + 1);
/* Mark the command as currently being processed. */
mc->mc_status = MLX_STATUS_BUSY;
@@ -2155,6 +2158,7 @@
while ((*mlx->mlx_findcomplete)(mlx, &ident, &status) != 0) {
result = 1;
+ ident--;
if (ident >= MLX_MAX_QUEUECNT) {
printf("%s: bad completion returned\n",
diff -r eaa0f892b9ad -r 086e6b62faf2 sys/dev/ic/mlxvar.h
--- a/sys/dev/ic/mlxvar.h Sun Sep 22 18:13:38 2002 +0000
+++ b/sys/dev/ic/mlxvar.h Sun Sep 22 18:59:00 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mlxvar.h,v 1.6 2002/08/26 15:27:13 ad Exp $ */
+/* $NetBSD: mlxvar.h,v 1.7 2002/09/22 18:59:00 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -80,8 +80,8 @@
/* Maximum queue depth, matching the older controllers. */
#define MLX_MAX_QUEUECNT 63
-/* Number of CCBs to reserve for `special' operations. */
-#define MLX_NCCBS_RESERVE 7
+/* Number of CCBs to reserve for control operations. */
+#define MLX_NCCBS_CONTROL 7
/* Structure describing a system drive as attached to the controller. */
struct mlx_sysdrive {
@@ -120,6 +120,7 @@
#define MC_XFER_IN MU_XFER_IN /* Map describes inbound xfer */
#define MC_XFER_OUT MU_XFER_OUT /* Map describes outbound xfer */
#define MC_WAITING 0x0400 /* We have waiters */
+#define MC_CONTROL 0x0800 /* Control operation */
/*
* Per-controller state.
@@ -137,7 +138,7 @@
SIMPLEQ_HEAD(, mlx_ccb) mlx_ccb_queue;
struct mlx_ccb *mlx_ccbs;
int mlx_nccbs;
- int mlx_nccbs_free;
+ int mlx_nccbs_ctrl;
caddr_t mlx_sgls;
bus_addr_t mlx_sgls_paddr;
@@ -227,7 +228,7 @@
mc->mc_mbox[0x0] = code;
mc->mc_mbox[0x2] = f1;
- mc->mc_mbox[0x3] = (((f2 >> 24) & 0x3) << 6) | ((f1 >> 8) & 0x3f);
+ mc->mc_mbox[0x3] = ((f2 >> 18) & 0xc0) | ((f1 >> 8) & 0x3f);
mc->mc_mbox[0x4] = f2;
mc->mc_mbox[0x5] = (f2 >> 8);
mc->mc_mbox[0x6] = (f2 >> 16);
Home |
Main Index |
Thread Index |
Old Index