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);
223 static void twl_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header)
231 tw_dev->aen_count++;
234 event = tw_dev->event_queue[tw_dev->error_index];
237 if (tw_dev->host)
238 sprintf(host, " scsi%d:", tw_dev->host->host_no);
249 event->sequence_id = tw_dev->error_sequence_id;
250 tw_dev->error_sequence_id++;
265 tw_dev->aen_count--;
267 tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH;
271 static int twl_post_command_packet(TW_Device_Extension *tw_dev, int request_id)
275 command_que_value = tw_dev->command_packet_phys[request_id];
279 writel((u32)((u64)command_que_value >> 32), TWL_HIBQPH_REG_ADDR(tw_dev));
281 writel((u32)(command_que_value | TWL_PULL_MODE), TWL_HIBQPL_REG_ADDR(tw_dev));
283 tw_dev->state[request_id] = TW_S_POSTED;
284 tw_dev->posted_request_count++;
285 if (tw_dev->posted_request_count > tw_dev->max_posted_request_count)
286 tw_dev->max_posted_request_count = tw_dev->posted_request_count;
292 static int twl_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
303 if (tw_dev->srb[request_id])
304 srb = tw_dev->srb[request_id];
307 full_command_packet = tw_dev->command_packet_virt[request_id];
345 command_packet->sgl_entries__lunh = cpu_to_le16(TW_REQ_LUN_IN((srb->device->lun >> 4), scsi_sg_count(tw_dev->srb[request_id])));
358 tw_dev->sector_count = scsi_bufflen(srb) / 512;
359 if (tw_dev->sector_count > tw_dev->max_sector_count)
360 tw_dev->max_sector_count = tw_dev->sector_count;
361 tw_dev->sgl_entries = scsi_sg_count(srb);
362 if (tw_dev->sgl_entries > tw_dev->max_sgl_entries)
363 tw_dev->max_sgl_entries = tw_dev->sgl_entries;
367 retval = twl_post_command_packet(tw_dev, request_id);
374 static int twl_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
381 full_command_packet = tw_dev->command_packet_virt[request_id];
392 sglist[0].address = tw_dev->generic_buffer_phys[request_id];
395 tw_dev->srb[request_id] = NULL;
398 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
399 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Post failed while reading AEN queue");
408 static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
417 full_command_packet = tw_dev->command_packet_virt[request_id];
422 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
428 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
443 tw_dev->srb[request_id] = NULL;
446 twl_post_command_packet(tw_dev, request_id);
450 static void twl_get_request_id(TW_Device_Extension *tw_dev, int *request_id)
452 *request_id = tw_dev->free_queue[tw_dev->free_head];
453 tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH;
454 tw_dev->state[*request_id] = TW_S_STARTED;
458 static void twl_free_request_id(TW_Device_Extension *tw_dev, int request_id)
460 tw_dev->free_queue[tw_dev->free_tail] = request_id;
461 tw_dev->state[request_id] = TW_S_FINISHED;
462 tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH;
466 static int twl_aen_complete(TW_Device_Extension *tw_dev, int request_id)
474 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
475 tw_dev->posted_request_count--;
477 full_command_packet = tw_dev->command_packet_virt[request_id];
483 if (twl_aen_read_queue(tw_dev, request_id))
496 twl_aen_sync_time(tw_dev, request_id);
500 twl_aen_queue_event(tw_dev, header);
503 if (twl_aen_read_queue(tw_dev, request_id))
512 tw_dev->state[request_id] = TW_S_COMPLETED;
513 twl_free_request_id(tw_dev, request_id);
514 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
520 static int twl_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds)
533 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev));
534 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
537 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
555 static int twl_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset)
571 full_command_packet = tw_dev->command_packet_virt[request_id];
582 sglist[0].address = tw_dev->generic_buffer_phys[request_id];
585 tw_dev->srb[request_id] = NULL;
589 if (twl_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
590 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "Error posting request sense");
595 if (twl_poll_response(tw_dev, request_id, 30)) {
596 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "No valid response while draining AEN queue");
597 tw_dev->posted_request_count--;
601 tw_dev->posted_request_count--;
602 header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
628 twl_aen_queue_event(tw_dev, header);
636 tw_dev->state[request_id] = TW_S_INITIAL;
641 static int twl_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
648 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev,
652 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
659 tw_dev->command_packet_phys[i] = dma_handle+(i*size);
660 tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size));
663 tw_dev->generic_buffer_phys[i] = dma_handle+(i*size);
664 tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size));
667 tw_dev->sense_buffer_phys[i] = dma_handle+(i*size);
668 tw_dev->sense_buffer_virt[i] = (TW_Command_Apache_Header *)((unsigned char *)cpu_addr + (i*size));
678 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)
725 TW_Device_Extension *tw_dev = twl_device_extension_list[iminor(inode)];
732 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
751 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted + sizeof(TW_Ioctl_Buf_Apache), &dma_handle, GFP_KERNEL);
766 spin_lock_irqsave(tw_dev->host->host_lock, flags);
767 twl_get_request_id(tw_dev, &request_id);
770 tw_dev->srb[request_id] = NULL;
773 tw_dev->chrdev_request_id = request_id;
778 twl_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted);
780 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full));
783 twl_post_command_packet(tw_dev, request_id);
784 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
789 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
792 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
795 tw_dev->host->host_no, TW_DRIVER, 0x6,
798 twl_reset_device_extension(tw_dev, 1);
803 memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_Full));
806 spin_lock_irqsave(tw_dev->host->host_lock, flags);
807 tw_dev->posted_request_count--;
808 tw_dev->state[request_id] = TW_S_COMPLETED;
809 twl_free_request_id(tw_dev, request_id);
810 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
822 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted + sizeof(TW_Ioctl_Buf_Apache), cpu_addr, dma_handle);
824 mutex_unlock(&tw_dev->ioctl_lock);
859 static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, int copy_sense, int print_host)
866 header = tw_dev->sense_buffer_virt[i];
867 full_command_packet = tw_dev->command_packet_virt[request_id];
877 tw_dev->host->host_no,
891 memcpy(tw_dev->srb[request_id]->sense_buffer, header->sense_data, TW_SENSE_DATA_LENGTH);
892 tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
900 static void twl_free_device_extension(TW_Device_Extension *tw_dev)
902 if (tw_dev->command_packet_virt[0])
903 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
905 tw_dev->command_packet_virt[0],
906 tw_dev->command_packet_phys[0]);
908 if (tw_dev->generic_buffer_virt[0])
909 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
911 tw_dev->generic_buffer_virt[0],
912 tw_dev->generic_buffer_phys[0]);
914 if (tw_dev->sense_buffer_virt[0])
915 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
918 tw_dev->sense_buffer_virt[0],
919 tw_dev->sense_buffer_phys[0]);
921 kfree(tw_dev->event_queue[0]);
925 static void *twl_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes)
933 full_command_packet = tw_dev->command_packet_virt[request_id];
943 param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
949 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
953 twl_post_command_packet(tw_dev, request_id);
956 if (twl_poll_response(tw_dev, request_id, 30))
957 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "No valid response during get param")
961 tw_dev->posted_request_count--;
962 tw_dev->state[request_id] = TW_S_INITIAL;
968 static int twl_initconnection(TW_Device_Extension *tw_dev, int message_credits,
984 full_command_packet = tw_dev->command_packet_virt[request_id];
1009 twl_post_command_packet(tw_dev, request_id);
1012 if (twl_poll_response(tw_dev, request_id, 30)) {
1013 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x8, "No valid response during init connection");
1025 tw_dev->posted_request_count--;
1026 tw_dev->state[request_id] = TW_S_INITIAL;
1032 static int twl_initialize_device_extension(TW_Device_Extension *tw_dev)
1037 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) {
1038 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x9, "Command packet memory allocation failed");
1043 if (twl_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) {
1044 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Generic memory allocation failed");
1049 if (twl_allocate_memory(tw_dev, sizeof(TW_Command_Apache_Header), 2)) {
1050 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xb, "Sense buffer allocation failed");
1055 tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL);
1056 if (!tw_dev->event_queue[0]) {
1057 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "Event info memory allocation failed");
1062 tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event)));
1063 tw_dev->free_queue[i] = i;
1064 tw_dev->state[i] = TW_S_INITIAL;
1067 tw_dev->free_head = TW_Q_START;
1068 tw_dev->free_tail = TW_Q_START;
1069 tw_dev->error_sequence_id = 1;
1070 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1072 mutex_init(&tw_dev->ioctl_lock);
1073 init_waitqueue_head(&tw_dev->ioctl_wqueue);
1081 static int twl_handle_attention_interrupt(TW_Device_Extension *tw_dev)
1087 doorbell = readl(TWL_HOBDB_REG_ADDR(tw_dev));
1091 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "Microcontroller Error: clearing");
1097 if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) {
1098 twl_get_request_id(tw_dev, &request_id);
1099 if (twl_aen_read_queue(tw_dev, request_id)) {
1100 tw_dev->state[request_id] = TW_S_COMPLETED;
1101 twl_free_request_id(tw_dev, request_id);
1102 clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
1110 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1113 readl(TWL_HOBDBC_REG_ADDR(tw_dev));
1121 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
1128 spin_lock(tw_dev->host->host_lock);
1131 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev));
1140 if (test_bit(TW_IN_RESET, &tw_dev->flags))
1145 if (twl_handle_attention_interrupt(tw_dev)) {
1146 TWL_MASK_INTERRUPTS(tw_dev);
1154 regh = readl(TWL_HOBQPH_REG_ADDR(tw_dev));
1155 regl = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
1158 mfa = readl(TWL_HOBQPL_REG_ADDR(tw_dev));
1166 if (tw_dev->sense_buffer_phys[i] == mfa) {
1167 request_id = le16_to_cpu(tw_dev->sense_buffer_virt[i]->header_desc.request_id);
1168 if (tw_dev->srb[request_id] != NULL)
1169 error = twl_fill_sense(tw_dev, i, request_id, 1, 1);
1172 if (request_id != tw_dev->chrdev_request_id)
1173 error = twl_fill_sense(tw_dev, i, request_id, 0, 1);
1175 memcpy(tw_dev->command_packet_virt[request_id], tw_dev->sense_buffer_virt[i], sizeof(TW_Command_Apache_Header));
1179 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev));
1180 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev));
1187 full_command_packet = tw_dev->command_packet_virt[request_id];
1190 if (tw_dev->state[request_id] != TW_S_POSTED) {
1191 if (tw_dev->srb[request_id] != NULL) {
1192 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Received a request id that wasn't posted");
1193 TWL_MASK_INTERRUPTS(tw_dev);
1199 if (tw_dev->srb[request_id] == NULL) {
1200 if (request_id != tw_dev->chrdev_request_id) {
1201 if (twl_aen_complete(tw_dev, request_id))
1202 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "Error completing AEN during attention interrupt");
1204 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1205 wake_up(&tw_dev->ioctl_wqueue);
1208 cmd = tw_dev->srb[request_id];
1215 if (full_command_packet->command.newcommand.sg_list[0].length < scsi_bufflen(tw_dev->srb[request_id]))
1222 tw_dev->state[request_id] = TW_S_COMPLETED;
1223 twl_free_request_id(tw_dev, request_id);
1224 tw_dev->posted_request_count--;
1228 reg = readl(TWL_HISTAT_REG_ADDR(tw_dev));
1232 spin_unlock(tw_dev->host->host_lock);
1237 static int twl_poll_register(TW_Device_Extension *tw_dev, void *reg, u32 value, u32 result, int seconds)
1258 static int twl_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
1272 TWL_SOFT_RESET(tw_dev);
1275 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, 0x0, 30)) {
1276 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Controller never went non-ready during reset sequence");
1280 if (twl_poll_register(tw_dev, TWL_SCRPD3_REG_ADDR(tw_dev), TWL_CONTROLLER_READY, TWL_CONTROLLER_READY, 60)) {
1281 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x11, "Controller not ready during reset sequence");
1288 if (twl_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS,
1294 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x12, "Initconnection failed while checking SRL");
1302 writel((u32)((u64)tw_dev->sense_buffer_phys[i] >> 32), TWL_HOBQPH_REG_ADDR(tw_dev));
1303 writel((u32)tw_dev->sense_buffer_phys[i], TWL_HOBQPL_REG_ADDR(tw_dev));
1306 status = readl(TWL_STATUS_REG_ADDR(tw_dev));
1312 status = readl(TWL_STATUS_REG_ADDR(tw_dev));
1314 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "Bad controller status after loading sense buffers");
1321 if (twl_aen_drain_queue(tw_dev, soft_reset)) {
1322 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x14, "AEN drain failed during reset sequence");
1329 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
1330 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
1331 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
1332 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
1333 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL;
1334 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH;
1335 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD;
1336 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl;
1337 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch;
1338 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build;
1349 static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset)
1356 scsi_block_requests(tw_dev->host);
1358 set_bit(TW_IN_RESET, &tw_dev->flags);
1359 TWL_MASK_INTERRUPTS(tw_dev);
1360 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1362 spin_lock_irqsave(tw_dev->host->host_lock, flags);
1366 if ((tw_dev->state[i] != TW_S_FINISHED) &&
1367 (tw_dev->state[i] != TW_S_INITIAL) &&
1368 (tw_dev->state[i] != TW_S_COMPLETED)) {
1369 struct scsi_cmnd *cmd = tw_dev->srb[i];
1381 tw_dev->free_queue[i] = i;
1382 tw_dev->state[i] = TW_S_INITIAL;
1384 tw_dev->free_head = TW_Q_START;
1385 tw_dev->free_tail = TW_Q_START;
1386 tw_dev->posted_request_count = 0;
1388 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
1390 if (twl_reset_sequence(tw_dev, 1))
1393 TWL_UNMASK_INTERRUPTS(tw_dev);
1395 clear_bit(TW_IN_RESET, &tw_dev->flags);
1396 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1401 scsi_unblock_requests(tw_dev->host);
1428 TW_Device_Extension *tw_dev = NULL;
1431 tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1433 tw_dev->num_resets++;
1440 mutex_lock(&tw_dev->ioctl_lock);
1443 if (twl_reset_device_extension(tw_dev, 0)) {
1444 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "Controller reset failed during scsi host reset");
1450 mutex_unlock(&tw_dev->ioctl_lock);
1459 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1462 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
1468 twl_get_request_id(tw_dev, &request_id);
1471 tw_dev->srb[request_id] = SCpnt;
1473 retval = twl_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
1475 tw_dev->state[request_id] = TW_S_COMPLETED;
1476 twl_free_request_id(tw_dev, request_id);
1488 static void __twl_shutdown(TW_Device_Extension *tw_dev)
1491 TWL_MASK_INTERRUPTS(tw_dev);
1494 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1496 printk(KERN_WARNING "3w-sas: Shutting down host %d.\n", tw_dev->host->host_no);
1499 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) {
1500 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Connection shutdown failed");
1506 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1513 TW_Device_Extension *tw_dev;
1518 tw_dev = (TW_Device_Extension *)host->hostdata;
1520 if (tw_dev->online)
1521 __twl_shutdown(tw_dev);
1555 TW_Device_Extension *tw_dev;
1581 tw_dev = shost_priv(host);
1584 tw_dev->host = host;
1585 tw_dev->tw_pci_dev = pdev;
1587 if (twl_initialize_device_extension(tw_dev)) {
1588 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension");
1596 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Failed to get mem region");
1601 tw_dev->base_addr = pci_iomap(pdev, 1, 0);
1602 if (!tw_dev->base_addr) {
1603 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap");
1609 TWL_MASK_INTERRUPTS(tw_dev);
1612 if (twl_reset_sequence(tw_dev, 0)) {
1613 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe");
1627 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "scsi add host failed");
1635 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE,
1639 ptr_phycount = twl_get_param(tw_dev, 2, TW_PARAM_PHY_SUMMARY_TABLE,
1646 (char *)twl_get_param(tw_dev, 1, TW_VERSION_TABLE,
1648 (char *)twl_get_param(tw_dev, 2, TW_VERSION_TABLE,
1654 set_bit(TW_USING_MSI, &tw_dev->flags);
1657 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev);
1659 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Error requesting IRQ");
1663 twl_device_extension_list[twl_device_extension_count] = tw_dev;
1667 TWL_UNMASK_INTERRUPTS(tw_dev);
1674 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Failed to create sysfs binary file: 3ware_aen_read");
1676 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Failed to create sysfs binary file: 3ware_compat_info");
1682 tw_dev->online = 1;
1686 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1690 iounmap(tw_dev->base_addr);
1694 twl_free_device_extension(tw_dev);
1706 TW_Device_Extension *tw_dev;
1711 tw_dev = (TW_Device_Extension *)host->hostdata;
1713 if (!tw_dev->online)
1720 scsi_remove_host(tw_dev->host);
1729 __twl_shutdown(tw_dev);
1732 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1736 iounmap(tw_dev->base_addr);
1742 twl_free_device_extension(tw_dev);
1744 scsi_host_put(tw_dev->host);
1753 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
1755 printk(KERN_WARNING "3w-sas: Suspending host %d.\n", tw_dev->host->host_no);
1757 TWL_MASK_INTERRUPTS(tw_dev);
1759 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1762 if (twl_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) {
1763 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x23, "Connection shutdown failed during suspend");
1769 TWL_CLEAR_DB_INTERRUPT(tw_dev);
1780 TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
1782 printk(KERN_WARNING "3w-sas: Resuming host %d.\n", tw_dev->host->host_no);
1793 if (twl_reset_sequence(tw_dev, 0)) {
1799 retval = request_irq(pdev->irq, twl_interrupt, IRQF_SHARED, "3w-sas", tw_dev);
1801 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Error requesting IRQ during resume");
1807 if (test_bit(TW_USING_MSI, &tw_dev->flags))
1811 TWL_UNMASK_INTERRUPTS(tw_dev);