diff options
author | John Baldwin <jhb@FreeBSD.org> | 2012-09-17 15:27:30 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2012-09-17 15:27:30 +0000 |
commit | 0fca6f8bf5de47b6d016500bf066d584959800f4 (patch) | |
tree | 101051e595babb417c37add67ba9f87bd7904b6a /sys/dev/mlx/mlx_disk.c | |
parent | 8b3daf895a629984a7c3ef5449c280288fd9dccb (diff) | |
download | src-0fca6f8bf5de47b6d016500bf066d584959800f4.tar.gz src-0fca6f8bf5de47b6d016500bf066d584959800f4.zip |
Add locking to mlx(4) to make it MPSAFE along with some other fixes:
- Use callout(9) rather than timeout(9).
- Add a mutex as an I/O lock that protects the adapter and is used
for the I/O path.
- Add an sx lock as a configuration lock that protects the relationship
of configured volumes.
- Freeze the request queue when a DMA load is deferred with EINPROGRESS
and unfreeze the queue when the DMA callback is invoked.
- Explicitly poll the hardware while waiting to submit a command to
allow completed commands to free up slots in the command ring.
- Remove driver-wide 'initted' variable from mlx_*_fw_handshake() routines.
That state should be per-controller instead. Add it as an argument
since the first caller knows when it is the first caller.
- Remove explicit bus_space tag/handle and use bus_*() rather than
bus_space_*().
- Move duplicated PCI device ID probing into a mlx_pci_match() routine.
- Don't check for PCIM_CMD_MEMEN (the PCI bus will enable that when
allocating the resource) and use pci_enable_busmaster() rather than
manipulating the register directly.
Tested by: no one despite multiple requests (hope it works)
Notes
Notes:
svn path=/head/; revision=240608
Diffstat (limited to 'sys/dev/mlx/mlx_disk.c')
-rw-r--r-- | sys/dev/mlx/mlx_disk.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c index db86bf85e2e7..8276a4a740e9 100644 --- a/sys/dev/mlx/mlx_disk.c +++ b/sys/dev/mlx/mlx_disk.c @@ -36,7 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> +#include <sys/sx.h> #include <sys/bus.h> #include <sys/conf.h> @@ -84,10 +86,17 @@ mlxd_open(struct disk *dp) return (ENXIO); /* controller not active? */ - if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN) + MLX_CONFIG_LOCK(sc->mlxd_controller); + MLX_IO_LOCK(sc->mlxd_controller); + if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN) { + MLX_IO_UNLOCK(sc->mlxd_controller); + MLX_CONFIG_UNLOCK(sc->mlxd_controller); return(ENXIO); + } sc->mlxd_flags |= MLXD_OPEN; + MLX_IO_UNLOCK(sc->mlxd_controller); + MLX_CONFIG_UNLOCK(sc->mlxd_controller); return (0); } @@ -97,10 +106,14 @@ mlxd_close(struct disk *dp) struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; debug_called(1); - + if (sc == NULL) return (ENXIO); + MLX_CONFIG_LOCK(sc->mlxd_controller); + MLX_IO_LOCK(sc->mlxd_controller); sc->mlxd_flags &= ~MLXD_OPEN; + MLX_IO_UNLOCK(sc->mlxd_controller); + MLX_CONFIG_UNLOCK(sc->mlxd_controller); return (0); } @@ -142,13 +155,16 @@ mlxd_strategy(mlx_bio *bp) } /* XXX may only be temporarily offline - sleep? */ + MLX_IO_LOCK(sc->mlxd_controller); if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { + MLX_IO_UNLOCK(sc->mlxd_controller); MLX_BIO_SET_ERROR(bp, ENXIO); goto bad; } MLX_BIO_STATS_START(bp); mlx_submit_buf(sc->mlxd_controller, bp); + MLX_IO_UNLOCK(sc->mlxd_controller); return; bad: @@ -232,7 +248,6 @@ mlxd_attach(device_t dev) sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size; sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors; sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads; - sc->mlxd_disk->d_flags = DISKFLAG_NEEDSGIANT; /* * Set maximum I/O size to the lesser of the recommended maximum and the practical |