All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] nobody loves the advansys driver
@ 2014-12-03 11:44 Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 01/12] advansys: use host_reset Hannes Reinecke
                   ` (14 more replies)
  0 siblings, 15 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Hi all,

it has been bugged me for ages that the advansys driver always
reported a compilation warning about not having been converted
to the DMA-API.
And even aggressive waiting hasn't made this warning go away.

So here's a patchset to update the advansys driver to current
standards and use the DMA-API.
Tested on ABP940-U2W.

As usual, reviews and comments are welcome.

Hannes Reinecke (12):
  advansys: use host_reset
  advansys: use shared host tag map for command lookup
  advansys: use DMA-API for mapping sense buffer
  advansys: Use DMA-API for carrier buffer
  advansys: Use DMA-API for mapping request blocks
  advansys: Use dma_pool for sg elements
  advansys: use 'bool' instead of 'int'
  advansys: use standard data types
  advansys: Remove 'TRUE' and 'FALSE' definitions
  advansys: Remove 'ERR' definition
  advansys: cleanup function return codes
  advansys: Update to version 3.5 and remove compilation warning

 MAINTAINERS             |    1 +
 drivers/scsi/advansys.c | 1073 +++++++++++++++++++++--------------------------
 2 files changed, 469 insertions(+), 605 deletions(-)

-- 
1.8.5.2


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

* [PATCH 01/12] advansys: use host_reset
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-04  9:17   ` Christoph Hellwig
  2014-12-03 11:44 ` [PATCH 02/12] advansys: use shared host tag map for command lookup Hannes Reinecke
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

The advansys_reset() function is actually a host reset, not a
bus reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 6719a33..d9b27ca 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2079,9 +2079,9 @@ do { \
  *      ADV_TRUE(1) - Queue was successfully aborted.
  *      ADV_FALSE(0) - Queue was not found on the active queue list.
  */
-#define AdvAbortQueue(asc_dvc, scsiq) \
+#define AdvAbortQueue(asc_dvc, srb_tag) \
         AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
-                       (ADV_DCNT) (scsiq))
+                       (ADV_DCNT) (srb_tag))
 
 /*
  * Send a Bus Device Reset Message to the specified target ID.
@@ -11250,7 +11250,7 @@ static struct scsi_host_template advansys_template = {
 	.name = DRV_NAME,
 	.info = advansys_info,
 	.queuecommand = advansys_queuecommand,
-	.eh_bus_reset_handler = advansys_reset,
+	.eh_host_reset_handler = advansys_reset,
 	.bios_param = advansys_biosparam,
 	.slave_configure = advansys_slave_configure,
 	/*
-- 
1.8.5.2


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

* [PATCH 02/12] advansys: use shared host tag map for command lookup
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 01/12] advansys: use host_reset Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-04  9:20   ` Christoph Hellwig
  2014-12-03 11:44 ` [PATCH 03/12] advansys: use DMA-API for mapping sense buffer Hannes Reinecke
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Convert to use a shared host tag map for command lookup. This
saves us having an internal structure and avoid the command
pointer abuse.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 218 ++++++++++++++++++------------------------------
 1 file changed, 79 insertions(+), 139 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index d9b27ca..6af2a52 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -315,7 +315,7 @@ typedef struct asc_scsiq_1 {
 } ASC_SCSIQ_1;
 
 typedef struct asc_scsiq_2 {
-	ASC_VADDR srb_ptr;
+	__le32 srb_tag;
 	uchar target_ix;
 	uchar flag;
 	uchar cdb_len;
@@ -592,8 +592,6 @@ typedef struct asc_dvc_var {
 	uchar min_sdtr_index;
 	uchar max_sdtr_index;
 	struct asc_board *drv_ptr;
-	int ptr_map_count;
-	void **ptr_map;
 	ASC_DCNT uc_break;
 } ASC_DVC_VAR;
 
@@ -1866,7 +1864,7 @@ typedef struct adv_scsi_req_q {
 	 * End of microcode structure - 60 bytes. The rest of the structure
 	 * is used by the Adv Library and ignored by the microcode.
 	 */
-	ADV_VADDR srb_ptr;
+	__le32 srb_tag;
 	ADV_SG_BLOCK *sg_list_ptr;	/* SG list virtual address. */
 	char *vdata_addr;	/* Data buffer virtual address. */
 	uchar a_flag;
@@ -1877,7 +1875,7 @@ typedef struct adv_scsi_req_q {
  * The following two structures are used to process Wide Board requests.
  *
  * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
- * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
+ * and microcode with the ADV_SCSI_REQ_Q field 'srb_tag' pointing to the
  * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  * Mid-Level SCSI request structure.
  *
@@ -1942,7 +1940,6 @@ typedef struct adv_dvc_var {
 	ADV_CARR_T *icq_sp;	/* Initiator command queue stopper pointer. */
 	ADV_CARR_T *irq_sp;	/* Initiator response queue stopper pointer. */
 	ushort carr_pending_cnt;	/* Count of pending carriers. */
-	struct adv_req *orig_reqp;	/* adv_req_t memory block. */
 	/*
 	 * Note: The following fields will not be used after initialization. The
 	 * driver may discard the buffer after initialization is done.
@@ -2068,8 +2065,8 @@ do { \
     AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
 
 /*
- * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
- * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
+ * Abort an SRB in the chip's RISC Memory. The 'srb_tag' argument must
+ * match the ASC_SCSI_REQ_Q 'srb_tag' field.
  *
  * If the request has not yet been sent to the device it will simply be
  * aborted from RISC memory. If the request is disconnected it will be
@@ -2345,6 +2342,7 @@ struct asc_stats {
  */
 struct asc_board {
 	struct device *dev;
+	struct Scsi_Host *shost;
 	uint flags;		/* Board flags */
 	unsigned int irq;
 	union {
@@ -2600,8 +2598,8 @@ static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
 	printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
 
 	printk
-	    (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
-	     q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
+	    (" target_ix 0x%x, target_lun %u, srb_tag 0x%x, tag_code 0x%x,\n",
+	     q->q2.target_ix, q->q1.target_lun, q->q2.srb_tag,
 	     q->q2.tag_code);
 
 	printk
@@ -2634,8 +2632,8 @@ static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
 static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
 {
 	printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
-	printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
-	       (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
+	printk(" srb_tag 0x%x, target_ix %u, cdb_len %u, tag_code %u,\n",
+	       q->d2.srb_tag, q->d2.target_ix, q->d2.cdb_len,
 	       q->d2.tag_code);
 	printk
 	    (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
@@ -2677,8 +2675,8 @@ static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
 
 	printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
 
-	printk("  target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
-	       q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
+	printk("  target_id %u, target_lun %u, srb_tag 0x%x, a_flag 0x%x\n",
+	       q->target_id, q->target_lun, q->srb_tag, q->a_flag);
 
 	printk("  cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
 	       q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
@@ -2722,59 +2720,6 @@ static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
 #endif /* ADVANSYS_DEBUG */
 
 /*
- * The advansys chip/microcode contains a 32-bit identifier for each command
- * known as the 'srb'.  I don't know what it stands for.  The driver used
- * to encode the scsi_cmnd pointer by calling virt_to_bus and retrieve it
- * with bus_to_virt.  Now the driver keeps a per-host map of integers to
- * pointers.  It auto-expands when full, unless it can't allocate memory.
- * Note that an srb of 0 is treated specially by the chip/firmware, hence
- * the return of i+1 in this routine, and the corresponding subtraction in
- * the inverse routine.
- */
-#define BAD_SRB 0
-static u32 advansys_ptr_to_srb(struct asc_dvc_var *asc_dvc, void *ptr)
-{
-	int i;
-	void **new_ptr;
-
-	for (i = 0; i < asc_dvc->ptr_map_count; i++) {
-		if (!asc_dvc->ptr_map[i])
-			goto out;
-	}
-
-	if (asc_dvc->ptr_map_count == 0)
-		asc_dvc->ptr_map_count = 1;
-	else
-		asc_dvc->ptr_map_count *= 2;
-
-	new_ptr = krealloc(asc_dvc->ptr_map,
-			asc_dvc->ptr_map_count * sizeof(void *), GFP_ATOMIC);
-	if (!new_ptr)
-		return BAD_SRB;
-	asc_dvc->ptr_map = new_ptr;
- out:
-	ASC_DBG(3, "Putting ptr %p into array offset %d\n", ptr, i);
-	asc_dvc->ptr_map[i] = ptr;
-	return i + 1;
-}
-
-static void * advansys_srb_to_ptr(struct asc_dvc_var *asc_dvc, u32 srb)
-{
-	void *ptr;
-
-	srb--;
-	if (srb >= asc_dvc->ptr_map_count) {
-		printk("advansys: bad SRB %u, max %u\n", srb,
-							asc_dvc->ptr_map_count);
-		return NULL;
-	}
-	ptr = asc_dvc->ptr_map[srb];
-	asc_dvc->ptr_map[srb] = NULL;
-	ASC_DBG(3, "Returning ptr %p from array offset %d\n", ptr, srb);
-	return ptr;
-}
-
-/*
  * advansys_info()
  *
  * Return suitable for printing on the console with the argument
@@ -6132,6 +6077,13 @@ static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
 		AdvResetChipAndSB(adv_dvc_varp);
 		break;
 
+	case ADV_ASYNC_CARRIER_READY_FAILURE:
+		/*
+		 * Carrier not ready; abort the command.
+		 */
+		ASC_DBG(0, "ADV_ASYNC_CARRIER_READY_FAILURE\n");
+		break;
+
 	case ADV_HOST_SCSI_BUS_RESET:
 		/*
 		 * Host generated SCSI bus reset occurred.
@@ -6152,15 +6104,15 @@ static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  */
 static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 {
-	struct asc_board *boardp;
+	struct asc_board *boardp = adv_dvc_varp->drv_ptr;
+	u32 srb_tag;
 	adv_req_t *reqp;
 	adv_sgblk_t *sgblkp;
 	struct scsi_cmnd *scp;
-	struct Scsi_Host *shost;
 	ADV_DCNT resid_cnt;
 
-	ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
-		 (ulong)adv_dvc_varp, (ulong)scsiqp);
+	ASC_DBG(1, "adv_dvc_varp 0x%p, scsiqp 0x%p\n",
+		adv_dvc_varp, scsiqp);
 	ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
 
 	/*
@@ -6168,22 +6120,9 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	 * completed. The adv_req_t structure actually contains the
 	 * completed ADV_SCSI_REQ_Q structure.
 	 */
-	reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
-	ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
-	if (reqp == NULL) {
-		ASC_PRINT("adv_isr_callback: reqp is NULL\n");
-		return;
-	}
+	srb_tag = le32_to_cpu(scsiqp->srb_tag);
+	scp = scsi_host_find_tag(boardp->shost, srb_tag);
 
-	/*
-	 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
-	 * command that has been completed.
-	 *
-	 * Note: The adv_req_t request structure and adv_sgblk_t structure,
-	 * if any, are dropped, because a board structure pointer can not be
-	 * determined.
-	 */
-	scp = reqp->cmndp;
 	ASC_DBG(1, "scp 0x%p\n", scp);
 	if (scp == NULL) {
 		ASC_PRINT
@@ -6192,12 +6131,21 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	}
 	ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
 
-	shost = scp->device->host;
-	ASC_STATS(shost, callback);
-	ASC_DBG(1, "shost 0x%p\n", shost);
+	reqp = (adv_req_t *)scp->host_scribble;
+	ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
+	if (reqp == NULL) {
+		ASC_PRINT("adv_isr_callback: reqp is NULL\n");
+		return;
+	}
+	/*
+	 * Remove backreferences to avoid duplicate
+	 * command completions.
+	 */
+	scp->host_scribble = NULL;
+	reqp->cmndp = NULL;
 
-	boardp = shost_priv(shost);
-	BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
+	ASC_STATS(boardp->shost, callback);
+	ASC_DBG(1, "shost 0x%p\n", boardp->shost);
 
 	/*
 	 * 'done_status' contains the command's ending status.
@@ -6295,13 +6243,6 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 		boardp->adv_sgblkp = sgblkp;
 	}
 
-	/*
-	 * Free the adv_req_t structure used with the command by adding
-	 * it back to the board free list.
-	 */
-	reqp->next_reqp = boardp->adv_reqp;
-	boardp->adv_reqp = reqp;
-
 	ASC_DBG(1, "done\n");
 }
 
@@ -7111,25 +7052,21 @@ _AscCopyLramScsiDoneQ(PortAddr iop_base,
  */
 static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 {
-	struct asc_board *boardp;
+	struct asc_board *boardp = asc_dvc_varp->drv_ptr;
+	u32 srb_tag;
 	struct scsi_cmnd *scp;
-	struct Scsi_Host *shost;
 
 	ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
 	ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
 
-	scp = advansys_srb_to_ptr(asc_dvc_varp, qdonep->d2.srb_ptr);
+	srb_tag = le32_to_cpu(qdonep->d2.srb_tag);
+	scp = scsi_host_find_tag(boardp->shost, srb_tag);
 	if (!scp)
 		return;
 
 	ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
 
-	shost = scp->device->host;
-	ASC_STATS(shost, callback);
-	ASC_DBG(1, "shost 0x%p\n", shost);
-
-	boardp = shost_priv(shost);
-	BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
+	ASC_STATS(boardp->shost, callback);
 
 	dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
 			 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
@@ -7312,7 +7249,11 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 			scsiq->d3.done_stat = QD_WITH_ERROR;
 			goto FATAL_ERR_QDONE;
 		}
-		if ((scsiq->d2.srb_ptr == 0UL) ||
+		/*
+		 * Fixme: this doesn't look right.
+		 * We can easily get an srb_tag of 0.
+		 */
+		if ((scsiq->d2.srb_tag == 0UL) ||
 		    ((scsiq->q_status & QS_ABORTED) != 0)) {
 			return (0x11);
 		} else if (scsiq->q_status == QS_DONE) {
@@ -7888,13 +7829,9 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
 
 	/*
-	 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
+	 * Set the srb_tag to the command tag.
 	 */
-	asc_scsi_q->q2.srb_ptr = advansys_ptr_to_srb(asc_dvc, scp);
-	if (asc_scsi_q->q2.srb_ptr == BAD_SRB) {
-		scp->result = HOST_BYTE(DID_SOFT_ERROR);
-		return ASC_ERROR;
-	}
+	asc_scsi_q->q2.srb_tag = cpu_to_le32(scp->request->tag);
 
 	/*
 	 * Build the ASC_SCSI_Q request.
@@ -8106,6 +8043,7 @@ static int
 adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	      ADV_SCSI_REQ_Q **adv_scsiqpp)
 {
+	u32 srb_tag = scp->request->tag;
 	adv_req_t *reqp;
 	ADV_SCSI_REQ_Q *scsiqp;
 	int i;
@@ -8116,14 +8054,11 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	 * Allocate an adv_req_t structure from the board to execute
 	 * the command.
 	 */
-	if (boardp->adv_reqp == NULL) {
+	reqp = &boardp->adv_reqp[srb_tag];
+	if (reqp->cmndp && reqp->cmndp != scp ) {
 		ASC_DBG(1, "no free adv_req_t\n");
 		ASC_STATS(scp->device->host, adv_build_noreq);
 		return ASC_BUSY;
-	} else {
-		reqp = boardp->adv_reqp;
-		boardp->adv_reqp = reqp->next_reqp;
-		reqp->next_reqp = NULL;
 	}
 
 	/*
@@ -8137,14 +8072,17 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
 
 	/*
-	 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
+	 * Set the srb_tag to the command tag.
+	 * A value of '0' is handled specially by the HBA, so
+	 * increment the value by 1.
 	 */
-	scsiqp->srb_ptr = ADV_VADDR_TO_U32(reqp);
+	scsiqp->srb_tag = cpu_to_le32(scp->request->tag);
 
 	/*
 	 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
 	 */
 	reqp->cmndp = scp;
+	scp->host_scribble = (void *)reqp;
 
 	/*
 	 * Build the ADV_SCSI_REQ_Q request.
@@ -8186,13 +8124,8 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 				   scp->device->host->sg_tablesize);
 			scsi_dma_unmap(scp);
 			scp->result = HOST_BYTE(DID_ERROR);
-
-			/*
-			 * Free the 'adv_req_t' structure by adding it back
-			 * to the board free list.
-			 */
-			reqp->next_reqp = boardp->adv_reqp;
-			boardp->adv_reqp = reqp;
+			reqp->cmndp = NULL;
+			scp->host_scribble = NULL;
 
 			return ASC_ERROR;
 		}
@@ -8201,12 +8134,10 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 
 		ret = adv_get_sglist(boardp, reqp, scp, use_sg);
 		if (ret != ADV_SUCCESS) {
-			/*
-			 * Free the adv_req_t structure by adding it back to
-			 * the board free list.
-			 */
-			reqp->next_reqp = boardp->adv_reqp;
-			boardp->adv_reqp = reqp;
+			scsi_dma_unmap(scp);
+			scp->result = HOST_BYTE(DID_ERROR);
+			reqp->cmndp = NULL;
+			scp->host_scribble = NULL;
 
 			return ret;
 		}
@@ -11267,6 +11198,7 @@ static struct scsi_host_template advansys_template = {
 	 * by enabling clustering, I/O throughput increases as well.
 	 */
 	.use_clustering = ENABLE_CLUSTERING,
+	.use_blk_tags = 1,
 };
 
 static int advansys_wide_init_chip(struct Scsi_Host *shost)
@@ -11295,7 +11227,7 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	 * If the allocation fails decrement and try again.
 	 */
 	for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
-		reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
+		reqp = kzalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
 
 		ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
 			 (ulong)sizeof(adv_req_t) * req_cnt);
@@ -11307,7 +11239,7 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	if (!reqp)
 		goto kmalloc_failed;
 
-	adv_dvc->orig_reqp = reqp;
+	board->adv_reqp = reqp;
 
 	/*
 	 * Allocate up to ADV_TOT_SG_BLOCK request structures for
@@ -11340,7 +11272,6 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	for (; req_cnt > 0; req_cnt--) {
 		reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
 	}
-	board->adv_reqp = &reqp[0];
 
 	if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
 		ASC_DBG(2, "AdvInitAsc3550Driver()\n");
@@ -11373,8 +11304,8 @@ static void advansys_wide_free_mem(struct asc_board *board)
 	struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
 	kfree(adv_dvc->carrier_buf);
 	adv_dvc->carrier_buf = NULL;
-	kfree(adv_dvc->orig_reqp);
-	adv_dvc->orig_reqp = board->adv_reqp = NULL;
+	kfree(board->adv_reqp);
+	board->adv_reqp = NULL;
 	while (board->adv_sgblkp) {
 		adv_sgblk_t *sgp = board->adv_sgblkp;
 		board->adv_sgblkp = sgp->next_sgblkp;
@@ -11674,6 +11605,11 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
 		/* Set maximum number of queues the adapter can handle. */
 		shost->can_queue = adv_dvc_varp->max_host_qng;
 	}
+	ret = scsi_init_shared_tag_map(shost, shost->can_queue);
+	if (ret) {
+		shost_printk(KERN_ERR, shost, "init tag map failed\n");
+		goto err_free_dma;
+	}
 
 	/*
 	 * Following v1.3.89, 'cmd_per_lun' is no longer needed
@@ -11945,6 +11881,7 @@ static int advansys_isa_probe(struct device *dev, unsigned int id)
 	board = shost_priv(shost);
 	board->irq = advansys_isa_irq_no(iop_base);
 	board->dev = dev;
+	board->shost = shost;
 
 	err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
 	if (err)
@@ -12027,6 +11964,7 @@ static int advansys_vlb_probe(struct device *dev, unsigned int id)
 	board = shost_priv(shost);
 	board->irq = advansys_vlb_irq_no(iop_base);
 	board->dev = dev;
+	board->shost = shost;
 
 	err = advansys_board_found(shost, iop_base, ASC_IS_VL);
 	if (err)
@@ -12134,6 +12072,7 @@ static int advansys_eisa_probe(struct device *dev)
 		board = shost_priv(shost);
 		board->irq = irq;
 		board->dev = dev;
+		board->shost = shost;
 
 		err = advansys_board_found(shost, ioport, ASC_IS_EISA);
 		if (!err) {
@@ -12250,6 +12189,7 @@ static int advansys_pci_probe(struct pci_dev *pdev,
 	board = shost_priv(shost);
 	board->irq = pdev->irq;
 	board->dev = &pdev->dev;
+	board->shost = shost;
 
 	if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
 	    pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
-- 
1.8.5.2


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

* [PATCH 03/12] advansys: use DMA-API for mapping sense buffer
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 01/12] advansys: use host_reset Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 02/12] advansys: use shared host tag map for command lookup Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 04/12] advansys: Use DMA-API for carrier buffer Hannes Reinecke
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 6af2a52..4979e5a 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -309,7 +309,7 @@ typedef struct asc_scsiq_1 {
 	uchar target_lun;
 	ASC_PADDR data_addr;
 	ASC_DCNT data_cnt;
-	ASC_PADDR sense_addr;
+	__le32 sense_addr;
 	uchar sense_len;
 	uchar extra_bytes;
 } ASC_SCSIQ_1;
@@ -6110,6 +6110,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	adv_sgblk_t *sgblkp;
 	struct scsi_cmnd *scp;
 	ADV_DCNT resid_cnt;
+	dma_addr_t sense_addr;
 
 	ASC_DBG(1, "adv_dvc_varp 0x%p, scsiqp 0x%p\n",
 		adv_dvc_varp, scsiqp);
@@ -6147,6 +6148,10 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	ASC_STATS(boardp->shost, callback);
 	ASC_DBG(1, "shost 0x%p\n", boardp->shost);
 
+	sense_addr = le32_to_cpu(scsiqp->sense_addr);
+	dma_unmap_single(boardp->dev, sense_addr,
+			 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+
 	/*
 	 * 'done_status' contains the command's ending status.
 	 */
@@ -7930,18 +7935,16 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  *      ADV_ERROR(-1) - SG List creation failed
  */
 static int
-adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
-	       int use_sg)
+adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
+	       ADV_SCSI_REQ_Q *scsiqp, struct scsi_cmnd *scp, int use_sg)
 {
 	adv_sgblk_t *sgblkp;
-	ADV_SCSI_REQ_Q *scsiqp;
 	struct scatterlist *slp;
 	int sg_elem_cnt;
 	ADV_SG_BLOCK *sg_block, *prev_sg_block;
 	ADV_PADDR sg_block_paddr;
 	int i;
 
-	scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
 	slp = scsi_sglist(scp);
 	sg_elem_cnt = use_sg;
 	prev_sg_block = NULL;
@@ -8046,9 +8049,9 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	u32 srb_tag = scp->request->tag;
 	adv_req_t *reqp;
 	ADV_SCSI_REQ_Q *scsiqp;
-	int i;
 	int ret;
 	int use_sg;
+	dma_addr_t sense_addr;
 
 	/*
 	 * Allocate an adv_req_t structure from the board to execute
@@ -8091,19 +8094,23 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	/* Set CDB length and copy it to the request structure.  */
 	scsiqp->cdb_len = scp->cmd_len;
 	/* Copy first 12 CDB bytes to cdb[]. */
-	for (i = 0; i < scp->cmd_len && i < 12; i++) {
-		scsiqp->cdb[i] = scp->cmnd[i];
-	}
+	memcpy(scsiqp->cdb, scp->cmnd, scp->cmd_len < 12 ? scp->cmd_len : 12);
 	/* Copy last 4 CDB bytes, if present, to cdb16[]. */
-	for (; i < scp->cmd_len; i++) {
-		scsiqp->cdb16[i - 12] = scp->cmnd[i];
+	if (scp->cmd_len > 12) {
+		int cdb16_len = scp->cmd_len - 12;
+
+		memcpy(scsiqp->cdb16, &scp->cmnd[12], cdb16_len);
 	}
 
 	scsiqp->target_id = scp->device->id;
 	scsiqp->target_lun = scp->device->lun;
 
-	scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
-	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
+	sense_addr = dma_map_single(boardp->dev, scp->sense_buffer,
+				    SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+	scsiqp->sense_addr = cpu_to_le32(sense_addr);
+	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
+	dma_cache_sync(boardp->dev, scp->sense_buffer,
+		       SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
 
 	/* Build ADV_SCSI_REQ_Q */
 
@@ -8132,7 +8139,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 
 		scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp));
 
-		ret = adv_get_sglist(boardp, reqp, scp, use_sg);
+		ret = adv_get_sglist(boardp, reqp, scsiqp, scp, use_sg);
 		if (ret != ADV_SUCCESS) {
 			scsi_dma_unmap(scp);
 			scp->result = HOST_BYTE(DID_ERROR);
-- 
1.8.5.2


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

* [PATCH 04/12] advansys: Use DMA-API for carrier buffer
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (2 preceding siblings ...)
  2014-12-03 11:44 ` [PATCH 03/12] advansys: use DMA-API for mapping sense buffer Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 05/12] advansys: Use DMA-API for mapping request blocks Hannes Reinecke
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 238 +++++++++++++++++++++---------------------------
 1 file changed, 104 insertions(+), 134 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4979e5a..ec8f122 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -963,8 +963,6 @@ typedef struct asc_mc_saved {
 #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
 #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
 
-#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
-
 /*
  * Define total number of simultaneous maximum element scatter-gather
  * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
@@ -1745,16 +1743,16 @@ typedef struct adveep_38C1600_config {
  * little-endian.
  */
 typedef struct adv_carr_t {
-	ADV_VADDR carr_va;	/* Carrier Virtual Address */
-	ADV_PADDR carr_pa;	/* Carrier Physical Address */
-	ADV_VADDR areq_vpa;	/* ASC_SCSI_REQ_Q Virtual or Physical Address */
+	__le32 carr_va;	/* Carrier Virtual Address */
+	__le32 carr_pa;	/* Carrier Physical Address */
+	__le32 areq_vpa;	/* ASC_SCSI_REQ_Q Virtual or Physical Address */
 	/*
 	 * next_vpa [31:4]            Carrier Virtual or Physical Next Pointer
 	 *
 	 * next_vpa [3:1]             Reserved Bits
 	 * next_vpa [0]               Done Flag set in Response Queue.
 	 */
-	ADV_VADDR next_vpa;
+	__le32 next_vpa;
 } ADV_CARR_T;
 
 /*
@@ -1768,11 +1766,14 @@ typedef struct adv_carr_t {
 
 #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
 
-#define ADV_CARRIER_NUM_PAGE_CROSSING \
-    (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
+/*
+ * Each carrier is 64 bytes, and we need three additional
+ * carrier for icq, irq, and the termination carrier.
+ */
+#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 3)
 
 #define ADV_CARRIER_BUFSIZE \
-    ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
+    (ADV_CARRIER_COUNT * sizeof(ADV_CARR_T))
 
 /*
  * ASC_SCSI_REQ_Q 'a_flag' definitions
@@ -1844,8 +1845,8 @@ typedef struct adv_scsi_req_q {
 	uchar target_lun;	/* Device target logical unit number. */
 	ADV_PADDR data_addr;	/* Data buffer physical address. */
 	ADV_DCNT data_cnt;	/* Data count. Ucode sets to residual. */
-	ADV_PADDR sense_addr;
-	ADV_PADDR carr_pa;
+	__le32 sense_addr;
+	__le32 carr_pa;
 	uchar mflag;
 	uchar sense_len;
 	uchar cdb_len;		/* SCSI CDB length. Must <= 16 bytes. */
@@ -1856,19 +1857,18 @@ typedef struct adv_scsi_req_q {
 	uchar sg_working_ix;
 	uchar cdb[12];		/* SCSI CDB bytes 0-11. */
 	ADV_PADDR sg_real_addr;	/* SG list physical address. */
-	ADV_PADDR scsiq_rptr;
+	__le32 scsiq_rptr;
 	uchar cdb16[4];		/* SCSI CDB bytes 12-15. */
-	ADV_VADDR scsiq_ptr;
-	ADV_VADDR carr_va;
+	__le32 scsiq_ptr;
+	__le32 carr_va;
 	/*
 	 * End of microcode structure - 60 bytes. The rest of the structure
 	 * is used by the Adv Library and ignored by the microcode.
 	 */
 	__le32 srb_tag;
-	ADV_SG_BLOCK *sg_list_ptr;	/* SG list virtual address. */
-	char *vdata_addr;	/* Data buffer virtual address. */
 	uchar a_flag;
-	uchar pad[2];		/* Pad out to a word boundary. */
+	uchar pad[3];		/* Pad out to a word boundary. */
+	ADV_SG_BLOCK *sg_list_ptr;	/* SG list virtual address. */
 } ADV_SCSI_REQ_Q;
 
 /*
@@ -1935,8 +1935,9 @@ typedef struct adv_dvc_var {
 	uchar chip_scsi_id;	/* chip SCSI target ID */
 	uchar chip_type;
 	uchar bist_err_code;
-	ADV_CARR_T *carrier_buf;
+	ADV_CARR_T *carrier;
 	ADV_CARR_T *carr_freelist;	/* Carrier free list. */
+	dma_addr_t carrier_addr;
 	ADV_CARR_T *icq_sp;	/* Initiator command queue stopper pointer. */
 	ADV_CARR_T *irq_sp;	/* Initiator response queue stopper pointer. */
 	ushort carr_pending_cnt;	/* Count of pending carriers. */
@@ -2468,12 +2469,11 @@ static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
 	printk("  start_motor 0x%x, scsi_reset_wait 0x%x\n",
 	       (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
 
-	printk("  max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
+	printk("  max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%p\n",
 	       (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
-	       (ulong)h->carr_freelist);
+	       h->carr_freelist);
 
-	printk("  icq_sp 0x%lx, irq_sp 0x%lx\n",
-	       (ulong)h->icq_sp, (ulong)h->irq_sp);
+	printk("  icq_sp 0x%p, irq_sp 0x%p\n", h->icq_sp, h->irq_sp);
 
 	printk("  no_scam 0x%x, tagqng_able 0x%x\n",
 	       (unsigned)h->no_scam, (unsigned)h->tagqng_able);
@@ -2678,8 +2678,8 @@ static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
 	printk("  target_id %u, target_lun %u, srb_tag 0x%x, a_flag 0x%x\n",
 	       q->target_id, q->target_lun, q->srb_tag, q->a_flag);
 
-	printk("  cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
-	       q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
+	printk("  cntl 0x%x, data_addr 0x%lx\n",
+	       q->cntl, (ulong)le32_to_cpu(q->data_addr));
 
 	printk("  data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
 	       (ulong)le32_to_cpu(q->data_cnt),
@@ -4345,38 +4345,61 @@ static int AdvLoadMicrocode(AdvPortAddr iop_base, const unsigned char *buf,
 	return 0;
 }
 
-static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
+static void AdvBuildCarrierFreelist(struct adv_dvc_var *adv_dvc)
 {
-	ADV_CARR_T *carrp;
-	ADV_SDCNT buf_size;
-	ADV_PADDR carr_paddr;
+	off_t carr_offset = 0, next_offset;
+	dma_addr_t carr_paddr;
+	int carr_num = ADV_CARRIER_BUFSIZE / sizeof(ADV_CARR_T), i;
 
-	carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
-	asc_dvc->carr_freelist = NULL;
-	if (carrp == asc_dvc->carrier_buf) {
-		buf_size = ADV_CARRIER_BUFSIZE;
-	} else {
-		buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
+	for (i = 0; i < carr_num; i++) {
+		carr_offset = i * sizeof(ADV_CARR_T);
+		/* Get physical address of the carrier 'carrp'. */
+		carr_paddr = adv_dvc->carrier_addr + carr_offset;
+
+		adv_dvc->carrier[i].carr_pa = cpu_to_le32(carr_paddr);
+		adv_dvc->carrier[i].carr_va = cpu_to_le32(carr_offset);
+		adv_dvc->carrier[i].areq_vpa = 0;
+		next_offset = carr_offset + sizeof(ADV_CARR_T);
+		if (i == carr_num)
+			next_offset = ~0;
+		adv_dvc->carrier[i].next_vpa = cpu_to_le32(next_offset);
 	}
+	/*
+	 * We cannot have a carrier with 'carr_va' of '0', as
+	 * a reference to this carrier would be interpreted as
+	 * list termination.
+	 * So start at carrier 1 with the freelist.
+	 */
+	adv_dvc->carr_freelist = &adv_dvc->carrier[1];
+}
 
-	do {
-		/* Get physical address of the carrier 'carrp'. */
-		carr_paddr = cpu_to_le32(virt_to_bus(carrp));
+static ADV_CARR_T *adv_get_carrier(struct adv_dvc_var *adv_dvc, u32 offset)
+{
+	int index;
 
-		buf_size -= sizeof(ADV_CARR_T);
+	BUG_ON(offset > ADV_CARRIER_BUFSIZE);
 
-		carrp->carr_pa = carr_paddr;
-		carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
+	index = offset / sizeof(ADV_CARR_T);
+	return &adv_dvc->carrier[index];
+}
 
-		/*
-		 * Insert the carrier at the beginning of the freelist.
-		 */
-		carrp->next_vpa =
-			cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
-		asc_dvc->carr_freelist = carrp;
+static ADV_CARR_T *adv_get_next_carrier(struct adv_dvc_var *adv_dvc)
+{
+	ADV_CARR_T *carrp = adv_dvc->carr_freelist;
+	u32 next_vpa = le32_to_cpu(carrp->next_vpa);
+
+	if (next_vpa == 0 || next_vpa == ~0) {
+		ASC_DBG(1, "invalid vpa offset 0x%x\n", next_vpa);
+		return NULL;
+	}
 
-		carrp++;
-	} while (buf_size > 0);
+	adv_dvc->carr_freelist = adv_get_carrier(adv_dvc, next_vpa);
+	/*
+	 * insert stopper carrier to terminate list
+	 */
+	carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
+
+	return carrp;
 }
 
 /*
@@ -4865,17 +4888,11 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
 	 * Set-up the Host->RISC Initiator Command Queue (ICQ).
 	 */
 
-	if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->icq_sp) {
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
-
-	/*
-	 * The first command issued will be placed in the stopper carrier.
-	 */
-	asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC ICQ physical address start value.
@@ -4885,21 +4902,11 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
 	/*
 	 * Set-up the RISC->Host Initiator Response Queue (IRQ).
 	 */
-	if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->irq_sp) {
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
-
-	/*
-	 * The first command completed by the RISC will be placed in
-	 * the stopper.
-	 *
-	 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
-	 * completed the RISC will set the ASC_RQ_STOPPER bit.
-	 */
-	asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC IRQ physical address start value.
@@ -5362,17 +5369,12 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
 	 * Set-up the Host->RISC Initiator Command Queue (ICQ).
 	 */
 
-	if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->icq_sp) {
+		ASC_DBG(0, "Failed to get ICQ carrier\n");
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
-
-	/*
-	 * The first command issued will be placed in the stopper carrier.
-	 */
-	asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC ICQ physical address start value.
@@ -5383,21 +5385,12 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
 	/*
 	 * Set-up the RISC->Host Initiator Response Queue (IRQ).
 	 */
-	if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->irq_sp) {
+		ASC_DBG(0, "Failed to get IRQ carrier\n");
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
-
-	/*
-	 * The first command completed by the RISC will be placed in
-	 * the stopper.
-	 *
-	 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
-	 * completed the RISC will set the ASC_RQ_STOPPER bit.
-	 */
-	asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC IRQ physical address start value.
@@ -5872,17 +5865,11 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
 	/*
 	 * Set-up the Host->RISC Initiator Command Queue (ICQ).
 	 */
-	if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->icq_sp) {
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
-
-	/*
-	 * The first command issued will be placed in the stopper carrier.
-	 */
-	asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC ICQ physical address start value. Initialize the
@@ -5896,21 +5883,11 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
 	/*
 	 * Set-up the RISC->Host Initiator Response Queue (IRQ).
 	 */
-	if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
+	asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc);
+	if (!asc_dvc->irq_sp) {
 		asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
 		return ADV_ERROR;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
-
-	/*
-	 * The first command completed by the RISC will be placed in
-	 * the stopper.
-	 *
-	 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
-	 * completed the RISC will set the ASC_RQ_STOPPER bit.
-	 */
-	asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
 
 	/*
 	 * Set RISC IRQ physical address start value.
@@ -6350,11 +6327,10 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
 		 * stopper carrier.
 		 */
 		free_carrp = asc_dvc->irq_sp;
-		asc_dvc->irq_sp = (ADV_CARR_T *)
-		    ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
+		asc_dvc->irq_sp = adv_get_carrier(asc_dvc,
+						  ASC_GET_CARRP(irq_next_vpa));
 
-		free_carrp->next_vpa =
-		    cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
+		free_carrp->next_vpa = asc_dvc->carr_freelist->carr_va;
 		asc_dvc->carr_freelist = free_carrp;
 		asc_dvc->carr_pending_cnt--;
 
@@ -8119,7 +8095,6 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 		/* Zero-length transfer */
 		reqp->sgblkp = NULL;
 		scsiqp->data_cnt = 0;
-		scsiqp->vdata_addr = NULL;
 
 		scsiqp->data_addr = 0;
 		scsiqp->sg_list_ptr = NULL;
@@ -8768,19 +8743,13 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
 	 * Allocate a carrier ensuring at least one carrier always
 	 * remains on the freelist and initialize fields.
 	 */
-	if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
+	new_carrp = adv_get_next_carrier(asc_dvc);
+	if (!new_carrp) {
+		ASC_DBG(1, "No free carriers\n");
 		return ADV_BUSY;
 	}
-	asc_dvc->carr_freelist = (ADV_CARR_T *)
-	    ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
-	asc_dvc->carr_pending_cnt++;
 
-	/*
-	 * Set the carrier to be a stopper by setting 'next_vpa'
-	 * to the stopper value. The current stopper will be changed
-	 * below to point to the new stopper.
-	 */
-	new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
+	asc_dvc->carr_pending_cnt++;
 
 	/*
 	 * Clear the ADV_SCSI_REQ_Q done flag.
@@ -8796,11 +8765,7 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
 	scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
 	scsiq->scsiq_rptr = req_paddr;
 
-	scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
-	/*
-	 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
-	 * order during initialization.
-	 */
+	scsiq->carr_va = asc_dvc->icq_sp->carr_va;
 	scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
 
 	/*
@@ -11220,12 +11185,13 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 
 	/*
 	 * Allocate buffer carrier structures. The total size
-	 * is about 4 KB, so allocate all at once.
+	 * is about 8 KB, so allocate all at once.
 	 */
-	adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
-	ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
+	adv_dvc->carrier = dma_alloc_coherent(board->dev,
+		ADV_CARRIER_BUFSIZE, &adv_dvc->carrier_addr, GFP_KERNEL);
+	ASC_DBG(1, "carrier 0x%p\n", adv_dvc->carrier);
 
-	if (!adv_dvc->carrier_buf)
+	if (!adv_dvc->carrier)
 		goto kmalloc_failed;
 
 	/*
@@ -11309,8 +11275,12 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 static void advansys_wide_free_mem(struct asc_board *board)
 {
 	struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
-	kfree(adv_dvc->carrier_buf);
-	adv_dvc->carrier_buf = NULL;
+
+	if (adv_dvc->carrier) {
+		dma_free_coherent(board->dev, ADV_CARRIER_BUFSIZE,
+				  adv_dvc->carrier, adv_dvc->carrier_addr);
+		adv_dvc->carrier = NULL;
+	}
 	kfree(board->adv_reqp);
 	board->adv_reqp = NULL;
 	while (board->adv_sgblkp) {
-- 
1.8.5.2


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

* [PATCH 05/12] advansys: Use DMA-API for mapping request blocks
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (3 preceding siblings ...)
  2014-12-03 11:44 ` [PATCH 04/12] advansys: Use DMA-API for carrier buffer Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-03 11:44 ` [PATCH 06/12] advansys: Use dma_pool for sg elements Hannes Reinecke
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 104 +++++++++++++++++++++++++-----------------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index ec8f122..c5395b5 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1894,11 +1894,11 @@ typedef struct adv_sgblk {
 
 typedef struct adv_req {
 	ADV_SCSI_REQ_Q scsi_req_q;	/* Adv Library request structure. */
-	uchar align[32];	/* Request structure padding. */
+	uchar align[24];	/* Request structure padding. */
 	struct scsi_cmnd *cmndp;	/* Mid-Level SCSI command pointer. */
+	dma_addr_t req_addr;
 	adv_sgblk_t *sgblkp;	/* Adv Library scatter-gather pointer. */
-	struct adv_req *next_reqp;	/* Next Request Structure. */
-} adv_req_t;
+} adv_req_t __aligned(32);
 
 /*
  * Adapter operation variable structure.
@@ -2380,6 +2380,8 @@ struct asc_board {
 	void __iomem *ioremap_addr;	/* I/O Memory remap address. */
 	ushort ioport;		/* I/O Port address. */
 	adv_req_t *adv_reqp;	/* Request structures. */
+	dma_addr_t adv_reqp_addr;
+	size_t adv_reqp_size;
 	adv_sgblk_t *adv_sgblkp;	/* Scatter-gather structures. */
 	ushort bios_signature;	/* BIOS Signature. */
 	ushort bios_version;	/* BIOS Version. */
@@ -4403,6 +4405,17 @@ static ADV_CARR_T *adv_get_next_carrier(struct adv_dvc_var *adv_dvc)
 }
 
 /*
+ * 'offset' is the index in the request pointer array
+ */
+static adv_req_t * adv_get_reqp(struct adv_dvc_var *adv_dvc, u32 offset)
+{
+	struct asc_board *boardp = adv_dvc->drv_ptr;
+
+	BUG_ON(offset > adv_dvc->max_host_qng);
+	return &boardp->adv_reqp[offset];
+}
+
+/*
  * Send an idle command to the chip and wait for completion.
  *
  * Command completion is polled for once per microsecond.
@@ -6178,6 +6191,10 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 				scp->result = STATUS_BYTE(scsiqp->scsi_status);
 			}
 			break;
+		case QHSTA_M_SEL_TIMEOUT:
+			ASC_DBG(1, "Selection timeout\n");
+			scp->result = HOST_BYTE(DID_NO_CONNECT);
+			break;
 
 		default:
 			/* Some other QHSTA error occurred. */
@@ -6255,6 +6272,7 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
 	ADV_CARR_T *free_carrp;
 	ADV_VADDR irq_next_vpa;
 	ADV_SCSI_REQ_Q *scsiq;
+	adv_req_t *reqp;
 
 	iop_base = asc_dvc->iop_base;
 
@@ -6307,8 +6325,11 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
 		 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
 		 * in AdvExeScsiQueue().
 		 */
-		scsiq = (ADV_SCSI_REQ_Q *)
-		    ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
+		u32 pa_offset = le32_to_cpu(asc_dvc->irq_sp->areq_vpa);
+		ASC_DBG(1, "irq_sp %p areq_vpa %u\n",
+			asc_dvc->irq_sp, pa_offset);
+		reqp = adv_get_reqp(asc_dvc, pa_offset);
+		scsiq = &reqp->scsi_req_q;
 
 		/*
 		 * Request finished with good status and the queue was not
@@ -8020,7 +8041,7 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
  */
 static int
 adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
-	      ADV_SCSI_REQ_Q **adv_scsiqpp)
+	      adv_req_t **adv_reqpp)
 {
 	u32 srb_tag = scp->request->tag;
 	adv_req_t *reqp;
@@ -8040,10 +8061,9 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 		return ASC_BUSY;
 	}
 
-	/*
-	 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
-	 */
-	scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
+	reqp->req_addr = boardp->adv_reqp_addr + (srb_tag * sizeof(adv_req_t));
+
+	scsiqp = &reqp->scsi_req_q;
 
 	/*
 	 * Initialize the structure.
@@ -8058,7 +8078,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	scsiqp->srb_tag = cpu_to_le32(scp->request->tag);
 
 	/*
-	 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
+	 * Set 'host_scribble' to point to the adv_req_t structure.
 	 */
 	reqp->cmndp = scp;
 	scp->host_scribble = (void *)reqp;
@@ -8132,7 +8152,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
 	ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
 
-	*adv_scsiqpp = scsiqp;
+	*adv_reqpp = reqp;
 
 	return ASC_NOERROR;
 }
@@ -8722,11 +8742,11 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  *      ADV_ERROR(-1) -  Invalid ADV_SCSI_REQ_Q request structure
  *                       host IC error.
  */
-static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
+static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, adv_req_t *reqp)
 {
 	AdvPortAddr iop_base;
-	ADV_PADDR req_paddr;
 	ADV_CARR_T *new_carrp;
+	ADV_SCSI_REQ_Q *scsiq = &reqp->scsi_req_q;
 
 	/*
 	 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
@@ -8756,14 +8776,9 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
 	 */
 	scsiq->a_flag &= ~ADV_SCSIQ_DONE;
 
-	req_paddr = virt_to_bus(scsiq);
-	BUG_ON(req_paddr & 31);
-	/* Wait for assertion before making little-endian */
-	req_paddr = cpu_to_le32(req_paddr);
-
 	/* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
-	scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
-	scsiq->scsiq_rptr = req_paddr;
+	scsiq->scsiq_ptr = cpu_to_le32(scsiq->srb_tag);
+	scsiq->scsiq_rptr = cpu_to_le32(reqp->req_addr);
 
 	scsiq->carr_va = asc_dvc->icq_sp->carr_va;
 	scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
@@ -8773,7 +8788,7 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
 	 * the microcode. The newly allocated stopper will become the new
 	 * stopper.
 	 */
-	asc_dvc->icq_sp->areq_vpa = req_paddr;
+	asc_dvc->icq_sp->areq_vpa = scsiq->scsiq_rptr;
 
 	/*
 	 * Set the 'next_vpa' pointer for the old stopper to be the
@@ -8840,9 +8855,9 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 		err_code = asc_dvc->err_code;
 	} else {
 		ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
-		ADV_SCSI_REQ_Q *adv_scsiqp;
+		adv_req_t *adv_reqp;
 
-		switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
+		switch (adv_build_req(boardp, scp, &adv_reqp)) {
 		case ASC_NOERROR:
 			ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
 			break;
@@ -8862,7 +8877,7 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 			return ASC_ERROR;
 		}
 
-		ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
+		ret = AdvExeScsiQueue(adv_dvc, adv_reqp);
 		err_code = adv_dvc->err_code;
 	}
 
@@ -8877,6 +8892,7 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 		ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
 		break;
 	case ASC_BUSY:
+		ASC_DBG(1, "ExeScsiQueue() ASC_BUSY\n");
 		ASC_STATS(scp->device->host, exe_busy);
 		break;
 	case ASC_ERROR:
@@ -11177,8 +11193,6 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 {
 	struct asc_board *board = shost_priv(shost);
 	struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
-	int req_cnt = 0;
-	adv_req_t *reqp = NULL;
 	int sg_cnt = 0;
 	adv_sgblk_t *sgp;
 	int warn_code, err_code;
@@ -11199,20 +11213,19 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	 * board. The total size is about 16 KB, so allocate all at once.
 	 * If the allocation fails decrement and try again.
 	 */
-	for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
-		reqp = kzalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
-
-		ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
-			 (ulong)sizeof(adv_req_t) * req_cnt);
-
-		if (reqp)
-			break;
+	board->adv_reqp_size = adv_dvc->max_host_qng * sizeof(adv_req_t);
+	if (board->adv_reqp_size & 0x1f) {
+		ASC_DBG(1, "unaligned reqp %lu bytes\n", sizeof(adv_req_t));
+		board->adv_reqp_size = ADV_32BALIGN(board->adv_reqp_size);
 	}
