summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/amd64/mp_machdep.c10
-rw-r--r--sys/dev/cy/cy.c43
-rw-r--r--sys/dev/cy/cy_isa.c43
-rw-r--r--sys/i386/i386/mp_machdep.c10
-rw-r--r--sys/i386/include/smptests.h12
-rw-r--r--sys/i386/isa/cy.c43
-rw-r--r--sys/kern/subr_witness.c3
7 files changed, 62 insertions, 102 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index ff3ee05..f58a94f 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/smp.h>
-#include <machine/smptests.h> /** COUNT_XINVLTLB_HITS, USE_COMLOCK */
+#include <machine/smptests.h> /** COUNT_XINVLTLB_HITS */
#include <machine/specialreg.h>
#include <machine/privatespace.h>
@@ -146,11 +146,6 @@ __FBSDID("$FreeBSD$");
/* lock region used by kernel profiling */
int mcount_lock;
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct mtx com_mtx;
-#endif
-
/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
int current_postcode;
@@ -345,9 +340,6 @@ cpu_mp_start(void)
setidt(IPI_STOP, IDTVEC(cpustop),
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#ifdef USE_COMLOCK
- mtx_init(&com_mtx, "com", NULL, MTX_SPIN);
-#endif
mtx_init(&smp_tlb_mtx, "tlb", NULL, MTX_SPIN);
/* Set boot_cpu_id if needed. */
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 3d3998d..895bd6e 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -91,27 +91,6 @@ __FBSDID("$FreeBSD$");
#error "The cy device requires the old isa compatibility shims"
#endif
-#ifdef SMP
-
-#include <machine/smptests.h> /** xxx_LOCK */
-
-#ifdef USE_COMLOCK
-#define COM_LOCK() mtx_lock_spin(&com_mtx)
-#define COM_UNLOCK() mtx_unlock_spin(&com_mtx)
-#else
-#define COM_LOCK()
-#define COM_UNLOCK()
-#endif /* USE_COMLOCK */
-
-#else /* SMP */
-
-#define COM_LOCK()
-#define COM_UNLOCK()
-
-#endif /* SMP */
-
-extern struct mtx com_mtx;
-
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
* sio.c. There is also lots of ugly formatting and unnecessary ifdefs to
@@ -154,7 +133,9 @@ extern struct mtx com_mtx;
#define comstop cystop
#define siowrite cywrite
#define sio_ih cy_ih
+#define sio_inited cy_inited
#define sio_irec cy_irec
+#define sio_lock cy_lock
#define sio_timeout cy_timeout
#define sio_timeout_handle cy_timeout_handle
#define sio_timeouts_until_log cy_timeouts_until_log
@@ -231,6 +212,14 @@ static char const * const error_desc[] = {
#define CE_NTYPES 3
#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
+#ifdef SMP
+#define COM_LOCK() mtx_lock_spin(&sio_lock)
+#define COM_UNLOCK() mtx_unlock_spin(&sio_lock)
+#else
+#define COM_LOCK()
+#define COM_UNLOCK()
+#endif
+
/* types. XXX - should be elsewhere */
typedef u_char bool_t; /* boolean */
typedef u_char volatile *cy_addr;
@@ -378,6 +367,8 @@ void cystatus(int unit);
#endif
static char driver_name[] = "cy";
+static struct mtx sio_lock;
+static int sio_inited;
/* table and macro for fast conversion from a unit number to its com struct */
static struct com_s *p_com_addr[NSIO];
@@ -442,6 +433,12 @@ sioprobe(dev)
{
cy_addr iobase;
+ while (sio_inited != 2)
+ if (atomic_cmpset_int(&sio_inited, 0, 1)) {
+ mtx_init(&sio_lock, driver_name, NULL, MTX_SPIN);
+ atomic_store_rel_int(&sio_inited, 2);
+ }
+
iobase = (cy_addr)dev->id_maddr;
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
@@ -2854,7 +2851,7 @@ cd_getreg(com, reg)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
@@ -2893,7 +2890,7 @@ cd_setreg(com, reg, val)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 3d3998d..895bd6e 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -91,27 +91,6 @@ __FBSDID("$FreeBSD$");
#error "The cy device requires the old isa compatibility shims"
#endif
-#ifdef SMP
-
-#include <machine/smptests.h> /** xxx_LOCK */
-
-#ifdef USE_COMLOCK
-#define COM_LOCK() mtx_lock_spin(&com_mtx)
-#define COM_UNLOCK() mtx_unlock_spin(&com_mtx)
-#else
-#define COM_LOCK()
-#define COM_UNLOCK()
-#endif /* USE_COMLOCK */
-
-#else /* SMP */
-
-#define COM_LOCK()
-#define COM_UNLOCK()
-
-#endif /* SMP */
-
-extern struct mtx com_mtx;
-
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
* sio.c. There is also lots of ugly formatting and unnecessary ifdefs to
@@ -154,7 +133,9 @@ extern struct mtx com_mtx;
#define comstop cystop
#define siowrite cywrite
#define sio_ih cy_ih
+#define sio_inited cy_inited
#define sio_irec cy_irec
+#define sio_lock cy_lock
#define sio_timeout cy_timeout
#define sio_timeout_handle cy_timeout_handle
#define sio_timeouts_until_log cy_timeouts_until_log
@@ -231,6 +212,14 @@ static char const * const error_desc[] = {
#define CE_NTYPES 3
#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
+#ifdef SMP
+#define COM_LOCK() mtx_lock_spin(&sio_lock)
+#define COM_UNLOCK() mtx_unlock_spin(&sio_lock)
+#else
+#define COM_LOCK()
+#define COM_UNLOCK()
+#endif
+
/* types. XXX - should be elsewhere */
typedef u_char bool_t; /* boolean */
typedef u_char volatile *cy_addr;
@@ -378,6 +367,8 @@ void cystatus(int unit);
#endif
static char driver_name[] = "cy";
+static struct mtx sio_lock;
+static int sio_inited;
/* table and macro for fast conversion from a unit number to its com struct */
static struct com_s *p_com_addr[NSIO];
@@ -442,6 +433,12 @@ sioprobe(dev)
{
cy_addr iobase;
+ while (sio_inited != 2)
+ if (atomic_cmpset_int(&sio_inited, 0, 1)) {
+ mtx_init(&sio_lock, driver_name, NULL, MTX_SPIN);
+ atomic_store_rel_int(&sio_inited, 2);
+ }
+
iobase = (cy_addr)dev->id_maddr;
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
@@ -2854,7 +2851,7 @@ cd_getreg(com, reg)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
@@ -2893,7 +2890,7 @@ cd_setreg(com, reg, val)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index ff3ee05..f58a94f 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/smp.h>
-#include <machine/smptests.h> /** COUNT_XINVLTLB_HITS, USE_COMLOCK */
+#include <machine/smptests.h> /** COUNT_XINVLTLB_HITS */
#include <machine/specialreg.h>
#include <machine/privatespace.h>
@@ -146,11 +146,6 @@ __FBSDID("$FreeBSD$");
/* lock region used by kernel profiling */
int mcount_lock;
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct mtx com_mtx;
-#endif
-
/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
int current_postcode;
@@ -345,9 +340,6 @@ cpu_mp_start(void)
setidt(IPI_STOP, IDTVEC(cpustop),
SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#ifdef USE_COMLOCK
- mtx_init(&com_mtx, "com", NULL, MTX_SPIN);
-#endif
mtx_init(&smp_tlb_mtx, "tlb", NULL, MTX_SPIN);
/* Set boot_cpu_id if needed. */
diff --git a/sys/i386/include/smptests.h b/sys/i386/include/smptests.h
index ca0fc6a..c1ca6ff 100644
--- a/sys/i386/include/smptests.h
+++ b/sys/i386/include/smptests.h
@@ -34,18 +34,6 @@
*/
/*
- * These defines enable critical region locking of areas that were
- * protected via cli/sti in the UP kernel.
- *
- * COMLOCK protects the sio/cy drivers.
- * known to be incomplete:
- * joystick lkm
- * ?
- */
-#define USE_COMLOCK
-
-
-/*
* Send CPUSTOP IPI for stop/restart of other CPUs on DDB break.
#define VERBOSE_CPUSTOP_ON_DDBBREAK
*/
diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c
index 3d3998d..895bd6e 100644
--- a/sys/i386/isa/cy.c
+++ b/sys/i386/isa/cy.c
@@ -91,27 +91,6 @@ __FBSDID("$FreeBSD$");
#error "The cy device requires the old isa compatibility shims"
#endif
-#ifdef SMP
-
-#include <machine/smptests.h> /** xxx_LOCK */
-
-#ifdef USE_COMLOCK
-#define COM_LOCK() mtx_lock_spin(&com_mtx)
-#define COM_UNLOCK() mtx_unlock_spin(&com_mtx)
-#else
-#define COM_LOCK()
-#define COM_UNLOCK()
-#endif /* USE_COMLOCK */
-
-#else /* SMP */
-
-#define COM_LOCK()
-#define COM_UNLOCK()
-
-#endif /* SMP */
-
-extern struct mtx com_mtx;
-
/*
* Dictionary so that I can name everything *sio* or *com* to compare with
* sio.c. There is also lots of ugly formatting and unnecessary ifdefs to
@@ -154,7 +133,9 @@ extern struct mtx com_mtx;
#define comstop cystop
#define siowrite cywrite
#define sio_ih cy_ih
+#define sio_inited cy_inited
#define sio_irec cy_irec
+#define sio_lock cy_lock
#define sio_timeout cy_timeout
#define sio_timeout_handle cy_timeout_handle
#define sio_timeouts_until_log cy_timeouts_until_log
@@ -231,6 +212,14 @@ static char const * const error_desc[] = {
#define CE_NTYPES 3
#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
+#ifdef SMP
+#define COM_LOCK() mtx_lock_spin(&sio_lock)
+#define COM_UNLOCK() mtx_unlock_spin(&sio_lock)
+#else
+#define COM_LOCK()
+#define COM_UNLOCK()
+#endif
+
/* types. XXX - should be elsewhere */
typedef u_char bool_t; /* boolean */
typedef u_char volatile *cy_addr;
@@ -378,6 +367,8 @@ void cystatus(int unit);
#endif
static char driver_name[] = "cy";
+static struct mtx sio_lock;
+static int sio_inited;
/* table and macro for fast conversion from a unit number to its com struct */
static struct com_s *p_com_addr[NSIO];
@@ -442,6 +433,12 @@ sioprobe(dev)
{
cy_addr iobase;
+ while (sio_inited != 2)
+ if (atomic_cmpset_int(&sio_inited, 0, 1)) {
+ mtx_init(&sio_lock, driver_name, NULL, MTX_SPIN);
+ atomic_store_rel_int(&sio_inited, 2);
+ }
+
iobase = (cy_addr)dev->id_maddr;
/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
@@ -2854,7 +2851,7 @@ cd_getreg(com, reg)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
@@ -2893,7 +2890,7 @@ cd_setreg(com, reg, val)
critical_enter();
#ifdef SMP
need_unlock = 0;
- if (!mtx_owned(&com_mtx)) {
+ if (!mtx_owned(&sio_lock)) {
COM_LOCK();
need_unlock = 1;
}
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 1585e00..6cb5dba 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -272,9 +272,6 @@ static struct witness_order_list_entry order_lists[] = {
*/
#ifdef SMP
{ "ap boot", &lock_class_mtx_spin },
-#ifdef __i386__
- { "com", &lock_class_mtx_spin },
-#endif
#endif
{ "sio", &lock_class_mtx_spin },
#ifdef __i386__
OpenPOWER on IntegriCloud