svn commit: r359900 - head/sys/dev/uart

John Baldwin jhb at FreeBSD.org
Mon Apr 13 20:59:10 UTC 2020


Author: jhb
Date: Mon Apr 13 20:59:09 2020
New Revision: 359900
URL: https://svnweb.freebsd.org/changeset/base/359900

Log:
  Export a sysctl count of RX FIFO overrun events.
  
  uart(4) backends currently detect RX FIFO overrun errors and report
  them to the uart(4) core layer.  They are then reported to the generic
  TTY layer which promptly ignores them.  As a result, there is
  currently no good way to determine if a uart is experiencing RX FIFO
  overruns.  One could add a generic per-tty counter, but there did not
  appear to be a good way to export those.  Instead, add a sysctl under
  the uart(4) sysctl tree to export the count of overruns.
  
  Reviewed by:	brooks
  MFC after:	2 weeks
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D24368

Modified:
  head/sys/dev/uart/uart_bus.h
  head/sys/dev/uart/uart_core.c

Modified: head/sys/dev/uart/uart_bus.h
==============================================================================
--- head/sys/dev/uart/uart_bus.h	Mon Apr 13 20:43:57 2020	(r359899)
+++ head/sys/dev/uart/uart_bus.h	Mon Apr 13 20:59:09 2020	(r359900)
@@ -111,6 +111,7 @@ struct uart_softc {
 	int		sc_rxput;
 	int		sc_rxget;
 	int		sc_rxfifosz;	/* Size of RX FIFO. */
+	int		sc_rxoverruns;
 
 	/* Transmitter data. */
 	uint8_t		*sc_txbuf;

Modified: head/sys/dev/uart/uart_core.c
==============================================================================
--- head/sys/dev/uart/uart_core.c	Mon Apr 13 20:43:57 2020	(r359899)
+++ head/sys/dev/uart/uart_core.c	Mon Apr 13 20:59:09 2020	(r359900)
@@ -333,6 +333,7 @@ uart_intr_overrun(void *arg)
 			sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN;
 		uart_sched_softih(sc, SER_INT_RXREADY);
 	}
+	sc->sc_rxoverruns++;
 	UART_FLUSH(sc, UART_FLUSH_RECEIVER);
 	return (0);
 }
@@ -740,6 +741,12 @@ uart_bus_attach(device_t dev)
 
 	if (sc->sc_sysdev != NULL)
 		sc->sc_sysdev->hwmtx = sc->sc_hwmtx;
+
+	if (sc->sc_rxfifosz > 1)
+		SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
+		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
+		    "rx_overruns", CTLFLAG_RD, &sc->sc_rxoverruns, 0,
+		    "Receive overruns");
 
 	return (0);
 


More information about the svn-src-head mailing list