Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2010 05:11:48 +0000 (UTC)
From:      Randall Stewart <rrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r203009 - head/sys/mips/rmi
Message-ID:  <201001260511.o0Q5BmpV086970@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rrs
Date: Tue Jan 26 05:11:48 2010
New Revision: 203009
URL: http://svn.freebsd.org/changeset/base/203009

Log:
  To prevent a LOR we need to pass in
  a lock flag in the pic routines. In
  some places we hold the pic lock, others
  we do not.

Modified:
  head/sys/mips/rmi/intr_machdep.c
  head/sys/mips/rmi/pic.h

Modified: head/sys/mips/rmi/intr_machdep.c
==============================================================================
--- head/sys/mips/rmi/intr_machdep.c	Tue Jan 26 05:10:10 2010	(r203008)
+++ head/sys/mips/rmi/intr_machdep.c	Tue Jan 26 05:11:48 2010	(r203009)
@@ -147,17 +147,17 @@ cpu_intr(struct trapframe *tf)
 		if ((i == IPI_AST) || (i == IPI_RENDEZVOUS) || (i == IPI_STOP)
 		    || (i == IPI_SMP_CALL_FUNCTION)) {
 			write_c0_eirr64(1ULL << i);
-			pic_ack(i);
+			pic_ack(i,0);
 			smp_handle_ipi(tf, i);
-			pic_delayed_ack(i);
+			pic_delayed_ack(i,0);
 			continue;
 		}
 #ifdef XLR_PERFMON
 		if (i == IPI_PERFMON) {
 			write_c0_eirr64(1ULL << i);
-			pic_ack(i);
+			pic_ack(i,0);
 			xlr_perfmon_sampler(NULL);
-			pic_delayed_ack(i);
+			pic_delayed_ack(i,0);
 			continue;
 		}
 #endif
@@ -167,7 +167,7 @@ cpu_intr(struct trapframe *tf)
 		ie = mih->mih_event;
 
 		write_c0_eirr64(1ULL << i);
-		pic_ack(i);
+		pic_ack(i, 0);
 		if (!ie || TAILQ_EMPTY(&ie->ie_handlers)) {
 			printf("stray interrupt %d\n", i);
 			continue;
@@ -175,7 +175,7 @@ cpu_intr(struct trapframe *tf)
 		if (intr_event_handle(ie, tf) != 0) {
 			printf("stray interrupt %d\n", i);
 		}
-		pic_delayed_ack(i);
+		pic_delayed_ack(i, 0);
 	}
 	critical_exit();
 }

Modified: head/sys/mips/rmi/pic.h
==============================================================================
--- head/sys/mips/rmi/pic.h	Tue Jan 26 05:10:10 2010	(r203008)
+++ head/sys/mips/rmi/pic.h	Tue Jan 26 05:11:48 2010	(r203009)
@@ -29,6 +29,8 @@
  * RMI_BSD */
 #ifndef _RMI_PIC_H_
 #define _RMI_PIC_H_
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 extern int rmi_spin_mutex_safe;
 
@@ -202,44 +204,44 @@ extern struct mtx xlr_pic_lock;
 
 
 static __inline__ __uint32_t 
-pic_read_control(void)
+pic_read_control(int haslock)
 {
 	xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET);
 	__uint32_t reg;
 
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_lock_spin(&xlr_pic_lock);
 	xlr_read_reg(mmio, PIC_CTRL);
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_unlock_spin(&xlr_pic_lock);
 	return reg;
 }
 
 static __inline__ void 
-pic_write_control(__uint32_t control)
+pic_write_control(__uint32_t control, int haslock)
 {
 	xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET);
 
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_lock_spin(&xlr_pic_lock);
 	xlr_write_reg(mmio, PIC_CTRL, control);
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_unlock_spin(&xlr_pic_lock);
 }
 static __inline__ void 
-pic_update_control(__uint32_t control)
+pic_update_control(__uint32_t control, int haslock)
 {
 	xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET);
 
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_lock_spin(&xlr_pic_lock);
 	xlr_write_reg(mmio, PIC_CTRL, (control | xlr_read_reg(mmio, PIC_CTRL)));
-	if (rmi_spin_mutex_safe)
+	if ((rmi_spin_mutex_safe) && (haslock == 0))
 	  mtx_unlock_spin(&xlr_pic_lock);
 }
 
 static __inline__ void 
-pic_ack(int irq)
+pic_ack(int irq, int haslock)
 {
 	xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET);
 
@@ -248,10 +250,10 @@ pic_ack(int irq)
 		return;
 
 	if (PIC_IRQ_IS_EDGE_TRIGGERED(irq)) {
-	  if (rmi_spin_mutex_safe)
+	  if ((rmi_spin_mutex_safe) && (haslock == 0))
 		mtx_lock_spin(&xlr_pic_lock);
 	  xlr_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE)));
-	  if (rmi_spin_mutex_safe)
+	  if ((rmi_spin_mutex_safe) && (haslock == 0))
 		mtx_unlock_spin(&xlr_pic_lock);
 		return;
 	}
@@ -259,7 +261,7 @@ pic_ack(int irq)
 }
 
 static inline void 
-pic_delayed_ack(int irq)
+pic_delayed_ack(int irq, int haslock)
 {
 	xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET);
 
@@ -267,10 +269,10 @@ pic_delayed_ack(int irq)
 		return;
 
 	if (!PIC_IRQ_IS_EDGE_TRIGGERED(irq)) {
-	    if (rmi_spin_mutex_safe)
+		if ((rmi_spin_mutex_safe)&& (haslock == 0))
 		  mtx_lock_spin(&xlr_pic_lock);
 		xlr_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE)));
-		if (rmi_spin_mutex_safe)
+		if ((rmi_spin_mutex_safe) && (haslock == 0))
 		  mtx_unlock_spin(&xlr_pic_lock);
 		return;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001260511.o0Q5BmpV086970>