blob: 4b9fd93bc2305402a168b9a94566868392e18552 [file] [log] [blame] [raw]
The syscons(4) write should acquire a per-phyical-device lock because some
data that a write operation will manipulating could be shared by many virtual
devices.
Based on revision 330832.
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/dev/syscons/syscons.c freebsd-10.4/sys/dev/syscons/syscons.c
--- /var/archive3/public/freebsd-releng-10.4-src/sys/dev/syscons/syscons.c 2017-09-29 08:19:54.000000000 +0800
+++ freebsd-10.4/sys/dev/syscons/syscons.c 2021-07-19 00:30:56.365556000 +0800
@@ -2689,13 +2689,13 @@
#endif
if (scp->tsw) {
- if (!kdb_active && !mtx_owned(&scp->scr_lock)) {
+ if (!kdb_active && !mtx_owned(&scp->sc->write_mtx)) {
need_unlock = 1;
- mtx_lock_spin(&scp->scr_lock);
+ mtx_lock_spin(&scp->sc->write_mtx);
}
(*scp->tsw->te_puts)(scp, buf, len, kernel);
if (need_unlock)
- mtx_unlock_spin(&scp->scr_lock);
+ mtx_unlock_spin(&scp->sc->write_mtx);
}
if (scp->sc->delayed_next_scr)
@@ -2854,14 +2854,16 @@
sc_get_bios_values(&bios_value);
init_done = WARM;
- /*
- * Allocate resources. Even if we are being called for the second
- * time, we must allocate them again, because they might have
- * disappeared...
- */
- sc = sc_get_softc(unit, flags & SC_KERNEL_CONSOLE);
- if ((sc->flags & SC_INIT_DONE) == 0)
- SC_VIDEO_LOCKINIT(sc);
+ /*
+ * Allocate resources. Even if we are being called for the second
+ * time, we must allocate them again, because they might have
+ * disappeared...
+ */
+ sc = sc_get_softc(unit, flags & SC_KERNEL_CONSOLE);
+ if ((sc->flags & SC_INIT_DONE) == 0) {
+ mtx_init(&sc->write_mtx, "syscons write lock", NULL, MTX_SPIN);
+ SC_VIDEO_LOCKINIT(sc);
+ }
adp = NULL;
if (sc->adapter >= 0) {
@@ -3078,7 +3080,8 @@
(*scp->tsw->te_term)(scp, &scp->ts);
if (scp->ts != NULL)
free(scp->ts, M_DEVBUF);
- mtx_destroy(&scp->scr_lock);
+ mtx_destroy(&sc->video_mtx);
+ mtx_destroy(&sc->write_mtx);
/* clear the structure */
if (!(flags & SC_KERNEL_CONSOLE)) {
@@ -3303,8 +3306,6 @@
scp->history = NULL;
scp->history_pos = 0;
scp->history_size = 0;
-
- mtx_init(&scp->scr_lock, "scrlock", NULL, MTX_SPIN);
}
int
diff -ru --exclude-from freebsd-src-diff-exclude-names --new-file /var/archive3/public/freebsd-releng-10.4-src/sys/dev/syscons/syscons.h freebsd-10.4/sys/dev/syscons/syscons.h
--- /var/archive3/public/freebsd-releng-10.4-src/sys/dev/syscons/syscons.h 2017-09-29 08:19:54.000000000 +0800
+++ freebsd-10.4/sys/dev/syscons/syscons.h 2021-07-19 00:27:15.543547000 +0800
@@ -231,6 +231,7 @@
char write_in_progress;
char blink_in_progress;
struct mtx video_mtx;
+ struct mtx write_mtx; /* mutex for sc_puts() */
long scrn_time_stamp;
@@ -344,7 +345,6 @@
int splash_save_mode; /* saved mode for splash screen */
int splash_save_status; /* saved status for splash screen */
- struct mtx scr_lock; /* mutex for sc_puts() */
#ifdef _SCR_MD_STAT_DECLARED_
scr_md_stat_t md; /* machine dependent vars */
#endif