tws.c (256281) | tws.c (275977) |
---|---|
1/* 2 * Copyright (c) 2010, LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah 5 * Support: freebsdraid@lsi.com 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2010, LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah 5 * Support: freebsdraid@lsi.com 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: stable/10/sys/dev/tws/tws.c 255871 2013-09-25 17:16:21Z scottl $"); | 36__FBSDID("$FreeBSD: stable/10/sys/dev/tws/tws.c 275977 2014-12-21 02:39:10Z smh $"); |
37 38#include <dev/tws/tws.h> 39#include <dev/tws/tws_services.h> 40#include <dev/tws/tws_hdm.h> 41 42#include <cam/cam.h> 43#include <cam/cam_ccb.h> 44 --- 148 unchanged lines hidden (view full) --- 193 sc->subvendor_id = pci_get_subvendor(dev); 194 sc->subdevice_id = pci_get_subdevice(dev); 195 196 /* Intialize mutexes */ 197 mtx_init( &sc->q_lock, "tws_q_lock", NULL, MTX_DEF); 198 mtx_init( &sc->sim_lock, "tws_sim_lock", NULL, MTX_DEF); 199 mtx_init( &sc->gen_lock, "tws_gen_lock", NULL, MTX_DEF); 200 mtx_init( &sc->io_lock, "tws_io_lock", NULL, MTX_DEF | MTX_RECURSE); | 37 38#include <dev/tws/tws.h> 39#include <dev/tws/tws_services.h> 40#include <dev/tws/tws_hdm.h> 41 42#include <cam/cam.h> 43#include <cam/cam_ccb.h> 44 --- 148 unchanged lines hidden (view full) --- 193 sc->subvendor_id = pci_get_subvendor(dev); 194 sc->subdevice_id = pci_get_subdevice(dev); 195 196 /* Intialize mutexes */ 197 mtx_init( &sc->q_lock, "tws_q_lock", NULL, MTX_DEF); 198 mtx_init( &sc->sim_lock, "tws_sim_lock", NULL, MTX_DEF); 199 mtx_init( &sc->gen_lock, "tws_gen_lock", NULL, MTX_DEF); 200 mtx_init( &sc->io_lock, "tws_io_lock", NULL, MTX_DEF | MTX_RECURSE); |
201 callout_init(&sc->stats_timer, CALLOUT_MPSAFE); |
|
201 202 if ( tws_init_trace_q(sc) == FAILURE ) 203 printf("trace init failure\n"); 204 /* send init event */ 205 mtx_lock(&sc->gen_lock); 206 tws_send_event(sc, TWS_INIT_START); 207 mtx_unlock(&sc->gen_lock); 208 --- 181 unchanged lines hidden (view full) --- 390 TWS_TRACE(sc, "bus release mem resource", 0, sc->mfa_res_id); 391 } 392 if ( sc->reg_res ){ 393 if (bus_release_resource(sc->tws_dev, 394 SYS_RES_MEMORY, sc->reg_res_id, sc->reg_res)) 395 TWS_TRACE(sc, "bus release mem resource", 0, sc->reg_res_id); 396 } 397 | 202 203 if ( tws_init_trace_q(sc) == FAILURE ) 204 printf("trace init failure\n"); 205 /* send init event */ 206 mtx_lock(&sc->gen_lock); 207 tws_send_event(sc, TWS_INIT_START); 208 mtx_unlock(&sc->gen_lock); 209 --- 181 unchanged lines hidden (view full) --- 391 TWS_TRACE(sc, "bus release mem resource", 0, sc->mfa_res_id); 392 } 393 if ( sc->reg_res ){ 394 if (bus_release_resource(sc->tws_dev, 395 SYS_RES_MEMORY, sc->reg_res_id, sc->reg_res)) 396 TWS_TRACE(sc, "bus release mem resource", 0, sc->reg_res_id); 397 } 398 |
399 for ( i=0; i< tws_queue_depth; i++) { 400 if (sc->reqs[i].dma_map) 401 bus_dmamap_destroy(sc->data_tag, sc->reqs[i].dma_map); 402 callout_drain(&sc->reqs[i].timeout); 403 } 404 405 callout_drain(&sc->stats_timer); |
|
398 free(sc->reqs, M_TWS); 399 free(sc->sense_bufs, M_TWS); 400 free(sc->scan_ccb, M_TWS); 401 if (sc->ioctl_data_mem) 402 bus_dmamem_free(sc->data_tag, sc->ioctl_data_mem, sc->ioctl_data_map); | 406 free(sc->reqs, M_TWS); 407 free(sc->sense_bufs, M_TWS); 408 free(sc->scan_ccb, M_TWS); 409 if (sc->ioctl_data_mem) 410 bus_dmamem_free(sc->data_tag, sc->ioctl_data_mem, sc->ioctl_data_map); |
411 if (sc->data_tag) 412 bus_dma_tag_destroy(sc->data_tag); |
|
403 free(sc->aen_q.q, M_TWS); 404 free(sc->trace_q.q, M_TWS); 405 mtx_destroy(&sc->q_lock); 406 mtx_destroy(&sc->sim_lock); 407 mtx_destroy(&sc->gen_lock); 408 mtx_destroy(&sc->io_lock); 409 destroy_dev(sc->tws_cdev); 410 sysctl_ctx_free(&sc->tws_clist); --- 280 unchanged lines hidden (view full) --- 691 sc->reqs[i].cmd_pkt_phy = sc->dma_mem_phys + 692 sizeof(struct tws_command_header) + 693 (i * sizeof(struct tws_command_packet)); 694 sc->reqs[i].request_id = i; 695 sc->reqs[i].sc = sc; 696 697 sc->reqs[i].cmd_pkt->hdr.header_desc.size_header = 128; 698 | 413 free(sc->aen_q.q, M_TWS); 414 free(sc->trace_q.q, M_TWS); 415 mtx_destroy(&sc->q_lock); 416 mtx_destroy(&sc->sim_lock); 417 mtx_destroy(&sc->gen_lock); 418 mtx_destroy(&sc->io_lock); 419 destroy_dev(sc->tws_cdev); 420 sysctl_ctx_free(&sc->tws_clist); --- 280 unchanged lines hidden (view full) --- 701 sc->reqs[i].cmd_pkt_phy = sc->dma_mem_phys + 702 sizeof(struct tws_command_header) + 703 (i * sizeof(struct tws_command_packet)); 704 sc->reqs[i].request_id = i; 705 sc->reqs[i].sc = sc; 706 707 sc->reqs[i].cmd_pkt->hdr.header_desc.size_header = 128; 708 |
699 callout_handle_init(&sc->reqs[i].thandle); | 709 callout_init(&sc->reqs[i].timeout, CALLOUT_MPSAFE); |
700 sc->reqs[i].state = TWS_REQ_STATE_FREE; 701 if ( i >= TWS_RESERVED_REQS ) 702 tws_q_insert_tail(sc, &sc->reqs[i], TWS_FREE_Q); 703 } 704 mtx_unlock(&sc->q_lock); 705 return(SUCCESS); 706} 707 --- 133 unchanged lines hidden (view full) --- 841 bzero(&r->cmd_pkt->cmd, sizeof(struct tws_command_apache)); 842 r->data = NULL; 843 r->length = 0; 844 r->type = type; 845 r->flags = TWS_DIR_UNKNOWN; 846 r->error_code = TWS_REQ_RET_INVALID; 847 r->cb = NULL; 848 r->ccb_ptr = NULL; | 710 sc->reqs[i].state = TWS_REQ_STATE_FREE; 711 if ( i >= TWS_RESERVED_REQS ) 712 tws_q_insert_tail(sc, &sc->reqs[i], TWS_FREE_Q); 713 } 714 mtx_unlock(&sc->q_lock); 715 return(SUCCESS); 716} 717 --- 133 unchanged lines hidden (view full) --- 851 bzero(&r->cmd_pkt->cmd, sizeof(struct tws_command_apache)); 852 r->data = NULL; 853 r->length = 0; 854 r->type = type; 855 r->flags = TWS_DIR_UNKNOWN; 856 r->error_code = TWS_REQ_RET_INVALID; 857 r->cb = NULL; 858 r->ccb_ptr = NULL; |
849 r->thandle.callout = NULL; | 859 callout_stop(&r->timeout); |
850 r->next = r->prev = NULL; 851 852 r->state = ((type == TWS_REQ_TYPE_SCSI_IO) ? TWS_REQ_STATE_TRAN : TWS_REQ_STATE_BUSY); 853 } 854 855 mtx_unlock(my_mutex); 856 857 return(r); --- 42 unchanged lines hidden --- | 860 r->next = r->prev = NULL; 861 862 r->state = ((type == TWS_REQ_TYPE_SCSI_IO) ? TWS_REQ_STATE_TRAN : TWS_REQ_STATE_BUSY); 863 } 864 865 mtx_unlock(my_mutex); 866 867 return(r); --- 42 unchanged lines hidden --- |