[parisc-linux] ZONE_DMA

Matthew Wilcox matthew@wil.cx
Mon, 1 Jan 2001 19:18:48 +0000


On Mon, Jan 01, 2001 at 07:01:19PM +0000, Alan Cox wrote:
> > But if we have none, then all GFP_DMA allocations will fail.  Which
> > includes the scsi midlayers.  Ooh, I just noticed that scsi_scan.c
> > is broken...  expect a patch RSN.
> 
> SCSI may need fixing, but do you want to do it right 8)

I don't think I have time to do that :-)

Here's a patch which makes it slightly better.  Justifications:
 * changed GFP_DMA to GFP_KERNEL | GFP_DMA since GFP_DMA alone is nonsense.
 * got rid of the ?: since it's pure obfuscation in this case.
 * changed &scsi_result0[0] to scsi_result0.  again, sheer obfuscation.

just peering at this little bit makes me realise how large the scsi
problems must be :-)

It compiles.  I promise no more.

Index: drivers/scsi/scsi_scan.c
===================================================================
RCS file: /var/cvs/linux/drivers/scsi/scsi_scan.c,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 scsi_scan.c
--- drivers/scsi/scsi_scan.c	2000/09/19 15:01:34	1.1.1.1
+++ drivers/scsi/scsi_scan.c	2001/01/01 19:09:43
@@ -288,8 +288,11 @@ void scan_scsis(struct Scsi_Host *shpnt,
 		scsi_initialize_queue(SDpnt, shpnt);
 		SDpnt->request_queue.queuedata = (void *) SDpnt;
 		/* Make sure we have something that is valid for DMA purposes */
-		scsi_result = ((!shpnt->unchecked_isa_dma)
-			       ? &scsi_result0[0] : kmalloc(512, GFP_DMA));
+		if (shpnt->unchecked_isa_dma) {
+			scsi_result = kmalloc(512, GFP_KERNEL | GFP_DMA);
+		} else {
+			scsi_result = scsi_result0;
+		}
 	}
 
 	if (scsi_result == NULL) {
@@ -411,7 +414,7 @@ void scan_scsis(struct Scsi_Host *shpnt,
 		}		/* for channel ends */
 	}			/* if/else hardcoded */
 
-      leave:
+ leave:
 
 	{			/* Unchain SRpnt from host_queue */
 		Scsi_Device *prev, *next;
@@ -438,7 +441,7 @@ void scan_scsis(struct Scsi_Host *shpnt,
 	}
 
 	/* If we allocated a buffer so we could do DMA, free it now */
-	if (scsi_result != &scsi_result0[0] && scsi_result != NULL) {
+	if (scsi_result != scsi_result0 && scsi_result != NULL) {
 		kfree(scsi_result);
 	} {
 		Scsi_Device *sdev;

-- 
Revolutions do not require corporate support.