Module Name:    src
Committed By:   martin
Date:           Thu Oct 26 15:11:02 UTC 2023

Modified Files:
        src/sys/dev/pci [netbsd-10]: mpii.c

Log Message:
Pull up following revision(s) (requested by buhrow in ticket #435):

        sys/dev/pci/mpii.c: revision 1.30

Fixes for PR kern/57133:

I can now explain why this assert is firing and have a fix for it.  It is a  
regression introduced in R1.22 of mpii.c.

        If a request comes in and the IOC returns a 
MPII_SCSIIO_STATUS_CHECK_COND condition, after
 a successful transfer, or one that is a recovered error,
 mpii(4) correctly sets the xs->error to XS_SENSE, but incorrectly sets 
xs->resid to 0 before
 returning the xfer to the upper scsi layers.  Once the upper layers get it, 
they notice the
 XS_SENSE check condition and because it's a retryable error, they increment 
xs_requeuecnt, set
 ERESTART and send the xfer request down to the mpii(4) layer again for a 
retry. What they do
 not do is reset xs->resid equal to xs->datalen.  When the xfer comes down to 
mpii(4) again, the
 assert happens.  The fix is for the mpii(4) driver to leave xs->resid alone 
when it encounters
 a MPII_SCSIIO_STATUS_CHECK_COND condition.

This bug affects NetBSD-10, netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.6.1 src/sys/dev/pci/mpii.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.29 src/sys/dev/pci/mpii.c:1.29.6.1
--- src/sys/dev/pci/mpii.c:1.29	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/mpii.c	Thu Oct 26 15:11:02 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.29 2021/08/07 16:19:14 thorpej Exp $ */
+/* $NetBSD: mpii.c,v 1.29.6.1 2023/10/26 15:11:02 martin Exp $ */
 /*	$OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $	*/
 /*
  * Copyright (c) 2010, 2012 Mike Belopuhov
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.29 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.29.6.1 2023/10/26 15:11:02 martin Exp $");
 
 #include "bio.h"
 
@@ -3204,7 +3204,6 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
 	}
 
 	KASSERT(xs->error == XS_NOERROR);
-	KASSERT(xs->resid == xs->datalen);
 	KASSERT(xs->status == SCSI_OK);
 
 	if (ccb->ccb_rcb == NULL) {
@@ -3264,7 +3263,6 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
 			break;
 
 		case MPII_SCSIIO_STATUS_CHECK_COND:
-			xs->resid = 0;
 			xs->error = XS_SENSE;
 			break;
 

Reply via email to