+	board->adv_reqp = dma_alloc_coherent(board->dev, board->adv_reqp_size,
+		&board->adv_reqp_addr, GFP_KERNEL);
 
-	if (!reqp)
+	if (!board->adv_reqp)
 		goto kmalloc_failed;
 
-	board->adv_reqp = reqp;
+	ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", board->adv_reqp,
+		adv_dvc->max_host_qng, board->adv_reqp_size);
 
 	/*
 	 * Allocate up to ADV_TOT_SG_BLOCK request structures for
@@ -11236,16 +11249,6 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	if (!board->adv_sgblkp)
 		goto kmalloc_failed;
 
-	/*
-	 * Point 'adv_reqp' to the request structures and
-	 * link them together.
-	 */
-	req_cnt--;
-	reqp[req_cnt].next_reqp = NULL;
-	for (; req_cnt > 0; req_cnt--) {
-		reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
-	}
-
 	if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
 		ASC_DBG(2, "AdvInitAsc3550Driver()\n");
 		warn_code = AdvInitAsc3550Driver(adv_dvc);
@@ -11281,8 +11284,11 @@ static void advansys_wide_free_mem(struct asc_board *board)
 				  adv_dvc->carrier, adv_dvc->carrier_addr);
 		adv_dvc->carrier = NULL;
 	}
