All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH Resend 1/3] pm8001:add reinitialize SPC parameters before phy start
       [not found] ` <200910302144286878481@usish.com>
@ 2009-10-30 13:51   ` jack_wang
  0 siblings, 0 replies; 7+ messages in thread
From: jack_wang @ 2009-10-30 13:51 UTC (permalink / raw)
  To: jack_wang; +Cc: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0001-add-reinitialize-SPC-parameters-before-phy-start.patch --]
[-- Type: application/octet-stream, Size: 6535 bytes --]

>From e827a9bc8d20f1aac0609c2b61a3d56082a5e127 Mon Sep 17 00:00:00 2001
From: Jack Wang <jack_wang@usish.com>
Date: Fri, 30 Oct 2009 16:42:21 +0800
Subject: [PATCH 1/3] add reinitialize SPC parameters before phy start

We should reinitialize SPC patameters to enhance some disks will cause open
retry timeout and sata head of line blocking timeout issues. We also need set
g3_with_ssc bit properly.
 
Signed-off-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: Lindar Liu <lindar_liu@usish.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c |   68 +++++++++++++++++++++++++++++++++----
 drivers/scsi/pm8001/pm8001_hwi.h |   19 ++++++++++
 drivers/scsi/pm8001/pm8001_sas.c |    1 +
 drivers/scsi/pm8001/pm8001_sas.h |    1 +
 4 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index aa5756f..c4a2ca4 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -375,13 +375,16 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 {
 	u32 offset;
 	u32 value;
-	u32 i;
+	u32 i, j;
+	u32 bit_cnt;
 
 #define SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR 0x00030000
 #define SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR 0x00040000
 #define SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET 0x1074
 #define SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET 0x1074
-#define PHY_SSC_BIT_SHIFT 13
+#define PHY_G3_WITHOUT_SSC_BIT_SHIFT 12
+#define PHY_G3_WITH_SSC_BIT_SHIFT 13
+#define SNW3_PHY_CAPABILITIES_PARITY 31
 
    /*
     * Using shifted destination address 0x3_0000:0x1074 + 0x4000*N (N=0:3)
@@ -393,10 +396,22 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 	for (i = 0; i < 4; i++) {
 		offset = SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET + 0x4000 * i;
 		value = pm8001_cr32(pm8001_ha, 2, offset);
-		if (SSCbit)
-			value = value | (0x00000001 << PHY_SSC_BIT_SHIFT);
+		if (SSCbit) {
+			value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
+		} else {
+			value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
+		}
+		bit_cnt = 0;
+		for (j = 0; j < 31; j++)
+			if ((value >> j) & 0x00000001)
+				bit_cnt++;
+		if (bit_cnt % 2)
+			value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
 		else
-			value = value & (~(0x00000001<<PHY_SSC_BIT_SHIFT));
+			value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
+
 		pm8001_cw32(pm8001_ha, 2, offset, value);
 	}
 
@@ -408,10 +423,22 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 	for (i = 4; i < 8; i++) {
 		offset = SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET + 0x4000 * (i-4);
 		value = pm8001_cr32(pm8001_ha, 2, offset);
-		if (SSCbit)
-			value = value | (0x00000001 << PHY_SSC_BIT_SHIFT);
+		if (SSCbit) {
+			value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
+		} else {
+			value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
+		}
+		bit_cnt = 0;
+		for (j = 0; j < 31; j++)
+			if ((value >> j) & 0x00000001)
+				bit_cnt++;
+		if (bit_cnt % 2)
+			value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
 		else
-			value = value & (~(0x00000001<<PHY_SSC_BIT_SHIFT));
+			value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
+
 		pm8001_cw32(pm8001_ha, 2, offset, value);
 	}
 
@@ -4338,6 +4365,30 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	payload.nds = cpu_to_le32(state);
 	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
 	return 0;
+}
+
+static int
+pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha)
+{
+	struct sas_re_initialization_req payload;
+	struct inbound_queue_table *circularQ;
+	struct pm8001_ccb_info *ccb;
+	int rc;
+	u32 tag;
+	u32 opc = OPC_INB_SAS_RE_INITIALIZE;
+	memset(&payload, 0, sizeof(payload));
+	rc = pm8001_tag_alloc(pm8001_ha, &tag);
+	if (rc)
+		return -1;
+	ccb = &pm8001_ha->ccb_info[tag];
+	ccb->ccb_tag = tag;
+	circularQ = &pm8001_ha->inbnd_q_tbl[0];
+	payload.tag = cpu_to_le32(tag);
+	payload.SSAHOLT = cpu_to_le32(0xd << 25);
+	payload.sata_hol_tmo = cpu_to_le32(80);
+	payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff);
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
 
 }
 
@@ -4367,5 +4418,6 @@ const struct pm8001_dispatch pm8001_8001_dispatch = {
 	.set_nvmd_req		= pm8001_chip_set_nvmd_req,
 	.fw_flash_update_req	= pm8001_chip_fw_flash_update_req,
 	.set_dev_state_req	= pm8001_chip_set_dev_state_req,
+	.sas_re_init_req	= pm8001_chip_sas_re_initialization,
 };
 
diff --git a/drivers/scsi/pm8001/pm8001_hwi.h b/drivers/scsi/pm8001/pm8001_hwi.h
index 3690a2b..eebeca8 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.h
+++ b/drivers/scsi/pm8001/pm8001_hwi.h
@@ -490,6 +490,25 @@ struct set_dev_state_req {
 	u32	reserved[12];
 } __attribute__((packed, aligned(4)));
 
+/*
+ * brief the data structure of sas_re_initialization
+ */
+struct sas_re_initialization_req {
+
+	__le32	tag;
+	__le32	SSAHOLT;/* bit29-set max port;
+			** bit28-set open reject cmd retries.
+			** bit27-set open reject data retries.
+			** bit26-set open reject option, remap:1 or not:0.
+			** bit25-set sata head of line time out.
+			*/
+	__le32 reserved_maxPorts;
+	__le32 open_reject_cmdretries_data_retries;/* cmd retries: 31-bit16;
+						    * data retries: bit15-bit0.
+						    */
+	__le32	sata_hol_tmo;
+	u32	reserved1[10];
+} __attribute__((packed, aligned(4)));
 
 /*
  * brief the data structure of SATA Start Command
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 7bf30fa..1e840fd 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -240,6 +240,7 @@ void pm8001_scan_start(struct Scsi_Host *shost)
 	struct pm8001_hba_info *pm8001_ha;
 	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
 	pm8001_ha = sha->lldd_ha;
+	PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
 	for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
 		PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
 }
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 14c676b..ed6dbd1 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -153,6 +153,7 @@ struct pm8001_dispatch {
 		u32 state);
 	int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
 		u32 state);
+	int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
 };
 
 struct pm8001_chip_info {
-- 
1.6.4.msysgit.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH Resend 2/3] pm8001:enhance IOMB process modules
       [not found] ` <200910302144471408205@usish.com>
@ 2009-10-30 13:53   ` jack_wang
  2009-11-04 17:32     ` James Bottomley
                       ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: jack_wang @ 2009-10-30 13:53 UTC (permalink / raw)
  To: jack_wang; +Cc: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0002-enhance-IOMB-process-modules.patch --]
[-- Type: application/octet-stream, Size: 27644 bytes --]

>From cd774d67ae6608c0670022ed355c0afa6e79841d Mon Sep 17 00:00:00 2001
From: Jack Wang <jack_wang@usish.com>
Date: Fri, 30 Oct 2009 17:20:42 +0800
Subject: [PATCH 2/3] enhance IOMB process modules

We set interupt cascading count of outbound queue to get better performance,
correct some unnecessary return values and some noisy print messages.

Signed-off-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: Lindar Liu <lindar_liu@usish.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c |  242 ++++++++++++++++++++++----------------
 drivers/scsi/pm8001/pm8001_sas.h |    2 +-
 2 files changed, 139 insertions(+), 105 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index c4a2ca4..14e8709 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -231,7 +231,7 @@ init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 		pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr	=
 			pm8001_ha->memoryMap.region[PI].phys_addr_lo;
 		pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay	=
-			0 | (0 << 16) | (0 << 24);
+			0 | (10 << 16) | (0 << 24);
 		pm8001_ha->outbnd_q_tbl[i].pi_virt		=
 			pm8001_ha->memoryMap.region[PI].virt_ptr;
 		offsetob = i * 0x24;
@@ -341,7 +341,7 @@ update_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha, int number)
  * @pm8001_ha : our hba card infomation
  * @shiftValue : shifting value in memory bar.
  */
-static u32 bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue)
+static int bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue)
 {
 	u32 regVal;
 	u32 max_wait_count;
@@ -1217,7 +1217,7 @@ pm8001_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha)
  * @messageSize: the message size of this transfer, normally it is 64 bytes
  * @messagePtr: the pointer to message.
  */
-static u32 mpi_msg_free_get(struct inbound_queue_table *circularQ,
+static int mpi_msg_free_get(struct inbound_queue_table *circularQ,
 			    u16 messageSize, void **messagePtr)
 {
 	u32 offset, consumer_index;
@@ -1257,7 +1257,7 @@ static u32 mpi_msg_free_get(struct inbound_queue_table *circularQ,
  * @opCode: the operation code represents commands which LLDD and fw recognized.
  * @payload: the command payload of each operation command.
  */
-static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
+static int mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 			 struct inbound_queue_table *circularQ,
 			 u32 opCode, void *payload)
 {
@@ -1270,7 +1270,7 @@ static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 			pm8001_printk("No free mpi buffer \n"));
 		return -1;
 	}
-
+	BUG_ON(!payload);
 	/*Copy to the payload*/
 	memcpy(pMessage, payload, (64 - sizeof(struct mpi_msg_hdr)));
 
@@ -1289,10 +1289,30 @@ static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 	return 0;
 }
 
