git: 525ac1948af8 - releng/13.2 - loader: comconsole: don't unconditionally wipe out hw.uart.console

From: Gordon Tetlow <gordon_at_FreeBSD.org>
Date: Wed, 21 Jun 2023 05:41:46 UTC
The branch releng/13.2 has been updated by gordon:

URL: https://cgit.FreeBSD.org/src/commit/?id=525ac1948af8fb7253f15e3645f4041cb0e2b107

commit 525ac1948af8fb7253f15e3645f4041cb0e2b107
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-04-14 04:41:22 +0000
Commit:     Gordon Tetlow <gordon@FreeBSD.org>
CommitDate: 2023-06-21 05:05:15 +0000

    loader: comconsole: don't unconditionally wipe out hw.uart.console
    
    It may be the case that we need to set hw.uart.console manually in some
    scenarios that comconsole can't necessarily support.  Avoid clobbering
    hw.uart.console unless we've actually selected comconsole so that one
    could at least get kernel console output..
    
    Discussed with: imp
    Sponsored by:   Zenith Electronics LLC
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit ec671f4980437008b0119c6367816083e15fa503)
    (cherry picked from commit 362677cae8e9ac4c6f7ff4d74a4378ea11d47797)
    
    Approved by:    so
    Security:       FreeBSD-EN-23:06.loader
---
 stand/i386/libi386/comconsole.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/stand/i386/libi386/comconsole.c b/stand/i386/libi386/comconsole.c
index ed1f1aa08ed7..6d48e876fa37 100644
--- a/stand/i386/libi386/comconsole.c
+++ b/stand/i386/libi386/comconsole.c
@@ -324,12 +324,13 @@ comc_setup(int speed, int port)
 	char intbuf[64];
 	int tries;
 
-	unsetenv("hw.uart.console");
 	comc_curspeed = speed;
 	comc_port = port;
 	if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0)
 		return;
 
+	unsetenv("hw.uart.console");
+
 #define	COMC_TEST	0xbb
 	/*
 	 * Write byte to scratch register and read it out.