Lines Matching refs:h
238 static int hpsa_add_sas_host(struct ctlr_info *h);
239 static void hpsa_delete_sas_host(struct ctlr_info *h);
244 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
257 static int hpsa_passthru_ioctl(struct ctlr_info *h,
259 static int hpsa_big_passthru_ioctl(struct ctlr_info *h,
267 static void cmd_free(struct ctlr_info *h, struct CommandList *c);
268 static struct CommandList *cmd_alloc(struct ctlr_info *h);
269 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c);
270 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
272 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
275 static void hpsa_free_cmd_pool(struct ctlr_info *h);
279 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
290 static void hpsa_update_scsi_devices(struct ctlr_info *h);
291 static int check_for_unit_attention(struct ctlr_info *h,
293 static void check_ioctl_unit_attention(struct ctlr_info *h,
298 static void hpsa_free_performant_mode(struct ctlr_info *h);
299 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
300 static inline u32 next_command(struct ctlr_info *h, u8 q);
308 static int wait_for_device_to_become_ready(struct ctlr_info *h,
314 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
317 static void hpsa_drain_accel_commands(struct ctlr_info *h);
318 static void hpsa_flush_cache(struct ctlr_info *h);
319 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
323 static u32 lockup_detected(struct ctlr_info *h);
324 static int detect_controller_lockup(struct ctlr_info *h);
325 static void hpsa_disable_rld_caching(struct ctlr_info *h);
326 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
328 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
330 static int hpsa_luns_changed(struct ctlr_info *h);
331 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
374 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
392 dev_warn(&h->pdev->dev, in check_for_unit_attention()
394 h->devname); in check_for_unit_attention()
397 dev_warn(&h->pdev->dev, in check_for_unit_attention()
398 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
401 dev_warn(&h->pdev->dev, in check_for_unit_attention()
402 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
409 dev_warn(&h->pdev->dev, in check_for_unit_attention()
411 h->devname); in check_for_unit_attention()
414 dev_warn(&h->pdev->dev, in check_for_unit_attention()
416 h->devname); in check_for_unit_attention()
419 dev_warn(&h->pdev->dev, in check_for_unit_attention()
421 h->devname); in check_for_unit_attention()
427 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
433 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
437 static u32 lockup_detected(struct ctlr_info *h);
442 struct ctlr_info *h; in host_show_lockup_detected() local
445 h = shost_to_hba(shost); in host_show_lockup_detected()
446 ld = lockup_detected(h); in host_show_lockup_detected()
456 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
467 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
468 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
469 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
471 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
480 struct ctlr_info *h; in host_store_raid_offload_debug() local
493 h = shost_to_hba(shost); in host_store_raid_offload_debug()
494 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
495 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
496 h->raid_offload_debug); in host_store_raid_offload_debug()
504 struct ctlr_info *h; in host_store_rescan() local
506 h = shost_to_hba(shost); in host_store_rescan()
507 hpsa_scan_start(h->scsi_host); in host_store_rescan()
520 struct ctlr_info *h; in host_show_firmware_revision() local
524 h = shost_to_hba(shost); in host_show_firmware_revision()
525 if (!h->hba_inquiry_data) in host_show_firmware_revision()
527 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
536 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
539 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
545 struct ctlr_info *h; in host_show_transport_mode() local
548 h = shost_to_hba(shost); in host_show_transport_mode()
550 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
557 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
560 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
562 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
641 struct ctlr_info *h; in host_show_resettable() local
644 h = shost_to_hba(shost); in host_show_resettable()
645 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
676 struct ctlr_info *h; in raid_level_show() local
682 h = sdev_to_hba(sdev); in raid_level_show()
683 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
686 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
692 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
698 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
708 struct ctlr_info *h; in lunid_show() local
715 h = sdev_to_hba(sdev); in lunid_show()
716 spin_lock_irqsave(&h->lock, flags); in lunid_show()
719 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
723 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
730 struct ctlr_info *h; in unique_id_show() local
737 h = sdev_to_hba(sdev); in unique_id_show()
738 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
741 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
745 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
758 struct ctlr_info *h; in sas_address_show() local
765 h = sdev_to_hba(sdev); in sas_address_show()
766 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
769 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
773 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
781 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
788 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
789 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
792 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
796 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
809 struct ctlr_info *h; in path_info_show() local
822 h = sdev_to_hba(sdev); in path_info_show()
823 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
826 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
843 h->scsi_host->host_no, in path_info_show()
887 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
894 struct ctlr_info *h; in host_show_ctlr_num() local
897 h = shost_to_hba(shost); in host_show_ctlr_num()
898 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
904 struct ctlr_info *h; in host_show_legacy_board() local
907 h = shost_to_hba(shost); in host_show_legacy_board()
908 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
993 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
996 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
998 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
999 return h->access.command_completed(h, q); in next_command()
1001 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
1002 return h->access.command_completed(h, q); in next_command()
1007 atomic_dec(&h->commands_outstanding); in next_command()
1012 if (rq->current_entry == h->max_commands) { in next_command()
1051 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1054 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1055 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1056 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1062 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1066 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1079 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1083 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1088 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1099 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1102 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1106 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1119 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1135 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1140 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1141 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1144 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1148 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1149 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1152 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1155 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1156 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1163 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1166 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1167 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1170 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1171 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1174 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1175 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1178 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1179 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1183 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1185 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1193 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1195 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1197 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1202 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1213 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1214 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1215 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1228 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1234 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1270 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1272 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1284 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1289 int n = h->ndevices; in hpsa_scsi_add_entry()
1295 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1311 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1327 sd = h->dev[i]; in hpsa_scsi_add_entry()
1340 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1348 h->dev[n] = device; in hpsa_scsi_add_entry()
1349 h->ndevices++; in hpsa_scsi_add_entry()
1352 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1362 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1369 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1374 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1386 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1387 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1390 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1393 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1394 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1395 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1396 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1403 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1409 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1411 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1415 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1422 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1430 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1431 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1434 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1438 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1442 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1451 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1452 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1455 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1456 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1457 h->ndevices--; in hpsa_scsi_remove_entry()
1458 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1471 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1480 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1481 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1482 if (h->dev[i] == added) { in fixup_botched_add()
1483 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1484 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1485 h->ndevices--; in fixup_botched_add()
1489 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1588 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1595 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1596 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1599 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1603 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1611 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1612 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1613 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1617 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1621 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1623 h->scsi_host->host_no, in hpsa_show_volume_status()
1629 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1631 h->scsi_host->host_no, in hpsa_show_volume_status()
1635 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1637 h->scsi_host->host_no, in hpsa_show_volume_status()
1641 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1643 h->scsi_host->host_no, in hpsa_show_volume_status()
1647 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1649 h->scsi_host->host_no, in hpsa_show_volume_status()
1653 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1655 h->scsi_host->host_no, in hpsa_show_volume_status()
1659 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1661 h->scsi_host->host_no, in hpsa_show_volume_status()
1665 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1667 h->scsi_host->host_no, in hpsa_show_volume_status()
1671 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1673 h->scsi_host->host_no, in hpsa_show_volume_status()
1677 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1679 h->scsi_host->host_no, in hpsa_show_volume_status()
1683 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1685 h->scsi_host->host_no, in hpsa_show_volume_status()
1689 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1691 h->scsi_host->host_no, in hpsa_show_volume_status()
1701 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1740 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1753 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1756 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1772 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1776 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1810 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1814 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1818 if (!h->scsi_host) in hpsa_add_device()
1822 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1825 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1830 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1836 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1837 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1840 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1844 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1847 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1850 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1857 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1868 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1877 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1880 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1885 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1890 if (!h->scsi_host) in hpsa_remove_device()
1897 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1900 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1911 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1920 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1937 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1938 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1939 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1940 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1943 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1949 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1954 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1966 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1967 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1971 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1975 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1982 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
2001 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
2002 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
2006 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2007 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2010 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2016 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2021 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2031 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2032 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2034 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2037 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2047 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2062 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2075 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2078 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2083 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2084 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2096 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2102 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2103 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2114 struct ctlr_info *h; in hpsa_slave_alloc() local
2116 h = sdev_to_hba(sdev); in hpsa_slave_alloc()
2117 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2124 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_slave_alloc()
2131 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_slave_alloc()
2139 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2186 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2190 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2192 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2193 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2194 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2196 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2197 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2200 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2204 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2207 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2210 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2212 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2213 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2214 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2215 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2223 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2227 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2231 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2233 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2234 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2235 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2237 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2238 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2241 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2245 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2248 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2250 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2253 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2254 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2255 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2257 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2264 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2268 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2275 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2277 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2279 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2288 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2298 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2301 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2308 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2309 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2312 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2314 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2316 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2325 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2330 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2333 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2334 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2343 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2423 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2424 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2458 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2474 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2478 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2481 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2482 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2485 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2488 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2493 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2496 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2499 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2503 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2509 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2527 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2530 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2533 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2534 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2536 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2540 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2560 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2570 struct ctlr_info *h; in complete_scsi_command() local
2582 h = cp->h; in complete_scsi_command()
2586 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2592 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2594 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2598 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2599 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2603 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2609 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2617 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2631 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2635 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2639 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2645 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2661 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2688 h->drv_req_rescan = 1; in complete_scsi_command()
2703 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2710 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2732 dev_warn(&h->pdev->dev, in complete_scsi_command()
2749 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2754 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2759 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2767 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2772 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2777 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2782 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2785 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2793 dev_warn(&h->pdev->dev, in complete_scsi_command()
2798 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2802 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2847 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2853 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2861 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2867 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2870 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2874 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2877 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2883 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2890 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2899 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2909 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2910 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2912 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2918 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2924 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2928 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2932 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2944 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2959 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2965 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2970 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2973 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2976 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2979 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2982 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2985 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2988 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2991 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2994 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2997 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
3003 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
3010 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
3011 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
3016 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3022 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3026 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3030 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3041 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3054 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3062 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3064 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3069 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3075 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3079 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3083 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3090 c = cmd_alloc(h); in hpsa_send_reset()
3094 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3095 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3097 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3104 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3108 cmd_free(h, c); in hpsa_send_reset()
3112 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3118 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3163 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3171 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3177 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3178 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3182 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3186 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3188 lockup_detected(h)); in hpsa_do_reset()
3191 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3192 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3198 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3200 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3204 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3215 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3219 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3233 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3244 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3271 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3273 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3276 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3280 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3283 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3287 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3294 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3302 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3309 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3316 c = cmd_alloc(h); in hpsa_get_raid_map()
3318 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3321 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3322 cmd_free(h, c); in hpsa_get_raid_map()
3325 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3331 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3335 cmd_free(h, c); in hpsa_get_raid_map()
3340 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3343 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3346 cmd_free(h, c); in hpsa_get_raid_map()
3350 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3358 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3360 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3368 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3374 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3378 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3382 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3389 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3391 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3396 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3402 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3406 cmd_free(h, c); in hpsa_bmic_id_controller()
3410 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3418 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3419 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3427 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3431 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3435 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3446 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3465 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3487 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3490 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3495 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3497 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3508 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3529 cmd_free(h, c); in hpsa_get_enclosure_info()
3532 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3536 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3548 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3549 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3566 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3579 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3583 h->sas_address = sa; in hpsa_get_sas_address()
3588 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3593 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3599 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3608 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3610 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3611 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3618 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3631 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3643 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3668 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3682 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3684 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3702 rc = hpsa_get_raid_map(h, scsi3addr, this_device); in hpsa_get_ioaccel_status()
3715 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3722 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3729 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3742 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3751 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3755 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3762 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3769 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3775 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3776 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3786 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3790 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3796 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3806 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3821 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3824 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3836 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3849 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3853 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3860 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3880 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3892 c = cmd_alloc(h); in hpsa_volume_offline()
3894 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3895 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3898 cmd_free(h, c); in hpsa_volume_offline()
3907 cmd_free(h, c); in hpsa_volume_offline()
3910 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3939 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3960 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3962 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3981 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3983 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3985 h->ctlr, __func__, in hpsa_update_device_info()
3986 h->scsi_host->host_no, in hpsa_update_device_info()
4000 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
4001 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
4002 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
4003 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
4005 h->legacy_board) { in hpsa_update_device_info()
4009 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4017 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4028 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4057 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4088 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4115 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4119 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4120 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4125 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4129 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4130 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4136 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4143 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4152 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4180 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4197 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4243 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4250 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4255 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4267 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4277 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4294 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4326 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4332 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4367 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4371 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4373 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4375 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4380 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4381 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4392 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4397 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4405 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4411 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4428 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4433 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4441 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4448 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4451 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4453 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4457 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4461 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4481 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4501 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4514 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4536 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4539 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4541 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4547 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4575 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4583 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4600 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4601 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4614 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4625 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4626 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4629 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4631 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4645 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4649 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4731 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4736 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4746 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4754 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4767 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4801 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4820 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4828 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4842 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4849 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4890 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4905 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4910 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4924 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4927 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4939 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4954 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4956 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4964 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4998 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5009 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
5021 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5024 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5037 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5044 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5063 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5064 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5068 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5102 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5446 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5456 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5505 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5511 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5512 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5517 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5523 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5528 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5536 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5537 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5539 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5545 c->h = h; in hpsa_cmd_init()
5549 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5553 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5554 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5556 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5561 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5564 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5573 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5592 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5598 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5602 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5608 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5625 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5630 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5634 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5635 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5641 rc = hpsa_ioaccel_submit(h, c, cmd, true); in hpsa_command_resubmit_worker()
5651 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5656 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5666 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5683 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5689 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5706 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5715 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5735 h->acciopath_status)) { in hpsa_scsi_queue_command()
5737 rc = hpsa_ioaccel_submit(h, c, cmd, false); in hpsa_scsi_queue_command()
5741 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5745 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5748 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5752 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5753 h->scan_finished = 1; in hpsa_scan_complete()
5754 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5755 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5760 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5769 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5770 return hpsa_scan_complete(h); in hpsa_scan_start()
5775 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5776 if (h->scan_waiting) { in hpsa_scan_start()
5777 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5781 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5785 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5786 if (h->scan_finished) in hpsa_scan_start()
5788 h->scan_waiting = 1; in hpsa_scan_start()
5789 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5790 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5797 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5798 h->scan_waiting = 0; in hpsa_scan_start()
5799 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5801 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5802 return hpsa_scan_complete(h); in hpsa_scan_start()
5807 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5808 if (h->reset_in_progress) { in hpsa_scan_start()
5809 h->drv_req_rescan = 1; in hpsa_scan_start()
5810 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5811 hpsa_scan_complete(h); in hpsa_scan_start()
5814 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5816 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5818 hpsa_scan_complete(h); in hpsa_scan_start()
5839 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5843 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5844 finished = h->scan_finished; in hpsa_scan_finished()
5845 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5849 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5855 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5866 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5868 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5870 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5871 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5874 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5878 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5882 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5884 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5887 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5912 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5919 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5921 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5948 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5965 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5973 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5981 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5991 c = cmd_alloc(h); in wait_for_device_to_become_ready()
6000 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6007 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
6013 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6015 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6017 cmd_free(h, c); in wait_for_device_to_become_ready()
6028 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
6035 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6036 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
6039 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6040 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6041 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6043 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6050 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6061 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6065 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6071 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6075 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6093 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6107 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6116 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6119 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6120 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6123 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6134 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6138 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6140 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6141 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6142 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6156 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6157 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6161 h->last_collision_tag = idx; in cmd_tagged_alloc()
6167 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6178 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6196 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6222 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6229 c = h->cmd_pool + i; in cmd_alloc()
6232 cmd_free(h, c); /* already in use */ in cmd_alloc()
6236 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6239 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6257 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6262 i = c - h->cmd_pool; in cmd_free()
6263 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6272 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_passthru() local
6288 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6290 err = hpsa_passthru_ioctl(h, &arg64); in hpsa_ioctl32_passthru()
6291 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6303 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_big_passthru() local
6319 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6321 err = hpsa_big_passthru_ioctl(h, &arg64); in hpsa_ioctl32_big_passthru()
6322 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6363 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6369 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6370 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6371 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6372 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6378 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6387 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6401 static int hpsa_passthru_ioctl(struct ctlr_info *h, in hpsa_passthru_ioctl() argument
6430 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6452 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6454 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6464 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6467 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6468 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6486 cmd_free(h, c); in hpsa_passthru_ioctl()
6492 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, in hpsa_big_passthru_ioctl() argument
6547 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6559 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6561 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6565 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6576 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6579 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6580 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6603 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6616 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6621 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6630 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl() local
6637 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6640 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6642 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6650 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6652 rc = hpsa_passthru_ioctl(h, &iocommand); in hpsa_ioctl()
6653 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6664 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6666 rc = hpsa_big_passthru_ioctl(h, &ioc); in hpsa_ioctl()
6667 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6677 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6681 c = cmd_alloc(h); in hpsa_send_host_reset()
6684 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6688 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6696 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6859 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6895 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6900 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6917 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6935 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6937 return h->access.command_completed(h, q); in get_next_completion()
6940 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6942 return h->access.intr_pending(h); in interrupt_pending()
6945 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6947 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6948 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6951 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6954 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6955 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6963 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6972 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6979 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6980 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6990 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6995 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6998 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
7016 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
7020 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
7023 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
7025 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7026 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
7027 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
7029 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
7036 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
7040 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
7043 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7044 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
7046 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7052 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7056 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7058 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7059 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7060 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7062 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7063 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7071 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7075 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7076 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7078 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7079 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7481 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7483 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7484 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7487 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7492 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7493 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7498 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7504 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7510 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7516 switch (h->board_id) { in hpsa_interrupt_mode()
7523 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7526 h->msix_vectors = ret; in hpsa_interrupt_mode()
7534 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7629 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7631 if (h->transtable) { in hpsa_free_cfgtables()
7632 iounmap(h->transtable); in hpsa_free_cfgtables()
7633 h->transtable = NULL; in hpsa_free_cfgtables()
7635 if (h->cfgtable) { in hpsa_free_cfgtables()
7636 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7637 h->cfgtable = NULL; in hpsa_free_cfgtables()
7644 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7652 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7656 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7657 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7658 if (!h->cfgtable) { in hpsa_find_cfgtables()
7659 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7662 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7666 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7667 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7669 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7670 if (!h->transtable) { in hpsa_find_cfgtables()
7671 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7672 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7678 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7683 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7686 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7687 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7689 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7690 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7692 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7694 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7702 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7704 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7711 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7713 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7714 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7715 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7716 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7717 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7719 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7720 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7721 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7728 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7729 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7730 h->chainsize = 0; in hpsa_find_board_params()
7734 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7735 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7736 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7737 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7738 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7739 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7740 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7743 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7745 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7746 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7752 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7756 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7762 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7768 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7772 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7774 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7776 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7779 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7786 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7787 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7788 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7799 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7810 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7812 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7813 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7814 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7826 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7830 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7834 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7837 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7838 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7839 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7840 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7842 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7843 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7845 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7848 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7853 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7855 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7856 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7857 h->vaddr = NULL; in hpsa_free_pci_init()
7858 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7863 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7864 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7868 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7873 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7876 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7877 h->access = *(products[prod_index].access); in hpsa_pci_init()
7878 h->legacy_board = legacy_board; in hpsa_pci_init()
7879 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7882 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7885 pci_disable_device(h->pdev); in hpsa_pci_init()
7889 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7891 dev_err(&h->pdev->dev, in hpsa_pci_init()
7893 pci_disable_device(h->pdev); in hpsa_pci_init()
7897 pci_set_master(h->pdev); in hpsa_pci_init()
7899 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7904 hpsa_setup_reply_map(h); in hpsa_pci_init()
7906 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7909 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7910 if (!h->vaddr) { in hpsa_pci_init()
7911 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7915 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7918 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7921 hpsa_find_board_params(h); in hpsa_pci_init()
7923 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7927 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7928 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7929 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7935 hpsa_free_cfgtables(h); in hpsa_pci_init()
7937 iounmap(h->vaddr); in hpsa_pci_init()
7938 h->vaddr = NULL; in hpsa_pci_init()
7940 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7946 pci_disable_device(h->pdev); in hpsa_pci_init()
7947 pci_release_regions(h->pdev); in hpsa_pci_init()
7951 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7956 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7957 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7959 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7960 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7962 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7963 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
8029 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
8031 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8032 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8033 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8034 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8035 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8036 h->cmd_pool, in hpsa_free_cmd_pool()
8037 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8038 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8039 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8041 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8042 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8043 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8044 h->errinfo_pool, in hpsa_free_cmd_pool()
8045 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8046 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8047 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8051 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8053 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8054 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8055 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8056 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8057 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8058 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8059 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8060 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8061 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8062 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8063 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8066 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
8069 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
8074 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
8080 irq_vector = h->intr_mode; in hpsa_free_irqs()
8082 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8084 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8085 &h->q[h->intr_mode]); in hpsa_free_irqs()
8086 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8090 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8091 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8092 h->q[i] = 0; in hpsa_free_irqs()
8095 h->q[i] = 0; in hpsa_free_irqs()
8099 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
8107 irq_vector = h->intr_mode; in hpsa_request_irqs()
8114 h->q[i] = (u8) i; in hpsa_request_irqs()
8116 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8118 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8119 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8120 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8121 0, h->intrname[i], in hpsa_request_irqs()
8122 &h->q[i]); in hpsa_request_irqs()
8126 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8128 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8130 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8131 h->q[j] = 0; in hpsa_request_irqs()
8134 h->q[j] = 0; in hpsa_request_irqs()
8140 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8141 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8142 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8143 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8145 h->intrname[0], in hpsa_request_irqs()
8146 &h->q[h->intr_mode]); in hpsa_request_irqs()
8148 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8149 "%s-intx", h->devname); in hpsa_request_irqs()
8150 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8152 h->intrname[0], in hpsa_request_irqs()
8153 &h->q[h->intr_mode]); in hpsa_request_irqs()
8157 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8158 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8159 hpsa_free_irqs(h); in hpsa_request_irqs()
8165 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8168 hpsa_send_host_reset(h, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8170 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8171 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8173 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8177 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8178 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8180 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8188 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8192 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8193 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8195 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8196 h->reply_queue_size, in hpsa_free_reply_queues()
8197 h->reply_queue[i].head, in hpsa_free_reply_queues()
8198 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8199 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8200 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8202 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8205 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8207 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8208 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8209 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8210 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8211 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8212 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8213 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8214 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8215 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8216 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8217 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8218 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8220 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8221 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8222 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8224 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8225 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8226 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8229 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8233 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8239 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8240 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8241 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8246 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8249 cmd_free(h, c); in fail_all_outstanding_cmds()
8251 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8255 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8261 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8267 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8272 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8273 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8274 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8277 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8279 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8282 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8283 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8284 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8285 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8287 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8288 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8290 pci_disable_device(h->pdev); in controller_lockup_detected()
8291 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8294 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8302 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8303 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8311 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8312 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8316 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8317 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8318 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8319 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8320 controller_lockup_detected(h); in detect_controller_lockup()
8325 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8326 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8339 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8347 if (!h) in hpsa_set_ioaccel_status()
8357 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8361 device = h->dev[i]; in hpsa_set_ioaccel_status()
8365 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8371 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8412 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8416 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8420 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8422 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8423 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8425 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8427 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8430 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8431 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8432 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8434 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8436 h->events, event_type); in hpsa_ack_ctlr_events()
8437 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8439 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8441 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8442 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8445 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8446 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8447 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8457 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8459 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8460 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8464 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8467 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8468 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8474 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8480 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8481 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8484 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8485 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8486 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8488 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8491 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8493 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8497 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8506 if (!h->lastlogicals) in hpsa_luns_changed()
8513 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8514 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8518 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8519 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8521 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8530 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8538 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8539 if (h->reset_in_progress) { in hpsa_perform_rescan()
8540 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8541 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8544 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8546 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8550 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8559 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8563 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8564 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8565 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8568 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8570 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8571 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8572 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8575 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8576 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8577 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8579 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8585 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8588 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8589 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8590 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8593 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8595 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8596 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8597 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8598 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8599 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8601 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8604 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8605 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8606 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8607 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8608 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8614 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8617 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8618 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8621 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8622 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8623 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8624 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8625 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8628 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8633 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8635 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8640 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8642 kfree(h->reply_map); in hpda_free_ctlr_info()
8643 kfree(h); in hpda_free_ctlr_info()
8648 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8650 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8651 if (!h) in hpda_alloc_ctlr_info()
8654 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8655 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8656 kfree(h); in hpda_alloc_ctlr_info()
8659 return h; in hpda_alloc_ctlr_info()
8665 struct ctlr_info *h; in hpsa_init_one() local
8699 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8700 if (!h) { in hpsa_init_one()
8705 h->pdev = pdev; in hpsa_init_one()
8707 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8708 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8709 spin_lock_init(&h->lock); in hpsa_init_one()
8710 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8711 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8712 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8713 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8716 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8717 if (!h->lockup_detected) { in hpsa_init_one()
8718 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8722 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8724 rc = hpsa_pci_init(h); in hpsa_init_one()
8730 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8734 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8735 h->ctlr = number_of_controllers; in hpsa_init_one()
8749 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8751 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8754 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8757 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8760 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8761 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8762 mutex_init(&h->reset_mutex); in hpsa_init_one()
8763 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8764 h->scan_waiting = 0; in hpsa_init_one()
8766 pci_set_drvdata(pdev, h); in hpsa_init_one()
8767 h->ndevices = 0; in hpsa_init_one()
8769 spin_lock_init(&h->devlock); in hpsa_init_one()
8770 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8775 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8776 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8781 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8782 if (!h->resubmit_wq) { in hpsa_init_one()
8787 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8788 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8807 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8808 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8809 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8810 hpsa_free_irqs(h); in hpsa_init_one()
8811 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8814 dev_warn(&h->pdev->dev, in hpsa_init_one()
8820 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8821 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8822 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8830 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8835 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8836 dev_info(&h->pdev->dev, in hpsa_init_one()
8838 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8840 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8842 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8844 dev_info(&h->pdev->dev, in hpsa_init_one()
8851 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8861 h->acciopath_status = 1; in hpsa_init_one()
8863 h->discovery_polling = 0; in hpsa_init_one()
8867 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8869 hpsa_hba_inquiry(h); in hpsa_init_one()
8871 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8872 if (!h->lastlogicals) in hpsa_init_one()
8873 dev_info(&h->pdev->dev, in hpsa_init_one()
8877 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8882 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8883 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8884 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8885 h->heartbeat_sample_interval); in hpsa_init_one()
8886 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8887 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8888 h->heartbeat_sample_interval); in hpsa_init_one()
8889 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8890 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8895 kfree(h->lastlogicals); in hpsa_init_one()
8897 hpsa_free_performant_mode(h); in hpsa_init_one()
8898 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8900 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8902 hpsa_free_cmd_pool(h); in hpsa_init_one()
8904 hpsa_free_irqs(h); in hpsa_init_one()
8906 scsi_host_put(h->scsi_host); in hpsa_init_one()
8907 h->scsi_host = NULL; in hpsa_init_one()
8909 hpsa_free_pci_init(h); in hpsa_init_one()
8911 if (h->lockup_detected) { in hpsa_init_one()
8912 free_percpu(h->lockup_detected); in hpsa_init_one()
8913 h->lockup_detected = NULL; in hpsa_init_one()
8916 if (h->resubmit_wq) { in hpsa_init_one()
8917 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8918 h->resubmit_wq = NULL; in hpsa_init_one()
8920 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8921 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8922 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8924 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8925 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8926 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8928 hpda_free_ctlr_info(h); in hpsa_init_one()
8932 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8938 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8944 c = cmd_alloc(h); in hpsa_flush_cache()
8946 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8950 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_flush_cache()
8956 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8958 cmd_free(h, c); in hpsa_flush_cache()
8965 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8972 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8979 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8982 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8986 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8994 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8998 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_disable_rld_caching()
9004 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
9008 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
9017 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9020 cmd_free(h, c); in hpsa_disable_rld_caching()
9026 struct ctlr_info *h; in __hpsa_shutdown() local
9028 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
9033 hpsa_flush_cache(h); in __hpsa_shutdown()
9034 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9035 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
9036 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
9045 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
9049 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9050 kfree(h->dev[i]); in hpsa_free_device_info()
9051 h->dev[i] = NULL; in hpsa_free_device_info()
9057 struct ctlr_info *h; in hpsa_remove_one() local
9064 h = pci_get_drvdata(pdev); in hpsa_remove_one()
9067 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9068 h->remove_in_progress = 1; in hpsa_remove_one()
9069 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9070 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9071 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9072 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9073 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9074 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9075 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9077 hpsa_delete_sas_host(h); in hpsa_remove_one()
9085 if (h->scsi_host) in hpsa_remove_one()
9086 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9091 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
9093 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9094 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9095 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
9096 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
9097 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
9098 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
9099 kfree(h->lastlogicals); in hpsa_remove_one()
9103 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9104 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9107 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
9109 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9110 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9112 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9176 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9230 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9231 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9235 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9237 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9240 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9241 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9242 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9243 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9245 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9246 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9247 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9248 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9251 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9252 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9258 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9259 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9263 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9264 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9265 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9269 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9271 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9276 h->access = access; in hpsa_enter_performant_mode()
9277 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9285 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9286 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9287 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9288 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9290 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9291 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9292 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9295 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9296 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9298 h->reply_queue_size); in hpsa_enter_performant_mode()
9303 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9304 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9307 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9318 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9325 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9328 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9329 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9330 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9331 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9334 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9335 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9339 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9341 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9343 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9344 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9345 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9353 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9355 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9356 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9357 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9358 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9359 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9360 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9361 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9363 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9364 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9368 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9370 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9371 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9372 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9373 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9381 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9382 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9386 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9387 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9390 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9391 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9394 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9395 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9399 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9404 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9406 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9408 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9409 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9410 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9411 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9412 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9413 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9414 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9416 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9417 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9421 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9427 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9428 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9429 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9434 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9435 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9439 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9440 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9443 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9444 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9449 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9453 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9454 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9458 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9463 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9465 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9466 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9467 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9468 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9469 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9475 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9483 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9489 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9493 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9498 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9499 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9501 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9503 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9504 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9505 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9506 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9508 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9512 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9513 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9514 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9518 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9520 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9525 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9531 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9532 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9534 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9535 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9536 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9545 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9553 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9554 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9558 cmd_free(h, c); in hpsa_drain_accel_commands()
9730 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9736 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9737 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9747 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9755 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9761 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9777 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9792 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9794 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9850 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9856 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9858 if (!h) in hpsa_sas_get_enclosure_identifier()
9861 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()