-static u32 mpi_msg_free_set(struct pm8001_hba_info *pm8001_ha,
+static u32 mpi_msg_free_set(struct pm8001_hba_info *pm8001_ha, void *pMsg,
 			    struct outbound_queue_table *circularQ, u8 bc)
 {
 	u32 producer_index;
+	struct mpi_msg_hdr *msgHeader;
+	struct mpi_msg_hdr *pOutBoundMsgHeader;
+
+	msgHeader = (struct mpi_msg_hdr *)(pMsg - sizeof(struct mpi_msg_hdr));
+	pOutBoundMsgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt +
+				circularQ->consumer_idx * 64);
+	if (pOutBoundMsgHeader != msgHeader) {
+		PM8001_FAIL_DBG(pm8001_ha,
+			pm8001_printk("consumer_idx = %d msgHeader = %p\n",
+			circularQ->consumer_idx, msgHeader));
+
+		/* Update the producer index from SPC */
+		producer_index = pm8001_read_32(circularQ->pi_virt);
+		circularQ->producer_index = cpu_to_le32(producer_index);
+		PM8001_FAIL_DBG(pm8001_ha,
+			pm8001_printk("consumer_idx = %d producer_index = %d"
+			"msgHeader = %p\n", circularQ->consumer_idx,
+			circularQ->producer_index, msgHeader));
+		return 0;
+	}
 	/* free the circular queue buffer elements associated with the message*/
 	circularQ->consumer_idx = (circularQ->consumer_idx + bc) % 256;
 	/* update the CI of outbound queue */
@@ -1324,8 +1344,6 @@ static u32 mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
 	do {
 		/* If there are not-yet-delivered messages ... */
 		if (circularQ->producer_index != circularQ->consumer_idx) {
-			PM8001_IO_DBG(pm8001_ha,
-				pm8001_printk("process an IOMB\n"));
 			/*Get the pointer to the circular queue buffer element*/
 			msgHeader = (struct mpi_msg_hdr *)
 				(circularQ->base_virt +
@@ -1342,34 +1360,43 @@ static u32 mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
 					*pBC = (u8)((msgHeader_tmp >> 24) &
 						0x1f);
 					PM8001_IO_DBG(pm8001_ha,
-						pm8001_printk("mpi_msg_consume"
-						": CI=%d PI=%d msgHeader=%x\n",
+						pm8001_printk(": CI=%d PI=%d "
+						"msgHeader=%x\n",
 						circularQ->consumer_idx,
 						circularQ->producer_index,
 						msgHeader_tmp));
 					return MPI_IO_STATUS_SUCCESS;
 				} else {
-					u32 producer_index;
-					void *pi_virt = circularQ->pi_virt;
-					/* free the circular queue buffer
-					elements associated with the message*/
 					circularQ->consumer_idx =
 						(circularQ->consumer_idx +
-						((msgHeader_tmp >> 24) & 0x1f))
-						% 256;
+						((msgHeader_tmp >> 24) & 0x1f))
+						% 256;
+					msgHeader_tmp = 0;
+					pm8001_write_32(msgHeader, 0, 0);
 					/* update the CI of outbound queue */
 					pm8001_cw32(pm8001_ha,
 						circularQ->ci_pci_bar,
 						circularQ->ci_offset,
 						circularQ->consumer_idx);
-					/* Update the producer index from SPC */
-					producer_index =
-						pm8001_read_32(pi_virt);
-					circularQ->producer_index =
-						cpu_to_le32(producer_index);
+
 				}
-			} else
+			} else {
+				circularQ->consumer_idx =
+					(circularQ->consumer_idx +
+					((msgHeader_tmp >> 24) & 0x1f)) % 256;
+				msgHeader_tmp = 0;
+				pm8001_write_32(msgHeader, 0, 0);
+				/* update the CI of outbound queue */
+				pm8001_cw32(pm8001_ha, circularQ->ci_pci_bar,
+					circularQ->ci_offset,
+					circularQ->consumer_idx);
 				return MPI_IO_STATUS_FAIL;
+			}
+		} else {
+			u32 producer_index;
+			void *pi_virt = circularQ->pi_virt;
+			/* Update the producer index from SPC */
+			producer_index = pm8001_read_32(pi_virt);
+			circularQ->producer_index = cpu_to_le32(producer_index);
 		}
 	} while (circularQ->producer_index != circularQ->consumer_idx);
 	/* while we don't have any more not-yet-delivered message */
@@ -1441,7 +1468,7 @@ static int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha, void *data,
  * So we will tell the caller who maybe waiting the result to tell upper layer
  * that the task has been finished.
  */
-static int
+static void
 mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
@@ -1461,14 +1488,13 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 	pm8001_dev = ccb->device;
 	param = le32_to_cpu(psspPayload->param);
 
-	PM8001_IO_DBG(pm8001_ha, pm8001_printk("OPC_OUB_SSP_COMP\n"));
 	t = ccb->task;
 
-	if (status)
+	if (status && status != IO_UNDERFLOW)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sas IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	switch (status) {
 	case IO_SUCCESS:
@@ -1581,6 +1607,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_XFER_ERROR_ACK_NAK_TIMEOUT:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1675,11 +1702,10 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
+static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
 	unsigned long flags;
@@ -1700,7 +1726,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sas IO status 0x%x\n", event));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk("port_id = %x,device_id = %x\n",
@@ -1787,6 +1813,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_XFER_ERROR_ACK_NAK_TIMEOUT:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1840,7 +1867,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 	case IO_XFER_CMD_FRAME_ISSUED:
 		PM8001_IO_DBG(pm8001_ha,
 			pm8001_printk("  IO_XFER_CMD_FRAME_ISSUED\n"));
-		return 0;
+		return;
 	default:
 		PM8001_IO_DBG(pm8001_ha,
 			pm8001_printk("Unknown status 0x%x\n", event));
@@ -1866,11 +1893,10 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int
+static void
 mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
 	struct sas_task *t;
@@ -1898,7 +1924,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sata IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 
 	switch (status) {
 	case IO_SUCCESS:
@@ -2015,7 +2041,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*in order to force CPU ordering*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_BAD_DESTINATION:
@@ -2033,7 +2059,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED:
@@ -2059,7 +2085,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/* ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_WRONG_DESTINATION:
@@ -2124,7 +2150,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_DS_IN_RECOVERY:
@@ -2146,7 +2172,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY:
@@ -2180,11 +2206,10 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		mb();/* ditto */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
+static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
 	unsigned long flags;
@@ -2205,7 +2230,7 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sata IO status 0x%x\n", event));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk("port_id = %x,device_id = %x\n",
@@ -2268,7 +2293,7 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_BAD_DESTINATION:
@@ -2382,11 +2407,10 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int
+static void
 mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
 	u32 param;
@@ -2412,7 +2436,7 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("smp IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 
 	switch (status) {
 	case IO_SUCCESS:
@@ -2585,7 +2609,6 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 static void
@@ -2682,8 +2705,8 @@ mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_printk("Get NVMD success, IR=0, dataLen=%d\n",
 			(dlen_status & NVMD_LEN) >> 24));
 	}
-	memcpy((void *)(fw_control_context->usrAddr),
-		(void *)(pm8001_ha->memoryMap.region[NVMD].virt_ptr),
+	memcpy(fw_control_context->usrAddr,
+		pm8001_ha->memoryMap.region[NVMD].virt_ptr,
 		fw_control_context->len);
 	complete(pm8001_ha->nvmd_completion);
 	ccb->task = NULL;
@@ -3184,28 +3207,28 @@ mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		(struct task_abort_resp *)(piomb + 4);
 	ccb = &pm8001_ha->ccb_info[pPayload->tag];
 	t = ccb->task;
-	ts = &t->task_status;
 
-	if (t == NULL)
-		return -1;
 
 	status = le32_to_cpu(pPayload->status);
 	tag = le32_to_cpu(pPayload->tag);
 	scp = le32_to_cpu(pPayload->scp);
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk(" status = 0x%x\n", status));
+	if (t == NULL)
+		return -1;
+	ts = &t->task_status;
 	if (status != 0)
 		PM8001_FAIL_DBG(pm8001_ha,
-			pm8001_printk("task abort failed tag = 0x%x,"
-			" scp= 0x%x\n", tag, scp));
+			pm8001_printk("task abort failed status 0x%x ,"
+			"tag = 0x%x, scp= 0x%x\n", status, tag, scp));
 	switch (status) {
 	case IO_SUCCESS:
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n"));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAM_GOOD;
 		break;
 	case IO_NOT_VALID:
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_NOT_VALID\n"));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("IO_NOT_VALID\n"));
 		ts->resp = TMF_RESP_FUNC_FAILED;
 		break;
 	}
@@ -3443,7 +3466,7 @@ static void process_one_iomb(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 pHeader = (u32)*(u32 *)piomb;
 	u8 opc = (u8)((le32_to_cpu(pHeader)) & 0xFFF);
 
-	PM8001_MSG_DBG(pm8001_ha, pm8001_printk("process_one_iomb:\n"));
+	PM8001_MSG_DBG(pm8001_ha, pm8001_printk("process_one_iomb:"));
 
 	switch (opc) {
 	case OPC_OUB_ECHO:
@@ -3609,17 +3632,16 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
 	struct outbound_queue_table *circularQ;
 	void *pMsg1 = NULL;
 	u8 bc = 0;
-	u32 ret = MPI_IO_STATUS_FAIL, processedMsgCount = 0;
+	u32 ret = MPI_IO_STATUS_FAIL;
 
 	circularQ = &pm8001_ha->outbnd_q_tbl[0];
 	do {
 		ret = mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc);
 		if (MPI_IO_STATUS_SUCCESS == ret) {
 			/* process the outbound message */
-			process_one_iomb(pm8001_ha, (void *)((u8 *)pMsg1 - 4));
+			process_one_iomb(pm8001_ha, (void *)(pMsg1 - 4));
 			/* free the message from the outbound circular buffer */
-			mpi_msg_free_set(pm8001_ha, circularQ, bc);
-			processedMsgCount++;
+			mpi_msg_free_set(pm8001_ha, pMsg1, circularQ, bc);
 		}
 		if (MPI_IO_STATUS_BUSY == ret) {
 			u32 producer_idx;
@@ -3631,8 +3653,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
 				/* OQ is empty */
 				break;
 		}
-	} while (100 > processedMsgCount);/*end message processing if hit the
-	count*/
+	} while (1);
 	return ret;
 }
 
@@ -3743,6 +3764,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
 	struct pm8001_device *pm8001_dev = dev->lldd_dev;
 	struct ssp_ini_io_start_req ssp_cmd;
 	u32 tag = ccb->ccb_tag;
+	int ret;
 	__le64 phys_addr;
 	struct inbound_queue_table *circularQ;
 	u32 opc = OPC_INB_SSPINIIOSTART;
@@ -3780,8 +3802,8 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
 		ssp_cmd.len = cpu_to_le32(task->total_xfer_len);
 		ssp_cmd.esgl = 0;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd);
