Hi,

is anyone still using floppies? If yes, it would be nice if they could 
give the diff below a test. It defers probing of the drives which reduces 
boot time quite a bit. If floppy does not work with the diff, please also 
test if it works without it. On qemu, floppy access seems to be broken (or 
I did something wrong).

Cheers,
Stefan


diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c
index 3e16d054428..460830a97cc 100644
--- a/sys/dev/isa/fd.c
+++ b/sys/dev/isa/fd.c
@@ -210,11 +210,11 @@ fdprobe(struct device *parent, void *match, void *aux)
        /* select drive and turn on motor */
        bus_space_write_1(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive));
        /* wait for motor to spin up */
-       delay(250000);
+       tsleep(fdc, 0, "fdprobe", 250 * hz / 1000);
        out_fdc(iot, ioh, NE7CMD_RECAL);
        out_fdc(iot, ioh, drive);
        /* wait for recalibrate */
-       delay(2000000);
+       tsleep(fdc, 0, "fdprobe", 2000 * hz / 1000);
        out_fdc(iot, ioh, NE7CMD_SENSEI);
        n = fdcresult(fdc);
 #ifdef FD_DEBUG
@@ -228,7 +228,7 @@ fdprobe(struct device *parent, void *match, void *aux)
 #endif
 
        /* turn off motor */
-       delay(250000);
+       tsleep(fdc, 0, "fdprobe", 250 * hz / 1000);
        bus_space_write_1(iot, ioh, fdout, FDO_FRST);
 
        /* flags & 0x20 forces the drive to be found even if it won't probe */
diff --git a/sys/dev/isa/fdc.c b/sys/dev/isa/fdc.c
index c7b7ae4562c..ee195367322 100644
--- a/sys/dev/isa/fdc.c
+++ b/sys/dev/isa/fdc.c
@@ -57,6 +57,7 @@
 #include <sys/syslog.h>
 #include <sys/queue.h>
 #include <sys/timeout.h>
+#include <sys/kthread.h>
 
 #include <machine/cpu.h>
 #include <machine/bus.h>
@@ -79,6 +80,8 @@
 /* controller driver configuration */
 int fdcprobe(struct device *, void *, void *);
 void fdcattach(struct device *, struct device *, void *);
+void fdcattach_deferred(void *);
+void fdc_create_kthread(void *);
 
 struct cfattach fdc_ca = {
        sizeof(struct fdc_softc), fdcprobe, fdcattach
@@ -139,8 +142,6 @@ fdcattach(struct device *parent, struct device *self, void 
*aux)
        bus_space_handle_t ioh;
        bus_space_handle_t ioh_ctl;
        struct isa_attach_args *ia = aux;
-       struct fdc_attach_args fa;
-       int type;
 
        iot = ia->ia_iot;
 
@@ -163,6 +164,22 @@ fdcattach(struct device *parent, struct device *self, void 
*aux)
        fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
            IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname);
 
+       kthread_create_deferred(fdc_create_kthread, fdc);
+}
+
+void
+fdc_create_kthread(void *arg)
+{
+       kthread_create(fdcattach_deferred, arg, NULL, "fdcattach");
+}
+
+void
+fdcattach_deferred(void *arg)
+{
+       struct fdc_softc *fdc = arg;
+       struct fdc_attach_args fa;
+       int type;
+
 #if defined(__i386__) || defined(__amd64__)
        /*
         * The NVRAM info only tells us about the first two disks on the
@@ -187,8 +204,9 @@ fdcattach(struct device *parent, struct device *self, void 
*aux)
                else
 #endif
                        fa.fa_deftype = NULL;           /* unknown */
-               (void)config_found(self, (void *)&fa, fddprint);
+               (void)config_found(&fdc->sc_dev, (void *)&fa, fddprint);
        }
+       kthread_exit(0);
 }
 
 /*

Reply via email to