[PATCH 4/4] Don't crash on IOMMU overflow in A100U2W driver

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <torvalds@...>
Cc: <linux-scsi@...>, <linux-kernel@...>
Date: Tuesday, July 15, 2008 - 5:19 pm

Handle IOMMU overflow correctly, by retrying. IOMMU errors can happen and 
drivers must deal with them.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
 drivers/scsi/a100u2w.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: linux-2.6.26-fast/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-fast.orig/drivers/scsi/a100u2w.c	2008-07-15 15:49:39.000000000 +0200
+++ linux-2.6.26-fast/drivers/scsi/a100u2w.c	2008-07-15 16:04:50.000000000 +0200
@@ -840,7 +840,7 @@ static irqreturn_t orc_interrupt(struct 
  *	Build a host adapter control block from the SCSI mid layer command
  */
 
-static void inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd)
+static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd)
 {				/* Create corresponding SCB     */
 	struct scatterlist *sg;
 	struct orc_sgent *sgent;		/* Pointer to SG list           */
@@ -865,7 +865,8 @@ static void inia100_build_scb(struct orc
 	sgent = (struct orc_sgent *) & escb->sglist[0];
 
 	count_sg = scsi_dma_map(cmd);
-	BUG_ON(count_sg < 0);
+	if (count_sg < 0)
+		return count_sg;
 	BUG_ON(count_sg > TOTAL_SG_ENTRY);
 
 	/* Build the scatter gather lists */
@@ -898,6 +899,7 @@ static void inia100_build_scb(struct orc
 		scb->tag_msg = 0;	/* No tag support               */
 	}
 	memcpy(scb->cdb, cmd->cmnd, scb->cdb_len);
+	return 0;
 }
 
 /**
@@ -921,7 +923,10 @@ static int inia100_queue(struct scsi_cmn
 	if ((scb = orc_alloc_scb(host)) == NULL)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
-	inia100_build_scb(host, scb, cmd);
+	if (inia100_build_scb(host, scb, cmd)) {
+		orc_release_scb(host, scb);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
 	orc_exec_scb(host, scb);	/* Start execute SCB            */
 	return 0;
 }
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/4] Fix endianity in A100U2W SCSI driver, Mikulas Patocka, (Tue Jul 15, 10:11 am)
Re: [PATCH 1/4] Fix endianity in A100U2W SCSI driver, Linus Torvalds, (Tue Jul 15, 1:23 pm)
[PATCH 1/4] Fix endianity in A100U2W SCSI driver, Mikulas Patocka, (Tue Jul 15, 5:15 pm)
[PATCH 2/4] Add udelay to A100U2W SCSI driver, Mikulas Patocka, (Tue Jul 15, 10:12 am)
[PATCH 2/4] Add udelay to A100U2W SCSI driver, Mikulas Patocka, (Tue Jul 15, 5:16 pm)
[PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver, Mikulas Patocka, (Tue Jul 15, 10:14 am)
[PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver, Mikulas Patocka, (Tue Jul 15, 5:18 pm)
[PATCH 4/4] Don't crash on IOMMU overflow in A100U2W driver, Mikulas Patocka, (Tue Jul 15, 10:15 am)
[PATCH 4/4] Don't crash on IOMMU overflow in A100U2W driver, Mikulas Patocka, (Tue Jul 15, 5:19 pm)