+	return ret;
 }
 
 static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
@@ -3791,6 +3813,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 	struct domain_device *dev = task->dev;
 	struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
 	u32 tag = ccb->ccb_tag;
+	int ret;
 	struct sata_start_req sata_cmd;
 	u32 hdr_tag, ncg_tag = 0;
 	__le64 phys_addr;
@@ -3849,8 +3872,8 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 		sata_cmd.len = cpu_to_le32(task->total_xfer_len);
 		sata_cmd.esgl = 0;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd);
+	return ret;
 }
 
 /**
@@ -3864,6 +3887,7 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
 {
 	struct phy_start_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 tag = 0x01;
 	u32 opcode = OPC_INB_PHYSTART;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
@@ -3883,8 +3907,8 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
 	memcpy(payload.sas_identify.sas_addr,
 		pm8001_ha->sas_addr, SAS_ADDR_SIZE);
 	payload.sas_identify.phy_id = phy_id;
-	mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
+	return ret;
 }
 
 /**
@@ -3898,14 +3922,15 @@ static int pm8001_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct phy_stop_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 tag = 0x01;
 	u32 opcode = OPC_INB_PHYSTOP;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	memset(&payload, 0, sizeof(payload));
 	payload.tag = cpu_to_le32(tag);
 	payload.phy_id = cpu_to_le32(phy_id);
-	mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
+	return ret;
 }
 
 /**
@@ -3919,7 +3944,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
 	u32 stp_sspsmp_sata = 0x4;
 	struct inbound_queue_table *circularQ;
 	u32 linkrate, phy_id;
-	u32 rc, tag = 0xdeadbeef;
+	int rc, tag = 0xdeadbeef;
 	struct pm8001_ccb_info *ccb;
 	u8 retryFlag = 0x1;
 	u16 firstBurstSize = 0;
@@ -3963,8 +3988,8 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
 		cpu_to_le32(ITNT | (firstBurstSize * 0x10000));
 	memcpy(&payload.sas_addr_hi, pm8001_dev->sas_device->sas_addr,
 		SAS_ADDR_SIZE);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
 }
 
 /**
@@ -3975,16 +4000,17 @@ static int pm8001_chip_dereg_dev_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct dereg_dev_req payload;
 	u32 opc = OPC_INB_DEREG_DEV_HANDLE;
+	int ret;
 	struct inbound_queue_table *circularQ;
 
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
-	memset((u8 *)&payload, 0, sizeof(payload));
+	memset(&payload, 0, sizeof(payload));
 	payload.tag = 1;
 	payload.device_id = cpu_to_le32(device_id);
 	PM8001_MSG_DBG(pm8001_ha,
 		pm8001_printk("unregister device device_id = %d\n", device_id));
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 /**
@@ -3999,14 +4025,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct local_phy_ctl_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
 	memset((u8 *)&payload, 0, sizeof(payload));
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	payload.tag = 1;
 	payload.phyop_phyid =
 		cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F));
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 static u32 pm8001_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
@@ -4028,12 +4055,16 @@ static u32 pm8001_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
  * @irq: irq number.
  * @stat: stat.
  */
-static void
+static irqreturn_t
 pm8001_chip_isr(struct pm8001_hba_info *pm8001_ha)
 {
+	unsigned long flags;
+	spin_lock_irqsave(&pm8001_ha->lock, flags);
 	pm8001_chip_interrupt_disable(pm8001_ha);
 	process_oq(pm8001_ha);
 	pm8001_chip_interrupt_enable(pm8001_ha);
+	spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+	return IRQ_HANDLED;
 }
 
 static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
@@ -4041,7 +4072,7 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
 {
 	struct task_abort_req task_abort;
 	struct inbound_queue_table *circularQ;
-
+	int ret;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	memset(&task_abort, 0, sizeof(task_abort));
 	if (ABORT_SINGLE == (flag & ABORT_MASK)) {
@@ -4054,8 +4085,8 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
 		task_abort.device_id = cpu_to_le32(dev_id);
 		task_abort.tag = cpu_to_le32(cmd_tag);
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort);
+	return ret;
 }
 
 /**
@@ -4068,7 +4099,8 @@ static int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc, device_id;
 	int rc = TMF_RESP_FUNC_FAILED;
-	PM8001_IO_DBG(pm8001_ha, pm8001_printk("Abort tag[%x]", task_tag));
+	PM8001_EH_DBG(pm8001_ha, pm8001_printk("cmd_tag = %x, abort task tag"
+		" = %x", cmd_tag, task_tag));
 	if (pm8001_dev->dev_type == SAS_END_DEV)
 		opc = OPC_INB_SSP_ABORT;
 	else if (pm8001_dev->dev_type == SATA_DEV)
@@ -4079,7 +4111,7 @@ static int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
 	rc = send_task_abort(pm8001_ha, opc, device_id, flag,
 		task_tag, cmd_tag);
 	if (rc != TMF_RESP_FUNC_COMPLETE)
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("rc= %d\n", rc));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("rc= %d\n", rc));
 	return rc;
 }
 
@@ -4098,17 +4130,17 @@ static int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha,
 	u32 opc = OPC_INB_SSPINITMSTART;
 	struct inbound_queue_table *circularQ;
 	struct ssp_ini_tm_start_req sspTMCmd;
+	int ret;
 
 	memset(&sspTMCmd, 0, sizeof(sspTMCmd));
 	sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id);
 	sspTMCmd.relate_tag = cpu_to_le32(tmf->tag_of_task_to_be_managed);
 	sspTMCmd.tmf = cpu_to_le32(tmf->tmf);
-	sspTMCmd.ds_ads_m = cpu_to_le32(1 << 2);
 	memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8);
 	sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag);
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd);
+	return ret;
 }
 
 static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
@@ -4116,7 +4148,7 @@ static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc = OPC_INB_GET_NVMD_DATA;
 	u32 nvmd_type;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	struct inbound_queue_table *circularQ;
@@ -4183,8 +4215,8 @@ static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 	default:
 		break;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
+	return rc;
 }
 
 static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
@@ -4192,7 +4224,7 @@ static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc = OPC_INB_SET_NVMD_DATA;
 	u32 nvmd_type;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	struct inbound_queue_table *circularQ;
@@ -4259,8 +4291,8 @@ static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 	default:
 		break;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
+	return rc;
 }
 
 /**
@@ -4275,6 +4307,7 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha,
 	struct fw_flash_Update_req payload;
 	struct fw_flash_updata_info *info;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 opc = OPC_INB_FW_FLASH_UPDATE;
 
 	memset((u8 *)&payload, 0, sizeof(struct fw_flash_Update_req));
@@ -4287,8 +4320,8 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha,
 	payload.len = info->sgl.im_len.len ;
 	payload.sgl_addr_lo = lower_32_bits(info->sgl.addr);
 	payload.sgl_addr_hi = upper_32_bits(info->sgl.addr);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 static int
@@ -4298,7 +4331,7 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 	struct fw_flash_updata_info flash_update_info;
 	struct fw_control_info *fw_control;
 	struct fw_control_ex *fw_control_context;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	void *buffer = NULL;
@@ -4321,8 +4354,8 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 				return -ENOMEM;
 		}
 	}
-	memset((void *)buffer, 0, fw_control->len);
-	memcpy((void *)buffer, fw_control->buffer, fw_control->len);
+	memset(buffer, 0, fw_control->len);
+	memcpy(buffer, fw_control->buffer, fw_control->len);
 	flash_update_info.sgl.addr = cpu_to_le64(phys_addr);
 	flash_update_info.sgl.im_len.len = cpu_to_le32(fw_control->len);
 	flash_update_info.sgl.im_len.e = 0;
@@ -4338,8 +4371,8 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 	ccb = &pm8001_ha->ccb_info[tag];
 	ccb->fw_control_context = fw_control_context;
 	ccb->ccb_tag = tag;
-	pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag);
-	return 0;
+	rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
+		tag);
+	return rc;
 }
 
 static int
@@ -4349,10 +4382,10 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	struct set_dev_state_req payload;
 	struct inbound_queue_table *circularQ;
 	struct pm8001_ccb_info *ccb;
-	u32 rc;
+	int rc;
 	u32 tag;
 	u32 opc = OPC_INB_SET_DEVICE_STATE;
-	memset((u8 *)&payload, 0, sizeof(payload));
+	memset(&payload, 0, sizeof(payload));
 	rc = pm8001_tag_alloc(pm8001_ha, &tag);
 	if (rc)
 		return -1;
@@ -4363,8 +4396,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	payload.tag = cpu_to_le32(tag);
 	payload.device_id = cpu_to_le32(pm8001_dev->device_id);
 	payload.nds = cpu_to_le32(state);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
+
 }
 
 static int
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index ed6dbd1..30f2ede 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -119,7 +119,7 @@ struct pm8001_dispatch {
 	void (*chip_rst)(struct pm8001_hba_info *pm8001_ha);
 	int (*chip_ioremap)(struct pm8001_hba_info *pm8001_ha);
 	void (*chip_iounmap)(struct pm8001_hba_info *pm8001_ha);
-	void (*isr)(struct pm8001_hba_info *pm8001_ha);
+	irqreturn_t (*isr)(struct pm8001_hba_info *pm8001_ha);
 	u32 (*is_our_interupt)(struct pm8001_hba_info *pm8001_ha);
 	int (*isr_process_oq)(struct pm8001_hba_info *pm8001_ha);
 	void (*interrupt_enable)(struct pm8001_hba_info *pm8001_ha);
-- 
1.6.4.msysgit.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH Resend 2/3] pm8001:enhance IOMB process modules
  2009-10-30 13:53   ` [PATCH Resend 2/3] pm8001:enhance IOMB process modules jack_wang
@ 2009-11-04 17:32     ` James Bottomley
  2009-11-05  1:03       ` jack wang
  2009-11-05 14:32     ` [PATCH v2 1/3] pm8001:add reinitialize SPC parameters before phy start jack_wang
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: James Bottomley @ 2009-11-04 17:32 UTC (permalink / raw)
  To: jack_wang; +Cc: linux-scsi

Just for future reference, git doesn't like patches in this format.
What it's expecting is the change log in the actual email and the patch
as an attachment.

On Fri, 2009-10-30 at 21:53 +0800, jack_wang wrote:
> @@ -1342,34 +1360,43 @@ static u32 mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
>                                         *pBC = (u8)((msgHeader_tmp >> 24) &
>                                                 0x1f);
>                                         PM8001_IO_DBG(pm8001_ha,
> -                                               pm8001_printk("mpi_msg_consume"
> -                                               ": CI=%d PI=%d msgHeader=%x\n",
> +                                               pm8001_printk(": CI=%d PI=%d "
> +                                               "msgHeader=%x\n",
>                                                 circularQ->consumer_idx,
>                                                 circularQ->producer_index,
>                                                 msgHeader_tmp));
>                                         return MPI_IO_STATUS_SUCCESS;
>                                 } else {
> -                                       u32 producer_index;
> -                                       void *pi_virt = circularQ->pi_virt;
> -                                       /* free the circular queue buffer
> -                                       elements associated with the message*/
>                                         circularQ->consumer_idx =
>                                                 (circularQ->consumer_idx +
> -                                               ((msgHeader_tmp >> 24) & 0x1f))
> -                                               % 256;
> +                                               ((msgHeader_tmp >> 24) & 0x1f))
> +                                               % 256;
> +                                       msgHeader_tmp = 0;
> +                                       pm8001_write_32(msgHeader, 0, 0);
>                                         /* update the CI of outbound queue */
>                                         pm8001_cw32(pm8001_ha,
>                                                 circularQ->ci_pci_bar,
>                                                 circularQ->ci_offset,
>                                                 circularQ->consumer_idx);
> -                                       /* Update the producer index from SPC */
> -                                       producer_index =
> -                                               pm8001_read_32(pi_virt);
> -                                       circularQ->producer_index =
> -                                               cpu_to_le32(producer_index);
> +
>                                 }
> -                       } else
> +                       } else {
> +                               circularQ->consumer_idx =
> +                                       (circularQ->consumer_idx +
> +                                       ((msgHeader_tmp >> 24) & 0x1f)) % 256;
> +                               msgHeader_tmp = 0;
> +                               pm8001_write_32(msgHeader, 0, 0);
> +                               /* update the CI of outbound queue */
> +                               pm8001_cw32(pm8001_ha, circularQ->ci_pci_bar,
> +                                       circularQ->ci_offset,
> +                                       circularQ->consumer_idx);
>                                 return MPI_IO_STATUS_FAIL;
> +                       }
> +               } else {
> +                       u32 producer_index;
> +                       void *pi_virt = circularQ->pi_virt;
> +                       /* Update the producer index from SPC */
> +                       producer_index = pm8001_read_32(pi_virt);
> +                       circularQ->producer_index = cpu_to_le32(producer_index);
>                 }
>         } while (circularQ->producer_index != circularQ->consumer_idx);
>         /* while we don't have any more not-yet-delivered message */

