From nobody@FreeBSD.org  Thu Aug  2 06:09:56 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0776F16A41A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  2 Aug 2007 06:09:56 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E7DBC13C4A6
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  2 Aug 2007 06:09:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l7269tJ3063119
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 2 Aug 2007 06:09:55 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l7269tqa063118;
	Thu, 2 Aug 2007 06:09:55 GMT
	(envelope-from nobody)
Message-Id: <200708020609.l7269tqa063118@www.freebsd.org>
Date: Thu, 2 Aug 2007 06:09:55 GMT
From: Martin Nilsson <martin@gneto.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [mpt][mfi] Patches to make mfi support LSI SAS1078 chip
X-Send-Pr-Version: www-3.0

>Number:         115133
>Category:       kern
>Synopsis:       [mpt] [mfi] [patch] Patches to make mfi support LSI SAS1078 chip
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    scottl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 02 06:10:09 GMT 2007
>Closed-Date:    Sat Aug 07 16:53:24 UTC 2010
>Last-Modified:  Sat Aug 07 16:53:24 UTC 2010
>Originator:     Martin Nilsson
>Release:        7.0-CURRENT
>Organization:
>Environment:
FreeBSD t126.gneto.com 7.0-CURRENT FreeBSD 7.0-CURRENT #5: Wed Aug  1 18:30:14 CEST 2007     root@t126.gneto.com:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
The attached patches removes SAS1078 support from mpt which does not work and adds it to the mfi driver. The patches have been taken from the Linux driver on LSI Logics webpage.

With the patches the following cards should work:
SAS8704ELP
SAS8708ELP (tested)
SAS8888ELP

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Common subdirectories: mpt.orig/mpilib and mpt/mpilib
diff -u mpt.orig/mpt_pci.c mpt/mpt_pci.c
--- mpt.orig/mpt_pci.c	2007-05-05 22:18:24.000000000 +0200
+++ mpt/mpt_pci.c	2007-08-01 22:11:22.000000000 +0200
@@ -181,10 +181,6 @@
 #define PCI_PRODUCT_LSI_SAS1068E	0x0058
 #endif
 
-#ifndef PCI_PRODUCT_LSI_SAS1078
-#define PCI_PRODUCT_LSI_SAS1078		0x0060
-#endif
-
 #ifndef	PCIM_CMD_SERRESPEN
 #define	PCIM_CMD_SERRESPEN	0x0100
 #endif
@@ -264,7 +260,6 @@
 	case PCI_PRODUCT_LSI_SAS1066E:
 	case PCI_PRODUCT_LSI_SAS1068:
 	case PCI_PRODUCT_LSI_SAS1068E:
-	case PCI_PRODUCT_LSI_SAS1078:
 		desc = "LSILogic SAS/SATA Adapter";
 		break;
 	default:
@@ -440,7 +435,6 @@
 	case PCI_PRODUCT_LSI_SAS1066E:
 	case PCI_PRODUCT_LSI_SAS1068:
 	case PCI_PRODUCT_LSI_SAS1068E:
-	case PCI_PRODUCT_LSI_SAS1078:
 		mpt->is_sas = 1;
 		break;
 	default:


>Release-Note:
>Audit-Trail:

From: Martin Nilsson <martin@gneto.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/115133: [mpt][mfi] Patches to make mfi support LSI SAS1078
 chip
