tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: patch review: avoid com delay() in VMs



On Wed, 5 Feb 2025, Emile `iMil' Heitor wrote:

After several back-and-forths, thanks Martin, Simon and Taylor for
your help, here's a cleaner approach based on prop_dictionary_util,
avoiding #ifdefs:

Another day, another proposal!
Here are the results of discussions about finally getting rid of delay()
and instead checking LSR_TXRDY (aka LSR_THRE) or LSR_TSRE (aka LSR_TEMT)

diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index d271b594346..082b5b8a985 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -536,6 +536,7 @@ com_attach_subr(struct com_softc *sc)
        struct tty *tp;
        uint32_t cpr;
        uint8_t lcr;
+       int timo;
        const char *fifo_msg = NULL;
        prop_dictionary_t dict;
        bool is_console = true;
@@ -588,9 +589,13 @@ com_attach_subr(struct com_softc *sc)
                        sc->sc_lcr = cflag2lcr(comcons_info.cflag);
                        break;
                }
+               /* wait for output to finish */
+               timo = 10000;
+               while (!ISSET(CSR_READ_1(regsp, COM_REG_LSR),
+                   LSR_TXRDY | LSR_TSRE) && --timo)
+                       continue;

                /* Make sure the console is always "hardwired". */
-               delay(10000);                   /* wait for output to finish */
                if (is_console) {
                        SET(sc->sc_hwflags, COM_HW_CONSOLE);
                }

------------------------------------------------------------------------
Emile `iMil' Heitor <imil@{home.imil.net,NetBSD.org}> | https://imil.net



Home | Main Index | Thread Index | Old Index