This hunk is refusing to apply:

patching file drivers/scsi/pm8001/pm8001_hwi.c
patch: **** malformed patch at line 164:        /* while we don't have
any more not-yet-delivered message */

The problem seems to be that the header promises there will be 43 lines
after patching and there are actually 44 ... did you edit this patch
after generating the diff?

James



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH Resend 2/3] pm8001:enhance IOMB process modules
  2009-11-04 17:32     ` James Bottomley
@ 2009-11-05  1:03       ` jack wang
  0 siblings, 0 replies; 7+ messages in thread
From: jack wang @ 2009-11-05  1:03 UTC (permalink / raw)
  To: 'James Bottomley'; +Cc: 'linux-scsi'

Just for future reference, git doesn't like patches in this format.
What it's expecting is the change log in the actual email and the patch
as an attachment.
[Jack] Sorry James
I will re-diff the patches and send them later today.
 
On Fri, 2009-10-30 at 21:53 +0800, jack_wang wrote:
> @@ -1342,34 +1360,43 @@ static u32 mpi_msg_consume(struct pm8001_hba_info
*pm8001_ha,
>                                         *pBC = (u8)((msgHeader_tmp >> 24)
&
>                                                 0x1f);
>                                         PM8001_IO_DBG(pm8001_ha,
> -
pm8001_printk("mpi_msg_consume"
> -                                               ": CI=%d PI=%d
msgHeader=%x\n",
> +                                               pm8001_printk(": CI=%d
PI=%d "
> +                                               "msgHeader=%x\n",
>                                                 circularQ->consumer_idx,
>                                                 circularQ->producer_index,
>                                                 msgHeader_tmp));
>                                         return MPI_IO_STATUS_SUCCESS;
>                                 } else {
> -                                       u32 producer_index;
> -                                       void *pi_virt =
circularQ->pi_virt;
> -                                       /* free the circular queue buffer
> -                                       elements associated with the
message*/
>                                         circularQ->consumer_idx =
>                                                 (circularQ->consumer_idx +
> -                                               ((msgHeader_tmp >> 24) &
0x1f))
> -                                               % 256;
> +                                               ((msgHeader_tmp >> 24) &
0x1f))
> +                                               % 256;
> +                                       msgHeader_tmp = 0;
> +                                       pm8001_write_32(msgHeader, 0, 0);
>                                         /* update the CI of outbound queue
*/
>                                         pm8001_cw32(pm8001_ha,
>                                                 circularQ->ci_pci_bar,
>                                                 circularQ->ci_offset,
>                                                 circularQ->consumer_idx);
> -                                       /* Update the producer index from
SPC */
> -                                       producer_index =
> -                                               pm8001_read_32(pi_virt);
> -                                       circularQ->producer_index =
> -
cpu_to_le32(producer_index);
> +
>                                 }
> -                       } else
> +                       } else {
> +                               circularQ->consumer_idx =
> +                                       (circularQ->consumer_idx +
> +                                       ((msgHeader_tmp >> 24) & 0x1f)) %
256;
> +                               msgHeader_tmp = 0;
> +                               pm8001_write_32(msgHeader, 0, 0);
> +                               /* update the CI of outbound queue */
> +                               pm8001_cw32(pm8001_ha,
circularQ->ci_pci_bar,
> +                                       circularQ->ci_offset,
> +                                       circularQ->consumer_idx);
>                                 return MPI_IO_STATUS_FAIL;
> +                       }
> +               } else {
> +                       u32 producer_index;
> +                       void *pi_virt = circularQ->pi_virt;
> +                       /* Update the producer index from SPC */
> +                       producer_index = pm8001_read_32(pi_virt);
> +                       circularQ->producer_index =
cpu_to_le32(producer_index);
>                 }
>         } while (circularQ->producer_index != circularQ->consumer_idx);
>         /* while we don't have any more not-yet-delivered message */

This hunk is refusing to apply:

patching file drivers/scsi/pm8001/pm8001_hwi.c
patch: **** malformed patch at line 164:        /* while we don't have
any more not-yet-delivered message */

The problem seems to be that the header promises there will be 43 lines
after patching and there are actually 44 ... did you edit this patch
after generating the diff?

James

[Jack] Yes ,sorry , I modify the patch directly because the checkpatch
error.
I will re-diff it .


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] pm8001:add reinitialize SPC parameters before phy start
  2009-10-30 13:53   ` [PATCH Resend 2/3] pm8001:enhance IOMB process modules jack_wang
  2009-11-04 17:32     ` James Bottomley
