Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2015 08:02:21 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r292322 - in stable/10: share/man/man4 sys/dev/arcmsr
Message-ID:  <201512160802.tBG82L06029023@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Wed Dec 16 08:02:21 2015
New Revision: 292322
URL: https://svnweb.freebsd.org/changeset/base/292322

Log:
  MFC r259564,259565,291641:
  
  Update arcmsr(4) to 1.30.00.00 in order to add support of
  ARC-1203 SATA RAID controllers.
  
  Many thanks to Areca for continuing to support FreeBSD.

Modified:
  stable/10/share/man/man4/arcmsr.4
  stable/10/sys/dev/arcmsr/arcmsr.c
  stable/10/sys/dev/arcmsr/arcmsr.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/arcmsr.4
==============================================================================
--- stable/10/share/man/man4/arcmsr.4	Wed Dec 16 06:21:26 2015	(r292321)
+++ stable/10/share/man/man4/arcmsr.4	Wed Dec 16 08:02:21 2015	(r292322)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 27, 2013
+.Dd December 18, 2013
 .Dt ARCMSR 4
 .Os
 .Sh NAME
@@ -143,6 +143,8 @@ ARC-1681
 ARC-1880
 .It
 ARC-1882
+.It
+ARC-1883
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/arcmsr?" -compact

Modified: stable/10/sys/dev/arcmsr/arcmsr.c
==============================================================================
--- stable/10/sys/dev/arcmsr/arcmsr.c	Wed Dec 16 06:21:26 2015	(r292321)
+++ stable/10/sys/dev/arcmsr/arcmsr.c	Wed Dec 16 08:02:21 2015	(r292322)
@@ -75,6 +75,8 @@
 ** 1.20.00.26   12/14/2012  Ching Huang     Added support ARC1214,1224,1264,1284
 ** 1.20.00.27   05/06/2013  Ching Huang     Fixed out standing cmd full on ARC-12x4
 ** 1.20.00.28   09/13/2013  Ching Huang     Removed recursive mutex in arcmsr_abort_dr_ccbs
+** 1.20.00.29   12/18/2013  Ching Huang     Change simq allocation number, support ARC1883
+** 1.30.00.00   11/30/2015  Ching Huang     Added support ARC1203
 ******************************************************************************************
 */
 
@@ -125,15 +127,15 @@ __FBSDID("$FreeBSD$");
 **************************************************************************
 */
 #if __FreeBSD_version >= 500005
-    #include <sys/selinfo.h>
-    #include <sys/mutex.h>
-    #include <sys/endian.h>
-    #include <dev/pci/pcivar.h>
-    #include <dev/pci/pcireg.h>
+	#include <sys/selinfo.h>
+	#include <sys/mutex.h>
+	#include <sys/endian.h>
+	#include <dev/pci/pcivar.h>
+	#include <dev/pci/pcireg.h>
 #else
-    #include <sys/select.h>
-    #include <pci/pcivar.h>
-    #include <pci/pcireg.h>
+	#include <sys/select.h>
+	#include <pci/pcivar.h>
+	#include <pci/pcireg.h>
 #endif
 
 #if !defined(CAM_NEW_TRAN_CODE) && __FreeBSD_version >= 700025
@@ -146,7 +148,7 @@ __FBSDID("$FreeBSD$");
 #define arcmsr_callout_init(a)	callout_init(a);
 #endif
 
-#define ARCMSR_DRIVER_VERSION	"arcmsr version 1.20.00.28 2013-09-13"
+#define ARCMSR_DRIVER_VERSION	"arcmsr version 1.30.00.00 2015-11-30"
 #include <dev/arcmsr/arcmsr.h>
 /*
 **************************************************************************
@@ -180,8 +182,8 @@ static int arcmsr_iop_message_xfer(struc
 static int arcmsr_resume(device_t dev);
 static int arcmsr_suspend(device_t dev);
 static void arcmsr_rescanLun_cb(struct cam_periph *periph, union ccb *ccb);
-static void	arcmsr_polling_devmap(void *arg);
-static void	arcmsr_srb_timeout(void *arg);
+static void arcmsr_polling_devmap(void *arg);
+static void arcmsr_srb_timeout(void *arg);
 static void arcmsr_hbd_postqueue_isr(struct AdapterControlBlock *acb);
 #ifdef ARCMSR_DEBUG1
 static void arcmsr_dump_data(struct AdapterControlBlock *acb);
@@ -219,11 +221,11 @@ static device_method_t arcmsr_methods[]=
 	{ 0, 0 }
 #endif
 };
-	
+
 static driver_t arcmsr_driver={
 	"arcmsr", arcmsr_methods, sizeof(struct AdapterControlBlock)
 };
-	
+
 static devclass_t arcmsr_devclass;
 DRIVER_MODULE(arcmsr, pci, arcmsr_driver, arcmsr_devclass, 0, 0);
 MODULE_DEPEND(arcmsr, pci, 1, 1, 1);
@@ -246,38 +248,38 @@ static struct cdevsw arcmsr_cdevsw={
 	};
 #else
 	#define ARCMSR_CDEV_MAJOR	180
-	
+
 static struct cdevsw arcmsr_cdevsw = {
-		arcmsr_open,				/* open     */
-		arcmsr_close,				/* close    */
-		noread,						/* read     */
-		nowrite,					/* write    */
-		arcmsr_ioctl,				/* ioctl    */
-		nopoll,						/* poll     */
-		nommap,						/* mmap     */
-		nostrategy,					/* strategy */
-		"arcmsr",					/* name     */
-		ARCMSR_CDEV_MAJOR,			/* major    */
-		nodump,						/* dump     */
-		nopsize,					/* psize    */
-		0							/* flags    */
+		arcmsr_open,			/* open     */
+		arcmsr_close,			/* close    */
+		noread,				/* read     */
+		nowrite,			/* write    */
+		arcmsr_ioctl,			/* ioctl    */
+		nopoll,				/* poll     */
+		nommap,				/* mmap     */
+		nostrategy,			/* strategy */
+		"arcmsr",			/* name     */
+		ARCMSR_CDEV_MAJOR,		/* major    */
+		nodump,				/* dump     */
+		nopsize,			/* psize    */
+		0				/* flags    */
 	};
 #endif
 /*
 **************************************************************************
 **************************************************************************
 */