Date: Thu, 02 Aug 2007 08:22:00 +0200

 This is a multi-part message in MIME format.
 --------------080105060103090609080704
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 And here is the mfi patch...
 
 --------------080105060103090609080704
 Content-Type: text/x-patch;
  name="mfi.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="mfi.diff"
 
 Only in mfi: CmdTool.log
 diff -u mfi.orig/mfi.c mfi/mfi.c
 --- mfi.orig/mfi.c	2007-06-04 18:39:22.000000000 +0200
 +++ mfi/mfi.c	2007-08-01 22:10:51.000000000 +0200
 @@ -120,7 +120,11 @@
  	int32_t fw_state, cur_state;
  	int max_wait, i;
  
 -	fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_FWSTATE_MASK;
 +	if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +		fw_state = MFI_READ4(sc, MFI_OSP) & MFI_FWSTATE_MASK;
 +	} else {
 +		fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_FWSTATE_MASK;
 +	}
  	while (fw_state != MFI_FWSTATE_READY) {
  		if (bootverbose)
  			device_printf(sc->mfi_dev, "Waiting for firmware to "
 @@ -153,7 +157,11 @@
  			return (ENXIO);
  		}
  		for (i = 0; i < (max_wait * 10); i++) {
 -			fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_FWSTATE_MASK;
 +		        if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +		                fw_state = MFI_READ4(sc, MFI_OSP) & MFI_FWSTATE_MASK;
 +		        } else {
 +		        	fw_state = MFI_READ4(sc, MFI_OMSG0) & MFI_FWSTATE_MASK;
 +		        }
  			if (fw_state == cur_state)
  				DELAY(100000);
  			else
 @@ -208,7 +216,11 @@
  	 * It would be nice if these constants were available at runtime
  	 * instead of compile time.
  	 */
 -	status = MFI_READ4(sc, MFI_OMSG0);
 +	if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +	 	status = MFI_READ4(sc, MFI_OSP);
 +	} else {
 +	 	status = MFI_READ4(sc, MFI_OMSG0);
 + 	}
  	sc->mfi_max_fw_cmds = status & MFI_FWSTATE_MAXCMD_MASK;
  	max_fw_sge = (status & MFI_FWSTATE_MAXSGL_MASK) >> 16;
  	sc->mfi_max_sge = min(max_fw_sge, ((MAXPHYS / PAGE_SIZE) + 1));
 @@ -781,10 +793,16 @@
  	sc = (struct mfi_softc *)arg;
  
  	status = MFI_READ4(sc, MFI_OSTS);
 -	if ((status & MFI_OSTS_INTR_VALID) == 0)
 -		return;
 +	if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +		if ((status & MFI_OSTS_INTR_VALID_1078) == 0)
 +			return;
 +		MFI_WRITE4(sc, MFI_ODBC, status);
 +	} else {
 +		if ((status & MFI_OSTS_INTR_VALID) == 0)
 +			return;
 +		MFI_WRITE4(sc, MFI_OSTS, status);
 +	}
  
 -	MFI_WRITE4(sc, MFI_OSTS, status);
  
  	pi = sc->mfi_comms->hw_pi;
  	ci = sc->mfi_comms->hw_ci;
 @@ -848,7 +866,11 @@
  mfi_enable_intr(struct mfi_softc *sc)
  {
  
 -	MFI_WRITE4(sc, MFI_OMSK, 0x01);
 +	if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +		MFI_WRITE4(sc, MFI_ODBC,  0xffffffff);
 +		MFI_WRITE4(sc, MFI_OMSK, ~0x80000004);
 +	} else 
 +		MFI_WRITE4(sc, MFI_OMSK, 0x01);
  }
  
  static void
 @@ -1635,8 +1657,13 @@
  	if (cm->cm_extra_frames > 7)
  		cm->cm_extra_frames = 7;
  
 -	MFI_WRITE4(sc, MFI_IQP, (cm->cm_frame_busaddr >> 3) |
 -	    cm->cm_extra_frames);
 +	if(sc->mfi_flags & MFI_FLAGS_PPC) {
 +		MFI_WRITE4(sc, MFI_IQP, cm->cm_frame_busaddr |
 +	    	(cm->cm_extra_frames<<1)|1);
 +	} else {
 +		MFI_WRITE4(sc, MFI_IQP, (cm->cm_frame_busaddr >> 3) |
 +	    	cm->cm_extra_frames);
 +	}
  
  	if ((cm->cm_flags & MFI_CMD_POLLED) == 0)
  		return (0);
 diff -u mfi.orig/mfi_pci.c mfi/mfi_pci.c
 --- mfi.orig/mfi_pci.c	2007-05-10 17:33:41.000000000 +0200
 +++ mfi/mfi_pci.c	2007-08-01 22:10:51.000000000 +0200
 @@ -91,6 +91,7 @@
  	{0x1000, 0x0411, 0xffff, 0xffff, 0, "LSI MegaSAS 1064R"}, /* Brocton IOP */
  	{0x1000, 0x0413, 0xffff, 0xffff, 0, "LSI MegaSAS 1064R"}, /* Verde ZCR */
  	{0x1028, 0x0015, 0xffff, 0xffff, 0, "Dell PERC 5/i"},
 +	{0x1000, 0x0060, 0xffff, 0xffff, MFI_FLAGS_PPC, "LSI MegaSAS 1078R"}, /* ppc IOP */
  	{0, 0, 0, 0, 0, NULL}
  };
  
 diff -u mfi.orig/mfireg.h mfi/mfireg.h
 --- mfi.orig/mfireg.h	2007-05-16 19:23:36.000000000 +0200
 +++ mfi/mfireg.h	2007-08-01 22:10:51.000000000 +0200
 @@ -55,10 +55,14 @@
  #define MFI_OMSK	0x34	/* Outbound interrupt mask */
  #define MFI_IQP		0x40	/* Inbound queue port */
  #define MFI_OQP		0x44	/* Outbound queue port */
 +#define MFI_ODBC	0xa0	/* Outbound doorbell clear */
 +#define MFI_OSP		0xb0	/* Outbound scratch pad */
 +#define MFI_ILQP	0xc0	/* inbound low queue port */
 +#define MFI_IHQP	0xc4	/* inbound high queue port */
  
  /* Bits for MFI_OSTS */
 -#define MFI_OSTS_INTR_VALID	0x00000002
 -
 +#define MFI_OSTS_INTR_VALID	 0x00000002
 +#define MFI_OSTS_INTR_VALID_1078 0x80000000
  /*
   * Firmware state values.  Found in OMSG0 during initialization.
   */
 diff -u mfi.orig/mfivar.h mfi/mfivar.h
 --- mfi.orig/mfivar.h	2007-06-04 18:39:22.000000000 +0200
 +++ mfi/mfivar.h	2007-08-01 22:10:51.000000000 +0200
 @@ -101,6 +101,7 @@
  #define MFI_FLAGS_QFRZN		(1<<1)
  #define MFI_FLAGS_OPEN		(1<<2)
  #define MFI_FLAGS_STOP		(1<<3)
 +#define MFI_FLAGS_PPC		(1<<4)
  
  	struct mfi_hwcomms		*mfi_comms;
  	TAILQ_HEAD(,mfi_command)	mfi_free;
 
 --------------080105060103090609080704--