@ 2009-11-05 14:32     ` jack_wang
  2009-11-05 14:33     ` [PATCH V2 2/3] pm8001:enhance IOMB process modules jack_wang
  2009-11-05 14:33     ` [PATCH v2 3/3] pm8001:Fixes for tag alloc, error goto and code cleanup jack_wang
  3 siblings, 0 replies; 7+ messages in thread
From: jack_wang @ 2009-11-05 14:32 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, jack wang, lindar_liu, aoqingyun

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]


We should reinitialize SPC patameters to enhance some disks will cause open
retry timeout and sata head of line blocking timeout issues. We also need set
g3_with_ssc bit properly.   patch attached.
changelog:
	v1->v2 re-diff the patch ues git format patch  base latest scsi-misc tree

------------------				 
jack_wang
2009-11-05

[-- Attachment #2: 0001-Add-reinitialize-SPC-parameters-before-phy-start.patch --]
[-- Type: application/octet-stream, Size: 7712 bytes --]

From 7117d6209358919a0172be5cb19676dbaf9ee125 Mon Sep 17 00:00:00 2001
From: Jack Wang <jack_wang@usish.com>
Date: Thu, 5 Nov 2009 21:35:05 +0800
Subject: [PATCH 1/3] Add reinitialize SPC parameters before phy start

Signed-off-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: Lindar Liu <lindar_liu@usish.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c |   76 ++++++++++++++++++++++++++++++++------
 drivers/scsi/pm8001/pm8001_hwi.h |   19 +++++++++
 drivers/scsi/pm8001/pm8001_sas.c |    1 +
 drivers/scsi/pm8001/pm8001_sas.h |    1 +
 4 files changed, 85 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index aa5756f..d18c263 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -57,9 +57,9 @@ static void __devinit read_main_config_table(struct pm8001_hba_info *pm8001_ha)
 	pm8001_ha->main_cfg_tbl.ctrl_cap_flag	= pm8001_mr32(address, 0x14);
 	pm8001_ha->main_cfg_tbl.gst_offset	= pm8001_mr32(address, 0x18);
 	pm8001_ha->main_cfg_tbl.inbound_queue_offset =
-		pm8001_mr32(address, 0x1C);
+		pm8001_mr32(address, MAIN_IBQ_OFFSET);
 	pm8001_ha->main_cfg_tbl.outbound_queue_offset =
-		pm8001_mr32(address, 0x20);
+		pm8001_mr32(address, MAIN_OBQ_OFFSET);
 	pm8001_ha->main_cfg_tbl.hda_mode_flag	=
 		pm8001_mr32(address, MAIN_HDA_FLAGS_OFFSET);
 
@@ -124,7 +124,7 @@ read_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha)
 	int i;
 	void __iomem *address = pm8001_ha->inbnd_q_tbl_addr;
 	for (i = 0; i < inbQ_num; i++) {
-		u32 offset = i * 0x24;
+		u32 offset = i * 0x20;
 		pm8001_ha->inbnd_q_tbl[i].pi_pci_bar =
 		      get_pci_bar_index(pm8001_mr32(address, (offset + 0x14)));
 		pm8001_ha->inbnd_q_tbl[i].pi_offset =
@@ -231,7 +231,7 @@ init_default_table_values(struct pm8001_hba_info *pm8001_ha)
 		pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr	=
 			pm8001_ha->memoryMap.region[PI].phys_addr_lo;
 		pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay	=
-			0 | (0 << 16) | (0 << 24);
+			0 | (10 << 16) | (0 << 24);
 		pm8001_ha->outbnd_q_tbl[i].pi_virt		=
 			pm8001_ha->memoryMap.region[PI].virt_ptr;
 		offsetob = i * 0x24;
@@ -375,13 +375,16 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 {
 	u32 offset;
 	u32 value;
-	u32 i;
+	u32 i, j;
+	u32 bit_cnt;
 
 #define SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR 0x00030000
 #define SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR 0x00040000
 #define SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET 0x1074
 #define SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET 0x1074
-#define PHY_SSC_BIT_SHIFT 13
+#define PHY_G3_WITHOUT_SSC_BIT_SHIFT 12
+#define PHY_G3_WITH_SSC_BIT_SHIFT 13
+#define SNW3_PHY_CAPABILITIES_PARITY 31
 
    /*
     * Using shifted destination address 0x3_0000:0x1074 + 0x4000*N (N=0:3)
@@ -393,10 +396,22 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 	for (i = 0; i < 4; i++) {
 		offset = SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET + 0x4000 * i;
 		value = pm8001_cr32(pm8001_ha, 2, offset);
-		if (SSCbit)
-			value = value | (0x00000001 << PHY_SSC_BIT_SHIFT);
+		if (SSCbit) {
+			value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
+		} else {
+			value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
+		}
+		bit_cnt = 0;
+		for (j = 0; j < 31; j++)
+			if ((value >> j) & 0x00000001)
+				bit_cnt++;
+		if (bit_cnt % 2)
+			value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
 		else
-			value = value & (~(0x00000001<<PHY_SSC_BIT_SHIFT));
+			value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
+
 		pm8001_cw32(pm8001_ha, 2, offset, value);
 	}
 
@@ -408,10 +423,22 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 	for (i = 4; i < 8; i++) {
 		offset = SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET + 0x4000 * (i-4);
 		value = pm8001_cr32(pm8001_ha, 2, offset);
-		if (SSCbit)
-			value = value | (0x00000001 << PHY_SSC_BIT_SHIFT);
+		if (SSCbit) {
+			value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
+		} else {
+			value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
+			value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
+		}
+		bit_cnt = 0;
+		for (j = 0; j < 31; j++)
+			if ((value >> j) & 0x00000001)
+				bit_cnt++;
+		if (bit_cnt % 2)
+			value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
 		else
-			value = value & (~(0x00000001<<PHY_SSC_BIT_SHIFT));
+			value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
+
 		pm8001_cw32(pm8001_ha, 2, offset, value);
 	}
 
@@ -4338,6 +4365,30 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	payload.nds = cpu_to_le32(state);
 	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
 	return 0;
+}
+
+static int
+pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha)
+{
+	struct sas_re_initialization_req payload;
+	struct inbound_queue_table *circularQ;
+	struct pm8001_ccb_info *ccb;
+	int rc;
+	u32 tag;
+	u32 opc = OPC_INB_SAS_RE_INITIALIZE;
+	memset(&payload, 0, sizeof(payload));
+	rc = pm8001_tag_alloc(pm8001_ha, &tag);
+	if (rc)
+		return -1;
+	ccb = &pm8001_ha->ccb_info[tag];
+	ccb->ccb_tag = tag;
+	circularQ = &pm8001_ha->inbnd_q_tbl[0];
+	payload.tag = cpu_to_le32(tag);
+	payload.SSAHOLT = cpu_to_le32(0xd << 25);
+	payload.sata_hol_tmo = cpu_to_le32(80);
+	payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff);
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
 
 }
 
@@ -4367,5 +4418,6 @@ const struct pm8001_dispatch pm8001_8001_dispatch = {
 	.set_nvmd_req		= pm8001_chip_set_nvmd_req,
 	.fw_flash_update_req	= pm8001_chip_fw_flash_update_req,
 	.set_dev_state_req	= pm8001_chip_set_dev_state_req,
+	.sas_re_init_req	= pm8001_chip_sas_re_initialization,
 };
 
diff --git a/drivers/scsi/pm8001/pm8001_hwi.h b/drivers/scsi/pm8001/pm8001_hwi.h
index 3690a2b..96e4daa 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.h
+++ b/drivers/scsi/pm8001/pm8001_hwi.h
@@ -490,6 +490,25 @@ struct set_dev_state_req {
 	u32	reserved[12];
 } __attribute__((packed, aligned(4)));
 
+/*
+ * brief the data structure of sas_re_initialization
+ */
+struct sas_re_initialization_req {
+
+	__le32	tag;
+	__le32	SSAHOLT;/* bit29-set max port;
+			** bit28-set open reject cmd retries.
+			** bit27-set open reject data retries.
+			** bit26-set open reject option, remap:1 or not:0.
+			** bit25-set sata head of line time out.
+			*/
+	__le32 reserved_maxPorts;
+	__le32 open_reject_cmdretries_data_retries;/* cmd retries: 31-bit16;
+						    * data retries: bit15-bit0.
+						    */
+	__le32	sata_hol_tmo;
+	u32	reserved1[10];
+} __attribute__((packed, aligned(4)));
 
 /*
  * brief the data structure of SATA Start Command
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 7bf30fa..1e840fd 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -240,6 +240,7 @@ void pm8001_scan_start(struct Scsi_Host *shost)
 	struct pm8001_hba_info *pm8001_ha;
 	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
 	pm8001_ha = sha->lldd_ha;
+	PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
 	for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
 		PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
 }
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 14c676b..ed6dbd1 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -153,6 +153,7 @@ struct pm8001_dispatch {
 		u32 state);
 	int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
 		u32 state);
+	int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
 };
 
 struct pm8001_chip_info {
-- 
1.6.4.msysgit.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 2/3] pm8001:enhance IOMB process modules
  2009-10-30 13:53   ` [PATCH Resend 2/3] pm8001:enhance IOMB process modules jack_wang
  2009-11-04 17:32     ` James Bottomley
  2009-11-05 14:32     ` [PATCH v2 1/3] pm8001:add reinitialize SPC parameters before phy start jack_wang
@ 2009-11-05 14:33     ` jack_wang
  2009-11-05 14:33     ` [PATCH v2 3/3] pm8001:Fixes for tag alloc, error goto and code cleanup jack_wang
  3 siblings, 0 replies; 7+ messages in thread
From: jack_wang @ 2009-11-05 14:33 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, jack wang, lindar_liu, aoqingyun

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

We set interupt cascading count of outbound queue to get better performance,
correct some unnecessary return values and some noisy print messages.  patch attached.


------------------				 
jack_wang
2009-11-05

[-- Attachment #2: 0002-Enhance-IOMB-process-modules.patch --]
[-- Type: application/octet-stream, Size: 28294 bytes --]

From 7ef714c5b59965f9c2e59d27132d9c7a2250ec01 Mon Sep 17 00:00:00 2001
From: Jack Wang <jack_wang@usish.com>
Date: Thu, 5 Nov 2009 21:46:58 +0800
Subject: [PATCH 2/3] Enhance IOMB process modules

Signed-off-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: Lindar Liu <lindar_liu@usish.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c |  245 ++++++++++++++++++++++----------------
 drivers/scsi/pm8001/pm8001_sas.h |    2 +-
 2 files changed, 141 insertions(+), 106 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index d18c263..a3de306 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -341,7 +341,7 @@ update_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha, int number)
  * @pm8001_ha : our hba card infomation
  * @shiftValue : shifting value in memory bar.
  */
-static u32 bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue)
+static int bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue)
 {
 	u32 regVal;
 	u32 max_wait_count;
@@ -1217,7 +1217,7 @@ pm8001_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha)
  * @messageSize: the message size of this transfer, normally it is 64 bytes
  * @messagePtr: the pointer to message.
  */
-static u32 mpi_msg_free_get(struct inbound_queue_table *circularQ,
+static int mpi_msg_free_get(struct inbound_queue_table *circularQ,
 			    u16 messageSize, void **messagePtr)
 {
 	u32 offset, consumer_index;
@@ -1257,7 +1257,7 @@ static u32 mpi_msg_free_get(struct inbound_queue_table *circularQ,
  * @opCode: the operation code represents commands which LLDD and fw recognized.
  * @payload: the command payload of each operation command.
  */
-static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
+static int mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 			 struct inbound_queue_table *circularQ,
 			 u32 opCode, void *payload)
 {
@@ -1270,7 +1270,7 @@ static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 			pm8001_printk("No free mpi buffer \n"));
 		return -1;
 	}
-
+	BUG_ON(!payload);
 	/*Copy to the payload*/
 	memcpy(pMessage, payload, (64 - sizeof(struct mpi_msg_hdr)));
 
@@ -1289,10 +1289,30 @@ static u32 mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 	return 0;
 }
 
