patch-2.1.126 linux/drivers/char/tpqic02.c

Next file: linux/drivers/char/tty_io.c
Previous file: linux/drivers/char/sysrq.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.125/linux/drivers/char/tpqic02.c linux/drivers/char/tpqic02.c
@@ -1360,6 +1360,7 @@
  */ 
 static inline void dma_transfer(void)
 {
+	unsigned long flags;
 
 	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
@@ -1369,6 +1370,7 @@
 		outb_p(ctlbits, QIC02_CTL_PORT);
 
 
+	flags=claim_dma_lock();
 	clear_dma_ff(QIC02_TAPE_DMA);
 	set_dma_mode(QIC02_TAPE_DMA, dma_mode);
 	set_dma_addr(QIC02_TAPE_DMA, buffaddr+dma_bytes_done);	/* full address */
@@ -1393,6 +1395,9 @@
 
 	/* start computer DMA controller */
 	enable_dma(QIC02_TAPE_DMA);
+
+	release_dma_lock(flags);
+
 	/* block transfer should start now, jumping to the 
 	 * interrupt routine when done or an exception was detected.
 	 */
@@ -1410,6 +1415,7 @@
 /* assume 'bytes_todo'>0 */
 {
 	int stat;
+	unsigned long flags;
 	
 	tpqputs(TPQD_DEBUG, "start_dma() enter");
 	TPQDEB({printk(TPQIC02_NAME ": doing_read==%d, doing_write==%d\n", doing_read, doing_write);})
@@ -1506,9 +1512,10 @@
 
 	/* initiate first data block read from/write to the tape controller */
 
+	save_flags(flags);
 	cli();
 	dma_transfer();
-	sti();
+	restore_flags(flags);
 
 	TPQPUTS("start_dma() end");
 	return TE_OK;
@@ -1524,13 +1531,18 @@
 static void end_dma(unsigned long * bytes_done)
 {
 	int stat = TE_OK;
+	unsigned long flags;
 
 	TIMEROFF;
 
 	TPQPUTS("end_dma() enter");
 
+	flags=claim_dma_lock();
+	
 	disable_dma(QIC02_TAPE_DMA);
 	clear_dma_ff(QIC02_TAPE_DMA);
+	
+	release_dma_lock(flags);
 
 	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
@@ -1633,6 +1645,7 @@
 static void qic02_tape_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int stat, r, i;
+	unsigned long flags;
 
 	TIMEROFF;
 
@@ -1682,10 +1695,14 @@
 				r = 1;
 			}
 
+		flags=claim_dma_lock();
+		
 		if ( (i = get_dma_residue(QIC02_TAPE_DMA)) != 0 ) {
 			printk(TPQIC02_NAME ": dma_residue == %x !!!\n", i);
 			r = 1;	/* big trouble, but can't do much about it... */
 		}
+		
+		release_dma_lock(flags);
 
 		if (r) 
 			return;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov