aac.c (126674) | aac.c (128258) |
---|---|
1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2001 Scott Long 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 Adaptec, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2001 Scott Long 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 Adaptec, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 126674 2004-03-05 22:42:17Z jhb $"); | 31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 128258 2004-04-14 19:11:29Z scottl $"); |
32 33/* 34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 35 */ 36 37#include "opt_aac.h" 38 39/* #include <stddef.h> */ --- 27 unchanged lines hidden (view full) --- 67static void aac_get_bus_info(struct aac_softc *sc); 68 69/* Command Processing */ 70static void aac_timeout(struct aac_softc *sc); 71static int aac_map_command(struct aac_command *cm); 72static void aac_complete(void *context, int pending); 73static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp); 74static void aac_bio_complete(struct aac_command *cm); | 32 33/* 34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 35 */ 36 37#include "opt_aac.h" 38 39/* #include <stddef.h> */ --- 27 unchanged lines hidden (view full) --- 67static void aac_get_bus_info(struct aac_softc *sc); 68 69/* Command Processing */ 70static void aac_timeout(struct aac_softc *sc); 71static int aac_map_command(struct aac_command *cm); 72static void aac_complete(void *context, int pending); 73static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp); 74static void aac_bio_complete(struct aac_command *cm); |
75static int aac_wait_command(struct aac_command *cm, int timeout); | 75static int aac_wait_command(struct aac_command *cm); |
76static void aac_command_thread(struct aac_softc *sc); 77 78/* Command Buffer Management */ 79static void aac_map_command_sg(void *arg, bus_dma_segment_t *segs, 80 int nseg, int error); 81static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs, 82 int nseg, int error); 83static int aac_alloc_commands(struct aac_softc *sc); --- 946 unchanged lines hidden (view full) --- 1030 } 1031 aac_biodone(bp); 1032} 1033 1034/* 1035 * Submit a command to the controller, return when it completes. 1036 * XXX This is very dangerous! If the card has gone out to lunch, we could 1037 * be stuck here forever. At the same time, signals are not caught | 76static void aac_command_thread(struct aac_softc *sc); 77 78/* Command Buffer Management */ 79static void aac_map_command_sg(void *arg, bus_dma_segment_t *segs, 80 int nseg, int error); 81static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs, 82 int nseg, int error); 83static int aac_alloc_commands(struct aac_softc *sc); --- 946 unchanged lines hidden (view full) --- 1030 } 1031 aac_biodone(bp); 1032} 1033 1034/* 1035 * Submit a command to the controller, return when it completes. 1036 * XXX This is very dangerous! If the card has gone out to lunch, we could 1037 * be stuck here forever. At the same time, signals are not caught |
1038 * because there is a risk that a signal could wakeup the tsleep before 1039 * the card has a chance to complete the command. The passed in timeout 1040 * is ignored for the same reason. Since there is no way to cancel a 1041 * command in progress, we should probably create a 'dead' queue where 1042 * commands go that have been interrupted/timed-out/etc, that keeps them 1043 * out of the free pool. That way, if the card is just slow, it won't 1044 * spam the memory of a command that has been recycled. | 1038 * because there is a risk that a signal could wakeup the sleep before 1039 * the card has a chance to complete the command. Since there is no way 1040 * to cancel a command that is in progress, we can't protect against the 1041 * card completing a command late and spamming the command and data 1042 * memory. So, we are held hostage until the command completes. |
1045 */ 1046static int | 1043 */ 1044static int |
1047aac_wait_command(struct aac_command *cm, int timeout) | 1045aac_wait_command(struct aac_command *cm) |
1048{ 1049 struct aac_softc *sc; | 1046{ 1047 struct aac_softc *sc; |
1050 int error = 0; | 1048 int error; |
1051 1052 debug_called(2); 1053 1054 sc = cm->cm_sc; 1055 1056 /* Put the command on the ready queue and get things going */ 1057 cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; 1058 aac_enqueue_ready(cm); 1059 aac_startio(sc); | 1049 1050 debug_called(2); 1051 1052 sc = cm->cm_sc; 1053 1054 /* Put the command on the ready queue and get things going */ 1055 cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; 1056 aac_enqueue_ready(cm); 1057 aac_startio(sc); |
1060 while (!(cm->cm_flags & AAC_CMD_COMPLETED) && (error != EWOULDBLOCK)) { 1061 error = msleep(cm, &sc->aac_io_lock, PRIBIO, "aacwait", 0); 1062 } | 1058 error = msleep(cm, &sc->aac_io_lock, PRIBIO, "aacwait", 0); |
1063 return(error); 1064} 1065 1066/* 1067 *Command Buffer Management 1068 */ 1069 1070/* --- 1471 unchanged lines hidden (view full) --- 2542 if ((error = copyin(ufib, cm->cm_fib, size)) != 0) 2543 goto out; 2544 cm->cm_fib->Header.Size = size; 2545 cm->cm_timestamp = time_second; 2546 2547 /* 2548 * Pass the FIB to the controller, wait for it to complete. 2549 */ | 1059 return(error); 1060} 1061 1062/* 1063 *Command Buffer Management 1064 */ 1065 1066/* --- 1471 unchanged lines hidden (view full) --- 2538 if ((error = copyin(ufib, cm->cm_fib, size)) != 0) 2539 goto out; 2540 cm->cm_fib->Header.Size = size; 2541 cm->cm_timestamp = time_second; 2542 2543 /* 2544 * Pass the FIB to the controller, wait for it to complete. 2545 */ |
2550 if ((error = aac_wait_command(cm, 30)) != 0) { /* XXX user timeout? */ | 2546 if ((error = aac_wait_command(cm)) != 0) { |
2551 device_printf(sc->aac_dev, 2552 "aac_wait_command return %d\n", error); 2553 goto out; 2554 } 2555 2556 /* 2557 * Copy the FIB and data back out to the caller. 2558 */ --- 433 unchanged lines hidden --- | 2547 device_printf(sc->aac_dev, 2548 "aac_wait_command return %d\n", error); 2549 goto out; 2550 } 2551 2552 /* 2553 * Copy the FIB and data back out to the caller. 2554 */ --- 433 unchanged lines hidden --- |