-static u32 mpi_msg_free_set(struct pm8001_hba_info *pm8001_ha,
+static u32 mpi_msg_free_set(struct pm8001_hba_info *pm8001_ha, void *pMsg,
 			    struct outbound_queue_table *circularQ, u8 bc)
 {
 	u32 producer_index;
+	struct mpi_msg_hdr *msgHeader;
+	struct mpi_msg_hdr *pOutBoundMsgHeader;
+
+	msgHeader = (struct mpi_msg_hdr *)(pMsg - sizeof(struct mpi_msg_hdr));
+	pOutBoundMsgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt +
+				circularQ->consumer_idx * 64);
+	if (pOutBoundMsgHeader != msgHeader) {
+		PM8001_FAIL_DBG(pm8001_ha,
+			pm8001_printk("consumer_idx = %d msgHeader = %p\n",
+			circularQ->consumer_idx, msgHeader));
+
+		/* Update the producer index from SPC */
+		producer_index = pm8001_read_32(circularQ->pi_virt);
+		circularQ->producer_index = cpu_to_le32(producer_index);
+		PM8001_FAIL_DBG(pm8001_ha,
+			pm8001_printk("consumer_idx = %d producer_index = %d"
+			"msgHeader = %p\n", circularQ->consumer_idx,
+			circularQ->producer_index, msgHeader));
+		return 0;
+	}
 	/* free the circular queue buffer elements associated with the message*/
 	circularQ->consumer_idx = (circularQ->consumer_idx + bc) % 256;
 	/* update the CI of outbound queue */
@@ -1324,8 +1344,6 @@ static u32 mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
 	do {
 		/* If there are not-yet-delivered messages ... */
 		if (circularQ->producer_index != circularQ->consumer_idx) {
-			PM8001_IO_DBG(pm8001_ha,
-				pm8001_printk("process an IOMB\n"));
 			/*Get the pointer to the circular queue buffer element*/
 			msgHeader = (struct mpi_msg_hdr *)
 				(circularQ->base_virt +
@@ -1342,34 +1360,43 @@ static u32 mpi_msg_consume(struct pm8001_hba_info *pm8001_ha,
 					*pBC = (u8)((msgHeader_tmp >> 24) &
 						0x1f);
 					PM8001_IO_DBG(pm8001_ha,
-						pm8001_printk("mpi_msg_consume"
-						": CI=%d PI=%d msgHeader=%x\n",
+						pm8001_printk(": CI=%d PI=%d "
+						"msgHeader=%x\n",
 						circularQ->consumer_idx,
 						circularQ->producer_index,
 						msgHeader_tmp));
 					return MPI_IO_STATUS_SUCCESS;
 				} else {
-					u32 producer_index;
-					void *pi_virt = circularQ->pi_virt;
-					/* free the circular queue buffer
-					elements associated with the message*/
 					circularQ->consumer_idx =
 						(circularQ->consumer_idx +
 						((msgHeader_tmp >> 24) & 0x1f))
 						% 256;
+					msgHeader_tmp = 0;
+					pm8001_write_32(msgHeader, 0, 0);
 					/* update the CI of outbound queue */
 					pm8001_cw32(pm8001_ha,
 						circularQ->ci_pci_bar,
 						circularQ->ci_offset,
 						circularQ->consumer_idx);
-					/* Update the producer index from SPC */
-					producer_index =
-						pm8001_read_32(pi_virt);
-					circularQ->producer_index =
-						cpu_to_le32(producer_index);
 				}
-			} else
+			} else {
+				circularQ->consumer_idx =
+					(circularQ->consumer_idx +
+					((msgHeader_tmp >> 24) & 0x1f)) % 256;
+				msgHeader_tmp = 0;
+				pm8001_write_32(msgHeader, 0, 0);
+				/* update the CI of outbound queue */
+				pm8001_cw32(pm8001_ha, circularQ->ci_pci_bar,
+					circularQ->ci_offset,
+					circularQ->consumer_idx);
 				return MPI_IO_STATUS_FAIL;
+			}
+		} else {
+			u32 producer_index;
+			void *pi_virt = circularQ->pi_virt;
+			/* Update the producer index from SPC */
+			producer_index = pm8001_read_32(pi_virt);
+			circularQ->producer_index = cpu_to_le32(producer_index);
 		}
 	} while (circularQ->producer_index != circularQ->consumer_idx);
 	/* while we don't have any more not-yet-delivered message */
@@ -1441,7 +1468,7 @@ static int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha, void *data,
  * So we will tell the caller who maybe waiting the result to tell upper layer
  * that the task has been finished.
  */
-static int
+static void
 mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
@@ -1461,14 +1488,13 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 	pm8001_dev = ccb->device;
 	param = le32_to_cpu(psspPayload->param);
 
-	PM8001_IO_DBG(pm8001_ha, pm8001_printk("OPC_OUB_SSP_COMP\n"));
 	t = ccb->task;
 
-	if (status)
+	if (status && status != IO_UNDERFLOW)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sas IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	switch (status) {
 	case IO_SUCCESS:
@@ -1541,7 +1567,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
-		ts->open_rej_reason = SAS_OREJ_RSVD_CONT0;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1581,6 +1607,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_XFER_ERROR_ACK_NAK_TIMEOUT:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1656,7 +1683,7 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		break;
 	}
 	PM8001_IO_DBG(pm8001_ha,
-		pm8001_printk("scsi_satus = %x \n ",
+		pm8001_printk("scsi_status = %x \n ",
 		psspPayload->ssp_resp_iu.status));
 	spin_lock_irqsave(&t->task_state_lock, flags);
 	t->task_state_flags &= ~SAS_TASK_STATE_PENDING;
@@ -1675,11 +1702,10 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
+static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
 	unsigned long flags;
@@ -1700,7 +1726,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sas IO status 0x%x\n", event));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk("port_id = %x,device_id = %x\n",
@@ -1747,7 +1773,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
-		ts->open_rej_reason = SAS_OREJ_RSVD_CONT0;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1787,6 +1813,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_OPEN_REJECT;
+		ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		break;
 	case IO_XFER_ERROR_ACK_NAK_TIMEOUT:
 		PM8001_IO_DBG(pm8001_ha,
@@ -1840,7 +1867,7 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 	case IO_XFER_CMD_FRAME_ISSUED:
 		PM8001_IO_DBG(pm8001_ha,
 			pm8001_printk("  IO_XFER_CMD_FRAME_ISSUED\n"));
-		return 0;
+		return;
 	default:
 		PM8001_IO_DBG(pm8001_ha,
 			pm8001_printk("Unknown status 0x%x\n", event));
@@ -1866,11 +1893,10 @@ static int mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int
+static void
 mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
 	struct sas_task *t;
@@ -1898,7 +1924,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sata IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 
 	switch (status) {
 	case IO_SUCCESS:
@@ -2015,7 +2041,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*in order to force CPU ordering*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_BAD_DESTINATION:
@@ -2033,7 +2059,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED:
@@ -2059,7 +2085,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/* ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_WRONG_DESTINATION:
@@ -2124,7 +2150,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_DS_IN_RECOVERY:
@@ -2146,7 +2172,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY:
@@ -2180,11 +2206,10 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		mb();/* ditto */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
+static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
 	struct sas_task *t;
 	unsigned long flags;
@@ -2205,7 +2230,7 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("sata IO status 0x%x\n", event));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 	ts = &t->task_status;
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk("port_id = %x,device_id = %x\n",
@@ -2268,7 +2293,7 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 			pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
 			mb();/*ditto*/
 			t->task_done(t);
-			return 0;
+			return;
 		}
 		break;
 	case IO_OPEN_CNX_ERROR_BAD_DESTINATION:
@@ -2382,11 +2407,10 @@ static int mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 /*See the comments for mpi_ssp_completion */
-static int
+static void
 mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
 	u32 param;
@@ -2412,7 +2436,7 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		PM8001_FAIL_DBG(pm8001_ha,
 			pm8001_printk("smp IO status 0x%x\n", status));
 	if (unlikely(!t || !t->lldd_task || !t->dev))
-		return -1;
+		return;
 
 	switch (status) {
 	case IO_SUCCESS:
@@ -2585,7 +2609,6 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		mb();/* in order to force CPU ordering */
 		t->task_done(t);
 	}
-	return 0;
 }
 
 static void
@@ -2682,8 +2705,8 @@ mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 			pm8001_printk("Get NVMD success, IR=0, dataLen=%d\n",
 			(dlen_status & NVMD_LEN) >> 24));
 	}
-	memcpy((void *)(fw_control_context->usrAddr),
-		(void *)(pm8001_ha->memoryMap.region[NVMD].virt_ptr),
+	memcpy(fw_control_context->usrAddr,
+		pm8001_ha->memoryMap.region[NVMD].virt_ptr,
 		fw_control_context->len);
 	complete(pm8001_ha->nvmd_completion);
 	ccb->task = NULL;
@@ -3184,28 +3207,28 @@ mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		(struct task_abort_resp *)(piomb + 4);
 	ccb = &pm8001_ha->ccb_info[pPayload->tag];
 	t = ccb->task;
-	ts = &t->task_status;
 
-	if (t == NULL)
-		return -1;
 
 	status = le32_to_cpu(pPayload->status);
 	tag = le32_to_cpu(pPayload->tag);
 	scp = le32_to_cpu(pPayload->scp);
 	PM8001_IO_DBG(pm8001_ha,
 		pm8001_printk(" status = 0x%x\n", status));
+	if (t == NULL)
+		return -1;
+	ts = &t->task_status;
 	if (status != 0)
 		PM8001_FAIL_DBG(pm8001_ha,
-			pm8001_printk("task abort failed tag = 0x%x,"
-			" scp= 0x%x\n", tag, scp));
+			pm8001_printk("task abort failed status 0x%x ,"
+			"tag = 0x%x, scp= 0x%x\n", status, tag, scp));
 	switch (status) {
 	case IO_SUCCESS:
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n"));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n"));
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAM_GOOD;
 		break;
 	case IO_NOT_VALID:
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_NOT_VALID\n"));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("IO_NOT_VALID\n"));
 		ts->resp = TMF_RESP_FUNC_FAILED;
 		break;
 	}
@@ -3443,7 +3466,7 @@ static void process_one_iomb(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 pHeader = (u32)*(u32 *)piomb;
 	u8 opc = (u8)((le32_to_cpu(pHeader)) & 0xFFF);
 
-	PM8001_MSG_DBG(pm8001_ha, pm8001_printk("process_one_iomb:\n"));
+	PM8001_MSG_DBG(pm8001_ha, pm8001_printk("process_one_iomb:"));
 
 	switch (opc) {
 	case OPC_OUB_ECHO:
@@ -3609,17 +3632,16 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
 	struct outbound_queue_table *circularQ;
 	void *pMsg1 = NULL;
 	u8 bc = 0;
-	u32 ret = MPI_IO_STATUS_FAIL, processedMsgCount = 0;
+	u32 ret = MPI_IO_STATUS_FAIL;
 
 	circularQ = &pm8001_ha->outbnd_q_tbl[0];
 	do {
 		ret = mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc);
 		if (MPI_IO_STATUS_SUCCESS == ret) {
 			/* process the outbound message */
-			process_one_iomb(pm8001_ha, (void *)((u8 *)pMsg1 - 4));
+			process_one_iomb(pm8001_ha, (void *)(pMsg1 - 4));
 			/* free the message from the outbound circular buffer */
-			mpi_msg_free_set(pm8001_ha, circularQ, bc);
-			processedMsgCount++;
+			mpi_msg_free_set(pm8001_ha, pMsg1, circularQ, bc);
 		}
 		if (MPI_IO_STATUS_BUSY == ret) {
 			u32 producer_idx;
@@ -3631,8 +3653,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
 				/* OQ is empty */
 				break;
 		}
-	} while (100 > processedMsgCount);/*end message processing if hit the
-	count*/
+	} while (1);
 	return ret;
 }
 