-	kfree(board->adv_reqp);
-	board->adv_reqp = NULL;
+	if (board->adv_reqp) {
+		dma_free_coherent(board->dev, board->adv_reqp_size,
+				  board->adv_reqp, board->adv_reqp_addr);
+		board->adv_reqp = NULL;
+	}
 	while (board->adv_sgblkp) {
 		adv_sgblk_t *sgp = board->adv_sgblkp;
 		board->adv_sgblkp = sgp->next_sgblkp;
-- 
1.8.5.2


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

* [PATCH 06/12] advansys: Use dma_pool for sg elements
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (4 preceding siblings ...)
  2014-12-03 11:44 ` [PATCH 05/12] advansys: Use DMA-API for mapping request blocks Hannes Reinecke
@ 2014-12-03 11:44 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 07/12] advansys: use 'bool' instead of 'int' Hannes Reinecke
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 102 ++++++++++++++++++++----------------------------
 1 file changed, 42 insertions(+), 60 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index c5395b5..0aea820 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1820,10 +1820,10 @@ typedef struct asc_sg_block {
 	uchar reserved2;
 	uchar reserved3;
 	uchar sg_cnt;		/* Valid entries in block. */
-	ADV_PADDR sg_ptr;	/* Pointer to next sg block. */
+	__le32 sg_ptr;	/* Pointer to next sg block. */
 	struct {
-		ADV_PADDR sg_addr;	/* SG element address. */
-		ADV_DCNT sg_count;	/* SG element count. */
+		__le32 sg_addr;	/* SG element address. */
+		__le32 sg_count;	/* SG element count. */
 	} sg_list[NO_OF_SG_PER_BLOCK];
 } ADV_SG_BLOCK;
 
@@ -1888,7 +1888,7 @@ typedef struct adv_scsi_req_q {
  */
 typedef struct adv_sgblk {
 	ADV_SG_BLOCK sg_block;	/* Sgblock structure. */
-	uchar align[32];	/* Sgblock structure padding. */
+	dma_addr_t sg_addr;	/* Physical address */
 	struct adv_sgblk *next_sgblkp;	/* Next scatter-gather structure. */
 } adv_sgblk_t;
 
@@ -2382,7 +2382,7 @@ struct asc_board {
 	adv_req_t *adv_reqp;	/* Request structures. */
 	dma_addr_t adv_reqp_addr;
 	size_t adv_reqp_size;
-	adv_sgblk_t *adv_sgblkp;	/* Scatter-gather structures. */
+	struct dma_pool *adv_sgblk_pool;	/* Scatter-gather structures. */
 	ushort bios_signature;	/* BIOS Signature. */
 	ushort bios_version;	/* BIOS Version. */
 	ushort bios_codeseg;	/* BIOS Code Segment. */
@@ -2674,6 +2674,7 @@ static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
 {
 	int sg_blk_cnt;
 	struct asc_sg_block *sg_ptr;
+	adv_sgblk_t *sgblkp;
 
 	printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
 
@@ -2700,21 +2701,15 @@ static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
 
 	/* Display the request's ADV_SG_BLOCK structures. */
 	if (q->sg_list_ptr != NULL) {
+		sgblkp = container_of(q->sg_list_ptr, adv_sgblk_t, sg_block);
 		sg_blk_cnt = 0;
-		while (1) {
-			/*
-			 * 'sg_ptr' is a physical address. Convert it to a virtual
-			 * address by indexing 'sg_blk_cnt' into the virtual address
-			 * array 'sg_list_ptr'.
-			 *
-			 * XXX - Assumes all SG physical blocks are virtually contiguous.
-			 */
-			sg_ptr =
-			    &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
+		while (sgblkp) {
+			sg_ptr = &sgblkp->sg_block;
 			asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
 			if (sg_ptr->sg_ptr == 0) {
 				break;
 			}
+			sgblkp = sgblkp->next_sgblkp;
 			sg_blk_cnt++;
 		}
 	}
@@ -6237,9 +6232,8 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 		/* Remove 'sgblkp' from the request list. */
 		reqp->sgblkp = sgblkp->next_sgblkp;
 
-		/* Add 'sgblkp' to the board free list. */
-		sgblkp->next_sgblkp = boardp->adv_sgblkp;
-		boardp->adv_sgblkp = sgblkp;
+		dma_pool_free(boardp->adv_sgblk_pool, sgblkp,
+			      sgblkp->sg_addr);
 	}
 
 	ASC_DBG(1, "done\n");
@@ -7935,15 +7929,16 @@ static int
 adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
 	       ADV_SCSI_REQ_Q *scsiqp, struct scsi_cmnd *scp, int use_sg)
 {
-	adv_sgblk_t *sgblkp;
+	adv_sgblk_t *sgblkp, *prev_sgblkp;
 	struct scatterlist *slp;
 	int sg_elem_cnt;
 	ADV_SG_BLOCK *sg_block, *prev_sg_block;
-	ADV_PADDR sg_block_paddr;
+	dma_addr_t sgblk_paddr;
 	int i;
 
 	slp = scsi_sglist(scp);
 	sg_elem_cnt = use_sg;
+	prev_sgblkp = NULL;
 	prev_sg_block = NULL;
 	reqp->sgblkp = NULL;
 
@@ -7953,7 +7948,9 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
 		 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
 		 * (15) scatter-gather elements.
 		 */
-		if ((sgblkp = boardp->adv_sgblkp) == NULL) {
+		sgblkp = dma_pool_alloc(boardp->adv_sgblk_pool, GFP_KERNEL,
+					&sgblk_paddr);
+		if (!sgblkp) {
 			ASC_DBG(1, "no free adv_sgblk_t\n");
 			ASC_STATS(scp->device->host, adv_build_nosg);
 
@@ -7964,24 +7961,16 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
 			while ((sgblkp = reqp->sgblkp) != NULL) {
 				/* Remove 'sgblkp' from the request list. */
 				reqp->sgblkp = sgblkp->next_sgblkp;
-
-				/* Add 'sgblkp' to the board free list. */
-				sgblkp->next_sgblkp = boardp->adv_sgblkp;
-				boardp->adv_sgblkp = sgblkp;
+				sgblkp->next_sgblkp = NULL;
+				dma_pool_free(boardp->adv_sgblk_pool, sgblkp,
+					      sgblkp->sg_addr);
 			}
 			return ASC_BUSY;
 		}
-
 		/* Complete 'adv_sgblk_t' board allocation. */
-		boardp->adv_sgblkp = sgblkp->next_sgblkp;
+		sgblkp->sg_addr = sgblk_paddr;
 		sgblkp->next_sgblkp = NULL;
-
-		/*
-		 * Get 8 byte aligned virtual and physical addresses
-		 * for the allocated ADV_SG_BLOCK structure.
-		 */
-		sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
-		sg_block_paddr = virt_to_bus(sg_block);
+		sg_block = &sgblkp->sg_block;
 
 		/*
 		 * Check if this is the first 'adv_sgblk_t' for the
@@ -7996,17 +7985,16 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
 			 * address pointers.
 			 */
 			scsiqp->sg_list_ptr = sg_block;
-			scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
+			scsiqp->sg_real_addr = cpu_to_le32(sgblk_paddr);
 		} else {
 			/* Request's second or later scatter-gather block. */
-			sgblkp->next_sgblkp = reqp->sgblkp;
-			reqp->sgblkp = sgblkp;
+			prev_sgblkp->next_sgblkp = reqp->sgblkp;
 
 			/*
 			 * Point the previous ADV_SG_BLOCK structure to
 			 * the newly allocated ADV_SG_BLOCK structure.
 			 */
-			prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
+			prev_sg_block->sg_ptr = cpu_to_le32(sgblk_paddr);
 		}
 
 		for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
@@ -8017,15 +8005,19 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
 			ASC_STATS_ADD(scp->device->host, xfer_sect,
 				      DIV_ROUND_UP(sg_dma_len(slp), 512));
 
-			if (--sg_elem_cnt == 0) {	/* Last ADV_SG_BLOCK and scatter-gather entry. */
+			if (--sg_elem_cnt == 0) {
+				/*
+				 * Last ADV_SG_BLOCK and scatter-gather entry.
+				 */
 				sg_block->sg_cnt = i + 1;
-				sg_block->sg_ptr = 0L;	/* Last ADV_SG_BLOCK in list. */
+				sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
 				return ADV_SUCCESS;
 			}
 			slp++;
 		}
 		sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
 		prev_sg_block = sg_block;
+		prev_sgblkp = sgblkp;
 	}
 }
 
@@ -11193,8 +11185,7 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 {
 	struct asc_board *board = shost_priv(shost);
 	struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
-	int sg_cnt = 0;
-	adv_sgblk_t *sgp;
+	size_t sgblk_pool_size;
 	int warn_code, err_code;
 
 	/*
@@ -11231,22 +11222,14 @@ static int advansys_wide_init_chip(struct Scsi_Host *shost)
 	 * Allocate up to ADV_TOT_SG_BLOCK request structures for
 	 * the Wide board. Each structure is about 136 bytes.
 	 */
-	board->adv_sgblkp = NULL;
-	for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
-		sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
-
-		if (!sgp)
-			break;
-
-		sgp->next_sgblkp = board->adv_sgblkp;
-		board->adv_sgblkp = sgp;
-
-	}
+	sgblk_pool_size = sizeof(adv_sgblk_t) * ADV_TOT_SG_BLOCK;
+	board->adv_sgblk_pool = dma_pool_create("adv_sgblk", board->dev,
+						sgblk_pool_size, 32, 0);
 
-	ASC_DBG(1, "sg_cnt %d * %lu = %lu bytes\n", sg_cnt, sizeof(adv_sgblk_t),
-		 sizeof(adv_sgblk_t) * sg_cnt);
+	ASC_DBG(1, "sg_cnt %d * %lu = %lu bytes\n", ADV_TOT_SG_BLOCK,
+		sizeof(adv_sgblk_t), sgblk_pool_size);
 
-	if (!board->adv_sgblkp)
+	if (!board->adv_sgblk_pool)
 		goto kmalloc_failed;
 
 	if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
@@ -11289,10 +11272,9 @@ static void advansys_wide_free_mem(struct asc_board *board)
 				  board->adv_reqp, board->adv_reqp_addr);
 		board->adv_reqp = NULL;
 	}
-	while (board->adv_sgblkp) {
-		adv_sgblk_t *sgp = board->adv_sgblkp;
-		board->adv_sgblkp = sgp->next_sgblkp;
-		kfree(sgp);
+	if (board->adv_sgblk_pool) {
+		dma_pool_destroy(board->adv_sgblk_pool);
+		board->adv_sgblk_pool = NULL;
 	}
 }
 
-- 
1.8.5.2


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

* [PATCH 07/12] advansys: use 'bool' instead of 'int'
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (5 preceding siblings ...)
  2014-12-03 11:44 ` [PATCH 06/12] advansys: Use dma_pool for sg elements Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 08/12] advansys: use standard data types Hannes Reinecke
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 0aea820..0d29d0b 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -3820,17 +3820,17 @@ static int AscStopChip(PortAddr iop_base)
 	return (1);
 }
 
