Subject: [Patch] Interrupt-free IDE driver

From: [email-masked] (Olaf Titz)
Date: 22 Feb 1994 21:00:34 GMT

This patch enables interrupts while reading/writing a disk sector on
IDE disks. There was a two-liner for older Linux kernels that doesn't
work anymore since the affected inline functions have been moved to a
header in 0.99.15, so I took the opportunity of making it a bit
cleaner. You can disable it by #define CONFIG_NO_STI_IO.

The effect is a drastically reduced interrupt latency during disk I/O,
needed mostly for the serial driver.

Rumours are that this doesn't work with some IDE disks that have odd
interrupt timing. Use strictly at your own risk etc.

Olaf

--- drivers/block/hd.c.orig	Fri Jan 21 13:50:11 1994
+++ drivers/block/hd.c	Tue Feb  8 19:41:32 1994
@@ -30,6 +30,7 @@
 #define REALLY_SLOW_IO
 #include <asm/system.h>
 #include <asm/io.h>
+#include <asm/ion.h>
 #include <asm/segment.h>
 
 #define MAJOR_NR HD_MAJOR
@@ -333,7 +334,7 @@
 	do_hd_request();
 	return;
 ok_to_read:
-	insw(HD_DATA,CURRENT->buffer,256);
+	ninsw(HD_DATA,CURRENT->buffer,256);
 	CURRENT->errors = 0;
 	CURRENT->buffer += 512;
 	CURRENT->sector++;
@@ -392,7 +393,7 @@
 		end_request(1);
 	if (i > 0) {
 		SET_INTR(&write_intr);
-		outsw(HD_DATA,CURRENT->buffer,256);
+		noutsw(HD_DATA,CURRENT->buffer,256);
 		sti();
 	} else {
 #if (HD_DELAY > 0)
@@ -502,7 +503,7 @@
 			bad_rw_intr();
 			goto repeat;
 		}
-		outsw(HD_DATA,CURRENT->buffer,256);
+		noutsw(HD_DATA,CURRENT->buffer,256);
 		sti();
 		return;
 	}
--- include/asm/ion.h.orig	Tue Feb  8 19:41:32 1994
+++ include/asm/ion.h	Tue Feb  8 19:41:32 1994
@@ -0,0 +1,40 @@
+#ifndef _ASM_ION_H
+#define _ASM_ION_H
+
+/*
+ * This contains versions of ins/outs with interrups enabled. -ot
+ */
+
+#ifdef CONFIG_NO_STI_IO
+
+#define ninsb insb
+#define ninsw insw
+#define ninsl insl
+
+#define noutsb outsb
+#define noutsw outsw
+#define noutsl outsl
+
+#else
+
+#define __NINS(s) \
+extern inline void nins##s(unsigned short port, void * addr, unsigned long count) \
+{ __asm__ __volatile__ ("pushf ; sti ; cld ; rep ; ins" #s "; popf" \
+: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
+
+#define __NOUTS(s) \
+extern inline void nouts##s(unsigned short port, const void * addr, unsigned long count) \
+{ __asm__ __volatile__ ("pushf; sti ; cld ; rep ; outs" #s "; popf" \
+: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
+
+__NINS(b)
+__NINS(w)
+__NINS(l)
+
+__NOUTS(b)
+__NOUTS(w)
+__NOUTS(l)
+
+#endif
+
+#endif
-- 
        olaf titz     o       [email-masked]          praetorius@irc
  comp.sc.student    _>\ _         [email-masked]      LINUX - the choice
karlsruhe germany   (_)<(_)      [email-masked]     of a GNU generation
what good is a photograph of you? everytime i look at it it makes me feel blue