X-Authentication-Warning: ulab-17.ms.mff.cuni.cz: prak3264 owned process doing -bs
Date: Wed, 19 Nov 1997 15:20:34 +0100 (MET)
From: Patrik Rak <prak3264@ss1000.ms.mff.cuni.cz>
X-Sender: prak3264@ulab-17.ms.mff.cuni.cz
To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Fastlane & ESP patches.
Sender: owner-linux-m68k@phil.uni-sb.de

Hi!

I have found misplaced ifdef in drivers/scsi/esp.c, which was responsible
for causing havoc under certain situations (reset completed while there
was deselected command).

Below are two patches fixing this, one for 2.0.31-pre3 and second one for
2.1.64.

Also, the 2.1.64 patch contains the "forgotten enable_irq() in
esp_abort()" patch I already sent here relative to 2.1.61.

I also fixed some interrupt handling the fastlane(_eps).c to really do
what esp.c expects it should do... The patches below contain these fixes
as well.

I have tested the 2.0.31-pre3 patch. The 6.1.64 one was not tested yet
(the kernel will build tonight:), but I have tested the same patch on
2.1.61 and it worked fine (well, it at least did not broke anything :).

Note that I am not sure (yet) if this patches cure the annoying
fastlane-lockup bug...

Patrik

--- linux-2.1.64/drivers/scsi/esp.c	1997/11/19 13:56:35	1.1
+++ linux-2.1.64/drivers/scsi/esp.c	1997/11/19 14:06:26
@@ -44,20 +44,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-/* This is really ugly (Jesper?) -Patrik */
-
-#ifndef DMA_IRQ_P
-#define DMA_IRQ_P(regs)		(esp->dma_irq_p(esp))
-#endif /* DMA_IRQ_P */
-
-#ifndef DMA_INTSON
-#define DMA_INTSON(regs)	(esp->dma_ints_on(esp))
-#endif /* DMA_INTSON */
-
-#ifndef DMA_INTSOFF
-#define DMA_INTSOFF(regs)	(esp->dma_ints_off(esp))
-#endif /* DMA_INTSOFF */
-
 /* Command phase enumeration. */
 enum {
 	not_issued    = 0x00,  /* Still in the issue_SC queue.          */
@@ -1422,6 +1408,9 @@
 		}
 	}
 
+	if(don)
+		esp->dma_ints_on(esp);
+
 	/* Yuck, the command to abort is disconnected, it is not
 	 * worth trying to abort it now if something else is live
 	 * on the bus at this time.  So, we let the SCSI code wait
@@ -3597,8 +3586,8 @@
 		if(esp->disconnected_SC) {
 			Scsi_Cmnd *SCptr;
 			while((SCptr = remove_first_SC(&esp->disconnected_SC))) {
-				if(!SCptr->use_sg)
 #ifdef CONFIG_SCSI_SUNESP
+				if(!SCptr->use_sg)
 					mmu_release_scsi_one(SCptr->SCp.have_data_in,
 							     SCptr->request_bufflen,
 							     ((struct linux_sbus_device *) (esp->edev))->my_bus);
@@ -3654,6 +3643,12 @@
 repeat:
 	again = 0;
 	for_each_esp(esp) {
+	
+#ifndef INO_TO_PIL
+#warn defining missing INO_TO_IPL macro as no-op...
+#define INO_TO_PIL(x) (x)
+#endif
+
 		if(INO_TO_PIL(esp) == irq) {
 			if(esp->dma_irq_p(esp)) {
 				again = 1;
--- linux-2.1.64/drivers/scsi/fastlane.c	1997/11/19 13:56:35	1.1
+++ linux-2.1.64/drivers/scsi/fastlane.c	1997/11/19 14:16:16
@@ -5,8 +5,8 @@
  * This driver is based on the CyberStorm driver, hence the occasional
  * reference to CyberStorm.
  *
- * Betatesting & crucial adjustments by Patrik Rak 
- * (prak3264@ss1000.ms.mff.cuni.cz)
+ * Betatesting & crucial adjustments by
+ *        Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz)
  *
  */
 
@@ -43,8 +43,11 @@
 
 #include <asm/pgtable.h>
 
+/* Such day has just come... */
+#if 0
 /* Let this defined unless you really need to enable DMA IRQ one day */
 #define NODMAIRQ
+#endif
 
 static int  dma_bytes_sent(struct NCR_ESP *esp, int fifo_count);
 static int  dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd *sp);
@@ -55,6 +58,7 @@
 static void dma_ints_off(struct NCR_ESP *esp);
 static void dma_ints_on(struct NCR_ESP *esp);
 static int  dma_irq_p(struct NCR_ESP *esp);
+static void dma_irq_exit(struct NCR_ESP *esp);
 static void dma_led_off(struct NCR_ESP *esp);
 static void dma_led_on(struct NCR_ESP *esp);
 static int  dma_ports_p(struct NCR_ESP *esp);
@@ -113,7 +117,7 @@
 		esp->dma_drain = 0;
 		esp->dma_invalidate = 0;
 		esp->dma_irq_entry = 0;
-		esp->dma_irq_exit = 0;
+		esp->dma_irq_exit = &dma_irq_exit;
 		esp->dma_led_on = &dma_led_on;
 		esp->dma_led_off = &dma_led_off;
 		esp->dma_poll = 0;
@@ -279,39 +283,34 @@
 	enable_irq(esp->irq);
 }
 
+static void dma_irq_exit(struct NCR_ESP *esp)
+{
+	struct fastlane_dma_registers *dregs = 
+		(struct fastlane_dma_registers *) (esp->dregs);
+
+	dregs->ctrl_reg = ctrl_data & ~(FASTLANE_DMA_EDI|FASTLANE_DMA_ESI);
+	nop();
+	dregs->ctrl_reg = ctrl_data;
+}
+
 static int dma_irq_p(struct NCR_ESP *esp)
 {
 	struct fastlane_dma_registers *dregs = 
 		(struct fastlane_dma_registers *) (esp->dregs);
-#if 0
 	unsigned char dma_status;
-	int r = 0;
 
 	dma_status = dregs->cond_reg;
 
 	if(dma_status & FASTLANE_DMA_IACT)
 		return 0;	/* not our IRQ */
 
-	/* Return 1 if ESP requested IRQ */
-	if(
+	/* Return non-zero if ESP requested IRQ */
+	return (
 #ifndef NODMAIRQ
 	   (dma_status & FASTLANE_DMA_CREQ) &&
 #endif
 	   (!(dma_status & FASTLANE_DMA_MINT)) &&
-	   ((((struct ESP_regs *) (esp->eregs))->esp_status) & ESP_STAT_INTR))
-		r = 1;
-
-	dregs->ctrl_reg = (ctrl_data & ~(FASTLANE_DMA_EDI|FASTLANE_DMA_ESI) );
-	dregs->ctrl_reg = ctrl_data;
-
-	return r;
-#else
-	int r;
-	r = (((struct ESP_regs *) (esp->eregs))->esp_status) & ESP_STAT_INTR;
-	dregs->ctrl_reg = ctrl_data & ~(FASTLANE_DMA_EDI|FASTLANE_DMA_ESI);
-	dregs->ctrl_reg = ctrl_data;
-	return r;
-#endif
+	   ((((struct ESP_regs *) (esp->eregs))->esp_status) & ESP_STAT_INTR));
 }
 
 static void dma_led_off(struct NCR_ESP *esp)


