public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Fix endianity in A100U2W SCSI driver
@ 2008-07-15 14:11 Mikulas Patocka
  2008-07-15 14:12 ` [PATCH 2/4] Add udelay to " Mikulas Patocka
  2008-07-15 17:23 ` [PATCH 1/4] Fix endianity in " Linus Torvalds
  0 siblings, 2 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 14:11 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

(sending to Linus, because there's no maintainer for this driver)

Support big endian systems.

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

Index: linux-2.6.26-rc8/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-rc8.orig/drivers/scsi/a100u2w.c	2008-06-25 03:58:20.000000000 +0200
+++ linux-2.6.26-rc8/drivers/scsi/a100u2w.c	2008-07-01 18:51:20.000000000 +0200
@@ -389,7 +389,7 @@ static u8 orc_load_firmware(struct orc_h

  	outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL);	/* Enable SRAM programming */
  	data32_ptr = (u8 *) & data32;
-	data32 = 0;		/* Initial FW address to 0 */
+	data32 = cpu_to_le32(0);		/* Initial FW address to 0 */
  	outw(0x0010, host->base + ORC_EBIOSADR0);
  	*data32_ptr = inb(host->base + ORC_EBIOSDATA);		/* Read from BIOS */
  	outw(0x0011, host->base + ORC_EBIOSADR0);
@@ -397,18 +397,18 @@ static u8 orc_load_firmware(struct orc_h
  	outw(0x0012, host->base + ORC_EBIOSADR0);
  	*(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
  	outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2);
-	outl(data32, host->base + ORC_FWBASEADR);		/* Write FW address */
+	outl(le32_to_cpu(data32), host->base + ORC_FWBASEADR);		/* Write FW address */

  	/* Copy the code from the BIOS to the SRAM */

-	bios_addr = (u16) data32;	/* FW code locate at BIOS address + ? */
+	bios_addr = (u16) le32_to_cpu(data32);	/* FW code locate at BIOS address + ? */
  	for (i = 0, data32_ptr = (u8 *) & data32;	/* Download the code    */
  	     i < 0x1000;	/* Firmware code size = 4K      */
  	     i++, bios_addr++) {
  		outw(bios_addr, host->base + ORC_EBIOSADR0);
  		*data32_ptr++ = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
  		if ((i % 4) == 3) {
-			outl(data32, host->base + ORC_RISCRAM);	/* Write every 4 bytes */
+			outl(le32_to_cpu(data32), host->base + ORC_RISCRAM);	/* Write every 4 bytes */
  			data32_ptr = (u8 *) & data32;
  		}
  	}
@@ -423,7 +423,7 @@ static u8 orc_load_firmware(struct orc_h
  		outw(bios_addr, host->base + ORC_EBIOSADR0);
  		*data32_ptr++ = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
  		if ((i % 4) == 3) {
-			if (inl(host->base + ORC_RISCRAM) != data32) {
+			if (inl(host->base + ORC_RISCRAM) != le32_to_cpu(data32)) {
  				outb(PRGMRST, host->base + ORC_RISCCTL);	/* Reset program to 0 */
  				outb(data, host->base + ORC_GCFG);	/*Disable EEPROM programming */
  				return 0;
@@ -459,8 +459,8 @@ static void setup_SCBs(struct orc_host *

  	for (i = 0; i < ORC_MAXQUEUE; i++) {
  		escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i));
-		scb->sg_addr = (u32) escb_phys;
-		scb->sense_addr = (u32) escb_phys;
+		scb->sg_addr = cpu_to_le32((u32) escb_phys);
+		scb->sense_addr = cpu_to_le32((u32) escb_phys);
  		scb->escb = escb;
  		scb->scbidx = i;
  		scb++;
@@ -642,8 +642,8 @@ static int orc_device_reset(struct orc_h
  	scb->link = 0xFF;
  	scb->reserved0 = 0;
  	scb->reserved1 = 0;
-	scb->xferlen = 0;
-	scb->sg_len = 0;
+	scb->xferlen = cpu_to_le32(0);
+	scb->sg_len = cpu_to_le32(0);

  	escb->srb = NULL;
  	escb->srb = cmd;
@@ -858,9 +858,9 @@ static void inia100_build_scb(struct orc
  	scb->lun = cmd->device->lun;
  	scb->reserved0 = 0;
  	scb->reserved1 = 0;
-	scb->sg_len = 0;
+	scb->sg_len = cpu_to_le32(0);

-	scb->xferlen = (u32) scsi_bufflen(cmd);
+	scb->xferlen = cpu_to_le32((u32) scsi_bufflen(cmd));
  	sgent = (struct orc_sgent *) & escb->sglist[0];

  	count_sg = scsi_dma_map(cmd);
@@ -868,18 +868,18 @@ static void inia100_build_scb(struct orc

  	/* Build the scatter gather lists */
  	if (count_sg) {
-		scb->sg_len = (u32) (count_sg * 8);
+		scb->sg_len = cpu_to_le32((u32) (count_sg * 8));
  		scsi_for_each_sg(cmd, sg, count_sg, i) {
-			sgent->base = (u32) sg_dma_address(sg);
-			sgent->length = (u32) sg_dma_len(sg);
+			sgent->base = cpu_to_le32((u32) sg_dma_address(sg));
+			sgent->length = cpu_to_le32((u32) sg_dma_len(sg));
  			sgent++;
  		}
  	} else {
-		scb->sg_len = 0;
-		sgent->base = 0;
-		sgent->length = 0;
+		scb->sg_len = cpu_to_le32(0);
+		sgent->base = cpu_to_le32(0);
+		sgent->length = cpu_to_le32(0);
  	}
-	scb->sg_addr = (u32) scb->sense_addr;
+	scb->sg_addr = (u32) scb->sense_addr;	/* sense_addr is already little endian */
  	scb->hastat = 0;
  	scb->tastat = 0;
  	scb->link = 0xFF;

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

* [PATCH 2/4] Add udelay to A100U2W SCSI driver
  2008-07-15 14:11 [PATCH 1/4] Fix endianity in A100U2W SCSI driver Mikulas Patocka
@ 2008-07-15 14:12 ` Mikulas Patocka
  2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
  2008-07-15 21:16   ` [PATCH 2/4] Add udelay to A100U2W SCSI driver Mikulas Patocka
  2008-07-15 17:23 ` [PATCH 1/4] Fix endianity in " Linus Torvalds
  1 sibling, 2 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 14:12 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

udelay is required on Sun Ultra 5.
I don't know any reason or explanation for this, it was found purely
experimentally.

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

Index: linux-2.6.26-rc8/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-rc8.orig/drivers/scsi/a100u2w.c	2008-07-01 18:48:09.000000000 +0200
+++ linux-2.6.26-rc8/drivers/scsi/a100u2w.c	2008-07-01 18:48:11.000000000 +0200
@@ -401,6 +401,7 @@ static u8 orc_load_firmware(struct orc_h

  	/* Copy the code from the BIOS to the SRAM */

+	udelay(500);	/* Required on Sun Ultra 5 ... 350 -> failures */
  	bios_addr = (u16) le32_to_cpu(data32);	/* FW code locate at BIOS address + ? */
  	for (i = 0, data32_ptr = (u8 *) & data32;	/* Download the code    */
  	     i < 0x1000;	/* Firmware code size = 4K      */

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

* [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver
  2008-07-15 14:12 ` [PATCH 2/4] Add udelay to " Mikulas Patocka
@ 2008-07-15 14:14   ` Mikulas Patocka
  2008-07-15 14:15     ` [PATCH 4/4] Don't crash on IOMMU overflow in " Mikulas Patocka
                       ` (2 more replies)
  2008-07-15 21:16   ` [PATCH 2/4] Add udelay to A100U2W SCSI driver Mikulas Patocka
  1 sibling, 3 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 14:14 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

With broken Sparc64 IOMMU accounting, the kernel submits larger requests 
then allowed. Better to crash on BUG than corrupt memory. This needs to be 
fixed in sparc64 code.

For description of the crashes, see: 
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0807.1/1465.html

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

Index: linux-2.6.26-devel/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-devel.orig/drivers/scsi/a100u2w.c	2008-07-14 20:03:43.000000000 +0200
+++ linux-2.6.26-devel/drivers/scsi/a100u2w.c	2008-07-15 00:46:02.000000000 +0200
@@ -866,6 +866,7 @@ static void inia100_build_scb(struct orc

  	count_sg = scsi_dma_map(cmd);
  	BUG_ON(count_sg < 0);
+	BUG_ON(count_sg > TOTAL_SG_ENTRY);

  	/* Build the scatter gather lists */
  	if (count_sg) {

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

* [PATCH 4/4] Don't crash on IOMMU overflow in A100U2W driver
  2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
@ 2008-07-15 14:15     ` Mikulas Patocka
  2008-07-15 21:19       ` Mikulas Patocka
  2008-07-15 15:17     ` [PATCH 3/4] BUG_ON on kernel misbehavior on " James Bottomley
  2008-07-15 21:18     ` Mikulas Patocka
  2 siblings, 1 reply; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 14:15 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

Handle IOMMU overflow correctly, by retrying.

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;
  }

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

* Re: [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver
  2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
  2008-07-15 14:15     ` [PATCH 4/4] Don't crash on IOMMU overflow in " Mikulas Patocka
@ 2008-07-15 15:17     ` James Bottomley
  2008-07-15 21:18     ` Mikulas Patocka
  2 siblings, 0 replies; 10+ messages in thread
From: James Bottomley @ 2008-07-15 15:17 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: torvalds, linux-scsi, linux-kernel

On Tue, 2008-07-15 at 10:14 -0400, Mikulas Patocka wrote:
> With broken Sparc64 IOMMU accounting, the kernel submits larger requests 
> then allowed. Better to crash on BUG than corrupt memory. This needs to be 
> fixed in sparc64 code.

This analysis is correct ... and the reason we don't add driver work
arounds, so it really needs to be fixed in sparc, not worked around in
the driver.

James



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

* Re: [PATCH 1/4] Fix endianity in A100U2W SCSI driver
  2008-07-15 14:11 [PATCH 1/4] Fix endianity in A100U2W SCSI driver Mikulas Patocka
  2008-07-15 14:12 ` [PATCH 2/4] Add udelay to " Mikulas Patocka
@ 2008-07-15 17:23 ` Linus Torvalds
  2008-07-15 21:15   ` Mikulas Patocka
  1 sibling, 1 reply; 10+ messages in thread
From: Linus Torvalds @ 2008-07-15 17:23 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: linux-scsi, linux-kernel



On Tue, 15 Jul 2008, Mikulas Patocka wrote:
> 
> Support big endian systems.

Hmm. Your email seems whitespace-corrupted.

It's a strange form of corruption, where a line that should start with a 
single space and a tab (normal for a patch) seems to have _two_ spaces and 
a tab. Empty lines with just a space have also had their space removed.

You seem to be a pine user (good man - but you may want to update to 
'alpine' these days and enjoy the much improved multi-charset support), 
but you also have "format=flowed", and I suspect that's related to the 
problem.

So please check the config option that says "quell flowed text", and make 
sure that "no strip whitespace before send" is also set.

I'll drop the patches, please re-send.

		Linus

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

* [PATCH 1/4] Fix endianity in A100U2W SCSI driver
  2008-07-15 17:23 ` [PATCH 1/4] Fix endianity in " Linus Torvalds
@ 2008-07-15 21:15   ` Mikulas Patocka
  0 siblings, 0 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 21:15 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-scsi, linux-kernel

On Tue, 15 Jul 2008, Linus Torvalds wrote:

> On Tue, 15 Jul 2008, Mikulas Patocka wrote:
> > 
> > Support big endian systems.
> 
> Hmm. Your email seems whitespace-corrupted.

Oh, sorry. I disabled "quell flowed text", sent mail to myself and it 
applies. Here I'm sending them again:


Support big endian systems in a100u2w driver.

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

Index: linux-2.6.26-rc8/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-rc8.orig/drivers/scsi/a100u2w.c	2008-06-25 03:58:20.000000000 +0200
+++ linux-2.6.26-rc8/drivers/scsi/a100u2w.c	2008-07-01 18:51:20.000000000 +0200
@@ -389,7 +389,7 @@ static u8 orc_load_firmware(struct orc_h
 
 	outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL);	/* Enable SRAM programming */
 	data32_ptr = (u8 *) & data32;
-	data32 = 0;		/* Initial FW address to 0 */
+	data32 = cpu_to_le32(0);		/* Initial FW address to 0 */
 	outw(0x0010, host->base + ORC_EBIOSADR0);
 	*data32_ptr = inb(host->base + ORC_EBIOSDATA);		/* Read from BIOS */
 	outw(0x0011, host->base + ORC_EBIOSADR0);
@@ -397,18 +397,18 @@ static u8 orc_load_firmware(struct orc_h
 	outw(0x0012, host->base + ORC_EBIOSADR0);
 	*(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
 	outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2);
-	outl(data32, host->base + ORC_FWBASEADR);		/* Write FW address */
+	outl(le32_to_cpu(data32), host->base + ORC_FWBASEADR);		/* Write FW address */
 
 	/* Copy the code from the BIOS to the SRAM */
 
-	bios_addr = (u16) data32;	/* FW code locate at BIOS address + ? */
+	bios_addr = (u16) le32_to_cpu(data32);	/* FW code locate at BIOS address + ? */
 	for (i = 0, data32_ptr = (u8 *) & data32;	/* Download the code    */
 	     i < 0x1000;	/* Firmware code size = 4K      */
 	     i++, bios_addr++) {
 		outw(bios_addr, host->base + ORC_EBIOSADR0);
 		*data32_ptr++ = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
 		if ((i % 4) == 3) {
-			outl(data32, host->base + ORC_RISCRAM);	/* Write every 4 bytes */
+			outl(le32_to_cpu(data32), host->base + ORC_RISCRAM);	/* Write every 4 bytes */
 			data32_ptr = (u8 *) & data32;
 		}
 	}
@@ -423,7 +423,7 @@ static u8 orc_load_firmware(struct orc_h
 		outw(bios_addr, host->base + ORC_EBIOSADR0);
 		*data32_ptr++ = inb(host->base + ORC_EBIOSDATA);	/* Read from BIOS */
 		if ((i % 4) == 3) {
-			if (inl(host->base + ORC_RISCRAM) != data32) {
+			if (inl(host->base + ORC_RISCRAM) != le32_to_cpu(data32)) {
 				outb(PRGMRST, host->base + ORC_RISCCTL);	/* Reset program to 0 */
 				outb(data, host->base + ORC_GCFG);	/*Disable EEPROM programming */
 				return 0;
@@ -459,8 +459,8 @@ static void setup_SCBs(struct orc_host *
 
 	for (i = 0; i < ORC_MAXQUEUE; i++) {
 		escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i));
-		scb->sg_addr = (u32) escb_phys;
-		scb->sense_addr = (u32) escb_phys;
+		scb->sg_addr = cpu_to_le32((u32) escb_phys);
+		scb->sense_addr = cpu_to_le32((u32) escb_phys);
 		scb->escb = escb;
 		scb->scbidx = i;
 		scb++;
@@ -642,8 +642,8 @@ static int orc_device_reset(struct orc_h
 	scb->link = 0xFF;
 	scb->reserved0 = 0;
 	scb->reserved1 = 0;
-	scb->xferlen = 0;
-	scb->sg_len = 0;
+	scb->xferlen = cpu_to_le32(0);
+	scb->sg_len = cpu_to_le32(0);
 
 	escb->srb = NULL;
 	escb->srb = cmd;
@@ -858,9 +858,9 @@ static void inia100_build_scb(struct orc
 	scb->lun = cmd->device->lun;
 	scb->reserved0 = 0;
 	scb->reserved1 = 0;
-	scb->sg_len = 0;
+	scb->sg_len = cpu_to_le32(0);
 
-	scb->xferlen = (u32) scsi_bufflen(cmd);
+	scb->xferlen = cpu_to_le32((u32) scsi_bufflen(cmd));
 	sgent = (struct orc_sgent *) & escb->sglist[0];
 
 	count_sg = scsi_dma_map(cmd);
@@ -868,18 +868,18 @@ static void inia100_build_scb(struct orc
 
 	/* Build the scatter gather lists */
 	if (count_sg) {
-		scb->sg_len = (u32) (count_sg * 8);
+		scb->sg_len = cpu_to_le32((u32) (count_sg * 8));
 		scsi_for_each_sg(cmd, sg, count_sg, i) {
-			sgent->base = (u32) sg_dma_address(sg);
-			sgent->length = (u32) sg_dma_len(sg);
+			sgent->base = cpu_to_le32((u32) sg_dma_address(sg));
+			sgent->length = cpu_to_le32((u32) sg_dma_len(sg));
 			sgent++;
 		}
 	} else {
-		scb->sg_len = 0;
-		sgent->base = 0;
-		sgent->length = 0;
+		scb->sg_len = cpu_to_le32(0);
+		sgent->base = cpu_to_le32(0);
+		sgent->length = cpu_to_le32(0);
 	}
-	scb->sg_addr = (u32) scb->sense_addr;
+	scb->sg_addr = (u32) scb->sense_addr;	/* sense_addr is already little endian */
 	scb->hastat = 0;
 	scb->tastat = 0;
 	scb->link = 0xFF;

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

* [PATCH 2/4] Add udelay to A100U2W SCSI driver
  2008-07-15 14:12 ` [PATCH 2/4] Add udelay to " Mikulas Patocka
  2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
@ 2008-07-15 21:16   ` Mikulas Patocka
  1 sibling, 0 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 21:16 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

udelay is required on Sun Ultra 5.
I don't know any reason or explanation for this, it was found purely
experimentally.

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

Index: linux-2.6.26-rc8/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-rc8.orig/drivers/scsi/a100u2w.c	2008-07-01 18:48:09.000000000 +0200
+++ linux-2.6.26-rc8/drivers/scsi/a100u2w.c	2008-07-01 18:48:11.000000000 +0200
@@ -401,6 +401,7 @@ static u8 orc_load_firmware(struct orc_h
 
 	/* Copy the code from the BIOS to the SRAM */
 
+	udelay(500);	/* Required on Sun Ultra 5 ... 350 -> failures */
 	bios_addr = (u16) le32_to_cpu(data32);	/* FW code locate at BIOS address + ? */
 	for (i = 0, data32_ptr = (u8 *) & data32;	/* Download the code    */
 	     i < 0x1000;	/* Firmware code size = 4K      */

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

* [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver
  2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
  2008-07-15 14:15     ` [PATCH 4/4] Don't crash on IOMMU overflow in " Mikulas Patocka
  2008-07-15 15:17     ` [PATCH 3/4] BUG_ON on kernel misbehavior on " James Bottomley
@ 2008-07-15 21:18     ` Mikulas Patocka
  2 siblings, 0 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 21:18 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

With broken Sparc64 IOMMU accounting, the kernel submits larger requests then
allowed. Better to crash on BUG than corrupt memory.

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

Index: linux-2.6.26-devel/drivers/scsi/a100u2w.c
===================================================================
--- linux-2.6.26-devel.orig/drivers/scsi/a100u2w.c	2008-07-14 20:03:43.000000000 +0200
+++ linux-2.6.26-devel/drivers/scsi/a100u2w.c	2008-07-15 00:46:02.000000000 +0200
@@ -866,6 +866,7 @@ static void inia100_build_scb(struct orc
 
 	count_sg = scsi_dma_map(cmd);
 	BUG_ON(count_sg < 0);
+	BUG_ON(count_sg > TOTAL_SG_ENTRY);
 
 	/* Build the scatter gather lists */
 	if (count_sg) {

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

* [PATCH 4/4] Don't crash on IOMMU overflow in A100U2W driver
  2008-07-15 14:15     ` [PATCH 4/4] Don't crash on IOMMU overflow in " Mikulas Patocka
@ 2008-07-15 21:19       ` Mikulas Patocka
  0 siblings, 0 replies; 10+ messages in thread
From: Mikulas Patocka @ 2008-07-15 21:19 UTC (permalink / raw)
  To: torvalds; +Cc: linux-scsi, linux-kernel

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;
 }

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

end of thread, other threads:[~2008-07-15 21:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-15 14:11 [PATCH 1/4] Fix endianity in A100U2W SCSI driver Mikulas Patocka
2008-07-15 14:12 ` [PATCH 2/4] Add udelay to " Mikulas Patocka
2008-07-15 14:14   ` [PATCH 3/4] BUG_ON on kernel misbehavior on A100U2W driver Mikulas Patocka
2008-07-15 14:15     ` [PATCH 4/4] Don't crash on IOMMU overflow in " Mikulas Patocka
2008-07-15 21:19       ` Mikulas Patocka
2008-07-15 15:17     ` [PATCH 3/4] BUG_ON on kernel misbehavior on " James Bottomley
2008-07-15 21:18     ` Mikulas Patocka
2008-07-15 21:16   ` [PATCH 2/4] Add udelay to A100U2W SCSI driver Mikulas Patocka
2008-07-15 17:23 ` [PATCH 1/4] Fix endianity in " Linus Torvalds
2008-07-15 21:15   ` Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox