svn commit: r310348 - head/sys/dev/hyperv/vmbus

Sepherosa Ziehau sephe at FreeBSD.org
Wed Dec 21 03:23:37 UTC 2016


Author: sephe
Date: Wed Dec 21 03:23:35 2016
New Revision: 310348
URL: https://svnweb.freebsd.org/changeset/base/310348

Log:
  hyperv: Unbreak EARLY_AP_STARUP Hyper-V bootstrap by using intrhook
  
  Properly working pause and friends are required.
  
  MFC after:	3 days
  Sponsored by:	Microsoft

Modified:
  head/sys/dev/hyperv/vmbus/vmbus.c
  head/sys/dev/hyperv/vmbus/vmbus_var.h

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c	Wed Dec 21 03:09:07 2016	(r310347)
+++ head/sys/dev/hyperv/vmbus/vmbus.c	Wed Dec 21 03:23:35 2016	(r310348)
@@ -99,6 +99,9 @@ static uint32_t			vmbus_get_vcpu_id_meth
 				    device_t dev, int cpu);
 static struct taskqueue		*vmbus_get_eventtq_method(device_t, device_t,
 				    int);
+#ifdef EARLY_AP_STARTUP
+static void			vmbus_intrhook(void *);
+#endif
 
 static int			vmbus_init(struct vmbus_softc *);
 static int			vmbus_connect(struct vmbus_softc *, uint32_t);
@@ -1402,6 +1405,21 @@ vmbus_event_proc_dummy(struct vmbus_soft
 {
 }
 
+#ifdef EARLY_AP_STARTUP
+
+static void
+vmbus_intrhook(void *xsc)
+{
+	struct vmbus_softc *sc = xsc;
+
+	if (bootverbose)
+		device_printf(sc->vmbus_dev, "intrhook\n");
+	vmbus_doattach(sc);
+	config_intrhook_disestablish(&sc->vmbus_intrhook);
+}
+
+#endif	/* EARLY_AP_STARTUP */
+
 static int
 vmbus_attach(device_t dev)
 {
@@ -1416,7 +1434,14 @@ vmbus_attach(device_t dev)
 	 */
 	vmbus_sc->vmbus_event_proc = vmbus_event_proc_dummy;
 
-#ifndef EARLY_AP_STARTUP
+#ifdef EARLY_AP_STARTUP
+	/*
+	 * Defer the real attach until the pause(9) works as expected.
+	 */
+	vmbus_sc->vmbus_intrhook.ich_func = vmbus_intrhook;
+	vmbus_sc->vmbus_intrhook.ich_arg = vmbus_sc;
+	config_intrhook_establish(&vmbus_sc->vmbus_intrhook);
+#else	/* !EARLY_AP_STARTUP */
 	/* 
 	 * If the system has already booted and thread
 	 * scheduling is possible indicated by the global
@@ -1424,8 +1449,8 @@ vmbus_attach(device_t dev)
 	 * initialization directly.
 	 */
 	if (!cold)
-#endif
 		vmbus_doattach(vmbus_sc);
+#endif	/* EARLY_AP_STARTUP */
 
 	return (0);
 }

Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed Dec 21 03:09:07 2016	(r310347)
+++ head/sys/dev/hyperv/vmbus/vmbus_var.h	Wed Dec 21 03:23:35 2016	(r310348)
@@ -30,6 +30,7 @@
 #define _VMBUS_VAR_H_
 
 #include <sys/param.h>
+#include <sys/kernel.h>
 #include <sys/taskqueue.h>
 #include <sys/rman.h>
 
@@ -128,6 +129,8 @@ struct vmbus_softc {
 	struct mtx		vmbus_chan_lock;
 	TAILQ_HEAD(, vmbus_channel) vmbus_chans;
 
+	struct intr_config_hook	vmbus_intrhook;
+
 #ifdef NEW_PCIB
 	/* The list of usable MMIO ranges for PCIe pass-through */
 	struct pcib_host_resources vmbus_mmio_res;


More information about the svn-src-head mailing list