mlx_disk.c (138090) | mlx_disk.c (240608) |
---|---|
1/*- 2 * Copyright (c) 1999 Jonathan Lemon 3 * Copyright (c) 1999 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999 Jonathan Lemon 3 * Copyright (c) 1999 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/mlx/mlx_disk.c 138090 2004-11-25 12:15:49Z scottl $"); | 30__FBSDID("$FreeBSD: head/sys/dev/mlx/mlx_disk.c 240608 2012-09-17 15:27:30Z jhb $"); |
31 32/* 33 * Disk driver for Mylex DAC960 RAID adapters. 34 */ 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/kernel.h> | 31 32/* 33 * Disk driver for Mylex DAC960 RAID adapters. 34 */ 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/kernel.h> |
39#include <sys/lock.h> |
|
39#include <sys/module.h> | 40#include <sys/module.h> |
41#include <sys/sx.h> |
|
40 41#include <sys/bus.h> 42#include <sys/conf.h> 43 44#include <machine/bus.h> 45#include <sys/rman.h> 46 47#include <geom/geom_disk.h> --- 31 unchanged lines hidden (view full) --- 79 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 80 81 debug_called(1); 82 83 if (sc == NULL) 84 return (ENXIO); 85 86 /* controller not active? */ | 42 43#include <sys/bus.h> 44#include <sys/conf.h> 45 46#include <machine/bus.h> 47#include <sys/rman.h> 48 49#include <geom/geom_disk.h> --- 31 unchanged lines hidden (view full) --- 81 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 82 83 debug_called(1); 84 85 if (sc == NULL) 86 return (ENXIO); 87 88 /* controller not active? */ |
87 if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN) | 89 MLX_CONFIG_LOCK(sc->mlxd_controller); 90 MLX_IO_LOCK(sc->mlxd_controller); 91 if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN) { 92 MLX_IO_UNLOCK(sc->mlxd_controller); 93 MLX_CONFIG_UNLOCK(sc->mlxd_controller); |
88 return(ENXIO); | 94 return(ENXIO); |
95 } |
|
89 90 sc->mlxd_flags |= MLXD_OPEN; | 96 97 sc->mlxd_flags |= MLXD_OPEN; |
98 MLX_IO_UNLOCK(sc->mlxd_controller); 99 MLX_CONFIG_UNLOCK(sc->mlxd_controller); |
|
91 return (0); 92} 93 94static int 95mlxd_close(struct disk *dp) 96{ 97 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 98 99 debug_called(1); | 100 return (0); 101} 102 103static int 104mlxd_close(struct disk *dp) 105{ 106 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 107 108 debug_called(1); |
100 | 109 |
101 if (sc == NULL) 102 return (ENXIO); | 110 if (sc == NULL) 111 return (ENXIO); |
112 MLX_CONFIG_LOCK(sc->mlxd_controller); 113 MLX_IO_LOCK(sc->mlxd_controller); |
|
103 sc->mlxd_flags &= ~MLXD_OPEN; | 114 sc->mlxd_flags &= ~MLXD_OPEN; |
115 MLX_IO_UNLOCK(sc->mlxd_controller); 116 MLX_CONFIG_UNLOCK(sc->mlxd_controller); |
|
104 return (0); 105} 106 107static int 108mlxd_ioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) 109{ 110 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 111 int error; --- 25 unchanged lines hidden (view full) --- 137 138 /* bogus disk? */ 139 if (sc == NULL) { 140 MLX_BIO_SET_ERROR(bp, EINVAL); 141 goto bad; 142 } 143 144 /* XXX may only be temporarily offline - sleep? */ | 117 return (0); 118} 119 120static int 121mlxd_ioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) 122{ 123 struct mlxd_softc *sc = (struct mlxd_softc *)dp->d_drv1; 124 int error; --- 25 unchanged lines hidden (view full) --- 150 151 /* bogus disk? */ 152 if (sc == NULL) { 153 MLX_BIO_SET_ERROR(bp, EINVAL); 154 goto bad; 155 } 156 157 /* XXX may only be temporarily offline - sleep? */ |
158 MLX_IO_LOCK(sc->mlxd_controller); |
|
145 if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { | 159 if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { |
160 MLX_IO_UNLOCK(sc->mlxd_controller); |
|
146 MLX_BIO_SET_ERROR(bp, ENXIO); 147 goto bad; 148 } 149 150 MLX_BIO_STATS_START(bp); 151 mlx_submit_buf(sc->mlxd_controller, bp); | 161 MLX_BIO_SET_ERROR(bp, ENXIO); 162 goto bad; 163 } 164 165 MLX_BIO_STATS_START(bp); 166 mlx_submit_buf(sc->mlxd_controller, bp); |
167 MLX_IO_UNLOCK(sc->mlxd_controller); |
|
152 return; 153 154 bad: 155 /* 156 * Correctly set the bio to indicate a failed tranfer. 157 */ 158 MLX_BIO_RESID(bp) = MLX_BIO_LENGTH(bp); 159 MLX_BIO_DONE(bp); --- 67 unchanged lines hidden (view full) --- 227 sc->mlxd_disk->d_strategy = mlxd_strategy; 228 sc->mlxd_disk->d_name = "mlxd"; 229 sc->mlxd_disk->d_unit = sc->mlxd_unit; 230 sc->mlxd_disk->d_drv1 = sc; 231 sc->mlxd_disk->d_sectorsize = MLX_BLKSIZE; 232 sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size; 233 sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors; 234 sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads; | 168 return; 169 170 bad: 171 /* 172 * Correctly set the bio to indicate a failed tranfer. 173 */ 174 MLX_BIO_RESID(bp) = MLX_BIO_LENGTH(bp); 175 MLX_BIO_DONE(bp); --- 67 unchanged lines hidden (view full) --- 243 sc->mlxd_disk->d_strategy = mlxd_strategy; 244 sc->mlxd_disk->d_name = "mlxd"; 245 sc->mlxd_disk->d_unit = sc->mlxd_unit; 246 sc->mlxd_disk->d_drv1 = sc; 247 sc->mlxd_disk->d_sectorsize = MLX_BLKSIZE; 248 sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size; 249 sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors; 250 sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads; |
235 sc->mlxd_disk->d_flags = DISKFLAG_NEEDSGIANT; | |
236 237 /* 238 * Set maximum I/O size to the lesser of the recommended maximum and the practical 239 * maximum except on v2 cards where the maximum is set to 8 pages. 240 */ 241 if (sc->mlxd_controller->mlx_iftype == MLX_IFTYPE_2) 242 sc->mlxd_disk->d_maxsize = 8 * MLX_PAGE_SIZE; 243 else { --- 22 unchanged lines hidden --- | 251 252 /* 253 * Set maximum I/O size to the lesser of the recommended maximum and the practical 254 * maximum except on v2 cards where the maximum is set to 8 pages. 255 */ 256 if (sc->mlxd_controller->mlx_iftype == MLX_IFTYPE_2) 257 sc->mlxd_disk->d_maxsize = 8 * MLX_PAGE_SIZE; 258 else { --- 22 unchanged lines hidden --- |