@@ -3743,6 +3764,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
 	struct pm8001_device *pm8001_dev = dev->lldd_dev;
 	struct ssp_ini_io_start_req ssp_cmd;
 	u32 tag = ccb->ccb_tag;
+	int ret;
 	__le64 phys_addr;
 	struct inbound_queue_table *circularQ;
 	u32 opc = OPC_INB_SSPINIIOSTART;
@@ -3780,8 +3802,8 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
 		ssp_cmd.len = cpu_to_le32(task->total_xfer_len);
 		ssp_cmd.esgl = 0;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd);
+	return ret;
 }
 
 static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
@@ -3791,6 +3813,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 	struct domain_device *dev = task->dev;
 	struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
 	u32 tag = ccb->ccb_tag;
+	int ret;
 	struct sata_start_req sata_cmd;
 	u32 hdr_tag, ncg_tag = 0;
 	__le64 phys_addr;
@@ -3849,8 +3872,8 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 		sata_cmd.len = cpu_to_le32(task->total_xfer_len);
 		sata_cmd.esgl = 0;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd);
+	return ret;
 }
 
 /**
@@ -3864,6 +3887,7 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
 {
 	struct phy_start_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 tag = 0x01;
 	u32 opcode = OPC_INB_PHYSTART;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
@@ -3883,8 +3907,8 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id)
 	memcpy(payload.sas_identify.sas_addr,
 		pm8001_ha->sas_addr, SAS_ADDR_SIZE);
 	payload.sas_identify.phy_id = phy_id;
-	mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
+	return ret;
 }
 
 /**
@@ -3898,14 +3922,15 @@ static int pm8001_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct phy_stop_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 tag = 0x01;
 	u32 opcode = OPC_INB_PHYSTOP;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	memset(&payload, 0, sizeof(payload));
 	payload.tag = cpu_to_le32(tag);
 	payload.phy_id = cpu_to_le32(phy_id);
-	mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
+	return ret;
 }
 
 /**
@@ -3919,7 +3944,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
 	u32 stp_sspsmp_sata = 0x4;
 	struct inbound_queue_table *circularQ;
 	u32 linkrate, phy_id;
-	u32 rc, tag = 0xdeadbeef;
+	int rc, tag = 0xdeadbeef;
 	struct pm8001_ccb_info *ccb;
 	u8 retryFlag = 0x1;
 	u16 firstBurstSize = 0;
@@ -3963,8 +3988,8 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
 		cpu_to_le32(ITNT | (firstBurstSize * 0x10000));
 	memcpy(&payload.sas_addr_hi, pm8001_dev->sas_device->sas_addr,
 		SAS_ADDR_SIZE);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
 }
 
 /**
@@ -3975,16 +4000,17 @@ static int pm8001_chip_dereg_dev_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct dereg_dev_req payload;
 	u32 opc = OPC_INB_DEREG_DEV_HANDLE;
+	int ret;
 	struct inbound_queue_table *circularQ;
 
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
-	memset((u8 *)&payload, 0, sizeof(payload));
+	memset(&payload, 0, sizeof(payload));
 	payload.tag = 1;
 	payload.device_id = cpu_to_le32(device_id);
 	PM8001_MSG_DBG(pm8001_ha,
 		pm8001_printk("unregister device device_id = %d\n", device_id));
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 /**
@@ -3999,14 +4025,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
 {
 	struct local_phy_ctl_req payload;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
 	memset((u8 *)&payload, 0, sizeof(payload));
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	payload.tag = 1;
 	payload.phyop_phyid =
 		cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F));
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 static u32 pm8001_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
@@ -4028,12 +4055,16 @@ static u32 pm8001_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
  * @irq: irq number.
  * @stat: stat.
  */
-static void
+static irqreturn_t
 pm8001_chip_isr(struct pm8001_hba_info *pm8001_ha)
 {
+	unsigned long flags;
+	spin_lock_irqsave(&pm8001_ha->lock, flags);
 	pm8001_chip_interrupt_disable(pm8001_ha);
 	process_oq(pm8001_ha);
 	pm8001_chip_interrupt_enable(pm8001_ha);
+	spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+	return IRQ_HANDLED;
 }
 
 static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
@@ -4041,7 +4072,7 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
 {
 	struct task_abort_req task_abort;
 	struct inbound_queue_table *circularQ;
-
+	int ret;
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	memset(&task_abort, 0, sizeof(task_abort));
 	if (ABORT_SINGLE == (flag & ABORT_MASK)) {
@@ -4054,8 +4085,8 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc,
 		task_abort.device_id = cpu_to_le32(dev_id);
 		task_abort.tag = cpu_to_le32(cmd_tag);
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort);
+	return ret;
 }
 
 /**
@@ -4068,7 +4099,8 @@ static int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc, device_id;
 	int rc = TMF_RESP_FUNC_FAILED;
-	PM8001_IO_DBG(pm8001_ha, pm8001_printk("Abort tag[%x]", task_tag));
+	PM8001_EH_DBG(pm8001_ha, pm8001_printk("cmd_tag = %x, abort task tag"
+		" = %x", cmd_tag, task_tag));
 	if (pm8001_dev->dev_type == SAS_END_DEV)
 		opc = OPC_INB_SSP_ABORT;
 	else if (pm8001_dev->dev_type == SATA_DEV)
@@ -4079,7 +4111,7 @@ static int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,
 	rc = send_task_abort(pm8001_ha, opc, device_id, flag,
 		task_tag, cmd_tag);
 	if (rc != TMF_RESP_FUNC_COMPLETE)
-		PM8001_IO_DBG(pm8001_ha, pm8001_printk("rc= %d\n", rc));
+		PM8001_EH_DBG(pm8001_ha, pm8001_printk("rc= %d\n", rc));
 	return rc;
 }
 
@@ -4098,17 +4130,17 @@ static int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha,
 	u32 opc = OPC_INB_SSPINITMSTART;
 	struct inbound_queue_table *circularQ;
 	struct ssp_ini_tm_start_req sspTMCmd;
+	int ret;
 
 	memset(&sspTMCmd, 0, sizeof(sspTMCmd));
 	sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id);
 	sspTMCmd.relate_tag = cpu_to_le32(tmf->tag_of_task_to_be_managed);
 	sspTMCmd.tmf = cpu_to_le32(tmf->tmf);
-	sspTMCmd.ds_ads_m = cpu_to_le32(1 << 2);
 	memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8);
 	sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag);
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd);
+	return ret;
 }
 
 static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
@@ -4116,7 +4148,7 @@ static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc = OPC_INB_GET_NVMD_DATA;
 	u32 nvmd_type;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	struct inbound_queue_table *circularQ;
@@ -4183,8 +4215,8 @@ static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 	default:
 		break;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
+	return rc;
 }
 
 static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
@@ -4192,7 +4224,7 @@ static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 {
 	u32 opc = OPC_INB_SET_NVMD_DATA;
 	u32 nvmd_type;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	struct inbound_queue_table *circularQ;
@@ -4259,8 +4291,8 @@ static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
 	default:
 		break;
 	}
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
+	return rc;
 }
 
 /**
@@ -4275,9 +4307,10 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha,
 	struct fw_flash_Update_req payload;
 	struct fw_flash_updata_info *info;
 	struct inbound_queue_table *circularQ;
+	int ret;
 	u32 opc = OPC_INB_FW_FLASH_UPDATE;
 
-	memset((u8 *)&payload, 0, sizeof(struct fw_flash_Update_req));
+	memset(&payload, 0, sizeof(struct fw_flash_Update_req));
 	circularQ = &pm8001_ha->inbnd_q_tbl[0];
 	info = fw_flash_updata_info;
 	payload.tag = cpu_to_le32(tag);
@@ -4287,8 +4320,8 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha,
 	payload.len = info->sgl.im_len.len ;
 	payload.sgl_addr_lo = lower_32_bits(info->sgl.addr);
 	payload.sgl_addr_hi = upper_32_bits(info->sgl.addr);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return ret;
 }
 
 static int
@@ -4298,7 +4331,7 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 	struct fw_flash_updata_info flash_update_info;
 	struct fw_control_info *fw_control;
 	struct fw_control_ex *fw_control_context;
-	u32 rc;
+	int rc;
 	u32 tag;
 	struct pm8001_ccb_info *ccb;
 	void *buffer = NULL;
@@ -4321,8 +4354,8 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 				return -ENOMEM;
 		}
 	}
-	memset((void *)buffer, 0, fw_control->len);
-	memcpy((void *)buffer, fw_control->buffer, fw_control->len);
+	memset(buffer, 0, fw_control->len);
+	memcpy(buffer, fw_control->buffer, fw_control->len);
 	flash_update_info.sgl.addr = cpu_to_le64(phys_addr);
 	flash_update_info.sgl.im_len.len = cpu_to_le32(fw_control->len);
 	flash_update_info.sgl.im_len.e = 0;
@@ -4338,8 +4371,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 	ccb = &pm8001_ha->ccb_info[tag];
 	ccb->fw_control_context = fw_control_context;
 	ccb->ccb_tag = tag;
-	pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag);
-	return 0;
+	rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
+		tag);
+	return rc;
 }
 
 static int
@@ -4349,10 +4383,10 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	struct set_dev_state_req payload;
 	struct inbound_queue_table *circularQ;
 	struct pm8001_ccb_info *ccb;
-	u32 rc;
+	int rc;
 	u32 tag;
 	u32 opc = OPC_INB_SET_DEVICE_STATE;
-	memset((u8 *)&payload, 0, sizeof(payload));
+	memset(&payload, 0, sizeof(payload));
 	rc = pm8001_tag_alloc(pm8001_ha, &tag);
 	if (rc)
 		return -1;
@@ -4363,8 +4397,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
 	payload.tag = cpu_to_le32(tag);
 	payload.device_id = cpu_to_le32(pm8001_dev->device_id);
 	payload.nds = cpu_to_le32(state);
-	mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
-	return 0;
+	rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
+	return rc;
+
 }
 
 static int
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index ed6dbd1..30f2ede 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -119,7 +119,7 @@ struct pm8001_dispatch {
 	void (*chip_rst)(struct pm8001_hba_info *pm8001_ha);
 	int (*chip_ioremap)(struct pm8001_hba_info *pm8001_ha);
 	void (*chip_iounmap)(struct pm8001_hba_info *pm8001_ha);
-	void (*isr)(struct pm8001_hba_info *pm8001_ha);
+	irqreturn_t (*isr)(struct pm8001_hba_info *pm8001_ha);
 	u32 (*is_our_interupt)(struct pm8001_hba_info *pm8001_ha);
 	int (*isr_process_oq)(struct pm8001_hba_info *pm8001_ha);
 	void (*interrupt_enable)(struct pm8001_hba_info *pm8001_ha);
-- 
1.6.4.msysgit.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] pm8001:Fixes for tag alloc, error goto and code cleanup
  2009-10-30 13:53   ` [PATCH Resend 2/3] pm8001:enhance IOMB process modules jack_wang
                       ` (2 preceding siblings ...)
  2009-11-05 14:33     ` [PATCH V2 2/3] pm8001:enhance IOMB process modules jack_wang
@ 2009-11-05 14:33     ` jack_wang
  3 siblings, 0 replies; 7+ messages in thread
From: jack_wang @ 2009-11-05 14:33 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, jack wang, lindar_liu, aoqingyun

[-- Attachment #1: Type: text/plain, Size: 161 bytes --]

Allocate right size for bitmap tag,fix error goto and cleanup print message and
undocable commemts. patch attached.

------------------				 
jack_wang
2009-11-05

[-- Attachment #2: 0003-Fixes-for-tag-alloc-error-goto-and-code-cleanup.patch --]
[-- Type: application/octet-stream, Size: 8353 bytes --]

From 27b35cdbfc6fb0eaa7eeea8c562da2a50e1d8826 Mon Sep 17 00:00:00 2001
From: Jack Wang <jack_wang@usish.com>
Date: Thu, 5 Nov 2009 22:01:16 +0800
Subject: [PATCH 3/3] Fixes for tag alloc, error goto and code cleanup

Signed-off-by: Lindar Liu <lindar_liu@usish.com>
Signed-off-by: Jack Wang <jack_wang@usish.com>
---
 drivers/scsi/pm8001/pm8001_init.c |   11 ++++--
 drivers/scsi/pm8001/pm8001_sas.c  |   60 ++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 811b5d3..42ebe72 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -203,9 +203,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
 	for (i = 0; i < pm8001_ha->chip->n_phy; i++)
 		pm8001_phy_init(pm8001_ha, i);
 
-	pm8001_ha->tags = kmalloc(sizeof(*pm8001_ha->tags)*PM8001_MAX_DEVICES,
-		GFP_KERNEL);
-
+	pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
+	if (!pm8001_ha->tags)
+		goto err_out;
 	/* MPI Memory region 1 for AAP Event Log for fw */
 	pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
 	pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
