Date: Mon, 9 Jun 1997 23:45:22 +0200 (MET DST)
From: Guenther Kelleter <guenther@Pool.Informatik.RWTH-Aachen.de>
X-Sender: guenther@pc7390
To: linux-m68k@phil.uni-sb.de
Subject: Re: L68K: fs affair (was: Quantum Fireball problems.)
In-Reply-To: <9706062317.AA13442@faui21.informatik.uni-erlangen.de>
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

On Sat, 7 Jun 1997, Roman Hodek wrote:

> What's so bad about the Falcon is that it can't do scatter-gather. Let
> me explain: The Linux buffer cache breaks all disk requests down into
> 1k chunks (usually), the size of a buffer. These buffers are usually
> discontiguous in memory. Scatter-gather is now the method to merge
> requests for buffers that don't follow one another in memory into one
> command for the disk. This saves a lot of time (overhead of command,
> message, status, bus free phases, ...) On a TT, this works rather
> fine. But the Falcon SCSI design is broken, because the DMA can't
> interrupt itself if it's finished. Due to that, we can't reprogram the
> DMA for a different destination address during a command. There are
> two solutions for this: Either make that sh*t DMA interrupt, or put
> all buffer one after another in memory. Something like the latter is
> done under TOS...


Hey!

I think it's time for a little patch to improve SCSI performance on
Falcons slightly, which I'm using since more than half a year now without
any problems.

This one adds one more parameter to the kernel option `atascsi'. If set to
> 0 then clustering of continuous blocks in memory is enabled, but only if
there's no memory outside the DMA-able area (i.e. >= 16MB on Falcon),
since this would require a larger bounce buffer than the currently
available 4K sized buffer. 

I use it with a `Magnum FAST RAM Card'.



--- Documentation/m68k/kernel-options.txt.~1~	Sat May 17 15:37:05 1997
+++ Documentation/m68k/kernel-options.txt	Mon Jun  9 23:23:50 1997
@@ -575,7 +575,8 @@
 4.4) atascsi=
 -------------
 
-Syntax: atascsi=<can_queue>[,<cmd_per_lun>[,<scat-gat>[,<host-id>[,<tagged>]]]]
+Syntax: atascsi=<can_queue>[,<cmd_per_lun>[,<scat-gat>[,<host-id>[,<tagged>[,
+		<clustering>]]]]]
 
   This option sets some parameters for the Atari native SCSI driver.
 Generally, any number of arguments can be omitted from the end. And
@@ -636,6 +637,20 @@
     one LUN, and the SCSI device itself orders the requests so they
     can be performed in optimal order. Not all SCSI devices support
     tagged queuing (:-().
+
+  <clustering>:
+    Normally SCSI DMA transfers on the Atari Falcon are only done in
+    1K chunks even if blocks are contiguous in memory, due to the broken
+    DMA design which is not capable of scatter-gather. If you have a Falcon
+    without `FAST-RAM' above 16MB (e.g. Magnum RAM Card), you can turn on
+    clustering of contiguous blocks > 1K, so that they are transferred
+    with only one SCSI command and one setup of the DMA.
+    Clustering improves SCSI performance on machines which don't support
+    scatter-gather.
+
+    0 turns off clustering, all other values > 0 turn on clustering if
+    there is no memory block present outside the DMA-able memory area.
+    Default is `off'.
 
 
 
--- drivers/scsi/atari_scsi.c.~1~	Thu May 22 23:37:11 1997
+++ drivers/scsi/atari_scsi.c	Mon Jun  9 23:01:02 1997
@@ -252,6 +252,8 @@
 #endif
 static int setup_hostid = -1;
 MODULE_PARM(setup_hostid, "i");
+static int setup_use_clustering = -1;
+MODULE_PARM(setup_use_clustering, "i");
 
 
 #if defined(REAL_DMA)
@@ -610,7 +612,7 @@
 	} while(0)
     
 				   
