Lines Matching refs:tw_dev

93 static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset);
104 TW_Device_Extension *tw_dev = (TW_Device_Extension *)shost->hostdata;
111 spin_lock_irqsave(tw_dev->host->host_lock, flags);
112 ret = memory_read_from_buffer(outbuf, count, &offset, tw_dev->event_queue[0], sizeof(TW_Event) * TW_Q_LENGTH);
113 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
135 TW_Device_Extension *tw_dev = (TW_Device_Extension *)shost->hostdata;
142 spin_lock_irqsave(tw_dev->host->host_lock, flags);
143 ret = memory_read_from_buffer(outbuf, count, &offset, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info));
144 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
164 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
168 spin_lock_irqsave(tw_dev->host->host_lock, flags);
179 tw_dev->posted_request_count,
180 tw_dev->max_posted_request_count,
181 tw_dev->sgl_entries,
182 tw_dev->max_sgl_entries,
183 tw_dev->sector_count,
184 tw_dev->max_sector_count,
185 tw_dev->num_resets,
186 tw_dev->aen_count);
187 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
221 static void twl_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header)
229 tw_dev->aen_count++;
232 event = tw_dev->event_queue[tw_dev->error_index];
235 if (tw_dev->host)
236 sprintf(host, " scsi%d:", tw_dev->host->host_no);
247 event->sequence_id = tw_dev->error_sequence_id;
248 tw_dev->error_sequence_id++;
263 tw_dev->aen_count--;
265 tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH;
269 static int twl_post_command_packet(TW_Device_Extension *tw_dev, int request_id)
273 command_que_value = tw_dev->command_packet_phys[request_id];
277 writel((u32)((u64)command_que_value >> 32), TWL_HIBQPH_REG_ADDR(tw_dev));
279 writel((u32)(command_que_value | TWL_PULL_MODE), TWL_HIBQPL_REG_ADDR(tw_dev));
281 tw_dev->state[request_id] = TW_S_POSTED;
282 tw_dev->posted_request_count++;
283 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count)
284 tw_dev->max_posted_request_count = tw_dev->posted_request_count;
290 static int twl_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
301 if (tw_dev->srb[request_id]) {
302 srb = tw_dev->srb[request_id];
308 full_command_packet = tw_dev->command_packet_virt[request_id];
346 command_packet->sgl_entries__lunh = cpu_to_le16(TW_REQ_LUN_IN((srb->device->lun >> 4), scsi_sg_count(tw_dev->srb[request_id])));
359 tw_dev->sector_count = scsi_bufflen(srb) / 512;
360 if (tw_dev->sector_count > tw_dev->max_sector_count)
361 tw_dev->max_sector_count = tw_dev->sector_count;
362 tw_dev->sgl_entries = scsi_sg_count(srb);
363 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries)
364 tw_dev->max_sgl_entries = tw_dev->sgl_entries;
368 retval = twl_post_command_packet(tw_dev, request_id);
375 static int twl_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
382 full_command_packet = tw_dev->command_packet_virt[request_id];
393 sglist[0].address = tw_dev->generic_buffer_phys[request_id];
396 tw_dev->srb[request_id] = NULL;
399 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
400 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Post failed while reading AEN queue");
409 static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
418 full_command_packet = tw_dev->command_packet_virt[request_id];
423 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
429 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
444 tw_dev->srb[request_id] = NULL;
447 twl_post_command_packet(tw_dev, request_id);
451 static void twl_get_request_id(TW_Device_Extension *tw_dev, int *request_id)
453 *request_id = tw_dev->free_queue[tw_dev->free_head];
454 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH;
455 tw_dev->state[*request_id] = TW_S_STARTED;
459 static void twl_free_request_id(TW_Device_Extension *tw_dev, int request_id)
461 tw_dev->free_queue[tw_dev->free_tail] = request_id;
462 tw_dev->state[request_id] = TW_S_FINISHED;
463 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH;
467 static int twl_aen_complete(TW_Device_Extension *tw_dev, int request_id)
475 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
476 tw_dev->posted_request_count--;
478 full_command_packet = tw_dev->command_packet_virt[request_id];
484 if (twl_aen_read_queue(tw_dev, request_id))
497 twl_aen_sync_time(tw_dev, request_id);
501 twl_aen_queue_event(tw_dev, header);
504 if (twl_aen_read_queue(tw_dev, request_id))
513 tw_dev->state[request_id] = TW_S_COMPLETED;
514 twl_free_request_id(tw_dev, request_id);
515 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
521 static int twl_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds)
534 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev));
535 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
538 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
556 static int twl_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset)
572 full_command_packet = tw_dev->command_packet_virt[request_id];
583 sglist[0].address = tw_dev->generic_buffer_phys[request_id];
586 tw_dev->srb[request_id] = NULL;
590 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
591 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "Error posting request sense");
596 if (twl_poll_response(tw_dev, request_id, 30)) {
597 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "No valid response while draining AEN queue");
598 tw_dev->posted_request_count--;
602 tw_dev->posted_request_count--;
603 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
629 twl_aen_queue_event(tw_dev, header);
637 tw_dev->state[request_id] = TW_S_INITIAL;
642 static int twl_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
649 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev,
653 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
660 tw_dev->command_packet_phys[i] = dma_handle+(i*size);
661 tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size));
664 tw_dev->generic_buffer_phys[i] = dma_handle+(i*size);
665 tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size));
668 tw_dev->sense_buffer_phys[i] = dma_handle+(i*size);
669 tw_dev->sense_buffer_virt[i] = (TW_Command_Apache_Header *)((unsigned char *)cpu_addr + (i*size));
679 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)
726 TW_Device_Extension *tw_dev = twl_device_extension_list[iminor(inode)];
733 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
752 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);
767 spin_lock_irqsave(tw_dev->host->host_lock, flags);
768 twl_get_request_id(tw_dev, &request_id);
771 tw_dev->srb[request_id] = NULL;
774 tw_dev->chrdev_request_id = request_id;
779 twl_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted);
781 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full));
784 twl_post_command_packet(tw_dev, request_id);
785 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
790 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
793 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
796 tw_dev->host->host_no, TW_DRIVER, 0x6,
799 twl_reset_device_extension(tw_dev, 1);
804 memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_Full));
807 spin_lock_irqsave(tw_dev->host->host_lock, flags);
808 tw_dev->posted_request_count--;
809 tw_dev->state[request_id] = TW_S_COMPLETED;
810 twl_free_request_id(tw_dev, request_id);
811 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
823 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle);
825 mutex_unlock(&tw_dev->ioctl_lock);
860 static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, int copy_sense, int print_host)
868 header = tw_dev->sense_buffer_virt[i];
869 full_command_packet = tw_dev->command_packet_virt[request_id];
879 tw_dev->host->host_no,
893 memcpy(tw_dev->srb[request_id]->sense_buffer, header->sense_data, TW_SENSE_DATA_LENGTH);
894 tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
902 static void twl_free_device_extension(TW_Device_Extension *tw_dev)
904 if (tw_dev->command_packet_virt[0])
905 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
907 tw_dev->command_packet_virt[0],
908 tw_dev->command_packet_phys[0]);
910 if (tw_dev->generic_buffer_virt[0])
911 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
913 tw_dev->generic_buffer_virt[0],
914 tw_dev->generic_buffer_phys[0]);
916 if (tw_dev->sense_buffer_virt[0])
917 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
920 tw_dev->sense_buffer_virt[0],
921 tw_dev->sense_buffer_phys[0]);
923 kfree(tw_dev->event_queue[0]);
927 static void *twl_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes)
935 full_command_packet = tw_dev->command_packet_virt[request_id];
945 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
951 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
955 twl_post_command_packet(tw_dev, request_id);
958 if (twl_poll_response(tw_dev, request_id, 30))
959 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "No valid response during get param")
963 tw_dev->posted_request_count--;
964 tw_dev->state[request_id] = TW_S_INITIAL;
970 static int twl_initconnection(TW_Device_Extension *tw_dev, int message_credits,
986 full_command_packet = tw_dev->command_packet_virt[request_id];
1011 twl_post_command_packet(tw_dev, request_id);
1014 if (twl_poll_response(tw_dev, request_id, 30)) {
1015 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x8, "No valid response during init connection");
1027 tw_dev->posted_request_count--;
1028 tw_dev->state[request_id] = TW_S_INITIAL;
1034 static int twl_initialize_device_extension(TW_Device_Extension *tw_dev)
1039 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) {
1040 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x9, "Command packet memory allocation failed");
1045 if (twl_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) {
1046 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Generic memory allocation failed");
1051 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Apache_Header), 2)) {
1052 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xb, "Sense buffer allocation failed");
1057 tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL);
1058 if (!tw_dev->event_queue[0]) {
1059 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "Event info memory allocation failed");
1064 tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event)));
1065 tw_dev->free_queue[i] = i;
1066 tw_dev->state[i] = TW_S_INITIAL;
1069 tw_dev->free_head = TW_Q_START;
1070 tw_dev->free_tail = TW_Q_START;
1071 tw_dev->error_sequence_id = 1;
1072 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1074 mutex_init(&tw_dev->ioctl_lock);
1075 init_waitqueue_head(&tw_dev->ioctl_wqueue);
1083 static int twl_handle_attention_interrupt(TW_Device_Extension *tw_dev)
1089 doorbell = readl(TWL_HOBDB_REG_ADDR(tw_dev));
1093 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "Microcontroller Error: clearing");
1099 if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) {
1100 twl_get_request_id(tw_dev, &request_id);
1101 if (twl_aen_read_queue(tw_dev, request_id)) {
1102 tw_dev->state[request_id] = TW_S_COMPLETED;
1103 twl_free_request_id(tw_dev, request_id);
1104 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
1112 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1115 readl(TWL_HOBDBC_REG_ADDR(tw_dev));
1123 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
1130 spin_lock(tw_dev->host->host_lock);
1133 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev));
1142 if (test_bit(TW_IN_RESET, &tw_dev->flags))
1147 if (twl_handle_attention_interrupt(tw_dev)) {
1148 TWL_MASK_INTERRUPTS(tw_dev);
1156 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev));
1157 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
1160 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
1168 if (tw_dev->sense_buffer_phys[i] == mfa) {
1169 request_id = le16_to_cpu(tw_dev->sense_buffer_virt[i]->header_desc.request_id);
1170 if (tw_dev->srb[request_id] != NULL)
1171 error = twl_fill_sense(tw_dev, i, request_id, 1, 1);
1174 if (request_id != tw_dev->chrdev_request_id)
1175 error = twl_fill_sense(tw_dev, i, request_id, 0, 1);
1177 memcpy(tw_dev->command_packet_virt[request_id], tw_dev->sense_buffer_virt[i], sizeof(TW_Command_Apache_Header));
1181 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev));
1182 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev));
1189 full_command_packet = tw_dev->command_packet_virt[request_id];
1192 if (tw_dev->state[request_id] != TW_S_POSTED) {
1193 if (tw_dev->srb[request_id] != NULL) {
1194 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Received a request id that wasn't posted");
1195 TWL_MASK_INTERRUPTS(tw_dev);
1201 if (tw_dev->srb[request_id] == NULL) {
1202 if (request_id != tw_dev->chrdev_request_id) {
1203 if (twl_aen_complete(tw_dev, request_id))
1204 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "Error completing AEN during attention interrupt");
1206 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1207 wake_up(&tw_dev->ioctl_wqueue);
1210 cmd = tw_dev->srb[request_id];
1217 if (full_command_packet->command.newcommand.sg_list[0].length < scsi_bufflen(tw_dev->srb[request_id]))
1224 tw_dev->state[request_id] = TW_S_COMPLETED;
1225 twl_free_request_id(tw_dev, request_id);
1226 tw_dev->posted_request_count--;
1230 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev));
1234 spin_unlock(tw_dev->host->host_lock);
1239 static int twl_poll_register(TW_Device_Extension *tw_dev, void *reg, u32 value, u32 result, int seconds)
1260 static int twl_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
1274 TWL_SOFT_RESET(tw_dev);
1277 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, 0x0, 30)) {
1278 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Controller never went non-ready during reset sequence");
1282 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, TWL_CONTROLLER_READY, 60)) {
1283 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x11, "Controller not ready during reset sequence");
1290 if (twl_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS,
1296 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x12, "Initconnection failed while checking SRL");
1304 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev));
1305 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev));
1308 status = readl(TWL_STATUS_REG_ADDR(tw_dev));
1314 status = readl(TWL_STATUS_REG_ADDR(tw_dev));
1316 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "Bad controller status after loading sense buffers");
1323 if (twl_aen_drain_queue(tw_dev, soft_reset)) {
1324 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x14, "AEN drain failed during reset sequence");
1331 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
1332 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
1333 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
1334 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
1335 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL;
1336 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH;
1337 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD;
1338 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl;
1339 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch;
1340 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build;
1351 static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset)
1358 scsi_block_requests(tw_dev->host);
1360 set_bit(TW_IN_RESET, &tw_dev->flags);
1361 TWL_MASK_INTERRUPTS(tw_dev);
1362 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1364 spin_lock_irqsave(tw_dev->host->host_lock, flags);
1368 if ((tw_dev->state[i] != TW_S_FINISHED) &&
1369 (tw_dev->state[i] != TW_S_INITIAL) &&
1370 (tw_dev->state[i] != TW_S_COMPLETED)) {
1371 struct scsi_cmnd *cmd = tw_dev->srb[i];
1383 tw_dev->free_queue[i] = i;
1384 tw_dev->state[i] = TW_S_INITIAL;
1386 tw_dev->free_head = TW_Q_START;
1387 tw_dev->free_tail = TW_Q_START;
1388 tw_dev->posted_request_count = 0;
1390 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
1392 if (twl_reset_sequence(tw_dev, 1))
1395 TWL_UNMASK_INTERRUPTS(tw_dev);
1397 clear_bit(TW_IN_RESET, &tw_dev->flags);
1398 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1403 scsi_unblock_requests(tw_dev->host);
1411 TW_Device_Extension *tw_dev;
1413 tw_dev = (TW_Device_Extension *)sdev->host->hostdata;
1433 TW_Device_Extension *tw_dev = NULL;
1436 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1438 tw_dev->num_resets++;
1445 mutex_lock(&tw_dev->ioctl_lock);
1448 if (twl_reset_device_extension(tw_dev, 0)) {
1449 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "Controller reset failed during scsi host reset");
1455 mutex_unlock(&tw_dev->ioctl_lock);
1463 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1466 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
1475 twl_get_request_id(tw_dev, &request_id);
1478 tw_dev->srb[request_id] = SCpnt;
1480 retval = twl_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
1482 tw_dev->state[request_id] = TW_S_COMPLETED;
1483 twl_free_request_id(tw_dev, request_id);
1495 static void __twl_shutdown(TW_Device_Extension *tw_dev)
1498 TWL_MASK_INTERRUPTS(tw_dev);
1501 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1503 printk(KERN_WARNING "3w-sas: Shutting down host %d.\n", tw_dev->host->host_no);
1506 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) {
1507 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Connection shutdown failed");
1513 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1520 TW_Device_Extension *tw_dev;
1525 tw_dev = (TW_Device_Extension *)host->hostdata;
1527 if (tw_dev->online)
1528 __twl_shutdown(tw_dev);
1563 TW_Device_Extension *tw_dev;
1591 tw_dev = shost_priv(host);
1594 tw_dev->host = host;
1595 tw_dev->tw_pci_dev = pdev;
1597 if (twl_initialize_device_extension(tw_dev)) {
1598 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension");
1606 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Failed to get mem region");
1611 tw_dev->base_addr = pci_iomap(pdev, 1, 0);
1612 if (!tw_dev->base_addr) {
1613 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap");
1619 TWL_MASK_INTERRUPTS(tw_dev);
1622 if (twl_reset_sequence(tw_dev, 0)) {
1623 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe");
1637 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "scsi add host failed");
1645 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE,
1649 ptr_phycount = twl_get_param(tw_dev, 2, TW_PARAM_PHY_SUMMARY_TABLE,
1656 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE,
1658 (char *)twl_get_param(tw_dev, 2, TW_VERSION_TABLE,
1664 set_bit(TW_USING_MSI, &tw_dev->flags);
1667 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev);
1669 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Error requesting IRQ");
1673 twl_device_extension_list[twl_device_extension_count] = tw_dev;
1677 TWL_UNMASK_INTERRUPTS(tw_dev);
1684 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Failed to create sysfs binary file: 3ware_aen_read");
1686 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Failed to create sysfs binary file: 3ware_compat_info");
1692 tw_dev->online = 1;
1696 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1700 iounmap(tw_dev->base_addr);
1704 twl_free_device_extension(tw_dev);
1716 TW_Device_Extension *tw_dev;
1721 tw_dev = (TW_Device_Extension *)host->hostdata;
1723 if (!tw_dev->online)
1730 scsi_remove_host(tw_dev->host);
1739 __twl_shutdown(tw_dev);
1742 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1746 iounmap(tw_dev->base_addr);
1752 twl_free_device_extension(tw_dev);
1754 scsi_host_put(tw_dev->host);
1764 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
1766 printk(KERN_WARNING "3w-sas: Suspending host %d.\n", tw_dev->host->host_no);
1768 TWL_MASK_INTERRUPTS(tw_dev);
1770 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1773 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) {
1774 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x23, "Connection shutdown failed during suspend");
1780 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1794 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
1796 printk(KERN_WARNING "3w-sas: Resuming host %d.\n", tw_dev->host->host_no);
1803 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x24, "Enable device failed during resume");
1820 if (twl_reset_sequence(tw_dev, 0)) {
1826 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev);
1828 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Error requesting IRQ during resume");
1834 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1838 TWL_UNMASK_INTERRUPTS(tw_dev);