diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2017-09-03 20:03:59 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2017-09-03 20:03:59 +0000 |
commit | 44c7d6b7077e333fc1222c7090566fa825d7b0b8 (patch) | |
tree | 5c17c5a25c0ea09b04b5c8b119da7de61176e740 /sys | |
parent | 597782ee10bf024d5563f2daf2f0547d8b152e3c (diff) |
fdc: defer probing of floppy drives
Defer probing of the drives to a kthread. This avoids several seconds of
delay() during boot. However, drives may now appear only after init has
started. But this does not affect installs from floppy. In that case the root
ramdisk is linked into the kernel and loaded by the boot loader.
Approach suggested by deraadt@, tested by miod@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/isa/fd.c | 8 | ||||
-rw-r--r-- | sys/dev/isa/fdc.c | 26 |
2 files changed, 26 insertions, 8 deletions
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 3e16d054428..0767e21c153 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.104 2017/05/04 22:47:27 deraadt Exp $ */ +/* $OpenBSD: fd.c,v 1.105 2017/09/03 20:03:58 sf Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -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..75e8e9f7d67 100644 --- a/sys/dev/isa/fdc.c +++ b/sys/dev/isa/fdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdc.c,v 1.20 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: fdc.c,v 1.21 2017/09/03 20:03:58 sf Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -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); } /* |