-int atari_scsi_detect (Scsi_Host_Template *host)
+__initfunc(int atari_scsi_detect (Scsi_Host_Template *host))
 {
 	static int called = 0;
 	struct Scsi_Host *instance;
@@ -680,16 +682,7 @@
 		atari_dma_orig_addr = 0;
 	}
 #endif
-	instance = scsi_register (host, sizeof (struct NCR5380_hostdata));
-	atari_scsi_host = instance;
-       /* Set irq to 0, to avoid that the mid-level code disables our interrupt
-        * during queue_command calls. This is completely unnecessary, and even
-        * worse causes bad problems on the Falcon, where the int is shared with
-        * IDE and floppy! */
-       instance->irq = 0;
-
 	atari_scsi_reset_boot();
-	NCR5380_init (instance, 0);
 
 	if (IS_A_TT()) {
 
@@ -734,20 +727,48 @@
 		atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
 					: 0xff000000);
 #endif
+		/* Since Falcon cannot scatter-gather: Use clustering for
+		 * contiguous requests, this is safe only if all RAM is DMA-able
+		 * (s[drt].c is broken w.r.t. bounce buffers on m68k,
+		 * see the usage of ISA_DMA_THRESHOLD).
+		 */
+		if (setup_use_clustering == 1) {
+			int i;
+			host->use_clustering = ENABLE_CLUSTERING;
+#ifdef REAL_DMA
+			for (i=0; i<m68k_num_memory; i++)
+				if (((m68k_memory[i].addr + m68k_memory[i].size - 1)
+				    & atari_dma_stram_mask) != 0) {
+					host->use_clustering = DISABLE_CLUSTERING;
+					break;
+				}
+#endif
+		}
 	}
 
-	printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d "
+	instance = scsi_register(host, sizeof (struct NCR5380_hostdata));
+	atari_scsi_host = instance;
+	/* Set irq to 0, to avoid that the mid-level code disables our interrupt
+	 * during queue_command calls. This is completely unnecessary, and even
+	 * worse causes bad problems on the Falcon, where the int is shared with
+	 * IDE and floppy! */
+	instance->irq = 0;
+	NCR5380_init(instance, 0);
+
+	printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d"
 #ifdef SUPPORT_TAGS
-			"TAGGED-QUEUING=%s "
+	       " TAGGED-QUEUING=%s"
 #endif
-			"HOSTID=%d",
-			instance->host_no, instance->hostt->can_queue,
-			instance->hostt->cmd_per_lun,
-			instance->hostt->sg_tablesize,
+	       " CLUSTERING=%s"
+	       " HOSTID=%d"
+	       "\n" KERN_INFO "      ",
+	       instance->host_no, instance->can_queue,
+	       instance->cmd_per_lun, instance->sg_tablesize,
 #ifdef SUPPORT_TAGS
-			setup_use_tagged_queuing ? "yes" : "no",
+	       setup_use_tagged_queuing ? "yes" : "no",
 #endif
-			instance->hostt->this_id );
+	       instance->use_clustering == ENABLE_CLUSTERING ? "yes" : "no",
+	       instance->this_id);
 	NCR5380_print_options (instance);
 	printk ("\n");
 
@@ -769,7 +790,8 @@
 __initfunc(void atari_scsi_setup( char *str, int *ints ))
 {
 	/* Format of atascsi parameter is:
-	 *   atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
+	 *   atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,
+	 *           <use_tags>,<use_clustering>
 	 * Defaults depend on TT or Falcon, hostid determined at run time.
 	 * Negative values mean don't change.
 	 */
@@ -826,6 +848,10 @@
 			setup_use_tagged_queuing = !!ints[5];
 	}
 #endif
+	if (ints[0] >= 6) {
+		if (ints[6] >= 0)
+			setup_use_clustering = !!ints[6];
+	}
 }
 
 int atari_scsi_reset( Scsi_Cmnd *cmd, unsigned int reset_flags)
---------------------



Guenther
----
<guenther@pool.informatik.rwth-aachen.de>