-static int AscIsChipHalted(PortAddr iop_base)
+static bool AscIsChipHalted(PortAddr iop_base)
 {
 	if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
 		if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
-			return (1);
+			return true;
 		}
 	}
-	return (0);
+	return false;
 }
 
-static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
+static bool AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
 {
 	PortAddr iop_base;
 	int i = 10;
@@ -6476,11 +6476,11 @@ AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
 	return byte;
 }
 
-static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
+static bool AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
 {
 	ASC_SCSI_BIT_ID_TYPE org_id;
 	int i;
-	int sta = TRUE;
+	bool sta = true;
 
 	AscSetBank(iop_base, 1);
 	org_id = AscReadChipDvcID(iop_base);
@@ -6494,10 +6494,10 @@ static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
 		AscSetBank(iop_base, 0);
 		AscSetChipSyn(iop_base, sdtr_data);
 		if (AscGetChipSyn(iop_base) != sdtr_data) {
-			sta = FALSE;
+			sta = false;
 		}
 	} else {
-		sta = FALSE;
+		sta = false;
 	}
 	AscSetBank(iop_base, 1);
 	AscWriteChipDvcID(iop_base, org_id);
@@ -7562,32 +7562,32 @@ static irqreturn_t advansys_interrupt(int irq, void *dev_id)
 	return result;
 }
 
-static int AscHostReqRiscHalt(PortAddr iop_base)
+static bool AscHostReqRiscHalt(PortAddr iop_base)
 {
 	int count = 0;
-	int sta = 0;
+	bool sta = false;
 	uchar saved_stop_code;
 
 	if (AscIsChipHalted(iop_base))
-		return (1);
+		return true;
 	saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
 	AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
 			 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
 	do {
 		if (AscIsChipHalted(iop_base)) {
-			sta = 1;
+			sta = true;
 			break;
 		}
 		mdelay(100);
 	} while (count++ < 20);
 	AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
-	return (sta);
+	return sta;
 }
 
