Lines Matching refs:h

237 static int hpsa_add_sas_host(struct ctlr_info *h);
238 static void hpsa_delete_sas_host(struct ctlr_info *h);
243 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
261 static void cmd_free(struct ctlr_info *h, struct CommandList *c);
262 static struct CommandList *cmd_alloc(struct ctlr_info *h);
263 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c);
264 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
266 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
269 static void hpsa_free_cmd_pool(struct ctlr_info *h);
273 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
284 static void hpsa_update_scsi_devices(struct ctlr_info *h);
285 static int check_for_unit_attention(struct ctlr_info *h,
287 static void check_ioctl_unit_attention(struct ctlr_info *h,
292 static void hpsa_free_performant_mode(struct ctlr_info *h);
293 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
294 static inline u32 next_command(struct ctlr_info *h, u8 q);
302 static int wait_for_device_to_become_ready(struct ctlr_info *h,
308 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
311 static void hpsa_drain_accel_commands(struct ctlr_info *h);
312 static void hpsa_flush_cache(struct ctlr_info *h);
313 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
317 static u32 lockup_detected(struct ctlr_info *h);
318 static int detect_controller_lockup(struct ctlr_info *h);
319 static void hpsa_disable_rld_caching(struct ctlr_info *h);
320 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
322 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
324 static int hpsa_luns_changed(struct ctlr_info *h);
325 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
373 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
391 dev_warn(&h->pdev->dev, in check_for_unit_attention()
393 h->devname); in check_for_unit_attention()
396 dev_warn(&h->pdev->dev, in check_for_unit_attention()
397 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
400 dev_warn(&h->pdev->dev, in check_for_unit_attention()
401 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
408 dev_warn(&h->pdev->dev, in check_for_unit_attention()
410 h->devname); in check_for_unit_attention()
413 dev_warn(&h->pdev->dev, in check_for_unit_attention()
415 h->devname); in check_for_unit_attention()
418 dev_warn(&h->pdev->dev, in check_for_unit_attention()
420 h->devname); in check_for_unit_attention()
426 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
432 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
436 static u32 lockup_detected(struct ctlr_info *h);
441 struct ctlr_info *h; in host_show_lockup_detected() local
444 h = shost_to_hba(shost); in host_show_lockup_detected()
445 ld = lockup_detected(h); in host_show_lockup_detected()
455 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
466 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
467 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
468 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
470 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
479 struct ctlr_info *h; in host_store_raid_offload_debug() local
492 h = shost_to_hba(shost); in host_store_raid_offload_debug()
493 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
494 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
495 h->raid_offload_debug); in host_store_raid_offload_debug()
503 struct ctlr_info *h; in host_store_rescan() local
505 h = shost_to_hba(shost); in host_store_rescan()
506 hpsa_scan_start(h->scsi_host); in host_store_rescan()
513 struct ctlr_info *h; in host_show_firmware_revision() local
517 h = shost_to_hba(shost); in host_show_firmware_revision()
518 if (!h->hba_inquiry_data) in host_show_firmware_revision()
520 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
529 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
532 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
538 struct ctlr_info *h; in host_show_transport_mode() local
541 h = shost_to_hba(shost); in host_show_transport_mode()
543 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
550 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
553 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
555 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
634 struct ctlr_info *h; in host_show_resettable() local
637 h = shost_to_hba(shost); in host_show_resettable()
638 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
669 struct ctlr_info *h; in raid_level_show() local
675 h = sdev_to_hba(sdev); in raid_level_show()
676 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
679 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
685 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
691 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
701 struct ctlr_info *h; in lunid_show() local
708 h = sdev_to_hba(sdev); in lunid_show()
709 spin_lock_irqsave(&h->lock, flags); in lunid_show()
712 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
716 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
723 struct ctlr_info *h; in unique_id_show() local
730 h = sdev_to_hba(sdev); in unique_id_show()
731 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
734 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
738 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
751 struct ctlr_info *h; in sas_address_show() local
758 h = sdev_to_hba(sdev); in sas_address_show()
759 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
762 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
766 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
774 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
781 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
782 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
785 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
789 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
802 struct ctlr_info *h; in path_info_show() local
815 h = sdev_to_hba(sdev); in path_info_show()
816 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
819 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
836 h->scsi_host->host_no, in path_info_show()
880 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
887 struct ctlr_info *h; in host_show_ctlr_num() local
890 h = shost_to_hba(shost); in host_show_ctlr_num()
891 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
897 struct ctlr_info *h; in host_show_legacy_board() local
900 h = shost_to_hba(shost); in host_show_legacy_board()
901 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
983 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
986 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
988 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
989 return h->access.command_completed(h, q); in next_command()
991 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
992 return h->access.command_completed(h, q); in next_command()
997 atomic_dec(&h->commands_outstanding); in next_command()
1002 if (rq->current_entry == h->max_commands) { in next_command()
1041 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1044 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1045 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1046 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1052 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1056 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1069 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1073 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1078 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1089 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1092 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1096 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1109 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1125 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1130 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1131 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1134 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1138 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1139 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1142 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1145 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1146 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1148 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1151 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1152 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1155 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1156 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1159 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1160 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1163 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1164 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1168 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1173 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1181 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1183 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1185 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1190 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1201 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1202 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1203 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1216 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1222 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1258 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1260 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1272 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1277 int n = h->ndevices; in hpsa_scsi_add_entry()
1283 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1299 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1315 sd = h->dev[i]; in hpsa_scsi_add_entry()
1328 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1336 h->dev[n] = device; in hpsa_scsi_add_entry()
1337 h->ndevices++; in hpsa_scsi_add_entry()
1340 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1350 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1357 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1362 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1374 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1375 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1378 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1381 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1382 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1383 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1384 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1391 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1397 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1399 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1403 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1410 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1418 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1419 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1422 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1426 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1430 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1439 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1440 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1443 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1444 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1445 h->ndevices--; in hpsa_scsi_remove_entry()
1446 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1459 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1468 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1469 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1470 if (h->dev[i] == added) { in fixup_botched_add()
1471 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1472 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1473 h->ndevices--; in fixup_botched_add()
1477 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1576 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1583 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1584 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1587 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1591 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1599 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1600 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1601 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1605 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1609 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1611 h->scsi_host->host_no, in hpsa_show_volume_status()
1617 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1619 h->scsi_host->host_no, in hpsa_show_volume_status()
1623 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1625 h->scsi_host->host_no, in hpsa_show_volume_status()
1629 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1631 h->scsi_host->host_no, in hpsa_show_volume_status()
1635 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1637 h->scsi_host->host_no, in hpsa_show_volume_status()
1641 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1643 h->scsi_host->host_no, in hpsa_show_volume_status()
1647 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1649 h->scsi_host->host_no, in hpsa_show_volume_status()
1653 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1655 h->scsi_host->host_no, in hpsa_show_volume_status()
1659 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1661 h->scsi_host->host_no, in hpsa_show_volume_status()
1665 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1667 h->scsi_host->host_no, in hpsa_show_volume_status()
1671 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1673 h->scsi_host->host_no, in hpsa_show_volume_status()
1677 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1679 h->scsi_host->host_no, in hpsa_show_volume_status()
1689 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1728 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1741 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1744 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1761 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1765 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1799 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1803 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1807 if (!h->scsi_host) in hpsa_add_device()
1811 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1814 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1819 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1825 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1826 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1829 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1833 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1836 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1839 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1845 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()
1866 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1871 if (!h->scsi_host) in hpsa_remove_device()
1878 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1881 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1892 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1901 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1918 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1919 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1920 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1921 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1924 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1930 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1935 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1947 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1948 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1952 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1956 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1963 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1982 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
1983 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
1987 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
1988 h->ndevices, &entry); in adjust_hpsa_scsi_table()
1991 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
1997 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2002 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2012 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2013 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2015 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2018 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2028 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2043 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2056 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2059 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2064 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2065 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2077 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2083 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2084 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2095 struct ctlr_info *h; in hpsa_slave_alloc() local
2097 h = sdev_to_hba(sdev); in hpsa_slave_alloc()
2098 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2105 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_slave_alloc()
2112 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_slave_alloc()
2120 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2152 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2156 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2158 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2159 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2160 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2162 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2163 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2166 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2170 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2173 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2174 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2176 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2178 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2179 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2180 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2181 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2183 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2189 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2193 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2197 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2199 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2200 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2201 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2203 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2204 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2207 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2211 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2214 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2216 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2219 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2220 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2221 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2223 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2230 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2234 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2241 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2243 temp64 = pci_map_single(h->pdev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2245 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2254 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2264 pci_unmap_single(h->pdev, temp64, chain_size, PCI_DMA_TODEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2267 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2274 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2275 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2278 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2280 temp64 = pci_map_single(h->pdev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2282 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2291 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2296 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2299 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2300 pci_unmap_single(h->pdev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2309 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2388 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2389 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2420 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2441 spin_lock_irqsave(&h->lock, flags); in hpsa_cmd_resolve_events()
2446 spin_unlock_irqrestore(&h->lock, flags); in hpsa_cmd_resolve_events()
2450 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2453 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2456 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2457 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2460 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2463 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2468 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2471 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2474 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2478 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2483 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2499 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2502 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2503 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2505 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2509 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2529 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2539 struct ctlr_info *h; in complete_scsi_command() local
2551 h = cp->h; in complete_scsi_command()
2555 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2561 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2563 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2567 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2568 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2572 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2581 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2595 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2600 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2603 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2607 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2613 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2629 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2660 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2667 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2689 dev_warn(&h->pdev->dev, in complete_scsi_command()
2706 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2711 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2716 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2724 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2729 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2734 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2739 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2742 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2750 dev_warn(&h->pdev->dev, in complete_scsi_command()
2755 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2759 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2804 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2810 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2818 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2824 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2827 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2831 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2834 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2840 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2847 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2855 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2865 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2866 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2868 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2874 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2880 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2884 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2888 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2900 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2915 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2921 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2926 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2929 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2932 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2935 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2938 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2941 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2944 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2947 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2950 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2953 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
2959 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
2966 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
2967 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
2972 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_do_receive_diagnostic()
2978 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
2982 cmd_free(h, c); in hpsa_do_receive_diagnostic()
2986 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
2997 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3010 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3018 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3020 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3025 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_scsi_do_inquiry()
3031 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3035 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3039 static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_send_reset() argument
3046 c = cmd_alloc(h); in hpsa_send_reset()
3050 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, in hpsa_send_reset()
3052 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3054 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3061 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3065 cmd_free(h, c); in hpsa_send_reset()
3069 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3075 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3120 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3128 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3135 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3136 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3142 for (i = 0; i < h->nr_cmds; i++) { in hpsa_do_reset()
3143 struct CommandList *c = h->cmd_pool + i; in hpsa_do_reset()
3146 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, scsi3addr)) { in hpsa_do_reset()
3156 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_do_reset()
3161 spin_unlock_irqrestore(&h->lock, flags); in hpsa_do_reset()
3164 cmd_free(h, c); in hpsa_do_reset()
3167 rc = hpsa_send_reset(h, scsi3addr, reset_type, reply_queue); in hpsa_do_reset()
3169 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3171 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()
3182 rc = wait_for_device_to_become_ready(h, scsi3addr, 0); in hpsa_do_reset()
3184 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3188 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3199 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3203 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3217 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3228 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3231 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3233 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3235 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3237 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3239 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3241 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3260 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3264 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3271 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3278 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3286 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3293 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3300 c = cmd_alloc(h); in hpsa_get_raid_map()
3302 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3305 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3306 cmd_free(h, c); in hpsa_get_raid_map()
3309 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_get_raid_map()
3315 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3319 cmd_free(h, c); in hpsa_get_raid_map()
3324 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3327 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3330 cmd_free(h, c); in hpsa_get_raid_map()
3334 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3342 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3344 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3352 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_bmic_sense_subsystem_information()
3358 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3362 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3366 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3373 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3375 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3380 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_bmic_id_controller()
3386 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3390 cmd_free(h, c); in hpsa_bmic_id_controller()
3394 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3402 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3403 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3411 hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE, in hpsa_bmic_id_physical_device()
3415 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3419 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3430 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3444 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3466 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3469 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3474 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3476 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3487 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE, in hpsa_get_enclosure_info()
3508 cmd_free(h, c); in hpsa_get_enclosure_info()
3511 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3515 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3527 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3528 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3545 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3558 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3562 h->sas_address = sa; in hpsa_get_sas_address()
3567 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3572 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3578 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3587 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3589 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3590 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3597 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3610 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3622 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3647 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3661 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3663 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3677 if (hpsa_get_raid_map(h, scsi3addr, this_device)) in hpsa_get_ioaccel_status()
3687 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3694 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3701 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3714 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3723 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3727 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3734 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_scsi_do_report_luns()
3741 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3747 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3748 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3758 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3762 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3768 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3778 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3793 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3796 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3808 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3821 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3825 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3832 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3852 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3866 c = cmd_alloc(h); in hpsa_volume_offline()
3868 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3869 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3872 cmd_free(h, c); in hpsa_volume_offline()
3883 cmd_free(h, c); in hpsa_volume_offline()
3886 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3915 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3936 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3938 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3957 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3959 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3961 h->ctlr, __func__, in hpsa_update_device_info()
3962 h->scsi_host->host_no, in hpsa_update_device_info()
3972 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
3973 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
3974 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
3975 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
3977 h->legacy_board) { in hpsa_update_device_info()
3981 dev_info(&h->pdev->dev, in hpsa_update_device_info()
3989 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4001 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4030 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4061 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4088 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4092 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4093 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4098 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4102 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4103 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4109 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4116 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4125 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4153 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4167 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4208 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4215 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4220 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4232 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4242 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4259 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4291 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4297 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4333 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4338 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4340 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4342 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4347 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4348 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4359 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4364 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4372 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4378 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4396 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4401 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4408 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4415 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4418 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4420 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4424 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4428 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4448 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4468 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4481 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4503 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4506 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4508 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4514 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4542 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4550 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4567 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4568 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4582 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4593 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4594 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4597 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4599 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4613 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4617 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4698 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4703 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4713 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4721 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4734 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4768 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4787 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4795 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4806 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4813 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4854 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4869 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4874 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4888 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4891 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4903 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4918 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4920 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4928 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4957 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
4968 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
4980 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4983 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
4991 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
4998 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5014 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5015 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5019 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5053 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5379 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5389 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5438 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5444 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5445 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5448 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5453 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5461 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5462 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5464 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5470 c->h = h; in hpsa_cmd_init()
5474 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5478 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5479 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5481 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5486 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5489 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5498 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5511 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5514 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5518 hpsa_cmd_init(h, c->cmdindex, c); in hpsa_ioaccel_submit()
5521 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5538 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5541 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5543 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5544 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5549 rc = hpsa_ioaccel_submit(h, c, cmd, dev->scsi3addr); in hpsa_command_resubmit_worker()
5559 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5564 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5565 if (hpsa_ciss_submit(c->h, c, cmd, dev->scsi3addr)) { in hpsa_command_resubmit_worker()
5582 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5589 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5608 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5613 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5621 h->acciopath_status)) { in hpsa_scsi_queue_command()
5622 rc = hpsa_ioaccel_submit(h, c, cmd, scsi3addr); in hpsa_scsi_queue_command()
5626 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5630 return hpsa_ciss_submit(h, c, cmd, scsi3addr); in hpsa_scsi_queue_command()
5633 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5637 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5638 h->scan_finished = 1; in hpsa_scan_complete()
5639 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5640 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5645 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5654 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5655 return hpsa_scan_complete(h); in hpsa_scan_start()
5660 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5661 if (h->scan_waiting) { in hpsa_scan_start()
5662 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5666 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5670 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5671 if (h->scan_finished) in hpsa_scan_start()
5673 h->scan_waiting = 1; in hpsa_scan_start()
5674 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5675 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5682 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5683 h->scan_waiting = 0; in hpsa_scan_start()
5684 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5686 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5687 return hpsa_scan_complete(h); in hpsa_scan_start()
5692 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5693 if (h->reset_in_progress) { in hpsa_scan_start()
5694 h->drv_req_rescan = 1; in hpsa_scan_start()
5695 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5696 hpsa_scan_complete(h); in hpsa_scan_start()
5699 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5701 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5703 hpsa_scan_complete(h); in hpsa_scan_start()
5724 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5728 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5729 finished = h->scan_finished; in hpsa_scan_finished()
5730 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5734 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5738 sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h)); in hpsa_scsi_host_alloc()
5740 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5751 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5753 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5755 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5756 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5759 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5763 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5767 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5769 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5772 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5797 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5804 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5806 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, DEFAULT_TIMEOUT); in hpsa_send_test_unit_ready()
5833 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5850 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5858 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5866 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5876 c = cmd_alloc(h); in wait_for_device_to_become_ready()
5885 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
5892 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
5898 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
5900 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
5902 cmd_free(h, c); in wait_for_device_to_become_ready()
5912 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
5919 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
5920 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
5923 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
5924 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
5925 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
5927 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
5934 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
5945 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
5949 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
5955 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
5959 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
5977 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
5980 rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type, in hpsa_eh_device_reset_handler()
5990 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
5993 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
5994 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
5995 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6005 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6009 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6011 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6012 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6013 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6028 dev_err(&h->pdev->dev, in cmd_tagged_alloc()
6036 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6040 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6058 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6084 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6091 c = h->cmd_pool + i; in cmd_alloc()
6094 cmd_free(h, c); /* already in use */ in cmd_alloc()
6099 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_alloc()
6102 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6112 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6117 i = c - h->cmd_pool; in cmd_free()
6119 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_free()
6230 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6236 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6237 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6238 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6239 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6245 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6254 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6268 static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_passthru_ioctl() argument
6301 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6323 temp64 = pci_map_single(h->pdev, buff, in hpsa_passthru_ioctl()
6325 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6335 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6338 hpsa_pci_unmap(h->pdev, c, 1, PCI_DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6339 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6361 cmd_free(h, c); in hpsa_passthru_ioctl()
6367 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_big_passthru_ioctl() argument
6438 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6450 temp64 = pci_map_single(h->pdev, buff[i], in hpsa_big_passthru_ioctl()
6452 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6456 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6467 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6470 hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6471 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6498 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6512 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6517 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6525 struct ctlr_info *h; in hpsa_ioctl() local
6529 h = sdev_to_hba(dev); in hpsa_ioctl()
6535 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6538 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6540 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6542 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6544 rc = hpsa_passthru_ioctl(h, argp); in hpsa_ioctl()
6545 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6548 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6550 rc = hpsa_big_passthru_ioctl(h, argp); in hpsa_ioctl()
6551 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6558 static void hpsa_send_host_reset(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_send_host_reset() argument
6563 c = cmd_alloc(h); in hpsa_send_host_reset()
6566 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6570 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6578 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6741 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6777 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6782 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6799 if (hpsa_map_one(h->pdev, c, buff, size, pci_dir)) in fill_cmd()
6817 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6819 return h->access.command_completed(h, q); in get_next_completion()
6822 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6824 return h->access.intr_pending(h); in interrupt_pending()
6827 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6829 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6830 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6833 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6836 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6837 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6845 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6854 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6861 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6862 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6872 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6877 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6880 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
6898 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
6902 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
6905 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
6907 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
6908 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
6909 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
6911 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
6918 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
6922 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
6925 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
6926 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
6928 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
6934 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
6938 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
6940 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
6941 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
6942 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
6944 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
6945 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
6953 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
6957 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
6958 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
6960 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
6961 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7364 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7366 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7367 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7370 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7375 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7376 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7381 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7387 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7393 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7399 switch (h->board_id) { in hpsa_interrupt_mode()
7406 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7409 h->msix_vectors = ret; in hpsa_interrupt_mode()
7417 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7512 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7514 if (h->transtable) { in hpsa_free_cfgtables()
7515 iounmap(h->transtable); in hpsa_free_cfgtables()
7516 h->transtable = NULL; in hpsa_free_cfgtables()
7518 if (h->cfgtable) { in hpsa_free_cfgtables()
7519 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7520 h->cfgtable = NULL; in hpsa_free_cfgtables()
7527 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7535 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7539 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7540 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7541 if (!h->cfgtable) { in hpsa_find_cfgtables()
7542 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7545 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7549 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7550 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7552 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7553 if (!h->transtable) { in hpsa_find_cfgtables()
7554 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7555 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7561 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7566 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7569 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7570 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7572 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7573 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7575 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7577 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7585 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7587 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7594 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7596 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7597 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7598 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7599 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7600 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7602 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7603 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7604 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7611 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7612 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7613 h->chainsize = 0; in hpsa_find_board_params()
7617 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7618 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7619 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7620 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7621 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7622 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7623 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7626 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7628 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7629 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7635 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7639 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7645 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7651 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7655 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7657 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7659 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7662 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7669 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7670 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7671 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7682 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7693 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7695 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7696 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7697 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7709 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7713 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7717 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7720 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7721 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7722 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7723 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7725 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7726 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7728 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7731 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7736 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7738 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7739 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7740 h->vaddr = NULL; in hpsa_free_pci_init()
7741 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7746 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7747 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7751 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7756 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7759 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7760 h->access = *(products[prod_index].access); in hpsa_pci_init()
7761 h->legacy_board = legacy_board; in hpsa_pci_init()
7762 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7765 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7767 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7768 pci_disable_device(h->pdev); in hpsa_pci_init()
7772 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7774 dev_err(&h->pdev->dev, in hpsa_pci_init()
7776 pci_disable_device(h->pdev); in hpsa_pci_init()
7780 pci_set_master(h->pdev); in hpsa_pci_init()
7782 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7787 hpsa_setup_reply_map(h); in hpsa_pci_init()
7789 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7792 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7793 if (!h->vaddr) { in hpsa_pci_init()
7794 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7798 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7801 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7804 hpsa_find_board_params(h); in hpsa_pci_init()
7806 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7810 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7811 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7812 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7818 hpsa_free_cfgtables(h); in hpsa_pci_init()
7820 iounmap(h->vaddr); in hpsa_pci_init()
7821 h->vaddr = NULL; in hpsa_pci_init()
7823 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7829 pci_disable_device(h->pdev); in hpsa_pci_init()
7830 pci_release_regions(h->pdev); in hpsa_pci_init()
7834 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7839 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7840 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7842 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7843 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7845 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7846 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
7912 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
7914 kfree(h->cmd_pool_bits); in hpsa_free_cmd_pool()
7915 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
7916 if (h->cmd_pool) { in hpsa_free_cmd_pool()
7917 pci_free_consistent(h->pdev, in hpsa_free_cmd_pool()
7918 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
7919 h->cmd_pool, in hpsa_free_cmd_pool()
7920 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
7921 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
7922 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
7924 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
7925 pci_free_consistent(h->pdev, in hpsa_free_cmd_pool()
7926 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
7927 h->errinfo_pool, in hpsa_free_cmd_pool()
7928 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
7929 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
7930 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
7934 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
7936 h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), in hpsa_alloc_cmd_pool()
7939 h->cmd_pool = pci_alloc_consistent(h->pdev, in hpsa_alloc_cmd_pool()
7940 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
7941 &(h->cmd_pool_dhandle)); in hpsa_alloc_cmd_pool()
7942 h->errinfo_pool = pci_alloc_consistent(h->pdev, in hpsa_alloc_cmd_pool()
7943 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
7944 &(h->errinfo_pool_dhandle)); in hpsa_alloc_cmd_pool()
7945 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
7946 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
7947 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
7948 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
7951 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
7954 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
7959 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
7963 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
7965 free_irq(pci_irq_vector(h->pdev, 0), &h->q[h->intr_mode]); in hpsa_free_irqs()
7966 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
7970 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
7971 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
7972 h->q[i] = 0; in hpsa_free_irqs()
7975 h->q[i] = 0; in hpsa_free_irqs()
7979 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
7990 h->q[i] = (u8) i; in hpsa_request_irqs()
7992 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
7994 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
7995 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
7996 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
7997 0, h->intrname[i], in hpsa_request_irqs()
7998 &h->q[i]); in hpsa_request_irqs()
8002 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8004 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8006 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8007 h->q[j] = 0; in hpsa_request_irqs()
8010 h->q[j] = 0; in hpsa_request_irqs()
8016 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8017 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8018 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8019 rc = request_irq(pci_irq_vector(h->pdev, 0), in hpsa_request_irqs()
8021 h->intrname[0], in hpsa_request_irqs()
8022 &h->q[h->intr_mode]); in hpsa_request_irqs()
8024 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8025 "%s-intx", h->devname); in hpsa_request_irqs()
8026 rc = request_irq(pci_irq_vector(h->pdev, 0), in hpsa_request_irqs()
8028 h->intrname[0], in hpsa_request_irqs()
8029 &h->q[h->intr_mode]); in hpsa_request_irqs()
8033 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8034 pci_irq_vector(h->pdev, 0), h->devname); in hpsa_request_irqs()
8035 hpsa_free_irqs(h); in hpsa_request_irqs()
8041 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8044 hpsa_send_host_reset(h, RAID_CTLR_LUNID, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8046 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8047 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8049 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8053 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8054 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8056 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8064 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8068 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8069 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8071 pci_free_consistent(h->pdev, in hpsa_free_reply_queues()
8072 h->reply_queue_size, in hpsa_free_reply_queues()
8073 h->reply_queue[i].head, in hpsa_free_reply_queues()
8074 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8075 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8076 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8078 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8081 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8083 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8084 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8085 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8086 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8087 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8088 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8089 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8090 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8091 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8092 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8093 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8094 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8096 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8097 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8098 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8100 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8104 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8110 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8111 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8112 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8117 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8120 cmd_free(h, c); in fail_all_outstanding_cmds()
8122 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8126 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8132 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8138 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8143 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8144 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8145 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8148 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8150 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8153 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8154 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8155 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8156 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8158 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8159 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8161 pci_disable_device(h->pdev); in controller_lockup_detected()
8162 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8165 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8173 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8174 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8182 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8183 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8187 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8188 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8189 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8190 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8191 controller_lockup_detected(h); in detect_controller_lockup()
8196 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8197 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8210 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8218 if (!h) in hpsa_set_ioaccel_status()
8228 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8229 device = h->dev[i]; in hpsa_set_ioaccel_status()
8233 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8239 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8270 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8274 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8278 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8280 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8281 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8283 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8285 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8288 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8289 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8290 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8292 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8294 h->events, event_type); in hpsa_ack_ctlr_events()
8295 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8297 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8299 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8300 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8303 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8304 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8305 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8315 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8317 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8318 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8322 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8325 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8326 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8332 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8338 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8339 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8342 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8343 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8344 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8346 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8349 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8351 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8355 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8364 if (!h->lastlogicals) in hpsa_luns_changed()
8371 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8372 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8376 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8377 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8379 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8388 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8396 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8397 if (h->reset_in_progress) { in hpsa_perform_rescan()
8398 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8399 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8402 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8404 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8408 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8417 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8421 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8422 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8423 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8426 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8428 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8429 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8430 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8433 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8434 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8435 schedule_delayed_work(&h->event_monitor_work, in hpsa_event_monitor_worker()
8437 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8443 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8446 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8447 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8448 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8451 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8453 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8454 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8455 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8456 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8457 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8459 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8462 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8463 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8464 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8465 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8466 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8472 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8475 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8476 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8479 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8480 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8481 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8482 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8483 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8486 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8491 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8493 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8498 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8500 kfree(h->reply_map); in hpda_free_ctlr_info()
8501 kfree(h); in hpda_free_ctlr_info()
8506 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8508 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8509 if (!h) in hpda_alloc_ctlr_info()
8512 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8513 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8514 kfree(h); in hpda_alloc_ctlr_info()
8517 return h; in hpda_alloc_ctlr_info()
8523 struct ctlr_info *h; in hpsa_init_one() local
8557 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8558 if (!h) { in hpsa_init_one()
8563 h->pdev = pdev; in hpsa_init_one()
8565 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8566 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8567 spin_lock_init(&h->lock); in hpsa_init_one()
8568 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8569 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8570 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8571 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8574 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8575 if (!h->lockup_detected) { in hpsa_init_one()
8576 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8580 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8582 rc = hpsa_pci_init(h); in hpsa_init_one()
8588 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8592 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8593 h->ctlr = number_of_controllers; in hpsa_init_one()
8611 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8613 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8616 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8619 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8622 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8623 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8624 mutex_init(&h->reset_mutex); in hpsa_init_one()
8625 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8626 h->scan_waiting = 0; in hpsa_init_one()
8628 pci_set_drvdata(pdev, h); in hpsa_init_one()
8629 h->ndevices = 0; in hpsa_init_one()
8631 spin_lock_init(&h->devlock); in hpsa_init_one()
8632 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8637 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8638 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8643 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8644 if (!h->resubmit_wq) { in hpsa_init_one()
8663 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8664 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8665 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8666 hpsa_free_irqs(h); in hpsa_init_one()
8667 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8670 dev_warn(&h->pdev->dev, in hpsa_init_one()
8676 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8677 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8678 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8686 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8691 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8692 dev_info(&h->pdev->dev, in hpsa_init_one()
8694 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8696 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8698 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8700 dev_info(&h->pdev->dev, in hpsa_init_one()
8707 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8717 h->acciopath_status = 1; in hpsa_init_one()
8719 h->discovery_polling = 0; in hpsa_init_one()
8723 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8725 hpsa_hba_inquiry(h); in hpsa_init_one()
8727 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8728 if (!h->lastlogicals) in hpsa_init_one()
8729 dev_info(&h->pdev->dev, in hpsa_init_one()
8733 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8738 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8739 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8740 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8741 h->heartbeat_sample_interval); in hpsa_init_one()
8742 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8743 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8744 h->heartbeat_sample_interval); in hpsa_init_one()
8745 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8746 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8751 hpsa_free_performant_mode(h); in hpsa_init_one()
8752 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8754 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8756 hpsa_free_cmd_pool(h); in hpsa_init_one()
8758 hpsa_free_irqs(h); in hpsa_init_one()
8760 scsi_host_put(h->scsi_host); in hpsa_init_one()
8761 h->scsi_host = NULL; in hpsa_init_one()
8763 hpsa_free_pci_init(h); in hpsa_init_one()
8765 if (h->lockup_detected) { in hpsa_init_one()
8766 free_percpu(h->lockup_detected); in hpsa_init_one()
8767 h->lockup_detected = NULL; in hpsa_init_one()
8770 if (h->resubmit_wq) { in hpsa_init_one()
8771 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8772 h->resubmit_wq = NULL; in hpsa_init_one()
8774 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8775 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8776 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8778 kfree(h); in hpsa_init_one()
8782 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8788 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8794 c = cmd_alloc(h); in hpsa_flush_cache()
8796 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8800 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_flush_cache()
8806 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8808 cmd_free(h, c); in hpsa_flush_cache()
8815 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8822 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8829 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8832 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8836 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_disable_rld_caching()
8844 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8848 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_disable_rld_caching()
8854 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8858 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, in hpsa_disable_rld_caching()
8867 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
8870 cmd_free(h, c); in hpsa_disable_rld_caching()
8876 struct ctlr_info *h; in __hpsa_shutdown() local
8878 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
8883 hpsa_flush_cache(h); in __hpsa_shutdown()
8884 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
8885 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
8886 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
8895 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
8899 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
8900 kfree(h->dev[i]); in hpsa_free_device_info()
8901 h->dev[i] = NULL; in hpsa_free_device_info()
8907 struct ctlr_info *h; in hpsa_remove_one() local
8914 h = pci_get_drvdata(pdev); in hpsa_remove_one()
8917 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
8918 h->remove_in_progress = 1; in hpsa_remove_one()
8919 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
8920 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
8921 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
8922 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
8923 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
8924 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
8926 hpsa_delete_sas_host(h); in hpsa_remove_one()
8934 if (h->scsi_host) in hpsa_remove_one()
8935 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
8940 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
8942 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
8943 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
8944 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
8945 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
8946 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
8947 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
8948 kfree(h->lastlogicals); in hpsa_remove_one()
8952 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
8953 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
8956 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
8958 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
8959 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
8962 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9024 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9078 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9079 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9083 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9085 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9088 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9089 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9090 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9091 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9093 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9094 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9095 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9096 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9099 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9100 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9106 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9107 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9111 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9112 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9113 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9117 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9119 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9124 h->access = access; in hpsa_enter_performant_mode()
9125 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9133 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9134 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9135 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9136 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9138 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9139 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9140 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9143 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9144 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9146 h->reply_queue_size); in hpsa_enter_performant_mode()
9151 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9152 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9155 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9166 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9174 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9177 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9178 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9179 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9180 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9183 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9184 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9188 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9190 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9192 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9193 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9194 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9202 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9204 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9205 pci_free_consistent(h->pdev, in hpsa_free_ioaccel1_cmd_and_bft()
9206 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9207 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9208 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9209 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9210 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9212 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9213 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9217 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9219 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9220 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9221 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9222 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9230 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9231 pci_alloc_consistent(h->pdev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9232 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9233 &(h->ioaccel_cmd_pool_dhandle)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9235 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9236 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9239 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9240 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9243 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9244 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9248 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9253 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9255 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9257 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9258 pci_free_consistent(h->pdev, in hpsa_free_ioaccel2_cmd_and_bft()
9259 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9260 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9261 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9262 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9263 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9265 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9266 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9270 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9276 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9277 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9278 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9279 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9283 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9284 pci_alloc_consistent(h->pdev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9285 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9286 &(h->ioaccel2_cmd_pool_dhandle)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9288 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9289 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9292 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9293 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9298 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9302 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9303 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9307 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9312 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9314 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9315 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9316 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9317 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9318 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9324 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9334 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9342 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9348 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9353 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9354 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9356 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9358 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9359 h->reply_queue[i].head = pci_alloc_consistent(h->pdev, in hpsa_put_ctlr_into_performant_mode()
9360 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9361 &(h->reply_queue[i].busaddr)); in hpsa_put_ctlr_into_performant_mode()
9362 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9366 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9367 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9368 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9372 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9374 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9379 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9385 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9386 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9388 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9389 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9390 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9399 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9407 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9408 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9412 cmd_free(h, c); in hpsa_drain_accel_commands()
9584 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9590 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9591 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9601 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9609 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9615 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9631 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9645 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9647 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9701 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9707 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9709 if (!h) in hpsa_sas_get_enclosure_identifier()
9712 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()