-#if __FreeBSD_version < 500005
+#if	__FreeBSD_version < 500005
 	static int arcmsr_open(dev_t dev, int flags, int fmt, struct proc *proc)
 #else
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 	static int arcmsr_open(dev_t dev, int flags, int fmt, struct thread *proc)
 	#else
 	static int arcmsr_open(struct cdev *dev, int flags, int fmt, struct thread *proc)
 	#endif 
 #endif
 {
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
@@ -292,17 +294,17 @@ static struct cdevsw arcmsr_cdevsw = {
 **************************************************************************
 **************************************************************************
 */
-#if __FreeBSD_version < 500005
+#if	__FreeBSD_version < 500005
 	static int arcmsr_close(dev_t dev, int flags, int fmt, struct proc *proc)
 #else
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 	static int arcmsr_close(dev_t dev, int flags, int fmt, struct thread *proc)
 	#else
 	static int arcmsr_close(struct cdev *dev, int flags, int fmt, struct thread *proc)
 	#endif 
 #endif
 {
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
@@ -317,17 +319,17 @@ static struct cdevsw arcmsr_cdevsw = {
 **************************************************************************
 **************************************************************************
 */
-#if __FreeBSD_version < 500005
+#if	__FreeBSD_version < 500005
 	static int arcmsr_ioctl(dev_t dev, u_long ioctl_cmd, caddr_t arg, int flags, struct proc *proc)
 #else
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 	static int arcmsr_ioctl(dev_t dev, u_long ioctl_cmd, caddr_t arg, int flags, struct thread *proc)
 	#else
 	static int arcmsr_ioctl(struct cdev *dev, u_long ioctl_cmd, caddr_t arg, int flags, struct thread *proc)
 	#endif 
 #endif
 {
-	#if __FreeBSD_version < 503000
+	#if	__FreeBSD_version < 503000
 		struct AdapterControlBlock *acb = dev->si_drv1;
 	#else
 		int	unit = dev2unit(dev);
@@ -346,7 +348,7 @@ static struct cdevsw arcmsr_cdevsw = {
 static u_int32_t arcmsr_disable_allintr( struct AdapterControlBlock *acb)
 {
 	u_int32_t intmask_org = 0;
-	
+
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			/* disable all outbound interrupt */
@@ -355,10 +357,11 @@ static u_int32_t arcmsr_disable_allintr(
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			/* disable all outbound interrupt */
-			intmask_org = CHIP_REG_READ32(HBB_DOORBELL, 
-						0, iop2drv_doorbell_mask) & (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); /* disable outbound message0 int */
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell_mask, 0); /* disable all interrupt */
+			intmask_org = READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask)
+						& (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); /* disable outbound message0 int */
+			WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask, 0); /* disable all interrupt */
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
@@ -383,7 +386,7 @@ static u_int32_t arcmsr_disable_allintr(
 static void arcmsr_enable_allintr( struct AdapterControlBlock *acb, u_int32_t intmask_org)
 {
 	u_int32_t mask;
-	
+
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			/* enable outbound Post Queue, outbound doorbell Interrupt */
@@ -393,9 +396,10 @@ static void arcmsr_enable_allintr( struc
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			/* enable ARCMSR_IOP2DRV_MESSAGE_CMD_DONE */
 			mask = (ARCMSR_IOP2DRV_DATA_WRITE_OK|ARCMSR_IOP2DRV_DATA_READ_OK|ARCMSR_IOP2DRV_CDB_DONE|ARCMSR_IOP2DRV_MESSAGE_CMD_DONE);
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell_mask, intmask_org | mask); /*1=interrupt enable, 0=interrupt disable*/
+			WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell_mask, intmask_org | mask); /*1=interrupt enable, 0=interrupt disable*/
 			acb->outbound_int_enable = (intmask_org | mask) & 0x0000000f;
 		}
 		break;
@@ -424,7 +428,7 @@ static u_int8_t arcmsr_hba_wait_msgint_r
 {
 	u_int32_t Index;
 	u_int8_t Retries = 0x00;
-	
+
 	do {
 		for(Index=0; Index < 100; Index++) {
 			if(CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & ARCMSR_MU_OUTBOUND_MESSAGE0_INT) {
@@ -444,12 +448,13 @@ static u_int8_t arcmsr_hbb_wait_msgint_r
 {
 	u_int32_t Index;
 	u_int8_t Retries = 0x00;
-	
+	struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
+
 	do {
 		for(Index=0; Index < 100; Index++) {
-			if(CHIP_REG_READ32(HBB_DOORBELL, 0, iop2drv_doorbell) & ARCMSR_IOP2DRV_MESSAGE_CMD_DONE) {
-				CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN);/*clear interrupt*/
-				CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_DRV2IOP_END_OF_INTERRUPT);
+			if(READ_CHIP_REG32(0, phbbmu->iop2drv_doorbell) & ARCMSR_IOP2DRV_MESSAGE_CMD_DONE) {
+				WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN);/*clear interrupt*/
+				WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_END_OF_INTERRUPT);
 				return TRUE;
 			}
 			UDELAY(10000);
@@ -465,7 +470,7 @@ static u_int8_t arcmsr_hbc_wait_msgint_r
 {
 	u_int32_t Index;
 	u_int8_t Retries = 0x00;
-	
+
 	do {
 		for(Index=0; Index < 100; Index++) {
 			if(CHIP_REG_READ32(HBC_MessageUnit, 0, outbound_doorbell) & ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE) {
@@ -485,7 +490,7 @@ static u_int8_t arcmsr_hbd_wait_msgint_r
 {
 	u_int32_t Index;
 	u_int8_t Retries = 0x00;
-	
+
 	do {
 		for(Index=0; Index < 100; Index++) {
 			if(CHIP_REG_READ32(HBD_MessageUnit, 0, outbound_doorbell) & ARCMSR_HBDMU_IOP2DRV_MESSAGE_CMD_DONE) {
@@ -504,7 +509,7 @@ static u_int8_t arcmsr_hbd_wait_msgint_r
 static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb)
 {
 	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
-	
+
 	CHIP_REG_WRITE32(HBA_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
 	do {
 		if(arcmsr_hba_wait_msgint_ready(acb)) {
@@ -521,9 +526,9 @@ static void arcmsr_flush_hba_cache(struc
 static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb)
 {
 	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
-	
-	CHIP_REG_WRITE32(HBB_DOORBELL, 
-	0, drv2iop_doorbell, ARCMSR_MESSAGE_FLUSH_CACHE);
+	struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
+
+	WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_FLUSH_CACHE);
 	do {
 		if(arcmsr_hbb_wait_msgint_ready(acb)) {
 			break;
@@ -539,7 +544,7 @@ static void arcmsr_flush_hbb_cache(struc
 static void arcmsr_flush_hbc_cache(struct AdapterControlBlock *acb)
 {
 	int retry_count = 30;/* enlarge wait flush adapter cache time: 10 minute */
-	
+
 	CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
 	CHIP_REG_WRITE32(HBC_MessageUnit, 0, inbound_doorbell, ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE);
 	do {
@@ -557,7 +562,7 @@ static void arcmsr_flush_hbc_cache(struc
 static void arcmsr_flush_hbd_cache(struct AdapterControlBlock *acb)
 {
 	int retry_count = 30; /* enlarge wait flush adapter cache time: 10 minute */
-	
+
 	CHIP_REG_WRITE32(HBD_MessageUnit, 0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_FLUSH_CACHE);
 	do {
 		if(arcmsr_hbd_wait_msgint_ready(acb)) {
@@ -599,7 +604,7 @@ static void arcmsr_flush_adapter_cache(s
 static int arcmsr_suspend(device_t dev)
 {
 	struct AdapterControlBlock	*acb = device_get_softc(dev);
-	
+
 	/* flush controller */
 	arcmsr_iop_parking(acb);
 	/* disable all outbound interrupt */
@@ -613,7 +618,7 @@ static int arcmsr_suspend(device_t dev)
 static int arcmsr_resume(device_t dev)
 {
 	struct AdapterControlBlock	*acb = device_get_softc(dev);
-	
+
 	arcmsr_iop_init(acb);
 	return(0);
 }
@@ -626,7 +631,7 @@ static void arcmsr_async(void *cb_arg, u
 	struct AdapterControlBlock *acb;
 	u_int8_t target_id, target_lun;
 	struct cam_sim *sim;
-	
+
 	sim = (struct cam_sim *) cb_arg;
 	acb =(struct AdapterControlBlock *) cam_sim_softc(sim);
 	switch (code) {
@@ -649,7 +654,7 @@ static void arcmsr_async(void *cb_arg, u
 static void arcmsr_report_sense_info(struct CommandControlBlock *srb)
 {
 	union ccb *pccb = srb->pccb;
-	
+
 	pccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
 	pccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
 	if(pccb->csio.sense_len) {
@@ -677,7 +682,8 @@ static void arcmsr_abort_hba_allcmd(stru
 */
 static void arcmsr_abort_hbb_allcmd(struct AdapterControlBlock *acb)
 {
-	CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_MESSAGE_ABORT_CMD);
+	struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
+	WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_ABORT_CMD);
 	if(!arcmsr_hbb_wait_msgint_ready(acb)) {
 		printf("arcmsr%d: wait 'abort all outstanding command' timeout \n", acb->pci_unit);
 	}
@@ -738,12 +744,12 @@ static void arcmsr_srb_complete(struct C
 {
 	struct AdapterControlBlock *acb = srb->acb;
 	union ccb *pccb = srb->pccb;
-	
+
 	if(srb->srb_flags & SRB_FLAG_TIMER_START)
 		callout_stop(&srb->ccb_callout);
 	if((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
 		bus_dmasync_op_t op;
-	
+
 		if((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
 			op = BUS_DMASYNC_POSTREAD;
 		} else {
@@ -772,7 +778,7 @@ static void arcmsr_srb_complete(struct C
 static void arcmsr_report_srb_state(struct AdapterControlBlock *acb, struct CommandControlBlock *srb, u_int16_t error)
 {
 	int target, lun;
-	
+
 	target = srb->pccb->ccb_h.target_id;
 	lun = srb->pccb->ccb_h.target_lun;
 	if(error == FALSE) {
@@ -823,7 +829,7 @@ static void arcmsr_report_srb_state(stru
 static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, u_int32_t flag_srb, u_int16_t error)
 {
 	struct CommandControlBlock *srb;
-	
+
 	/* check if command done with no error*/
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_C:
@@ -859,7 +865,7 @@ static void	arcmsr_srb_timeout(void *arg
 	struct AdapterControlBlock *acb;
 	int target, lun;
 	u_int8_t cmd;
-	
+
 	target = srb->pccb->ccb_h.target_id;
 	lun = srb->pccb->ccb_h.target_lun;
 	acb = srb->acb;
@@ -875,7 +881,7 @@ static void	arcmsr_srb_timeout(void *arg
 	}
 	ARCMSR_LOCK_RELEASE(&acb->isr_lock);
 #ifdef ARCMSR_DEBUG1
-    	arcmsr_dump_data(acb);
+	arcmsr_dump_data(acb);
 #endif
 }
 
@@ -888,29 +894,29 @@ static void arcmsr_done4abort_postqueue(
 	int i=0;
 	u_int32_t flag_srb;
 	u_int16_t error;
-	
+
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			u_int32_t outbound_intstatus;
-	
+
 			/*clear and abort all outbound posted Q*/
 			outbound_intstatus = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_intstatus) & acb->outbound_int_enable;
 			CHIP_REG_WRITE32(HBA_MessageUnit, 0, outbound_intstatus, outbound_intstatus);/*clear interrupt*/
 			while(((flag_srb=CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_queueport)) != 0xFFFFFFFF) && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) {
-                error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
+				error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 				arcmsr_drain_donequeue(acb, flag_srb, error);
 			}
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
 			struct HBB_MessageUnit *phbbmu=(struct HBB_MessageUnit *)acb->pmu;
-	
+
 			/*clear all outbound posted Q*/
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN); /* clear doorbell interrupt */
+			WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_DOORBELL_INT_CLEAR_PATTERN); /* clear doorbell interrupt */
 			for(i=0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) {
 				if((flag_srb = phbbmu->done_qbuffer[i]) != 0) {
 					phbbmu->done_qbuffer[i] = 0;
-                	error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
+					error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE0)?TRUE:FALSE;
 					arcmsr_drain_donequeue(acb, flag_srb, error);
 				}
 				phbbmu->post_qbuffer[i] = 0;
@@ -920,10 +926,10 @@ static void arcmsr_done4abort_postqueue(
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
-	
+
 			while((CHIP_REG_READ32(HBC_MessageUnit, 0, host_int_status) & ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR) && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) {
 				flag_srb = CHIP_REG_READ32(HBC_MessageUnit, 0, outbound_queueport_low);
-                error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE;
+				error = (flag_srb & ARCMSR_SRBREPLY_FLAG_ERROR_MODE1) ? TRUE : FALSE;
 				arcmsr_drain_donequeue(acb, flag_srb, error);
 			}
 		}
@@ -943,7 +949,7 @@ static void arcmsr_iop_reset(struct Adap
 	struct CommandControlBlock *srb;
 	u_int32_t intmask_org;
 	u_int32_t i=0;
-	
+
 	if(acb->srboutstandingcount>0) {
 		/* disable all outbound interrupt */
 		intmask_org = arcmsr_disable_allintr(acb);
@@ -984,7 +990,7 @@ static void arcmsr_build_srb(struct Comm
 	union ccb *pccb = srb->pccb;
 	struct ccb_scsiio *pcsio = &pccb->csio;
 	u_int32_t arccdbsize = 0x30;
-	
+
 	memset(arcmsr_cdb, 0, sizeof(struct ARCMSR_CDB));
 	arcmsr_cdb->Bus = 0;
 	arcmsr_cdb->TargetID = pccb->ccb_h.target_id;
@@ -996,7 +1002,7 @@ static void arcmsr_build_srb(struct Comm
 		struct AdapterControlBlock *acb = srb->acb;
 		bus_dmasync_op_t op;	
 		u_int32_t length, i, cdb_sgcount = 0;
-	
+
 		if((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
 			op = BUS_DMASYNC_PREREAD;
 		} else {
@@ -1018,11 +1024,11 @@ static void arcmsr_build_srb(struct Comm
 				arccdbsize += sizeof(struct SG32ENTRY);
 			} else {
 				u_int32_t sg64s_size = 0, tmplength = length;
-	
+
 				while(1) {
 					u_int64_t span4G, length0;
 					struct SG64ENTRY *pdma_sg = (struct SG64ENTRY *)psge;
-	
+
 					span4G = (u_int64_t)address_lo + tmplength;
 					pdma_sg->addresshigh = address_hi;
 					pdma_sg->address = address_lo;
@@ -1055,8 +1061,8 @@ static void arcmsr_build_srb(struct Comm
 	} else {
 		arcmsr_cdb->DataLength = 0;
 	}
-    srb->arc_cdb_size = arccdbsize;
-    arcmsr_cdb->msgPages = (arccdbsize/256) + ((arccdbsize % 256) ? 1 : 0);
+	srb->arc_cdb_size = arccdbsize;
+	arcmsr_cdb->msgPages = (arccdbsize/256) + ((arccdbsize % 256) ? 1 : 0);
 }
 /*
 **************************************************************************
@@ -1066,7 +1072,7 @@ static void arcmsr_post_srb(struct Adapt
 {
 	u_int32_t cdb_phyaddr_low = (u_int32_t) srb->cdb_phyaddr_low;
 	struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&srb->arcmsr_cdb;
-	
+
 	bus_dmamap_sync(acb->srb_dmat, acb->srb_dmamap, (srb->srb_flags & SRB_FLAG_WRITE) ? BUS_DMASYNC_POSTWRITE:BUS_DMASYNC_POSTREAD);
 	atomic_add_int(&acb->srboutstandingcount, 1);
 	srb->srb_state = ARCMSR_SRB_START;
@@ -1083,7 +1089,7 @@ static void arcmsr_post_srb(struct Adapt
 	case ACB_ADAPTER_TYPE_B: {
 			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			int ending_index, index;
-	
+
 			index = phbbmu->postq_index;
 			ending_index = ((index+1) % ARCMSR_MAX_HBB_POSTQUEUE);
 			phbbmu->post_qbuffer[ending_index] = 0;
@@ -1095,26 +1101,26 @@ static void arcmsr_post_srb(struct Adapt
 			index++;
 			index %= ARCMSR_MAX_HBB_POSTQUEUE;     /*if last index number set it to 0 */
 			phbbmu->postq_index = index;
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_DRV2IOP_CDB_POSTED);
+			WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_CDB_POSTED);
 		}
 		break;
-    case ACB_ADAPTER_TYPE_C: {
-            u_int32_t ccb_post_stamp, arc_cdb_size, cdb_phyaddr_hi32;
+	case ACB_ADAPTER_TYPE_C: {
+			u_int32_t ccb_post_stamp, arc_cdb_size, cdb_phyaddr_hi32;
 
-            arc_cdb_size = (srb->arc_cdb_size > 0x300) ? 0x300 : srb->arc_cdb_size;
-            ccb_post_stamp = (cdb_phyaddr_low | ((arc_cdb_size-1) >> 6) | 1);
+			arc_cdb_size = (srb->arc_cdb_size > 0x300) ? 0x300 : srb->arc_cdb_size;
+			ccb_post_stamp = (cdb_phyaddr_low | ((arc_cdb_size-1) >> 6) | 1);
 			cdb_phyaddr_hi32 = acb->srb_phyaddr.B.phyadd_high;
-            if(cdb_phyaddr_hi32)
-            {
-			    CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_high, cdb_phyaddr_hi32);
-			    CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_low, ccb_post_stamp);
-            }
-            else
-            {
-			    CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_low, ccb_post_stamp);
-            }
-        }
-        break;
+			if(cdb_phyaddr_hi32)
+			{
+				CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_high, cdb_phyaddr_hi32);
+				CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_low, ccb_post_stamp);
+			}
+			else
+			{
+				CHIP_REG_WRITE32(HBC_MessageUnit,0,inbound_queueport_low, ccb_post_stamp);
+			}
+		}
+		break;
 	case ACB_ADAPTER_TYPE_D: {
 			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
 			u_int16_t index_stripped;
@@ -1152,29 +1158,29 @@ static void arcmsr_post_srb(struct Adapt
 static struct QBUFFER *arcmsr_get_iop_rqbuffer( struct AdapterControlBlock *acb)
 {
 	struct QBUFFER *qbuffer=NULL;
-	
+
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbamu->message_rbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
 			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_rbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
 			struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbcmu->message_rbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_D: {
 			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_rbuffer;
 		}
 		break;
@@ -1188,29 +1194,29 @@ static struct QBUFFER *arcmsr_get_iop_rq
 static struct QBUFFER *arcmsr_get_iop_wqbuffer( struct AdapterControlBlock *acb)
 {
 	struct QBUFFER *qbuffer = NULL;
-	
+
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A: {
 			struct HBA_MessageUnit *phbamu = (struct HBA_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbamu->message_wbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
 			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbbmu->hbb_rwbuffer->message_wbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
 			struct HBC_MessageUnit *phbcmu = (struct HBC_MessageUnit *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbcmu->message_wbuffer;
 		}
 		break;
 	case ACB_ADAPTER_TYPE_D: {
 			struct HBD_MessageUnit0 *phbdmu = (struct HBD_MessageUnit0 *)acb->pmu;
-	
+
 			qbuffer = (struct QBUFFER *)&phbdmu->phbdmu->message_wbuffer;
 		}
 		break;
@@ -1230,8 +1236,9 @@ static void arcmsr_iop_message_read(stru
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			/* let IOP know data has been read */
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_READ_OK);
+			WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_READ_OK);
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
@@ -1262,11 +1269,12 @@ static void arcmsr_iop_message_wrote(str
 		}
 		break;
 	case ACB_ADAPTER_TYPE_B: {
+			struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 			/*
 			** push inbound doorbell tell iop, driver data write ok 
 			** and wait reply on next hwinterrupt for next Qbuffer post
 			*/
-			CHIP_REG_WRITE32(HBB_DOORBELL, 0, drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_WRITE_OK);
+			WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_DRV2IOP_DATA_WRITE_OK);
 		}
 		break;
 	case ACB_ADAPTER_TYPE_C: {
@@ -1295,7 +1303,7 @@ static void arcmsr_stop_hba_bgrb(struct 
 {
 	acb->acb_flags &= ~ACB_F_MSG_START_BGRB;
 	CHIP_REG_WRITE32(HBA_MessageUnit, 
-	0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_STOP_BGRB);
+		0, inbound_msgaddr0, ARCMSR_INBOUND_MESG0_STOP_BGRB);
 	if(!arcmsr_hba_wait_msgint_ready(acb)) {
 		printf("arcmsr%d: wait 'stop adapter background rebulid' timeout \n"
 			, acb->pci_unit);
@@ -1307,9 +1315,9 @@ static void arcmsr_stop_hba_bgrb(struct 
 */
 static void arcmsr_stop_hbb_bgrb(struct AdapterControlBlock *acb)
 {
+	struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 	acb->acb_flags &= ~ACB_F_MSG_START_BGRB;
-	CHIP_REG_WRITE32(HBB_DOORBELL, 
-	0, drv2iop_doorbell, ARCMSR_MESSAGE_STOP_BGRB);
+	WRITE_CHIP_REG32(0, phbbmu->drv2iop_doorbell, ARCMSR_MESSAGE_STOP_BGRB);
 	if(!arcmsr_hbb_wait_msgint_ready(acb)) {
 		printf( "arcmsr%d: wait 'stop adapter background rebulid' timeout \n"
 			, acb->pci_unit);
@@ -1387,7 +1395,7 @@ static void arcmsr_poll(struct cam_sim *
 **************************************************************************
 */
 static u_int32_t arcmsr_Read_iop_rqbuffer_data_D(struct AdapterControlBlock *acb,
-    struct QBUFFER *prbuffer) {
+	struct QBUFFER *prbuffer) {
 
 	u_int8_t *pQbuffer;
 	u_int8_t *buf1 = 0;
@@ -1432,13 +1440,13 @@ static u_int32_t arcmsr_Read_iop_rqbuffe
 **************************************************************************
 */
 static u_int32_t arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *acb,
-    struct QBUFFER *prbuffer) {
+	struct QBUFFER *prbuffer) {
 
 	u_int8_t *pQbuffer;
 	u_int8_t *iop_data;
 	u_int32_t iop_len;
 
-	if(acb->adapter_type == ACB_ADAPTER_TYPE_D) {
+	if(acb->adapter_type & (ACB_ADAPTER_TYPE_C | ACB_ADAPTER_TYPE_D)) {
 		return(arcmsr_Read_iop_rqbuffer_data_D(acb, prbuffer));
 	}
 	iop_data = (u_int8_t *)prbuffer->data;
@@ -1464,12 +1472,12 @@ static void arcmsr_iop2drv_data_wrote_ha
 {
 	struct QBUFFER *prbuffer;
 	int my_empty_len;
-	
+
 	/*check this iop data if overflow my rqbuffer*/
 	ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock);
 	prbuffer = arcmsr_get_iop_rqbuffer(acb);
 	my_empty_len = (acb->rqbuf_lastindex - acb->rqbuf_firstindex - 1) &
-	    (ARCMSR_MAX_QBUFFER-1);
+		(ARCMSR_MAX_QBUFFER-1);
 	if(my_empty_len >= prbuffer->data_len) {
 		if(arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)
 			acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
@@ -1489,7 +1497,7 @@ static void arcmsr_Write_data_2iop_wqbuf
 	u_int8_t *buf1 = 0;
 	u_int32_t *iop_data, *buf2 = 0;
 	u_int32_t allxfer_len = 0, data_len;
-	
+
 	if(acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READ) {
 		buf1 = malloc(128, M_DEVBUF, M_NOWAIT | M_ZERO);
 		buf2 = (u_int32_t *)buf1;
@@ -1532,8 +1540,8 @@ static void arcmsr_Write_data_2iop_wqbuf
 	struct QBUFFER *pwbuffer;
 	u_int8_t *iop_data;
 	int32_t allxfer_len=0;
-	
-	if(acb->adapter_type == ACB_ADAPTER_TYPE_D) {
+
+	if(acb->adapter_type & (ACB_ADAPTER_TYPE_C | ACB_ADAPTER_TYPE_D)) {
 		arcmsr_Write_data_2iop_wqbuffer_D(acb);
 		return;
 	}
@@ -1585,8 +1593,8 @@ static void arcmsr_rescanLun_cb(struct c
 /*
 	if (ccb->ccb_h.status != CAM_REQ_CMP)
 		printf("arcmsr_rescanLun_cb: Rescan Target=%x, lun=%x,"
-		    "failure status=%x\n", ccb->ccb_h.target_id,
-		    ccb->ccb_h.target_lun, ccb->ccb_h.status);
+			"failure status=%x\n", ccb->ccb_h.target_id,
+			ccb->ccb_h.target_lun, ccb->ccb_h.status);
 	else
 		printf("arcmsr_rescanLun_cb: Rescan lun successfully!\n");
 */
@@ -1600,7 +1608,7 @@ static void	arcmsr_rescan_lun(struct Ada
 	union ccb           *ccb;
 
 	if ((ccb = (union ccb *)xpt_alloc_ccb_nowait()) == NULL)
- 		return;
+			return;
 	if (xpt_create_path(&path, NULL, cam_sim_path(acb->psim), target, lun) != CAM_REQ_CMP)
 	{
 		xpt_free_ccb(ccb);
@@ -1618,9 +1626,9 @@ static void	arcmsr_rescan_lun(struct Ada
 
 static void arcmsr_abort_dr_ccbs(struct AdapterControlBlock *acb, int target, int lun)
 {
-   	struct CommandControlBlock *srb;
+	struct CommandControlBlock *srb;
 	u_int32_t intmask_org;
-   	int i;
+	int i;
 
 	/* disable all outbound interrupts */
 	intmask_org = arcmsr_disable_allintr(acb);
@@ -1629,13 +1637,13 @@ static void arcmsr_abort_dr_ccbs(struct 
 		srb = acb->psrb_pool[i];
 		if (srb->srb_state == ARCMSR_SRB_START)
 		{
-           	if((target == srb->pccb->ccb_h.target_id) && (lun == srb->pccb->ccb_h.target_lun))
-            {
-		    	srb->srb_state = ARCMSR_SRB_ABORTED;
+			if((target == srb->pccb->ccb_h.target_id) && (lun == srb->pccb->ccb_h.target_lun))
+			{
+				srb->srb_state = ARCMSR_SRB_ABORTED;
 				srb->pccb->ccb_h.status |= CAM_REQ_ABORTED;
-		    	arcmsr_srb_complete(srb, 1);
+				arcmsr_srb_complete(srb, 1);
 				printf("arcmsr%d: abort scsi id %d lun %d srb=%p \n", acb->pci_unit, target, lun, srb);
-       		}
+			}
 		}
 	}
 	/* enable outbound Post Queue, outbound doorbell Interrupt */
@@ -1648,87 +1656,87 @@ static void arcmsr_abort_dr_ccbs(struct 
 static void arcmsr_dr_handle(struct AdapterControlBlock *acb) {
 	u_int32_t	devicemap;
 	u_int32_t	target, lun;
-    u_int32_t	deviceMapCurrent[4]={0};
-    u_int8_t	*pDevMap;
+	u_int32_t	deviceMapCurrent[4]={0};
+	u_int8_t	*pDevMap;
 
 	switch (acb->adapter_type) {
 	case ACB_ADAPTER_TYPE_A:
-			devicemap = offsetof(struct HBA_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
-			for (target = 0; target < 4; target++) 
-			{
-            	deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
-            	devicemap += 4;
-			}
-			break;
+		devicemap = offsetof(struct HBA_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
+		for (target = 0; target < 4; target++) 
+		{
+			deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
+			devicemap += 4;
+		}
+		break;
 
 	case ACB_ADAPTER_TYPE_B:
-			devicemap = offsetof(struct HBB_RWBUFFER, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
-			for (target = 0; target < 4; target++) 
-			{
-            	deviceMapCurrent[target]=bus_space_read_4(acb->btag[1], acb->bhandle[1],  devicemap);
-            	devicemap += 4;
-			}
-			break;
+		devicemap = offsetof(struct HBB_RWBUFFER, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
+		for (target = 0; target < 4; target++) 
+		{
+			deviceMapCurrent[target]=bus_space_read_4(acb->btag[1], acb->bhandle[1],  devicemap);
+			devicemap += 4;
+		}
+		break;
 
 	case ACB_ADAPTER_TYPE_C:
-			devicemap = offsetof(struct HBC_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
-			for (target = 0; target < 4; target++) 
-			{
-            	deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
-            	devicemap += 4;
-			}
-			break;
+		devicemap = offsetof(struct HBC_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
+		for (target = 0; target < 4; target++) 
+		{
+			deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
+			devicemap += 4;
+		}
+		break;
 	case ACB_ADAPTER_TYPE_D:
-			devicemap = offsetof(struct HBD_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
-			for (target = 0; target < 4; target++) 
-			{
-            	deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
-            	devicemap += 4;
-			}
-			break;
-	}
-
-		if(acb->acb_flags & ACB_F_BUS_HANG_ON)
+		devicemap = offsetof(struct HBD_MessageUnit, msgcode_rwbuffer[ARCMSR_FW_DEVMAP_OFFSET]);
+		for (target = 0; target < 4; target++) 
 		{
-			acb->acb_flags &= ~ACB_F_BUS_HANG_ON;
+			deviceMapCurrent[target]=bus_space_read_4(acb->btag[0], acb->bhandle[0],  devicemap);
+			devicemap += 4;
 		}
-		/* 
-		** adapter posted CONFIG message 
-		** copy the new map, note if there are differences with the current map
-		*/
-		pDevMap = (u_int8_t	*)&deviceMapCurrent[0];
-		for (target = 0; target < ARCMSR_MAX_TARGETID - 1; target++) 
+		break;
+	}
+
+	if(acb->acb_flags & ACB_F_BUS_HANG_ON)
+	{
+		acb->acb_flags &= ~ACB_F_BUS_HANG_ON;
+	}
+	/* 
+	** adapter posted CONFIG message 
+	** copy the new map, note if there are differences with the current map
+	*/
+	pDevMap = (u_int8_t	*)&deviceMapCurrent[0];
+	for (target = 0; target < ARCMSR_MAX_TARGETID - 1; target++) 
+	{
+		if (*pDevMap != acb->device_map[target])
 		{
-			if (*pDevMap != acb->device_map[target])
-			{
-                u_int8_t difference, bit_check;
+			u_int8_t difference, bit_check;
 
-                difference = *pDevMap ^ acb->device_map[target];
-                for(lun=0; lun < ARCMSR_MAX_TARGETLUN; lun++)
-                {
-                    bit_check = (1 << lun);						/*check bit from 0....31*/
-                    if(difference & bit_check)
-                    {
-                        if(acb->device_map[target] & bit_check)
-                        {/* unit departed */
-							printf("arcmsr_dr_handle: Target=%x, lun=%x, GONE!!!\n",target,lun);
- 							arcmsr_abort_dr_ccbs(acb, target, lun);
-                        	arcmsr_rescan_lun(acb, target, lun);
-        					acb->devstate[target][lun] = ARECA_RAID_GONE;
-                        }
-                        else
-                        {/* unit arrived */
-							printf("arcmsr_dr_handle: Target=%x, lun=%x, Plug-IN!!!\n",target,lun);
-                        	arcmsr_rescan_lun(acb, target, lun);
-        					acb->devstate[target][lun] = ARECA_RAID_GOOD;
-                        }
-                    }
-                }
-/*				printf("arcmsr_dr_handle: acb->device_map[%x]=0x%x, deviceMapCurrent[%x]=%x\n",target,acb->device_map[target],target,*pDevMap); */
-				acb->device_map[target] = *pDevMap;
+			difference = *pDevMap ^ acb->device_map[target];
+			for(lun=0; lun < ARCMSR_MAX_TARGETLUN; lun++)
+			{
+				bit_check = (1 << lun);		/*check bit from 0....31*/
+				if(difference & bit_check)
+				{
+					if(acb->device_map[target] & bit_check)
+					{/* unit departed */
+						printf("arcmsr_dr_handle: Target=%x, lun=%x, GONE!!!\n",target,lun);
+						arcmsr_abort_dr_ccbs(acb, target, lun);
+						arcmsr_rescan_lun(acb, target, lun);
+						acb->devstate[target][lun] = ARECA_RAID_GONE;
+					}
+					else
+					{/* unit arrived */
+						printf("arcmsr_dr_handle: Target=%x, lun=%x, Plug-IN!!!\n",target,lun);
+						arcmsr_rescan_lun(acb, target, lun);
+						acb->devstate[target][lun] = ARECA_RAID_GOOD;
+					}
+				}
 			}
-			pDevMap++;
+/*			printf("arcmsr_dr_handle: acb->device_map[%x]=0x%x, deviceMapCurrent[%x]=%x\n",target,acb->device_map[target],target,*pDevMap); */
+			acb->device_map[target] = *pDevMap;
 		}
+		pDevMap++;
+	}
 }
 /*
 **************************************************************************
@@ -1748,9 +1756,10 @@ static void arcmsr_hba_message_isr(struc
 */
 static void arcmsr_hbb_message_isr(struct AdapterControlBlock *acb) {
 	u_int32_t outbound_message;
+	struct HBB_MessageUnit *phbbmu = (struct HBB_MessageUnit *)acb->pmu;
 
 	/* clear interrupts */
-	CHIP_REG_WRITE32(HBB_DOORBELL, 0, iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN);
+	WRITE_CHIP_REG32(0, phbbmu->iop2drv_doorbell, ARCMSR_MESSAGE_INT_CLEAR_PATTERN);
 	outbound_message = CHIP_REG_READ32(HBB_RWBUFFER, 1, msgcode_rwbuffer[0]);
 	if (outbound_message == ARCMSR_SIGNATURE_GET_CONFIG)
 		arcmsr_dr_handle( acb );
@@ -1785,8 +1794,8 @@ static void arcmsr_hbd_message_isr(struc
 */
 static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb)
 {
-	u_int32_t outbound_doorbell;
-	
+	u_int32_t doorbell_status;
+
 	/*
 	*******************************************************************
 	**  Maybe here we need to check wrqbuffer_lock is lock or not
@@ -1794,14 +1803,12 @@ static void arcmsr_hba_doorbell_isr(stru
 	**  check if there are any mail need to pack from firmware
 	*******************************************************************
 	*/
-	outbound_doorbell = CHIP_REG_READ32(HBA_MessageUnit, 
-	0, outbound_doorbell);
-	CHIP_REG_WRITE32(HBA_MessageUnit, 
-	0, outbound_doorbell, outbound_doorbell); /* clear doorbell interrupt */
-	if(outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK) {
+	doorbell_status = CHIP_REG_READ32(HBA_MessageUnit, 0, outbound_doorbell);
+	CHIP_REG_WRITE32(HBA_MessageUnit, 0, outbound_doorbell, doorbell_status); /* clear doorbell interrupt */
+	if(doorbell_status & ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK) {
 		arcmsr_iop2drv_data_wrote_handle(acb);
 	}
-	if(outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_READ_OK) {
+	if(doorbell_status & ARCMSR_OUTBOUND_IOP331_DATA_READ_OK) {
 		arcmsr_iop2drv_data_read_handle(acb);
 	}
 }

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512160802.tBG82L06029023>