Lines Matching refs:tw_dev
121 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
122 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
124 static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
127 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_ho…
128 static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
129 static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id);
130 static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits,
140 static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int req…
141 static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds);
142 static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds);
143 static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal);
144 static int twa_reset_device_extension(TW_Device_Extension *tw_dev);
145 static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
146 static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
149 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
159 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; in twa_show_stats() local
163 spin_lock_irqsave(tw_dev->host->host_lock, flags); in twa_show_stats()
176 tw_dev->posted_request_count, in twa_show_stats()
177 tw_dev->max_posted_request_count, in twa_show_stats()
178 tw_dev->pending_request_count, in twa_show_stats()
179 tw_dev->max_pending_request_count, in twa_show_stats()
180 tw_dev->sgl_entries, in twa_show_stats()
181 tw_dev->max_sgl_entries, in twa_show_stats()
182 tw_dev->sector_count, in twa_show_stats()
183 tw_dev->max_sector_count, in twa_show_stats()
184 tw_dev->num_resets, in twa_show_stats()
185 tw_dev->aen_count); in twa_show_stats()
186 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); in twa_show_stats()
228 static int twa_aen_complete(TW_Device_Extension *tw_dev, int request_id) in twa_aen_complete() argument
236 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; in twa_aen_complete()
237 tw_dev->posted_request_count--; in twa_aen_complete()
239 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_aen_complete()
245 if (twa_aen_read_queue(tw_dev, request_id)) in twa_aen_complete()
258 twa_aen_sync_time(tw_dev, request_id); in twa_aen_complete()
262 twa_aen_queue_event(tw_dev, header); in twa_aen_complete()
265 if (twa_aen_read_queue(tw_dev, request_id)) in twa_aen_complete()
274 tw_dev->state[request_id] = TW_S_COMPLETED; in twa_aen_complete()
275 twa_free_request_id(tw_dev, request_id); in twa_aen_complete()
276 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); in twa_aen_complete()
282 static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset) in twa_aen_drain_queue() argument
298 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_aen_drain_queue()
309 sglist[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); in twa_aen_drain_queue()
311 if (tw_dev->generic_buffer_phys[request_id] & TW_ALIGNMENT_9000_SGL) { in twa_aen_drain_queue()
312 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1, "Found unaligned address during AEN drain"); in twa_aen_drain_queue()
317 tw_dev->srb[request_id] = NULL; in twa_aen_drain_queue()
321 if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { in twa_aen_drain_queue()
322 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Error posting request sense"); in twa_aen_drain_queue()
327 if (twa_poll_response(tw_dev, request_id, 30)) { in twa_aen_drain_queue()
328 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "No valid response while draining AEN queue"); in twa_aen_drain_queue()
329 tw_dev->posted_request_count--; in twa_aen_drain_queue()
333 tw_dev->posted_request_count--; in twa_aen_drain_queue()
334 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; in twa_aen_drain_queue()
360 twa_aen_queue_event(tw_dev, header); in twa_aen_drain_queue()
368 tw_dev->state[request_id] = TW_S_INITIAL; in twa_aen_drain_queue()
373 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header) in twa_aen_queue_event() argument
381 tw_dev->aen_count++; in twa_aen_queue_event()
384 event = tw_dev->event_queue[tw_dev->error_index]; in twa_aen_queue_event()
388 if (tw_dev->host) { in twa_aen_queue_event()
389 sprintf(host, " scsi%d:", tw_dev->host->host_no); in twa_aen_queue_event()
391 tw_dev->aen_clobber = 1; in twa_aen_queue_event()
403 event->sequence_id = tw_dev->error_sequence_id; in twa_aen_queue_event()
404 tw_dev->error_sequence_id++; in twa_aen_queue_event()
420 tw_dev->aen_count--; in twa_aen_queue_event()
422 if ((tw_dev->error_index + 1) == TW_Q_LENGTH) in twa_aen_queue_event()
423 tw_dev->event_queue_wrapped = 1; in twa_aen_queue_event()
424 tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH; in twa_aen_queue_event()
428 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) in twa_aen_read_queue() argument
435 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_aen_read_queue()
446 sglist[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); in twa_aen_read_queue()
449 tw_dev->srb[request_id] = NULL; in twa_aen_read_queue()
452 if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { in twa_aen_read_queue()
453 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "Post failed while reading AEN queue"); in twa_aen_read_queue()
476 static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) in twa_aen_sync_time() argument
485 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_aen_sync_time()
490 …command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[requ… in twa_aen_sync_time()
496 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; in twa_aen_sync_time()
510 tw_dev->srb[request_id] = NULL; in twa_aen_sync_time()
513 twa_post_command_packet(tw_dev, request_id, 1); in twa_aen_sync_time()
517 static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) in twa_allocate_memory() argument
524 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, in twa_allocate_memory()
527 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); in twa_allocate_memory()
532 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory"); in twa_allocate_memory()
533 dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH, in twa_allocate_memory()
543 tw_dev->command_packet_phys[i] = dma_handle+(i*size); in twa_allocate_memory()
544 tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size)); in twa_allocate_memory()
547 tw_dev->generic_buffer_phys[i] = dma_handle+(i*size); in twa_allocate_memory()
548 tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); in twa_allocate_memory()
573 static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed) in twa_check_srl() argument
580 if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS, in twa_check_srl()
586 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "Initconnection failed while checking SRL"); in twa_check_srl()
590 tw_dev->tw_compat_info.working_srl = fw_on_ctlr_srl; in twa_check_srl()
591 tw_dev->tw_compat_info.working_branch = fw_on_ctlr_branch; in twa_check_srl()
592 tw_dev->tw_compat_info.working_build = fw_on_ctlr_build; in twa_check_srl()
596 if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS, in twa_check_srl()
603 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Initconnection (base mode) failed while checking SRL"); in twa_check_srl()
608 …TW_PRINTK(tw_dev->host, TW_DRIVER, 0x32, "Firmware and driver incompatibility: please upgrade firm… in twa_check_srl()
610 …TW_PRINTK(tw_dev->host, TW_DRIVER, 0x33, "Firmware and driver incompatibility: please upgrade driv… in twa_check_srl()
614 tw_dev->tw_compat_info.working_srl = TW_BASE_FW_SRL; in twa_check_srl()
615 tw_dev->tw_compat_info.working_branch = TW_BASE_FW_BRANCH; in twa_check_srl()
616 tw_dev->tw_compat_info.working_build = TW_BASE_FW_BUILD; in twa_check_srl()
620 strlcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, in twa_check_srl()
621 sizeof(tw_dev->tw_compat_info.driver_version)); in twa_check_srl()
622 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; in twa_check_srl()
623 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; in twa_check_srl()
624 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD; in twa_check_srl()
625 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL; in twa_check_srl()
626 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH; in twa_check_srl()
627 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD; in twa_check_srl()
628 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl; in twa_check_srl()
629 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch; in twa_check_srl()
630 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build; in twa_check_srl()
654 TW_Device_Extension *tw_dev = twa_device_extension_list[iminor(inode)]; in twa_chrdev_ioctl() local
661 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { in twa_chrdev_ioctl()
680 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, in twa_chrdev_ioctl()
697 spin_lock_irqsave(tw_dev->host->host_lock, flags); in twa_chrdev_ioctl()
698 twa_get_request_id(tw_dev, &request_id); in twa_chrdev_ioctl()
701 tw_dev->srb[request_id] = NULL; in twa_chrdev_ioctl()
704 tw_dev->chrdev_request_id = request_id; in twa_chrdev_ioctl()
709 twa_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted); in twa_chrdev_ioctl()
711 …memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_F… in twa_chrdev_ioctl()
714 twa_post_command_packet(tw_dev, request_id, 1); in twa_chrdev_ioctl()
715 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); in twa_chrdev_ioctl()
720 …timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FR… in twa_chrdev_ioctl()
723 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { in twa_chrdev_ioctl()
726 tw_dev->host->host_no, TW_DRIVER, 0x37, in twa_chrdev_ioctl()
729 twa_reset_device_extension(tw_dev); in twa_chrdev_ioctl()
734 …memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_F… in twa_chrdev_ioctl()
737 spin_lock_irqsave(tw_dev->host->host_lock, flags); in twa_chrdev_ioctl()
738 tw_dev->posted_request_count--; in twa_chrdev_ioctl()
739 tw_dev->state[request_id] = TW_S_COMPLETED; in twa_chrdev_ioctl()
740 twa_free_request_id(tw_dev, request_id); in twa_chrdev_ioctl()
741 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); in twa_chrdev_ioctl()
747 memcpy(tw_compat_info, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info)); in twa_chrdev_ioctl()
750 if (tw_dev->event_queue_wrapped) { in twa_chrdev_ioctl()
751 if (tw_dev->aen_clobber) { in twa_chrdev_ioctl()
753 tw_dev->aen_clobber = 0; in twa_chrdev_ioctl()
757 if (!tw_dev->error_index) { in twa_chrdev_ioctl()
763 event_index = (tw_dev->error_index - 1 + TW_Q_LENGTH) % TW_Q_LENGTH; in twa_chrdev_ioctl()
764 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); in twa_chrdev_ioctl()
765 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; in twa_chrdev_ioctl()
768 if (tw_dev->event_queue_wrapped) { in twa_chrdev_ioctl()
769 if (tw_dev->aen_clobber) { in twa_chrdev_ioctl()
771 tw_dev->aen_clobber = 0; in twa_chrdev_ioctl()
774 event_index = tw_dev->error_index; in twa_chrdev_ioctl()
776 if (!tw_dev->error_index) { in twa_chrdev_ioctl()
783 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); in twa_chrdev_ioctl()
784 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; in twa_chrdev_ioctl()
791 if (tw_dev->event_queue_wrapped) { in twa_chrdev_ioctl()
792 if (tw_dev->aen_clobber) { in twa_chrdev_ioctl()
794 tw_dev->aen_clobber = 0; in twa_chrdev_ioctl()
796 start_index = tw_dev->error_index; in twa_chrdev_ioctl()
798 if (!tw_dev->error_index) { in twa_chrdev_ioctl()
804 …event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id + 1) % TW… in twa_chrdev_ioctl()
806 if (!(tw_dev->event_queue[event_index]->sequence_id > sequence_id)) { in twa_chrdev_ioctl()
808 tw_dev->aen_clobber = 1; in twa_chrdev_ioctl()
812 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); in twa_chrdev_ioctl()
813 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; in twa_chrdev_ioctl()
820 if (tw_dev->event_queue_wrapped) { in twa_chrdev_ioctl()
821 if (tw_dev->aen_clobber) { in twa_chrdev_ioctl()
823 tw_dev->aen_clobber = 0; in twa_chrdev_ioctl()
825 start_index = tw_dev->error_index; in twa_chrdev_ioctl()
827 if (!tw_dev->error_index) { in twa_chrdev_ioctl()
833 …event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id - 1) % TW… in twa_chrdev_ioctl()
835 if (!(tw_dev->event_queue[event_index]->sequence_id < sequence_id)) { in twa_chrdev_ioctl()
837 tw_dev->aen_clobber = 1; in twa_chrdev_ioctl()
841 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); in twa_chrdev_ioctl()
842 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; in twa_chrdev_ioctl()
848 if ((tw_lock->force_flag == 1) || (tw_dev->ioctl_sem_lock == 0) || in twa_chrdev_ioctl()
849 ktime_after(current_time, tw_dev->ioctl_time)) { in twa_chrdev_ioctl()
850 tw_dev->ioctl_sem_lock = 1; in twa_chrdev_ioctl()
851 tw_dev->ioctl_time = ktime_add_ms(current_time, tw_lock->timeout_msec); in twa_chrdev_ioctl()
856 tw_lock->time_remaining_msec = ktime_ms_delta(tw_dev->ioctl_time, current_time); in twa_chrdev_ioctl()
860 if (tw_dev->ioctl_sem_lock == 1) { in twa_chrdev_ioctl()
861 tw_dev->ioctl_sem_lock = 0; in twa_chrdev_ioctl()
877 dma_free_coherent(&tw_dev->tw_pci_dev->dev, in twa_chrdev_ioctl()
881 mutex_unlock(&tw_dev->ioctl_lock); in twa_chrdev_ioctl()
908 static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value) in twa_decode_bits() argument
914 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "PCI Parity Error: clearing"); in twa_decode_bits()
915 writel(TW_CONTROL_CLEAR_PARITY_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); in twa_decode_bits()
919 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "PCI Abort: clearing"); in twa_decode_bits()
920 writel(TW_CONTROL_CLEAR_PCI_ABORT, TW_CONTROL_REG_ADDR(tw_dev)); in twa_decode_bits()
921 pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT); in twa_decode_bits()
925 if (((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) && in twa_decode_bits()
926 (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9690SA)) || in twa_decode_bits()
927 (!test_bit(TW_IN_RESET, &tw_dev->flags))) in twa_decode_bits()
928 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); in twa_decode_bits()
929 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); in twa_decode_bits()
933 if (tw_dev->reset_print == 0) { in twa_decode_bits()
934 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing"); in twa_decode_bits()
935 tw_dev->reset_print = 1; in twa_decode_bits()
945 static int twa_empty_response_queue(TW_Device_Extension *tw_dev) in twa_empty_response_queue() argument
950 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_empty_response_queue()
953 readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); in twa_empty_response_queue()
954 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_empty_response_queue()
966 static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev) in twa_empty_response_queue_large() argument
972 if (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9000) { in twa_empty_response_queue_large()
975 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); in twa_empty_response_queue_large()
990 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_ho… in twa_fill_sense() argument
997 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_fill_sense()
1007 tw_dev->host->host_no, in twa_fill_sense()
1019 …memcpy(tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data, TW_SENSE_DAT… in twa_fill_sense()
1020 tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1); in twa_fill_sense()
1030 static void twa_free_device_extension(TW_Device_Extension *tw_dev) in twa_free_device_extension() argument
1032 if (tw_dev->command_packet_virt[0]) in twa_free_device_extension()
1033 dma_free_coherent(&tw_dev->tw_pci_dev->dev, in twa_free_device_extension()
1035 tw_dev->command_packet_virt[0], in twa_free_device_extension()
1036 tw_dev->command_packet_phys[0]); in twa_free_device_extension()
1038 if (tw_dev->generic_buffer_virt[0]) in twa_free_device_extension()
1039 dma_free_coherent(&tw_dev->tw_pci_dev->dev, in twa_free_device_extension()
1041 tw_dev->generic_buffer_virt[0], in twa_free_device_extension()
1042 tw_dev->generic_buffer_phys[0]); in twa_free_device_extension()
1044 kfree(tw_dev->event_queue[0]); in twa_free_device_extension()
1048 static void twa_free_request_id(TW_Device_Extension *tw_dev, int request_id) in twa_free_request_id() argument
1050 tw_dev->free_queue[tw_dev->free_tail] = request_id; in twa_free_request_id()
1051 tw_dev->state[request_id] = TW_S_FINISHED; in twa_free_request_id()
1052 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH; in twa_free_request_id()
1056 static void *twa_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter… in twa_get_param() argument
1064 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_get_param()
1074 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; in twa_get_param()
1080 …command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[requ… in twa_get_param()
1084 twa_post_command_packet(tw_dev, request_id, 1); in twa_get_param()
1087 if (twa_poll_response(tw_dev, request_id, 30)) in twa_get_param()
1088 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "No valid response during get param") in twa_get_param()
1092 tw_dev->posted_request_count--; in twa_get_param()
1093 tw_dev->state[request_id] = TW_S_INITIAL; in twa_get_param()
1099 static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id) in twa_get_request_id() argument
1101 *request_id = tw_dev->free_queue[tw_dev->free_head]; in twa_get_request_id()
1102 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH; in twa_get_request_id()
1103 tw_dev->state[*request_id] = TW_S_STARTED; in twa_get_request_id()
1107 static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits, in twa_initconnection() argument
1123 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_initconnection()
1147 twa_post_command_packet(tw_dev, request_id, 1); in twa_initconnection()
1150 if (twa_poll_response(tw_dev, request_id, 30)) { in twa_initconnection()
1151 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "No valid response during init connection"); in twa_initconnection()
1163 tw_dev->posted_request_count--; in twa_initconnection()
1164 tw_dev->state[request_id] = TW_S_INITIAL; in twa_initconnection()
1170 static int twa_initialize_device_extension(TW_Device_Extension *tw_dev) in twa_initialize_device_extension() argument
1175 if (twa_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) { in twa_initialize_device_extension()
1176 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Command packet memory allocation failed"); in twa_initialize_device_extension()
1181 if (twa_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) { in twa_initialize_device_extension()
1182 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x17, "Generic memory allocation failed"); in twa_initialize_device_extension()
1187 tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL); in twa_initialize_device_extension()
1188 if (!tw_dev->event_queue[0]) { in twa_initialize_device_extension()
1189 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x18, "Event info memory allocation failed"); in twa_initialize_device_extension()
1195 …tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Eve… in twa_initialize_device_extension()
1196 tw_dev->free_queue[i] = i; in twa_initialize_device_extension()
1197 tw_dev->state[i] = TW_S_INITIAL; in twa_initialize_device_extension()
1200 tw_dev->pending_head = TW_Q_START; in twa_initialize_device_extension()
1201 tw_dev->pending_tail = TW_Q_START; in twa_initialize_device_extension()
1202 tw_dev->free_head = TW_Q_START; in twa_initialize_device_extension()
1203 tw_dev->free_tail = TW_Q_START; in twa_initialize_device_extension()
1204 tw_dev->error_sequence_id = 1; in twa_initialize_device_extension()
1205 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; in twa_initialize_device_extension()
1207 mutex_init(&tw_dev->ioctl_lock); in twa_initialize_device_extension()
1208 init_waitqueue_head(&tw_dev->ioctl_wqueue); in twa_initialize_device_extension()
1222 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance; in twa_interrupt() local
1226 spin_lock(tw_dev->host->host_lock); in twa_interrupt()
1229 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_interrupt()
1238 if (test_bit(TW_IN_RESET, &tw_dev->flags)) in twa_interrupt()
1243 if (twa_decode_bits(tw_dev, status_reg_value)) { in twa_interrupt()
1244 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in twa_interrupt()
1251 TW_CLEAR_HOST_INTERRUPT(tw_dev); in twa_interrupt()
1255 TW_CLEAR_ATTENTION_INTERRUPT(tw_dev); in twa_interrupt()
1256 if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) { in twa_interrupt()
1257 twa_get_request_id(tw_dev, &request_id); in twa_interrupt()
1259 error = twa_aen_read_queue(tw_dev, request_id); in twa_interrupt()
1261 tw_dev->state[request_id] = TW_S_COMPLETED; in twa_interrupt()
1262 twa_free_request_id(tw_dev, request_id); in twa_interrupt()
1263 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); in twa_interrupt()
1270 TW_MASK_COMMAND_INTERRUPT(tw_dev); in twa_interrupt()
1272 while (tw_dev->pending_request_count > 0) { in twa_interrupt()
1273 request_id = tw_dev->pending_queue[tw_dev->pending_head]; in twa_interrupt()
1274 if (tw_dev->state[request_id] != TW_S_PENDING) { in twa_interrupt()
1275 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x19, "Found request id that wasn't pending"); in twa_interrupt()
1276 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in twa_interrupt()
1279 if (twa_post_command_packet(tw_dev, request_id, 1)==0) { in twa_interrupt()
1280 tw_dev->pending_head = (tw_dev->pending_head + 1) % TW_Q_LENGTH; in twa_interrupt()
1281 tw_dev->pending_request_count--; in twa_interrupt()
1295 response_que.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); in twa_interrupt()
1297 full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_interrupt()
1301 if (tw_dev->srb[request_id] != NULL) { in twa_interrupt()
1302 error = twa_fill_sense(tw_dev, request_id, 1, 1); in twa_interrupt()
1305 if (request_id != tw_dev->chrdev_request_id) { in twa_interrupt()
1306 error = twa_fill_sense(tw_dev, request_id, 0, 1); in twa_interrupt()
1312 if (tw_dev->state[request_id] != TW_S_POSTED) { in twa_interrupt()
1313 if (tw_dev->srb[request_id] != NULL) { in twa_interrupt()
1314 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted"); in twa_interrupt()
1315 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in twa_interrupt()
1321 if (tw_dev->srb[request_id] == NULL) { in twa_interrupt()
1322 if (request_id != tw_dev->chrdev_request_id) { in twa_interrupt()
1323 if (twa_aen_complete(tw_dev, request_id)) in twa_interrupt()
1324 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt"); in twa_interrupt()
1326 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; in twa_interrupt()
1327 wake_up(&tw_dev->ioctl_wqueue); in twa_interrupt()
1332 cmd = tw_dev->srb[request_id]; in twa_interrupt()
1334 twa_scsiop_execute_scsi_complete(tw_dev, request_id); in twa_interrupt()
1358 tw_dev->state[request_id] = TW_S_COMPLETED; in twa_interrupt()
1359 twa_free_request_id(tw_dev, request_id); in twa_interrupt()
1360 tw_dev->posted_request_count--; in twa_interrupt()
1364 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_interrupt()
1366 if (twa_decode_bits(tw_dev, status_reg_value)) { in twa_interrupt()
1367 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in twa_interrupt()
1375 spin_unlock(tw_dev->host->host_lock); in twa_interrupt()
1380 static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int req… in twa_load_sgl() argument
1406 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA) in twa_load_sgl()
1419 static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds) in twa_poll_response() argument
1423 TW_Command_Full *full_command_packet = tw_dev->command_packet_virt[request_id]; in twa_poll_response()
1425 if (twa_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, seconds) == 0) { in twa_poll_response()
1426 response_queue.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); in twa_poll_response()
1429 …TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "Found unexpected request id while polling for response"); in twa_poll_response()
1435 twa_fill_sense(tw_dev, request_id, 0, 0); in twa_poll_response()
1442 twa_fill_sense(tw_dev, request_id, 0, 0); in twa_poll_response()
1456 static int twa_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds) in twa_poll_status() argument
1462 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_poll_status()
1466 twa_decode_bits(tw_dev, status_reg_value); in twa_poll_status()
1469 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_poll_status()
1472 twa_decode_bits(tw_dev, status_reg_value); in twa_poll_status()
1485 static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds) in twa_poll_status_gone() argument
1491 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_poll_status_gone()
1495 twa_decode_bits(tw_dev, status_reg_value); in twa_poll_status_gone()
1498 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_poll_status_gone()
1500 twa_decode_bits(tw_dev, status_reg_value); in twa_poll_status_gone()
1513 static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal) in twa_post_command_packet() argument
1519 command_que_value = tw_dev->command_packet_phys[request_id]; in twa_post_command_packet()
1522 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) || in twa_post_command_packet()
1523 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) { in twa_post_command_packet()
1525 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev)); in twa_post_command_packet()
1528 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); in twa_post_command_packet()
1531 twa_decode_bits(tw_dev, status_reg_value); in twa_post_command_packet()
1533 …if (((tw_dev->pending_request_count > 0) && (tw_dev->state[request_id] != TW_S_PENDING)) || (statu… in twa_post_command_packet()
1542 if (tw_dev->state[request_id] != TW_S_PENDING) { in twa_post_command_packet()
1543 tw_dev->state[request_id] = TW_S_PENDING; in twa_post_command_packet()
1544 tw_dev->pending_request_count++; in twa_post_command_packet()
1545 if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) { in twa_post_command_packet()
1546 tw_dev->max_pending_request_count = tw_dev->pending_request_count; in twa_post_command_packet()
1548 tw_dev->pending_queue[tw_dev->pending_tail] = request_id; in twa_post_command_packet()
1549 tw_dev->pending_tail = (tw_dev->pending_tail + 1) % TW_Q_LENGTH; in twa_post_command_packet()
1551 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); in twa_post_command_packet()
1554 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) || in twa_post_command_packet()
1555 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) { in twa_post_command_packet()
1557 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4); in twa_post_command_packet()
1561 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); in twa_post_command_packet()
1562 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4); in twa_post_command_packet()
1564 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); in twa_post_command_packet()
1567 tw_dev->state[request_id] = TW_S_POSTED; in twa_post_command_packet()
1568 tw_dev->posted_request_count++; in twa_post_command_packet()
1569 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) { in twa_post_command_packet()
1570 tw_dev->max_posted_request_count = tw_dev->posted_request_count; in twa_post_command_packet()
1579 static int twa_reset_device_extension(TW_Device_Extension *tw_dev) in twa_reset_device_extension() argument
1585 set_bit(TW_IN_RESET, &tw_dev->flags); in twa_reset_device_extension()
1586 TW_DISABLE_INTERRUPTS(tw_dev); in twa_reset_device_extension()
1587 TW_MASK_COMMAND_INTERRUPT(tw_dev); in twa_reset_device_extension()
1588 spin_lock_irqsave(tw_dev->host->host_lock, flags); in twa_reset_device_extension()
1592 if ((tw_dev->state[i] != TW_S_FINISHED) && in twa_reset_device_extension()
1593 (tw_dev->state[i] != TW_S_INITIAL) && in twa_reset_device_extension()
1594 (tw_dev->state[i] != TW_S_COMPLETED)) { in twa_reset_device_extension()
1595 if (tw_dev->srb[i]) { in twa_reset_device_extension()
1596 struct scsi_cmnd *cmd = tw_dev->srb[i]; in twa_reset_device_extension()
1608 tw_dev->free_queue[i] = i; in twa_reset_device_extension()
1609 tw_dev->state[i] = TW_S_INITIAL; in twa_reset_device_extension()
1611 tw_dev->free_head = TW_Q_START; in twa_reset_device_extension()
1612 tw_dev->free_tail = TW_Q_START; in twa_reset_device_extension()
1613 tw_dev->posted_request_count = 0; in twa_reset_device_extension()
1614 tw_dev->pending_request_count = 0; in twa_reset_device_extension()
1615 tw_dev->pending_head = TW_Q_START; in twa_reset_device_extension()
1616 tw_dev->pending_tail = TW_Q_START; in twa_reset_device_extension()
1617 tw_dev->reset_print = 0; in twa_reset_device_extension()
1619 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); in twa_reset_device_extension()
1621 if (twa_reset_sequence(tw_dev, 1)) in twa_reset_device_extension()
1624 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); in twa_reset_device_extension()
1625 clear_bit(TW_IN_RESET, &tw_dev->flags); in twa_reset_device_extension()
1626 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; in twa_reset_device_extension()
1634 static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset) in twa_reset_sequence() argument
1640 TW_SOFT_RESET(tw_dev); in twa_reset_sequence()
1642 if (twa_empty_response_queue_large(tw_dev)) { in twa_reset_sequence()
1643 …TW_PRINTK(tw_dev->host, TW_DRIVER, 0x36, "Response queue (large) empty failed during reset sequenc… in twa_reset_sequence()
1651 …if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTE… in twa_reset_sequence()
1652 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Microcontroller not ready during reset sequence"); in twa_reset_sequence()
1659 if (twa_empty_response_queue(tw_dev)) { in twa_reset_sequence()
1660 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Response queue empty failed during reset sequence"); in twa_reset_sequence()
1669 if (twa_check_srl(tw_dev, &flashed)) { in twa_reset_sequence()
1670 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Compatibility check failed during reset sequence"); in twa_reset_sequence()
1682 if (twa_aen_drain_queue(tw_dev, soft_reset)) { in twa_reset_sequence()
1683 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x22, "AEN drain failed during reset sequence"); in twa_reset_sequence()
1722 TW_Device_Extension *tw_dev = NULL; in twa_scsi_eh_reset() local
1725 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; in twa_scsi_eh_reset()
1727 tw_dev->num_resets++; in twa_scsi_eh_reset()
1734 mutex_lock(&tw_dev->ioctl_lock); in twa_scsi_eh_reset()
1737 if (twa_reset_device_extension(tw_dev)) { in twa_scsi_eh_reset()
1738 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); in twa_scsi_eh_reset()
1744 mutex_unlock(&tw_dev->ioctl_lock); in twa_scsi_eh_reset()
1753 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; in twa_scsi_queue_lck() local
1756 if (test_bit(TW_IN_RESET, &tw_dev->flags)) { in twa_scsi_queue_lck()
1762 if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { in twa_scsi_queue_lck()
1770 twa_get_request_id(tw_dev, &request_id); in twa_scsi_queue_lck()
1773 tw_dev->srb[request_id] = SCpnt; in twa_scsi_queue_lck()
1775 retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL); in twa_scsi_queue_lck()
1780 twa_free_request_id(tw_dev, request_id); in twa_scsi_queue_lck()
1787 tw_dev->state[request_id] = TW_S_COMPLETED; in twa_scsi_queue_lck()
1788 twa_free_request_id(tw_dev, request_id); in twa_scsi_queue_lck()
1798 static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, in DEF_SCSI_QCMD()
1810 if (tw_dev->srb[request_id]) in DEF_SCSI_QCMD()
1811 srb = tw_dev->srb[request_id]; in DEF_SCSI_QCMD()
1814 full_command_packet = tw_dev->command_packet_virt[request_id]; in DEF_SCSI_QCMD()
1849 tw_dev->generic_buffer_virt[request_id], in DEF_SCSI_QCMD()
1851 command_packet->sg_list[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); in DEF_SCSI_QCMD()
1862 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2e, "Found unaligned sgl address during execute scsi"); in DEF_SCSI_QCMD()
1867 …command_packet->sgl_entries__lunh = TW_REQ_LUN_IN((srb->device->lun >> 4), scsi_sg_count(tw_dev->s… in DEF_SCSI_QCMD()
1875 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2f, "Found unaligned sgl address during internal post"); in DEF_SCSI_QCMD()
1891 tw_dev->sector_count = num_sectors; in DEF_SCSI_QCMD()
1892 if (tw_dev->sector_count > tw_dev->max_sector_count) in DEF_SCSI_QCMD()
1893 tw_dev->max_sector_count = tw_dev->sector_count; in DEF_SCSI_QCMD()
1897 tw_dev->sgl_entries = scsi_sg_count(tw_dev->srb[request_id]); in DEF_SCSI_QCMD()
1898 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries) in DEF_SCSI_QCMD()
1899 tw_dev->max_sgl_entries = tw_dev->sgl_entries; in DEF_SCSI_QCMD()
1904 retval = twa_post_command_packet(tw_dev, request_id, 0); in DEF_SCSI_QCMD()
1906 twa_post_command_packet(tw_dev, request_id, 1); in DEF_SCSI_QCMD()
1914 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id) in twa_scsiop_execute_scsi_complete() argument
1916 struct scsi_cmnd *cmd = tw_dev->srb[request_id]; in twa_scsiop_execute_scsi_complete()
1922 void *buf = tw_dev->generic_buffer_virt[request_id]; in twa_scsiop_execute_scsi_complete()
1930 static void __twa_shutdown(TW_Device_Extension *tw_dev) in __twa_shutdown() argument
1933 TW_DISABLE_INTERRUPTS(tw_dev); in __twa_shutdown()
1936 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); in __twa_shutdown()
1938 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no); in __twa_shutdown()
1941 if (twa_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { in __twa_shutdown()
1942 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x31, "Connection shutdown failed"); in __twa_shutdown()
1948 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in __twa_shutdown()
1955 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; in twa_shutdown() local
1957 __twa_shutdown(tw_dev); in twa_shutdown()
2002 TW_Device_Extension *tw_dev; in twa_probe() local
2030 tw_dev = (TW_Device_Extension *)host->hostdata; in twa_probe()
2033 tw_dev->host = host; in twa_probe()
2034 tw_dev->tw_pci_dev = pdev; in twa_probe()
2036 if (twa_initialize_device_extension(tw_dev)) { in twa_probe()
2037 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension"); in twa_probe()
2045 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Failed to get mem region"); in twa_probe()
2058 tw_dev->base_addr = ioremap(mem_addr, mem_len); in twa_probe()
2059 if (!tw_dev->base_addr) { in twa_probe()
2060 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); in twa_probe()
2066 TW_DISABLE_INTERRUPTS(tw_dev); in twa_probe()
2069 if (twa_reset_sequence(tw_dev, 0)) { in twa_probe()
2084 host->max_lun = TW_MAX_LUNS(tw_dev->tw_compat_info.working_srl); in twa_probe()
2090 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed"); in twa_probe()
2100 (char *)twa_get_param(tw_dev, 0, TW_VERSION_TABLE, in twa_probe()
2102 (char *)twa_get_param(tw_dev, 1, TW_VERSION_TABLE, in twa_probe()
2104 le32_to_cpu(*(__le32 *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE, in twa_probe()
2110 set_bit(TW_USING_MSI, &tw_dev->flags); in twa_probe()
2113 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); in twa_probe()
2115 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x30, "Error requesting IRQ"); in twa_probe()
2119 twa_device_extension_list[twa_device_extension_count] = tw_dev; in twa_probe()
2123 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); in twa_probe()
2135 if (test_bit(TW_USING_MSI, &tw_dev->flags)) in twa_probe()
2139 iounmap(tw_dev->base_addr); in twa_probe()
2143 twa_free_device_extension(tw_dev); in twa_probe()
2155 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; in twa_remove() local
2157 scsi_remove_host(tw_dev->host); in twa_remove()
2166 __twa_shutdown(tw_dev); in twa_remove()
2169 if (test_bit(TW_USING_MSI, &tw_dev->flags)) in twa_remove()
2173 iounmap(tw_dev->base_addr); in twa_remove()
2179 twa_free_device_extension(tw_dev); in twa_remove()
2181 scsi_host_put(tw_dev->host); in twa_remove()
2191 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; in twa_suspend() local
2193 printk(KERN_WARNING "3w-9xxx: Suspending host %d.\n", tw_dev->host->host_no); in twa_suspend()
2195 TW_DISABLE_INTERRUPTS(tw_dev); in twa_suspend()
2196 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); in twa_suspend()
2198 if (test_bit(TW_USING_MSI, &tw_dev->flags)) in twa_suspend()
2202 if (twa_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { in twa_suspend()
2203 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x38, "Connection shutdown failed during suspend"); in twa_suspend()
2207 TW_CLEAR_ALL_INTERRUPTS(tw_dev); in twa_suspend()
2218 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; in twa_resume() local
2220 printk(KERN_WARNING "3w-9xxx: Resuming host %d.\n", tw_dev->host->host_no); in twa_resume()
2234 if (twa_reset_sequence(tw_dev, 0)) { in twa_resume()
2240 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); in twa_resume()
2242 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x42, "Error requesting IRQ during resume"); in twa_resume()
2248 if (test_bit(TW_USING_MSI, &tw_dev->flags)) in twa_resume()
2252 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); in twa_resume()