summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons/syscons.h
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2006-09-13 15:48:15 +0000
committerscottl <scottl@FreeBSD.org>2006-09-13 15:48:15 +0000
commitae1ca6fd73256507ef9094b93fec5b9760349c20 (patch)
tree3f6091ef6a36694ab3df9980406f14ca618e4170 /sys/dev/syscons/syscons.h
parent3927aa447494d5f1b31035c64ecc9b2ae7401a52 (diff)
downloadFreeBSD-src-ae1ca6fd73256507ef9094b93fec5b9760349c20.zip
FreeBSD-src-ae1ca6fd73256507ef9094b93fec5b9760349c20.tar.gz
Introduce a spinlock for synchronizing access to the video output hardware
in syscons. This replaces a simple access semaphore that was assumed to be protected by Giant but often was not. If two threads that were otherwise SMP-safe called printf at the same time, there was a high likelyhood that the semaphore would get corrupted and result in a permanently frozen video console. This is similar to what is already done in the serial console drivers.
Diffstat (limited to 'sys/dev/syscons/syscons.h')
-rw-r--r--sys/dev/syscons/syscons.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 1cd33b2..089adf2 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -34,6 +34,9 @@
#ifndef _DEV_SYSCONS_SYSCONS_H_
#define _DEV_SYSCONS_SYSCONS_H_
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
/* machine-dependent part of the header */
#ifdef PC98
@@ -225,9 +228,9 @@ typedef struct sc_softc {
char font_loading_in_progress;
char switch_in_progress;
- char videoio_in_progress;
char write_in_progress;
char blink_in_progress;
+ struct mtx video_mtx;
long scrn_time_stamp;
@@ -532,6 +535,19 @@ typedef struct {
#define kbd_poll(kbd, on) \
(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
+#define SC_VIDEO_LOCKINIT(sc) \
+ mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,MTX_SPIN);
+#define SC_VIDEO_LOCK(sc) \
+ do { \
+ if (!cold) \
+ mtx_lock_spin(&(sc)->video_mtx); \
+ } while(0)
+#define SC_VIDEO_UNLOCK(sc) \
+ do { \
+ if (!cold) \
+ mtx_unlock_spin(&(sc)->video_mtx); \
+ } while(0)
+
/* syscons.c */
extern int (*sc_user_ioctl)(struct cdev *dev, u_long cmd, caddr_t data,
int flag, struct thread *td);
OpenPOWER on IntegriCloud