aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2014-11-21 21:14:05 +0000
committerBrooks Davis <brooks@FreeBSD.org>2014-11-21 21:14:05 +0000
commita1f76946d54f50e738a1471dd9db2399463236a0 (patch)
treeaa7a5874e0f978277c705d1684917b462b79ea4e /sys
parent9d88fc7ce33cd4f01211d99dd7305a79ded03384 (diff)
downloadsrc-a1f76946d54f50e738a1471dd9db2399463236a0.tar.gz
src-a1f76946d54f50e738a1471dd9db2399463236a0.zip
Merge from CheriBSD:
commit d0c7d235c09fc65dbdb278e7016a96f79c6a49cc Make the Altera JTAG UART device driver slightly more forgiving of the foibles of a sub-par hrdware interface by increasing the timeout for spotting JTAG polling from one to two seconds. commit 19ed45a18832560dab967c179d83b71081c3a220 Update comment. commit 8edfe803f033cc8e33229f99894c2b7496a44d5f Add a comment about a device-driver race condition that could cause the BERI pipeline to wedge awaiting JTAG in the event that both the low-level console and the tty layer decide to write to the JTAG FIFO just before JTAG is disconnected. Resolving this race is a bit tricky as it looks like there isn't a way to 'give the character back' to the tty layer when we discover the race. The easy fix is to drop the character, which we don't yet do, but perhaps should as that is a better outcome than wedging the pipeline. commit 2ea26cf579c9defcf31e413e7c9b0fbc159237fc Add a comment about an inherent race with hardware in the Altera JTAG UART's low-level console code. Submitted by: rwatson MFC after: 1 week Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/head/; revision=274821
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c3
-rw-r--r--sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c20
2 files changed, 21 insertions, 2 deletions
diff --git a/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c b/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c
index ae8459713003..96d20ceb21f4 100644
--- a/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c
+++ b/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c
@@ -221,6 +221,9 @@ aju_cons_write(char ch)
* disconnection.
*
* XXXRW: The polling delay may require tuning.
+ *
+ * XXXRW: Notice the inherent race with hardware: in clearing the
+ * bit, we may race with hardware setting the same bit.
*/
v = aju_cons_control_read();
if (v & ALTERA_JTAG_UART_CONTROL_AC) {
diff --git a/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c b/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
index ad5b8a41bdc5..dd46ea04038c 100644
--- a/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
+++ b/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
@@ -65,9 +65,9 @@ static struct ttydevsw aju_ttydevsw = {
/*
* When polling for the AC bit, the number of times we have to not see it
- * before assuming JTAG has disappeared on us. By default, one second.
+ * before assuming JTAG has disappeared on us. By default, two seconds.
*/
-#define AJU_JTAG_MAXMISS 5
+#define AJU_JTAG_MAXMISS 10
/*
* Polling intervals for input/output and JTAG connection events.
@@ -255,6 +255,22 @@ aju_handle_output(struct altera_jtag_uart_softc *sc, struct tty *tp)
if (ttydisc_getc(tp, &ch, sizeof(ch)) != sizeof(ch))
panic("%s: ttydisc_getc", __func__);
AJU_LOCK(sc);
+
+ /*
+ * XXXRW: There is a slight race here in which we test
+ * for writability, drop the lock, get the character
+ * from the tty layer, re-acquire the lock, and then
+ * write. It's possible for other code --
+ * specifically, the low-level console -- to have
+ * written in the mean time, which might mean that
+ * there is no longer space. The BERI memory bus will
+ * cause this write to block, wedging the processor
+ * until space is available -- which could be a while
+ * if JTAG is not attached!
+ *
+ * The 'easy' fix is to drop the character if WSPACE
+ * has become unset. Not sure what the 'hard' fix is.
+ */
aju_data_write(sc, ch);
} else {
/*