Searched refs:tw_dev (Results 1 - 4 of 4) sorted by relevance

/linux-4.4.14/drivers/scsi/
H A D3w-9xxx.c124 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
125 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
127 static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
130 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host);
131 static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
132 static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id);
133 static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits,
143 static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length);
144 static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds);
145 static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds);
146 static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal);
147 static int twa_reset_device_extension(TW_Device_Extension *tw_dev);
148 static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
149 static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg);
150 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
160 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twa_show_stats() local
164 spin_lock_irqsave(tw_dev->host->host_lock, flags); twa_show_stats()
177 tw_dev->posted_request_count, twa_show_stats()
178 tw_dev->max_posted_request_count, twa_show_stats()
179 tw_dev->pending_request_count, twa_show_stats()
180 tw_dev->max_pending_request_count, twa_show_stats()
181 tw_dev->sgl_entries, twa_show_stats()
182 tw_dev->max_sgl_entries, twa_show_stats()
183 tw_dev->sector_count, twa_show_stats()
184 tw_dev->max_sector_count, twa_show_stats()
185 tw_dev->num_resets, twa_show_stats()
186 tw_dev->aen_count); twa_show_stats()
187 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twa_show_stats()
227 static int twa_aen_complete(TW_Device_Extension *tw_dev, int request_id) twa_aen_complete() argument
235 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; twa_aen_complete()
236 tw_dev->posted_request_count--; twa_aen_complete()
238 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_aen_complete()
244 if (twa_aen_read_queue(tw_dev, request_id)) twa_aen_complete()
257 twa_aen_sync_time(tw_dev, request_id); twa_aen_complete()
261 twa_aen_queue_event(tw_dev, header); twa_aen_complete()
264 if (twa_aen_read_queue(tw_dev, request_id)) twa_aen_complete()
273 tw_dev->state[request_id] = TW_S_COMPLETED; twa_aen_complete()
274 twa_free_request_id(tw_dev, request_id); twa_aen_complete()
275 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); twa_aen_complete()
281 static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset) twa_aen_drain_queue() argument
297 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_aen_drain_queue()
308 sglist[0].address = tw_dev->generic_buffer_phys[request_id]; twa_aen_drain_queue()
311 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1, "Found unaligned address during AEN drain"); twa_aen_drain_queue()
316 tw_dev->srb[request_id] = NULL; twa_aen_drain_queue()
320 if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { twa_aen_drain_queue()
321 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Error posting request sense"); twa_aen_drain_queue()
326 if (twa_poll_response(tw_dev, request_id, 30)) { twa_aen_drain_queue()
327 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "No valid response while draining AEN queue"); twa_aen_drain_queue()
328 tw_dev->posted_request_count--; twa_aen_drain_queue()
332 tw_dev->posted_request_count--; twa_aen_drain_queue()
333 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; twa_aen_drain_queue()
359 twa_aen_queue_event(tw_dev, header); twa_aen_drain_queue()
367 tw_dev->state[request_id] = TW_S_INITIAL; twa_aen_drain_queue()
372 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header) twa_aen_queue_event() argument
381 tw_dev->aen_count++; twa_aen_queue_event()
384 event = tw_dev->event_queue[tw_dev->error_index]; twa_aen_queue_event()
388 if (tw_dev->host) { twa_aen_queue_event()
389 sprintf(host, " scsi%d:", tw_dev->host->host_no); twa_aen_queue_event()
391 tw_dev->aen_clobber = 1; twa_aen_queue_event()
403 event->sequence_id = tw_dev->error_sequence_id; twa_aen_queue_event()
404 tw_dev->error_sequence_id++; twa_aen_queue_event()
420 tw_dev->aen_count--; twa_aen_queue_event()
422 if ((tw_dev->error_index + 1) == TW_Q_LENGTH) twa_aen_queue_event()
423 tw_dev->event_queue_wrapped = 1; twa_aen_queue_event()
424 tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH; twa_aen_queue_event()
428 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) twa_aen_read_queue() argument
435 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_aen_read_queue()
446 sglist[0].address = tw_dev->generic_buffer_phys[request_id]; twa_aen_read_queue()
449 tw_dev->srb[request_id] = NULL; twa_aen_read_queue()
452 if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { twa_aen_read_queue()
453 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "Post failed while reading AEN queue"); twa_aen_read_queue()
476 static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) twa_aen_sync_time() argument
486 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_aen_sync_time()
491 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); twa_aen_sync_time()
497 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; twa_aen_sync_time()
513 tw_dev->srb[request_id] = NULL; twa_aen_sync_time()
516 twa_post_command_packet(tw_dev, request_id, 1); twa_aen_sync_time()
520 static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) twa_allocate_memory() argument
527 cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); twa_allocate_memory()
529 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); twa_allocate_memory()
534 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory"); twa_allocate_memory()
535 pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle); twa_allocate_memory()
544 tw_dev->command_packet_phys[i] = dma_handle+(i*size); twa_allocate_memory()
545 tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size)); twa_allocate_memory()
548 tw_dev->generic_buffer_phys[i] = dma_handle+(i*size); twa_allocate_memory()
549 tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); twa_allocate_memory()
574 static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed) twa_check_srl() argument
581 if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS, twa_check_srl()
587 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "Initconnection failed while checking SRL"); twa_check_srl()
591 tw_dev->tw_compat_info.working_srl = fw_on_ctlr_srl; twa_check_srl()
592 tw_dev->tw_compat_info.working_branch = fw_on_ctlr_branch; twa_check_srl()
593 tw_dev->tw_compat_info.working_build = fw_on_ctlr_build; twa_check_srl()
597 if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS, twa_check_srl()
604 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Initconnection (base mode) failed while checking SRL"); twa_check_srl()
609 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x32, "Firmware and driver incompatibility: please upgrade firmware"); twa_check_srl()
611 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x33, "Firmware and driver incompatibility: please upgrade driver"); twa_check_srl()
615 tw_dev->tw_compat_info.working_srl = TW_BASE_FW_SRL; twa_check_srl()
616 tw_dev->tw_compat_info.working_branch = TW_BASE_FW_BRANCH; twa_check_srl()
617 tw_dev->tw_compat_info.working_build = TW_BASE_FW_BUILD; twa_check_srl()
621 strlcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, twa_check_srl()
622 sizeof(tw_dev->tw_compat_info.driver_version)); twa_check_srl()
623 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; twa_check_srl()
624 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; twa_check_srl()
625 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD; twa_check_srl()
626 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL; twa_check_srl()
627 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH; twa_check_srl()
628 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD; twa_check_srl()
629 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl; twa_check_srl()
630 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch; twa_check_srl()
631 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build; twa_check_srl()
656 TW_Device_Extension *tw_dev = twa_device_extension_list[iminor(inode)]; twa_chrdev_ioctl() local
663 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { twa_chrdev_ioctl()
682 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, &dma_handle, GFP_KERNEL); twa_chrdev_ioctl()
697 spin_lock_irqsave(tw_dev->host->host_lock, flags); twa_chrdev_ioctl()
698 twa_get_request_id(tw_dev, &request_id); twa_chrdev_ioctl()
701 tw_dev->srb[request_id] = NULL; twa_chrdev_ioctl()
704 tw_dev->chrdev_request_id = request_id; twa_chrdev_ioctl()
709 twa_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted); twa_chrdev_ioctl()
711 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full)); twa_chrdev_ioctl()
714 twa_post_command_packet(tw_dev, request_id, 1); twa_chrdev_ioctl()
715 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twa_chrdev_ioctl()
720 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); twa_chrdev_ioctl()
723 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { twa_chrdev_ioctl()
726 tw_dev->host->host_no, TW_DRIVER, 0x37, twa_chrdev_ioctl()
729 twa_reset_device_extension(tw_dev); twa_chrdev_ioctl()
734 memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_Full)); twa_chrdev_ioctl()
737 spin_lock_irqsave(tw_dev->host->host_lock, flags); twa_chrdev_ioctl()
738 tw_dev->posted_request_count--; twa_chrdev_ioctl()
739 tw_dev->state[request_id] = TW_S_COMPLETED; twa_chrdev_ioctl()
740 twa_free_request_id(tw_dev, request_id); twa_chrdev_ioctl()
741 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twa_chrdev_ioctl()
747 memcpy(tw_compat_info, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info)); twa_chrdev_ioctl()
750 if (tw_dev->event_queue_wrapped) { twa_chrdev_ioctl()
751 if (tw_dev->aen_clobber) { twa_chrdev_ioctl()
753 tw_dev->aen_clobber = 0; twa_chrdev_ioctl()
757 if (!tw_dev->error_index) { twa_chrdev_ioctl()
763 event_index = (tw_dev->error_index - 1 + TW_Q_LENGTH) % TW_Q_LENGTH; twa_chrdev_ioctl()
764 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); twa_chrdev_ioctl()
765 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; twa_chrdev_ioctl()
768 if (tw_dev->event_queue_wrapped) { twa_chrdev_ioctl()
769 if (tw_dev->aen_clobber) { twa_chrdev_ioctl()
771 tw_dev->aen_clobber = 0; twa_chrdev_ioctl()
774 event_index = tw_dev->error_index; twa_chrdev_ioctl()
776 if (!tw_dev->error_index) { twa_chrdev_ioctl()
783 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); twa_chrdev_ioctl()
784 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; twa_chrdev_ioctl()
791 if (tw_dev->event_queue_wrapped) { twa_chrdev_ioctl()
792 if (tw_dev->aen_clobber) { twa_chrdev_ioctl()
794 tw_dev->aen_clobber = 0; twa_chrdev_ioctl()
796 start_index = tw_dev->error_index; twa_chrdev_ioctl()
798 if (!tw_dev->error_index) { twa_chrdev_ioctl()
804 event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id + 1) % TW_Q_LENGTH; twa_chrdev_ioctl()
806 if (!(tw_dev->event_queue[event_index]->sequence_id > sequence_id)) { twa_chrdev_ioctl()
808 tw_dev->aen_clobber = 1; twa_chrdev_ioctl()
812 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); twa_chrdev_ioctl()
813 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; twa_chrdev_ioctl()
820 if (tw_dev->event_queue_wrapped) { twa_chrdev_ioctl()
821 if (tw_dev->aen_clobber) { twa_chrdev_ioctl()
823 tw_dev->aen_clobber = 0; twa_chrdev_ioctl()
825 start_index = tw_dev->error_index; twa_chrdev_ioctl()
827 if (!tw_dev->error_index) { twa_chrdev_ioctl()
833 event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id - 1) % TW_Q_LENGTH; twa_chrdev_ioctl()
835 if (!(tw_dev->event_queue[event_index]->sequence_id < sequence_id)) { twa_chrdev_ioctl()
837 tw_dev->aen_clobber = 1; twa_chrdev_ioctl()
841 memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event)); twa_chrdev_ioctl()
842 tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED; twa_chrdev_ioctl()
849 if ((tw_lock->force_flag == 1) || (tw_dev->ioctl_sem_lock == 0) || (current_time_ms >= tw_dev->ioctl_msec)) { twa_chrdev_ioctl()
850 tw_dev->ioctl_sem_lock = 1; twa_chrdev_ioctl()
851 tw_dev->ioctl_msec = current_time_ms + tw_lock->timeout_msec; twa_chrdev_ioctl()
856 tw_lock->time_remaining_msec = tw_dev->ioctl_msec - current_time_ms; twa_chrdev_ioctl()
860 if (tw_dev->ioctl_sem_lock == 1) { twa_chrdev_ioctl()
861 tw_dev->ioctl_sem_lock = 0; twa_chrdev_ioctl()
877 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle); twa_chrdev_ioctl()
879 mutex_unlock(&tw_dev->ioctl_lock); twa_chrdev_ioctl()
901 static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value) twa_decode_bits() argument
907 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "PCI Parity Error: clearing"); twa_decode_bits()
908 writel(TW_CONTROL_CLEAR_PARITY_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); twa_decode_bits()
912 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "PCI Abort: clearing"); twa_decode_bits()
913 writel(TW_CONTROL_CLEAR_PCI_ABORT, TW_CONTROL_REG_ADDR(tw_dev)); twa_decode_bits()
914 pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT); twa_decode_bits()
918 if (((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) && twa_decode_bits()
919 (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9690SA)) || twa_decode_bits()
920 (!test_bit(TW_IN_RESET, &tw_dev->flags))) twa_decode_bits()
921 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); twa_decode_bits()
922 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); twa_decode_bits()
926 if (tw_dev->reset_print == 0) { twa_decode_bits()
927 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing"); twa_decode_bits()
928 tw_dev->reset_print = 1; twa_decode_bits()
938 static int twa_empty_response_queue(TW_Device_Extension *tw_dev) twa_empty_response_queue() argument
943 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_empty_response_queue()
946 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); twa_empty_response_queue()
947 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_empty_response_queue()
959 static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev) twa_empty_response_queue_large() argument
965 if (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9000) { twa_empty_response_queue_large()
968 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); twa_empty_response_queue_large()
983 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host) twa_fill_sense() argument
990 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_fill_sense()
1000 tw_dev->host->host_no, twa_fill_sense()
1018 memcpy(tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data, TW_SENSE_DATA_LENGTH); twa_fill_sense()
1019 tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1); twa_fill_sense()
1029 static void twa_free_device_extension(TW_Device_Extension *tw_dev) twa_free_device_extension() argument
1031 if (tw_dev->command_packet_virt[0]) twa_free_device_extension()
1032 pci_free_consistent(tw_dev->tw_pci_dev, twa_free_device_extension()
1034 tw_dev->command_packet_virt[0], twa_free_device_extension()
1035 tw_dev->command_packet_phys[0]); twa_free_device_extension()
1037 if (tw_dev->generic_buffer_virt[0]) twa_free_device_extension()
1038 pci_free_consistent(tw_dev->tw_pci_dev, twa_free_device_extension()
1040 tw_dev->generic_buffer_virt[0], twa_free_device_extension()
1041 tw_dev->generic_buffer_phys[0]); twa_free_device_extension()
1043 kfree(tw_dev->event_queue[0]); twa_free_device_extension()
1047 static void twa_free_request_id(TW_Device_Extension *tw_dev, int request_id) twa_free_request_id() argument
1049 tw_dev->free_queue[tw_dev->free_tail] = request_id; twa_free_request_id()
1050 tw_dev->state[request_id] = TW_S_FINISHED; twa_free_request_id()
1051 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH; twa_free_request_id()
1055 static void *twa_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes) twa_get_param() argument
1063 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_get_param()
1073 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; twa_get_param()
1079 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); twa_get_param()
1083 twa_post_command_packet(tw_dev, request_id, 1); twa_get_param()
1086 if (twa_poll_response(tw_dev, request_id, 30)) twa_get_param()
1087 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "No valid response during get param") twa_get_param()
1091 tw_dev->posted_request_count--; twa_get_param()
1092 tw_dev->state[request_id] = TW_S_INITIAL; twa_get_param()
1098 static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id) twa_get_request_id() argument
1100 *request_id = tw_dev->free_queue[tw_dev->free_head]; twa_get_request_id()
1101 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH; twa_get_request_id()
1102 tw_dev->state[*request_id] = TW_S_STARTED; twa_get_request_id()
1106 static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits, twa_initconnection() argument
1122 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_initconnection()
1147 twa_post_command_packet(tw_dev, request_id, 1); twa_initconnection()
1150 if (twa_poll_response(tw_dev, request_id, 30)) { twa_initconnection()
1151 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "No valid response during init connection"); twa_initconnection()
1163 tw_dev->posted_request_count--; twa_initconnection()
1164 tw_dev->state[request_id] = TW_S_INITIAL; twa_initconnection()
1170 static int twa_initialize_device_extension(TW_Device_Extension *tw_dev) twa_initialize_device_extension() argument
1175 if (twa_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) { twa_initialize_device_extension()
1176 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Command packet memory allocation failed"); twa_initialize_device_extension()
1181 if (twa_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) { twa_initialize_device_extension()
1182 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x17, "Generic memory allocation failed"); twa_initialize_device_extension()
1187 tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL); twa_initialize_device_extension()
1188 if (!tw_dev->event_queue[0]) { twa_initialize_device_extension()
1189 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x18, "Event info memory allocation failed"); twa_initialize_device_extension()
1195 tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event))); twa_initialize_device_extension()
1196 tw_dev->free_queue[i] = i; twa_initialize_device_extension()
1197 tw_dev->state[i] = TW_S_INITIAL; twa_initialize_device_extension()
1200 tw_dev->pending_head = TW_Q_START; twa_initialize_device_extension()
1201 tw_dev->pending_tail = TW_Q_START; twa_initialize_device_extension()
1202 tw_dev->free_head = TW_Q_START; twa_initialize_device_extension()
1203 tw_dev->free_tail = TW_Q_START; twa_initialize_device_extension()
1204 tw_dev->error_sequence_id = 1; twa_initialize_device_extension()
1205 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twa_initialize_device_extension()
1207 mutex_init(&tw_dev->ioctl_lock); twa_initialize_device_extension()
1208 init_waitqueue_head(&tw_dev->ioctl_wqueue); twa_initialize_device_extension()
1222 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance; twa_interrupt() local
1226 spin_lock(tw_dev->host->host_lock); twa_interrupt()
1229 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_interrupt()
1238 if (test_bit(TW_IN_RESET, &tw_dev->flags)) twa_interrupt()
1243 if (twa_decode_bits(tw_dev, status_reg_value)) { twa_interrupt()
1244 TW_CLEAR_ALL_INTERRUPTS(tw_dev); twa_interrupt()
1251 TW_CLEAR_HOST_INTERRUPT(tw_dev); twa_interrupt()
1255 TW_CLEAR_ATTENTION_INTERRUPT(tw_dev); twa_interrupt()
1256 if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) { twa_interrupt()
1257 twa_get_request_id(tw_dev, &request_id); twa_interrupt()
1259 error = twa_aen_read_queue(tw_dev, request_id); twa_interrupt()
1261 tw_dev->state[request_id] = TW_S_COMPLETED; twa_interrupt()
1262 twa_free_request_id(tw_dev, request_id); twa_interrupt()
1263 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); twa_interrupt()
1270 TW_MASK_COMMAND_INTERRUPT(tw_dev); twa_interrupt()
1272 while (tw_dev->pending_request_count > 0) { twa_interrupt()
1273 request_id = tw_dev->pending_queue[tw_dev->pending_head]; twa_interrupt()
1274 if (tw_dev->state[request_id] != TW_S_PENDING) { twa_interrupt()
1275 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x19, "Found request id that wasn't pending"); twa_interrupt()
1276 TW_CLEAR_ALL_INTERRUPTS(tw_dev); twa_interrupt()
1279 if (twa_post_command_packet(tw_dev, request_id, 1)==0) { twa_interrupt()
1280 tw_dev->pending_head = (tw_dev->pending_head + 1) % TW_Q_LENGTH; twa_interrupt()
1281 tw_dev->pending_request_count--; twa_interrupt()
1295 response_que.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); twa_interrupt()
1297 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_interrupt()
1301 if (tw_dev->srb[request_id] != NULL) { twa_interrupt()
1302 error = twa_fill_sense(tw_dev, request_id, 1, 1); twa_interrupt()
1305 if (request_id != tw_dev->chrdev_request_id) { twa_interrupt()
1306 error = twa_fill_sense(tw_dev, request_id, 0, 1); twa_interrupt()
1312 if (tw_dev->state[request_id] != TW_S_POSTED) { twa_interrupt()
1313 if (tw_dev->srb[request_id] != NULL) { twa_interrupt()
1314 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted"); twa_interrupt()
1315 TW_CLEAR_ALL_INTERRUPTS(tw_dev); twa_interrupt()
1321 if (tw_dev->srb[request_id] == NULL) { twa_interrupt()
1322 if (request_id != tw_dev->chrdev_request_id) { twa_interrupt()
1323 if (twa_aen_complete(tw_dev, request_id)) twa_interrupt()
1324 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt"); twa_interrupt()
1326 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twa_interrupt()
1327 wake_up(&tw_dev->ioctl_wqueue); twa_interrupt()
1332 cmd = tw_dev->srb[request_id]; twa_interrupt()
1334 twa_scsiop_execute_scsi_complete(tw_dev, request_id); twa_interrupt()
1348 if (full_command_packet->command.newcommand.sg_list[0].length < scsi_bufflen(tw_dev->srb[request_id])) twa_interrupt()
1356 tw_dev->state[request_id] = TW_S_COMPLETED; twa_interrupt()
1357 twa_free_request_id(tw_dev, request_id); twa_interrupt()
1358 tw_dev->posted_request_count--; twa_interrupt()
1362 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_interrupt()
1364 if (twa_decode_bits(tw_dev, status_reg_value)) { twa_interrupt()
1365 TW_CLEAR_ALL_INTERRUPTS(tw_dev); twa_interrupt()
1373 spin_unlock(tw_dev->host->host_lock); twa_interrupt()
1378 static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length) twa_load_sgl() argument
1404 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA) twa_load_sgl()
1417 static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds) twa_poll_response() argument
1421 TW_Command_Full *full_command_packet = tw_dev->command_packet_virt[request_id]; twa_poll_response()
1423 if (twa_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, seconds) == 0) { twa_poll_response()
1424 response_queue.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); twa_poll_response()
1427 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "Found unexpected request id while polling for response"); twa_poll_response()
1433 twa_fill_sense(tw_dev, request_id, 0, 0); twa_poll_response()
1440 twa_fill_sense(tw_dev, request_id, 0, 0); twa_poll_response()
1454 static int twa_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds) twa_poll_status() argument
1460 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_poll_status()
1464 twa_decode_bits(tw_dev, status_reg_value); twa_poll_status()
1467 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_poll_status()
1470 twa_decode_bits(tw_dev, status_reg_value); twa_poll_status()
1483 static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds) twa_poll_status_gone() argument
1489 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_poll_status_gone()
1493 twa_decode_bits(tw_dev, status_reg_value); twa_poll_status_gone()
1496 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_poll_status_gone()
1498 twa_decode_bits(tw_dev, status_reg_value); twa_poll_status_gone()
1511 static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal) twa_post_command_packet() argument
1517 command_que_value = tw_dev->command_packet_phys[request_id]; twa_post_command_packet()
1520 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) || twa_post_command_packet()
1521 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) { twa_post_command_packet()
1523 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev)); twa_post_command_packet()
1526 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); twa_post_command_packet()
1529 twa_decode_bits(tw_dev, status_reg_value); twa_post_command_packet()
1531 if (((tw_dev->pending_request_count > 0) && (tw_dev->state[request_id] != TW_S_PENDING)) || (status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL)) { twa_post_command_packet()
1540 if (tw_dev->state[request_id] != TW_S_PENDING) { twa_post_command_packet()
1541 tw_dev->state[request_id] = TW_S_PENDING; twa_post_command_packet()
1542 tw_dev->pending_request_count++; twa_post_command_packet()
1543 if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) { twa_post_command_packet()
1544 tw_dev->max_pending_request_count = tw_dev->pending_request_count; twa_post_command_packet()
1546 tw_dev->pending_queue[tw_dev->pending_tail] = request_id; twa_post_command_packet()
1547 tw_dev->pending_tail = (tw_dev->pending_tail + 1) % TW_Q_LENGTH; twa_post_command_packet()
1549 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); twa_post_command_packet()
1552 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) || twa_post_command_packet()
1553 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) { twa_post_command_packet()
1555 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4); twa_post_command_packet()
1559 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); twa_post_command_packet()
1560 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4); twa_post_command_packet()
1562 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); twa_post_command_packet()
1565 tw_dev->state[request_id] = TW_S_POSTED; twa_post_command_packet()
1566 tw_dev->posted_request_count++; twa_post_command_packet()
1567 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) { twa_post_command_packet()
1568 tw_dev->max_posted_request_count = tw_dev->posted_request_count; twa_post_command_packet()
1577 static int twa_reset_device_extension(TW_Device_Extension *tw_dev) twa_reset_device_extension() argument
1583 set_bit(TW_IN_RESET, &tw_dev->flags); twa_reset_device_extension()
1584 TW_DISABLE_INTERRUPTS(tw_dev); twa_reset_device_extension()
1585 TW_MASK_COMMAND_INTERRUPT(tw_dev); twa_reset_device_extension()
1586 spin_lock_irqsave(tw_dev->host->host_lock, flags); twa_reset_device_extension()
1590 if ((tw_dev->state[i] != TW_S_FINISHED) && twa_reset_device_extension()
1591 (tw_dev->state[i] != TW_S_INITIAL) && twa_reset_device_extension()
1592 (tw_dev->state[i] != TW_S_COMPLETED)) { twa_reset_device_extension()
1593 if (tw_dev->srb[i]) { twa_reset_device_extension()
1594 struct scsi_cmnd *cmd = tw_dev->srb[i]; twa_reset_device_extension()
1606 tw_dev->free_queue[i] = i; twa_reset_device_extension()
1607 tw_dev->state[i] = TW_S_INITIAL; twa_reset_device_extension()
1609 tw_dev->free_head = TW_Q_START; twa_reset_device_extension()
1610 tw_dev->free_tail = TW_Q_START; twa_reset_device_extension()
1611 tw_dev->posted_request_count = 0; twa_reset_device_extension()
1612 tw_dev->pending_request_count = 0; twa_reset_device_extension()
1613 tw_dev->pending_head = TW_Q_START; twa_reset_device_extension()
1614 tw_dev->pending_tail = TW_Q_START; twa_reset_device_extension()
1615 tw_dev->reset_print = 0; twa_reset_device_extension()
1617 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twa_reset_device_extension()
1619 if (twa_reset_sequence(tw_dev, 1)) twa_reset_device_extension()
1622 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); twa_reset_device_extension()
1623 clear_bit(TW_IN_RESET, &tw_dev->flags); twa_reset_device_extension()
1624 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twa_reset_device_extension()
1632 static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset) twa_reset_sequence() argument
1638 TW_SOFT_RESET(tw_dev); twa_reset_sequence()
1640 if (twa_empty_response_queue_large(tw_dev)) { twa_reset_sequence()
1641 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x36, "Response queue (large) empty failed during reset sequence"); twa_reset_sequence()
1649 if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 60)) { twa_reset_sequence()
1650 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Microcontroller not ready during reset sequence"); twa_reset_sequence()
1657 if (twa_empty_response_queue(tw_dev)) { twa_reset_sequence()
1658 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Response queue empty failed during reset sequence"); twa_reset_sequence()
1667 if (twa_check_srl(tw_dev, &flashed)) { twa_reset_sequence()
1668 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Compatibility check failed during reset sequence"); twa_reset_sequence()
1680 if (twa_aen_drain_queue(tw_dev, soft_reset)) { twa_reset_sequence()
1681 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x22, "AEN drain failed during reset sequence"); twa_reset_sequence()
1699 TW_Device_Extension *tw_dev; twa_scsi_biosparam() local
1701 tw_dev = (TW_Device_Extension *)sdev->host->hostdata; twa_scsi_biosparam()
1723 TW_Device_Extension *tw_dev = NULL; twa_scsi_eh_reset() local
1726 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; twa_scsi_eh_reset()
1728 tw_dev->num_resets++; twa_scsi_eh_reset()
1735 mutex_lock(&tw_dev->ioctl_lock); twa_scsi_eh_reset()
1738 if (twa_reset_device_extension(tw_dev)) { twa_scsi_eh_reset()
1739 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); twa_scsi_eh_reset()
1745 mutex_unlock(&tw_dev->ioctl_lock); twa_scsi_eh_reset()
1753 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; twa_scsi_queue_lck() local
1756 if (test_bit(TW_IN_RESET, &tw_dev->flags)) { twa_scsi_queue_lck()
1762 if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { twa_scsi_queue_lck()
1773 twa_get_request_id(tw_dev, &request_id); twa_scsi_queue_lck()
1776 tw_dev->srb[request_id] = SCpnt; twa_scsi_queue_lck()
1778 retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL); twa_scsi_queue_lck()
1783 twa_free_request_id(tw_dev, request_id); twa_scsi_queue_lck()
1790 tw_dev->state[request_id] = TW_S_COMPLETED; twa_scsi_queue_lck()
1791 twa_free_request_id(tw_dev, request_id); twa_scsi_queue_lck()
1801 static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg) twa_scsiop_execute_scsi() argument
1811 if (tw_dev->srb[request_id]) { twa_scsiop_execute_scsi()
1812 srb = tw_dev->srb[request_id]; twa_scsiop_execute_scsi()
1818 full_command_packet = tw_dev->command_packet_virt[request_id]; twa_scsiop_execute_scsi()
1853 tw_dev->generic_buffer_virt[request_id], twa_scsiop_execute_scsi()
1855 command_packet->sg_list[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); twa_scsiop_execute_scsi()
1866 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2e, "Found unaligned sgl address during execute scsi"); scsi_for_each_sg()
1871 command_packet->sgl_entries__lunh = cpu_to_le16(TW_REQ_LUN_IN((srb->device->lun >> 4), scsi_sg_count(tw_dev->srb[request_id])));
1879 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2f, "Found unaligned sgl address during internal post");
1895 tw_dev->sector_count = num_sectors;
1896 if (tw_dev->sector_count > tw_dev->max_sector_count)
1897 tw_dev->max_sector_count = tw_dev->sector_count;
1901 tw_dev->sgl_entries = scsi_sg_count(tw_dev->srb[request_id]);
1902 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries)
1903 tw_dev->max_sgl_entries = tw_dev->sgl_entries;
1908 retval = twa_post_command_packet(tw_dev, request_id, 0);
1910 twa_post_command_packet(tw_dev, request_id, 1);
1918 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id) twa_scsiop_execute_scsi_complete() argument
1920 struct scsi_cmnd *cmd = tw_dev->srb[request_id]; twa_scsiop_execute_scsi_complete()
1926 void *buf = tw_dev->generic_buffer_virt[request_id]; twa_scsiop_execute_scsi_complete()
1934 static void __twa_shutdown(TW_Device_Extension *tw_dev) __twa_shutdown() argument
1937 TW_DISABLE_INTERRUPTS(tw_dev); __twa_shutdown()
1940 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); __twa_shutdown()
1942 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no); __twa_shutdown()
1945 if (twa_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { __twa_shutdown()
1946 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x31, "Connection shutdown failed"); __twa_shutdown()
1952 TW_CLEAR_ALL_INTERRUPTS(tw_dev); __twa_shutdown()
1959 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twa_shutdown() local
1961 __twa_shutdown(tw_dev); twa_shutdown()
2007 TW_Device_Extension *tw_dev; twa_probe() local
2035 tw_dev = (TW_Device_Extension *)host->hostdata; twa_probe()
2038 tw_dev->host = host; twa_probe()
2039 tw_dev->tw_pci_dev = pdev; twa_probe()
2041 if (twa_initialize_device_extension(tw_dev)) { twa_probe()
2042 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension"); twa_probe()
2049 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Failed to get mem region"); twa_probe()
2062 tw_dev->base_addr = ioremap(mem_addr, mem_len); twa_probe()
2063 if (!tw_dev->base_addr) { twa_probe()
2064 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); twa_probe()
2069 TW_DISABLE_INTERRUPTS(tw_dev); twa_probe()
2072 if (twa_reset_sequence(tw_dev, 0)) twa_probe()
2085 host->max_lun = TW_MAX_LUNS(tw_dev->tw_compat_info.working_srl); twa_probe()
2091 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed"); twa_probe()
2101 (char *)twa_get_param(tw_dev, 0, TW_VERSION_TABLE, twa_probe()
2103 (char *)twa_get_param(tw_dev, 1, TW_VERSION_TABLE, twa_probe()
2105 le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE, twa_probe()
2111 set_bit(TW_USING_MSI, &tw_dev->flags); twa_probe()
2114 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); twa_probe()
2116 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x30, "Error requesting IRQ"); twa_probe()
2120 twa_device_extension_list[twa_device_extension_count] = tw_dev; twa_probe()
2124 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); twa_probe()
2136 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twa_probe()
2140 iounmap(tw_dev->base_addr); twa_probe()
2144 twa_free_device_extension(tw_dev); twa_probe()
2156 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twa_remove() local
2158 scsi_remove_host(tw_dev->host); twa_remove()
2167 __twa_shutdown(tw_dev); twa_remove()
2170 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twa_remove()
2174 iounmap(tw_dev->base_addr); twa_remove()
2180 twa_free_device_extension(tw_dev); twa_remove()
2182 scsi_host_put(tw_dev->host); twa_remove()
2192 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twa_suspend() local
2194 printk(KERN_WARNING "3w-9xxx: Suspending host %d.\n", tw_dev->host->host_no); twa_suspend()
2196 TW_DISABLE_INTERRUPTS(tw_dev); twa_suspend()
2197 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); twa_suspend()
2199 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twa_suspend()
2203 if (twa_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { twa_suspend()
2204 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x38, "Connection shutdown failed during suspend"); twa_suspend()
2208 TW_CLEAR_ALL_INTERRUPTS(tw_dev); twa_suspend()
2222 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twa_resume() local
2224 printk(KERN_WARNING "3w-9xxx: Resuming host %d.\n", tw_dev->host->host_no); twa_resume()
2231 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x39, "Enable device failed during resume"); twa_resume()
2248 if (twa_reset_sequence(tw_dev, 0)) { twa_resume()
2254 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); twa_resume()
2256 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x42, "Error requesting IRQ during resume"); twa_resume()
2262 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twa_resume()
2266 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); twa_resume()
H A D3w-sas.c96 static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset);
107 TW_Device_Extension *tw_dev = (TW_Device_Extension *)shost->hostdata; twl_sysfs_aen_read() local
114 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_sysfs_aen_read()
115 ret = memory_read_from_buffer(outbuf, count, &offset, tw_dev->event_queue[0], sizeof(TW_Event) * TW_Q_LENGTH); twl_sysfs_aen_read()
116 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_sysfs_aen_read()
138 TW_Device_Extension *tw_dev = (TW_Device_Extension *)shost->hostdata; twl_sysfs_compat_info() local
145 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_sysfs_compat_info()
146 ret = memory_read_from_buffer(outbuf, count, &offset, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info)); twl_sysfs_compat_info()
147 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_sysfs_compat_info()
167 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twl_show_stats() local
171 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_show_stats()
182 tw_dev->posted_request_count, twl_show_stats()
183 tw_dev->max_posted_request_count, twl_show_stats()
184 tw_dev->sgl_entries, twl_show_stats()
185 tw_dev->max_sgl_entries, twl_show_stats()
186 tw_dev->sector_count, twl_show_stats()
187 tw_dev->max_sector_count, twl_show_stats()
188 tw_dev->num_resets, twl_show_stats()
189 tw_dev->aen_count); twl_show_stats()
190 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_show_stats()
224 static void twl_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header) twl_aen_queue_event() argument
233 tw_dev->aen_count++; twl_aen_queue_event()
236 event = tw_dev->event_queue[tw_dev->error_index]; twl_aen_queue_event()
239 if (tw_dev->host) twl_aen_queue_event()
240 sprintf(host, " scsi%d:", tw_dev->host->host_no); twl_aen_queue_event()
251 event->sequence_id = tw_dev->error_sequence_id; twl_aen_queue_event()
252 tw_dev->error_sequence_id++; twl_aen_queue_event()
267 tw_dev->aen_count--; twl_aen_queue_event()
269 tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH; twl_aen_queue_event()
273 static int twl_post_command_packet(TW_Device_Extension *tw_dev, int request_id) twl_post_command_packet() argument
277 command_que_value = tw_dev->command_packet_phys[request_id]; twl_post_command_packet()
281 writel((u32)((u64)command_que_value >> 32), TWL_HIBQPH_REG_ADDR(tw_dev)); twl_post_command_packet()
283 writel((u32)(command_que_value | TWL_PULL_MODE), TWL_HIBQPL_REG_ADDR(tw_dev)); twl_post_command_packet()
285 tw_dev->state[request_id] = TW_S_POSTED; twl_post_command_packet()
286 tw_dev->posted_request_count++; twl_post_command_packet()
287 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) twl_post_command_packet()
288 tw_dev->max_posted_request_count = tw_dev->posted_request_count; twl_post_command_packet()
294 static int twl_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry_ISO *sglistarg) twl_scsiop_execute_scsi() argument
303 if (tw_dev->srb[request_id]) { twl_scsiop_execute_scsi()
304 srb = tw_dev->srb[request_id]; twl_scsiop_execute_scsi()
310 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_scsiop_execute_scsi()
348 command_packet->sgl_entries__lunh = cpu_to_le16(TW_REQ_LUN_IN((srb->device->lun >> 4), scsi_sg_count(tw_dev->srb[request_id])));
361 tw_dev->sector_count = scsi_bufflen(srb) / 512;
362 if (tw_dev->sector_count > tw_dev->max_sector_count)
363 tw_dev->max_sector_count = tw_dev->sector_count;
364 tw_dev->sgl_entries = scsi_sg_count(srb);
365 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries)
366 tw_dev->max_sgl_entries = tw_dev->sgl_entries;
370 retval = twl_post_command_packet(tw_dev, request_id);
377 static int twl_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) twl_aen_read_queue() argument
384 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_aen_read_queue()
395 sglist[0].address = tw_dev->generic_buffer_phys[request_id]; twl_aen_read_queue()
398 tw_dev->srb[request_id] = NULL; twl_aen_read_queue()
401 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { twl_aen_read_queue()
402 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Post failed while reading AEN queue"); twl_aen_read_queue()
411 static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) twl_aen_sync_time() argument
421 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_aen_sync_time()
426 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); twl_aen_sync_time()
432 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; twl_aen_sync_time()
448 tw_dev->srb[request_id] = NULL; twl_aen_sync_time()
451 twl_post_command_packet(tw_dev, request_id); twl_aen_sync_time()
455 static void twl_get_request_id(TW_Device_Extension *tw_dev, int *request_id) twl_get_request_id() argument
457 *request_id = tw_dev->free_queue[tw_dev->free_head]; twl_get_request_id()
458 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH; twl_get_request_id()
459 tw_dev->state[*request_id] = TW_S_STARTED; twl_get_request_id()
463 static void twl_free_request_id(TW_Device_Extension *tw_dev, int request_id) twl_free_request_id() argument
465 tw_dev->free_queue[tw_dev->free_tail] = request_id; twl_free_request_id()
466 tw_dev->state[request_id] = TW_S_FINISHED; twl_free_request_id()
467 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH; twl_free_request_id()
471 static int twl_aen_complete(TW_Device_Extension *tw_dev, int request_id) twl_aen_complete() argument
479 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; twl_aen_complete()
480 tw_dev->posted_request_count--; twl_aen_complete()
482 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_aen_complete()
488 if (twl_aen_read_queue(tw_dev, request_id)) twl_aen_complete()
501 twl_aen_sync_time(tw_dev, request_id); twl_aen_complete()
505 twl_aen_queue_event(tw_dev, header); twl_aen_complete()
508 if (twl_aen_read_queue(tw_dev, request_id)) twl_aen_complete()
517 tw_dev->state[request_id] = TW_S_COMPLETED; twl_aen_complete()
518 twl_free_request_id(tw_dev, request_id); twl_aen_complete()
519 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); twl_aen_complete()
525 static int twl_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds) twl_poll_response() argument
538 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev)); twl_poll_response()
539 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev)); twl_poll_response()
542 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev)); twl_poll_response()
560 static int twl_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset) twl_aen_drain_queue() argument
576 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_aen_drain_queue()
587 sglist[0].address = tw_dev->generic_buffer_phys[request_id]; twl_aen_drain_queue()
590 tw_dev->srb[request_id] = NULL; twl_aen_drain_queue()
594 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) { twl_aen_drain_queue()
595 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "Error posting request sense"); twl_aen_drain_queue()
600 if (twl_poll_response(tw_dev, request_id, 30)) { twl_aen_drain_queue()
601 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "No valid response while draining AEN queue"); twl_aen_drain_queue()
602 tw_dev->posted_request_count--; twl_aen_drain_queue()
606 tw_dev->posted_request_count--; twl_aen_drain_queue()
607 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id]; twl_aen_drain_queue()
633 twl_aen_queue_event(tw_dev, header); twl_aen_drain_queue()
641 tw_dev->state[request_id] = TW_S_INITIAL; twl_aen_drain_queue()
646 static int twl_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) twl_allocate_memory() argument
653 cpu_addr = pci_zalloc_consistent(tw_dev->tw_pci_dev, size * TW_Q_LENGTH, twl_allocate_memory()
656 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); twl_allocate_memory()
663 tw_dev->command_packet_phys[i] = dma_handle+(i*size); twl_allocate_memory()
664 tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size)); twl_allocate_memory()
667 tw_dev->generic_buffer_phys[i] = dma_handle+(i*size); twl_allocate_memory()
668 tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); twl_allocate_memory()
671 tw_dev->sense_buffer_phys[i] = dma_handle+(i*size); twl_allocate_memory()
672 tw_dev->sense_buffer_virt[i] = (TW_Command_Apache_Header *)((unsigned char *)cpu_addr + (i*size)); twl_allocate_memory()
682 static void twl_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length) twl_load_sgl() argument
729 TW_Device_Extension *tw_dev = twl_device_extension_list[iminor(inode)]; twl_chrdev_ioctl() local
736 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { twl_chrdev_ioctl()
755 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, &dma_handle, GFP_KERNEL); twl_chrdev_ioctl()
770 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_chrdev_ioctl()
771 twl_get_request_id(tw_dev, &request_id); twl_chrdev_ioctl()
774 tw_dev->srb[request_id] = NULL; twl_chrdev_ioctl()
777 tw_dev->chrdev_request_id = request_id; twl_chrdev_ioctl()
782 twl_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted); twl_chrdev_ioctl()
784 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full)); twl_chrdev_ioctl()
787 twl_post_command_packet(tw_dev, request_id); twl_chrdev_ioctl()
788 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_chrdev_ioctl()
793 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); twl_chrdev_ioctl()
796 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { twl_chrdev_ioctl()
799 tw_dev->host->host_no, TW_DRIVER, 0x6, twl_chrdev_ioctl()
802 twl_reset_device_extension(tw_dev, 1); twl_chrdev_ioctl()
807 memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_Full)); twl_chrdev_ioctl()
810 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_chrdev_ioctl()
811 tw_dev->posted_request_count--; twl_chrdev_ioctl()
812 tw_dev->state[request_id] = TW_S_COMPLETED; twl_chrdev_ioctl()
813 twl_free_request_id(tw_dev, request_id); twl_chrdev_ioctl()
814 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_chrdev_ioctl()
826 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle); twl_chrdev_ioctl()
828 mutex_unlock(&tw_dev->ioctl_lock); twl_chrdev_ioctl()
863 static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, int copy_sense, int print_host) twl_fill_sense() argument
871 header = tw_dev->sense_buffer_virt[i]; twl_fill_sense()
872 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_fill_sense()
882 tw_dev->host->host_no, twl_fill_sense()
896 memcpy(tw_dev->srb[request_id]->sense_buffer, header->sense_data, TW_SENSE_DATA_LENGTH); twl_fill_sense()
897 tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1); twl_fill_sense()
905 static void twl_free_device_extension(TW_Device_Extension *tw_dev) twl_free_device_extension() argument
907 if (tw_dev->command_packet_virt[0]) twl_free_device_extension()
908 pci_free_consistent(tw_dev->tw_pci_dev, twl_free_device_extension()
910 tw_dev->command_packet_virt[0], twl_free_device_extension()
911 tw_dev->command_packet_phys[0]); twl_free_device_extension()
913 if (tw_dev->generic_buffer_virt[0]) twl_free_device_extension()
914 pci_free_consistent(tw_dev->tw_pci_dev, twl_free_device_extension()
916 tw_dev->generic_buffer_virt[0], twl_free_device_extension()
917 tw_dev->generic_buffer_phys[0]); twl_free_device_extension()
919 if (tw_dev->sense_buffer_virt[0]) twl_free_device_extension()
920 pci_free_consistent(tw_dev->tw_pci_dev, twl_free_device_extension()
923 tw_dev->sense_buffer_virt[0], twl_free_device_extension()
924 tw_dev->sense_buffer_phys[0]); twl_free_device_extension()
926 kfree(tw_dev->event_queue[0]); twl_free_device_extension()
930 static void *twl_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes) twl_get_param() argument
938 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_get_param()
948 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id]; twl_get_param()
954 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); twl_get_param()
958 twl_post_command_packet(tw_dev, request_id); twl_get_param()
961 if (twl_poll_response(tw_dev, request_id, 30)) twl_get_param()
962 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "No valid response during get param") twl_get_param()
966 tw_dev->posted_request_count--; twl_get_param()
967 tw_dev->state[request_id] = TW_S_INITIAL; twl_get_param()
973 static int twl_initconnection(TW_Device_Extension *tw_dev, int message_credits, twl_initconnection() argument
989 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_initconnection()
1014 twl_post_command_packet(tw_dev, request_id); twl_initconnection()
1017 if (twl_poll_response(tw_dev, request_id, 30)) { twl_initconnection()
1018 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x8, "No valid response during init connection"); twl_initconnection()
1030 tw_dev->posted_request_count--; twl_initconnection()
1031 tw_dev->state[request_id] = TW_S_INITIAL; twl_initconnection()
1037 static int twl_initialize_device_extension(TW_Device_Extension *tw_dev) twl_initialize_device_extension() argument
1042 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) { twl_initialize_device_extension()
1043 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x9, "Command packet memory allocation failed"); twl_initialize_device_extension()
1048 if (twl_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) { twl_initialize_device_extension()
1049 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Generic memory allocation failed"); twl_initialize_device_extension()
1054 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Apache_Header), 2)) { twl_initialize_device_extension()
1055 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xb, "Sense buffer allocation failed"); twl_initialize_device_extension()
1060 tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL); twl_initialize_device_extension()
1061 if (!tw_dev->event_queue[0]) { twl_initialize_device_extension()
1062 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "Event info memory allocation failed"); twl_initialize_device_extension()
1067 tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event))); twl_initialize_device_extension()
1068 tw_dev->free_queue[i] = i; twl_initialize_device_extension()
1069 tw_dev->state[i] = TW_S_INITIAL; twl_initialize_device_extension()
1072 tw_dev->free_head = TW_Q_START; twl_initialize_device_extension()
1073 tw_dev->free_tail = TW_Q_START; twl_initialize_device_extension()
1074 tw_dev->error_sequence_id = 1; twl_initialize_device_extension()
1075 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twl_initialize_device_extension()
1077 mutex_init(&tw_dev->ioctl_lock); twl_initialize_device_extension()
1078 init_waitqueue_head(&tw_dev->ioctl_wqueue); twl_initialize_device_extension()
1086 static int twl_handle_attention_interrupt(TW_Device_Extension *tw_dev) twl_handle_attention_interrupt() argument
1092 doorbell = readl(TWL_HOBDB_REG_ADDR(tw_dev)); twl_handle_attention_interrupt()
1096 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "Microcontroller Error: clearing"); twl_handle_attention_interrupt()
1102 if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) { twl_handle_attention_interrupt()
1103 twl_get_request_id(tw_dev, &request_id); twl_handle_attention_interrupt()
1104 if (twl_aen_read_queue(tw_dev, request_id)) { twl_handle_attention_interrupt()
1105 tw_dev->state[request_id] = TW_S_COMPLETED; twl_handle_attention_interrupt()
1106 twl_free_request_id(tw_dev, request_id); twl_handle_attention_interrupt()
1107 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags); twl_handle_attention_interrupt()
1115 TWL_CLEAR_DB_INTERRUPT(tw_dev); twl_handle_attention_interrupt()
1118 readl(TWL_HOBDBC_REG_ADDR(tw_dev)); twl_handle_attention_interrupt()
1126 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance; twl_interrupt() local
1133 spin_lock(tw_dev->host->host_lock); twl_interrupt()
1136 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev)); twl_interrupt()
1145 if (test_bit(TW_IN_RESET, &tw_dev->flags)) twl_interrupt()
1150 if (twl_handle_attention_interrupt(tw_dev)) { twl_interrupt()
1151 TWL_MASK_INTERRUPTS(tw_dev); twl_interrupt()
1159 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev)); twl_interrupt()
1160 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev)); twl_interrupt()
1163 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev)); twl_interrupt()
1171 if (tw_dev->sense_buffer_phys[i] == mfa) { twl_interrupt()
1172 request_id = le16_to_cpu(tw_dev->sense_buffer_virt[i]->header_desc.request_id); twl_interrupt()
1173 if (tw_dev->srb[request_id] != NULL) twl_interrupt()
1174 error = twl_fill_sense(tw_dev, i, request_id, 1, 1); twl_interrupt()
1177 if (request_id != tw_dev->chrdev_request_id) twl_interrupt()
1178 error = twl_fill_sense(tw_dev, i, request_id, 0, 1); twl_interrupt()
1180 memcpy(tw_dev->command_packet_virt[request_id], tw_dev->sense_buffer_virt[i], sizeof(TW_Command_Apache_Header)); twl_interrupt()
1184 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev)); twl_interrupt()
1185 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev)); twl_interrupt()
1192 full_command_packet = tw_dev->command_packet_virt[request_id]; twl_interrupt()
1195 if (tw_dev->state[request_id] != TW_S_POSTED) { twl_interrupt()
1196 if (tw_dev->srb[request_id] != NULL) { twl_interrupt()
1197 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Received a request id that wasn't posted"); twl_interrupt()
1198 TWL_MASK_INTERRUPTS(tw_dev); twl_interrupt()
1204 if (tw_dev->srb[request_id] == NULL) { twl_interrupt()
1205 if (request_id != tw_dev->chrdev_request_id) { twl_interrupt()
1206 if (twl_aen_complete(tw_dev, request_id)) twl_interrupt()
1207 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "Error completing AEN during attention interrupt"); twl_interrupt()
1209 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twl_interrupt()
1210 wake_up(&tw_dev->ioctl_wqueue); twl_interrupt()
1213 cmd = tw_dev->srb[request_id]; twl_interrupt()
1220 if (full_command_packet->command.newcommand.sg_list[0].length < scsi_bufflen(tw_dev->srb[request_id])) twl_interrupt()
1227 tw_dev->state[request_id] = TW_S_COMPLETED; twl_interrupt()
1228 twl_free_request_id(tw_dev, request_id); twl_interrupt()
1229 tw_dev->posted_request_count--; twl_interrupt()
1233 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev)); twl_interrupt()
1237 spin_unlock(tw_dev->host->host_lock); twl_interrupt()
1242 static int twl_poll_register(TW_Device_Extension *tw_dev, void *reg, u32 value, u32 result, int seconds) twl_poll_register() argument
1263 static int twl_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset) twl_reset_sequence() argument
1277 TWL_SOFT_RESET(tw_dev); twl_reset_sequence()
1280 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, 0x0, 30)) { twl_reset_sequence()
1281 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Controller never went non-ready during reset sequence"); twl_reset_sequence()
1285 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, TWL_CONTROLLER_READY, 60)) { twl_reset_sequence()
1286 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x11, "Controller not ready during reset sequence"); twl_reset_sequence()
1293 if (twl_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS, twl_reset_sequence()
1299 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x12, "Initconnection failed while checking SRL"); twl_reset_sequence()
1307 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev)); twl_reset_sequence()
1308 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev)); twl_reset_sequence()
1311 status = readl(TWL_STATUS_REG_ADDR(tw_dev)); twl_reset_sequence()
1317 status = readl(TWL_STATUS_REG_ADDR(tw_dev)); twl_reset_sequence()
1319 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "Bad controller status after loading sense buffers"); twl_reset_sequence()
1326 if (twl_aen_drain_queue(tw_dev, soft_reset)) { twl_reset_sequence()
1327 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x14, "AEN drain failed during reset sequence"); twl_reset_sequence()
1334 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); twl_reset_sequence()
1335 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; twl_reset_sequence()
1336 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; twl_reset_sequence()
1337 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD; twl_reset_sequence()
1338 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL; twl_reset_sequence()
1339 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH; twl_reset_sequence()
1340 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD; twl_reset_sequence()
1341 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl; twl_reset_sequence()
1342 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch; twl_reset_sequence()
1343 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build; twl_reset_sequence()
1354 static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset) twl_reset_device_extension() argument
1361 scsi_block_requests(tw_dev->host); twl_reset_device_extension()
1363 set_bit(TW_IN_RESET, &tw_dev->flags); twl_reset_device_extension()
1364 TWL_MASK_INTERRUPTS(tw_dev); twl_reset_device_extension()
1365 TWL_CLEAR_DB_INTERRUPT(tw_dev); twl_reset_device_extension()
1367 spin_lock_irqsave(tw_dev->host->host_lock, flags); twl_reset_device_extension()
1371 if ((tw_dev->state[i] != TW_S_FINISHED) && twl_reset_device_extension()
1372 (tw_dev->state[i] != TW_S_INITIAL) && twl_reset_device_extension()
1373 (tw_dev->state[i] != TW_S_COMPLETED)) { twl_reset_device_extension()
1374 struct scsi_cmnd *cmd = tw_dev->srb[i]; twl_reset_device_extension()
1386 tw_dev->free_queue[i] = i; twl_reset_device_extension()
1387 tw_dev->state[i] = TW_S_INITIAL; twl_reset_device_extension()
1389 tw_dev->free_head = TW_Q_START; twl_reset_device_extension()
1390 tw_dev->free_tail = TW_Q_START; twl_reset_device_extension()
1391 tw_dev->posted_request_count = 0; twl_reset_device_extension()
1393 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); twl_reset_device_extension()
1395 if (twl_reset_sequence(tw_dev, 1)) twl_reset_device_extension()
1398 TWL_UNMASK_INTERRUPTS(tw_dev); twl_reset_device_extension()
1400 clear_bit(TW_IN_RESET, &tw_dev->flags); twl_reset_device_extension()
1401 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; twl_reset_device_extension()
1406 scsi_unblock_requests(tw_dev->host); twl_reset_device_extension()
1414 TW_Device_Extension *tw_dev; twl_scsi_biosparam() local
1416 tw_dev = (TW_Device_Extension *)sdev->host->hostdata; twl_scsi_biosparam()
1436 TW_Device_Extension *tw_dev = NULL; twl_scsi_eh_reset() local
1439 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; twl_scsi_eh_reset()
1441 tw_dev->num_resets++; twl_scsi_eh_reset()
1448 mutex_lock(&tw_dev->ioctl_lock); twl_scsi_eh_reset()
1451 if (twl_reset_device_extension(tw_dev, 0)) { twl_scsi_eh_reset()
1452 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "Controller reset failed during scsi host reset"); twl_scsi_eh_reset()
1458 mutex_unlock(&tw_dev->ioctl_lock); twl_scsi_eh_reset()
1466 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; twl_scsi_queue_lck() local
1469 if (test_bit(TW_IN_RESET, &tw_dev->flags)) { twl_scsi_queue_lck()
1478 twl_get_request_id(tw_dev, &request_id); twl_scsi_queue_lck()
1481 tw_dev->srb[request_id] = SCpnt; twl_scsi_queue_lck()
1483 retval = twl_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL); twl_scsi_queue_lck()
1485 tw_dev->state[request_id] = TW_S_COMPLETED; twl_scsi_queue_lck()
1486 twl_free_request_id(tw_dev, request_id); twl_scsi_queue_lck()
1498 static void __twl_shutdown(TW_Device_Extension *tw_dev) __twl_shutdown() argument
1501 TWL_MASK_INTERRUPTS(tw_dev); __twl_shutdown()
1504 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); __twl_shutdown()
1506 printk(KERN_WARNING "3w-sas: Shutting down host %d.\n", tw_dev->host->host_no); __twl_shutdown()
1509 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { __twl_shutdown()
1510 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Connection shutdown failed"); __twl_shutdown()
1516 TWL_CLEAR_DB_INTERRUPT(tw_dev); __twl_shutdown()
1523 TW_Device_Extension *tw_dev; twl_shutdown() local
1528 tw_dev = (TW_Device_Extension *)host->hostdata; twl_shutdown()
1530 if (tw_dev->online) twl_shutdown()
1531 __twl_shutdown(tw_dev); twl_shutdown()
1567 TW_Device_Extension *tw_dev; twl_probe() local
1595 tw_dev = shost_priv(host); twl_probe()
1598 tw_dev->host = host; twl_probe()
1599 tw_dev->tw_pci_dev = pdev; twl_probe()
1601 if (twl_initialize_device_extension(tw_dev)) { twl_probe()
1602 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension"); twl_probe()
1609 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Failed to get mem region"); twl_probe()
1614 tw_dev->base_addr = pci_iomap(pdev, 1, 0); twl_probe()
1615 if (!tw_dev->base_addr) { twl_probe()
1616 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap"); twl_probe()
1621 TWL_MASK_INTERRUPTS(tw_dev); twl_probe()
1624 if (twl_reset_sequence(tw_dev, 0)) { twl_probe()
1625 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe"); twl_probe()
1638 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "scsi add host failed"); twl_probe()
1646 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE, twl_probe()
1650 ptr_phycount = twl_get_param(tw_dev, 2, TW_PARAM_PHY_SUMMARY_TABLE, twl_probe()
1657 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE, twl_probe()
1659 (char *)twl_get_param(tw_dev, 2, TW_VERSION_TABLE, twl_probe()
1665 set_bit(TW_USING_MSI, &tw_dev->flags); twl_probe()
1668 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev); twl_probe()
1670 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Error requesting IRQ"); twl_probe()
1674 twl_device_extension_list[twl_device_extension_count] = tw_dev; twl_probe()
1678 TWL_UNMASK_INTERRUPTS(tw_dev); twl_probe()
1685 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Failed to create sysfs binary file: 3ware_aen_read"); twl_probe()
1687 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Failed to create sysfs binary file: 3ware_compat_info"); twl_probe()
1693 tw_dev->online = 1; twl_probe()
1697 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twl_probe()
1701 iounmap(tw_dev->base_addr); twl_probe()
1705 twl_free_device_extension(tw_dev); twl_probe()
1717 TW_Device_Extension *tw_dev; twl_remove() local
1722 tw_dev = (TW_Device_Extension *)host->hostdata; twl_remove()
1724 if (!tw_dev->online) twl_remove()
1731 scsi_remove_host(tw_dev->host); twl_remove()
1740 __twl_shutdown(tw_dev); twl_remove()
1743 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twl_remove()
1747 iounmap(tw_dev->base_addr); twl_remove()
1753 twl_free_device_extension(tw_dev); twl_remove()
1755 scsi_host_put(tw_dev->host); twl_remove()
1765 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twl_suspend() local
1767 printk(KERN_WARNING "3w-sas: Suspending host %d.\n", tw_dev->host->host_no); twl_suspend()
1769 TWL_MASK_INTERRUPTS(tw_dev); twl_suspend()
1771 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); twl_suspend()
1774 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) { twl_suspend()
1775 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x23, "Connection shutdown failed during suspend"); twl_suspend()
1781 TWL_CLEAR_DB_INTERRUPT(tw_dev); twl_suspend()
1795 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; twl_resume() local
1797 printk(KERN_WARNING "3w-sas: Resuming host %d.\n", tw_dev->host->host_no); twl_resume()
1804 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x24, "Enable device failed during resume"); twl_resume()
1821 if (twl_reset_sequence(tw_dev, 0)) { twl_resume()
1827 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev); twl_resume()
1829 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Error requesting IRQ during resume"); twl_resume()
1835 if (test_bit(TW_USING_MSI, &tw_dev->flags)) twl_resume()
1839 TWL_UNMASK_INTERRUPTS(tw_dev); twl_resume()
H A D3w-xxxx.c236 static int tw_reset_device_extension(TW_Device_Extension *tw_dev);
256 static int tw_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value, int print_host) tw_decode_bits() argument
263 sprintf(host, " scsi%d:", tw_dev->host->host_no); tw_decode_bits()
269 outl(TW_CONTROL_CLEAR_PARITY_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); tw_decode_bits()
274 outl(TW_CONTROL_CLEAR_PCI_ABORT, TW_CONTROL_REG_ADDR(tw_dev)); tw_decode_bits()
275 pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT); tw_decode_bits()
280 outl(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); tw_decode_bits()
285 outl(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); tw_decode_bits()
289 if (tw_dev->reset_print == 0) { tw_decode_bits()
291 tw_dev->reset_print = 1; tw_decode_bits()
300 static int tw_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds) tw_poll_status() argument
306 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_poll_status()
310 tw_decode_bits(tw_dev, status_reg_value, 0); tw_poll_status()
313 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_poll_status()
316 tw_decode_bits(tw_dev, status_reg_value, 0); tw_poll_status()
329 static int tw_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds) tw_poll_status_gone() argument
335 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_poll_status_gone()
339 tw_decode_bits(tw_dev, status_reg_value, 0); tw_poll_status_gone()
342 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_poll_status_gone()
345 tw_decode_bits(tw_dev, status_reg_value, 0); tw_poll_status_gone()
358 static int tw_post_command_packet(TW_Device_Extension *tw_dev, int request_id) tw_post_command_packet() argument
364 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_post_command_packet()
365 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_post_command_packet()
369 tw_decode_bits(tw_dev, status_reg_value, 1); tw_post_command_packet()
374 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); tw_post_command_packet()
375 tw_dev->state[request_id] = TW_S_POSTED; tw_post_command_packet()
376 tw_dev->posted_request_count++; tw_post_command_packet()
377 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) { tw_post_command_packet()
378 tw_dev->max_posted_request_count = tw_dev->posted_request_count; tw_post_command_packet()
382 if (tw_dev->state[request_id] != TW_S_PENDING) { tw_post_command_packet()
383 tw_dev->state[request_id] = TW_S_PENDING; tw_post_command_packet()
384 tw_dev->pending_request_count++; tw_post_command_packet()
385 if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) { tw_post_command_packet()
386 tw_dev->max_pending_request_count = tw_dev->pending_request_count; tw_post_command_packet()
388 tw_dev->pending_queue[tw_dev->pending_tail] = request_id; tw_post_command_packet()
389 if (tw_dev->pending_tail == TW_Q_LENGTH-1) { tw_post_command_packet()
390 tw_dev->pending_tail = TW_Q_START; tw_post_command_packet()
392 tw_dev->pending_tail = tw_dev->pending_tail + 1; tw_post_command_packet()
395 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); tw_post_command_packet()
402 static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill_sense) tw_decode_sense() argument
408 command = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_decode_sense()
410 printk(KERN_WARNING "3w-xxxx: scsi%d: Command failed: status = 0x%x, flags = 0x%x, unit #%d.\n", tw_dev->host->host_no, command->status, command->flags, TW_UNIT_OUT(command->unit__hostid)); tw_decode_sense()
419 tw_dev->srb[request_id]->sense_buffer[0] = (0x1 << 7 | 0x70); tw_decode_sense()
422 tw_dev->srb[request_id]->sense_buffer[2] = tw_sense_table[i][1]; tw_decode_sense()
425 tw_dev->srb[request_id]->sense_buffer[7] = 0xa; /* 10 bytes */ tw_decode_sense()
428 tw_dev->srb[request_id]->sense_buffer[12] = tw_sense_table[i][2]; tw_decode_sense()
431 tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3]; tw_decode_sense()
433 tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); tw_decode_sense()
447 static int tw_check_errors(TW_Device_Extension *tw_dev) tw_check_errors() argument
451 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_check_errors()
454 tw_decode_bits(tw_dev, status_reg_value, 0); tw_check_errors()
462 static void tw_empty_response_que(TW_Device_Extension *tw_dev) tw_empty_response_que() argument
466 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_empty_response_que()
469 response_que_value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); tw_empty_response_que()
470 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_empty_response_que()
475 static void tw_state_request_finish(TW_Device_Extension *tw_dev, int request_id) tw_state_request_finish() argument
477 tw_dev->free_queue[tw_dev->free_tail] = request_id; tw_state_request_finish()
478 tw_dev->state[request_id] = TW_S_FINISHED; tw_state_request_finish()
479 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH; tw_state_request_finish()
483 static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id) tw_state_request_start() argument
485 *request_id = tw_dev->free_queue[tw_dev->free_head]; tw_state_request_start()
486 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH; tw_state_request_start()
487 tw_dev->state[*request_id] = TW_S_STARTED; tw_state_request_start()
495 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; tw_show_stats() local
499 spin_lock_irqsave(tw_dev->host->host_lock, flags); tw_show_stats()
512 tw_dev->posted_request_count, tw_show_stats()
513 tw_dev->max_posted_request_count, tw_show_stats()
514 tw_dev->pending_request_count, tw_show_stats()
515 tw_dev->max_pending_request_count, tw_show_stats()
516 tw_dev->sgl_entries, tw_show_stats()
517 tw_dev->max_sgl_entries, tw_show_stats()
518 tw_dev->sector_count, tw_show_stats()
519 tw_dev->max_sector_count, tw_show_stats()
520 tw_dev->num_resets, tw_show_stats()
521 tw_dev->aen_count); tw_show_stats()
522 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); tw_show_stats()
542 static int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) tw_aen_read_queue() argument
552 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_aen_read_queue()
555 tw_decode_bits(tw_dev, status_reg_value, 1); tw_aen_read_queue()
558 if (tw_dev->command_packet_virtual_address[request_id] == NULL) { tw_aen_read_queue()
562 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_aen_read_queue()
570 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_aen_read_queue()
576 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_aen_read_queue()
580 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_aen_read_queue()
585 param_value = tw_dev->alignment_physical_address[request_id]; tw_aen_read_queue()
596 tw_dev->srb[request_id] = NULL; /* Flag internal command */ tw_aen_read_queue()
597 tw_dev->state[request_id] = TW_S_POSTED; tw_aen_read_queue()
598 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); tw_aen_read_queue()
608 static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) tw_aen_complete() argument
615 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_aen_complete()
619 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_aen_complete()
625 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: INFO: AEN queue overflow.\n", tw_dev->host->host_no); tw_aen_complete()
630 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s%d.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff], aen >> 8); tw_aen_complete()
633 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff]); tw_aen_complete()
636 printk(KERN_WARNING "3w-xxxx: scsi%d: Received AEN %d.\n", tw_dev->host->host_no, aen); tw_aen_complete()
640 tw_dev->aen_count++; tw_aen_complete()
643 tw_dev->aen_queue[tw_dev->aen_tail] = aen; tw_aen_complete()
644 if (tw_dev->aen_tail == TW_Q_LENGTH - 1) { tw_aen_complete()
645 tw_dev->aen_tail = TW_Q_START; tw_aen_complete()
647 tw_dev->aen_tail = tw_dev->aen_tail + 1; tw_aen_complete()
649 if (tw_dev->aen_head == tw_dev->aen_tail) { tw_aen_complete()
650 if (tw_dev->aen_head == TW_Q_LENGTH - 1) { tw_aen_complete()
651 tw_dev->aen_head = TW_Q_START; tw_aen_complete()
653 tw_dev->aen_head = tw_dev->aen_head + 1; tw_aen_complete()
657 error = tw_aen_read_queue(tw_dev, request_id); tw_aen_complete()
659 printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing AEN.\n", tw_dev->host->host_no); tw_aen_complete()
660 tw_dev->state[request_id] = TW_S_COMPLETED; tw_aen_complete()
661 tw_state_request_finish(tw_dev, request_id); tw_aen_complete()
664 tw_dev->state[request_id] = TW_S_COMPLETED; tw_aen_complete()
665 tw_state_request_finish(tw_dev, request_id); tw_aen_complete()
672 static int tw_aen_drain_queue(TW_Device_Extension *tw_dev) tw_aen_drain_queue() argument
689 if (tw_poll_status(tw_dev, TW_STATUS_ATTENTION_INTERRUPT | TW_STATUS_MICROCONTROLLER_READY, 30)) { tw_aen_drain_queue()
693 TW_CLEAR_ATTENTION_INTERRUPT(tw_dev); tw_aen_drain_queue()
696 tw_empty_response_que(tw_dev); tw_aen_drain_queue()
699 if (tw_dev->command_packet_virtual_address[request_id] == NULL) { tw_aen_drain_queue()
703 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_aen_drain_queue()
711 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_aen_drain_queue()
718 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_aen_drain_queue()
722 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_aen_drain_queue()
727 param_value = tw_dev->alignment_physical_address[request_id]; tw_aen_drain_queue()
738 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); tw_aen_drain_queue()
741 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) { tw_aen_drain_queue()
742 response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); tw_aen_drain_queue()
754 tw_decode_sense(tw_dev, request_id, 0); tw_aen_drain_queue()
780 tw_dev->aen_count++; tw_aen_drain_queue()
798 tw_dev->aen_count++; tw_aen_drain_queue()
804 tw_dev->aen_queue[tw_dev->aen_tail] = aen; tw_aen_drain_queue()
805 if (tw_dev->aen_tail == TW_Q_LENGTH - 1) { tw_aen_drain_queue()
806 tw_dev->aen_tail = TW_Q_START; tw_aen_drain_queue()
808 tw_dev->aen_tail = tw_dev->aen_tail + 1; tw_aen_drain_queue()
810 if (tw_dev->aen_head == tw_dev->aen_tail) { tw_aen_drain_queue()
811 if (tw_dev->aen_head == TW_Q_LENGTH - 1) { tw_aen_drain_queue()
812 tw_dev->aen_head = TW_Q_START; tw_aen_drain_queue()
814 tw_dev->aen_head = tw_dev->aen_head + 1; tw_aen_drain_queue()
830 static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) tw_allocate_memory() argument
838 cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); tw_allocate_memory()
844 if ((unsigned long)cpu_addr % (tw_dev->tw_pci_dev->device == TW_DEVICE_ID ? TW_ALIGNMENT_6000 : TW_ALIGNMENT_7000)) { tw_allocate_memory()
846 pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle); tw_allocate_memory()
855 tw_dev->command_packet_physical_address[i] = dma_handle+(i*size); tw_allocate_memory()
856 tw_dev->command_packet_virtual_address[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); tw_allocate_memory()
859 tw_dev->alignment_physical_address[i] = dma_handle+(i*size); tw_allocate_memory()
860 tw_dev->alignment_virtual_address[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size)); tw_allocate_memory()
885 TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)]; tw_chrdev_ioctl() local
893 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { tw_chrdev_ioctl()
912 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, &dma_handle, GFP_KERNEL); tw_chrdev_ioctl()
935 spin_lock_irqsave(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
936 if (tw_dev->aen_head == tw_dev->aen_tail) { tw_chrdev_ioctl()
939 tw_aen_code = tw_dev->aen_queue[tw_dev->aen_head]; tw_chrdev_ioctl()
940 if (tw_dev->aen_head == TW_Q_LENGTH - 1) { tw_chrdev_ioctl()
941 tw_dev->aen_head = TW_Q_START; tw_chrdev_ioctl()
943 tw_dev->aen_head = tw_dev->aen_head + 1; tw_chrdev_ioctl()
946 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
951 spin_lock_irqsave(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
953 tw_state_request_start(tw_dev, &request_id); tw_chrdev_ioctl()
956 tw_dev->srb[request_id] = NULL; tw_chrdev_ioctl()
959 tw_dev->chrdev_request_id = request_id; tw_chrdev_ioctl()
979 memcpy(tw_dev->command_packet_virtual_address[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command)); tw_chrdev_ioctl()
982 tw_post_command_packet(tw_dev, request_id); tw_chrdev_ioctl()
983 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
988 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); tw_chrdev_ioctl()
991 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { tw_chrdev_ioctl()
993 printk(KERN_WARNING "3w-xxxx: scsi%d: Character ioctl (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, cmd); tw_chrdev_ioctl()
995 if (tw_reset_device_extension(tw_dev)) { tw_chrdev_ioctl()
996 printk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): Reset failed for card %d.\n", tw_dev->host->host_no); tw_chrdev_ioctl()
1002 memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virtual_address[request_id], sizeof(TW_Command)); tw_chrdev_ioctl()
1005 spin_lock_irqsave(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
1006 tw_dev->posted_request_count--; tw_chrdev_ioctl()
1007 tw_dev->state[request_id] = TW_S_COMPLETED; tw_chrdev_ioctl()
1008 tw_state_request_finish(tw_dev, request_id); tw_chrdev_ioctl()
1009 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); tw_chrdev_ioctl()
1022 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); tw_chrdev_ioctl()
1024 mutex_unlock(&tw_dev->ioctl_lock); tw_chrdev_ioctl()
1054 static void tw_free_device_extension(TW_Device_Extension *tw_dev) tw_free_device_extension() argument
1059 if (tw_dev->command_packet_virtual_address[0]) tw_free_device_extension()
1060 pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Command)*TW_Q_LENGTH, tw_dev->command_packet_virtual_address[0], tw_dev->command_packet_physical_address[0]); tw_free_device_extension()
1062 if (tw_dev->alignment_virtual_address[0]) tw_free_device_extension()
1063 pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], tw_dev->alignment_physical_address[0]); tw_free_device_extension()
1067 static int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) tw_initconnection() argument
1077 if (tw_dev->command_packet_virtual_address[request_id] == NULL) { tw_initconnection()
1082 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_initconnection()
1091 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_initconnection()
1099 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); tw_initconnection()
1102 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) { tw_initconnection()
1103 response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); tw_initconnection()
1113 tw_decode_sense(tw_dev, request_id, 0); tw_initconnection()
1121 static int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, tw_setfeature() argument
1132 if (tw_dev->command_packet_virtual_address[request_id] == NULL) { tw_setfeature()
1136 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_setfeature()
1138 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_setfeature()
1146 param_value = tw_dev->alignment_physical_address[request_id]; tw_setfeature()
1149 tw_dev->state[request_id] = TW_S_COMPLETED; tw_setfeature()
1150 tw_state_request_finish(tw_dev, request_id); tw_setfeature()
1151 tw_dev->srb[request_id]->result = (DID_OK << 16); tw_setfeature()
1152 tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); tw_setfeature()
1161 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_setfeature()
1168 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); tw_setfeature()
1171 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) { tw_setfeature()
1172 response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); tw_setfeature()
1182 tw_decode_sense(tw_dev, request_id, 0); tw_setfeature()
1191 static int tw_reset_sequence(TW_Device_Extension *tw_dev) tw_reset_sequence() argument
1199 TW_SOFT_RESET(tw_dev); tw_reset_sequence()
1201 error = tw_aen_drain_queue(tw_dev); tw_reset_sequence()
1203 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN drain failed, retrying.\n", tw_dev->host->host_no); tw_reset_sequence()
1209 if (tw_check_errors(tw_dev)) { tw_reset_sequence()
1210 printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors found, retrying.\n", tw_dev->host->host_no); tw_reset_sequence()
1220 printk(KERN_WARNING "3w-xxxx: scsi%d: Controller errors, card not responding, check all cabling.\n", tw_dev->host->host_no); tw_reset_sequence()
1224 error = tw_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS); tw_reset_sequence()
1226 printk(KERN_WARNING "3w-xxxx: scsi%d: Connection initialization failed.\n", tw_dev->host->host_no); tw_reset_sequence()
1230 error = tw_setfeature(tw_dev, 2, 1, &c); tw_reset_sequence()
1239 static int tw_initialize_device_extension(TW_Device_Extension *tw_dev) tw_initialize_device_extension() argument
1246 error = tw_allocate_memory(tw_dev, sizeof(TW_Command), 0); tw_initialize_device_extension()
1253 error = tw_allocate_memory(tw_dev, sizeof(TW_Sector), 1); tw_initialize_device_extension()
1260 tw_dev->free_queue[i] = i; tw_initialize_device_extension()
1261 tw_dev->state[i] = TW_S_INITIAL; tw_initialize_device_extension()
1264 tw_dev->pending_head = TW_Q_START; tw_initialize_device_extension()
1265 tw_dev->pending_tail = TW_Q_START; tw_initialize_device_extension()
1266 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; tw_initialize_device_extension()
1268 mutex_init(&tw_dev->ioctl_lock); tw_initialize_device_extension()
1269 init_waitqueue_head(&tw_dev->ioctl_wqueue); tw_initialize_device_extension()
1275 static int tw_reset_device_extension(TW_Device_Extension *tw_dev) tw_reset_device_extension() argument
1283 set_bit(TW_IN_RESET, &tw_dev->flags); tw_reset_device_extension()
1284 TW_DISABLE_INTERRUPTS(tw_dev); tw_reset_device_extension()
1285 TW_MASK_COMMAND_INTERRUPT(tw_dev); tw_reset_device_extension()
1286 spin_lock_irqsave(tw_dev->host->host_lock, flags); tw_reset_device_extension()
1290 if ((tw_dev->state[i] != TW_S_FINISHED) && tw_reset_device_extension()
1291 (tw_dev->state[i] != TW_S_INITIAL) && tw_reset_device_extension()
1292 (tw_dev->state[i] != TW_S_COMPLETED)) { tw_reset_device_extension()
1293 srb = tw_dev->srb[i]; tw_reset_device_extension()
1304 tw_dev->free_queue[i] = i; tw_reset_device_extension()
1305 tw_dev->state[i] = TW_S_INITIAL; tw_reset_device_extension()
1307 tw_dev->free_head = TW_Q_START; tw_reset_device_extension()
1308 tw_dev->free_tail = TW_Q_START; tw_reset_device_extension()
1309 tw_dev->posted_request_count = 0; tw_reset_device_extension()
1310 tw_dev->pending_request_count = 0; tw_reset_device_extension()
1311 tw_dev->pending_head = TW_Q_START; tw_reset_device_extension()
1312 tw_dev->pending_tail = TW_Q_START; tw_reset_device_extension()
1313 tw_dev->reset_print = 0; tw_reset_device_extension()
1315 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); tw_reset_device_extension()
1317 if (tw_reset_sequence(tw_dev)) { tw_reset_device_extension()
1318 printk(KERN_WARNING "3w-xxxx: scsi%d: Reset sequence failed.\n", tw_dev->host->host_no); tw_reset_device_extension()
1322 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); tw_reset_device_extension()
1323 clear_bit(TW_IN_RESET, &tw_dev->flags); tw_reset_device_extension()
1324 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; tw_reset_device_extension()
1334 TW_Device_Extension *tw_dev; tw_scsi_biosparam() local
1337 tw_dev = (TW_Device_Extension *)sdev->host->hostdata; tw_scsi_biosparam()
1360 TW_Device_Extension *tw_dev=NULL; tw_scsi_eh_reset() local
1363 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; tw_scsi_eh_reset()
1365 tw_dev->num_resets++; tw_scsi_eh_reset()
1372 mutex_lock(&tw_dev->ioctl_lock); tw_scsi_eh_reset()
1375 if (tw_reset_device_extension(tw_dev)) { tw_scsi_eh_reset()
1376 printk(KERN_WARNING "3w-xxxx: scsi%d: Reset failed.\n", tw_dev->host->host_no); tw_scsi_eh_reset()
1382 mutex_unlock(&tw_dev->ioctl_lock); tw_scsi_eh_reset()
1387 static int tw_scsiop_inquiry(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_inquiry() argument
1397 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_inquiry()
1411 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_scsiop_inquiry()
1415 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_inquiry()
1420 param_value = tw_dev->alignment_physical_address[request_id]; tw_scsiop_inquiry()
1428 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_inquiry()
1435 tw_post_command_packet(tw_dev, request_id); tw_scsiop_inquiry()
1440 static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id, tw_transfer_internal() argument
1443 scsi_sg_copy_from_buffer(tw_dev->srb[request_id], data, len); tw_transfer_internal()
1447 static int tw_scsiop_inquiry_complete(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_inquiry_complete() argument
1461 sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id); tw_scsiop_inquiry_complete()
1463 tw_transfer_internal(tw_dev, request_id, request_buffer, tw_scsiop_inquiry_complete()
1466 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_inquiry_complete()
1473 if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) { tw_scsiop_inquiry_complete()
1474 tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1; tw_scsiop_inquiry_complete()
1476 tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0; tw_scsiop_inquiry_complete()
1477 tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); tw_scsiop_inquiry_complete()
1485 static int tw_scsiop_mode_sense(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_mode_sense() argument
1495 if (tw_dev->srb[request_id]->cmnd[2] != 0x8) { tw_scsiop_mode_sense()
1496 tw_dev->state[request_id] = TW_S_COMPLETED; tw_scsiop_mode_sense()
1497 tw_state_request_finish(tw_dev, request_id); tw_scsiop_mode_sense()
1498 tw_dev->srb[request_id]->result = (DID_OK << 16); tw_scsiop_mode_sense()
1499 tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); tw_scsiop_mode_sense()
1504 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_mode_sense()
1520 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_scsiop_mode_sense()
1525 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_mode_sense()
1527 param->table_id = TW_UNIT_INFORMATION_TABLE_BASE + tw_dev->srb[request_id]->device->id; tw_scsiop_mode_sense()
1530 param_value = tw_dev->alignment_physical_address[request_id]; tw_scsiop_mode_sense()
1538 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_mode_sense()
1545 tw_post_command_packet(tw_dev, request_id); tw_scsiop_mode_sense()
1551 static int tw_scsiop_mode_sense_complete(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_mode_sense_complete() argument
1559 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_mode_sense_complete()
1577 tw_transfer_internal(tw_dev, request_id, request_buffer, tw_scsiop_mode_sense_complete()
1584 static int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_read_capacity() argument
1594 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_read_capacity()
1604 command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id); tw_scsiop_read_capacity()
1610 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_scsiop_read_capacity()
1614 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_read_capacity()
1617 tw_dev->srb[request_id]->device->id; tw_scsiop_read_capacity()
1620 param_value = tw_dev->alignment_physical_address[request_id]; tw_scsiop_read_capacity()
1628 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_read_capacity()
1635 tw_post_command_packet(tw_dev, request_id); tw_scsiop_read_capacity()
1641 static int tw_scsiop_read_capacity_complete(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_read_capacity_complete() argument
1651 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_read_capacity_complete()
1678 tw_transfer_internal(tw_dev, request_id, buff, sizeof(buff)); tw_scsiop_read_capacity_complete()
1684 static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_read_write() argument
1695 srb = tw_dev->srb[request_id]; tw_scsiop_read_write()
1704 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_read_write()
1736 tw_dev->sector_count = num_sectors; tw_scsiop_read_write()
1737 if (tw_dev->sector_count > tw_dev->max_sector_count) tw_scsiop_read_write()
1738 tw_dev->max_sector_count = tw_dev->sector_count; tw_scsiop_read_write()
1748 scsi_for_each_sg(tw_dev->srb[request_id], sg, use_sg, i) { tw_scsiop_read_write()
1755 tw_dev->sgl_entries = scsi_sg_count(tw_dev->srb[request_id]); tw_scsiop_read_write()
1756 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries) tw_scsiop_read_write()
1757 tw_dev->max_sgl_entries = tw_dev->sgl_entries; tw_scsiop_read_write()
1759 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_read_write()
1766 tw_post_command_packet(tw_dev, request_id); tw_scsiop_read_write()
1772 static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_request_sense() argument
1782 tw_transfer_internal(tw_dev, request_id, request_buffer, tw_scsiop_request_sense()
1785 tw_dev->state[request_id] = TW_S_COMPLETED; tw_scsiop_request_sense()
1786 tw_state_request_finish(tw_dev, request_id); tw_scsiop_request_sense()
1789 tw_dev->srb[request_id]->result = (DID_ERROR << 16); tw_scsiop_request_sense()
1790 tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); tw_scsiop_request_sense()
1796 static int tw_scsiop_synchronize_cache(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_synchronize_cache() argument
1804 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_synchronize_cache()
1815 command_packet->unit__hostid = TW_UNITHOST_IN(0, tw_dev->srb[request_id]->device->id); tw_scsiop_synchronize_cache()
1819 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_synchronize_cache()
1826 tw_post_command_packet(tw_dev, request_id); tw_scsiop_synchronize_cache()
1832 static int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_test_unit_ready() argument
1842 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_scsiop_test_unit_ready()
1856 if (tw_dev->alignment_virtual_address[request_id] == NULL) { tw_scsiop_test_unit_ready()
1860 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_test_unit_ready()
1865 param_value = tw_dev->alignment_physical_address[request_id]; tw_scsiop_test_unit_ready()
1873 command_que_value = tw_dev->command_packet_physical_address[request_id]; tw_scsiop_test_unit_ready()
1880 tw_post_command_packet(tw_dev, request_id); tw_scsiop_test_unit_ready()
1886 static int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id) tw_scsiop_test_unit_ready_complete() argument
1893 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; tw_scsiop_test_unit_ready_complete()
1900 if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) { tw_scsiop_test_unit_ready_complete()
1901 tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 1; tw_scsiop_test_unit_ready_complete()
1903 tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = 0; tw_scsiop_test_unit_ready_complete()
1904 tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); tw_scsiop_test_unit_ready_complete()
1917 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; tw_scsi_queue_lck() local
1920 if (test_bit(TW_IN_RESET, &tw_dev->flags)) tw_scsi_queue_lck()
1927 tw_state_request_start(tw_dev, &request_id); tw_scsi_queue_lck()
1930 tw_dev->srb[request_id] = SCpnt; tw_scsi_queue_lck()
1938 retval = tw_scsiop_read_write(tw_dev, request_id); tw_scsi_queue_lck()
1942 retval = tw_scsiop_test_unit_ready(tw_dev, request_id); tw_scsi_queue_lck()
1946 retval = tw_scsiop_inquiry(tw_dev, request_id); tw_scsi_queue_lck()
1950 retval = tw_scsiop_read_capacity(tw_dev, request_id); tw_scsi_queue_lck()
1954 retval = tw_scsiop_request_sense(tw_dev, request_id); tw_scsi_queue_lck()
1958 retval = tw_scsiop_mode_sense(tw_dev, request_id); tw_scsi_queue_lck()
1962 retval = tw_scsiop_synchronize_cache(tw_dev, request_id); tw_scsi_queue_lck()
1968 printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); tw_scsi_queue_lck()
1969 tw_dev->state[request_id] = TW_S_COMPLETED; tw_scsi_queue_lck()
1970 tw_state_request_finish(tw_dev, request_id); tw_scsi_queue_lck()
1977 tw_dev->state[request_id] = TW_S_COMPLETED; tw_scsi_queue_lck()
1978 tw_state_request_finish(tw_dev, request_id); tw_scsi_queue_lck()
1993 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance; tw_interrupt() local
2000 spin_lock(tw_dev->host->host_lock); tw_interrupt()
2003 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_interrupt()
2012 if (test_bit(TW_IN_RESET, &tw_dev->flags)) tw_interrupt()
2018 if (tw_decode_bits(tw_dev, status_reg_value, 1)) { tw_interrupt()
2019 TW_CLEAR_ALL_INTERRUPTS(tw_dev); tw_interrupt()
2027 TW_CLEAR_HOST_INTERRUPT(tw_dev); tw_interrupt()
2033 TW_CLEAR_ATTENTION_INTERRUPT(tw_dev); tw_interrupt()
2034 tw_state_request_start(tw_dev, &request_id); tw_interrupt()
2035 error = tw_aen_read_queue(tw_dev, request_id); tw_interrupt()
2037 printk(KERN_WARNING "3w-xxxx: scsi%d: Error reading aen queue.\n", tw_dev->host->host_no); tw_interrupt()
2038 tw_dev->state[request_id] = TW_S_COMPLETED; tw_interrupt()
2039 tw_state_request_finish(tw_dev, request_id); tw_interrupt()
2046 while (tw_dev->pending_request_count > 0) { tw_interrupt()
2047 request_id = tw_dev->pending_queue[tw_dev->pending_head]; tw_interrupt()
2048 if (tw_dev->state[request_id] != TW_S_PENDING) { tw_interrupt()
2049 printk(KERN_WARNING "3w-xxxx: scsi%d: Found request id that wasn't pending.\n", tw_dev->host->host_no); tw_interrupt()
2052 if (tw_post_command_packet(tw_dev, request_id)==0) { tw_interrupt()
2053 if (tw_dev->pending_head == TW_Q_LENGTH-1) { tw_interrupt()
2054 tw_dev->pending_head = TW_Q_START; tw_interrupt()
2056 tw_dev->pending_head = tw_dev->pending_head + 1; tw_interrupt()
2058 tw_dev->pending_request_count--; tw_interrupt()
2065 if (tw_dev->pending_request_count == 0) tw_interrupt()
2066 TW_MASK_COMMAND_INTERRUPT(tw_dev); tw_interrupt()
2074 response_que.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); tw_interrupt()
2076 command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; tw_interrupt()
2082 if (tw_dev->srb[request_id] == NULL) { tw_interrupt()
2083 tw_decode_sense(tw_dev, request_id, 0); tw_interrupt()
2085 error = tw_decode_sense(tw_dev, request_id, 1); tw_interrupt()
2090 if (tw_dev->state[request_id] != TW_S_POSTED) { tw_interrupt()
2091 if (tw_dev->srb[request_id] != NULL) { tw_interrupt()
2092 printk(KERN_WARNING "3w-xxxx: scsi%d: Received a request id that wasn't posted.\n", tw_dev->host->host_no); tw_interrupt()
2100 if (tw_dev->srb[request_id] == NULL) { tw_interrupt()
2103 if (request_id != tw_dev->chrdev_request_id) { tw_interrupt()
2104 retval = tw_aen_complete(tw_dev, request_id); tw_interrupt()
2106 printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing aen.\n", tw_dev->host->host_no); tw_interrupt()
2109 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; tw_interrupt()
2110 wake_up(&tw_dev->ioctl_wqueue); tw_interrupt()
2113 switch (tw_dev->srb[request_id]->cmnd[0]) { tw_interrupt()
2124 error = tw_scsiop_test_unit_ready_complete(tw_dev, request_id); tw_interrupt()
2128 error = tw_scsiop_inquiry_complete(tw_dev, request_id); tw_interrupt()
2132 error = tw_scsiop_read_capacity_complete(tw_dev, request_id); tw_interrupt()
2136 error = tw_scsiop_mode_sense_complete(tw_dev, request_id); tw_interrupt()
2148 tw_dev->srb[request_id]->result = (DID_OK << 16); tw_interrupt()
2154 tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); tw_interrupt()
2159 scsi_dma_unmap(tw_dev->srb[request_id]); tw_interrupt()
2160 tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); tw_interrupt()
2161 tw_dev->state[request_id] = TW_S_COMPLETED; tw_interrupt()
2162 tw_state_request_finish(tw_dev, request_id); tw_interrupt()
2163 tw_dev->posted_request_count--; tw_interrupt()
2168 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); tw_interrupt()
2171 if (tw_decode_bits(tw_dev, status_reg_value, 1)) { tw_interrupt()
2172 TW_CLEAR_ALL_INTERRUPTS(tw_dev); tw_interrupt()
2180 spin_unlock(tw_dev->host->host_lock); tw_interrupt()
2185 static void __tw_shutdown(TW_Device_Extension *tw_dev) __tw_shutdown() argument
2188 TW_DISABLE_INTERRUPTS(tw_dev); __tw_shutdown()
2191 free_irq(tw_dev->tw_pci_dev->irq, tw_dev); __tw_shutdown()
2193 printk(KERN_WARNING "3w-xxxx: Shutting down host %d.\n", tw_dev->host->host_no); __tw_shutdown()
2196 if (tw_initconnection(tw_dev, 1)) { __tw_shutdown()
2203 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); __tw_shutdown()
2210 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; tw_shutdown() local
2212 __tw_shutdown(tw_dev); tw_shutdown()
2247 TW_Device_Extension *tw_dev; tw_probe() local
2270 tw_dev = (TW_Device_Extension *)host->hostdata; tw_probe()
2273 tw_dev->host = host; tw_probe()
2274 tw_dev->tw_pci_dev = pdev; tw_probe()
2276 if (tw_initialize_device_extension(tw_dev)) { tw_probe()
2289 tw_dev->base_addr = pci_resource_start(pdev, 0); tw_probe()
2290 if (!tw_dev->base_addr) { tw_probe()
2296 TW_DISABLE_INTERRUPTS(tw_dev); tw_probe()
2299 if (tw_reset_sequence(tw_dev)) tw_probe()
2319 printk(KERN_WARNING "3w-xxxx: scsi%d: Found a 3ware Storage Controller at 0x%x, IRQ: %d.\n", host->host_no, tw_dev->base_addr, pdev->irq); tw_probe()
2322 retval = request_irq(pdev->irq, tw_interrupt, IRQF_SHARED, "3w-xxxx", tw_dev); tw_probe()
2328 tw_device_extension_list[tw_device_extension_count] = tw_dev; tw_probe()
2332 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); tw_probe()
2348 tw_free_device_extension(tw_dev); tw_probe()
2360 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; tw_remove() local
2362 scsi_remove_host(tw_dev->host); tw_remove()
2371 __tw_shutdown(tw_dev); tw_remove()
2377 tw_free_device_extension(tw_dev); tw_remove()
2379 scsi_host_put(tw_dev->host); tw_remove()
H A D3w-sas.h188 #define TWL_MASK_INTERRUPTS(x) (writel(~0, TWL_HIMASK_REG_ADDR(tw_dev)))
189 #define TWL_UNMASK_INTERRUPTS(x) (writel(~TWL_HISTATUS_VALID_INTERRUPT, TWL_HIMASK_REG_ADDR(tw_dev)))
190 #define TWL_CLEAR_DB_INTERRUPT(x) (writel(~0, TWL_HOBDBC_REG_ADDR(tw_dev)))
191 #define TWL_SOFT_RESET(x) (writel(TWL_ISSUE_SOFT_RESET, TWL_HIBDB_REG_ADDR(tw_dev)))

Completed in 134 milliseconds