@@ -287,6 +287,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
 		pm8001_ha->ccb_info[i].ccb_dma_handle =
 			pm8001_ha->memoryMap.region[CCB_MEM].phys_addr +
 			i * sizeof(struct pm8001_ccb_info);
+		pm8001_ha->ccb_info[i].task = NULL;
+		pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
+		pm8001_ha->ccb_info[i].device = NULL;
 		++pm8001_ha->tags_num;
 	}
 	pm8001_ha->flags = PM8001F_INIT_TIME;
@@ -578,7 +581,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
 {
 	struct pci_dev *pdev;
 	irq_handler_t irq_handler = pm8001_interrupt;
-	u32 rc;
+	int rc;
 
 	pdev = pm8001_ha->pdev;
 
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 1e840fd..1f767a0 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -330,15 +330,12 @@ int pm8001_slave_configure(struct scsi_device *sdev)
 	return 0;
 }
 /**
-  * pm8001_task_exec -execute the task which come from upper level, send the
-  * command or data to DMA area and then increase CI,for queuecommand(ssp),
-  * it is from upper layer and for smp command,it is from libsas,
-  * for ata command it is from libata.
+  * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
   * @task: the task to be execute.
   * @num: if can_queue great than 1, the task can be queued up. for SMP task,
   * we always execute one one time.
   * @gfp_flags: gfp_flags.
-  * @is tmf: if it is task management task.
+  * @is_tmf: if it is task management task.
   * @tmf: the task management IU
   */
 #define DEV_IS_GONE(pm8001_dev)	\
@@ -379,7 +376,7 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
 					pm8001_printk("device %016llx not "
 					"ready.\n", SAS_ADDR(dev->sas_addr)));
 			}
-		rc = SAS_PHY_DOWN;
+			rc = SAS_PHY_DOWN;
 			goto out_done;
 		}
 		rc = pm8001_tag_alloc(pm8001_ha, &tag);
@@ -395,14 +392,14 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
 					t->data_dir);
 				if (!n_elem) {
 					rc = -ENOMEM;
-					goto err_out;
+					goto err_out_tag;
 				}
 			}
 		} else {
 			n_elem = t->num_scatter;
 		}
 
-		t->lldd_task = NULL;
+		t->lldd_task = ccb;
 		ccb->n_elem = n_elem;
 		ccb->ccb_tag = tag;
 		ccb->task = t;
@@ -435,7 +432,6 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
 				pm8001_printk("rc is %x\n", rc));
 			goto err_out_tag;
 		}
-		t->lldd_task = ccb;
 		/* TODO: select normal or high priority */
 		spin_lock(&t->task_state_lock);
 		t->task_state_flags |= SAS_TASK_AT_INITIATOR;
@@ -518,8 +514,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
 }
 
  /**
-  * pm8001_alloc_dev - find the empty pm8001_device structure, allocate and
-  * return it for use.
+  * pm8001_alloc_dev - find a empty pm8001_device
   * @pm8001_ha: our hba card information
   */
 struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
@@ -550,14 +545,16 @@ static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
 }
 
 /**
-  * pm8001_dev_found_notify - when libsas find a sas domain device, it should
-  * tell the LLDD that device is found, and then LLDD register this device to
-  * HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign
-  * a device ID(according to device's sas address) and returned it to LLDD.from
+  * pm8001_dev_found_notify - libsas notify a device is found.
+  * @dev: the device structure which sas layer used.
+  *
+  * when libsas find a sas domain device, it should tell the LLDD that
+  * device is found, and then LLDD register this device to HBA firmware
+  * by the command "OPC_INB_REG_DEV", after that the HBA will assign a
+  * device ID(according to device's sas address) and returned it to LLDD. From
   * now on, we communicate with HBA FW with the device ID which HBA assigned
   * rather than sas address. it is the neccessary step for our HBA but it is
   * the optional for other HBA driver.
-  * @dev: the device structure which sas layer used.
   */
 static int pm8001_dev_found_notify(struct domain_device *dev)
 {
@@ -665,14 +662,15 @@ static void pm8001_tmf_timedout(unsigned long data)
 
 #define PM8001_TASK_TIMEOUT 20
 /**
-  * pm8001_exec_internal_tmf_task - when errors or exception happened, we may
-  * want to do something, for example abort issued task which result in this
-  * execption, this is by calling this function, note it is also with the task
-  * execute interface.
+  * pm8001_exec_internal_tmf_task - execute some task management commands.
   * @dev: the wanted device.
   * @tmf: which task management wanted to be take.
   * @para_len: para_len.
   * @parameter: ssp task parameter.
+  *
+  * when errors or exception happened, we may want to do something, for example
+  * abort the issued task which result in this execption, it is done by calling
+  * this function, note it is also with the task execute interface.
   */
 static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
 	void *parameter, u32 para_len, struct pm8001_tmf_task *tmf)
@@ -737,9 +735,9 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
 			res = -EMSGSIZE;
 			break;
 		} else {
-			PM8001_IO_DBG(pm8001_ha,
-			pm8001_printk(" Task to dev %016llx response: 0x%x"
-				"status 0x%x\n",
+			PM8001_EH_DBG(pm8001_ha,
+				pm8001_printk(" Task to dev %016llx response:"
+				"0x%x status 0x%x\n",
 				SAS_ADDR(dev->sas_addr),
 				task->task_status.resp,
 				task->task_status.stat));
@@ -760,7 +758,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
 	u32 task_tag)
 {
 	int res, retry;
-	u32 rc, ccb_tag;
+	u32 ccb_tag;
 	struct pm8001_ccb_info *ccb;
 	struct sas_task *task = NULL;
 
@@ -777,9 +775,9 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
 		task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
 		add_timer(&task->timer);
 
-		rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
-		if (rc)
-			return rc;
+		res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
+		if (res)
+			return res;
 		ccb = &pm8001_ha->ccb_info[ccb_tag];
 		ccb->device = pm8001_dev;
 		ccb->ccb_tag = ccb_tag;
@@ -812,7 +810,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
 			break;
 
 		} else {
-			PM8001_IO_DBG(pm8001_ha,
+			PM8001_EH_DBG(pm8001_ha,
 				pm8001_printk(" Task to dev %016llx response: "
 					"0x%x status 0x%x\n",
 				SAS_ADDR(dev->sas_addr),
@@ -1027,11 +1025,11 @@ int pm8001_abort_task(struct sas_task *task)
 		}
 		device_id = pm8001_dev->device_id;
 		PM8001_EH_DBG(pm8001_ha,
-		pm8001_printk("abort io to device_id = %d\n", device_id));
-		tmf_task.tmf = 	TMF_ABORT_TASK;
+			pm8001_printk("abort io to deviceid= %d\n", device_id));
+		tmf_task.tmf = TMF_ABORT_TASK;
 		tmf_task.tag_of_task_to_be_managed = tag;
 		rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
-		rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
+		pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
 			pm8001_dev->sas_device, 0, tag);
 	} else if (task->task_proto & SAS_PROTOCOL_SATA ||
 		task->task_proto & SAS_PROTOCOL_STP) {
-- 
1.6.4.msysgit.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-11-05 14:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200910281755.n9SHtGrV004494@hera.kernel.org>
     [not found] ` <200910302144286878481@usish.com>
2009-10-30 13:51   ` [PATCH Resend 1/3] pm8001:add reinitialize SPC parameters before phy start jack_wang
     [not found] ` <200910302144471408205@usish.com>
2009-10-30 13:53   ` [PATCH Resend 2/3] pm8001:enhance IOMB process modules jack_wang
2009-11-04 17:32     ` James Bottomley
2009-11-05  1:03       ` jack wang
2009-11-05 14:32     ` [PATCH v2 1/3] pm8001:add reinitialize SPC parameters before phy start jack_wang
2009-11-05 14:33     ` [PATCH V2 2/3] pm8001:enhance IOMB process modules jack_wang
2009-11-05 14:33     ` [PATCH v2 3/3] pm8001:Fixes for tag alloc, error goto and code cleanup jack_wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.