[ydl-gen] endian problems in A100U2W

Stephen Harker s.harker at adfa.edu.au
Sat Aug 9 22:24:32 MDT 2008


This may be of interest to some others on the list.

A month or so ago I sent a bug report to the linux kernel mailing list
on a failure installing the a100u2w module on my 7600/200 (actually
with a G4 @450MHz).  This machine, though OldWorld is actually running
YDL5 (as well as OS9 and OSX).  The Apple systems work well on my
Initio Miles2 card, but I had never been able to get any success at
all on Linux.  With kernel 2.6.25.4 I got some useful error messages
which I sent in.

The following is the response which seems to fix a fair number of
endian bugs in the driver source.  At the moment I am away from home
and not in a position to try the patch, but it may be worth mentioning
here.  If the following email does not work due to lines being too
long try the url:

       http://marc.info/?l=linux-scsi&m=121613124207253&w=2


List:       linux-scsi
Subject:    [PATCH 1/4] Fix endianity in A100U2W SCSI driver
From:       Mikulas Patocka <mpatocka () redhat ! com>
Date:       2008-07-15 21:15:41
Message-ID: Pine.LNX.4.64.0807151710400.4356 () devserv ! devel ! redhat ! com
[Download message RAW]

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

-- 
Stephen Harker                           s.harker at adfa.edu.au
PEMS
UNSW at ADFA


More information about the yellowdog-general mailing list