aac.c (109716) | aac.c (110426) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/sys/dev/aac/aac.c 109716 2003-01-23 01:01:44Z scottl $ | 29 * $FreeBSD: head/sys/dev/aac/aac.c 110426 2003-02-05 23:24:25Z scottl $ |
30 */ 31 32/* 33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 34 */ 35 36#include "opt_aac.h" 37 --- 40 unchanged lines hidden (view full) --- 78 79/* Command Processing */ 80static void aac_timeout(struct aac_softc *sc); 81static int aac_start(struct aac_command *cm); 82static void aac_complete(void *context, int pending); 83static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp); 84static void aac_bio_complete(struct aac_command *cm); 85static int aac_wait_command(struct aac_command *cm, int timeout); | 30 */ 31 32/* 33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 34 */ 35 36#include "opt_aac.h" 37 --- 40 unchanged lines hidden (view full) --- 78 79/* Command Processing */ 80static void aac_timeout(struct aac_softc *sc); 81static int aac_start(struct aac_command *cm); 82static void aac_complete(void *context, int pending); 83static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp); 84static void aac_bio_complete(struct aac_command *cm); 85static int aac_wait_command(struct aac_command *cm, int timeout); |
86static void aac_host_command(struct aac_softc *sc); | 86static void aac_command_thread(struct aac_softc *sc); |
87static void aac_host_response(struct aac_softc *sc); 88 89/* Command Buffer Management */ 90static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs, 91 int nseg, int error); 92static int aac_alloc_commands(struct aac_softc *sc); 93static void aac_free_commands(struct aac_softc *sc); 94static void aac_map_command(struct aac_command *cm); --- 212 unchanged lines hidden (view full) --- 307#if __FreeBSD_version > 500005 308 (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit); 309 (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit); 310#endif 311 sc->aac_dev_t->si_drv1 = sc; 312 313 /* Create the AIF thread */ 314#if __FreeBSD_version > 500005 | 87static void aac_host_response(struct aac_softc *sc); 88 89/* Command Buffer Management */ 90static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs, 91 int nseg, int error); 92static int aac_alloc_commands(struct aac_softc *sc); 93static void aac_free_commands(struct aac_softc *sc); 94static void aac_map_command(struct aac_command *cm); --- 212 unchanged lines hidden (view full) --- 307#if __FreeBSD_version > 500005 308 (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit); 309 (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit); 310#endif 311 sc->aac_dev_t->si_drv1 = sc; 312 313 /* Create the AIF thread */ 314#if __FreeBSD_version > 500005 |
315 if (kthread_create((void(*)(void *))aac_host_command, sc, | 315 if (kthread_create((void(*)(void *))aac_command_thread, sc, |
316 &sc->aifthread, 0, 0, "aac%daif", unit)) 317#else | 316 &sc->aifthread, 0, 0, "aac%daif", unit)) 317#else |
318 if (kthread_create((void(*)(void *))aac_host_command, sc, | 318 if (kthread_create((void(*)(void *))aac_command_thread, sc, |
319 &sc->aifthread, "aac%daif", unit)) 320#endif 321 panic("Could not create AIF thread\n"); 322 323 /* Register the shutdown method to only be called post-dump */ 324 if ((EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown, sc->aac_dev, 325 SHUTDOWN_PRI_DEFAULT)) == NULL) 326 device_printf(sc->aac_dev, "shutdown event registration failed\n"); 327 328 /* Register with CAM for the non-DASD devices */ | 319 &sc->aifthread, "aac%daif", unit)) 320#endif 321 panic("Could not create AIF thread\n"); 322 323 /* Register the shutdown method to only be called post-dump */ 324 if ((EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown, sc->aac_dev, 325 SHUTDOWN_PRI_DEFAULT)) == NULL) 326 device_printf(sc->aac_dev, "shutdown event registration failed\n"); 327 328 /* Register with CAM for the non-DASD devices */ |
329 if (!(sc->quirks & AAC_QUIRK_NOCAM)) | 329 if (!(sc->quirks & AAC_QUIRK_NOCAM)) { 330 TAILQ_INIT(&sc->aac_sim_tqh); |
330 aac_get_bus_info(sc); | 331 aac_get_bus_info(sc); |
332 } |
|
331 332 return(0); 333} 334 335/* 336 * Probe for containers, create disks. 337 */ 338static void --- 39 unchanged lines hidden (view full) --- 378 if (bus_generic_attach(sc->aac_dev)) 379 device_printf(sc->aac_dev, "bus_generic_attach failed\n"); 380 381 /* mark the controller up */ 382 sc->aac_state &= ~AAC_STATE_SUSPEND; 383 384 /* enable interrupts now */ 385 AAC_UNMASK_INTERRUPTS(sc); | 333 334 return(0); 335} 336 337/* 338 * Probe for containers, create disks. 339 */ 340static void --- 39 unchanged lines hidden (view full) --- 380 if (bus_generic_attach(sc->aac_dev)) 381 device_printf(sc->aac_dev, "bus_generic_attach failed\n"); 382 383 /* mark the controller up */ 384 sc->aac_state &= ~AAC_STATE_SUSPEND; 385 386 /* enable interrupts now */ 387 AAC_UNMASK_INTERRUPTS(sc); |
386 387 /* enable the timeout watchdog */ 388 timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); | |
389} 390 391/* 392 * Create a device to respresent a new container 393 */ 394static void 395aac_add_container(struct aac_softc *sc, struct aac_mntinforesp *mir, int f) 396{ --- 82 unchanged lines hidden (view full) --- 479 480/* 481 * Disconnect from the controller completely, in preparation for unload. 482 */ 483int 484aac_detach(device_t dev) 485{ 486 struct aac_softc *sc; | 388} 389 390/* 391 * Create a device to respresent a new container 392 */ 393static void 394aac_add_container(struct aac_softc *sc, struct aac_mntinforesp *mir, int f) 395{ --- 82 unchanged lines hidden (view full) --- 478 479/* 480 * Disconnect from the controller completely, in preparation for unload. 481 */ 482int 483aac_detach(device_t dev) 484{ 485 struct aac_softc *sc; |
487#if AAC_BROKEN | 486 struct aac_container *co; 487 struct aac_sim *sim; |
488 int error; | 488 int error; |
489#endif | |
490 491 debug_called(1); 492 493 sc = device_get_softc(dev); 494 495 if (sc->aac_state & AAC_STATE_OPEN) | 489 490 debug_called(1); 491 492 sc = device_get_softc(dev); 493 494 if (sc->aac_state & AAC_STATE_OPEN) |
496 return(EBUSY); | 495 return(EBUSY); |
497 | 496 |
498#if AAC_BROKEN | 497 /* Remove the child containers */ 498 TAILQ_FOREACH(co, &sc->aac_container_tqh, co_link) { 499 error = device_delete_child(dev, co->co_disk); 500 if (error) 501 return (error); 502 } 503 504 /* Remove the CAM SIMs */ 505 TAILQ_FOREACH(sim, &sc->aac_sim_tqh, sim_link) { 506 error = device_delete_child(dev, sim->sim_dev); 507 if (error) 508 return (error); 509 } 510 511 bus_generic_detach(dev); 512 |
499 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { 500 sc->aifflags |= AAC_AIFFLAGS_EXIT; 501 wakeup(sc->aifthread); 502 tsleep(sc->aac_dev, PUSER | PCATCH, "aacdch", 30 * hz); 503 } 504 505 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) 506 panic("Cannot shutdown AIF thread\n"); 507 508 if ((error = aac_shutdown(dev))) 509 return(error); 510 511 aac_free(sc); 512 513 return(0); | 513 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { 514 sc->aifflags |= AAC_AIFFLAGS_EXIT; 515 wakeup(sc->aifthread); 516 tsleep(sc->aac_dev, PUSER | PCATCH, "aacdch", 30 * hz); 517 } 518 519 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) 520 panic("Cannot shutdown AIF thread\n"); 521 522 if ((error = aac_shutdown(dev))) 523 return(error); 524 525 aac_free(sc); 526 527 return(0); |
514#else 515 return (EBUSY); 516#endif | |
517} 518 519/* 520 * Bring the controller down to a dormant state and detach all child devices. 521 * 522 * This function is called before detach or system shutdown. 523 * 524 * Note that we can assume that the bioq on the controller is empty, as we won't --- 26 unchanged lines hidden (view full) --- 551 cc = (struct aac_close_command *)&fib->data[0]; 552 553 bzero(cc, sizeof(struct aac_close_command)); 554 cc->Command = VM_CloseAll; 555 cc->ContainerId = 0xffffffff; 556 if (aac_sync_fib(sc, ContainerCommand, 0, fib, 557 sizeof(struct aac_close_command))) 558 printf("FAILED.\n"); | 528} 529 530/* 531 * Bring the controller down to a dormant state and detach all child devices. 532 * 533 * This function is called before detach or system shutdown. 534 * 535 * Note that we can assume that the bioq on the controller is empty, as we won't --- 26 unchanged lines hidden (view full) --- 562 cc = (struct aac_close_command *)&fib->data[0]; 563 564 bzero(cc, sizeof(struct aac_close_command)); 565 cc->Command = VM_CloseAll; 566 cc->ContainerId = 0xffffffff; 567 if (aac_sync_fib(sc, ContainerCommand, 0, fib, 568 sizeof(struct aac_close_command))) 569 printf("FAILED.\n"); |
570 else 571 printf("done\n"); 572#if 0 |
|
559 else { 560 fib->data[0] = 0; 561 /* 562 * XXX Issuing this command to the controller makes it shut down 563 * but also keeps it from coming back up without a reset of the 564 * PCI bus. This is not desirable if you are just unloading the 565 * driver module with the intent to reload it later. 566 */ 567 if (aac_sync_fib(sc, FsaHostShutdown, AAC_FIBSTATE_SHUTDOWN, 568 fib, 1)) { 569 printf("FAILED.\n"); 570 } else { 571 printf("done.\n"); 572 } 573 } | 573 else { 574 fib->data[0] = 0; 575 /* 576 * XXX Issuing this command to the controller makes it shut down 577 * but also keeps it from coming back up without a reset of the 578 * PCI bus. This is not desirable if you are just unloading the 579 * driver module with the intent to reload it later. 580 */ 581 if (aac_sync_fib(sc, FsaHostShutdown, AAC_FIBSTATE_SHUTDOWN, 582 fib, 1)) { 583 printf("FAILED.\n"); 584 } else { 585 printf("done.\n"); 586 } 587 } |
588#endif |
|
574 575 AAC_MASK_INTERRUPTS(sc); 576 577 splx(s); 578 return(0); 579} 580 581/* --- 37 unchanged lines hidden (view full) --- 619 620/* 621 * Take an interrupt. 622 */ 623void 624aac_intr(void *arg) 625{ 626 struct aac_softc *sc; | 589 590 AAC_MASK_INTERRUPTS(sc); 591 592 splx(s); 593 return(0); 594} 595 596/* --- 37 unchanged lines hidden (view full) --- 634 635/* 636 * Take an interrupt. 637 */ 638void 639aac_intr(void *arg) 640{ 641 struct aac_softc *sc; |
627 u_int16_t reason; | |
628 u_int32_t *resp_queue; | 642 u_int32_t *resp_queue; |
643 u_int16_t reason; |
|
629 630 debug_called(2); 631 632 sc = (struct aac_softc *)arg; 633 634 /* 635 * Optimize the common case of adapter response interrupts. 636 * We must read from the card prior to processing the responses --- 8 unchanged lines hidden (view full) --- 645 AAC_CLEAR_ISTATUS(sc, reason); 646 (void)AAC_GET_ISTATUS(sc); 647 648 /* It's not ok to return here because of races with the previous step */ 649 if (reason & AAC_DB_RESPONSE_READY) 650 aac_host_response(sc); 651 652 /* controller wants to talk to the log */ | 644 645 debug_called(2); 646 647 sc = (struct aac_softc *)arg; 648 649 /* 650 * Optimize the common case of adapter response interrupts. 651 * We must read from the card prior to processing the responses --- 8 unchanged lines hidden (view full) --- 660 AAC_CLEAR_ISTATUS(sc, reason); 661 (void)AAC_GET_ISTATUS(sc); 662 663 /* It's not ok to return here because of races with the previous step */ 664 if (reason & AAC_DB_RESPONSE_READY) 665 aac_host_response(sc); 666 667 /* controller wants to talk to the log */ |
653 if (reason & AAC_DB_PRINTF) 654 aac_print_printf(sc); | 668 if (reason & AAC_DB_PRINTF) { 669 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { 670 sc->aifflags |= AAC_AIFFLAGS_PRINTF; 671 } else 672 aac_print_printf(sc); 673 } |
655 656 /* controller has a message for us? */ 657 if (reason & AAC_DB_COMMAND_READY) { | 674 675 /* controller has a message for us? */ 676 if (reason & AAC_DB_COMMAND_READY) { |
658 /* XXX What happens if the thread is already awake? */ | |
659 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { | 677 if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { |
660 sc->aifflags |= AAC_AIFFLAGS_PENDING; 661 wakeup(sc->aifthread); | 678 sc->aifflags |= AAC_AIFFLAGS_AIF; 679 } else { 680 /* 681 * XXX If the kthread is dead and we're at this point, 682 * there are bigger problems than just figuring out 683 * what to do with an AIF. 684 */ |
662 } | 685 } |
686 |
|
663 } | 687 } |
688 689 if ((sc->aifflags & AAC_AIFFLAGS_PENDING) != 0) 690 /* XXX Should this be done with cv_signal? */ 691 wakeup(sc->aifthread); |
|
664} 665 666/* 667 * Command Processing 668 */ 669 670/* 671 * Start as much queued I/O as possible on the controller --- 60 unchanged lines hidden (view full) --- 732 error = aac_enqueue_fib(sc, cm->cm_queue, cm); 733 return(error); 734} 735 736/* 737 * Handle notification of one or more FIBs coming from the controller. 738 */ 739static void | 692} 693 694/* 695 * Command Processing 696 */ 697 698/* 699 * Start as much queued I/O as possible on the controller --- 60 unchanged lines hidden (view full) --- 760 error = aac_enqueue_fib(sc, cm->cm_queue, cm); 761 return(error); 762} 763 764/* 765 * Handle notification of one or more FIBs coming from the controller. 766 */ 767static void |
740aac_host_command(struct aac_softc *sc) | 768aac_command_thread(struct aac_softc *sc) |
741{ 742 struct aac_fib *fib; 743 u_int32_t fib_size; 744 int size; 745 746 debug_called(2); 747 748 sc->aifflags |= AAC_AIFFLAGS_RUNNING; 749 750 while (!(sc->aifflags & AAC_AIFFLAGS_EXIT)) { | 769{ 770 struct aac_fib *fib; 771 u_int32_t fib_size; 772 int size; 773 774 debug_called(2); 775 776 sc->aifflags |= AAC_AIFFLAGS_RUNNING; 777 778 while (!(sc->aifflags & AAC_AIFFLAGS_EXIT)) { |
751 if (!(sc->aifflags & AAC_AIFFLAGS_PENDING)) 752 tsleep(sc->aifthread, PRIBIO, "aifthd", 15 * hz); | 779 if ((sc->aifflags & AAC_AIFFLAGS_PENDING) == 0) 780 tsleep(sc->aifthread, PRIBIO, "aifthd", 781 AAC_PERIODIC_INTERVAL * hz); |
753 | 782 |
754 sc->aifflags &= ~AAC_AIFFLAGS_PENDING; 755 for (;;) { | 783 /* While we're here, check to see if any commands are stuck */ 784 if ((sc->aifflags & AAC_AIFFLAGS_PENDING) == 0) 785 aac_timeout(sc); 786 787 /* Check the hardware printf message buffer */ 788 if ((sc->aifflags & AAC_AIFFLAGS_PRINTF) != 0) { 789 sc->aifflags &= ~AAC_AIFFLAGS_PRINTF; 790 aac_print_printf(sc); 791 } 792 793 while (sc->aifflags & AAC_AIFFLAGS_AIF) { 794 |
756 if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE, | 795 if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE, |
757 &fib_size, &fib)) | 796 &fib_size, &fib)) { 797 sc->aifflags &= ~AAC_AIFFLAGS_AIF; |
758 break; /* nothing to do */ | 798 break; /* nothing to do */ |
799 } |
|
759 760 AAC_PRINT_FIB(sc, fib); 761 762 switch (fib->Header.Command) { 763 case AifRequest: 764 aac_handle_aif(sc, fib); 765 break; 766 default: 767 device_printf(sc->aac_dev, "unknown command " 768 "from controller\n"); 769 break; 770 } 771 | 800 801 AAC_PRINT_FIB(sc, fib); 802 803 switch (fib->Header.Command) { 804 case AifRequest: 805 aac_handle_aif(sc, fib); 806 break; 807 default: 808 device_printf(sc->aac_dev, "unknown command " 809 "from controller\n"); 810 break; 811 } 812 |
772 /* Return the AIF to the controller. */ | |
773 if ((fib->Header.XferState == 0) || 774 (fib->Header.StructType != AAC_FIBTYPE_TFIB)) 775 break; 776 | 813 if ((fib->Header.XferState == 0) || 814 (fib->Header.StructType != AAC_FIBTYPE_TFIB)) 815 break; 816 |
817 /* Return the AIF to the controller. */ |
|
777 if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) { 778 fib->Header.XferState |= AAC_FIBSTATE_DONEHOST; 779 *(AAC_FSAStatus*)fib->data = ST_OK; 780 781 /* XXX Compute the Size field? */ 782 size = fib->Header.Size; 783 if (size > sizeof(struct aac_fib)) { 784 size = sizeof(struct aac_fib); --- 327 unchanged lines hidden (view full) --- 1112 struct aac_command *cm; 1113 int i; 1114 1115 debug_called(1); 1116 1117 /* allocate the FIBs in DMAable memory and load them */ 1118 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&sc->aac_fibs, 1119 BUS_DMA_NOWAIT, &sc->aac_fibmap)) { | 818 if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) { 819 fib->Header.XferState |= AAC_FIBSTATE_DONEHOST; 820 *(AAC_FSAStatus*)fib->data = ST_OK; 821 822 /* XXX Compute the Size field? */ 823 size = fib->Header.Size; 824 if (size > sizeof(struct aac_fib)) { 825 size = sizeof(struct aac_fib); --- 327 unchanged lines hidden (view full) --- 1153 struct aac_command *cm; 1154 int i; 1155 1156 debug_called(1); 1157 1158 /* allocate the FIBs in DMAable memory and load them */ 1159 if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&sc->aac_fibs, 1160 BUS_DMA_NOWAIT, &sc->aac_fibmap)) { |
1120 printf("Not enough contiguous memory available.\n"); | 1161 device_printf(sc->aac_dev, 1162 "Not enough contiguous memory available.\n"); |
1121 return (ENOMEM); 1122 } 1123 1124 /* 1125 * Work around a bug in the 2120 and 2200 that cannot DMA commands 1126 * below address 8192 in physical memory. 1127 * XXX If the padding is not needed, can it be put to use instead 1128 * of ignored? --- 671 unchanged lines hidden (view full) --- 1800 */ 1801static void 1802aac_timeout(struct aac_softc *sc) 1803{ 1804 int s; 1805 struct aac_command *cm; 1806 time_t deadline; 1807 | 1163 return (ENOMEM); 1164 } 1165 1166 /* 1167 * Work around a bug in the 2120 and 2200 that cannot DMA commands 1168 * below address 8192 in physical memory. 1169 * XXX If the padding is not needed, can it be put to use instead 1170 * of ignored? --- 671 unchanged lines hidden (view full) --- 1842 */ 1843static void 1844aac_timeout(struct aac_softc *sc) 1845{ 1846 int s; 1847 struct aac_command *cm; 1848 time_t deadline; 1849 |
1808#if 0 1809 /* simulate an interrupt to handle possibly-missed interrupts */ | |
1810 /* | 1850 /* |
1811 * XXX This was done to work around another bug which has since been 1812 * fixed. It is dangerous anyways because you don't want multiple 1813 * threads in the interrupt handler at the same time! If calling 1814 * is deamed neccesary in the future, proper mutexes must be used. 1815 */ 1816 s = splbio(); 1817 aac_intr(sc); 1818 splx(s); 1819 1820 /* kick the I/O queue to restart it in the case of deadlock */ 1821 aac_startio(sc); 1822#endif 1823 1824 /* 1825 * traverse the busy command list, bitch about late commands once | 1851 * Traverse the busy command list, bitch about late commands once |
1826 * only. 1827 */ 1828 deadline = time_second - AAC_CMD_TIMEOUT; 1829 s = splbio(); 1830 TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) { 1831 if ((cm->cm_timestamp < deadline) 1832 /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) { 1833 cm->cm_flags |= AAC_CMD_TIMEDOUT; 1834 device_printf(sc->aac_dev, 1835 "COMMAND %p TIMEOUT AFTER %d SECONDS\n", 1836 cm, (int)(time_second-cm->cm_timestamp)); 1837 AAC_PRINT_FIB(sc, cm->cm_fib); 1838 } 1839 } 1840 splx(s); 1841 | 1852 * only. 1853 */ 1854 deadline = time_second - AAC_CMD_TIMEOUT; 1855 s = splbio(); 1856 TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) { 1857 if ((cm->cm_timestamp < deadline) 1858 /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) { 1859 cm->cm_flags |= AAC_CMD_TIMEDOUT; 1860 device_printf(sc->aac_dev, 1861 "COMMAND %p TIMEOUT AFTER %d SECONDS\n", 1862 cm, (int)(time_second-cm->cm_timestamp)); 1863 AAC_PRINT_FIB(sc, cm->cm_fib); 1864 } 1865 } 1866 splx(s); 1867 |
1842 /* reset the timer for next time */ 1843 timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); | |
1844 return; 1845} 1846 1847/* 1848 * Interface Function Vectors 1849 */ 1850 1851/* --- 487 unchanged lines hidden (view full) --- 2339 goto out; 2340 cm->cm_fib->Header.Size = size; 2341 cm->cm_timestamp = time_second; 2342 2343 /* 2344 * Pass the FIB to the controller, wait for it to complete. 2345 */ 2346 if ((error = aac_wait_command(cm, 30)) != 0) { /* XXX user timeout? */ | 1868 return; 1869} 1870 1871/* 1872 * Interface Function Vectors 1873 */ 1874 1875/* --- 487 unchanged lines hidden (view full) --- 2363 goto out; 2364 cm->cm_fib->Header.Size = size; 2365 cm->cm_timestamp = time_second; 2366 2367 /* 2368 * Pass the FIB to the controller, wait for it to complete. 2369 */ 2370 if ((error = aac_wait_command(cm, 30)) != 0) { /* XXX user timeout? */ |
2347 printf("aac_wait_command return %d\n", error); | 2371 device_printf(sc->aac_dev, 2372 "aac_wait_command return %d\n", error); |
2348 goto out; 2349 } 2350 2351 /* 2352 * Copy the FIB and data back out to the caller. 2353 */ 2354 size = cm->cm_fib->Header.Size; 2355 if (size > sizeof(struct aac_fib)) { --- 87 unchanged lines hidden (view full) --- 2443 */ 2444 if (found) { 2445 i++; 2446 continue; 2447 } 2448 2449 /* 2450 * This is a new container. Do all the | 2373 goto out; 2374 } 2375 2376 /* 2377 * Copy the FIB and data back out to the caller. 2378 */ 2379 size = cm->cm_fib->Header.Size; 2380 if (size > sizeof(struct aac_fib)) { --- 87 unchanged lines hidden (view full) --- 2468 */ 2469 if (found) { 2470 i++; 2471 continue; 2472 } 2473 2474 /* 2475 * This is a new container. Do all the |
2451 * appropriate things to set it up. */ | 2476 * appropriate things to set it up. 2477 */ |
2452 aac_add_container(sc, mir, 1); 2453 added = 1; 2454 } 2455 i++; 2456 } while ((i < mir->MntRespCount) && 2457 (i < AAC_MAX_CONTAINERS)); 2458 aac_release_sync_fib(sc); 2459 --- 147 unchanged lines hidden (view full) --- 2607 2608 AAC_LOCK_ACQUIRE(&sc->aac_aifq_lock); 2609 if (sc->aac_aifq_tail == sc->aac_aifq_head) { 2610 error = EAGAIN; 2611 } else { 2612 error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, 2613 sizeof(struct aac_aif_command)); 2614 if (error) | 2478 aac_add_container(sc, mir, 1); 2479 added = 1; 2480 } 2481 i++; 2482 } while ((i < mir->MntRespCount) && 2483 (i < AAC_MAX_CONTAINERS)); 2484 aac_release_sync_fib(sc); 2485 --- 147 unchanged lines hidden (view full) --- 2633 2634 AAC_LOCK_ACQUIRE(&sc->aac_aifq_lock); 2635 if (sc->aac_aifq_tail == sc->aac_aifq_head) { 2636 error = EAGAIN; 2637 } else { 2638 error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, 2639 sizeof(struct aac_aif_command)); 2640 if (error) |
2615 printf("aac_return_aif: copyout returned %d\n", error); | 2641 device_printf(sc->aac_dev, 2642 "aac_return_aif: copyout returned %d\n", error); |
2616 if (!error) 2617 sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % 2618 AAC_AIFQ_LENGTH; 2619 } 2620 AAC_LOCK_RELEASE(&sc->aac_aifq_lock); 2621 return(error); 2622} 2623 --- 58 unchanged lines hidden (view full) --- 2682aac_get_bus_info(struct aac_softc *sc) 2683{ 2684 struct aac_fib *fib; 2685 struct aac_ctcfg *c_cmd; 2686 struct aac_ctcfg_resp *c_resp; 2687 struct aac_vmioctl *vmi; 2688 struct aac_vmi_businf_resp *vmi_resp; 2689 struct aac_getbusinf businfo; | 2643 if (!error) 2644 sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % 2645 AAC_AIFQ_LENGTH; 2646 } 2647 AAC_LOCK_RELEASE(&sc->aac_aifq_lock); 2648 return(error); 2649} 2650 --- 58 unchanged lines hidden (view full) --- 2709aac_get_bus_info(struct aac_softc *sc) 2710{ 2711 struct aac_fib *fib; 2712 struct aac_ctcfg *c_cmd; 2713 struct aac_ctcfg_resp *c_resp; 2714 struct aac_vmioctl *vmi; 2715 struct aac_vmi_businf_resp *vmi_resp; 2716 struct aac_getbusinf businfo; |
2690 struct aac_cam_inf *caminf; | 2717 struct aac_sim *caminf; |
2691 device_t child; 2692 int i, found, error; 2693 2694 aac_alloc_sync_fib(sc, &fib, 0); 2695 c_cmd = (struct aac_ctcfg *)&fib->data[0]; 2696 bzero(c_cmd, sizeof(struct aac_ctcfg)); 2697 2698 c_cmd->Command = VM_ContainerConfig; --- 48 unchanged lines hidden (view full) --- 2747 bcopy(&vmi_resp->BusInf, &businfo, sizeof(struct aac_getbusinf)); 2748 aac_release_sync_fib(sc); 2749 2750 found = 0; 2751 for (i = 0; i < businfo.BusCount; i++) { 2752 if (businfo.BusValid[i] != AAC_BUS_VALID) 2753 continue; 2754 | 2718 device_t child; 2719 int i, found, error; 2720 2721 aac_alloc_sync_fib(sc, &fib, 0); 2722 c_cmd = (struct aac_ctcfg *)&fib->data[0]; 2723 bzero(c_cmd, sizeof(struct aac_ctcfg)); 2724 2725 c_cmd->Command = VM_ContainerConfig; --- 48 unchanged lines hidden (view full) --- 2774 bcopy(&vmi_resp->BusInf, &businfo, sizeof(struct aac_getbusinf)); 2775 aac_release_sync_fib(sc); 2776 2777 found = 0; 2778 for (i = 0; i < businfo.BusCount; i++) { 2779 if (businfo.BusValid[i] != AAC_BUS_VALID) 2780 continue; 2781 |
2755 MALLOC(caminf, struct aac_cam_inf *, 2756 sizeof(struct aac_cam_inf), M_AACBUF, M_NOWAIT | M_ZERO); | 2782 MALLOC(caminf, struct aac_sim *, 2783 sizeof(struct aac_sim), M_AACBUF, M_NOWAIT | M_ZERO); |
2757 if (caminf == NULL) 2758 continue; 2759 2760 child = device_add_child(sc->aac_dev, "aacp", -1); 2761 if (child == NULL) { 2762 device_printf(sc->aac_dev, "device_add_child failed\n"); 2763 continue; 2764 } 2765 2766 caminf->TargetsPerBus = businfo.TargetsPerBus; 2767 caminf->BusNumber = i; 2768 caminf->InitiatorBusId = businfo.InitiatorBusId[i]; 2769 caminf->aac_sc = sc; 2770 2771 device_set_ivars(child, caminf); 2772 device_set_desc(child, "SCSI Passthrough Bus"); | 2784 if (caminf == NULL) 2785 continue; 2786 2787 child = device_add_child(sc->aac_dev, "aacp", -1); 2788 if (child == NULL) { 2789 device_printf(sc->aac_dev, "device_add_child failed\n"); 2790 continue; 2791 } 2792 2793 caminf->TargetsPerBus = businfo.TargetsPerBus; 2794 caminf->BusNumber = i; 2795 caminf->InitiatorBusId = businfo.InitiatorBusId[i]; 2796 caminf->aac_sc = sc; 2797 2798 device_set_ivars(child, caminf); 2799 device_set_desc(child, "SCSI Passthrough Bus"); |
2800 TAILQ_INSERT_TAIL(&sc->aac_sim_tqh, caminf, sim_link); |
|
2773 2774 found = 1; 2775 } 2776 2777 if (found) 2778 bus_generic_attach(sc->aac_dev); 2779 2780 return; 2781} | 2801 2802 found = 1; 2803 } 2804 2805 if (found) 2806 bus_generic_attach(sc->aac_dev); 2807 2808 return; 2809} |