Lines Matching full:h
21 #include <linux/module.h>
22 #include <linux/interrupt.h>
23 #include <linux/types.h>
24 #include <linux/pci.h>
25 #include <linux/kernel.h>
26 #include <linux/slab.h>
27 #include <linux/delay.h>
28 #include <linux/fs.h>
29 #include <linux/timer.h>
30 #include <linux/init.h>
31 #include <linux/spinlock.h>
32 #include <linux/compat.h>
33 #include <linux/blktrace_api.h>
34 #include <linux/uaccess.h>
35 #include <linux/io.h>
36 #include <linux/dma-mapping.h>
37 #include <linux/completion.h>
38 #include <linux/moduleparam.h>
39 #include <scsi/scsi.h>
40 #include <scsi/scsi_cmnd.h>
41 #include <scsi/scsi_device.h>
42 #include <scsi/scsi_host.h>
43 #include <scsi/scsi_tcq.h>
44 #include <scsi/scsi_eh.h>
45 #include <scsi/scsi_transport_sas.h>
46 #include <scsi/scsi_dbg.h>
47 #include <linux/cciss_ioctl.h>
48 #include <linux/string.h>
49 #include <linux/bitmap.h>
50 #include <linux/atomic.h>
51 #include <linux/jiffies.h>
52 #include <linux/percpu-defs.h>
53 #include <linux/percpu.h>
54 #include <asm/unaligned.h>
55 #include <asm/div64.h>
56 #include "hpsa_cmd.h"
57 #include "hpsa.h"
79 /* Embedded module documentation macros - see modules.h */
238 static int hpsa_add_sas_host(struct ctlr_info *h);
239 static void hpsa_delete_sas_host(struct ctlr_info *h);
244 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h,
257 static int hpsa_passthru_ioctl(struct ctlr_info *h,
259 static int hpsa_big_passthru_ioctl(struct ctlr_info *h,
267 static void cmd_free(struct ctlr_info *h, struct CommandList *c);
268 static struct CommandList *cmd_alloc(struct ctlr_info *h);
269 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c);
270 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
272 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
275 static void hpsa_free_cmd_pool(struct ctlr_info *h);
279 static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
290 static void hpsa_update_scsi_devices(struct ctlr_info *h);
291 static int check_for_unit_attention(struct ctlr_info *h,
293 static void check_ioctl_unit_attention(struct ctlr_info *h,
298 static void hpsa_free_performant_mode(struct ctlr_info *h);
299 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
300 static inline u32 next_command(struct ctlr_info *h, u8 q);
308 static int wait_for_device_to_become_ready(struct ctlr_info *h,
314 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
317 static void hpsa_drain_accel_commands(struct ctlr_info *h);
318 static void hpsa_flush_cache(struct ctlr_info *h);
319 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
323 static u32 lockup_detected(struct ctlr_info *h);
324 static int detect_controller_lockup(struct ctlr_info *h);
325 static void hpsa_disable_rld_caching(struct ctlr_info *h);
326 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
328 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
330 static int hpsa_luns_changed(struct ctlr_info *h);
331 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
374 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
392 dev_warn(&h->pdev->dev, in check_for_unit_attention()
394 h->devname); in check_for_unit_attention()
397 dev_warn(&h->pdev->dev, in check_for_unit_attention()
398 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
401 dev_warn(&h->pdev->dev, in check_for_unit_attention()
402 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
409 dev_warn(&h->pdev->dev, in check_for_unit_attention()
411 h->devname); in check_for_unit_attention()
414 dev_warn(&h->pdev->dev, in check_for_unit_attention()
416 h->devname); in check_for_unit_attention()
419 dev_warn(&h->pdev->dev, in check_for_unit_attention()
421 h->devname); in check_for_unit_attention()
427 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
433 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
437 static u32 lockup_detected(struct ctlr_info *h);
442 struct ctlr_info *h; in host_show_lockup_detected() local
445 h = shost_to_hba(shost); in host_show_lockup_detected()
446 ld = lockup_detected(h); in host_show_lockup_detected()
456 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
467 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
468 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
469 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
471 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
480 struct ctlr_info *h; in host_store_raid_offload_debug() local
493 h = shost_to_hba(shost); in host_store_raid_offload_debug()
494 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
495 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
496 h->raid_offload_debug); in host_store_raid_offload_debug()
504 struct ctlr_info *h; in host_store_rescan() local
506 h = shost_to_hba(shost); in host_store_rescan()
507 hpsa_scan_start(h->scsi_host); in host_store_rescan()
520 struct ctlr_info *h; in host_show_firmware_revision() local
524 h = shost_to_hba(shost); in host_show_firmware_revision()
525 if (!h->hba_inquiry_data) in host_show_firmware_revision()
527 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
536 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
539 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
545 struct ctlr_info *h; in host_show_transport_mode() local
548 h = shost_to_hba(shost); in host_show_transport_mode()
550 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
557 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
560 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
562 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
641 struct ctlr_info *h; in host_show_resettable() local
644 h = shost_to_hba(shost); in host_show_resettable()
645 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
676 struct ctlr_info *h; in raid_level_show() local
682 h = sdev_to_hba(sdev); in raid_level_show()
683 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
686 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
692 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
698 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
708 struct ctlr_info *h; in lunid_show() local
715 h = sdev_to_hba(sdev); in lunid_show()
716 spin_lock_irqsave(&h->lock, flags); in lunid_show()
719 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
723 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
730 struct ctlr_info *h; in unique_id_show() local
737 h = sdev_to_hba(sdev); in unique_id_show()
738 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
741 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
745 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
758 struct ctlr_info *h; in sas_address_show() local
765 h = sdev_to_hba(sdev); in sas_address_show()
766 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
769 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
773 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
781 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
788 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
789 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
792 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
796 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
809 struct ctlr_info *h; in path_info_show() local
822 h = sdev_to_hba(sdev); in path_info_show()
823 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
826 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
843 h->scsi_host->host_no, in path_info_show()
887 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
894 struct ctlr_info *h; in host_show_ctlr_num() local
897 h = shost_to_hba(shost); in host_show_ctlr_num()
898 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
904 struct ctlr_info *h; in host_show_legacy_board() local
907 h = shost_to_hba(shost); in host_show_legacy_board()
908 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
989 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
992 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
994 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
995 return h->access.command_completed(h, q); in next_command()
997 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
998 return h->access.command_completed(h, q); in next_command()
1003 atomic_dec(&h->commands_outstanding); in next_command()
1008 if (rq->current_entry == h->max_commands) { in next_command()
1047 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1050 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1051 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1052 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1058 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1062 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1075 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1079 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1084 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1095 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1098 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1102 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1115 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1131 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1136 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1137 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1140 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1144 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1145 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1148 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1151 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1152 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1159 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1162 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1163 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1166 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1167 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1170 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1171 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1174 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1175 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1179 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1181 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1189 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1191 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1193 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1198 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1202 * assumes h->devlock is held in hpsa_find_target_lun()
1209 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1210 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1211 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1224 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1230 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1266 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1268 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1279 /* Add an entry into h->dev[] array. */
1280 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1284 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1285 int n = h->ndevices; in hpsa_scsi_add_entry()
1291 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1307 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1323 sd = h->dev[i]; in hpsa_scsi_add_entry()
1336 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1344 h->dev[n] = device; in hpsa_scsi_add_entry()
1345 h->ndevices++; in hpsa_scsi_add_entry()
1348 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1356 * Update an entry in h->dev[] array.
1358 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1361 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1365 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1370 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1380 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1382 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1383 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1386 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1389 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1390 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1391 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1392 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1396 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1399 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1405 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1407 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1410 /* Replace an entry from h->dev[] array. */
1411 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1416 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1418 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1426 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1427 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1430 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1434 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1437 /* Remove an entry from h->dev[] array. */
1438 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1441 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1447 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1448 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1451 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1452 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1453 h->ndevices--; in hpsa_scsi_remove_entry()
1454 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1467 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1471 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1476 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1477 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1478 if (h->dev[i] == added) { in fixup_botched_add()
1479 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1480 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1481 h->ndevices--; in fixup_botched_add()
1485 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1584 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1591 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1592 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1595 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1599 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1607 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1608 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1609 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1613 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1617 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1619 h->scsi_host->host_no, in hpsa_show_volume_status()
1625 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1627 h->scsi_host->host_no, in hpsa_show_volume_status()
1631 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1633 h->scsi_host->host_no, in hpsa_show_volume_status()
1637 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1639 h->scsi_host->host_no, in hpsa_show_volume_status()
1643 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1645 h->scsi_host->host_no, in hpsa_show_volume_status()
1649 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1651 h->scsi_host->host_no, in hpsa_show_volume_status()
1655 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1657 h->scsi_host->host_no, in hpsa_show_volume_status()
1661 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1663 h->scsi_host->host_no, in hpsa_show_volume_status()
1667 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1669 h->scsi_host->host_no, in hpsa_show_volume_status()
1673 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1675 h->scsi_host->host_no, in hpsa_show_volume_status()
1679 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1681 h->scsi_host->host_no, in hpsa_show_volume_status()
1685 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1687 h->scsi_host->host_no, in hpsa_show_volume_status()
1697 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1736 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1749 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1752 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1768 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1772 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1806 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1810 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1814 if (!h->scsi_host) in hpsa_add_device()
1818 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1821 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1826 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1832 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1833 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1836 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1840 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1843 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1846 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1853 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1864 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1873 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1876 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1881 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1886 if (!h->scsi_host) in hpsa_remove_device()
1893 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1896 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1907 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1916 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1921 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1933 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1934 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1935 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1936 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1939 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1945 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1950 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1952 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1953 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1962 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1963 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1967 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1971 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1978 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1984 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
1997 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
1998 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
2002 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2003 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2006 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2012 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2017 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2020 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2027 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2028 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2030 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2033 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2036 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2037 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2043 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2058 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2071 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2074 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2076 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2079 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2080 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2090 * Assume's h->devlock is held.
2092 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2098 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2099 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2110 struct ctlr_info *h; in hpsa_slave_alloc() local
2112 h = sdev_to_hba(sdev); in hpsa_slave_alloc()
2113 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2120 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_slave_alloc()
2127 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_slave_alloc()
2135 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2182 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2186 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2188 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2189 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2190 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2192 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2193 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2196 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2200 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2203 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2204 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2206 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2210 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2211 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2213 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2219 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2223 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2227 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2229 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2230 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2231 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2233 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2234 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2237 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2241 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2244 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2246 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2249 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2250 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2251 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2253 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2260 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2264 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2271 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2273 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2275 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2284 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2294 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2297 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2304 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2305 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2308 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2310 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2312 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2321 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2326 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2329 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2330 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2339 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2419 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2420 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2454 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2470 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2474 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2477 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2478 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2481 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2484 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2489 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2492 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2495 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2499 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2505 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2523 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2526 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2529 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2530 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2532 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2536 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2556 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2566 struct ctlr_info *h; in complete_scsi_command() local
2578 h = cp->h; in complete_scsi_command()
2582 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2588 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2590 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2594 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2595 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2599 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2605 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2613 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2627 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2631 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2635 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2641 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2657 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2684 h->drv_req_rescan = 1; in complete_scsi_command()
2699 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2706 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2728 dev_warn(&h->pdev->dev, in complete_scsi_command()
2745 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2750 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2755 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2763 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2768 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2773 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2778 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2781 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2789 dev_warn(&h->pdev->dev, in complete_scsi_command()
2794 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2798 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2843 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2849 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2857 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2863 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2866 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2870 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2873 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2879 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2886 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2895 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2905 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2906 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2908 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2914 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2920 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2924 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2928 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2940 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2955 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2961 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2966 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2969 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2972 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2975 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2978 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2981 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2984 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2987 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2990 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2993 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
2999 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
3006 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
3007 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
3012 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3018 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3022 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3026 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3037 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3050 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3058 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3060 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3065 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3071 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3075 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3079 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3086 c = cmd_alloc(h); in hpsa_send_reset()
3090 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3091 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3093 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3100 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3104 cmd_free(h, c); in hpsa_send_reset()
3108 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3114 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3159 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3167 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3173 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3174 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3178 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3182 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3184 lockup_detected(h)); in hpsa_do_reset()
3187 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3188 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3194 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3196 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3200 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3211 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3215 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3229 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3240 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3272 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3276 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3279 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3283 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3284 " D%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3290 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3291 " M%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3298 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3305 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3312 c = cmd_alloc(h); in hpsa_get_raid_map()
3314 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3317 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3318 cmd_free(h, c); in hpsa_get_raid_map()
3321 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3327 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3331 cmd_free(h, c); in hpsa_get_raid_map()
3336 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3339 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3342 cmd_free(h, c); in hpsa_get_raid_map()
3346 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3354 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3356 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3364 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3370 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3374 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3378 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3385 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3387 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3392 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3398 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3402 cmd_free(h, c); in hpsa_bmic_id_controller()
3406 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3414 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3415 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3423 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3427 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3431 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3442 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3461 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3483 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3486 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3491 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3493 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3504 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3525 cmd_free(h, c); in hpsa_get_enclosure_info()
3528 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3532 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3544 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3545 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3562 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3575 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3579 h->sas_address = sa; in hpsa_get_sas_address()
3584 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3589 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3595 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3604 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3606 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3607 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3614 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3627 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3639 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3664 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3678 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3680 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3698 rc = hpsa_get_raid_map(h, scsi3addr, this_device); in hpsa_get_ioaccel_status()
3711 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3718 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3725 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3738 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3747 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3751 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3758 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3765 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3771 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3772 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3782 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3786 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3792 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3802 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3817 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3820 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3832 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3845 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3849 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3856 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3876 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3888 c = cmd_alloc(h); in hpsa_volume_offline()
3890 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3891 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3894 cmd_free(h, c); in hpsa_volume_offline()
3903 cmd_free(h, c); in hpsa_volume_offline()
3906 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3935 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3956 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3958 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3977 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3979 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3981 h->ctlr, __func__, in hpsa_update_device_info()
3982 h->scsi_host->host_no, in hpsa_update_device_info()
3996 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
3997 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
3998 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
3999 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
4001 h->legacy_board) { in hpsa_update_device_info()
4005 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4013 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4024 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4053 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4084 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4111 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4115 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4116 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4121 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4125 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4126 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4132 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4139 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4148 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4176 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4193 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4239 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4246 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4251 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4263 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4273 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4290 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4322 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4328 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4364 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4369 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4371 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4373 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4378 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4379 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4390 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4395 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4403 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4409 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4426 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4431 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4439 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4446 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4449 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4451 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4455 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4459 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4479 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4499 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4512 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4534 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4537 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4539 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4545 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4573 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4581 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4598 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4599 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4612 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4623 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4624 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4627 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4629 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4643 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4647 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4729 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4734 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4744 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4752 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4765 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4799 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4818 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4826 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4840 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4847 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4888 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4903 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4908 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4922 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4925 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4937 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4952 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4954 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4962 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4996 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5007 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
5019 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5022 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5035 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5042 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5061 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5062 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5066 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5100 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5444 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5454 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5503 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5509 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5510 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5515 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5521 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5526 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5534 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5535 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5537 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5543 c->h = h; in hpsa_cmd_init()
5547 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5551 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5552 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5554 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5559 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5562 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5571 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5590 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5596 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5600 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5606 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5623 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5628 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5632 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5633 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5639 rc = hpsa_ioaccel_submit(h, c, cmd, true); in hpsa_command_resubmit_worker()
5649 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5654 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5664 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5681 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5687 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5704 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5713 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5733 h->acciopath_status)) { in hpsa_scsi_queue_command()
5735 rc = hpsa_ioaccel_submit(h, c, cmd, false); in hpsa_scsi_queue_command()
5739 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5743 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5746 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5750 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5751 h->scan_finished = 1; in hpsa_scan_complete()
5752 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5753 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5758 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5767 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5768 return hpsa_scan_complete(h); in hpsa_scan_start()
5773 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5774 if (h->scan_waiting) { in hpsa_scan_start()
5775 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5779 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5783 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5784 if (h->scan_finished) in hpsa_scan_start()
5786 h->scan_waiting = 1; in hpsa_scan_start()
5787 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5788 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5795 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5796 h->scan_waiting = 0; in hpsa_scan_start()
5797 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5799 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5800 return hpsa_scan_complete(h); in hpsa_scan_start()
5805 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5806 if (h->reset_in_progress) { in hpsa_scan_start()
5807 h->drv_req_rescan = 1; in hpsa_scan_start()
5808 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5809 hpsa_scan_complete(h); in hpsa_scan_start()
5812 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5814 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5816 hpsa_scan_complete(h); in hpsa_scan_start()
5837 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5841 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5842 finished = h->scan_finished; in hpsa_scan_finished()
5843 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5847 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5851 sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h)); in hpsa_scsi_host_alloc()
5853 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5864 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5866 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5868 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5869 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5872 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5876 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5880 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5882 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5885 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5910 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5917 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5919 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5946 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5963 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5971 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5979 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5989 c = cmd_alloc(h); in wait_for_device_to_become_ready()
5998 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6005 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
6011 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6013 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6015 cmd_free(h, c); in wait_for_device_to_become_ready()
6026 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
6033 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6034 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
6037 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6038 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6039 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6041 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6048 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6059 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6063 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6069 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6073 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6091 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6105 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6114 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6117 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6118 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6121 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6132 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6136 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6138 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6139 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6140 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6154 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6155 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6159 h->last_collision_tag = idx; in cmd_tagged_alloc()
6165 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6176 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6194 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6220 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6227 c = h->cmd_pool + i; in cmd_alloc()
6230 cmd_free(h, c); /* already in use */ in cmd_alloc()
6235 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_alloc()
6238 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6256 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6261 i = c - h->cmd_pool; in cmd_free()
6263 h->cmd_pool_bits + (i / BITS_PER_LONG)); in cmd_free()
6272 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_passthru() local
6288 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6290 err = hpsa_passthru_ioctl(h, &arg64); in hpsa_ioctl32_passthru()
6291 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6303 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_big_passthru() local
6319 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6321 err = hpsa_big_passthru_ioctl(h, &arg64); in hpsa_ioctl32_big_passthru()
6322 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6363 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6369 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6370 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6371 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6372 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6378 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6387 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6401 static int hpsa_passthru_ioctl(struct ctlr_info *h, in hpsa_passthru_ioctl() argument
6430 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6452 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6454 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6464 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6467 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6468 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6486 cmd_free(h, c); in hpsa_passthru_ioctl()
6492 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, in hpsa_big_passthru_ioctl() argument
6547 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6559 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6561 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6565 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6576 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6579 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6580 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6603 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6616 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6621 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6630 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl() local
6637 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6640 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6642 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6650 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6652 rc = hpsa_passthru_ioctl(h, &iocommand); in hpsa_ioctl()
6653 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6664 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6666 rc = hpsa_big_passthru_ioctl(h, &ioc); in hpsa_ioctl()
6667 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6677 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6681 c = cmd_alloc(h); in hpsa_send_host_reset()
6684 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6688 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6696 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6859 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6895 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6900 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6917 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6935 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6937 return h->access.command_completed(h, q); in get_next_completion()
6940 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6942 return h->access.intr_pending(h); in interrupt_pending()
6945 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6947 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6948 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6951 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6954 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6955 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6963 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6972 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6979 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6980 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6990 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6995 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6998 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
7005 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7006 * Relies on (h-q[x] == x) being true for x such that
7016 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
7020 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
7023 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
7025 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7026 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
7027 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
7029 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
7036 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
7040 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
7043 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7044 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
7046 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7052 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7056 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7058 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7059 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7060 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7062 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7063 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7071 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7075 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7076 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7078 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7079 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7206 * CSR=00h. The software off state is D3, CSR=03h. To reset in hpsa_controller_hard_reset()
7481 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7483 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7484 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7487 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7492 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7493 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7498 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7504 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7510 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7516 switch (h->board_id) { in hpsa_interrupt_mode()
7523 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7526 h->msix_vectors = ret; in hpsa_interrupt_mode()
7534 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7629 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7631 if (h->transtable) { in hpsa_free_cfgtables()
7632 iounmap(h->transtable); in hpsa_free_cfgtables()
7633 h->transtable = NULL; in hpsa_free_cfgtables()
7635 if (h->cfgtable) { in hpsa_free_cfgtables()
7636 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7637 h->cfgtable = NULL; in hpsa_free_cfgtables()
7644 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7652 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7656 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7657 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7658 if (!h->cfgtable) { in hpsa_find_cfgtables()
7659 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7662 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7666 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7667 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7669 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7670 if (!h->transtable) { in hpsa_find_cfgtables()
7671 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7672 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7678 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7683 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7686 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7687 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7689 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7690 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7692 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7694 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7702 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7704 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7711 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7713 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7714 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7715 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7716 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7717 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7719 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7720 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7721 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7728 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7729 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7730 h->chainsize = 0; in hpsa_find_board_params()
7734 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7735 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7736 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7737 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7738 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7739 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7740 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7743 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7745 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7746 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7752 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7756 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7762 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7768 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7772 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7774 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7776 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7779 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7786 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7787 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7788 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7799 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7810 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7812 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7813 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7814 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7826 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7830 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7834 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7837 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7838 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7839 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7840 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7842 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7843 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7845 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7848 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7853 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7855 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7856 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7857 h->vaddr = NULL; in hpsa_free_pci_init()
7858 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7863 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7864 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7868 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7873 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7876 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7877 h->access = *(products[prod_index].access); in hpsa_pci_init()
7878 h->legacy_board = legacy_board; in hpsa_pci_init()
7879 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7882 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7885 pci_disable_device(h->pdev); in hpsa_pci_init()
7889 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7891 dev_err(&h->pdev->dev, in hpsa_pci_init()
7893 pci_disable_device(h->pdev); in hpsa_pci_init()
7897 pci_set_master(h->pdev); in hpsa_pci_init()
7899 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7904 hpsa_setup_reply_map(h); in hpsa_pci_init()
7906 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7909 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7910 if (!h->vaddr) { in hpsa_pci_init()
7911 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7915 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7918 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7921 hpsa_find_board_params(h); in hpsa_pci_init()
7923 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7927 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7928 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7929 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7935 hpsa_free_cfgtables(h); in hpsa_pci_init()
7937 iounmap(h->vaddr); in hpsa_pci_init()
7938 h->vaddr = NULL; in hpsa_pci_init()
7940 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7946 pci_disable_device(h->pdev); in hpsa_pci_init()
7947 pci_release_regions(h->pdev); in hpsa_pci_init()
7951 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7956 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7957 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7959 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7960 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7962 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7963 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
8029 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
8031 kfree(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8032 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8033 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8034 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8035 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8036 h->cmd_pool, in hpsa_free_cmd_pool()
8037 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8038 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8039 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8041 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8042 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8043 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8044 h->errinfo_pool, in hpsa_free_cmd_pool()
8045 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8046 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8047 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8051 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8053 h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), in hpsa_alloc_cmd_pool()
8056 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8057 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8058 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8059 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8060 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8061 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8062 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8063 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8064 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8065 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8068 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
8071 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
8076 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
8082 irq_vector = h->intr_mode; in hpsa_free_irqs()
8084 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8086 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8087 &h->q[h->intr_mode]); in hpsa_free_irqs()
8088 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8092 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8093 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8094 h->q[i] = 0; in hpsa_free_irqs()
8097 h->q[i] = 0; in hpsa_free_irqs()
8101 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
8109 irq_vector = h->intr_mode; in hpsa_request_irqs()
8112 * initialize h->q[x] = x so that interrupt handlers know which in hpsa_request_irqs()
8116 h->q[i] = (u8) i; in hpsa_request_irqs()
8118 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8120 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8121 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8122 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8123 0, h->intrname[i], in hpsa_request_irqs()
8124 &h->q[i]); in hpsa_request_irqs()
8128 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8130 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8132 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8133 h->q[j] = 0; in hpsa_request_irqs()
8136 h->q[j] = 0; in hpsa_request_irqs()
8142 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8143 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8144 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8145 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8147 h->intrname[0], in hpsa_request_irqs()
8148 &h->q[h->intr_mode]); in hpsa_request_irqs()
8150 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8151 "%s-intx", h->devname); in hpsa_request_irqs()
8152 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8154 h->intrname[0], in hpsa_request_irqs()
8155 &h->q[h->intr_mode]); in hpsa_request_irqs()
8159 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8160 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8161 hpsa_free_irqs(h); in hpsa_request_irqs()
8167 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8170 hpsa_send_host_reset(h, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8172 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8173 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8175 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8179 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8180 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8182 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8190 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8194 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8195 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8197 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8198 h->reply_queue_size, in hpsa_free_reply_queues()
8199 h->reply_queue[i].head, in hpsa_free_reply_queues()
8200 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8201 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8202 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8204 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8207 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8209 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8210 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8211 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8212 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8213 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8214 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8215 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8216 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8217 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8218 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8219 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8220 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8222 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8223 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8224 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8226 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8227 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8228 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8231 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8235 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8241 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8242 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8243 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8248 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8251 cmd_free(h, c); in fail_all_outstanding_cmds()
8253 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8257 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8263 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8269 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8274 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8275 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8276 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8279 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8281 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8284 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8285 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8286 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8287 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8289 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8290 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8292 pci_disable_device(h->pdev); in controller_lockup_detected()
8293 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8296 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8304 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8305 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8313 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8314 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8318 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8319 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8320 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8321 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8322 controller_lockup_detected(h); in detect_controller_lockup()
8327 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8328 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8341 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8349 if (!h) in hpsa_set_ioaccel_status()
8359 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8363 device = h->dev[i]; in hpsa_set_ioaccel_status()
8367 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8373 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8414 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8418 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8422 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8424 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8425 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8427 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8429 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8432 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8433 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8434 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8436 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8438 h->events, event_type); in hpsa_ack_ctlr_events()
8439 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8441 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8443 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8444 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8447 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8448 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8449 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8459 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8461 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8462 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8466 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8469 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8470 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8476 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8482 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8483 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8486 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8487 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8488 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8490 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8493 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8495 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8499 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8508 if (!h->lastlogicals) in hpsa_luns_changed()
8515 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8516 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8520 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8521 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8523 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8532 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8540 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8541 if (h->reset_in_progress) { in hpsa_perform_rescan()
8542 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8543 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8546 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8548 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8552 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8561 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8565 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8566 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8567 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8570 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8572 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8573 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8574 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8577 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8578 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8579 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8581 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8587 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8590 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8591 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8592 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8595 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8597 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8598 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8599 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8600 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8601 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8603 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8606 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8607 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8608 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8609 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8610 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8616 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8619 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8620 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8623 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8624 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8625 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8626 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8627 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8630 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8635 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8637 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8642 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8644 kfree(h->reply_map); in hpda_free_ctlr_info()
8645 kfree(h); in hpda_free_ctlr_info()
8650 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8652 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8653 if (!h) in hpda_alloc_ctlr_info()
8656 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8657 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8658 kfree(h); in hpda_alloc_ctlr_info()
8661 return h; in hpda_alloc_ctlr_info()
8667 struct ctlr_info *h; in hpsa_init_one() local
8698 * the driver. See comments in hpsa.h for more info. in hpsa_init_one()
8701 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8702 if (!h) { in hpsa_init_one()
8707 h->pdev = pdev; in hpsa_init_one()
8709 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8710 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8711 spin_lock_init(&h->lock); in hpsa_init_one()
8712 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8713 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8714 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8715 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8718 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8719 if (!h->lockup_detected) { in hpsa_init_one()
8720 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8722 goto clean1; /* aer/h */ in hpsa_init_one()
8724 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8726 rc = hpsa_pci_init(h); in hpsa_init_one()
8728 goto clean2; /* lu, aer/h */ in hpsa_init_one()
8730 /* relies on h-> settings made by hpsa_pci_init, including in hpsa_init_one()
8731 * interrupt_mode h->intr */ in hpsa_init_one()
8732 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8734 goto clean2_5; /* pci, lu, aer/h */ in hpsa_init_one()
8736 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8737 h->ctlr = number_of_controllers; in hpsa_init_one()
8746 goto clean3; /* shost, pci, lu, aer/h */ in hpsa_init_one()
8751 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8753 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8755 goto clean3; /* shost, pci, lu, aer/h */ in hpsa_init_one()
8756 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8758 goto clean4; /* irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8759 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8761 goto clean5; /* cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8762 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8763 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8764 mutex_init(&h->reset_mutex); in hpsa_init_one()
8765 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8766 h->scan_waiting = 0; in hpsa_init_one()
8768 pci_set_drvdata(pdev, h); in hpsa_init_one()
8769 h->ndevices = 0; in hpsa_init_one()
8771 spin_lock_init(&h->devlock); in hpsa_init_one()
8772 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8774 goto clean6; /* sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8777 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8778 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8783 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8784 if (!h->resubmit_wq) { in hpsa_init_one()
8786 goto clean7; /* aer/h */ in hpsa_init_one()
8789 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8790 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8809 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8810 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8811 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8812 hpsa_free_irqs(h); in hpsa_init_one()
8813 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8816 dev_warn(&h->pdev->dev, in hpsa_init_one()
8822 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8823 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8824 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8826 * skip hpsa_free_irqs(h) clean4 since that in hpsa_init_one()
8832 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8837 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8838 dev_info(&h->pdev->dev, in hpsa_init_one()
8840 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8842 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8844 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8846 dev_info(&h->pdev->dev, in hpsa_init_one()
8853 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8863 h->acciopath_status = 1; in hpsa_init_one()
8865 h->discovery_polling = 0; in hpsa_init_one()
8869 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8871 hpsa_hba_inquiry(h); in hpsa_init_one()
8873 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8874 if (!h->lastlogicals) in hpsa_init_one()
8875 dev_info(&h->pdev->dev, in hpsa_init_one()
8879 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8881 goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8884 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8885 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8886 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8887 h->heartbeat_sample_interval); in hpsa_init_one()
8888 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8889 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8890 h->heartbeat_sample_interval); in hpsa_init_one()
8891 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8892 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8896 clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8897 kfree(h->lastlogicals); in hpsa_init_one()
8898 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8899 hpsa_free_performant_mode(h); in hpsa_init_one()
8900 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8901 clean6: /* sg, cmd, irq, pci, lockup, wq/aer/h */ in hpsa_init_one()
8902 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8903 clean5: /* cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8904 hpsa_free_cmd_pool(h); in hpsa_init_one()
8905 clean4: /* irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8906 hpsa_free_irqs(h); in hpsa_init_one()
8907 clean3: /* shost, pci, lu, aer/h */ in hpsa_init_one()
8908 scsi_host_put(h->scsi_host); in hpsa_init_one()
8909 h->scsi_host = NULL; in hpsa_init_one()
8910 clean2_5: /* pci, lu, aer/h */ in hpsa_init_one()
8911 hpsa_free_pci_init(h); in hpsa_init_one()
8912 clean2: /* lu, aer/h */ in hpsa_init_one()
8913 if (h->lockup_detected) { in hpsa_init_one()
8914 free_percpu(h->lockup_detected); in hpsa_init_one()
8915 h->lockup_detected = NULL; in hpsa_init_one()
8917 clean1: /* wq/aer/h */ in hpsa_init_one()
8918 if (h->resubmit_wq) { in hpsa_init_one()
8919 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8920 h->resubmit_wq = NULL; in hpsa_init_one()
8922 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8923 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8924 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8926 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8927 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8928 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8930 kfree(h); in hpsa_init_one()
8934 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8940 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8946 c = cmd_alloc(h); in hpsa_flush_cache()
8948 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8952 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_flush_cache()
8958 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8960 cmd_free(h, c); in hpsa_flush_cache()
8967 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8974 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8981 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8984 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8988 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8996 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
9000 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_disable_rld_caching()
9006 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
9010 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
9019 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9022 cmd_free(h, c); in hpsa_disable_rld_caching()
9028 struct ctlr_info *h; in __hpsa_shutdown() local
9030 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
9035 hpsa_flush_cache(h); in __hpsa_shutdown()
9036 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9037 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
9038 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
9047 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
9051 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9052 kfree(h->dev[i]); in hpsa_free_device_info()
9053 h->dev[i] = NULL; in hpsa_free_device_info()
9059 struct ctlr_info *h; in hpsa_remove_one() local
9066 h = pci_get_drvdata(pdev); in hpsa_remove_one()
9069 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9070 h->remove_in_progress = 1; in hpsa_remove_one()
9071 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9072 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9073 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9074 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9075 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9076 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9077 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9079 hpsa_delete_sas_host(h); in hpsa_remove_one()
9087 if (h->scsi_host) in hpsa_remove_one()
9088 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9093 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
9095 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9096 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9097 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
9098 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
9099 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
9100 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
9101 kfree(h->lastlogicals); in hpsa_remove_one()
9105 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9106 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9109 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
9111 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9112 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9115 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9179 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9233 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9234 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9238 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9240 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9243 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9244 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9245 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9246 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9248 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9249 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9250 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9251 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9254 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9255 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9261 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9262 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9266 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9267 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9268 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9272 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9274 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9279 h->access = access; in hpsa_enter_performant_mode()
9280 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9288 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9289 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9290 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9291 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9293 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9294 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9295 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9298 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9299 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9301 h->reply_queue_size); in hpsa_enter_performant_mode()
9306 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9307 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9310 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9321 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9328 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9331 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9332 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9333 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9334 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9337 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9338 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9342 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9344 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9346 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9347 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9348 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9356 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9358 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9359 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9360 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9361 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9362 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9363 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9364 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9366 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9367 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9371 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9373 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9376 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9385 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9386 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9387 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9389 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9390 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9393 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9394 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9397 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9398 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9402 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9407 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9409 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9411 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9412 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9413 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9414 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9415 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9416 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9417 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9419 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9420 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9424 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9430 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9431 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9433 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9438 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9439 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9440 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9442 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9443 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9446 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9447 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9452 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9456 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9457 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9461 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9466 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9468 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9469 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9470 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9471 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9472 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9478 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9488 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9496 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9502 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9507 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9508 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9510 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9512 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9513 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9514 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9515 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9517 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9521 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9522 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9523 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9527 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9529 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9534 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9540 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9541 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9543 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9544 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9545 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9554 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9562 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9563 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9567 cmd_free(h, c); in hpsa_drain_accel_commands()
9739 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9745 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9746 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9756 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9764 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9770 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9786 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9800 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9802 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9856 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9862 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9864 if (!h) in hpsa_sas_get_enclosure_identifier()
9867 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()