NetBSD Problem Report #14866

Received: (qmail 25054 invoked from network); 8 Dec 2001 01:39:23 -0000
Message-Id: <200112080139.fB81dMZ05581@ns.mt.sri.com>
Date: Fri, 7 Dec 2001 18:39:22 -0700 (MST)
From: chris@cjones.org
Reply-To: chris@cjones.org
To: gnats-bugs@gnats.netbsd.org
Subject: lockmgr panic
X-Send-Pr-Version: 3.95

>Number:         14866
>Category:       kern
>Synopsis:       lockmgr panic with siop * 2, RAID, softdep
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 08 01:40:00 +0000 2001
>Closed-Date:    Fri Feb 01 16:39:35 +0000 2002
>Last-Modified:  Fri Dec 21 18:31:06 +0000 2012
>Originator:     Chris Jones
>Release:        NetBSD 1.5.3_ALPHA
>Organization:

>Environment:

1.5.3_ALPHA, i386, 2 independent RAID sets, softdep on some file systems.

cpu0: Intel Pentium II (Klamath) (686-class)
siop1 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop1: using on-board RAM
siop1: interrupting at irq 9
scsibus1 at siop1: 16 targets, 8 luns per target
siop0 at pci0 dev 13 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0: using on-board RAM
siop0: interrupting at irq 10
scsibus0 at siop0: 16 targets, 8 luns per target
sd2 at scsibus1 target 2 lun 0: <IBM, DMVS36D, 0210> SCSI3 0/direct fixed
sd3 at scsibus1 target 3 lun 0: <IBM, DMVS36D, 0210> SCSI3 0/direct fixed
st0 at scsibus1 target 5 lun 0: <HP, C1557A, U812> SCSI2 1/sequential removable
ch0 at scsibus1 target 5 lun 1: <HP, C1557A, U812> SCSI2 8/changer removable
sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST34572W, 0784> SCSI2 0/direct fixed
sd1 at scsibus0 target 1 lun 0: <SEAGATE, ST32272W, 0784> SCSI2 0/direct fixed
sd4 at scsibus0 target 4 lun 0: <IBM, DMVS36D, 0210> SCSI3 0/direct fixed

>Description:
When this machine boots a recent 1.5.x kernel, it usually panics.

panic: lockmgr: no context

Stack trace copied by hand:

cpu_Debugger
panic
lockmgr
uvm_map
uvm_km_valloc
_bus_dmamem_map
siop_morecbd
siop_scsicmd
scsipi_execute_xs
scsi_scsipi_cmd
scsipi_command
sdstart
scsipi_free_xs
scsipi_done
siop_scsicmd_end
siop_intr
Xintr10
--- interrupt ---
idle
bpendtsleep
ffs_full_fsync
ffs_fsync
sys_fsync
syscall

Another instance of this panic was the same up to the interrupt.  The
rest of the trace was:

--- interrupt ---
idle
bpendtsleep
rf_VerifyParityRAID1
rf_VerifyParity
rf_RewriteParity
rf_RewriteParityThread

In both instances, ddb's ps didn't show any process with the '>' next
to it.  Is there another way I can determine the active process?

>How-To-Repeat:
I can reproduce this on 1.5.3_ALPHA, and several earlier kernels.
It does not occur with the following kernel, though:

NetBSD gamera.mt.sri.com 1.5 NetBSD 1.5 (GAMERA) #6: Mon Jul  9 09:28:05 MDT 2001     root@gamera.mt.sri.com:/usr/src/sys/arch/i386/compile/GAMERA i386
NetBSD 1.5 (GAMERA) #6: Mon Jul  9 09:28:05 MDT 2001
    root@gamera.mt.sri.com:/usr/src/sys/arch/i386/compile/GAMERA

>Fix:
>Release-Note:
>Audit-Trail:

From: Matthias Buelow <mkb@mukappabeta.de>
To: chris@cjones.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/14866: lockmgr panic
Date: Sat, 8 Dec 2001 03:41:53 +0100

 chris@cjones.org writes:

 >>Synopsis:       lockmgr panic with siop * 2, RAID, softdep
 >1.5.3_ALPHA, i386, 2 independent RAID sets, softdep on some file systems.

 I just had the same panic with one siop, no RAID but with softdeps.
 I'll now disable the goddamn softdeps on the last machine I have it
 running on and hope it's going to be a bit more stable.
 I also have ohci* overruns (filed a PR on it a couple of minutes ago)
 but I think these two problems are unrelated.

 --mkb

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: chris@cjones.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/14866: lockmgr panic
Date: Sun, 9 Dec 2001 17:13:31 +0100

 --BXVAT5kNtrzKuDFl
 Content-Type: text/plain; charset=us-ascii

 On Fri, Dec 07, 2001 at 06:39:22PM -0700, chris@cjones.org wrote:
 > [...]
 > Stack trace copied by hand:
 > 
 > cpu_Debugger
 > panic
 > lockmgr
 > uvm_map
 > uvm_km_valloc
 > _bus_dmamem_map
 > siop_morecbd
 > siop_scsicmd
 > scsipi_execute_xs
 > scsi_scsipi_cmd
 > scsipi_command
 > sdstart
 > scsipi_free_xs
 > scsipi_done
 > siop_scsicmd_end
 > siop_intr
 > Xintr10

 Can you try the attached patch ?
 It solved this problem for me, and I'm running it on several servers; but
 it cause problems on someone else machine (which is why it's not commited
 yet).

 --
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

 --BXVAT5kNtrzKuDFl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="siop-diff2-1.5.2"

 Index: siop.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/ic/siop.c,v
 retrieving revision 1.21.2.7
 diff -u -r1.21.2.7 siop.c
 --- siop.c	2001/02/26 17:47:46	1.21.2.7
 +++ siop.c	2001/10/17 14:37:58
 @@ -83,7 +83,7 @@
  void 	siop_timeout __P((void *));
  int	siop_scsicmd __P((struct scsipi_xfer *));
  void	siop_dump_script __P((struct siop_softc *));
 -int	siop_morecbd __P((struct siop_softc *));
 +int	siop_morecbd __P((struct siop_softc *, int));
  struct siop_lunsw *siop_get_lunsw __P((struct siop_softc *));
  void	siop_add_reselsw __P((struct siop_softc *, int));
  void	siop_update_scntl3 __P((struct siop_softc *, struct siop_target *));
 @@ -202,6 +202,8 @@
  	TAILQ_INIT(&sc->free_list);
  	TAILQ_INIT(&sc->ready_list);
  	TAILQ_INIT(&sc->urgent_list);
 +	sc->sc_cmd_total = 0;
 +	sc->sc_cmd_reserved = 0;
  	TAILQ_INIT(&sc->cmds);
  	TAILQ_INIT(&sc->lunsw_list);
  	sc->sc_currschedslot = 0;
 @@ -558,7 +560,8 @@
  			if (siop_cmd) {
  				siop_cmd->status = CMDST_DONE;
  				xs->error = XS_SELTIMEOUT;
 -				freetarget = 1;
 +				if (siop_target->status == TARST_PROBING)
 +					freetarget = 1;
  				goto end;
  			} else {
  				printf("%s: selection timeout without "
 @@ -956,12 +959,23 @@
  		CALL_SCRIPT(Ent_script_sched);
  	else
  		restart = 1;
 +	if ((xs->xs_control & XS_CTL_DISCOVERY) &&
 +	    xs->cmd->opcode == INQUIRY &&
 +	    siop_cmd->siop_tables.status == SCSI_OK &&
 +	    siop_cmd->status == CMDST_DONE) {
 +		/* check is there is really a LUN here */
 +		struct scsipi_inquiry_data *inq =
 +		    (struct scsipi_inquiry_data *)xs->data;
 +		if ((inq->device & SID_QUAL) == SID_QUAL_RSVD ||
 +		    (inq->device & SID_QUAL) == SID_QUAL_BAD_LU)
 +			freetarget = 1;
 +	}
  	siop_scsicmd_end(siop_cmd);
  	siop_lun->siop_tag[tag].active = NULL;
  	if (siop_cmd->status == CMDST_FREE) {
  		TAILQ_INSERT_TAIL(&sc->free_list, siop_cmd, next);
  		siop_lun->lun_flags &= ~SIOP_LUNF_FULL;
 -		if (freetarget && siop_target->status == TARST_PROBING)
 +		if (freetarget)
  			siop_del_dev(sc, target, lun);
  	}
  	siop_start(sc);
 @@ -1243,20 +1257,32 @@
  #ifdef SIOP_DEBUG_SCHED
  	printf("starting cmd for %d:%d\n", target, lun);
  #endif
 +	if (xs->xs_control & XS_CTL_DISCOVERY &&
 +	    (sc->targets[target] == NULL ||
 +	    sc->targets[target]->siop_lun[lun] == NULL)) {
 +		/* allocate resource for this target/lun */
 +#ifdef SIOP_DEBUG
 +		printf("%s: discovery target %d lun %d; sc->sc_cmd_total = %d"
 +		    " sc->sc_cmd_reserved=%d\n",
 +		    sc->sc_dev.dv_xname, target, lun,
 +		    sc->sc_cmd_total, sc->sc_cmd_reserved);
 +#endif
 +		if (sc->sc_cmd_total - sc->sc_cmd_reserved < SIOP_NTAG) {
 +			if (siop_morecbd(sc, SIOP_NTAG) != 0) {
 +				xs->error = XS_DRIVER_STUFFUP;
 +				splx(s);
 +				return(TRY_AGAIN_LATER);
 +			}
 +		}
 +	}
 +				
  	siop_cmd = TAILQ_FIRST(&sc->free_list);
  	if (siop_cmd) {
  		TAILQ_REMOVE(&sc->free_list, siop_cmd, next);
  	} else {
 -		if (siop_morecbd(sc) == 0) {
 -			siop_cmd = TAILQ_FIRST(&sc->free_list);
 -#ifdef DIAGNOSTIC
 -			if (siop_cmd == NULL)
 -				panic("siop_morecbd succeed and does nothing");
 -#endif
 -			TAILQ_REMOVE(&sc->free_list, siop_cmd, next);
 -		}
 -	}
 -	if (siop_cmd == NULL) {
 +		/* this shouldn't happen */
 +		printf("%s:%d:%d: no free siop_cmd\n",
 +		     sc->sc_dev.dv_xname, target, lun);
  		xs->error = XS_DRIVER_STUFFUP;
  		splx(s);
  		return(TRY_AGAIN_LATER);
 @@ -1308,6 +1334,7 @@
  			splx(s);
  			return(TRY_AGAIN_LATER);
  		}
 +		sc->sc_cmd_reserved += SIOP_NTAG;
  		memset(sc->targets[target]->siop_lun[lun], 0,
  		    sizeof(struct siop_lun));
  	}
 @@ -1607,8 +1634,9 @@
  }

  int
 -siop_morecbd(sc)
 +siop_morecbd(sc, ncbd)
  	struct siop_softc *sc;
 +	int ncbd;
  {
  	int error, i, j;
  	bus_dma_segment_t seg;
 @@ -1616,6 +1644,10 @@
  	struct siop_cbd *newcbd;
  	bus_addr_t dsa;
  	u_int32_t *scr;
 +	int ncbdpgs, r_ncbd;
 +
 +	ncbdpgs = (ncbd + SIOP_NCMDPB - 1) / SIOP_NCMDPB;
 +	r_ncbd = ncbdpgs * SIOP_NCMDPB;

  	/* allocate a new list head */
  	newcbd = malloc(sizeof(struct siop_cbd), M_DEVBUF, M_NOWAIT);
 @@ -1628,37 +1660,37 @@

  	/* allocate cmd list */
  	newcbd->cmds =
 -	    malloc(sizeof(struct siop_cmd) * SIOP_NCMDPB, M_DEVBUF, M_NOWAIT);
 +	    malloc(sizeof(struct siop_cmd) * r_ncbd, M_DEVBUF, M_NOWAIT);
  	if (newcbd->cmds == NULL) {
  		printf("%s: can't allocate memory for command descriptors\n",
  		    sc->sc_dev.dv_xname);
  		error = ENOMEM;
  		goto bad3;
  	}
 -	memset(newcbd->cmds, 0, sizeof(struct siop_cmd) * SIOP_NCMDPB);
 -	error = bus_dmamem_alloc(sc->sc_dmat, NBPG, NBPG, 0, &seg, 1, &rseg,
 -	    BUS_DMA_NOWAIT);
 +	memset(newcbd->cmds, 0, sizeof(struct siop_cmd) * r_ncbd);
 +	error = bus_dmamem_alloc(sc->sc_dmat, NBPG * ncbdpgs, NBPG,
 +	    0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
  	if (error) {
  		printf("%s: unable to allocate cbd DMA memory, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad2;
  	}
 -	error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG,
 +	error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG * ncbdpgs,
  	    (caddr_t *)&newcbd->xfers, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
  	if (error) {
  		printf("%s: unable to map cbd DMA memory, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad2;
  	}
 -	error = bus_dmamap_create(sc->sc_dmat, NBPG, 1, NBPG, 0,
 -	    BUS_DMA_NOWAIT, &newcbd->xferdma);
 +	error = bus_dmamap_create(sc->sc_dmat, NBPG * ncbdpgs, 1,
 +	    NBPG * ncbdpgs, 0, BUS_DMA_NOWAIT, &newcbd->xferdma);
  	if (error) {
  		printf("%s: unable to create cbd DMA map, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad1;
  	}
  	error = bus_dmamap_load(sc->sc_dmat, newcbd->xferdma, newcbd->xfers,
 -	    NBPG, NULL, BUS_DMA_NOWAIT);
 +	    NBPG * ncbdpgs, NULL, BUS_DMA_NOWAIT);
  	if (error) {
  		printf("%s: unable to load cbd DMA map, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
 @@ -1669,7 +1701,7 @@
  	    (unsigned long)newcbd->xferdma->dm_segs[0].ds_addr);
  #endif

 -	for (i = 0; i < SIOP_NCMDPB; i++) {
 +	for (i = 0; i < r_ncbd; i++) {
  		error = bus_dmamap_create(sc->sc_dmat, MAXPHYS, SIOP_NSG,
  		    MAXPHYS, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
  		    &newcbd->cmds[i].dmamap_data);
 @@ -1745,6 +1777,7 @@
  #endif
  	}
  	TAILQ_INSERT_TAIL(&sc->cmds, newcbd, next);
 +	sc->sc_cmd_total += r_ncbd;
  	return 0;
  bad0:
  	bus_dmamap_destroy(sc->sc_dmat, newcbd->xferdma);
 @@ -1980,6 +2013,7 @@
  		return;
  	free(sc->targets[target]->siop_lun[lun], M_DEVBUF);
  	sc->targets[target]->siop_lun[lun] = NULL;
 +	sc->sc_cmd_reserved -= SIOP_NTAG;
  	/* XXX compact sw entry too ? */
  	/* check if we can free the whole target */
  	for (i = 0; i < 8; i++) {
 Index: siopvar.h
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/ic/siopvar.h,v
 retrieving revision 1.8.2.1
 diff -u -r1.8.2.1 siopvar.h
 --- siopvar.h	2000/12/15 04:49:52	1.8.2.1
 +++ siopvar.h	2001/10/17 14:37:58
 @@ -63,6 +63,8 @@
  	struct cmd_list free_list;	/* cmd descr free list */
  	struct cmd_list urgent_list;	/* hitgh priority cmd descr list */
  	struct cmd_list ready_list;	/* cmd descr ready list */
 +	int sc_cmd_total;		/* total # of cmd desc allocated */
 +	int sc_cmd_reserved;		/* # of cmd desc reserved for devices */
  	struct lunsw_list lunsw_list;	/* lunsw free list */
  	u_int32_t script_free_lo;	/* free ram offset from sc_scriptaddr */
  	u_int32_t script_free_hi;	/* free ram offset from sc_scriptaddr */

 --BXVAT5kNtrzKuDFl--
Responsible-Changed-From-To: kern-bug-people->bouyer 
Responsible-Changed-By: bouyer 
Responsible-Changed-When: Mon Dec 10 03:04:09 PST 2001 
Responsible-Changed-Why:  
I have a patch to test 

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: chris@cjones.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/14866: lockmgr panic
Date: Mon, 10 Dec 2001 22:36:18 +0100

 --UugvWAfsgieZRqgk
 Content-Type: text/plain; charset=us-ascii

 Ops, the patch I sent you has a bug, it only works on machines with 8k page
 size (and sadly I worked on this mostly with alpha and sparc64 machines
 lately :(
 This one is correct.

 --
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

 --UugvWAfsgieZRqgk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="siop-diff2-1.5.2"

 Index: siop.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/ic/siop.c,v
 retrieving revision 1.21.2.7
 diff -u -r1.21.2.7 siop.c
 --- siop.c	2001/02/26 17:47:46	1.21.2.7
 +++ siop.c	2001/12/10 21:24:07
 @@ -83,7 +83,7 @@
  void 	siop_timeout __P((void *));
  int	siop_scsicmd __P((struct scsipi_xfer *));
  void	siop_dump_script __P((struct siop_softc *));
 -int	siop_morecbd __P((struct siop_softc *));
 +int	siop_morecbd __P((struct siop_softc *, int));
  struct siop_lunsw *siop_get_lunsw __P((struct siop_softc *));
  void	siop_add_reselsw __P((struct siop_softc *, int));
  void	siop_update_scntl3 __P((struct siop_softc *, struct siop_target *));
 @@ -202,6 +202,8 @@
  	TAILQ_INIT(&sc->free_list);
  	TAILQ_INIT(&sc->ready_list);
  	TAILQ_INIT(&sc->urgent_list);
 +	sc->sc_cmd_total = 0;
 +	sc->sc_cmd_reserved = 0;
  	TAILQ_INIT(&sc->cmds);
  	TAILQ_INIT(&sc->lunsw_list);
  	sc->sc_currschedslot = 0;
 @@ -373,7 +375,8 @@
  	for (cbdp = TAILQ_FIRST(&sc->cmds); cbdp != NULL;
  	    cbdp = TAILQ_NEXT(cbdp, next)) {
  		if (dsa >= cbdp->xferdma->dm_segs[0].ds_addr &&
 -	    	    dsa < cbdp->xferdma->dm_segs[0].ds_addr + NBPG) {
 +	    	    dsa < cbdp->xferdma->dm_segs[0].ds_addr + 
 +		    cbdp->xferdma->dm_segs[0].ds_len) {
  			dsa -= cbdp->xferdma->dm_segs[0].ds_addr;
  			siop_cmd = &cbdp->cmds[dsa / sizeof(struct siop_xfer)];
  			siop_table_sync(siop_cmd,
 @@ -558,7 +561,8 @@
  			if (siop_cmd) {
  				siop_cmd->status = CMDST_DONE;
  				xs->error = XS_SELTIMEOUT;
 -				freetarget = 1;
 +				if (siop_target->status == TARST_PROBING)
 +					freetarget = 1;
  				goto end;
  			} else {
  				printf("%s: selection timeout without "
 @@ -956,12 +960,23 @@
  		CALL_SCRIPT(Ent_script_sched);
  	else
  		restart = 1;
 +	if ((xs->xs_control & XS_CTL_DISCOVERY) &&
 +	    xs->cmd->opcode == INQUIRY &&
 +	    siop_cmd->siop_tables.status == SCSI_OK &&
 +	    siop_cmd->status == CMDST_DONE) {
 +		/* check is there is really a LUN here */
 +		struct scsipi_inquiry_data *inq =
 +		    (struct scsipi_inquiry_data *)xs->data;
 +		if ((inq->device & SID_QUAL) == SID_QUAL_RSVD ||
 +		    (inq->device & SID_QUAL) == SID_QUAL_BAD_LU)
 +			freetarget = 1;
 +	}
  	siop_scsicmd_end(siop_cmd);
  	siop_lun->siop_tag[tag].active = NULL;
  	if (siop_cmd->status == CMDST_FREE) {
  		TAILQ_INSERT_TAIL(&sc->free_list, siop_cmd, next);
  		siop_lun->lun_flags &= ~SIOP_LUNF_FULL;
 -		if (freetarget && siop_target->status == TARST_PROBING)
 +		if (freetarget)
  			siop_del_dev(sc, target, lun);
  	}
  	siop_start(sc);
 @@ -1243,20 +1258,32 @@
  #ifdef SIOP_DEBUG_SCHED
  	printf("starting cmd for %d:%d\n", target, lun);
  #endif
 +	if (xs->xs_control & XS_CTL_DISCOVERY &&
 +	    (sc->targets[target] == NULL ||
 +	    sc->targets[target]->siop_lun[lun] == NULL)) {
 +		/* allocate resource for this target/lun */
 +#ifdef SIOP_DEBUG
 +		printf("%s: discovery target %d lun %d; sc->sc_cmd_total = %d"
 +		    " sc->sc_cmd_reserved=%d\n",
 +		    sc->sc_dev.dv_xname, target, lun,
 +		    sc->sc_cmd_total, sc->sc_cmd_reserved);
 +#endif
 +		if (sc->sc_cmd_total - sc->sc_cmd_reserved < SIOP_NTAG) {
 +			if (siop_morecbd(sc, SIOP_NTAG) != 0) {
 +				xs->error = XS_DRIVER_STUFFUP;
 +				splx(s);
 +				return(TRY_AGAIN_LATER);
 +			}
 +		}
 +	}
 +				
  	siop_cmd = TAILQ_FIRST(&sc->free_list);
  	if (siop_cmd) {
  		TAILQ_REMOVE(&sc->free_list, siop_cmd, next);
  	} else {
 -		if (siop_morecbd(sc) == 0) {
 -			siop_cmd = TAILQ_FIRST(&sc->free_list);
 -#ifdef DIAGNOSTIC
 -			if (siop_cmd == NULL)
 -				panic("siop_morecbd succeed and does nothing");
 -#endif
 -			TAILQ_REMOVE(&sc->free_list, siop_cmd, next);
 -		}
 -	}
 -	if (siop_cmd == NULL) {
 +		/* this shouldn't happen */
 +		printf("%s:%d:%d: no free siop_cmd\n",
 +		     sc->sc_dev.dv_xname, target, lun);
  		xs->error = XS_DRIVER_STUFFUP;
  		splx(s);
  		return(TRY_AGAIN_LATER);
 @@ -1308,6 +1335,7 @@
  			splx(s);
  			return(TRY_AGAIN_LATER);
  		}
 +		sc->sc_cmd_reserved += SIOP_NTAG;
  		memset(sc->targets[target]->siop_lun[lun], 0,
  		    sizeof(struct siop_lun));
  	}
 @@ -1607,8 +1635,9 @@
  }

  int
 -siop_morecbd(sc)
 +siop_morecbd(sc, ncbd)
  	struct siop_softc *sc;
 +	int ncbd;
  {
  	int error, i, j;
  	bus_dma_segment_t seg;
 @@ -1616,6 +1645,10 @@
  	struct siop_cbd *newcbd;
  	bus_addr_t dsa;
  	u_int32_t *scr;
 +	int ncbdpgs, r_ncbd;
 +
 +	ncbdpgs = (ncbd + SIOP_NCMDPB - 1) / SIOP_NCMDPB;
 +	r_ncbd = ncbdpgs * SIOP_NCMDPB;

  	/* allocate a new list head */
  	newcbd = malloc(sizeof(struct siop_cbd), M_DEVBUF, M_NOWAIT);
 @@ -1628,37 +1661,37 @@

  	/* allocate cmd list */
  	newcbd->cmds =
 -	    malloc(sizeof(struct siop_cmd) * SIOP_NCMDPB, M_DEVBUF, M_NOWAIT);
 +	    malloc(sizeof(struct siop_cmd) * r_ncbd, M_DEVBUF, M_NOWAIT);
  	if (newcbd->cmds == NULL) {
  		printf("%s: can't allocate memory for command descriptors\n",
  		    sc->sc_dev.dv_xname);
  		error = ENOMEM;
  		goto bad3;
  	}
 -	memset(newcbd->cmds, 0, sizeof(struct siop_cmd) * SIOP_NCMDPB);
 -	error = bus_dmamem_alloc(sc->sc_dmat, NBPG, NBPG, 0, &seg, 1, &rseg,
 -	    BUS_DMA_NOWAIT);
 +	memset(newcbd->cmds, 0, sizeof(struct siop_cmd) * r_ncbd);
 +	error = bus_dmamem_alloc(sc->sc_dmat, NBPG * ncbdpgs, NBPG,
 +	    0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
  	if (error) {
  		printf("%s: unable to allocate cbd DMA memory, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad2;
  	}
 -	error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG,
 +	error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG * ncbdpgs,
  	    (caddr_t *)&newcbd->xfers, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
  	if (error) {
  		printf("%s: unable to map cbd DMA memory, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad2;
  	}
 -	error = bus_dmamap_create(sc->sc_dmat, NBPG, 1, NBPG, 0,
 -	    BUS_DMA_NOWAIT, &newcbd->xferdma);
 +	error = bus_dmamap_create(sc->sc_dmat, NBPG * ncbdpgs, 1,
 +	    NBPG * ncbdpgs, 0, BUS_DMA_NOWAIT, &newcbd->xferdma);
  	if (error) {
  		printf("%s: unable to create cbd DMA map, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
  		goto bad1;
  	}
  	error = bus_dmamap_load(sc->sc_dmat, newcbd->xferdma, newcbd->xfers,
 -	    NBPG, NULL, BUS_DMA_NOWAIT);
 +	    NBPG * ncbdpgs, NULL, BUS_DMA_NOWAIT);
  	if (error) {
  		printf("%s: unable to load cbd DMA map, error = %d\n",
  		    sc->sc_dev.dv_xname, error);
 @@ -1669,7 +1702,7 @@
  	    (unsigned long)newcbd->xferdma->dm_segs[0].ds_addr);
  #endif

 -	for (i = 0; i < SIOP_NCMDPB; i++) {
 +	for (i = 0; i < r_ncbd; i++) {
  		error = bus_dmamap_create(sc->sc_dmat, MAXPHYS, SIOP_NSG,
  		    MAXPHYS, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
  		    &newcbd->cmds[i].dmamap_data);
 @@ -1745,6 +1778,7 @@
  #endif
  	}
  	TAILQ_INSERT_TAIL(&sc->cmds, newcbd, next);
 +	sc->sc_cmd_total += r_ncbd;
  	return 0;
  bad0:
  	bus_dmamap_destroy(sc->sc_dmat, newcbd->xferdma);
 @@ -1980,6 +2014,7 @@
  		return;
  	free(sc->targets[target]->siop_lun[lun], M_DEVBUF);
  	sc->targets[target]->siop_lun[lun] = NULL;
 +	sc->sc_cmd_reserved -= SIOP_NTAG;
  	/* XXX compact sw entry too ? */
  	/* check if we can free the whole target */
  	for (i = 0; i < 8; i++) {
 Index: siopvar.h
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/ic/siopvar.h,v
 retrieving revision 1.8.2.1
 diff -u -r1.8.2.1 siopvar.h
 --- siopvar.h	2000/12/15 04:49:52	1.8.2.1
 +++ siopvar.h	2001/12/10 21:24:07
 @@ -63,6 +63,8 @@
  	struct cmd_list free_list;	/* cmd descr free list */
  	struct cmd_list urgent_list;	/* hitgh priority cmd descr list */
  	struct cmd_list ready_list;	/* cmd descr ready list */
 +	int sc_cmd_total;		/* total # of cmd desc allocated */
 +	int sc_cmd_reserved;		/* # of cmd desc reserved for devices */
  	struct lunsw_list lunsw_list;	/* lunsw free list */
  	u_int32_t script_free_lo;	/* free ram offset from sc_scriptaddr */
  	u_int32_t script_free_hi;	/* free ram offset from sc_scriptaddr */

 --UugvWAfsgieZRqgk--
State-Changed-From-To: open->feedback 
State-Changed-By: bouyer 
State-Changed-When: Sat Jan 5 06:08:29 PST 2002 
State-Changed-Why:  
I sent a patch to try 

From: Chris Jones <chris@cjones.org>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: chris@cjones.org, gnats-bugs@gnats.netbsd.org
Subject: Re: kern/14866: lockmgr panic
Date: Fri, 1 Feb 2002 09:34:58 -0700

 --4Ckj6UjgE2iN1+kY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable

 On Mon, Dec 10, 2001 at 10:36:18PM +0100, Manuel Bouyer wrote:

 > Ops, the patch I sent you has a bug, it only works on machines with 8k pa=
 ge
 > size (and sadly I worked on this mostly with alpha and sparc64 machines
 > lately :(
 > This one is correct.

 Indeed, it is correct.  The machine works fine now; thanks!

 Sorry for the long delay in testing the patch.  If you have further
 patches you'd like me to test (if there's something that needs testing
 before being committed), I can probably do that now.

 Chris

 --=20
 ---------------------------------------------------- chris@cjones.org
 Chris Jones                                          Mad scientist at large
   www.netbsd.org www.postgresql.org www.schemers.org www.python.org

 --4Ckj6UjgE2iN1+kY
 Content-Type: application/pgp-signature
 Content-Disposition: inline

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (NetBSD)
 Comment: For info see http://www.gnupg.org

 iEYEARECAAYFAjxaw7IACgkQDPY2T8RzaD/X+wCfb2vD8jtBlz2oVCvSgUZ+58JR
 gmkAmwUkiNK0eZ/L5tk6F8OmPh/D6DIk
 =Z8X2
 -----END PGP SIGNATURE-----

 --4Ckj6UjgE2iN1+kY--
State-Changed-From-To: feedback->closed 
State-Changed-By: bouyer 
State-Changed-When: Fri Feb 1 08:38:50 PST 2002 
State-Changed-Why:  
Patch has been commited to 1.5 branch, and author said the patch solves the 
problem. 
Thanks ! 

From: Manuel Bouyer <bouyer@antioche.lip6.fr>
To: Chris Jones <chris@cjones.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/14866: lockmgr panic
Date: Fri, 1 Feb 2002 17:38:31 +0100

 On Fri, Feb 01, 2002 at 09:34:58AM -0700, Chris Jones wrote:
 > On Mon, Dec 10, 2001 at 10:36:18PM +0100, Manuel Bouyer wrote:
 > 
 > > Ops, the patch I sent you has a bug, it only works on machines with 8k page
 > > size (and sadly I worked on this mostly with alpha and sparc64 machines
 > > lately :(
 > > This one is correct.
 > 
 > Indeed, it is correct.  The machine works fine now; thanks!
 > 
 > Sorry for the long delay in testing the patch.  If you have further
 > patches you'd like me to test (if there's something that needs testing
 > before being committed), I can probably do that now.

 Ok thanks you. This patch has already been commited to the 1.5 branch
 (as 1.5.3 is close, and others have reported it worked, I asked pullup).

 --
 Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
 --

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.