tech-kern archive

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

patch review: avoid com delay() in VMs




com_attach_subr() in sys/dev/ic/com.c has a delay(10000) waiting for
output to finish, this is very unlikely to be useful inside a virtual
machine and slows down boot time in such machine.
I propose the following approach:

diff --git a/sys/arch/x86/include/cpu.h b/sys/arch/x86/include/cpu.h
index 6c26dc624b1..94c99946bc9 100644
--- a/sys/arch/x86/include/cpu.h
+++ b/sys/arch/x86/include/cpu.h
@@ -558,6 +558,12 @@ vm_guest_is_pvh(void)
        }
 }

+static __inline bool __unused
+inside_vm_guest(void)
+{
+       return vm_guest != VM_GUEST_NO;
+}
+
 /* cpu_topology.c */
 void   x86_cpu_topology(struct cpu_info *);

diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index d271b594346..f42b6a86720 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -589,6 +589,9 @@ com_attach_subr(struct com_softc *sc)
                        break;
                }

+#if defined(__i386__) || defined(__x86_64__)
+               if (!inside_vm_guest())
+#endif
                /* Make sure the console is always "hardwired". */
                delay(10000);                   /* wait for output to finish */
                if (is_console) {

Thoughts?

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



Home | Main Index | Thread Index | Old Index