Responsible-Changed-From-To: freebsd-bugs->mjacob 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Aug 2 07:13:55 UTC 2007 
Responsible-Changed-Why:  
Hello Matt, can you have a look at this please? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115133 
Responsible-Changed-From-To: mjacob->scottl 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Aug 2 10:05:55 UTC 2007 
Responsible-Changed-Why:  
Hi Scott, can you have a look at the change and see whether they are good 
I can commit it for you if that's OK (after mentor / re approval ofcourse). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115133 

From: pluknet <pluknet@gmail.com>
To: bug-followup@FreeBSD.org, martin@gneto.com
Cc:  
Subject: Re: kern/115133: [mpt] [mfi] [patch] Patches to make mfi support LSI 
	SAS1078 chip
Date: Thu, 22 Apr 2010 10:34:49 +0400

 JFYI, from my perspective, a similar diff in svn already (last chunk
 got there around 7.1).

From: Martin Nilsson <martin@gneto.com>
To: pluknet <pluknet@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/115133: [mpt] [mfi] [patch] Patches to make mfi support
 LSI 	SAS1078 chip
Date: Thu, 22 Apr 2010 08:39:21 +0200

 pluknet wrote:
 > JFYI, from my perspective, a similar diff in svn already (last chunk
 > got there around 7.1).
 >   
 Hi,
 
 This patch is very old, the support in the tree works ok and have for years.
 Please close this pr!
 
 
 Best regards,
 Martin Nilsson
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Sat Aug 7 16:52:53 UTC 2010 
State-Changed-Why:  
Submitter says this was fixed some time ago, close. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115133 
>Unformatted:
