Lines Matching refs:h
239 static int hpsa_add_sas_host(struct ctlr_info *h);
240 static void hpsa_delete_sas_host(struct ctlr_info *h);
245 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
258 static int hpsa_passthru_ioctl(struct ctlr_info *h,
260 static int hpsa_big_passthru_ioctl(struct ctlr_info *h,
268 static void cmd_free(struct ctlr_info *h, struct CommandList *c);
269 static struct CommandList *cmd_alloc(struct ctlr_info *h);
270 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c);
271 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
273 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
276 static void hpsa_free_cmd_pool(struct ctlr_info *h);
280 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
291 static void hpsa_update_scsi_devices(struct ctlr_info *h);
292 static int check_for_unit_attention(struct ctlr_info *h,
294 static void check_ioctl_unit_attention(struct ctlr_info *h,
299 static void hpsa_free_performant_mode(struct ctlr_info *h);
300 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
301 static inline u32 next_command(struct ctlr_info *h, u8 q);
309 static int wait_for_device_to_become_ready(struct ctlr_info *h,
315 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
318 static void hpsa_drain_accel_commands(struct ctlr_info *h);
319 static void hpsa_flush_cache(struct ctlr_info *h);
320 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
324 static u32 lockup_detected(struct ctlr_info *h);
325 static int detect_controller_lockup(struct ctlr_info *h);
326 static void hpsa_disable_rld_caching(struct ctlr_info *h);
327 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
329 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
331 static int hpsa_luns_changed(struct ctlr_info *h);
332 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
375 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
393 dev_warn(&h->pdev->dev, in check_for_unit_attention()
395 h->devname); in check_for_unit_attention()
398 dev_warn(&h->pdev->dev, in check_for_unit_attention()
399 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
402 dev_warn(&h->pdev->dev, in check_for_unit_attention()
403 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
410 dev_warn(&h->pdev->dev, in check_for_unit_attention()
412 h->devname); in check_for_unit_attention()
415 dev_warn(&h->pdev->dev, in check_for_unit_attention()
417 h->devname); in check_for_unit_attention()
420 dev_warn(&h->pdev->dev, in check_for_unit_attention()
422 h->devname); in check_for_unit_attention()
428 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
434 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
438 static u32 lockup_detected(struct ctlr_info *h);
443 struct ctlr_info *h; in host_show_lockup_detected() local
446 h = shost_to_hba(shost); in host_show_lockup_detected()
447 ld = lockup_detected(h); in host_show_lockup_detected()
457 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
468 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
469 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
470 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
472 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
481 struct ctlr_info *h; in host_store_raid_offload_debug() local
494 h = shost_to_hba(shost); in host_store_raid_offload_debug()
495 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
496 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
497 h->raid_offload_debug); in host_store_raid_offload_debug()
505 struct ctlr_info *h; in host_store_rescan() local
507 h = shost_to_hba(shost); in host_store_rescan()
508 hpsa_scan_start(h->scsi_host); in host_store_rescan()
521 struct ctlr_info *h; in host_show_firmware_revision() local
525 h = shost_to_hba(shost); in host_show_firmware_revision()
526 if (!h->hba_inquiry_data) in host_show_firmware_revision()
528 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
537 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
540 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
546 struct ctlr_info *h; in host_show_transport_mode() local
549 h = shost_to_hba(shost); in host_show_transport_mode()
551 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
558 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
561 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
563 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
642 struct ctlr_info *h; in host_show_resettable() local
645 h = shost_to_hba(shost); in host_show_resettable()
646 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
677 struct ctlr_info *h; in raid_level_show() local
683 h = sdev_to_hba(sdev); in raid_level_show()
684 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
687 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
693 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
699 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
709 struct ctlr_info *h; in lunid_show() local
716 h = sdev_to_hba(sdev); in lunid_show()
717 spin_lock_irqsave(&h->lock, flags); in lunid_show()
720 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
724 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
731 struct ctlr_info *h; in unique_id_show() local
738 h = sdev_to_hba(sdev); in unique_id_show()
739 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
742 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
746 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
759 struct ctlr_info *h; in sas_address_show() local
766 h = sdev_to_hba(sdev); in sas_address_show()
767 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
770 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
774 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
782 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
789 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
790 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
793 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
797 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
810 struct ctlr_info *h; in path_info_show() local
823 h = sdev_to_hba(sdev); in path_info_show()
824 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
827 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
844 h->scsi_host->host_no, in path_info_show()
888 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
895 struct ctlr_info *h; in host_show_ctlr_num() local
898 h = shost_to_hba(shost); in host_show_ctlr_num()
899 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
905 struct ctlr_info *h; in host_show_legacy_board() local
908 h = shost_to_hba(shost); in host_show_legacy_board()
909 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
990 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
993 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
995 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
996 return h->access.command_completed(h, q); in next_command()
998 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
999 return h->access.command_completed(h, q); in next_command()
1004 atomic_dec(&h->commands_outstanding); in next_command()
1009 if (rq->current_entry == h->max_commands) { in next_command()
1048 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1051 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1052 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1053 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1059 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1063 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1076 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1080 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1085 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1096 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1099 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1103 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1116 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1132 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1137 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1138 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1141 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1145 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1146 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1149 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1152 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1153 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1157 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1160 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1161 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1164 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1165 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1168 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1169 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1172 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1173 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1177 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1179 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1187 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1189 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1191 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1196 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1207 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1208 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1209 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1222 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1228 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1264 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1266 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1278 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1283 int n = h->ndevices; in hpsa_scsi_add_entry()
1289 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1305 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1321 sd = h->dev[i]; in hpsa_scsi_add_entry()
1334 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1342 h->dev[n] = device; in hpsa_scsi_add_entry()
1343 h->ndevices++; in hpsa_scsi_add_entry()
1346 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1356 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1363 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1368 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1380 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1381 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1384 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1387 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1388 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1389 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1390 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1397 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1403 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1405 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1409 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1416 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1424 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1425 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1428 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1432 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1436 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1445 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1446 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1449 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1450 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1451 h->ndevices--; in hpsa_scsi_remove_entry()
1452 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1465 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1474 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1475 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1476 if (h->dev[i] == added) { in fixup_botched_add()
1477 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1478 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1479 h->ndevices--; in fixup_botched_add()
1483 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1582 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1589 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1590 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1593 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1597 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1605 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1606 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1607 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1611 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1615 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1617 h->scsi_host->host_no, in hpsa_show_volume_status()
1623 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1625 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()
1695 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1734 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1747 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1750 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1766 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1770 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1804 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1808 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1812 if (!h->scsi_host) in hpsa_add_device()
1816 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1819 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1824 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1830 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1831 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1834 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1838 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1841 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1844 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1851 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1862 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1871 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1874 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1879 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1884 if (!h->scsi_host) in hpsa_remove_device()
1891 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1894 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1905 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1914 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1931 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1932 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1933 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1934 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1937 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1943 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1948 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1960 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1961 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1965 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1969 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1976 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1995 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
1996 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
2000 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2001 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2004 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2010 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2015 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2025 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2026 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2028 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2031 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2041 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2056 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2069 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2072 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2077 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2078 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2090 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2096 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2097 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2108 struct ctlr_info *h; in hpsa_slave_alloc() local
2110 h = sdev_to_hba(sdev); in hpsa_slave_alloc()
2111 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2118 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_slave_alloc()
2125 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_slave_alloc()
2133 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2180 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2184 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2186 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2187 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2188 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2190 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2191 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2194 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2198 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2201 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2202 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2204 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2206 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2207 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2211 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2221 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2225 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2227 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2228 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2229 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2231 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2232 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2235 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2239 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2242 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2244 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2247 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2248 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2249 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2251 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2258 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2262 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2269 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2271 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2273 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2282 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2292 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2295 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2302 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2303 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2306 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2308 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2310 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2319 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2324 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2327 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2328 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2337 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2418 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2419 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2453 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2469 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2473 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2476 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2477 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2480 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2483 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2488 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2491 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2494 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2498 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2504 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2522 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2525 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2528 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2529 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2531 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2535 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2555 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2565 struct ctlr_info *h; in complete_scsi_command() local
2577 h = cp->h; in complete_scsi_command()
2581 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2587 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2589 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2593 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2594 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2598 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2605 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2613 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2627 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2631 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2635 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2641 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2657 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2684 h->drv_req_rescan = 1; in complete_scsi_command()
2699 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2706 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2728 dev_warn(&h->pdev->dev, in complete_scsi_command()
2745 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2750 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2755 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2763 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2768 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2773 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2778 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2781 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2789 dev_warn(&h->pdev->dev, in complete_scsi_command()
2794 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2798 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2843 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2849 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2857 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2863 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2866 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2870 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2873 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2879 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2886 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2895 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2905 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2906 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2908 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2914 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2920 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2924 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2928 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2940 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2955 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2961 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2966 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2969 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2972 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2975 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2978 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2981 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2984 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2987 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2990 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2993 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
2999 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
3006 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
3007 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
3012 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3018 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3022 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3026 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3037 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3050 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3058 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3060 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3065 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3071 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3075 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3079 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3086 c = cmd_alloc(h); in hpsa_send_reset()
3090 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3091 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3093 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3100 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3104 cmd_free(h, c); in hpsa_send_reset()
3108 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3114 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3159 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3167 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3173 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3174 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3178 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3182 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3184 lockup_detected(h)); in hpsa_do_reset()
3187 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3188 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3194 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3196 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3200 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3211 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3215 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3229 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3240 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3272 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3276 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3279 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3283 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3290 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3298 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3305 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3312 c = cmd_alloc(h); in hpsa_get_raid_map()
3314 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3317 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3318 cmd_free(h, c); in hpsa_get_raid_map()
3321 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3327 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3331 cmd_free(h, c); in hpsa_get_raid_map()
3336 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3339 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3342 cmd_free(h, c); in hpsa_get_raid_map()
3346 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3354 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3356 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3364 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3370 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3374 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3378 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3385 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3387 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3392 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3398 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3402 cmd_free(h, c); in hpsa_bmic_id_controller()
3406 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3414 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3415 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3423 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3427 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3431 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3442 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3461 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3483 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3486 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3491 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3493 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3504 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3525 cmd_free(h, c); in hpsa_get_enclosure_info()
3528 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3532 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3544 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3545 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3562 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3575 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3579 h->sas_address = sa; in hpsa_get_sas_address()
3584 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3589 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3595 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3604 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3606 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3607 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3614 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3627 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3639 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3664 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3678 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3680 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3698 rc = hpsa_get_raid_map(h, scsi3addr, this_device); in hpsa_get_ioaccel_status()
3711 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3718 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3725 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3738 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3747 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3751 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3758 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3765 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3771 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3772 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3782 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3786 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3792 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3802 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3817 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3820 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3832 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3845 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3849 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3856 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3876 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3890 c = cmd_alloc(h); in hpsa_volume_offline()
3892 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3893 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3896 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
4368 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4373 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4375 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4377 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4382 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4383 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4394 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4399 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4407 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4413 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4431 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4436 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4444 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4451 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4454 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4456 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4460 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4464 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4484 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4504 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4517 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4539 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4542 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4544 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4550 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4578 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4586 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4603 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4604 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4618 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4629 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4630 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4633 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4635 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4649 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4653 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4735 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4740 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4750 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4758 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4771 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4805 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4824 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4832 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4846 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4853 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4894 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4909 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4914 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4928 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4931 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4943 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4958 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4960 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4968 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
5002 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5013 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
5025 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5028 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5041 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5048 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5067 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5068 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5072 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5106 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5450 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5460 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5509 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5515 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5516 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5521 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5527 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5532 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5540 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5541 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5543 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5549 c->h = h; in hpsa_cmd_init()
5553 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5557 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5558 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5560 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5565 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5568 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5577 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5595 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5599 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5603 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5607 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5624 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5629 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5633 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5634 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5639 rc = hpsa_ioaccel_submit(h, c, cmd); in hpsa_command_resubmit_worker()
5649 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5654 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5655 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5672 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5678 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5695 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5704 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5720 h->acciopath_status)) { in hpsa_scsi_queue_command()
5721 rc = hpsa_ioaccel_submit(h, c, cmd); in hpsa_scsi_queue_command()
5725 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5729 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5732 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5736 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5737 h->scan_finished = 1; in hpsa_scan_complete()
5738 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5739 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5744 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5753 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5754 return hpsa_scan_complete(h); in hpsa_scan_start()
5759 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5760 if (h->scan_waiting) { in hpsa_scan_start()
5761 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5765 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5769 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5770 if (h->scan_finished) in hpsa_scan_start()
5772 h->scan_waiting = 1; in hpsa_scan_start()
5773 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5774 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5781 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5782 h->scan_waiting = 0; in hpsa_scan_start()
5783 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5785 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5786 return hpsa_scan_complete(h); in hpsa_scan_start()
5791 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5792 if (h->reset_in_progress) { in hpsa_scan_start()
5793 h->drv_req_rescan = 1; in hpsa_scan_start()
5794 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5795 hpsa_scan_complete(h); in hpsa_scan_start()
5798 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5800 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5802 hpsa_scan_complete(h); in hpsa_scan_start()
5823 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5827 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5828 finished = h->scan_finished; in hpsa_scan_finished()
5829 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5833 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5839 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5850 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5852 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5854 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5855 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5858 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5862 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5866 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5868 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5871 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5896 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5903 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5905 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5932 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5949 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5957 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5965 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5975 c = cmd_alloc(h); in wait_for_device_to_become_ready()
5984 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
5991 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
5997 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
5999 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6001 cmd_free(h, c); in wait_for_device_to_become_ready()
6012 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
6019 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6020 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
6023 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6024 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6025 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6027 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6034 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6045 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6049 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6055 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6059 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6077 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6091 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6100 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6103 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6104 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6107 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6117 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6121 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6123 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6124 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6125 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6139 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6140 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6144 h->last_collision_tag = idx; in cmd_tagged_alloc()
6151 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6155 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6173 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6199 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6206 c = h->cmd_pool + i; in cmd_alloc()
6209 cmd_free(h, c); /* already in use */ in cmd_alloc()
6214 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_alloc()
6217 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6228 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6233 i = c - h->cmd_pool; in cmd_free()
6235 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_free()
6244 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_passthru() local
6260 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6262 err = hpsa_passthru_ioctl(h, &arg64); in hpsa_ioctl32_passthru()
6263 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6275 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_big_passthru() local
6291 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6293 err = hpsa_big_passthru_ioctl(h, &arg64); in hpsa_ioctl32_big_passthru()
6294 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6335 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6341 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6342 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6343 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6344 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6350 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6359 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6373 static int hpsa_passthru_ioctl(struct ctlr_info *h, in hpsa_passthru_ioctl() argument
6402 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6424 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6426 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6436 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6439 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6440 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6458 cmd_free(h, c); in hpsa_passthru_ioctl()
6464 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, in hpsa_big_passthru_ioctl() argument
6519 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6531 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6533 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6537 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6548 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6551 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6552 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6575 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6588 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6593 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6602 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl() local
6609 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6612 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6614 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6622 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6624 rc = hpsa_passthru_ioctl(h, &iocommand); in hpsa_ioctl()
6625 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6636 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6638 rc = hpsa_big_passthru_ioctl(h, &ioc); in hpsa_ioctl()
6639 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6649 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6653 c = cmd_alloc(h); in hpsa_send_host_reset()
6656 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6660 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6668 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6831 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6867 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6872 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6889 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6907 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6909 return h->access.command_completed(h, q); in get_next_completion()
6912 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6914 return h->access.intr_pending(h); in interrupt_pending()
6917 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6919 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6920 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6923 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6926 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6927 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6935 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6944 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6951 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6952 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6962 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6967 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6970 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
6988 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
6992 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
6995 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
6997 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
6998 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
6999 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
7001 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
7008 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
7012 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
7015 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7016 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
7018 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7024 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7028 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7030 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7031 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7032 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7034 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7035 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7043 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7047 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7048 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7050 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7051 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7454 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7456 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7457 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7460 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7465 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7466 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7471 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7477 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7483 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7489 switch (h->board_id) { in hpsa_interrupt_mode()
7496 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7499 h->msix_vectors = ret; in hpsa_interrupt_mode()
7507 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7602 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7604 if (h->transtable) { in hpsa_free_cfgtables()
7605 iounmap(h->transtable); in hpsa_free_cfgtables()
7606 h->transtable = NULL; in hpsa_free_cfgtables()
7608 if (h->cfgtable) { in hpsa_free_cfgtables()
7609 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7610 h->cfgtable = NULL; in hpsa_free_cfgtables()
7617 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7625 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7629 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7630 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7631 if (!h->cfgtable) { in hpsa_find_cfgtables()
7632 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7635 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7639 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7640 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7642 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7643 if (!h->transtable) { in hpsa_find_cfgtables()
7644 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7645 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7651 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7656 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7659 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7660 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7662 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7663 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7665 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7667 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7675 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7677 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7684 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7686 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7687 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7688 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7689 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7690 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7692 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7693 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7694 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7701 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7702 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7703 h->chainsize = 0; in hpsa_find_board_params()
7707 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7708 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7709 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7710 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7711 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7712 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7713 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7716 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7718 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7719 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7725 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7729 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7735 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7741 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7745 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7747 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7749 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7752 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7759 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7760 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7761 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7772 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7783 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7785 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7786 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7787 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7799 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7803 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7807 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7810 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7811 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7812 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7813 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7815 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7816 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7818 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7821 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7826 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7828 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7829 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7830 h->vaddr = NULL; in hpsa_free_pci_init()
7831 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7836 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7837 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7841 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7846 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7849 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7850 h->access = *(products[prod_index].access); in hpsa_pci_init()
7851 h->legacy_board = legacy_board; in hpsa_pci_init()
7852 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7855 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7857 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7858 pci_disable_device(h->pdev); in hpsa_pci_init()
7862 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7864 dev_err(&h->pdev->dev, in hpsa_pci_init()
7866 pci_disable_device(h->pdev); in hpsa_pci_init()
7870 pci_set_master(h->pdev); in hpsa_pci_init()
7872 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7877 hpsa_setup_reply_map(h); in hpsa_pci_init()
7879 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7882 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7883 if (!h->vaddr) { in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7888 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7891 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7894 hpsa_find_board_params(h); in hpsa_pci_init()
7896 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7900 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7901 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7902 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7908 hpsa_free_cfgtables(h); in hpsa_pci_init()
7910 iounmap(h->vaddr); in hpsa_pci_init()
7911 h->vaddr = NULL; in hpsa_pci_init()
7913 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7919 pci_disable_device(h->pdev); in hpsa_pci_init()
7920 pci_release_regions(h->pdev); in hpsa_pci_init()
7924 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7929 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7930 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7932 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7933 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7935 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7936 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
8002 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
8004 kfree(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8005 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8006 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8007 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8008 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8009 h->cmd_pool, in hpsa_free_cmd_pool()
8010 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8011 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8012 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8014 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8015 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8016 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8017 h->errinfo_pool, in hpsa_free_cmd_pool()
8018 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8019 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8020 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8024 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8026 h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), in hpsa_alloc_cmd_pool()
8029 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8030 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8031 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8032 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8033 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8034 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8035 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8036 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8037 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8038 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8041 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
8044 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
8049 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
8055 irq_vector = h->intr_mode; in hpsa_free_irqs()
8057 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8059 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8060 &h->q[h->intr_mode]); in hpsa_free_irqs()
8061 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8065 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8066 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8067 h->q[i] = 0; in hpsa_free_irqs()
8070 h->q[i] = 0; in hpsa_free_irqs()
8074 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
8082 irq_vector = h->intr_mode; in hpsa_request_irqs()
8089 h->q[i] = (u8) i; in hpsa_request_irqs()
8091 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8093 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8094 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8095 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8096 0, h->intrname[i], in hpsa_request_irqs()
8097 &h->q[i]); in hpsa_request_irqs()
8101 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8103 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8105 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8106 h->q[j] = 0; in hpsa_request_irqs()
8109 h->q[j] = 0; in hpsa_request_irqs()
8115 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8116 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8117 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8118 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8120 h->intrname[0], in hpsa_request_irqs()
8121 &h->q[h->intr_mode]); in hpsa_request_irqs()
8123 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8124 "%s-intx", h->devname); in hpsa_request_irqs()
8125 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8127 h->intrname[0], in hpsa_request_irqs()
8128 &h->q[h->intr_mode]); in hpsa_request_irqs()
8132 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8133 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8134 hpsa_free_irqs(h); in hpsa_request_irqs()
8140 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8143 hpsa_send_host_reset(h, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8145 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8146 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8148 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8152 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8153 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8155 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8163 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8167 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8168 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8170 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8171 h->reply_queue_size, in hpsa_free_reply_queues()
8172 h->reply_queue[i].head, in hpsa_free_reply_queues()
8173 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8174 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8175 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8177 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8180 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8182 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8183 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8184 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8185 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8186 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8187 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8188 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8189 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8190 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8191 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8192 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8193 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8195 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8196 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8197 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8199 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8200 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8201 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8204 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8208 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8214 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8215 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8216 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8221 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8224 cmd_free(h, c); in fail_all_outstanding_cmds()
8226 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8230 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8236 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8242 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8247 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8248 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8249 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8252 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8254 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8257 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8258 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8259 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8260 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8262 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8263 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8265 pci_disable_device(h->pdev); in controller_lockup_detected()
8266 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8269 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8277 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8278 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8286 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8287 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8291 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8292 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8293 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8294 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8295 controller_lockup_detected(h); in detect_controller_lockup()
8300 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8301 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8314 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8322 if (!h) in hpsa_set_ioaccel_status()
8332 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8336 device = h->dev[i]; in hpsa_set_ioaccel_status()
8340 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8346 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8387 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8391 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8395 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8397 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8398 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8400 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8402 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8405 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8406 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8407 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8409 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8411 h->events, event_type); in hpsa_ack_ctlr_events()
8412 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8414 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8416 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8417 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8420 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8421 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8422 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8432 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8434 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8435 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8439 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8442 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8443 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8449 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8455 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8456 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8459 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8460 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8461 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8463 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8466 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8468 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8472 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8481 if (!h->lastlogicals) in hpsa_luns_changed()
8488 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8489 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8493 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8494 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8496 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8505 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8513 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8514 if (h->reset_in_progress) { in hpsa_perform_rescan()
8515 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8516 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8519 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8521 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8525 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8534 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8538 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8539 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8540 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8543 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8545 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8546 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8547 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8550 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8551 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8552 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8554 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8560 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8563 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8564 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8565 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8568 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8570 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8571 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8572 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8573 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8574 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8576 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8579 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8580 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8581 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8582 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8583 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8589 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8592 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8593 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8596 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8597 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8598 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8599 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8600 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8603 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8608 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8610 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8615 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8617 kfree(h->reply_map); in hpda_free_ctlr_info()
8618 kfree(h); in hpda_free_ctlr_info()
8623 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8625 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8626 if (!h) in hpda_alloc_ctlr_info()
8629 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8630 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8631 kfree(h); in hpda_alloc_ctlr_info()
8634 return h; in hpda_alloc_ctlr_info()
8640 struct ctlr_info *h; in hpsa_init_one() local
8674 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8675 if (!h) { in hpsa_init_one()
8680 h->pdev = pdev; in hpsa_init_one()
8682 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8683 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8684 spin_lock_init(&h->lock); in hpsa_init_one()
8685 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8686 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8687 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8688 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8691 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8692 if (!h->lockup_detected) { in hpsa_init_one()
8693 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8697 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8699 rc = hpsa_pci_init(h); in hpsa_init_one()
8705 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8709 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8710 h->ctlr = number_of_controllers; in hpsa_init_one()
8728 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8730 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8733 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8736 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8739 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8740 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8741 mutex_init(&h->reset_mutex); in hpsa_init_one()
8742 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8743 h->scan_waiting = 0; in hpsa_init_one()
8745 pci_set_drvdata(pdev, h); in hpsa_init_one()
8746 h->ndevices = 0; in hpsa_init_one()
8748 spin_lock_init(&h->devlock); in hpsa_init_one()
8749 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8754 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8755 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8760 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8761 if (!h->resubmit_wq) { in hpsa_init_one()
8766 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8767 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8786 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8787 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8788 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8789 hpsa_free_irqs(h); in hpsa_init_one()
8790 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8793 dev_warn(&h->pdev->dev, in hpsa_init_one()
8799 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8800 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8801 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8809 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8814 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8815 dev_info(&h->pdev->dev, in hpsa_init_one()
8817 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8819 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8821 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8823 dev_info(&h->pdev->dev, in hpsa_init_one()
8830 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8840 h->acciopath_status = 1; in hpsa_init_one()
8842 h->discovery_polling = 0; in hpsa_init_one()
8846 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8848 hpsa_hba_inquiry(h); in hpsa_init_one()
8850 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8851 if (!h->lastlogicals) in hpsa_init_one()
8852 dev_info(&h->pdev->dev, in hpsa_init_one()
8856 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8861 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8862 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8863 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8864 h->heartbeat_sample_interval); in hpsa_init_one()
8865 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8866 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8867 h->heartbeat_sample_interval); in hpsa_init_one()
8868 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8869 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8874 kfree(h->lastlogicals); in hpsa_init_one()
8876 hpsa_free_performant_mode(h); in hpsa_init_one()
8877 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8879 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8881 hpsa_free_cmd_pool(h); in hpsa_init_one()
8883 hpsa_free_irqs(h); in hpsa_init_one()
8885 scsi_host_put(h->scsi_host); in hpsa_init_one()
8886 h->scsi_host = NULL; in hpsa_init_one()
8888 hpsa_free_pci_init(h); in hpsa_init_one()
8890 if (h->lockup_detected) { in hpsa_init_one()
8891 free_percpu(h->lockup_detected); in hpsa_init_one()
8892 h->lockup_detected = NULL; in hpsa_init_one()
8895 if (h->resubmit_wq) { in hpsa_init_one()
8896 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8897 h->resubmit_wq = NULL; in hpsa_init_one()
8899 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8900 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8901 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8903 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8904 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8905 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8907 hpda_free_ctlr_info(h); in hpsa_init_one()
8911 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8917 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8923 c = cmd_alloc(h); in hpsa_flush_cache()
8925 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8929 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_flush_cache()
8935 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8937 cmd_free(h, c); in hpsa_flush_cache()
8944 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8951 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8958 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8961 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8965 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8973 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8977 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_disable_rld_caching()
8983 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8987 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8996 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
8999 cmd_free(h, c); in hpsa_disable_rld_caching()
9005 struct ctlr_info *h; in __hpsa_shutdown() local
9007 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
9012 hpsa_flush_cache(h); in __hpsa_shutdown()
9013 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9014 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
9015 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
9024 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
9028 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9029 kfree(h->dev[i]); in hpsa_free_device_info()
9030 h->dev[i] = NULL; in hpsa_free_device_info()
9036 struct ctlr_info *h; in hpsa_remove_one() local
9043 h = pci_get_drvdata(pdev); in hpsa_remove_one()
9046 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9047 h->remove_in_progress = 1; in hpsa_remove_one()
9048 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9049 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9050 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9051 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9052 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9053 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9054 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9056 hpsa_delete_sas_host(h); in hpsa_remove_one()
9064 if (h->scsi_host) in hpsa_remove_one()
9065 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9070 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
9072 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9073 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9074 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
9075 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
9076 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
9077 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
9078 kfree(h->lastlogicals); in hpsa_remove_one()
9082 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9083 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9086 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
9088 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9089 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9092 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9154 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9208 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9209 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9213 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9215 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9218 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9219 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9220 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9221 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9223 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9224 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9225 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9226 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9229 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9230 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9236 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9237 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9241 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9242 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9243 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9247 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9249 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9254 h->access = access; in hpsa_enter_performant_mode()
9255 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9263 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9264 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9265 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9266 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9268 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9269 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9270 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9273 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9274 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9276 h->reply_queue_size); in hpsa_enter_performant_mode()
9281 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9282 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9285 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9296 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9304 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9307 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9308 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9309 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9310 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9313 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9314 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9318 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9320 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9322 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9323 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9324 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9332 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9334 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9335 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9336 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9337 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9338 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9339 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9340 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9342 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9343 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9347 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9349 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9350 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9351 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9352 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9360 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9361 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9362 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9363 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9365 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9366 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9369 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9370 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9373 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9378 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9385 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9387 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9388 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9389 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9390 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9391 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9392 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9393 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9395 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9396 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9400 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9406 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9407 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9408 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9409 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9413 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9414 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9415 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9416 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9418 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9419 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9422 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9423 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9428 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9433 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9442 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9444 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9445 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9446 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9447 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9448 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9454 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9464 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9472 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9478 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9483 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9484 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9486 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9488 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9489 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9490 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9491 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9493 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9497 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9498 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9499 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9503 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9505 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9510 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9516 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9517 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9519 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9520 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9521 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9530 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9538 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9539 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9543 cmd_free(h, c); in hpsa_drain_accel_commands()
9715 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9721 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9722 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9732 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9740 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9746 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9762 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9777 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9779 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9835 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9841 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9843 if (!h) in hpsa_sas_get_enclosure_identifier()
9846 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()