Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 May 2009 22:55:50 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192003 - head/sys/dev/xen/console
Message-ID:  <200905112255.n4BMtorH004362@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Mon May 11 22:55:49 2009
New Revision: 192003
URL: http://svn.freebsd.org/changeset/base/192003

Log:
  xen console lock needs to be a spin lock in case it is acquired from an interrupt context

Modified:
  head/sys/dev/xen/console/console.c
  head/sys/dev/xen/console/xencons_ring.c
  head/sys/dev/xen/console/xencons_ring.h

Modified: head/sys/dev/xen/console/console.c
==============================================================================
--- head/sys/dev/xen/console/console.c	Mon May 11 21:13:00 2009	(r192002)
+++ head/sys/dev/xen/console/console.c	Mon May 11 22:55:49 2009	(r192003)
@@ -76,17 +76,17 @@ static unsigned int wc, wp; /* write_con
 #define	XCUNIT(x)	(dev2unit(x))
 #define ISTTYOPEN(tp)	((tp) && ((tp)->t_state & TS_ISOPEN))
 #define CN_LOCK_INIT(x, _name) \
-        mtx_init(&x, _name, NULL, MTX_DEF|MTX_RECURSE)
+        mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE)
 
 #define CN_LOCK(l)        								\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_lock(&(l));			\
+                        mtx_lock_spin(&(l));			\
 		} while (0)
 #define CN_UNLOCK(l)        							\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_unlock(&(l));			\
+                        mtx_unlock_spin(&(l));			\
 		} while (0)
 #define CN_LOCK_ASSERT(x)    mtx_assert(&x, MA_OWNED)
 #define CN_LOCK_DESTROY(x)   mtx_destroy(&x)

Modified: head/sys/dev/xen/console/xencons_ring.c
==============================================================================
--- head/sys/dev/xen/console/xencons_ring.c	Mon May 11 21:13:00 2009	(r192002)
+++ head/sys/dev/xen/console/xencons_ring.c	Mon May 11 22:55:49 2009	(r192003)
@@ -89,7 +89,7 @@ xencons_handle_input(void *unused)
 	struct xencons_interface *intf;
 	XENCONS_RING_IDX cons, prod;
 
-	mtx_lock(&cn_mtx);
+	CN_LOCK(cn_mtx);
 	intf = xencons_interface();
 
 	cons = intf->in_cons;
@@ -107,7 +107,7 @@ xencons_handle_input(void *unused)
 	notify_remote_via_evtchn(xen_start_info->console_evtchn);
 
 	xencons_tx();
-	mtx_unlock(&cn_mtx);
+	CN_UNLOCK(cn_mtx);
 }
 
 void 

Modified: head/sys/dev/xen/console/xencons_ring.h
==============================================================================
--- head/sys/dev/xen/console/xencons_ring.h	Mon May 11 21:13:00 2009	(r192002)
+++ head/sys/dev/xen/console/xencons_ring.h	Mon May 11 22:55:49 2009	(r192003)
@@ -5,6 +5,17 @@
 #ifndef _XENCONS_RING_H
 #define _XENCONS_RING_H
 
+#define CN_LOCK(l)        								\
+		do {											\
+				if (panicstr == NULL)					\
+                        mtx_lock_spin(&(l));			\
+		} while (0)
+#define CN_UNLOCK(l)        							\
+		do {											\
+				if (panicstr == NULL)					\
+                        mtx_unlock_spin(&(l));			\
+		} while (0)
+
 int xencons_ring_init(void);
 int xencons_ring_send(const char *data, unsigned len);
 void xencons_rx(char *buf, unsigned len);



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