Module Name:    src
Committed By:   riastradh
Date:           Tue Apr 11 12:56:08 UTC 2023

Modified Files:
        src/sys/arch/evbarm/dev: plcom.c plcomreg.h plcomvar.h

Log Message:
evbarm/plcom(4): Sync some recent changes from com(4).

- Nix quirky `integrate' macro.
- Omit needless spltty in plcomstart.
- Comment on lock order.
- Update confusing comment about hangup delay.
- Add include guards.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/dev/plcomreg.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.67 src/sys/arch/evbarm/dev/plcom.c:1.68
--- src/sys/arch/evbarm/dev/plcom.c:1.67	Tue Jan 24 06:56:40 2023
+++ src/sys/arch/evbarm/dev/plcom.c	Tue Apr 11 12:56:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.67 2023/01/24 06:56:40 mlelstv Exp $	*/
+/*	$NetBSD: plcom.c,v 1.68 2023/04/11 12:56:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -91,10 +91,15 @@
  * COM driver for the Prime Cell PL010 and PL011 UARTs. Both are is similar to
  * the 16C550, but have a completely different programmer's model.
  * Derived from the NS16550AF com driver.
+ *
+ * Lock order:
+ *	tty_lock (IPL_VM)
+ *	-> sc->sc_lock (IPL_HIGH)
+ *	-> timecounter_lock (IPL_HIGH)
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.67 2023/01/24 06:56:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.68 2023/04/11 12:56:07 riastradh Exp $");
 
 #include "opt_plcom.h"
 #include "opt_kgdb.h"
@@ -181,12 +186,11 @@ void	plcomcnputc	(dev_t, int);
 void	plcomcnpollc	(dev_t, int);
 void	plcomcnhalt	(dev_t);
 
-#define	integrate	static inline
 void 	plcomsoft	(void *);
-integrate void plcom_rxsoft	(struct plcom_softc *, struct tty *);
-integrate void plcom_txsoft	(struct plcom_softc *, struct tty *);
-integrate void plcom_stsoft	(struct plcom_softc *, struct tty *);
-integrate void plcom_schedrx	(struct plcom_softc *);
+static inline void plcom_rxsoft	(struct plcom_softc *, struct tty *);
+static inline void plcom_txsoft	(struct plcom_softc *, struct tty *);
+static inline void plcom_stsoft	(struct plcom_softc *, struct tty *);
+static inline void plcom_schedrx	(struct plcom_softc *);
 void	plcomdiag		(void *);
 
 bool	plcom_intstatus(struct plcom_instance *, u_int *);
@@ -745,9 +749,9 @@ plcom_shutdown(struct plcom_softc *sc)
 	mutex_spin_exit(&timecounter_lock);
 
 	/*
-	 * Hang up if necessary.  Wait a bit, so the other side has time to
-	 * notice even if we immediately open the port again.
-	 * Avoid tsleeping above splhigh().
+	 * Hang up if necessary.  Record when we hung up, so if we
+	 * immediately open the port again, we will wait a bit until
+	 * the other side has had time to notice that we hung up.
 	 */
 	if (ISSET(tp->t_cflag, HUPCL)) {
 		plcom_modem(sc, 0);
@@ -1249,7 +1253,7 @@ plcomioctl(dev_t dev, u_long cmd, void *
 	return error;
 }
 
-integrate void
+static inline void
 plcom_schedrx(struct plcom_softc *sc)
 {
 
@@ -1765,19 +1769,17 @@ plcomstart(struct tty *tp)
 	struct plcom_softc *sc =
 		device_lookup_private(&plcom_cd, PLCOMUNIT(tp->t_dev));
 	struct plcom_instance *pi = &sc->sc_pi;
-	int s;
 
 	if (PLCOM_ISALIVE(sc) == 0)
 		return;
 
-	s = spltty();
 	if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
-		goto out;
+		return;
 	if (sc->sc_tx_stopped)
-		goto out;
+		return;
 
 	if (!ttypull(tp))
-		goto out;
+		return;
 
 	/* Grab the first contiguous region of buffer space. */
 	{
@@ -1825,9 +1827,6 @@ plcomstart(struct tty *tp)
 		sc->sc_tba += n;
 	}
 	mutex_spin_exit(&sc->sc_lock);
-out:
-	splx(s);
-	return;
 }
 
 /*
@@ -1870,7 +1869,7 @@ plcomdiag(void *arg)
 	    floods, floods == 1 ? "" : "s");
 }
 
-integrate void
+static inline void
 plcom_rxsoft(struct plcom_softc *sc, struct tty *tp)
 {
 	int (*rint) (int, struct tty *) = tp->t_linesw->l_rint;
@@ -1971,7 +1970,7 @@ plcom_rxsoft(struct plcom_softc *sc, str
 	}
 }
 
-integrate void
+static inline void
 plcom_txsoft(struct plcom_softc *sc, struct tty *tp)
 {
 
@@ -1983,7 +1982,7 @@ plcom_txsoft(struct plcom_softc *sc, str
 	(*tp->t_linesw->l_start)(tp);
 }
 
-integrate void
+static inline void
 plcom_stsoft(struct plcom_softc *sc, struct tty *tp)
 {
 	u_char msr, delta;

Index: src/sys/arch/evbarm/dev/plcomreg.h
diff -u src/sys/arch/evbarm/dev/plcomreg.h:1.7 src/sys/arch/evbarm/dev/plcomreg.h:1.8
--- src/sys/arch/evbarm/dev/plcomreg.h:1.7	Tue Jan 24 06:56:40 2023
+++ src/sys/arch/evbarm/dev/plcomreg.h	Tue Apr 11 12:56:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomreg.h,v 1.7 2023/01/24 06:56:40 mlelstv Exp $	*/
+/*	$NetBSD: plcomreg.h,v 1.8 2023/04/11 12:56:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -29,6 +29,8 @@
  * SUCH DAMAGE.
 */
 
+#ifndef	_SYS_ARCH_EVBARM_DEV_PLCOMREG_H_
+#define	_SYS_ARCH_EVBARM_DEV_PLCOMREG_H_
 
 #define	PLCOM_FREQ	1843200	/* 16-bit baud rate divisor */
 #define	PLCOM_TOLERANCE	30	/* baud rate tolerance, in 0.1% units */
@@ -173,3 +175,5 @@
 
 #define	PL010COM_UART_SIZE	0x100
 #define	PL011COM_UART_SIZE	0x1000
+
+#endif	/* _SYS_ARCH_EVBARM_DEV_PLCOMREG_H_ */

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.19 src/sys/arch/evbarm/dev/plcomvar.h:1.20
--- src/sys/arch/evbarm/dev/plcomvar.h:1.19	Tue Jan 24 06:56:40 2023
+++ src/sys/arch/evbarm/dev/plcomvar.h	Tue Apr 11 12:56:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.19 2023/01/24 06:56:40 mlelstv Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.20 2023/04/11 12:56:07 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -30,6 +30,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef	_SYS_ARCH_EVBARM_DEV_PLCOMVAR_H_
+#define	_SYS_ARCH_EVBARM_DEV_PLCOMVAR_H_
+
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
 #include "opt_plcom.h"
@@ -171,3 +174,4 @@ void plcom_attach_subr	(struct plcom_sof
 int  plcom_detach	(device_t, int);
 int  plcom_activate	(device_t, enum devact);
 
+#endif	/* _SYS_ARCH_EVBARM_DEV_PLCOMVAR_H_ */

Reply via email to