Lines Matching refs:h

238 static int hpsa_add_sas_host(struct ctlr_info *h);
239 static void hpsa_delete_sas_host(struct ctlr_info *h);
244 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
263 static void cmd_free(struct ctlr_info *h, struct CommandList *c);
264 static struct CommandList *cmd_alloc(struct ctlr_info *h);
265 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c);
266 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
268 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
271 static void hpsa_free_cmd_pool(struct ctlr_info *h);
275 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
286 static void hpsa_update_scsi_devices(struct ctlr_info *h);
287 static int check_for_unit_attention(struct ctlr_info *h,
289 static void check_ioctl_unit_attention(struct ctlr_info *h,
294 static void hpsa_free_performant_mode(struct ctlr_info *h);
295 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
296 static inline u32 next_command(struct ctlr_info *h, u8 q);
304 static int wait_for_device_to_become_ready(struct ctlr_info *h,
310 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
313 static void hpsa_drain_accel_commands(struct ctlr_info *h);
314 static void hpsa_flush_cache(struct ctlr_info *h);
315 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
319 static u32 lockup_detected(struct ctlr_info *h);
320 static int detect_controller_lockup(struct ctlr_info *h);
321 static void hpsa_disable_rld_caching(struct ctlr_info *h);
322 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
324 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
326 static int hpsa_luns_changed(struct ctlr_info *h);
327 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
370 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
388 dev_warn(&h->pdev->dev, in check_for_unit_attention()
390 h->devname); in check_for_unit_attention()
393 dev_warn(&h->pdev->dev, in check_for_unit_attention()
394 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
397 dev_warn(&h->pdev->dev, in check_for_unit_attention()
398 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
405 dev_warn(&h->pdev->dev, in check_for_unit_attention()
407 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()
423 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
429 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
433 static u32 lockup_detected(struct ctlr_info *h);
438 struct ctlr_info *h; in host_show_lockup_detected() local
441 h = shost_to_hba(shost); in host_show_lockup_detected()
442 ld = lockup_detected(h); in host_show_lockup_detected()
452 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
463 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
464 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
465 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
467 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
476 struct ctlr_info *h; in host_store_raid_offload_debug() local
489 h = shost_to_hba(shost); in host_store_raid_offload_debug()
490 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
491 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
492 h->raid_offload_debug); in host_store_raid_offload_debug()
500 struct ctlr_info *h; in host_store_rescan() local
502 h = shost_to_hba(shost); in host_store_rescan()
503 hpsa_scan_start(h->scsi_host); in host_store_rescan()
510 struct ctlr_info *h; in host_show_firmware_revision() local
514 h = shost_to_hba(shost); in host_show_firmware_revision()
515 if (!h->hba_inquiry_data) in host_show_firmware_revision()
517 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
526 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
529 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
535 struct ctlr_info *h; in host_show_transport_mode() local
538 h = shost_to_hba(shost); in host_show_transport_mode()
540 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
547 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
550 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
552 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
631 struct ctlr_info *h; in host_show_resettable() local
634 h = shost_to_hba(shost); in host_show_resettable()
635 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
666 struct ctlr_info *h; in raid_level_show() local
672 h = sdev_to_hba(sdev); in raid_level_show()
673 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
676 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
682 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
688 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
698 struct ctlr_info *h; in lunid_show() local
705 h = sdev_to_hba(sdev); in lunid_show()
706 spin_lock_irqsave(&h->lock, flags); in lunid_show()
709 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
713 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
720 struct ctlr_info *h; in unique_id_show() local
727 h = sdev_to_hba(sdev); in unique_id_show()
728 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
731 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
735 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
748 struct ctlr_info *h; in sas_address_show() local
755 h = sdev_to_hba(sdev); in sas_address_show()
756 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
759 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
763 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
771 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
778 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
779 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
782 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
786 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
799 struct ctlr_info *h; in path_info_show() local
812 h = sdev_to_hba(sdev); in path_info_show()
813 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
816 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
833 h->scsi_host->host_no, in path_info_show()
877 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
884 struct ctlr_info *h; in host_show_ctlr_num() local
887 h = shost_to_hba(shost); in host_show_ctlr_num()
888 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
894 struct ctlr_info *h; in host_show_legacy_board() local
897 h = shost_to_hba(shost); in host_show_legacy_board()
898 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
979 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
982 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
984 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
985 return h->access.command_completed(h, q); in next_command()
987 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
988 return h->access.command_completed(h, q); in next_command()
993 atomic_dec(&h->commands_outstanding); in next_command()
998 if (rq->current_entry == h->max_commands) { in next_command()
1037 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1040 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1041 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1042 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1048 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1052 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1065 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1069 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1074 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1085 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1088 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1092 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1105 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1121 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1126 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1127 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1130 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1134 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1135 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1138 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1141 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1142 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1146 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1149 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1150 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1153 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1154 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1157 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1158 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1161 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1162 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1166 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1168 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1176 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1178 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1180 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1185 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1196 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1197 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1198 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1211 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1217 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1253 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1255 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1267 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1272 int n = h->ndevices; in hpsa_scsi_add_entry()
1278 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1294 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1310 sd = h->dev[i]; in hpsa_scsi_add_entry()
1323 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1331 h->dev[n] = device; in hpsa_scsi_add_entry()
1332 h->ndevices++; in hpsa_scsi_add_entry()
1335 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1345 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1352 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1357 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1369 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1370 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1373 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1376 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1377 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1378 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1379 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1386 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1392 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1394 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1398 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1405 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1413 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1414 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1417 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1421 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1425 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1434 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1435 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1438 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1439 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1440 h->ndevices--; in hpsa_scsi_remove_entry()
1441 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1454 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1463 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1464 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1465 if (h->dev[i] == added) { in fixup_botched_add()
1466 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1467 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1468 h->ndevices--; in fixup_botched_add()
1472 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1571 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1578 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1579 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1582 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1586 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1594 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1595 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1596 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1600 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1604 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1606 h->scsi_host->host_no, in hpsa_show_volume_status()
1612 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1614 h->scsi_host->host_no, in hpsa_show_volume_status()
1618 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1620 h->scsi_host->host_no, in hpsa_show_volume_status()
1624 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1626 h->scsi_host->host_no, in hpsa_show_volume_status()
1630 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1632 h->scsi_host->host_no, in hpsa_show_volume_status()
1636 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1638 h->scsi_host->host_no, in hpsa_show_volume_status()
1642 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1644 h->scsi_host->host_no, in hpsa_show_volume_status()
1648 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1650 h->scsi_host->host_no, in hpsa_show_volume_status()
1654 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1656 h->scsi_host->host_no, in hpsa_show_volume_status()
1660 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1662 h->scsi_host->host_no, in hpsa_show_volume_status()
1666 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1668 h->scsi_host->host_no, in hpsa_show_volume_status()
1672 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1674 h->scsi_host->host_no, in hpsa_show_volume_status()
1684 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1723 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1736 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1739 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1756 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1760 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1794 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1798 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1802 if (!h->scsi_host) in hpsa_add_device()
1806 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1809 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1814 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1820 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1821 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1824 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1828 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1831 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1834 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1841 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1852 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1861 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1864 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1869 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1874 if (!h->scsi_host) in hpsa_remove_device()
1881 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1884 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1895 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1904 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1921 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1922 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1923 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1924 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1927 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1933 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1938 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1950 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1951 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1955 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1959 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1966 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1985 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
1986 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
1990 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
1991 h->ndevices, &entry); in adjust_hpsa_scsi_table()
1994 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2000 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2005 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2015 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2016 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2018 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2021 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2031 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2046 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2059 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2062 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2067 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2068 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2080 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2086 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2087 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2098 struct ctlr_info *h; in hpsa_slave_alloc() local
2100 h = sdev_to_hba(sdev); in hpsa_slave_alloc()
2101 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2108 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_slave_alloc()
2115 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_slave_alloc()
2123 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2165 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2169 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2171 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2172 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2173 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2175 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2176 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2179 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2183 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2186 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2187 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2189 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2191 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2192 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2193 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2194 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2196 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2202 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2206 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2210 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2212 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2213 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2214 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2216 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2217 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2220 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2224 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2227 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2229 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2232 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2233 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2234 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2236 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2243 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2247 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2254 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2256 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2258 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2267 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2277 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2280 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2287 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2288 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2291 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2293 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2295 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2304 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2309 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2312 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2313 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2322 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2403 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2404 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2438 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2454 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2458 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2461 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2462 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2465 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2468 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2473 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2476 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2479 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2483 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2489 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2508 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2511 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2514 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2515 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2517 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2521 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2541 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2551 struct ctlr_info *h; in complete_scsi_command() local
2563 h = cp->h; in complete_scsi_command()
2567 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2573 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2575 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2579 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2580 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2584 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2591 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2599 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2613 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2617 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2621 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2627 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2643 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2670 h->drv_req_rescan = 1; in complete_scsi_command()
2685 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2692 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2714 dev_warn(&h->pdev->dev, in complete_scsi_command()
2731 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2736 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2741 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2749 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2754 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2759 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2764 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2767 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2775 dev_warn(&h->pdev->dev, in complete_scsi_command()
2780 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2784 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2829 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2835 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2843 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2849 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2852 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2856 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2859 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2865 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2872 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2881 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2891 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2892 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2894 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2900 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2906 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2910 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2914 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2926 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2941 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2947 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2952 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2955 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2958 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2961 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2964 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2967 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2970 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2973 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2976 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2979 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
2985 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
2992 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
2993 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
2998 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3004 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3008 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3012 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3023 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3036 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3044 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3046 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3051 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3057 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3061 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3065 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3072 c = cmd_alloc(h); in hpsa_send_reset()
3076 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3077 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3079 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3086 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3090 cmd_free(h, c); in hpsa_send_reset()
3094 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3100 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3145 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3153 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3159 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3160 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3164 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3168 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3170 lockup_detected(h)); in hpsa_do_reset()
3173 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3174 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3180 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3182 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3186 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3197 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3201 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3215 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3226 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3229 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3231 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3233 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3235 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3237 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3239 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3241 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3258 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3262 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3276 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3284 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3291 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3298 c = cmd_alloc(h); in hpsa_get_raid_map()
3300 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3303 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3304 cmd_free(h, c); in hpsa_get_raid_map()
3307 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3313 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3317 cmd_free(h, c); in hpsa_get_raid_map()
3322 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3325 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3328 cmd_free(h, c); in hpsa_get_raid_map()
3332 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3340 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3342 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3350 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3356 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3360 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3364 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3371 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3373 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3378 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3384 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3388 cmd_free(h, c); in hpsa_bmic_id_controller()
3392 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3400 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3401 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3409 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3413 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3417 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3428 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3442 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3464 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3467 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3472 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3474 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3485 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3506 cmd_free(h, c); in hpsa_get_enclosure_info()
3509 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3513 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3525 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3526 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3543 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3556 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3560 h->sas_address = sa; in hpsa_get_sas_address()
3565 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3570 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3576 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3585 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3587 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3588 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3595 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3608 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3620 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3645 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3659 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3661 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3675 if (hpsa_get_raid_map(h, scsi3addr, this_device)) in hpsa_get_ioaccel_status()
3685 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3692 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3699 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3712 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3721 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3725 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3732 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3739 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3745 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3746 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3756 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3760 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3766 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3776 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3791 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3794 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3806 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3819 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3823 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3830 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3850 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3864 c = cmd_alloc(h); in hpsa_volume_offline()
3866 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3867 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3870 cmd_free(h, c); in hpsa_volume_offline()
3881 cmd_free(h, c); in hpsa_volume_offline()
3884 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3913 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3934 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3936 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3955 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3957 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3959 h->ctlr, __func__, in hpsa_update_device_info()
3960 h->scsi_host->host_no, in hpsa_update_device_info()
3974 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
3975 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
3976 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
3977 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
3979 h->legacy_board) { in hpsa_update_device_info()
3983 dev_info(&h->pdev->dev, in hpsa_update_device_info()
3991 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4003 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4032 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4063 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4090 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4094 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4095 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4100 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4104 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4105 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4111 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4118 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4127 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4155 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4169 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4210 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4217 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4222 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4234 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4244 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4261 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4293 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4299 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4335 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4340 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4342 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4344 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4349 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4350 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4361 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4366 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4374 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4380 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4398 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4403 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4410 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4417 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4420 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4422 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4426 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4430 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4450 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4470 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4483 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4505 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4508 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4510 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4516 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4544 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4552 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4569 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4570 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4584 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4595 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4596 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4599 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4601 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4615 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4619 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4701 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4706 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4716 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4724 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4737 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4771 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4790 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4798 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4812 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4819 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4860 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4875 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4880 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4894 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4897 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4909 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4924 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4926 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4934 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4968 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
4979 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
4991 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4994 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5007 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5014 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5033 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5034 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5038 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5072 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5405 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5415 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5464 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5470 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5471 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5476 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5482 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5487 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5495 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5496 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5498 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5504 c->h = h; in hpsa_cmd_init()
5508 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5512 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5513 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5515 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5520 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5523 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5532 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5550 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5554 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5558 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5562 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5579 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5584 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5588 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5589 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5594 rc = hpsa_ioaccel_submit(h, c, cmd); in hpsa_command_resubmit_worker()
5604 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5609 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5610 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5627 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5633 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5650 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5659 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5675 h->acciopath_status)) { in hpsa_scsi_queue_command()
5676 rc = hpsa_ioaccel_submit(h, c, cmd); in hpsa_scsi_queue_command()
5680 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5684 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5687 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5691 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5692 h->scan_finished = 1; in hpsa_scan_complete()
5693 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5694 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5699 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5708 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5709 return hpsa_scan_complete(h); in hpsa_scan_start()
5714 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5715 if (h->scan_waiting) { in hpsa_scan_start()
5716 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5720 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5724 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5725 if (h->scan_finished) in hpsa_scan_start()
5727 h->scan_waiting = 1; in hpsa_scan_start()
5728 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5729 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5736 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5737 h->scan_waiting = 0; in hpsa_scan_start()
5738 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5740 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5741 return hpsa_scan_complete(h); in hpsa_scan_start()
5746 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5747 if (h->reset_in_progress) { in hpsa_scan_start()
5748 h->drv_req_rescan = 1; in hpsa_scan_start()
5749 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5750 hpsa_scan_complete(h); in hpsa_scan_start()
5753 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5755 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5757 hpsa_scan_complete(h); in hpsa_scan_start()
5778 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5782 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5783 finished = h->scan_finished; in hpsa_scan_finished()
5784 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5788 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5792 sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h)); in hpsa_scsi_host_alloc()
5794 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5805 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5807 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5809 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5810 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5813 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5817 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5821 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5823 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5826 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5851 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5858 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5860 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5887 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5904 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5912 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5920 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5930 c = cmd_alloc(h); in wait_for_device_to_become_ready()
5939 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
5946 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
5952 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
5954 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
5956 cmd_free(h, c); in wait_for_device_to_become_ready()
5967 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
5974 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
5975 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
5978 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
5979 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
5980 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
5982 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
5989 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6000 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6004 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6010 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6014 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6032 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6046 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6055 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6058 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6059 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6062 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6072 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6076 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6078 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6079 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6080 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6094 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6095 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6099 h->last_collision_tag = idx; in cmd_tagged_alloc()
6106 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6110 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6128 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6154 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6161 c = h->cmd_pool + i; in cmd_alloc()
6164 cmd_free(h, c); /* already in use */ in cmd_alloc()
6169 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_alloc()
6172 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6183 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6188 i = c - h->cmd_pool; in cmd_free()
6190 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_free()
6302 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6308 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6309 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6310 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6311 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6317 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6326 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6340 static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_passthru_ioctl() argument
6373 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6395 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6397 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6407 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6410 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6411 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6433 cmd_free(h, c); in hpsa_passthru_ioctl()
6439 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_big_passthru_ioctl() argument
6506 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6518 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6520 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6524 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6535 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6538 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6539 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6566 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6580 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6585 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6594 struct ctlr_info *h; in hpsa_ioctl() local
6598 h = sdev_to_hba(dev); in hpsa_ioctl()
6604 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6607 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6609 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6611 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6613 rc = hpsa_passthru_ioctl(h, argp); in hpsa_ioctl()
6614 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6617 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6619 rc = hpsa_big_passthru_ioctl(h, argp); in hpsa_ioctl()
6620 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6627 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6631 c = cmd_alloc(h); in hpsa_send_host_reset()
6634 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6638 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6646 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6809 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6845 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6850 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6867 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6885 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6887 return h->access.command_completed(h, q); in get_next_completion()
6890 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6892 return h->access.intr_pending(h); in interrupt_pending()
6895 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6897 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6898 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6901 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6904 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6905 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6913 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6922 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6929 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6930 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6940 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6945 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6948 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
6966 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
6970 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
6973 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
6975 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
6976 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
6977 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
6979 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
6986 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
6990 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
6993 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
6994 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
6996 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7002 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7006 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7008 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7009 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7010 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7012 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7013 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7021 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7025 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7026 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7028 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7029 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7432 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7434 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7435 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7438 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7443 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7444 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7449 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7455 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7461 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7467 switch (h->board_id) { in hpsa_interrupt_mode()
7474 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7477 h->msix_vectors = ret; in hpsa_interrupt_mode()
7485 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7580 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7582 if (h->transtable) { in hpsa_free_cfgtables()
7583 iounmap(h->transtable); in hpsa_free_cfgtables()
7584 h->transtable = NULL; in hpsa_free_cfgtables()
7586 if (h->cfgtable) { in hpsa_free_cfgtables()
7587 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7588 h->cfgtable = NULL; in hpsa_free_cfgtables()
7595 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7603 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7607 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7608 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7609 if (!h->cfgtable) { in hpsa_find_cfgtables()
7610 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7613 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7617 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7618 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7620 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7621 if (!h->transtable) { in hpsa_find_cfgtables()
7622 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7623 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7629 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7634 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7637 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7638 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7640 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7641 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7643 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7645 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7653 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7655 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7662 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7664 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7665 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7666 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7667 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7668 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7670 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7671 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7672 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7679 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7680 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7681 h->chainsize = 0; in hpsa_find_board_params()
7685 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7686 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7687 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7688 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7689 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7690 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7691 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7694 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7696 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7697 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7703 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7707 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7713 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7719 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7723 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7725 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7727 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7730 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7737 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7738 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7739 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7750 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7761 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7763 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7764 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7765 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7777 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7781 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7785 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7788 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7789 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7790 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7791 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7793 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7794 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7796 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7799 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7804 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7806 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7807 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7808 h->vaddr = NULL; in hpsa_free_pci_init()
7809 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7814 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7815 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7819 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7824 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7827 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7828 h->access = *(products[prod_index].access); in hpsa_pci_init()
7829 h->legacy_board = legacy_board; in hpsa_pci_init()
7830 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7833 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7835 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7836 pci_disable_device(h->pdev); in hpsa_pci_init()
7840 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7842 dev_err(&h->pdev->dev, in hpsa_pci_init()
7844 pci_disable_device(h->pdev); in hpsa_pci_init()
7848 pci_set_master(h->pdev); in hpsa_pci_init()
7850 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7855 hpsa_setup_reply_map(h); in hpsa_pci_init()
7857 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7860 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7861 if (!h->vaddr) { in hpsa_pci_init()
7862 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7866 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7869 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7872 hpsa_find_board_params(h); in hpsa_pci_init()
7874 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7878 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7879 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7880 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7886 hpsa_free_cfgtables(h); in hpsa_pci_init()
7888 iounmap(h->vaddr); in hpsa_pci_init()
7889 h->vaddr = NULL; in hpsa_pci_init()
7891 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7897 pci_disable_device(h->pdev); in hpsa_pci_init()
7898 pci_release_regions(h->pdev); in hpsa_pci_init()
7902 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7907 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7908 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7910 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7911 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7913 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7914 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
7980 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
7982 kfree(h->cmd_pool_bits); in hpsa_free_cmd_pool()
7983 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
7984 if (h->cmd_pool) { in hpsa_free_cmd_pool()
7985 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
7986 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
7987 h->cmd_pool, in hpsa_free_cmd_pool()
7988 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
7989 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
7990 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
7992 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
7993 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
7994 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
7995 h->errinfo_pool, in hpsa_free_cmd_pool()
7996 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
7997 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
7998 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8002 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8004 h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), in hpsa_alloc_cmd_pool()
8007 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8008 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8009 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8010 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8011 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8012 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8013 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8014 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8015 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8016 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8019 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
8022 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
8027 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
8033 irq_vector = h->intr_mode; in hpsa_free_irqs()
8035 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8037 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8038 &h->q[h->intr_mode]); in hpsa_free_irqs()
8039 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8043 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8044 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8045 h->q[i] = 0; in hpsa_free_irqs()
8048 h->q[i] = 0; in hpsa_free_irqs()
8052 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
8060 irq_vector = h->intr_mode; in hpsa_request_irqs()
8067 h->q[i] = (u8) i; in hpsa_request_irqs()
8069 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8071 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8072 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8073 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8074 0, h->intrname[i], in hpsa_request_irqs()
8075 &h->q[i]); in hpsa_request_irqs()
8079 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8081 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8083 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8084 h->q[j] = 0; in hpsa_request_irqs()
8087 h->q[j] = 0; in hpsa_request_irqs()
8093 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8094 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8095 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8096 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8098 h->intrname[0], in hpsa_request_irqs()
8099 &h->q[h->intr_mode]); in hpsa_request_irqs()
8101 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8102 "%s-intx", h->devname); in hpsa_request_irqs()
8103 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8105 h->intrname[0], in hpsa_request_irqs()
8106 &h->q[h->intr_mode]); in hpsa_request_irqs()
8110 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8111 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8112 hpsa_free_irqs(h); in hpsa_request_irqs()
8118 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8121 hpsa_send_host_reset(h, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8123 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8124 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8126 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8130 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8131 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8133 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8141 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8145 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8146 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8148 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8149 h->reply_queue_size, in hpsa_free_reply_queues()
8150 h->reply_queue[i].head, in hpsa_free_reply_queues()
8151 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8152 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8153 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8155 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8158 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8160 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8161 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8162 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8163 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8164 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8165 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8166 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8167 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8168 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8169 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8170 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8171 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8173 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8174 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8175 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8177 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8178 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8179 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8182 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8186 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8192 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8193 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8194 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8199 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8202 cmd_free(h, c); in fail_all_outstanding_cmds()
8204 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8208 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8214 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8220 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8225 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8226 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8227 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8230 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8232 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8235 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8236 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8237 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8238 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8240 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8241 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8243 pci_disable_device(h->pdev); in controller_lockup_detected()
8244 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8247 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8255 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8256 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8264 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8265 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8269 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8270 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8271 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8272 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8273 controller_lockup_detected(h); in detect_controller_lockup()
8278 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8279 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8292 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8300 if (!h) in hpsa_set_ioaccel_status()
8310 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8311 device = h->dev[i]; in hpsa_set_ioaccel_status()
8315 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8321 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8352 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8356 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8360 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8362 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8363 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8365 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8367 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8370 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8371 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8372 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8374 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8376 h->events, event_type); in hpsa_ack_ctlr_events()
8377 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8379 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8381 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8382 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8385 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8386 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8387 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8397 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8399 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8400 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8404 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8407 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8408 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8414 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8420 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8421 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8424 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8425 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8426 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8428 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8431 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8433 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8437 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8446 if (!h->lastlogicals) in hpsa_luns_changed()
8453 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8454 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8458 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8459 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8461 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8470 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8478 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8479 if (h->reset_in_progress) { in hpsa_perform_rescan()
8480 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8481 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8484 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8486 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8490 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8499 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8503 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8504 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8505 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8508 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8510 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8511 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8512 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8515 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8516 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8517 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8519 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8525 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8528 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8529 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8530 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8533 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8535 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8536 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8537 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8538 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8539 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8541 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8544 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8545 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8546 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8547 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8548 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8554 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8557 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8558 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8561 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8562 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8563 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8564 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8565 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8568 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8573 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8575 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8580 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8582 kfree(h->reply_map); in hpda_free_ctlr_info()
8583 kfree(h); in hpda_free_ctlr_info()
8588 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8590 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8591 if (!h) in hpda_alloc_ctlr_info()
8594 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8595 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8596 kfree(h); in hpda_alloc_ctlr_info()
8599 return h; in hpda_alloc_ctlr_info()
8605 struct ctlr_info *h; in hpsa_init_one() local
8639 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8640 if (!h) { in hpsa_init_one()
8645 h->pdev = pdev; in hpsa_init_one()
8647 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8648 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8649 spin_lock_init(&h->lock); in hpsa_init_one()
8650 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8651 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8652 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8653 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8656 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8657 if (!h->lockup_detected) { in hpsa_init_one()
8658 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8662 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8664 rc = hpsa_pci_init(h); in hpsa_init_one()
8670 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8674 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8675 h->ctlr = number_of_controllers; in hpsa_init_one()
8693 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8695 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8698 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8701 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8704 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8705 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8706 mutex_init(&h->reset_mutex); in hpsa_init_one()
8707 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8708 h->scan_waiting = 0; in hpsa_init_one()
8710 pci_set_drvdata(pdev, h); in hpsa_init_one()
8711 h->ndevices = 0; in hpsa_init_one()
8713 spin_lock_init(&h->devlock); in hpsa_init_one()
8714 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8719 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8720 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8725 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8726 if (!h->resubmit_wq) { in hpsa_init_one()
8731 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8732 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8751 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8752 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8753 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8754 hpsa_free_irqs(h); in hpsa_init_one()
8755 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8758 dev_warn(&h->pdev->dev, in hpsa_init_one()
8764 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8765 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8766 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8774 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8779 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8780 dev_info(&h->pdev->dev, in hpsa_init_one()
8782 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8784 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8786 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8788 dev_info(&h->pdev->dev, in hpsa_init_one()
8795 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8805 h->acciopath_status = 1; in hpsa_init_one()
8807 h->discovery_polling = 0; in hpsa_init_one()
8811 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8813 hpsa_hba_inquiry(h); in hpsa_init_one()
8815 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8816 if (!h->lastlogicals) in hpsa_init_one()
8817 dev_info(&h->pdev->dev, in hpsa_init_one()
8821 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8826 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8827 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8828 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8829 h->heartbeat_sample_interval); in hpsa_init_one()
8830 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8831 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8832 h->heartbeat_sample_interval); in hpsa_init_one()
8833 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8834 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8839 hpsa_free_performant_mode(h); in hpsa_init_one()
8840 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8842 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8844 hpsa_free_cmd_pool(h); in hpsa_init_one()
8846 hpsa_free_irqs(h); in hpsa_init_one()
8848 scsi_host_put(h->scsi_host); in hpsa_init_one()
8849 h->scsi_host = NULL; in hpsa_init_one()
8851 hpsa_free_pci_init(h); in hpsa_init_one()
8853 if (h->lockup_detected) { in hpsa_init_one()
8854 free_percpu(h->lockup_detected); in hpsa_init_one()
8855 h->lockup_detected = NULL; in hpsa_init_one()
8858 if (h->resubmit_wq) { in hpsa_init_one()
8859 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8860 h->resubmit_wq = NULL; in hpsa_init_one()
8862 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8863 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8864 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8866 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8867 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8868 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8870 kfree(h); in hpsa_init_one()
8874 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8880 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8886 c = cmd_alloc(h); in hpsa_flush_cache()
8888 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8892 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_flush_cache()
8898 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8900 cmd_free(h, c); in hpsa_flush_cache()
8907 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8914 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8921 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8924 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8928 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8936 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8940 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_disable_rld_caching()
8946 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8950 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8959 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
8962 cmd_free(h, c); in hpsa_disable_rld_caching()
8968 struct ctlr_info *h; in __hpsa_shutdown() local
8970 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
8975 hpsa_flush_cache(h); in __hpsa_shutdown()
8976 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
8977 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
8978 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
8987 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
8991 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
8992 kfree(h->dev[i]); in hpsa_free_device_info()
8993 h->dev[i] = NULL; in hpsa_free_device_info()
8999 struct ctlr_info *h; in hpsa_remove_one() local
9006 h = pci_get_drvdata(pdev); in hpsa_remove_one()
9009 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9010 h->remove_in_progress = 1; in hpsa_remove_one()
9011 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9012 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9013 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9014 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9015 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9016 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9017 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9019 hpsa_delete_sas_host(h); in hpsa_remove_one()
9027 if (h->scsi_host) in hpsa_remove_one()
9028 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9033 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
9035 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9036 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9037 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
9038 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
9039 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
9040 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
9041 kfree(h->lastlogicals); in hpsa_remove_one()
9045 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9046 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9049 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
9051 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9052 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9055 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9117 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9171 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9172 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9176 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9178 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9181 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9182 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9183 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9184 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9186 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9187 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9188 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9189 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9192 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9193 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9199 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9200 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9204 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9205 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9206 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9210 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9212 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9217 h->access = access; in hpsa_enter_performant_mode()
9218 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9226 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9227 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9228 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9229 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9231 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9232 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9233 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9236 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9237 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9239 h->reply_queue_size); in hpsa_enter_performant_mode()
9244 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9245 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9248 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9259 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9267 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9270 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9271 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9272 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9273 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9276 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9277 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9281 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9283 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9285 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9286 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9287 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9295 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9297 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9298 pci_free_consistent(h->pdev, in hpsa_free_ioaccel1_cmd_and_bft()
9299 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9300 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9301 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9302 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9303 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9305 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9306 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9310 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9312 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9313 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9314 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9315 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9323 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9324 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9325 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9326 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9328 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9329 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9332 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9333 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9336 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9337 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9341 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9346 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9348 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9350 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9351 pci_free_consistent(h->pdev, in hpsa_free_ioaccel2_cmd_and_bft()
9352 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9353 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9354 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9355 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9356 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9358 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9359 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9363 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9369 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9370 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9371 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9372 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9376 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9377 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9378 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9379 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9381 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9382 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9385 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9386 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9391 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9395 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9396 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9400 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9405 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9407 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9408 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9409 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9410 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9411 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9417 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9427 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9435 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9441 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9446 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9447 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9449 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9451 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9452 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9453 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9454 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9456 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9460 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9461 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9462 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9466 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9468 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9473 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9479 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9480 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9482 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9483 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9484 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9493 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9501 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9502 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9506 cmd_free(h, c); in hpsa_drain_accel_commands()
9678 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9684 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9685 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9695 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9703 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9709 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9725 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9739 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9741 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9795 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9801 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9803 if (!h) in hpsa_sas_get_enclosure_identifier()
9806 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()