-static int
+static bool
 AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
 {
-	int sta = FALSE;
+	bool sta = false;
 
 	if (AscHostReqRiscHalt(iop_base)) {
 		sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
@@ -9483,7 +9483,7 @@ static ushort AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
 		AscResetChipAndScsiBus(asc_dvc);
 		mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
 	}
-	if (AscIsChipHalted(iop_base) == FALSE) {
+	if (!AscIsChipHalted(iop_base)) {
 		asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
 		return (warn_code);
 	}
-- 
1.8.5.2


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

* [PATCH 08/12] advansys: use standard data types
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (6 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 07/12] advansys: use 'bool' instead of 'int' Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 09/12] advansys: Remove 'TRUE' and 'FALSE' definitions Hannes Reinecke
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

No point in defining our own.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 176 ++++++++++++++++++------------------------------
 1 file changed, 67 insertions(+), 109 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 0d29d0b..364f3f8 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -76,20 +76,6 @@
 /* Enable driver tracing. */
 #undef ADVANSYS_DEBUG
 
-/*
- * Portable Data Types
- *
- * Any instance where a 32-bit long or pointer type is assumed
- * for precision or HW defined structures, the following define
- * types must be used. In Linux the char, short, and int types
- * are all consistent at 8, 16, and 32 bits respectively. Pointers
- * and long types are 64 bits on Alpha and UltraSPARC.
- */
-#define ASC_PADDR __u32		/* Physical/Bus address data type. */
-#define ASC_VADDR __u32		/* Virtual address data type. */
-#define ASC_DCNT  __u32		/* Unsigned Data count type. */
-#define ASC_SDCNT __s32		/* Signed Data count type. */
-
 typedef unsigned char uchar;
 
 #ifndef TRUE
@@ -307,8 +293,8 @@ typedef struct asc_scsiq_1 {
 	uchar sg_queue_cnt;
 	uchar target_id;
 	uchar target_lun;
-	ASC_PADDR data_addr;
-	ASC_DCNT data_cnt;
+	__le32 data_addr;
+	__le32 data_cnt;
 	__le32 sense_addr;
 	uchar sense_len;
 	uchar extra_bytes;
@@ -338,8 +324,8 @@ typedef struct asc_scsiq_4 {
 	uchar y_res;
 	ushort x_req_count;
 	ushort x_reconnect_rtn;
-	ASC_PADDR x_saved_data_addr;
-	ASC_DCNT x_saved_data_cnt;
+	__le32 x_saved_data_addr;
+	__le32 x_saved_data_cnt;
 } ASC_SCSIQ_4;
 
 typedef struct asc_q_done_info {
@@ -351,12 +337,12 @@ typedef struct asc_q_done_info {
 	uchar sense_len;
 	uchar extra_bytes;
 	uchar res;
-	ASC_DCNT remain_bytes;
+	u32 remain_bytes;
 } ASC_QDONE_INFO;
 
 typedef struct asc_sg_list {
-	ASC_PADDR addr;
-	ASC_DCNT bytes;
+	__le32 addr;
+	__le32 bytes;
 } ASC_SG_LIST;
 
 typedef struct asc_sg_head {
@@ -586,13 +572,13 @@ typedef struct asc_dvc_var {
 	char redo_scam;
 	ushort res2;
 	uchar dos_int13_table[ASC_MAX_TID + 1];
-	ASC_DCNT max_dma_count;
+	unsigned int max_dma_count;
 	ASC_SCSI_BIT_ID_TYPE no_scam;
 	ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
 	uchar min_sdtr_index;
 	uchar max_sdtr_index;
 	struct asc_board *drv_ptr;
-	ASC_DCNT uc_break;
+	unsigned int uc_break;
 } ASC_DVC_VAR;
 
 typedef struct asc_dvc_inq_info {
@@ -600,8 +586,8 @@ typedef struct asc_dvc_inq_info {
 } ASC_DVC_INQ_INFO;
 
 typedef struct asc_cap_info {
-	ASC_DCNT lba;
-	ASC_DCNT blk_size;
+	u32 lba;
+	u32 blk_size;
 } ASC_CAP_INFO;
 
 typedef struct asc_cap_info_array {
@@ -928,20 +914,6 @@ typedef struct asc_mc_saved {
 #define AscWriteChipDvcID(port, data)     outp((port)+IOP_REG_ID, data)
 
 /*
- * Portable Data Types
- *
- * Any instance where a 32-bit long or pointer type is assumed
- * for precision or HW defined structures, the following define
- * types must be used. In Linux the char, short, and int types
- * are all consistent at 8, 16, and 32 bits respectively. Pointers
- * and long types are 64 bits on Alpha and UltraSPARC.
- */
-#define ADV_PADDR __u32		/* Physical address data type. */
-#define ADV_VADDR __u32		/* Virtual address data type. */
-#define ADV_DCNT  __u32		/* Unsigned Data count type. */
-#define ADV_SDCNT __s32		/* Signed Data count type. */
-
-/*
  * These macros are used to convert a virtual address to a
  * 32-bit value. This currently can be used on Linux Alpha
  * which uses 64-bit virtual address but a 32-bit bus address.
@@ -949,7 +921,6 @@ typedef struct asc_mc_saved {
  * will give us time to change the HW and FW to handle 64-bit
  * addresses.
  */
-#define ADV_VADDR_TO_U32   virt_to_bus
 #define ADV_U32_TO_VADDR   bus_to_virt
 
 #define AdvPortAddr  void __iomem *	/* Virtual memory address size */
@@ -1843,8 +1814,8 @@ typedef struct adv_scsi_req_q {
 	uchar target_cmd;
 	uchar target_id;	/* Device target identifier. */
 	uchar target_lun;	/* Device target logical unit number. */
-	ADV_PADDR data_addr;	/* Data buffer physical address. */
-	ADV_DCNT data_cnt;	/* Data count. Ucode sets to residual. */
+	__le32 data_addr;	/* Data buffer physical address. */
+	__le32 data_cnt;	/* Data count. Ucode sets to residual. */
 	__le32 sense_addr;
 	__le32 carr_pa;
 	uchar mflag;
@@ -1856,7 +1827,7 @@ typedef struct adv_scsi_req_q {
 	uchar host_status;	/* Ucode host status. */
 	uchar sg_working_ix;
 	uchar cdb[12];		/* SCSI CDB bytes 0-11. */
-	ADV_PADDR sg_real_addr;	/* SG list physical address. */
+	__le32 sg_real_addr;	/* SG list physical address. */
 	__le32 scsiq_rptr;
 	uchar cdb16[4];		/* SCSI CDB bytes 12-15. */
 	__le32 scsiq_ptr;
@@ -2078,8 +2049,7 @@ do { \
  *      ADV_FALSE(0) - Queue was not found on the active queue list.
  */
 #define AdvAbortQueue(asc_dvc, srb_tag) \
-        AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
-                       (ADV_DCNT) (srb_tag))
+     AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, (srb_tag))
 
 /*
  * Send a Bus Device Reset Message to the specified target ID.
@@ -2093,8 +2063,7 @@ do { \
  *                     are not purged.
  */
 #define AdvResetDevice(asc_dvc, target_id) \
-        AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
-                    (ADV_DCNT) (target_id))
+     AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, (target_id))
 
 /*
  * SCSI Wide Type definition.
@@ -2151,8 +2120,6 @@ do { \
 #define QHSTA_M_SGBACKUP_ERROR      0x47	/* Scatter-Gather backup error */
 
 /* Return the address that is aligned at the next doubleword >= to 'addr'. */
-#define ADV_8BALIGN(addr)      (((ulong) (addr) + 0x7) & ~0x7)
-#define ADV_16BALIGN(addr)     (((ulong) (addr) + 0xF) & ~0xF)
 #define ADV_32BALIGN(addr)     (((ulong) (addr) + 0x1F) & ~0x1F)
 
 /*
@@ -2313,24 +2280,24 @@ do { \
 /* Per board statistics structure */
 struct asc_stats {
 	/* Driver Entrypoint Statistics */
-	ADV_DCNT queuecommand;	/* # calls to advansys_queuecommand() */
-	ADV_DCNT reset;		/* # calls to advansys_eh_bus_reset() */
-	ADV_DCNT biosparam;	/* # calls to advansys_biosparam() */
-	ADV_DCNT interrupt;	/* # advansys_interrupt() calls */
-	ADV_DCNT callback;	/* # calls to asc/adv_isr_callback() */
-	ADV_DCNT done;		/* # calls to request's scsi_done function */
-	ADV_DCNT build_error;	/* # asc/adv_build_req() ASC_ERROR returns. */
-	ADV_DCNT adv_build_noreq;	/* # adv_build_req() adv_req_t alloc. fail. */
-	ADV_DCNT adv_build_nosg;	/* # adv_build_req() adv_sgblk_t alloc. fail. */
+	unsigned int queuecommand;	/* # calls to advansys_queuecommand() */
+	unsigned int reset;		/* # calls to advansys_eh_bus_reset() */
+	unsigned int biosparam;	/* # calls to advansys_biosparam() */
+	unsigned int interrupt;	/* # advansys_interrupt() calls */
+	unsigned int callback;	/* # calls to asc/adv_isr_callback() */
+	unsigned int done;		/* # calls to request's scsi_done function */
+	unsigned int build_error;	/* # asc/adv_build_req() ASC_ERROR returns. */
+	unsigned int adv_build_noreq;	/* # adv_build_req() adv_req_t alloc. fail. */
+	unsigned int adv_build_nosg;	/* # adv_build_req() adv_sgblk_t alloc. fail. */
 	/* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
-	ADV_DCNT exe_noerror;	/* # ASC_NOERROR returns. */
-	ADV_DCNT exe_busy;	/* # ASC_BUSY returns. */
-	ADV_DCNT exe_error;	/* # ASC_ERROR returns. */
-	ADV_DCNT exe_unknown;	/* # unknown returns. */
+	unsigned int exe_noerror;	/* # ASC_NOERROR returns. */
+	unsigned int exe_busy;	/* # ASC_BUSY returns. */
+	unsigned int exe_error;	/* # ASC_ERROR returns. */
+	unsigned int exe_unknown;	/* # unknown returns. */
 	/* Data Transfer Statistics */
-	ADV_DCNT xfer_cnt;	/* # I/O requests received */
-	ADV_DCNT xfer_elem;	/* # scatter-gather elements */
-	ADV_DCNT xfer_sect;	/* # 512-byte blocks */
+	unsigned int xfer_cnt;	/* # I/O requests received */
+	unsigned int xfer_elem;	/* # scatter-gather elements */
+	unsigned int xfer_sect;	/* # 512-byte blocks */
 };
 #endif /* ADVANSYS_STATS */
 
@@ -3914,15 +3881,15 @@ static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
 }
 
 #if CC_VERY_LONG_SG_LIST
-static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
+static u32 AscReadLramDWord(PortAddr iop_base, ushort addr)
 {
 	ushort val_low, val_high;
-	ASC_DCNT dword_data;
+	u32 dword_data;
 
 	AscSetChipLramAddr(iop_base, addr);
 	val_low = AscGetChipLramData(iop_base);
 	val_high = AscGetChipLramData(iop_base);
-	dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
+	dword_data = ((u32) val_high << 16) | (u32) val_low;
 	return (dword_data);
 }
 #endif /* CC_VERY_LONG_SG_LIST */
@@ -4028,12 +3995,11 @@ AscMemWordCopyPtrFromLram(PortAddr iop_base,
 	}
 }
 
-static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
+static u32 AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
 {
-	ASC_DCNT sum;
+	u32 sum = 0;
 	int i;
 
-	sum = 0L;
 	for (i = 0; i < words; i++, s_addr += 2) {
 		sum += AscReadLramWord(iop_base, s_addr);
 	}
@@ -4090,11 +4056,11 @@ static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
 	return warn_code;
 }
 
-static ASC_DCNT
+static u32
 AscLoadMicroCode(PortAddr iop_base, ushort s_addr,
 		 const uchar *mcode_buf, ushort mcode_size)
 {
-	ASC_DCNT chksum;
+	u32 chksum;
 	ushort mcode_word_size;
 	ushort mcode_chksum;
 
@@ -4151,8 +4117,8 @@ static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
 	int i;
 	ushort warn_code;
 	PortAddr iop_base;
-	ASC_PADDR phy_addr;
-	ASC_DCNT phy_size;
+	__le32 phy_addr;
+	__le32 phy_size;
 	struct asc_board *board = asc_dvc_to_board(asc_dvc);
 
 	iop_base = asc_dvc->iop_base;
@@ -4296,7 +4262,7 @@ static int AdvLoadMicrocode(AdvPortAddr iop_base, const unsigned char *buf,
 			    int size, int memsize, int chksum)
 {
 	int i, j, end, len = 0;
-	ADV_DCNT sum;
+	u32 sum;
 
 	AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
 
@@ -4426,10 +4392,9 @@ static adv_req_t * adv_get_reqp(struct adv_dvc_var *adv_dvc, u32 offset)
  */
 static int
 AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
-	       ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
+	       ushort idle_cmd, u32 idle_cmd_parameter)
 {
-	int result;
-	ADV_DCNT i, j;
+	int result, i, j;
 	AdvPortAddr iop_base;
 
 	iop_base = asc_dvc->iop_base;
@@ -6094,7 +6059,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
 	adv_req_t *reqp;
 	adv_sgblk_t *sgblkp;
 	struct scsi_cmnd *scp;
-	ADV_DCNT resid_cnt;
+	u32 resid_cnt;
 	dma_addr_t sense_addr;
 
 	ASC_DBG(1, "adv_dvc_varp 0x%p, scsiqp 0x%p\n",
@@ -6264,7 +6229,7 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
 	uchar int_stat;
 	ushort target_bit;
 	ADV_CARR_T *free_carrp;
-	ADV_VADDR irq_next_vpa;
+	__le32 irq_next_vpa;
 	ADV_SCSI_REQ_Q *scsiq;
 	adv_req_t *reqp;
 
@@ -6998,7 +6963,7 @@ DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
 static uchar
 _AscCopyLramScsiDoneQ(PortAddr iop_base,
 		      ushort q_addr,
-		      ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
+		      ASC_QDONE_INFO *scsiq, unsigned int max_dma_count)
 {
 	ushort _val;
 	uchar sg_queue_cnt;
@@ -7025,10 +6990,10 @@ _AscCopyLramScsiDoneQ(PortAddr iop_base,
 	/*
 	 * Read high word of remain bytes from alternate location.
 	 */
-	scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
-							  (ushort)(q_addr +
-								   (ushort)
-								   ASC_SCSIQ_W_ALT_DC1)))
+	scsiq->remain_bytes = (((u32)AscReadLramWord(iop_base,
+						     (ushort)(q_addr +
+							      (ushort)
+							      ASC_SCSIQ_W_ALT_DC1)))
 			       << 16);
 	/*
 	 * Read low word of remain bytes from original location.
@@ -7255,8 +7220,7 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 		} else if (scsiq->q_status == QS_DONE) {
 			false_overrun = FALSE;
 			if (scsiq->extra_bytes != 0) {
-				scsiq->remain_bytes +=
-				    (ADV_DCNT)scsiq->extra_bytes;
+				scsiq->remain_bytes += scsiq->extra_bytes;
 			}
 			if (scsiq->d3.done_stat == QD_WITH_ERROR) {
 				if (scsiq->d3.host_stat ==
@@ -8301,8 +8265,8 @@ AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
 	int i;
 	ASC_SG_HEAD *sg_head;
 	ASC_SG_LIST_Q scsi_sg_q;
-	ASC_DCNT saved_data_addr;
-	ASC_DCNT saved_data_cnt;
+	__le32 saved_data_addr;
+	__le32 saved_data_cnt;
 	PortAddr iop_base;
 	ushort sg_list_dwords;
 	ushort sg_index;
@@ -8314,8 +8278,8 @@ AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
 	sg_head = scsiq->sg_head;
 	saved_data_addr = scsiq->q1.data_addr;
 	saved_data_cnt = scsiq->q1.data_cnt;
-	scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
-	scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
+	scsiq->q1.data_addr = sg_head->sg_list[0].addr;
+	scsiq->q1.data_cnt = sg_head->sg_list[0].bytes;
 #if CC_VERY_LONG_SG_LIST
 	/*
 	 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
@@ -8495,7 +8459,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	int n_q_required;
 	int disable_syn_offset_one_fix;
 	int i;
-	ASC_PADDR addr;
+	u32 addr;
 	ushort sg_entry_cnt = 0;
 	ushort sg_entry_cnt_minus_one = 0;
 	uchar target_ix;
@@ -8505,7 +8469,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	uchar scsi_cmd;
 	uchar disable_cmd;
 	ASC_SG_HEAD *sg_head;
-	ASC_DCNT data_cnt;
+	unsigned long data_cnt;
 
 	iop_base = asc_dvc->iop_base;
 	sg_head = scsiq->sg_head;
@@ -8551,10 +8515,8 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 		}
 #endif /* !CC_VERY_LONG_SG_LIST */
 		if (sg_entry_cnt == 1) {
-			scsiq->q1.data_addr =
-			    (ADV_PADDR)sg_head->sg_list[0].addr;
-			scsiq->q1.data_cnt =
-			    (ADV_DCNT)sg_head->sg_list[0].bytes;
+			scsiq->q1.data_addr = sg_head->sg_list[0].addr;
+			scsiq->q1.data_cnt = sg_head->sg_list[0].bytes;
 			scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
 		}
 		sg_entry_cnt_minus_one = sg_entry_cnt - 1;
@@ -8566,9 +8528,8 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 		if (scsiq->q1.cntl & QC_SG_HEAD) {
 			data_cnt = 0;
 			for (i = 0; i < sg_entry_cnt; i++) {
-				data_cnt +=
-				    (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
-							  bytes);
+				data_cnt += le32_to_cpu(sg_head->sg_list[i].
+							bytes);
 			}
 		} else {
 			data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
@@ -8605,12 +8566,11 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 			if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
 				if ((scsi_cmd == READ_6) ||
 				    (scsi_cmd == READ_10)) {
-					addr =
-					    (ADV_PADDR)le32_to_cpu(sg_head->
+					addr = le32_to_cpu(sg_head->
 								   sg_list
 								   [sg_entry_cnt_minus_one].
 								   addr) +
-					    (ADV_DCNT)le32_to_cpu(sg_head->
+						le32_to_cpu(sg_head->
 								  sg_list
 								  [sg_entry_cnt_minus_one].
 								  bytes);
@@ -8631,8 +8591,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 								sg_list
 								[sg_entry_cnt_minus_one].
 								bytes);
-						data_cnt -=
-						    (ASC_DCNT) extra_bytes;
+						data_cnt -= extra_bytes;
 						sg_head->
 						    sg_list
 						    [sg_entry_cnt_minus_one].
@@ -8687,8 +8646,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 						    == 0) {
 							scsiq->q2.tag_code |=
 							    ASC_TAG_FLAG_EXTRA_BYTES;
-							data_cnt -= (ASC_DCNT)
-							    extra_bytes;
+							data_cnt -= extra_bytes;
 							scsiq->q1.data_cnt =
 							    cpu_to_le32
 							    (data_cnt);
@@ -9051,7 +9009,7 @@ static int AscStopQueueExe(PortAddr iop_base)
 	return (0);
 }
 
-static ASC_DCNT AscGetMaxDmaCount(ushort bus_type)
+static unsigned int AscGetMaxDmaCount(ushort bus_type)
 {
 	if (bus_type & ASC_IS_ISA)
 		return ASC_MAX_ISA_DMA_COUNT;
-- 
1.8.5.2


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

* [PATCH 09/12] advansys: Remove 'TRUE' and 'FALSE' definitions
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (7 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 08/12] advansys: use standard data types Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 10/12] advansys: Remove 'ERR' definition Hannes Reinecke
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Use 'bool' type instead.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 79 ++++++++++++++++++++++++-------------------------
 1 file changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 364f3f8..42e9dc6 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -78,13 +78,6 @@
 
 typedef unsigned char uchar;
 
-#ifndef TRUE
-#define TRUE     (1)
-#endif
-#ifndef FALSE
-#define FALSE    (0)
-#endif
-
 #define ERR      (-1)
 #define UW_ERR   (uint)(0xFFFF)
 #define isodd_word(val)   ((((uint)val) & (uint)0x0001) != 0)
@@ -556,7 +549,7 @@ typedef struct asc_dvc_var {
 	dma_addr_t overrun_dma;
 	uchar scsi_reset_wait;
 	uchar chip_no;
-	char is_in_int;
+	bool is_in_int;
 	uchar max_total_qng;
 	uchar cur_total_qng;
 	uchar in_critical_cnt;
@@ -3771,7 +3764,7 @@ static int AscStartChip(PortAddr iop_base)
 	return (1);
 }
 
-static int AscStopChip(PortAddr iop_base)
+static bool AscStopChip(PortAddr iop_base)
 {
 	uchar cc_val;
 
@@ -3782,9 +3775,9 @@ static int AscStopChip(PortAddr iop_base)
 	AscSetChipIH(iop_base, INS_HALT);
 	AscSetChipIH(iop_base, INS_RFLAG_WTM);
 	if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
-		return (0);
+		return false;
 	}
-	return (1);
+	return true;
 }
 
 static bool AscIsChipHalted(PortAddr iop_base)
@@ -6481,7 +6474,7 @@ static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
 	EXT_MSG ext_msg;
 	EXT_MSG out_msg;
 	ushort halt_q_addr;
-	int sdtr_accept;
+	bool sdtr_accept;
 	ushort int_halt_code;
 	ASC_SCSI_BIT_ID_TYPE scsi_busy;
 	ASC_SCSI_BIT_ID_TYPE target_id;
@@ -6540,10 +6533,10 @@ static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
 		if (ext_msg.msg_type == EXTENDED_MESSAGE &&
 		    ext_msg.msg_req == EXTENDED_SDTR &&
 		    ext_msg.msg_len == MS_SDTR_LEN) {
-			sdtr_accept = TRUE;
+			sdtr_accept = true;
 			if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
 
-				sdtr_accept = FALSE;
+				sdtr_accept = false;
 				ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
 			}
 			if ((ext_msg.xfer_period <
@@ -6551,7 +6544,7 @@ static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
 			    || (ext_msg.xfer_period >
 				asc_dvc->sdtr_period_tbl[asc_dvc->
 							 max_sdtr_index])) {
-				sdtr_accept = FALSE;
+				sdtr_accept = false;
 				ext_msg.xfer_period =
 				    asc_dvc->sdtr_period_tbl[asc_dvc->
 							     min_sdtr_index];
@@ -7136,7 +7129,7 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 	uchar cur_target_qng;
 	ASC_QDONE_INFO scsiq_buf;
 	ASC_QDONE_INFO *scsiq;
-	int false_overrun;
+	bool false_overrun;
 
 	iop_base = asc_dvc->iop_base;
 	n_q_used = 1;
@@ -7218,7 +7211,11 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 		    ((scsiq->q_status & QS_ABORTED) != 0)) {
 			return (0x11);
 		} else if (scsiq->q_status == QS_DONE) {
-			false_overrun = FALSE;
+			/*
+			 * This is also curious.
+			 * false_overrun will _always_ be set to 'false'
+			 */
+			false_overrun = false;
 			if (scsiq->extra_bytes != 0) {
 				scsiq->remain_bytes += scsiq->extra_bytes;
 			}
@@ -7291,23 +7288,23 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 	uchar host_flag;
 
 	iop_base = asc_dvc->iop_base;
-	int_pending = FALSE;
+	int_pending = ASC_FALSE;
 
 	if (AscIsIntPending(iop_base) == 0)
 		return int_pending;
 
 	if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
-		return ERR;
+		return ASC_ERROR;
 	}
 	if (asc_dvc->in_critical_cnt != 0) {
 		AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
-		return ERR;
+		return ASC_ERROR;
 	}
 	if (asc_dvc->is_in_int) {
 		AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
-		return ERR;
+		return ASC_ERROR;
 	}
-	asc_dvc->is_in_int = TRUE;
+	asc_dvc->is_in_int = true;
 	ctrl_reg = AscGetChipControl(iop_base);
 	saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
 				       CC_SINGLE_STEP | CC_DIAG | CC_TEST));
@@ -7315,7 +7312,7 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 	if (chipstat & CSW_SCSI_RESET_LATCH) {
 		if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
 			int i = 10;
-			int_pending = TRUE;
+			int_pending = ADV_TRUE;
 			asc_dvc->sdtr_done = 0;
 			saved_ctrl_reg &= (uchar)(~CC_HALT);
 			while ((AscGetChipStatus(iop_base) &
@@ -7337,7 +7334,7 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 			 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
 	if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
 		AscAckInterrupt(iop_base);
-		int_pending = TRUE;
+		int_pending = ADV_TRUE;
 		if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
 			if (AscIsrChipHalted(asc_dvc) == ERR) {
 				goto ISR_REPORT_QDONE_FATAL_ERROR;
@@ -7359,13 +7356,13 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 				} while (status == 0x11);
 			}
 			if ((status & 0x80) != 0)
-				int_pending = ERR;
+				int_pending = ASC_ERROR;
 		}
 	}
 	AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
 	AscSetChipLramAddr(iop_base, saved_ram_addr);
 	AscSetChipControl(iop_base, saved_ctrl_reg);
-	asc_dvc->is_in_int = FALSE;
+	asc_dvc->is_in_int = false;
 	return int_pending;
 }
 
@@ -8457,7 +8454,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	PortAddr iop_base;
 	int sta;
 	int n_q_required;
-	int disable_syn_offset_one_fix;
+	bool disable_syn_offset_one_fix;
 	int i;
 	u32 addr;
 	ushort sg_entry_cnt = 0;
@@ -8522,7 +8519,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 		sg_entry_cnt_minus_one = sg_entry_cnt - 1;
 	}
 	scsi_cmd = scsiq->cdbptr[0];
-	disable_syn_offset_one_fix = FALSE;
+	disable_syn_offset_one_fix = false;
 	if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
 	    !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
 		if (scsiq->q1.cntl & QC_SG_HEAD) {
@@ -8536,7 +8533,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 		}
 		if (data_cnt != 0UL) {
 			if (data_cnt < 512UL) {
-				disable_syn_offset_one_fix = TRUE;
+				disable_syn_offset_one_fix = true;
 			} else {
 				for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
 				     i++) {
@@ -8547,7 +8544,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 					}
 					if (scsi_cmd == disable_cmd) {
 						disable_syn_offset_one_fix =
-						    TRUE;
+						    true;
 						break;
 					}
 				}
@@ -9092,7 +9089,7 @@ static ushort AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
 	/* asc_dvc->init_state initialized in AscInitGetConfig(). */
 	asc_dvc->sdtr_done = 0;
 	asc_dvc->cur_total_qng = 0;
-	asc_dvc->is_in_int = 0;
+	asc_dvc->is_in_int = false;
 	asc_dvc->in_critical_cnt = 0;
 	asc_dvc->last_q_shortage = 0;
 	asc_dvc->use_tagged_qng = 0;
@@ -9272,7 +9269,7 @@ static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
 	int retry;
 
 	retry = 0;
-	while (TRUE) {
+	while (true) {
 		AscSetChipEEPData(iop_base, data_reg);
 		mdelay(1);
 		read_back = AscGetChipEEPData(iop_base);
@@ -9408,7 +9405,7 @@ static int AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf,
 	int n_error;
 
 	retry = 0;
-	while (TRUE) {
+	while (true) {
 		if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
 						   bus_type)) == 0) {
 			break;
@@ -9435,7 +9432,7 @@ static ushort AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
 	warn_code = 0;
 	AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
 	AscStopQueueExe(iop_base);
-	if ((AscStopChip(iop_base) == FALSE) ||
+	if ((AscStopChip(iop_base)) ||
 	    (AscGetChipScsiCtrl(iop_base) != 0)) {
 		asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
 		AscResetChipAndScsiBus(asc_dvc);
@@ -11127,7 +11124,7 @@ static struct scsi_host_template advansys_template = {
 	 * must be set. The flag will be cleared in advansys_board_found
 	 * for non-ISA adapters.
 	 */
-	.unchecked_isa_dma = 1,
+	.unchecked_isa_dma = true,
 	/*
 	 * All adapters controlled by this driver are capable of large
 	 * scatter-gather lists. According to the mid-level SCSI documentation
@@ -11303,28 +11300,28 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
 		switch (asc_dvc_varp->bus_type) {
 #ifdef CONFIG_ISA
 		case ASC_IS_ISA:
-			shost->unchecked_isa_dma = TRUE;
+			shost->unchecked_isa_dma = true;
 			share_irq = 0;
 			break;
 		case ASC_IS_VL:
-			shost->unchecked_isa_dma = FALSE;
+			shost->unchecked_isa_dma = false;
 			share_irq = 0;
 			break;
 		case ASC_IS_EISA:
-			shost->unchecked_isa_dma = FALSE;
+			shost->unchecked_isa_dma = false;
 			share_irq = IRQF_SHARED;
 			break;
 #endif /* CONFIG_ISA */
 #ifdef CONFIG_PCI
 		case ASC_IS_PCI:
-			shost->unchecked_isa_dma = FALSE;
+			shost->unchecked_isa_dma = false;
 			share_irq = IRQF_SHARED;
 			break;
 #endif /* CONFIG_PCI */
 		default:
 			shost_printk(KERN_ERR, shost, "unknown adapter type: "
 					"%d\n", asc_dvc_varp->bus_type);
-			shost->unchecked_isa_dma = TRUE;
+			shost->unchecked_isa_dma = false;
 			share_irq = 0;
 			break;
 		}
@@ -11343,7 +11340,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
 		 * For Wide boards set PCI information before calling
 		 * AdvInitGetConfig().
 		 */
-		shost->unchecked_isa_dma = FALSE;
+		shost->unchecked_isa_dma = false;
 		share_irq = IRQF_SHARED;
 		ASC_DBG(2, "AdvInitGetConfig()\n");
 
-- 
1.8.5.2


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

* [PATCH 10/12] advansys: Remove 'ERR' definition
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (8 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 09/12] advansys: Remove 'TRUE' and 'FALSE' definitions Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 11/12] advansys: cleanup function return codes Hannes Reinecke
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 42e9dc6..14a4571 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -78,7 +78,6 @@
 
 typedef unsigned char uchar;
 
-#define ERR      (-1)
 #define UW_ERR   (uint)(0xFFFF)
 #define isodd_word(val)   ((((uint)val) & (uint)0x0001) != 0)
 
@@ -7276,33 +7275,33 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 	return (0);
 }
 
-static int AscISR(ASC_DVC_VAR *asc_dvc)
+static void AscISR(ASC_DVC_VAR *asc_dvc)
 {
 	ASC_CS_TYPE chipstat;
 	PortAddr iop_base;
 	ushort saved_ram_addr;
 	uchar ctrl_reg;
 	uchar saved_ctrl_reg;
-	int int_pending;
+	bool int_pending;
 	int status;
 	uchar host_flag;
 
 	iop_base = asc_dvc->iop_base;
-	int_pending = ASC_FALSE;
+	int_pending = false;
 
 	if (AscIsIntPending(iop_base) == 0)
-		return int_pending;
+		return;
 
 	if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
-		return ASC_ERROR;
+		return;
 	}
 	if (asc_dvc->in_critical_cnt != 0) {
 		AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
-		return ASC_ERROR;
+		return;
 	}
 	if (asc_dvc->is_in_int) {
 		AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
-		return ASC_ERROR;
+		return;
 	}
 	asc_dvc->is_in_int = true;
 	ctrl_reg = AscGetChipControl(iop_base);
@@ -7312,7 +7311,7 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 	if (chipstat & CSW_SCSI_RESET_LATCH) {
 		if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
 			int i = 10;
-			int_pending = ADV_TRUE;
+			int_pending = true;
 			asc_dvc->sdtr_done = 0;
 			saved_ctrl_reg &= (uchar)(~CC_HALT);
 			while ((AscGetChipStatus(iop_base) &
@@ -7334,9 +7333,9 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 			 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
 	if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
 		AscAckInterrupt(iop_base);
-		int_pending = ADV_TRUE;
+		int_pending = true;
 		if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
-			if (AscIsrChipHalted(asc_dvc) == ERR) {
+			if (AscIsrChipHalted(asc_dvc) == ASC_ERROR) {
 				goto ISR_REPORT_QDONE_FATAL_ERROR;
 			} else {
 				saved_ctrl_reg &= (uchar)(~CC_HALT);
@@ -7356,14 +7355,13 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
 				} while (status == 0x11);
 			}
 			if ((status & 0x80) != 0)
-				int_pending = ASC_ERROR;
+				printk("advansys: AscISR: interrupt still pending, status 0x%x\n", status);
 		}
 	}
 	AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
 	AscSetChipLramAddr(iop_base, saved_ram_addr);
 	AscSetChipControl(iop_base, saved_ctrl_reg);
 	asc_dvc->is_in_int = false;
-	return int_pending;
 }
 
 /*
@@ -8471,7 +8469,7 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	iop_base = asc_dvc->iop_base;
 	sg_head = scsiq->sg_head;
 	if (asc_dvc->err_code != 0)
-		return (ERR);
+		return ASC_ERROR;
 	scsiq->q1.q_no = 0;
 	if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
 		scsiq->q1.extra_bytes = 0;
@@ -8497,18 +8495,18 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	}
 	if (asc_dvc->in_critical_cnt != 0) {
 		AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
-		return (ERR);
+		return ASC_ERROR;
 	}
 	asc_dvc->in_critical_cnt++;
 	if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
 		if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
 			asc_dvc->in_critical_cnt--;
-			return (ERR);
+			return ASC_ERROR;
 		}
 #if !CC_VERY_LONG_SG_LIST
 		if (sg_entry_cnt > ASC_MAX_SG_LIST) {
 			asc_dvc->in_critical_cnt--;
-			return (ERR);
+			return ASC_ERROR;
 		}
 #endif /* !CC_VERY_LONG_SG_LIST */
 		if (sg_entry_cnt == 1) {
-- 
1.8.5.2


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

* [PATCH 11/12] advansys: cleanup function return codes
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (9 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 10/12] advansys: Remove 'ERR' definition Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-03 11:45 ` [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning Hannes Reinecke
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 14a4571..bd44d1b 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -3998,15 +3998,13 @@ static u32 AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
 	return (sum);
 }
 
-static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
+static void AscInitLram(ASC_DVC_VAR *asc_dvc)
 {
 	uchar i;
 	ushort s_addr;
 	PortAddr iop_base;
-	ushort warn_code;
 
 	iop_base = asc_dvc->iop_base;
-	warn_code = 0;
 	AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
 			  (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
 				    64) >> 1));
@@ -4045,7 +4043,6 @@ static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
 		AscWriteLramByte(iop_base,
 				 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
 	}
-	return warn_code;
 }
 
 static u32
@@ -4104,10 +4101,10 @@ static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
 	}
 }
 
-static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
+static int AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
 {
 	int i;
-	ushort warn_code;
+	int warn_code;
 	PortAddr iop_base;
 	__le32 phy_addr;
 	__le32 phy_size;
@@ -4149,12 +4146,12 @@ static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
 	AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
 	if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
 		asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
-		warn_code = UW_ERR;
+		warn_code = -EINVAL;
 		goto err_mcode_start;
 	}
 	if (AscStartChip(iop_base) != 1) {
 		asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
-		warn_code = UW_ERR;
+		warn_code = -EIO;
 		goto err_mcode_start;
 	}
 
@@ -4168,13 +4165,13 @@ err_dma_map:
 	return warn_code;
 }
 
-static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
+static int AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
 {
 	const struct firmware *fw;
 	const char fwname[] = "advansys/mcode.bin";
 	int err;
 	unsigned long chksum;
-	ushort warn_code;
+	int warn_code;
 	PortAddr iop_base;
 
 	iop_base = asc_dvc->iop_base;
@@ -4186,15 +4183,13 @@ static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
 	}
 	asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
 	if (asc_dvc->err_code != 0)
-		return UW_ERR;
+		return ASC_ERROR;
 	if (!AscFindSignature(asc_dvc->iop_base)) {
 		asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
 		return warn_code;
 	}
 	AscDisableInterrupt(iop_base);
-	warn_code |= AscInitLram(asc_dvc);
-	if (asc_dvc->err_code != 0)
-		return UW_ERR;
+	AscInitLram(asc_dvc);
 
 	err = request_firmware(&fw, fwname, asc_dvc->drv_ptr->dev);
 	if (err) {
@@ -9065,15 +9060,13 @@ static uchar AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
 }
 #endif /* CONFIG_ISA */
 
-static ushort AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
+static void AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
 {
 	int i;
 	PortAddr iop_base;
-	ushort warn_code;
 	uchar chip_version;
 
 	iop_base = asc_dvc->iop_base;
-	warn_code = 0;
 	asc_dvc->err_code = 0;
 	if ((asc_dvc->bus_type &
 	     (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
@@ -9149,7 +9142,6 @@ static ushort AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
 		asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
 		asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
 	}
-	return warn_code;
 }
 
 static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
@@ -9415,7 +9407,7 @@ static int AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf,
 	return n_error;
 }
 
-static ushort AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
+static int AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
 {
 	ASCEEP_CONFIG eep_config_buf;
 	ASCEEP_CONFIG *eep_config;
@@ -9591,8 +9583,8 @@ static int AscInitGetConfig(struct Scsi_Host *shost)
 		return asc_dvc->err_code;
 
 	if (AscFindSignature(asc_dvc->iop_base)) {
-		warn_code |= AscInitAscDvcVar(asc_dvc);
-		warn_code |= AscInitFromEEP(asc_dvc);
+		AscInitAscDvcVar(asc_dvc);
+		warn_code = AscInitFromEEP(asc_dvc);
 		asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
 		if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
 			asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
-- 
1.8.5.2


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

* [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (10 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 11/12] advansys: cleanup function return codes Hannes Reinecke
@ 2014-12-03 11:45 ` Hannes Reinecke
  2014-12-04  9:23   ` Christoph Hellwig
  2014-12-03 15:21 ` [PATCH 00/12] nobody loves the advansys driver Christoph Hellwig
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 11:45 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, Doug Gilbert, linux-scsi,
	Hannes Reinecke

The driver has now been converted to use the DMA-API, so
update the version number and remove the compilation warning.
And check for DMA mapping errors, while we're at it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 MAINTAINERS             |  1 +
 drivers/scsi/advansys.c | 41 +++++++++++++++++++++++++++--------------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9210908..4c111aa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -445,6 +445,7 @@ F:	drivers/input/misc/adxl34x.c
 
 ADVANSYS SCSI DRIVER
 M:	Matthew Wilcox <matthew@wil.cx>
+M:	Hannes Reinecke <hare@suse.de>
 L:	linux-scsi@vger.kernel.org
 S:	Maintained
 F:	Documentation/scsi/advansys.txt
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index bd44d1b..4f3f948 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1,5 +1,5 @@
 #define DRV_NAME "advansys"
-#define ASC_VERSION "3.4"	/* AdvanSys Driver Version */
+#define ASC_VERSION "3.5"	/* AdvanSys Driver Version */
 
 /*
  * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
@@ -7,6 +7,7 @@
  * Copyright (c) 1995-2000 Advanced System Products, Inc.
  * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
  * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
+ * Copyright (c) 2014 Hannes Reinecke <hare@suse.de>
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -51,24 +52,19 @@
 
 /* FIXME:
  *
- *  1. Although all of the necessary command mapping places have the
- *     appropriate dma_map.. APIs, the driver still processes its internal
- *     queue using bus_to_virt() and virt_to_bus() which are illegal under
- *     the API.  The entire queue processing structure will need to be
- *     altered to fix this.
+ *  1. (done)
  *  2. Need to add memory mapping workaround. Test the memory mapping.
  *     If it doesn't work revert to I/O port access. Can a test be done
  *     safely?
  *  3. Handle an interrupt not working. Keep an interrupt counter in
  *     the interrupt handler. In the timeout function if the interrupt
  *     has not occurred then print a message and run in polled mode.
- *  4. Need to add support for target mode commands, cf. CAM XPT.
- *  5. check DMA mapping functions for failure
+ *  4. (obsolete)
+ *  5. (done)
  *  6. Use scsi_transport_spi
  *  7. advansys_info is not safe against multiple simultaneous callers
  *  8. Add module_param to override ISA/VLB ioport array
  */
-#warning this driver is still not properly converted to the DMA API
 
 /* Enable driver /proc statistics. */
 #define ADVANSYS_STATS
@@ -7765,6 +7761,10 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
 	struct asc_board *board = shost_priv(scp->device->host);
 	scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
 					     SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+	if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) {
+		ASC_DBG(1, "failed to map sense buffer\n");
+		return 0;
+	}
 	dma_cache_sync(board->dev, scp->sense_buffer,
 		       SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
 	return cpu_to_le32(scp->SCp.dma_handle);
@@ -7794,6 +7794,8 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	    ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
 	asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
 	asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
+	if (!asc_scsi_q->q1.sense_addr)
+		return ASC_ERROR;
 
 	/*
 	 * If there are any outstanding requests for the current target,
@@ -7815,7 +7817,10 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 
 	/* Build ASC_SCSI_Q */
 	use_sg = scsi_dma_map(scp);
-	if (use_sg != 0) {
+	if (use_sg < 0) {
+		ASC_DBG(1, "failed to map sglist\n");
+		return ASC_BUSY;
+	} else if (use_sg > 0) {
 		int sgcnt;
 		struct scatterlist *slp;
 		struct asc_sg_head *asc_sg_head;
@@ -8049,6 +8054,11 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 
 	sense_addr = dma_map_single(boardp->dev, scp->sense_buffer,
 				    SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+	if (dma_mapping_error(boardp->dev, sense_addr)) {
+		ASC_DBG(1, "failed to map sense buffer\n");
+		ASC_STATS(scp->device->host, adv_build_noreq);
+		return ASC_BUSY;
+	}
 	scsiqp->sense_addr = cpu_to_le32(sense_addr);
 	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
 	dma_cache_sync(boardp->dev, scp->sense_buffer,
@@ -8057,7 +8067,11 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	/* Build ADV_SCSI_REQ_Q */
 
 	use_sg = scsi_dma_map(scp);
-	if (use_sg == 0) {
+	if (use_sg < 0) {
+		ASC_DBG(1, "failed to map SG list\n");
+		ASC_STATS(scp->device->host, adv_build_noreq);
+		return ASC_BUSY;
+	} else if (use_sg == 0) {
 		/* Zero-length transfer */
 		reqp->sgblkp = NULL;
 		scsiqp->data_cnt = 0;
@@ -8783,11 +8797,10 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
 		ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 		struct asc_scsi_q asc_scsi_q;
 
-		/* asc_build_req() can not return ASC_BUSY. */
 		ret = asc_build_req(boardp, scp, &asc_scsi_q);
-		if (ret == ASC_ERROR) {
+		if (ret == ASC_ERROR || ret == ASC_BUSY) {
 			ASC_STATS(scp->device->host, build_error);
-			return ASC_ERROR;
+			return ret;
 		}
 
 		ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
-- 
1.8.5.2


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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (11 preceding siblings ...)
  2014-12-03 11:45 ` [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning Hannes Reinecke
@ 2014-12-03 15:21 ` Christoph Hellwig
  2014-12-03 15:34   ` Ondrej Zary
  2014-12-03 16:06 ` Douglas Gilbert
  2014-12-03 18:29 ` Ondrej Zary
  14 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-03 15:21 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

Thanks for looking into this old driver.

If you've got a few spare cycles it might make sense to simply split
the "wide board" support out - the driver literally is two different
drivers with an if/else section in every method for the totally
different narrow vs wide boards.  Having at least a clean and simple
driver for the newer wide boards would be good, and narrow ones are
probably old enough that we can let the driver for those fade away..


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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 15:21 ` [PATCH 00/12] nobody loves the advansys driver Christoph Hellwig
@ 2014-12-03 15:34   ` Ondrej Zary
  2014-12-03 15:42     ` James Bottomley
  2014-12-04  9:12     ` Christoph Hellwig
  0 siblings, 2 replies; 30+ messages in thread
From: Ondrej Zary @ 2014-12-03 15:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Hannes Reinecke, James Bottomley, Matthew Wilcox, Doug Gilbert,
	linux-scsi

On Wednesday 03 December 2014, Christoph Hellwig wrote:
> Thanks for looking into this old driver.
>
> If you've got a few spare cycles it might make sense to simply split
> the "wide board" support out - the driver literally is two different
> drivers with an if/else section in every method for the totally
> different narrow vs wide boards.  Having at least a clean and simple
> driver for the newer wide boards would be good, and narrow ones are
> probably old enough that we can let the driver for those fade away..

I have an ASB-3940UA (bought around 2000) and use it for scanner so I can test 
patches.
The driver was working fine so I never had to look at the code. Now I see that 
it's 12K lines long :( Converting that to something simple would require a 
lot of work.

-- 
Ondrej Zary

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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 15:34   ` Ondrej Zary
@ 2014-12-03 15:42     ` James Bottomley
  2014-12-03 16:28       ` Hannes Reinecke
  2014-12-04  9:13       ` hch
  2014-12-04  9:12     ` Christoph Hellwig
  1 sibling, 2 replies; 30+ messages in thread
From: James Bottomley @ 2014-12-03 15:42 UTC (permalink / raw)
  To: linux; +Cc: hch, linux-scsi, dgilbert, hare, matthew

On Wed, 2014-12-03 at 16:34 +0100, Ondrej Zary wrote:
> On Wednesday 03 December 2014, Christoph Hellwig wrote:
> > Thanks for looking into this old driver.
> >
> > If you've got a few spare cycles it might make sense to simply split
> > the "wide board" support out - the driver literally is two different
> > drivers with an if/else section in every method for the totally
> > different narrow vs wide boards.  Having at least a clean and simple
> > driver for the newer wide boards would be good, and narrow ones are
> > probably old enough that we can let the driver for those fade away..
> 
> I have an ASB-3940UA (bought around 2000) and use it for scanner so I can test 
> patches.
> The driver was working fine so I never had to look at the code. Now I see that 
> it's 12K lines long :( Converting that to something simple would require a 
> lot of work.

That's the problem: The driver as-is works in all of the use cases, so
no-one has any motivation to fix it.  Plus the complexity is pretty
daunting.  It's not even the worst driver we have (that prize goes to
atp870u which still has internal bus scanning code).  I'm not saying
don't do the conversion, but I am saying it will have to be validated
and tested before it can go in because lots of people still seem to use
this family of devices in odd corners of the world.

James



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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (12 preceding siblings ...)
  2014-12-03 15:21 ` [PATCH 00/12] nobody loves the advansys driver Christoph Hellwig
@ 2014-12-03 16:06 ` Douglas Gilbert
  2014-12-03 18:29 ` Ondrej Zary
  14 siblings, 0 replies; 30+ messages in thread
From: Douglas Gilbert @ 2014-12-03 16:06 UTC (permalink / raw)
  To: Hannes Reinecke, James Bottomley
  Cc: Christoph Hellwig, Matthew Wilcox, linux-scsi

On 14-12-03 06:44 AM, Hannes Reinecke wrote:
> Hi all,
>
> it has been bugged me for ages that the advansys driver always
> reported a compilation warning about not having been converted
> to the DMA-API.
> And even aggressive waiting hasn't made this warning go away.
>
> So here's a patchset to update the advansys driver to current
> standards and use the DMA-API.
> Tested on ABP940-U2W.
>
> As usual, reviews and comments are welcome.
>
> Hannes Reinecke (12):
>    advansys: use host_reset
>    advansys: use shared host tag map for command lookup
>    advansys: use DMA-API for mapping sense buffer
>    advansys: Use DMA-API for carrier buffer
>    advansys: Use DMA-API for mapping request blocks
>    advansys: Use dma_pool for sg elements
>    advansys: use 'bool' instead of 'int'
>    advansys: use standard data types
>    advansys: Remove 'TRUE' and 'FALSE' definitions
>    advansys: Remove 'ERR' definition
>    advansys: cleanup function return codes
>    advansys: Update to version 3.5 and remove compilation warning
>
>   MAINTAINERS             |    1 +
>   drivers/scsi/advansys.c | 1073 +++++++++++++++++++++--------------------------
>   2 files changed, 469 insertions(+), 605 deletions(-)

Looks good.

Tried to find my old Advansys HBAs but failed, probably
the result of a purge a few years back. Hence I was unable
to test it with my few remaining SPI disks and tape drive.
If memory serves, for a while Advansys HBAs were bundled
with SCSI scanners.

The original Advansys maintainer, Bob Frey, I suspect was
the recipient of my first SCSI related queries.


Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>


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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 15:42     ` James Bottomley
@ 2014-12-03 16:28       ` Hannes Reinecke
  2014-12-04  9:13       ` hch
  1 sibling, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-03 16:28 UTC (permalink / raw)
  To: James Bottomley, linux; +Cc: hch, linux-scsi, dgilbert, matthew

On 12/03/2014 04:42 PM, James Bottomley wrote:
> On Wed, 2014-12-03 at 16:34 +0100, Ondrej Zary wrote:
>> On Wednesday 03 December 2014, Christoph Hellwig wrote:
>>> Thanks for looking into this old driver.
>>>
>>> If you've got a few spare cycles it might make sense to simply split
>>> the "wide board" support out - the driver literally is two different
>>> drivers with an if/else section in every method for the totally
>>> different narrow vs wide boards.  Having at least a clean and simple
>>> driver for the newer wide boards would be good, and narrow ones are
>>> probably old enough that we can let the driver for those fade away..
>>
>> I have an ASB-3940UA (bought around 2000) and use it for scanner so I can test 
>> patches.
>> The driver was working fine so I never had to look at the code. Now I see that 
>> it's 12K lines long :( Converting that to something simple would require a 
>> lot of work.
> 
> That's the problem: The driver as-is works in all of the use cases, so
> no-one has any motivation to fix it.  Plus the complexity is pretty
> daunting.  It's not even the worst driver we have (that prize goes to
> atp870u which still has internal bus scanning code).  I'm not saying
> don't do the conversion, but I am saying it will have to be validated
> and tested before it can go in because lots of people still seem to use
> this family of devices in odd corners of the world.
> 
It was actually on my mind, too, to split the driver up.
The code for the narrow board has some issues even today (I've
inserted some remarks in the code) which always get in the way when
trying to update the other side.

But then I only got a wide board, so I couldn't do any testing
there; I was sort of banking on Matt Wilcox to have a board
available ...

Ondrej, if you got a narrow board I'd be willing to to the split and
let you test out the result.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
                   ` (13 preceding siblings ...)
  2014-12-03 16:06 ` Douglas Gilbert
@ 2014-12-03 18:29 ` Ondrej Zary
  2014-12-04  7:12   ` Hannes Reinecke
  14 siblings, 1 reply; 30+ messages in thread
From: Ondrej Zary @ 2014-12-03 18:29 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

On Wednesday 03 December 2014 12:44:53 Hannes Reinecke wrote:
> Hi all,
>
> it has been bugged me for ages that the advansys driver always
> reported a compilation warning about not having been converted
> to the DMA-API.
> And even aggressive waiting hasn't made this warning go away.
>
> So here's a patchset to update the advansys driver to current
> standards and use the DMA-API.
> Tested on ABP940-U2W.
>
> As usual, reviews and comments are welcome.
>
> Hannes Reinecke (12):
>   advansys: use host_reset
>   advansys: use shared host tag map for command lookup
>   advansys: use DMA-API for mapping sense buffer
>   advansys: Use DMA-API for carrier buffer
>   advansys: Use DMA-API for mapping request blocks
>   advansys: Use dma_pool for sg elements
>   advansys: use 'bool' instead of 'int'
>   advansys: use standard data types
>   advansys: Remove 'TRUE' and 'FALSE' definitions
>   advansys: Remove 'ERR' definition
>   advansys: cleanup function return codes
>   advansys: Update to version 3.5 and remove compilation warning
>
>  MAINTAINERS             |    1 +
>  drivers/scsi/advansys.c | 1073
> +++++++++++++++++++++-------------------------- 2 files changed, 469
> insertions(+), 605 deletions(-)

Seems to break narrow boards, at least mine ASB-3940UA :(

[    4.266292] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
[    7.661374] scsi host2: AdvanSys SCSI 3.5: PCI Ultra: IO 0xA800-0xA80F, IRQ 0x9
[   28.840078] scsi 2:0:0:0: SCSI bus reset started...
[   28.846640] scsi 2:0:0:0: SCSI bus reset error: 0x2, status: 0x0
[   28.846648] scsi 2:0:0:0: Device offlined - not ready after error recovery
[   28.846803] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.852052] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.860051] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.868047] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.868249] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.876050] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.884048] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.892047] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.892243] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.900051] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.908048] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.916047] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.916241] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.924051] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.932048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.940048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.940240] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.948051] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.956049] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.964047] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.964239] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.972050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.980048] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
[   28.988050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2

Before the patch:
[    4.226690] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
[    7.644841] scsi host2: AdvanSys SCSI 3.4: PCI Ultra: IO 0xA800-0xA80F, IRQ 0x9
[    8.072257] scsi 2:0:2:0: Processor         HP       C1790A           3226 PQ: 0 ANSI: 2
[    8.919128] scsi 2:0:2:0: Attached scsi generic sg3 type 3

-- 
Ondrej Zary

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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 18:29 ` Ondrej Zary
@ 2014-12-04  7:12   ` Hannes Reinecke
  2014-12-07 14:44     ` Ondrej Zary
  0 siblings, 1 reply; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-04  7:12 UTC (permalink / raw)
  To: Ondrej Zary
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

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

On 12/03/2014 07:29 PM, Ondrej Zary wrote:
> On Wednesday 03 December 2014 12:44:53 Hannes Reinecke wrote:
>> Hi all,
>>
>> it has been bugged me for ages that the advansys driver always
>> reported a compilation warning about not having been converted
>> to the DMA-API.
>> And even aggressive waiting hasn't made this warning go away.
>>
>> So here's a patchset to update the advansys driver to current
>> standards and use the DMA-API.
>> Tested on ABP940-U2W.
>>
>> As usual, reviews and comments are welcome.
>>
>> Hannes Reinecke (12):
>>   advansys: use host_reset
>>   advansys: use shared host tag map for command lookup
>>   advansys: use DMA-API for mapping sense buffer
>>   advansys: Use DMA-API for carrier buffer
>>   advansys: Use DMA-API for mapping request blocks
>>   advansys: Use dma_pool for sg elements
>>   advansys: use 'bool' instead of 'int'
>>   advansys: use standard data types
>>   advansys: Remove 'TRUE' and 'FALSE' definitions
>>   advansys: Remove 'ERR' definition
>>   advansys: cleanup function return codes
>>   advansys: Update to version 3.5 and remove compilation warning
>>
>>  MAINTAINERS             |    1 +
>>  drivers/scsi/advansys.c | 1073
>> +++++++++++++++++++++-------------------------- 2 files changed, 469
>> insertions(+), 605 deletions(-)
> 
> Seems to break narrow boards, at least mine ASB-3940UA :(
> 
> [    4.266292] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
> [    7.661374] scsi host2: AdvanSys SCSI 3.5: PCI Ultra: IO 0xA800-0xA80F, IRQ 0x9
> [   28.840078] scsi 2:0:0:0: SCSI bus reset started...
> [   28.846640] scsi 2:0:0:0: SCSI bus reset error: 0x2, status: 0x0
> [   28.846648] scsi 2:0:0:0: Device offlined - not ready after error recovery
> [   28.846803] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.852052] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.860051] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.868047] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.868249] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.876050] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.884048] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.892047] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.892243] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.900051] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.908048] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.916047] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.916241] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.924051] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.932048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.940048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.940240] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.948051] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.956049] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.964047] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.964239] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.972050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.980048] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> [   28.988050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> 
> Before the patch:
> [    4.226690] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
> [    7.644841] scsi host2: AdvanSys SCSI 3.4: PCI Ultra: IO 0xA800-0xA80F, IRQ 0x9
> [    8.072257] scsi 2:0:2:0: Processor         HP       C1790A           3226 PQ: 0 ANSI: 2
> [    8.919128] scsi 2:0:2:0: Attached scsi generic sg3 type 3
> 
Right. So _this_ was the mysterious command about srb_tag '0' being
reserved. Can you try with this patch?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)

[-- Attachment #2: 0001-advansys-do-not-use-srb_tag-0-for-narrow-boards.patch --]
[-- Type: text/x-patch, Size: 2015 bytes --]

>From 1a2ed278e20636a6b242d9450d36b433af44ddf4 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 4 Dec 2014 08:08:48 +0100
Subject: [PATCH] advansys: do not use srb_tag '0' for narrow boards

The srb_tag '0' is used by the chip internally, so we
need to increase the request tag by 1 to avoid using it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/advansys.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4f3f948..15c555f 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7003,8 +7003,11 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 	ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
 	ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
 
+	/*
+	 * Decrease the srb_tag by 1 to find the SCSI command
+	 */
 	srb_tag = le32_to_cpu(qdonep->d2.srb_tag);
-	scp = scsi_host_find_tag(boardp->shost, srb_tag);
+	scp = scsi_host_find_tag(boardp->shost, srb_tag - 1);
 	if (!scp)
 		return;
 
@@ -7193,10 +7196,6 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
 			scsiq->d3.done_stat = QD_WITH_ERROR;
 			goto FATAL_ERR_QDONE;
 		}
-		/*
-		 * Fixme: this doesn't look right.
-		 * We can easily get an srb_tag of 0.
-		 */
 		if ((scsiq->d2.srb_tag == 0UL) ||
 		    ((scsiq->q_status & QS_ABORTED) != 0)) {
 			return (0x11);
@@ -7775,13 +7774,16 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 {
 	struct asc_dvc_var *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 	int use_sg;
+	u32 srb_tag;
 
 	memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
 
 	/*
-	 * Set the srb_tag to the command tag.
+	 * Set the srb_tag to the command tag + 1, as
+	 * srb_tag '0' is used internally by the chip.
 	 */
-	asc_scsi_q->q2.srb_tag = cpu_to_le32(scp->request->tag);
+	srb_tag = scp->request->tag + 1;
+	asc_scsi_q->q2.srb_tag = cpu_to_le32(srb_tag);
 
 	/*
 	 * Build the ASC_SCSI_Q request.
-- 
1.8.5.2


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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 15:34   ` Ondrej Zary
  2014-12-03 15:42     ` James Bottomley
@ 2014-12-04  9:12     ` Christoph Hellwig
  1 sibling, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-04  9:12 UTC (permalink / raw)
  To: Ondrej Zary
  Cc: Christoph Hellwig, Hannes Reinecke, James Bottomley,
	Matthew Wilcox, Doug Gilbert, linux-scsi

On Wed, Dec 03, 2014 at 04:34:48PM +0100, Ondrej Zary wrote:
> I have an ASB-3940UA (bought around 2000) and use it for scanner so I can test 
> patches.
> The driver was working fine so I never had to look at the code. Now I see that 
> it's 12K lines long :( Converting that to something simple would require a 
> lot of work.

So we've got a dedicated tester for the narrow boards :)

Just by splitting that monster in the two drivers it's underneath and
removing various pointless wrappers they'd be down to a fairly reasonable
size.

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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-03 15:42     ` James Bottomley
  2014-12-03 16:28       ` Hannes Reinecke
@ 2014-12-04  9:13       ` hch
  1 sibling, 0 replies; 30+ messages in thread
From: hch @ 2014-12-04  9:13 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux, hch, linux-scsi, dgilbert, hare, matthew

On Wed, Dec 03, 2014 at 03:42:19PM +0000, James Bottomley wrote:
> That's the problem: The driver as-is works in all of the use cases, so
> no-one has any motivation to fix it.  Plus the complexity is pretty
> daunting.  It's not even the worst driver we have (that prize goes to
> atp870u which still has internal bus scanning code).  I'm not saying
> don't do the conversion, but I am saying it will have to be validated
> and tested before it can go in because lots of people still seem to use
> this family of devices in odd corners of the world.

The split itself actually is really easy - every single method has
a "if (ASC_NARROW_BOARD(boardp)) { ... } else { ... }" so the
code actually is separate.  But now that we have Hannes interested
in the wide side, and also a tester for the the narrow side I think we're
fine anyway.

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

* Re: [PATCH 01/12] advansys: use host_reset
  2014-12-03 11:44 ` [PATCH 01/12] advansys: use host_reset Hannes Reinecke
@ 2014-12-04  9:17   ` Christoph Hellwig
  2014-12-04  9:23     ` Hannes Reinecke
  0 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-04  9:17 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

> -#define AdvAbortQueue(asc_dvc, scsiq) \
> +#define AdvAbortQueue(asc_dvc, srb_tag) \
>          AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
> -                       (ADV_DCNT) (scsiq))
> +                       (ADV_DCNT) (srb_tag))

