From nobody@FreeBSD.org  Wed Aug 15 04:03:53 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 9840437B40A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Aug 2001 04:03:53 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id f7FB3rl86388;
	Wed, 15 Aug 2001 04:03:53 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200108151103.f7FB3rl86388@freefall.freebsd.org>
Date: Wed, 15 Aug 2001 04:03:53 -0700 (PDT)
From: Katsuyuki Yumoto <yumoto@jpn.hp.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: amr_enquiry3 structure in amrreg.h (amr driver) is incorrect.
X-Send-Pr-Version: www-1.0

>Number:         29727
>Category:       kern
>Synopsis:       [amr] [patch] amr_enquiry3 structure in amrreg.h is incorrect.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 15 04:10:04 PDT 2001
>Closed-Date:    Tue Apr 25 16:34:42 GMT 2006
>Last-Modified:  Tue Apr 25 16:34:42 GMT 2006
>Originator:     Katsuyuki Yumoto
>Release:        4.3R
>Organization:
HP Japan
>Environment:
>Description:
In the amr_enquiry3 structure described in amrreg.h file, 
Please make sure ae_drivestate is not physical drive state but logical one.
Also ae_phydrivestate has to follow it.

>How-To-Repeat:
getting result of amr_enquiry3 structure by issuing Enq3 command via ioctl().




>Fix:
apply following patch

diff -u -N -r sys.b/dev/amr/amrreg.h sys/dev/amr/amrreg.h
--- sys.b/dev/amr/amrreg.h      Tue Aug 14 18:38:41 2001
+++ sys/dev/amr/amrreg.h        Tue Aug 14 18:37:54 2001
@@ -341,7 +341,8 @@
     u_int16_t  ae_opstatus[AMR_40LD_MAXDRIVES / 8];    /* operation status per
drive */
     u_int32_t  ae_drivesize[AMR_40LD_MAXDRIVES];       /* logical drive size */
     u_int8_t   ae_driveprop[AMR_40LD_MAXDRIVES];       /* logical drive propert
ies */
-    u_int8_t   ae_drivestate[AMR_40LD_MAXDRIVES];      /* physical drive state
*/
+    u_int8_t   ae_drivestate[AMR_40LD_MAXDRIVES];      /* logical drive state *
/
+    u_int8_t   ae_phydrivestate[AMR_40LD_MAXDRIVES];   /* physical drive state
*/
     u_int16_t  ae_driveformat[AMR_40LD_MAXPHYSDRIVES];
     u_int8_t   ae_targxfer[80];                        /* physical drive transf
er rates */

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-scsi 
Responsible-Changed-By: arved 
Responsible-Changed-When: Mon Aug 30 21:46:43 GMT 2004 
Responsible-Changed-Why:  
Over to freebsd-scsi for review 

http://www.freebsd.org/cgi/query-pr.cgi?pr=29727 
Responsible-Changed-From-To: freebsd-scsi->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Fri Jan 13 23:43:03 UTC 2006 
Responsible-Changed-Why:  
Since nobody seems to be interested, I will take this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=29727 
State-Changed-From-To: open->patched 
State-Changed-By: jkim 
State-Changed-When: Fri Jan 13 23:51:47 UTC 2006 
State-Changed-Why:  
Committed my version on HEAD. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=29727 
State-Changed-From-To: patched->closed 
State-Changed-By: jkim 
State-Changed-When: Tue Apr 25 16:32:04 UTC 2006 
State-Changed-Why:  
No problem so far. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=29727 
>Unformatted:
The patch doesn't seem to be correct.  Linux driver says:

http://lxr.linux.no/source/drivers/scsi/megaraid.h#L332

and size of the structure is 1,024 bytes as comment says.  On the other
hand, FreeBSD's structure is 1,248-byte long.  With Katsuyuki's patch,
it becomes 1,288-byte long.

The following patch is to sync. with Linux driver.

Index: amrreg.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/amr/amrreg.h,v
retrieving revision 1.8
diff -u -r1.8 amrreg.h
--- amrreg.h	23 Jan 2005 23:25:41 -0000	1.8
+++ amrreg.h	11 Aug 2005 19:51:35 -0000
@@ -377,8 +377,9 @@
     u_int16_t	ae_opstatus[AMR_40LD_MAXDRIVES / 8];	/* operation status per drive */
     u_int32_t	ae_drivesize[AMR_40LD_MAXDRIVES];	/* logical drive size */
     u_int8_t	ae_driveprop[AMR_40LD_MAXDRIVES];	/* logical drive properties */
-    u_int8_t	ae_drivestate[AMR_40LD_MAXDRIVES];	/* physical drive state */
-    u_int16_t	ae_driveformat[AMR_40LD_MAXPHYSDRIVES];
+    u_int8_t	ae_drivestate[AMR_40LD_MAXDRIVES];	/* logical drive state */
+    u_int8_t	ae_pdrivestate[AMR_40LD_MAXPHYSDRIVES];	/* physical drive state */
+    u_int16_t	ae_pdriveformat[AMR_40LD_MAXPHYSDRIVES / 16];
     u_int8_t	ae_targxfer[80];			/* physical drive transfer rates */
 
     u_int8_t	res1[263];		/* pad to 1024 bytes */
