NetBSD-Bugs archive

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

re: kern/49709: radeondrmkms panic if "/dev/" is on NFS root



> >Synopsis:       radeondrmkms panic if "/dev/" is on NFS root

actually, it's a timing issue, not NFS root related.

the problem is that /sbin/init is allowed to run as soon as mountroot
completes, but before the paused configuration threads complete their
task and in this case, the radeondrmkms driver has not gotten to
attaching a wsdisplay0 and taking over the console.

fortunately, we have working fixes for this, and are just trying to
figure out which is the best.  one that i've tested that work is
below.


.mrg.


Index: sys/device.h
===================================================================
RCS file: /cvsroot/src/sys/sys/device.h,v
retrieving revision 1.146
diff -p -u -r1.146 device.h
--- sys/device.h	22 Nov 2014 11:04:57 -0000	1.146
+++ sys/device.h	1 Mar 2015 13:02:53 -0000
@@ -479,6 +479,7 @@ void	config_create_mountrootthreads(void
 
 int	config_finalize_register(device_t, int (*)(device_t));
 void	config_finalize(void);
+void	config_finalize_mountroot(void);
 
 void	config_twiddle_init(void);
 void	config_twiddle_fn(void *);
Index: kern/init_main.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_main.c,v
retrieving revision 1.461
diff -p -u -r1.461 init_main.c
--- kern/init_main.c	27 Nov 2014 14:38:09 -0000	1.461
+++ kern/init_main.c	1 Mar 2015 13:02:53 -0000
@@ -712,6 +712,9 @@ main(void)
 	    uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
 		panic("fork aiodoned");
 
+	/* Wait for final configure threads to complete. */
+	config_finalize_mountroot();
+
 	/*
 	 * Okay, now we can let init(8) exec!  It's off to userland!
 	 */
Index: kern/subr_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_autoconf.c,v
retrieving revision 1.233
diff -p -u -r1.233 subr_autoconf.c
--- kern/subr_autoconf.c	6 Nov 2014 08:46:04 -0000	1.233
+++ kern/subr_autoconf.c	1 Mar 2015 13:02:53 -0000
@@ -202,6 +202,7 @@ int interrupt_config_threads = 8;
 struct deferred_config_head mountroot_config_queue =
 	TAILQ_HEAD_INITIALIZER(mountroot_config_queue);
 int mountroot_config_threads = 2;
+lwp_t **mountroot_config_lwpids;
 static bool root_is_mounted = false;
 
 static void config_process_deferred(struct deferred_config_head *, device_t);
@@ -481,9 +482,32 @@ config_create_mountrootthreads(void)
 	if (!root_is_mounted)
 		root_is_mounted = true;
 
+	mountroot_config_lwpids = kmem_alloc(sizeof(mountroot_config_lwpids) *
+					     mountroot_config_threads,
+					     KM_NOSLEEP);
+	KASSERT(mountroot_config_lwpids);
 	for (i = 0; i < mountroot_config_threads; i++) {
-		(void)kthread_create(PRI_NONE, 0, NULL,
-		    config_mountroot_thread, NULL, NULL, "configroot");
+		mountroot_config_lwpids[i] = 0;
+		(void)kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL,
+				     config_mountroot_thread, NULL,
+				     &mountroot_config_lwpids[i],
+				     "configroot");
+	}
+}
+
+void
+config_finalize_mountroot(void)
+{
+	int i, error;
+
+	for (i = 0; i < mountroot_config_threads; i++) {
+		if (mountroot_config_lwpids[i] == 0)
+			continue;
+
+		error = kthread_join(mountroot_config_lwpids[i]);
+		if (error)
+			printf("%s: thread %x joined with error %d\n",
+			       __func__, i, error);
 	}
 }
 


Home | Main Index | Thread Index | Old Index