This change looks unrelated.

> @@ -11250,7 +11250,7 @@ static struct scsi_host_template advansys_template = {
>  	.name = DRV_NAME,
>  	.info = advansys_info,
>  	.queuecommand = advansys_queuecommand,
> -	.eh_bus_reset_handler = advansys_reset,
> +	.eh_host_reset_handler = advansys_reset,

Please also update the comments in advansys_reset that talk about bus
resets and in one case event about a device reset.


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

* Re: [PATCH 02/12] advansys: use shared host tag map for command lookup
  2014-12-03 11:44 ` [PATCH 02/12] advansys: use shared host tag map for command lookup Hannes Reinecke
@ 2014-12-04  9:20   ` Christoph Hellwig
  2014-12-04  9:25     ` Hannes Reinecke
  0 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-04  9:20 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

>  typedef struct asc_scsiq_2 {
> -	ASC_VADDR srb_ptr;
> +	__le32 srb_tag;

Given that the tag has no meaning for the hardware why do you
want to endian switch it?  Keeping the ASC_VADDR for now makes
it easier to verify the hardware structures don't change.

> @@ -6132,6 +6077,13 @@ static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
>  		AdvResetChipAndSB(adv_dvc_varp);
>  		break;
>  
> +	case ADV_ASYNC_CARRIER_READY_FAILURE:
> +		/*
> +		 * Carrier not ready; abort the command.
> +		 */
> +		ASC_DBG(0, "ADV_ASYNC_CARRIER_READY_FAILURE\n");
> +		break;
> +

Where does this one come from?


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

* Re: [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning
  2014-12-03 11:45 ` [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning Hannes Reinecke
@ 2014-12-04  9:23   ` Christoph Hellwig
  2014-12-04  9:26     ` Hannes Reinecke
  0 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-04  9:23 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

>  /* FIXME:
>   *
> - *  1. Although all of the necessary command mapping places have the
> - *     appropriate dma_map.. APIs, the driver still processes its internal
> - *     queue using bus_to_virt() and virt_to_bus() which are illegal under
> - *     the API.  The entire queue processing structure will need to be
> - *     altered to fix this.
> + *  1. (done)
>   *  2. Need to add memory mapping workaround. Test the memory mapping.
>   *     If it doesn't work revert to I/O port access. Can a test be done
>   *     safely?
>   *  3. Handle an interrupt not working. Keep an interrupt counter in
>   *     the interrupt handler. In the timeout function if the interrupt
>   *     has not occurred then print a message and run in polled mode.
> - *  4. Need to add support for target mode commands, cf. CAM XPT.
> - *  5. check DMA mapping functions for failure
> + *  4. (obsolete)
> + *  5. (done)
>   *  6. Use scsi_transport_spi
>   *  7. advansys_info is not safe against multiple simultaneous callers
>   *  8. Add module_param to override ISA/VLB ioport array


Just drop the done/obsolete items and renumber the rest :)

> +	if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) {
> +		ASC_DBG(1, "failed to map sense buffer\n");
> +		return 0;
> +	}
>  	dma_cache_sync(board->dev, scp->sense_buffer,
>  		       SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
>  	return cpu_to_le32(scp->SCp.dma_handle);
> @@ -7794,6 +7794,8 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
>  	    ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
>  	asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
>  	asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
> +	if (!asc_scsi_q->q1.sense_addr)
> +		return ASC_ERROR;

Please split the addition of error handling into a separate patch,
or in case of newly added mappigns add them to the patch that add the
mappings.

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

* Re: [PATCH 01/12] advansys: use host_reset
  2014-12-04  9:17   ` Christoph Hellwig
@ 2014-12-04  9:23     ` Hannes Reinecke
  0 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-04  9:23 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Matthew Wilcox, Doug Gilbert, linux-scsi

On 12/04/2014 10:17 AM, Christoph Hellwig wrote:
>> -#define AdvAbortQueue(asc_dvc, scsiq) \
>> +#define AdvAbortQueue(asc_dvc, srb_tag) \
>>          AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
>> -                       (ADV_DCNT) (scsiq))
>> +                       (ADV_DCNT) (srb_tag))
> 
> This change looks unrelated.
> 
Yes, correct. This needs to be moved to the next patch.

>> @@ -11250,7 +11250,7 @@ static struct scsi_host_template advansys_template = {
>>  	.name = DRV_NAME,
>>  	.info = advansys_info,
>>  	.queuecommand = advansys_queuecommand,
>> -	.eh_bus_reset_handler = advansys_reset,
>> +	.eh_host_reset_handler = advansys_reset,
> 
> Please also update the comments in advansys_reset that talk about bus
> resets and in one case event about a device reset.
> 
Okay.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 02/12] advansys: use shared host tag map for command lookup
  2014-12-04  9:20   ` Christoph Hellwig
@ 2014-12-04  9:25     ` Hannes Reinecke
  2014-12-04  9:26       ` Christoph Hellwig
  0 siblings, 1 reply; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-04  9:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Matthew Wilcox, Doug Gilbert, linux-scsi

On 12/04/2014 10:20 AM, Christoph Hellwig wrote:
>>  typedef struct asc_scsiq_2 {
>> -	ASC_VADDR srb_ptr;
>> +	__le32 srb_tag;
> 
> Given that the tag has no meaning for the hardware why do you
> want to endian switch it?  Keeping the ASC_VADDR for now makes
> it easier to verify the hardware structures don't change.
> 
Mhm. See the patch I've just sent to Ondrej.
For the narrow board it actually _has_ a meaning.
But okay, the endian switch is probably pointless here.

>> @@ -6132,6 +6077,13 @@ static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
>>  		AdvResetChipAndSB(adv_dvc_varp);
>>  		break;
>>  
>> +	case ADV_ASYNC_CARRIER_READY_FAILURE:
>> +		/*
>> +		 * Carrier not ready; abort the command.
>> +		 */
>> +		ASC_DBG(0, "ADV_ASYNC_CARRIER_READY_FAILURE\n");
>> +		break;
>> +
> 
> Where does this one come from?
> 
Encountered during debugging, I just thought to have it printed.
But okay, I can move it into a separate patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning
  2014-12-04  9:23   ` Christoph Hellwig
@ 2014-12-04  9:26     ` Hannes Reinecke
  0 siblings, 0 replies; 30+ messages in thread
From: Hannes Reinecke @ 2014-12-04  9:26 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Matthew Wilcox, Doug Gilbert, linux-scsi

On 12/04/2014 10:23 AM, Christoph Hellwig wrote:
>>  /* FIXME:
>>   *
>> - *  1. Although all of the necessary command mapping places have the
>> - *     appropriate dma_map.. APIs, the driver still processes its internal
>> - *     queue using bus_to_virt() and virt_to_bus() which are illegal under
>> - *     the API.  The entire queue processing structure will need to be
>> - *     altered to fix this.
>> + *  1. (done)
>>   *  2. Need to add memory mapping workaround. Test the memory mapping.
>>   *     If it doesn't work revert to I/O port access. Can a test be done
>>   *     safely?
>>   *  3. Handle an interrupt not working. Keep an interrupt counter in
>>   *     the interrupt handler. In the timeout function if the interrupt
>>   *     has not occurred then print a message and run in polled mode.
>> - *  4. Need to add support for target mode commands, cf. CAM XPT.
>> - *  5. check DMA mapping functions for failure
>> + *  4. (obsolete)
>> + *  5. (done)
>>   *  6. Use scsi_transport_spi
>>   *  7. advansys_info is not safe against multiple simultaneous callers
>>   *  8. Add module_param to override ISA/VLB ioport array
> 
> 
> Just drop the done/obsolete items and renumber the rest :)
> 
>> +	if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) {
>> +		ASC_DBG(1, "failed to map sense buffer\n");
>> +		return 0;
>> +	}
>>  	dma_cache_sync(board->dev, scp->sense_buffer,
>>  		       SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
>>  	return cpu_to_le32(scp->SCp.dma_handle);
>> @@ -7794,6 +7794,8 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
>>  	    ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
>>  	asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
>>  	asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
>> +	if (!asc_scsi_q->q1.sense_addr)
>> +		return ASC_ERROR;
> 
> Please split the addition of error handling into a separate patch,
> or in case of newly added mappigns add them to the patch that add the
> mappings.
> 
Okay.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 02/12] advansys: use shared host tag map for command lookup
  2014-12-04  9:25     ` Hannes Reinecke
@ 2014-12-04  9:26       ` Christoph Hellwig
  0 siblings, 0 replies; 30+ messages in thread
From: Christoph Hellwig @ 2014-12-04  9:26 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Matthew Wilcox, Doug Gilbert,
	linux-scsi

On Thu, Dec 04, 2014 at 10:25:41AM +0100, Hannes Reinecke wrote:
> > Given that the tag has no meaning for the hardware why do you
> > want to endian switch it?  Keeping the ASC_VADDR for now makes
> > it easier to verify the hardware structures don't change.
> > 
> Mhm. See the patch I've just sent to Ondrej.
> For the narrow board it actually _has_ a meaning.
> But okay, the endian switch is probably pointless here.

Well, 0 vs non-0 isn't changed by endian conversion.  And the old
driver didn't do it either, so changing to and endianess conversion
needs to be documented, and preferably in a separate patch.


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

* Re: [PATCH 00/12] nobody loves the advansys driver
  2014-12-04  7:12   ` Hannes Reinecke
@ 2014-12-07 14:44     ` Ondrej Zary
  0 siblings, 0 replies; 30+ messages in thread
From: Ondrej Zary @ 2014-12-07 14:44 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, Christoph Hellwig, Matthew Wilcox, Doug Gilbert,
	linux-scsi

On Thursday 04 December 2014 08:12:53 Hannes Reinecke wrote:
> On 12/03/2014 07:29 PM, Ondrej Zary wrote:
> > On Wednesday 03 December 2014 12:44:53 Hannes Reinecke wrote:
> >> Hi all,
> >>
> >> it has been bugged me for ages that the advansys driver always
> >> reported a compilation warning about not having been converted
> >> to the DMA-API.
> >> And even aggressive waiting hasn't made this warning go away.
> >>
> >> So here's a patchset to update the advansys driver to current
> >> standards and use the DMA-API.
> >> Tested on ABP940-U2W.
> >>
> >> As usual, reviews and comments are welcome.
> >>
> >> Hannes Reinecke (12):
> >>   advansys: use host_reset
> >>   advansys: use shared host tag map for command lookup
> >>   advansys: use DMA-API for mapping sense buffer
> >>   advansys: Use DMA-API for carrier buffer
> >>   advansys: Use DMA-API for mapping request blocks
> >>   advansys: Use dma_pool for sg elements
> >>   advansys: use 'bool' instead of 'int'
> >>   advansys: use standard data types
> >>   advansys: Remove 'TRUE' and 'FALSE' definitions
> >>   advansys: Remove 'ERR' definition
> >>   advansys: cleanup function return codes
> >>   advansys: Update to version 3.5 and remove compilation warning
> >>
> >>  MAINTAINERS             |    1 +
> >>  drivers/scsi/advansys.c | 1073
> >> +++++++++++++++++++++-------------------------- 2 files changed, 469
> >> insertions(+), 605 deletions(-)
> >
> > Seems to break narrow boards, at least mine ASB-3940UA :(
> >
> > [    4.266292] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
> > [    7.661374] scsi host2: AdvanSys SCSI 3.5: PCI Ultra: IO
> > 0xA800-0xA80F, IRQ 0x9 [   28.840078] scsi 2:0:0:0: SCSI bus reset
> > started...
> > [   28.846640] scsi 2:0:0:0: SCSI bus reset error: 0x2, status: 0x0
> > [   28.846648] scsi 2:0:0:0: Device offlined - not ready after error
> > recovery [   28.846803] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code
> > 0x2 [   28.852052] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [
> >   28.860051] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.868047] scsi 2:0:1:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.868249] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.876050] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.884048] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.892047] scsi 2:0:2:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.892243] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.900051] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.908048] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.916047] scsi 2:0:3:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.916241] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.924051] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.932048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.940048] scsi 2:0:4:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.940240] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.948051] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.956049] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.964047] scsi 2:0:5:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.964239] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.972050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.980048] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2 [  
> > 28.988050] scsi 2:0:6:0: ExeScsiQueue() ASC_ERROR, err_code 0x2
> >
> > Before the patch:
> > [    4.226690] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 9
> > [    7.644841] scsi host2: AdvanSys SCSI 3.4: PCI Ultra: IO
> > 0xA800-0xA80F, IRQ 0x9 [    8.072257] scsi 2:0:2:0: Processor         HP 
> >      C1790A           3226 PQ: 0 ANSI: 2 [    8.919128] scsi 2:0:2:0:
> > Attached scsi generic sg3 type 3
>
> Right. So _this_ was the mysterious command about srb_tag '0' being
> reserved. Can you try with this patch?

Thanks, it fixes the problem.

-- 
Ondrej Zary

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

end of thread, other threads:[~2014-12-07 14:45 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03 11:44 [PATCH 00/12] nobody loves the advansys driver Hannes Reinecke
2014-12-03 11:44 ` [PATCH 01/12] advansys: use host_reset Hannes Reinecke
2014-12-04  9:17   ` Christoph Hellwig
2014-12-04  9:23     ` Hannes Reinecke
2014-12-03 11:44 ` [PATCH 02/12] advansys: use shared host tag map for command lookup Hannes Reinecke
2014-12-04  9:20   ` Christoph Hellwig
2014-12-04  9:25     ` Hannes Reinecke
2014-12-04  9:26       ` Christoph Hellwig
2014-12-03 11:44 ` [PATCH 03/12] advansys: use DMA-API for mapping sense buffer Hannes Reinecke
2014-12-03 11:44 ` [PATCH 04/12] advansys: Use DMA-API for carrier buffer Hannes Reinecke
2014-12-03 11:44 ` [PATCH 05/12] advansys: Use DMA-API for mapping request blocks Hannes Reinecke
2014-12-03 11:44 ` [PATCH 06/12] advansys: Use dma_pool for sg elements Hannes Reinecke
2014-12-03 11:45 ` [PATCH 07/12] advansys: use 'bool' instead of 'int' Hannes Reinecke
2014-12-03 11:45 ` [PATCH 08/12] advansys: use standard data types Hannes Reinecke
2014-12-03 11:45 ` [PATCH 09/12] advansys: Remove 'TRUE' and 'FALSE' definitions Hannes Reinecke
2014-12-03 11:45 ` [PATCH 10/12] advansys: Remove 'ERR' definition Hannes Reinecke
2014-12-03 11:45 ` [PATCH 11/12] advansys: cleanup function return codes Hannes Reinecke
2014-12-03 11:45 ` [PATCH 12/12] advansys: Update to version 3.5 and remove compilation warning Hannes Reinecke
2014-12-04  9:23   ` Christoph Hellwig
2014-12-04  9:26     ` Hannes Reinecke
2014-12-03 15:21 ` [PATCH 00/12] nobody loves the advansys driver Christoph Hellwig
2014-12-03 15:34   ` Ondrej Zary
2014-12-03 15:42     ` James Bottomley
2014-12-03 16:28       ` Hannes Reinecke
2014-12-04  9:13       ` hch
2014-12-04  9:12     ` Christoph Hellwig
2014-12-03 16:06 ` Douglas Gilbert
2014-12-03 18:29 ` Ondrej Zary
2014-12-04  7:12   ` Hannes Reinecke
2014-12-07 14:44     ` Ondrej Zary

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.