From: Martin Husemann <martin@duskware.de>
To: kern-bug-people@netbsd.org,gnats-admin@netbsd.org,netbsd-bugs@netbsd.org,gson@gson.org (Andreas Gustafsson)
Cc: 
Subject: Re: kern/55286: Kernel messages cause loss of serial console input
Date: Mon, 25 May 2020 13:00:02 +0000 (UTC)

The following reply was made to PR kern/55286; it has been noted by GNATS.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/55286: Kernel messages cause loss of serial console input
Date: Mon, 25 May 2020 14:56:07 +0200

Here is a patch that uses readahead in comcnputc only while we are still
cold - compile tested only, but should fix the problem as well.


Martin

Index: com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.358
diff -u -p -r1.358 com.c
--- src/sys/dev/ic/com.c	1 May 2020 07:27:51 -0000	1.358
+++ src/sys/dev/ic/com.c	25 May 2020 12:48:20 -0000
@@ -159,7 +159,7 @@ int	com_to_tiocm(struct com_softc *);
 void	com_iflush(struct com_softc *);
 
 int	com_common_getc(dev_t, struct com_regs *);
-static void	com_common_putc(dev_t, struct com_regs *, int);
+static void	com_common_putc(dev_t, struct com_regs *, int, int);
 
 int	cominit(struct com_regs *, int, int, int, tcflag_t);
 
@@ -2399,12 +2399,12 @@ com_common_getc(dev_t dev, struct com_re
 }
 
 static void
-com_common_putc(dev_t dev, struct com_regs *regsp, int c)
+com_common_putc(dev_t dev, struct com_regs *regsp, int c, int with_readahead)
 {
 	int s = splserial();
 	int cin, stat, timo;
 
-	if (com_readaheadcount < MAX_READAHEAD
+	if (with_readahead && com_readaheadcount < MAX_READAHEAD
 	     && ISSET(stat = CSR_READ_1(regsp, COM_REG_LSR), LSR_RXRDY)) {
 		int cn_trapped = 0;
 		cin = CSR_READ_1(regsp, COM_REG_RXDATA);
@@ -2572,7 +2572,7 @@ void
 comcnputc(dev_t dev, int c)
 {
 
-	com_common_putc(dev, &comcons_info.regs, c);
+	com_common_putc(dev, &comcons_info.regs, c, cold);
 }
 
 void
@@ -2641,8 +2641,8 @@ void
 com_kgdb_putc(void *arg, int c)
 {
 
-	com_common_putc(NODEV, &comkgdbregs, c);
+	com_common_putc(NODEV, &comkgdbregs, c, 0);
 }
 #endif /* KGDB */
  
 


