diff options
author | phk <phk@FreeBSD.org> | 2004-08-20 15:14:25 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-08-20 15:14:25 +0000 |
commit | 91de1b896dea3928223e2531589b4c7c0d422ada (patch) | |
tree | b948c22d12f559b0c58f576fc7da5d69acc1c8ef /sys/dev/fdc/fdc_isa.c | |
parent | ca124b900b50e6642bad1e763cd2750ba4776602 (diff) | |
download | FreeBSD-src-91de1b896dea3928223e2531589b4c7c0d422ada.zip FreeBSD-src-91de1b896dea3928223e2531589b4c7c0d422ada.tar.gz |
Rewrite of the floppy driver to make it MPsafe & GEOM friendly:
Centralize the fdctl_wr() function by adding the offset in
the resource to the softc structure.
Bugfix: Read the drive-change signal from the correct place:
same place as the ctl register.
Remove the cdevsw{} related code and implement a GEOM class.
Ditch the state-engine and park a thread on each controller
to service the queue.
Make the interrupt FAST & MPSAFE since it is just a simple
wakeup(9) call.
Rely on a per controller mutex to protect the bioqueues.
Grab GEOMs topology lock when we have to and Giant when
ISADMA needs it. Since all access to the hardware is
isolated in the per controller thread, the rest of the
driver is lock & Giant free.
Create a per-drive queue where requests are parked while
the motor spins up. When the motor is running the requests
are purged to the per controller queue. This allows
requests to other drives to be serviced during spin-up.
Only setup the motor-off timeout when we finish the last
request on the queue and cancel it when a new request
arrives. This fixes the bug in the old code where the motor
turned off while we were still retrying a request.
Make the "drive-change" work reliably. Probe the drive on
first opens. Probe with a recal and a seek to cyl=1 to
reset the drive change line and check again to see if we
have a media.
When we see the media disappear we destroy the geom provider,
create a new one, and flag that autodetection should happen
next time we see a media (unless a specific format is configured).
Add sysctl tunables for a lot of drive related parameters.
If you spend a lot of time waiting for floppies you can
grab the i82078 pdf from Intels web-page and try tuning
these.
Add sysctl debug.fdc.debugflags which will enable various
kinds of debugging printfs.
Add central definitions of our well known floppy formats.
Simplify datastructures for autoselection of format and
call the code at the right times.
Bugfix: Remove at least one piece of code which would have
made 2.88M floppies not work.
Use implied seeks on enhanced controllers.
Use multisector transfers on all controllers. Increase
ISADMA bounce buffers accordingly.
Fall back to single sector when retrying. Reset retry count
on every successful transaction.
Sort functions in a more sensible order and generally tidy
up a fair bit here and there.
Assorted related fixes and adjustments in userland utilities.
WORKAROUNDS:
Do allow r/w opens of r/o media but refuse actual write
operations. This is necessary until the p4::phk_bufwork
branch gets integrated (This problem relates to remounting
not reopening devices, see sys/*/*/${fs}_vfsops.c for details).
Keep PC98's private copy of the old floppy driver compiling
and presumably working (see below).
TODO (planned)
Move probing of drives until after interrupts/timeouts work
(like for ATA/SCSI drives).
TODO (unplanned)
This driver should be made to work on PC98 as well.
Test on YE-DATA PCMCIA floppy drive.
Fix 2.88M media.
This is a MT5 candidate (depends on the bioq_takefirst() addition).
Diffstat (limited to 'sys/dev/fdc/fdc_isa.c')
-rw-r--r-- | sys/dev/fdc/fdc_isa.c | 73 |
1 files changed, 12 insertions, 61 deletions
diff --git a/sys/dev/fdc/fdc_isa.c b/sys/dev/fdc/fdc_isa.c index 5ca027e..c80dba0 100644 --- a/sys/dev/fdc/fdc_isa.c +++ b/sys/dev/fdc/fdc_isa.c @@ -33,20 +33,20 @@ __FBSDID("$FreeBSD$"); #include <sys/bio.h> #include <sys/bus.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/rman.h> #include <sys/systm.h> #include <machine/bus.h> #include <dev/fdc/fdcvar.h> -#include <dev/fdc/fdcreg.h> #include <isa/isavar.h> #include <isa/isareg.h> static int fdc_isa_probe(device_t); -static void fdctl_wr_isa(fdc_p, u_int8_t); static struct isa_pnp_id fdc_ids[] = { {0x0007d041, "PC standard floppy disk controller"}, /* PNP0700 */ @@ -54,12 +54,6 @@ static struct isa_pnp_id fdc_ids[] = { {0} }; -static void -fdctl_wr_isa(fdc_p fdc, u_int8_t v) -{ - bus_space_write_1(fdc->ctlt, fdc->ctlh, 0, v); -} - int fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc) { @@ -165,6 +159,7 @@ fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc) } fdc->ctlt = rman_get_bustag(fdc->res_ctl); fdc->ctlh = rman_get_bushandle(fdc->res_ctl); + fdc->ctl_off = 0; fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq, RF_ACTIVE | RF_SHAREABLE); @@ -189,12 +184,11 @@ fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc) static int fdc_isa_probe(device_t dev) { - int error, ic_type; + int error; struct fdc_data *fdc; fdc = device_get_softc(dev); fdc->fdc_dev = dev; - fdc->fdctl_wr = fdctl_wr_isa; /* Check pnp ids */ error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids); @@ -203,32 +197,9 @@ fdc_isa_probe(device_t dev) /* Attempt to allocate our resources for the duration of the probe */ error = fdc_isa_alloc_resources(dev, fdc); - if (error) - goto out; - - /* Check that the controller is working. */ - error = fdc_initial_reset(fdc); - if (error) - goto out; - - /* Try to determine a more specific device type. */ - if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) { - switch (ic_type & 0xff) { - case 0x80: - device_set_desc(dev, "NEC 765 or clone"); - break; - case 0x81: /* not mentioned in any hardware doc */ - case 0x90: - device_set_desc(dev, - "Enhanced floppy controller (i82077, NE72065 or clone)"); - break; - default: - device_set_desc(dev, "Generic floppy controller"); - break; - } - } + if (error == 0) + error = fdc_initial_reset(dev, fdc); -out: fdc_release_resources(fdc); return (error); } @@ -236,40 +207,20 @@ out: static int fdc_isa_attach(device_t dev) { - int ic_type; struct fdc_data *fdc; int error; fdc = device_get_softc(dev); - fdc->fdctl_wr = fdctl_wr_isa; error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids); if (error == 0) fdc->flags |= FDC_ISPNP; - if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) { - switch (ic_type & 0xff) { - case 0x80: - fdc->fdct = FDC_NE765; - break; - case 0x81: /* not mentioned in any hardware doc */ - case 0x90: - fdc->fdct = FDC_ENHANCED; - break; - default: - fdc->fdct = FDC_UNKNOWN; - break; - } - } - error = fdc_isa_alloc_resources(dev, fdc); - if (error) - goto out; - error = fdc_attach(dev); - if (error) - goto out; - error = fdc_hints_probe(dev); - if (error) - goto out; -out: + if (error == 0) + error = fdc_isa_alloc_resources(dev, fdc); + if (error == 0) + error = fdc_attach(dev); + if (error == 0) + error = fdc_hints_probe(dev); if (error) fdc_release_resources(fdc); return (error); |