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 <linux/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);
291 static void hpsa_update_scsi_devices(struct ctlr_info *h);
292 static int check_for_unit_attention(struct ctlr_info *h,
294 static void check_ioctl_unit_attention(struct ctlr_info *h,
299 static void hpsa_free_performant_mode(struct ctlr_info *h);
300 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h);
301 static inline u32 next_command(struct ctlr_info *h, u8 q);
309 static int wait_for_device_to_become_ready(struct ctlr_info *h,
315 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h);
318 static void hpsa_drain_accel_commands(struct ctlr_info *h);
319 static void hpsa_flush_cache(struct ctlr_info *h);
320 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
324 static u32 lockup_detected(struct ctlr_info *h);
325 static int detect_controller_lockup(struct ctlr_info *h);
326 static void hpsa_disable_rld_caching(struct ctlr_info *h);
327 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
329 static bool hpsa_vpd_page_supported(struct ctlr_info *h,
331 static int hpsa_luns_changed(struct ctlr_info *h);
332 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c,
375 static int check_for_unit_attention(struct ctlr_info *h, in check_for_unit_attention() argument
393 dev_warn(&h->pdev->dev, in check_for_unit_attention()
395 h->devname); in check_for_unit_attention()
398 dev_warn(&h->pdev->dev, in check_for_unit_attention()
399 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
402 dev_warn(&h->pdev->dev, in check_for_unit_attention()
403 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
410 dev_warn(&h->pdev->dev, in check_for_unit_attention()
412 h->devname); in check_for_unit_attention()
415 dev_warn(&h->pdev->dev, in check_for_unit_attention()
417 h->devname); in check_for_unit_attention()
420 dev_warn(&h->pdev->dev, in check_for_unit_attention()
422 h->devname); in check_for_unit_attention()
428 static int check_for_busy(struct ctlr_info *h, struct CommandList *c) in check_for_busy() argument
434 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
438 static u32 lockup_detected(struct ctlr_info *h);
443 struct ctlr_info *h; in host_show_lockup_detected() local
446 h = shost_to_hba(shost); in host_show_lockup_detected()
447 ld = lockup_detected(h); in host_show_lockup_detected()
457 struct ctlr_info *h; in host_store_hp_ssd_smart_path_status() local
468 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
469 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
470 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
472 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
481 struct ctlr_info *h; in host_store_raid_offload_debug() local
494 h = shost_to_hba(shost); in host_store_raid_offload_debug()
495 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
496 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
497 h->raid_offload_debug); in host_store_raid_offload_debug()
505 struct ctlr_info *h; in host_store_rescan() local
507 h = shost_to_hba(shost); in host_store_rescan()
508 hpsa_scan_start(h->scsi_host); in host_store_rescan()
521 struct ctlr_info *h; in host_show_firmware_revision() local
525 h = shost_to_hba(shost); in host_show_firmware_revision()
526 if (!h->hba_inquiry_data) in host_show_firmware_revision()
528 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
537 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
540 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
546 struct ctlr_info *h; in host_show_transport_mode() local
549 h = shost_to_hba(shost); in host_show_transport_mode()
551 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
558 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
561 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
563 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
642 struct ctlr_info *h; in host_show_resettable() local
645 h = shost_to_hba(shost); in host_show_resettable()
646 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
677 struct ctlr_info *h; in raid_level_show() local
683 h = sdev_to_hba(sdev); in raid_level_show()
684 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
687 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
693 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
699 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
709 struct ctlr_info *h; in lunid_show() local
716 h = sdev_to_hba(sdev); in lunid_show()
717 spin_lock_irqsave(&h->lock, flags); in lunid_show()
720 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
724 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
731 struct ctlr_info *h; in unique_id_show() local
738 h = sdev_to_hba(sdev); in unique_id_show()
739 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
742 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
746 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
759 struct ctlr_info *h; in sas_address_show() local
766 h = sdev_to_hba(sdev); in sas_address_show()
767 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
770 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
774 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
782 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
789 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
790 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
793 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
797 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
810 struct ctlr_info *h; in path_info_show() local
823 h = sdev_to_hba(sdev); in path_info_show()
824 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
827 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
844 h->scsi_host->host_no, in path_info_show()
888 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
895 struct ctlr_info *h; in host_show_ctlr_num() local
898 h = shost_to_hba(shost); in host_show_ctlr_num()
899 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
905 struct ctlr_info *h; in host_show_legacy_board() local
908 h = shost_to_hba(shost); in host_show_legacy_board()
909 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
994 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
997 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
999 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
1000 return h->access.command_completed(h, q); in next_command()
1002 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
1003 return h->access.command_completed(h, q); in next_command()
1008 atomic_dec(&h->commands_outstanding); in next_command()
1013 if (rq->current_entry == h->max_commands) { in next_command()
1052 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1055 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1056 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1057 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1063 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1067 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1080 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1084 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1089 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1100 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1103 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1107 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1120 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1136 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1141 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1142 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1145 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1149 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1150 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1153 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1156 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1157 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1164 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1167 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1168 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1171 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1172 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1175 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1176 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1179 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1180 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1184 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1186 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1194 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1196 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1198 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1203 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1207 * assumes h->devlock is held in hpsa_find_target_lun()
1214 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1215 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1216 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1229 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1235 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1271 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1273 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1284 /* Add an entry into h->dev[] array. */
1285 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1289 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1290 int n = h->ndevices; in hpsa_scsi_add_entry()
1296 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1312 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1328 sd = h->dev[i]; in hpsa_scsi_add_entry()
1341 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1349 h->dev[n] = device; in hpsa_scsi_add_entry()
1350 h->ndevices++; in hpsa_scsi_add_entry()
1353 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1361 * Update an entry in h->dev[] array.
1363 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1366 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1370 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1375 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1385 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1387 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1388 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1391 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1394 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1395 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1396 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1397 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1401 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1404 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1410 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1412 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1415 /* Replace an entry from h->dev[] array. */
1416 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1421 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1423 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1431 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1432 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1435 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1439 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1442 /* Remove an entry from h->dev[] array. */
1443 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1446 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1452 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1453 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1456 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1457 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1458 h->ndevices--; in hpsa_scsi_remove_entry()
1459 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1472 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1476 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1481 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1482 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1483 if (h->dev[i] == added) { in fixup_botched_add()
1484 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1485 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1486 h->ndevices--; in fixup_botched_add()
1490 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1589 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1596 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1597 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1600 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1604 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1612 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1613 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1614 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1618 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1622 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1624 h->scsi_host->host_no, in hpsa_show_volume_status()
1630 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1632 h->scsi_host->host_no, in hpsa_show_volume_status()
1636 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1638 h->scsi_host->host_no, in hpsa_show_volume_status()
1642 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1644 h->scsi_host->host_no, in hpsa_show_volume_status()
1648 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1650 h->scsi_host->host_no, in hpsa_show_volume_status()
1654 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1656 h->scsi_host->host_no, in hpsa_show_volume_status()
1660 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1662 h->scsi_host->host_no, in hpsa_show_volume_status()
1666 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1668 h->scsi_host->host_no, in hpsa_show_volume_status()
1672 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1674 h->scsi_host->host_no, in hpsa_show_volume_status()
1678 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1680 h->scsi_host->host_no, in hpsa_show_volume_status()
1684 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1686 h->scsi_host->host_no, in hpsa_show_volume_status()
1690 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1692 h->scsi_host->host_no, in hpsa_show_volume_status()
1702 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1741 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1754 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1757 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1773 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1777 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1811 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1815 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1819 if (!h->scsi_host) in hpsa_add_device()
1823 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1826 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1831 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1837 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1838 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1841 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1845 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1848 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1851 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1858 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1869 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1878 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1881 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1886 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1891 if (!h->scsi_host) in hpsa_remove_device()
1898 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1901 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1912 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1921 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1926 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1938 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1939 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1940 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1941 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1944 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1950 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1955 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1957 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1958 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1967 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1968 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1972 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1976 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1983 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1989 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
2002 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
2003 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
2007 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2008 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2011 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2017 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2022 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2025 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2032 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2033 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2035 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2038 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2041 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2042 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2048 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2063 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2076 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2079 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2081 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2084 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2085 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2095 * Assume's h->devlock is held.
2097 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2103 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2104 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2115 struct ctlr_info *h; in hpsa_sdev_init() local
2117 h = sdev_to_hba(sdev); in hpsa_sdev_init()
2118 spin_lock_irqsave(&h->devlock, flags); in hpsa_sdev_init()
2125 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sdev_init()
2132 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_sdev_init()
2140 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_sdev_init()
2188 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2192 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2194 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2195 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2196 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2198 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2199 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2202 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2206 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2210 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2212 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2214 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2215 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2216 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2219 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2225 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2229 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2233 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2235 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2236 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2237 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2239 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2240 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2243 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2247 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2250 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2252 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2255 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2256 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2257 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2259 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2266 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2270 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2277 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2279 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2281 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2290 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2300 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2303 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2310 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2311 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2314 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2316 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2318 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2327 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2332 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2335 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2336 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2345 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2425 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2426 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2460 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2476 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2480 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2483 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2484 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2487 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2490 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2495 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2498 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2501 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2505 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2511 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2529 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2532 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2535 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2536 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2538 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2542 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2562 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2572 struct ctlr_info *h; in complete_scsi_command() local
2584 h = cp->h; in complete_scsi_command()
2588 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2594 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2596 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2600 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2601 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2605 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2611 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2619 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2633 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2637 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2641 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2647 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2663 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2690 h->drv_req_rescan = 1; in complete_scsi_command()
2705 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2712 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2734 dev_warn(&h->pdev->dev, in complete_scsi_command()
2751 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2756 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2761 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2769 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2774 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2779 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2784 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2787 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2795 dev_warn(&h->pdev->dev, in complete_scsi_command()
2800 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2804 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2849 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2855 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2863 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2869 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2872 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2876 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2879 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2885 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2892 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2901 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2911 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2912 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2914 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2920 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2926 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2930 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2934 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2946 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2961 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2967 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2972 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2975 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2978 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2981 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2984 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2987 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2990 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2993 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2996 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2999 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
3005 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
3012 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
3013 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
3018 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3024 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3028 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3032 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3043 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3056 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3064 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3066 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3071 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3077 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3081 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3085 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3092 c = cmd_alloc(h); in hpsa_send_reset()
3096 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3097 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3099 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3106 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3110 cmd_free(h, c); in hpsa_send_reset()
3114 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3120 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3165 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3173 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3179 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3180 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3184 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3188 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3190 lockup_detected(h)); in hpsa_do_reset()
3193 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3194 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3200 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3202 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3206 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3217 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3221 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3235 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3246 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3271 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3273 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3275 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3278 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3282 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3285 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3289 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3290 " D%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3296 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3297 " M%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3304 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3311 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3318 c = cmd_alloc(h); in hpsa_get_raid_map()
3320 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3323 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3324 cmd_free(h, c); in hpsa_get_raid_map()
3327 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3333 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3337 cmd_free(h, c); in hpsa_get_raid_map()
3342 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3345 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3348 cmd_free(h, c); in hpsa_get_raid_map()
3352 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3360 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3362 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3370 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3376 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3380 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3384 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3391 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3393 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3398 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3404 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3408 cmd_free(h, c); in hpsa_bmic_id_controller()
3412 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3420 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3421 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3429 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3433 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3437 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3448 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3467 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3489 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3492 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3497 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3499 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3510 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3531 cmd_free(h, c); in hpsa_get_enclosure_info()
3534 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3538 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3550 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3551 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3568 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3581 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3585 h->sas_address = sa; in hpsa_get_sas_address()
3590 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3595 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3601 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3610 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3612 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3613 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3620 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3633 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3645 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3670 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3684 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3686 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3704 rc = hpsa_get_raid_map(h, scsi3addr, this_device); in hpsa_get_ioaccel_status()
3717 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3724 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3731 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3744 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3753 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3757 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3764 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3771 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3777 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3778 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3788 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3792 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3798 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3808 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3823 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3826 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3838 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3851 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3855 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3862 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3882 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3894 c = cmd_alloc(h); in hpsa_volume_offline()
3896 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3897 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3900 cmd_free(h, c); in hpsa_volume_offline()
3909 cmd_free(h, c); in hpsa_volume_offline()
3912 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3941 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3962 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3964 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3983 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3985 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3987 h->ctlr, __func__, in hpsa_update_device_info()
3988 h->scsi_host->host_no, in hpsa_update_device_info()
4002 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
4003 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
4004 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
4005 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
4007 h->legacy_board) { in hpsa_update_device_info()
4011 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4019 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4030 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4059 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4090 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4117 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4121 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4122 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4127 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4131 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4132 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4138 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4145 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4154 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4182 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4199 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4245 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4252 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4257 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4269 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4279 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4296 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4328 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4334 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4369 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4373 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4375 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4377 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4382 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4383 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4394 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4399 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4407 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4413 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4430 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4435 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4443 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4450 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4453 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4455 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4459 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4463 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4483 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4503 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4516 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4538 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4541 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4543 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4549 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4577 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4585 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4602 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4603 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4616 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4627 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4628 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4631 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4633 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4647 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4651 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4733 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4738 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4748 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4756 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4769 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4803 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4822 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4830 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4844 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4851 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4892 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4907 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4912 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4926 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4929 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4941 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4956 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4958 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4966 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
5000 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5011 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
5023 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5026 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5039 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5046 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5065 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5066 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5070 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5104 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5448 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5458 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5507 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5513 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5514 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5519 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5525 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5530 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5538 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5539 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5541 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5547 c->h = h; in hpsa_cmd_init()
5551 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5555 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5556 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5558 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5563 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5566 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5575 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5594 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5600 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5604 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5610 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5627 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5632 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5636 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5637 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5643 rc = hpsa_ioaccel_submit(h, c, cmd, true); in hpsa_command_resubmit_worker()
5653 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5658 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5668 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5685 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5691 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5708 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5717 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5737 h->acciopath_status)) { in hpsa_scsi_queue_command()
5739 rc = hpsa_ioaccel_submit(h, c, cmd, false); in hpsa_scsi_queue_command()
5743 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5747 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5750 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5754 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5755 h->scan_finished = 1; in hpsa_scan_complete()
5756 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5757 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5762 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5771 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5772 return hpsa_scan_complete(h); in hpsa_scan_start()
5777 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5778 if (h->scan_waiting) { in hpsa_scan_start()
5779 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5783 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5787 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5788 if (h->scan_finished) in hpsa_scan_start()
5790 h->scan_waiting = 1; in hpsa_scan_start()
5791 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5792 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5799 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5800 h->scan_waiting = 0; in hpsa_scan_start()
5801 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5803 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5804 return hpsa_scan_complete(h); in hpsa_scan_start()
5809 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5810 if (h->reset_in_progress) { in hpsa_scan_start()
5811 h->drv_req_rescan = 1; in hpsa_scan_start()
5812 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5813 hpsa_scan_complete(h); in hpsa_scan_start()
5816 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5818 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5820 hpsa_scan_complete(h); in hpsa_scan_start()
5841 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5845 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5846 finished = h->scan_finished; in hpsa_scan_finished()
5847 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5851 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5857 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5868 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5870 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5872 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5873 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5876 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5880 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5884 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5886 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5889 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5914 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5921 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5923 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5950 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5967 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5975 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5983 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5993 c = cmd_alloc(h); in wait_for_device_to_become_ready()
6002 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6009 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
6015 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6017 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6019 cmd_free(h, c); in wait_for_device_to_become_ready()
6030 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
6037 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6038 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
6041 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6042 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6043 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6045 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6052 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6063 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6067 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6073 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6077 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6095 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6109 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6118 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6121 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6122 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6125 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6136 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6140 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6142 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6143 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6144 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6158 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6159 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6163 h->last_collision_tag = idx; in cmd_tagged_alloc()
6169 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6180 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6198 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6224 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6231 c = h->cmd_pool + i; in cmd_alloc()
6234 cmd_free(h, c); /* already in use */ in cmd_alloc()
6238 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6241 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6259 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6264 i = c - h->cmd_pool; in cmd_free()
6265 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6274 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_passthru() local
6290 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6292 err = hpsa_passthru_ioctl(h, &arg64); in hpsa_ioctl32_passthru()
6293 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6305 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_big_passthru() local
6321 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6323 err = hpsa_big_passthru_ioctl(h, &arg64); in hpsa_ioctl32_big_passthru()
6324 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6365 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6371 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6372 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6373 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6374 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6380 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6389 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6403 static int hpsa_passthru_ioctl(struct ctlr_info *h, in hpsa_passthru_ioctl() argument
6432 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6454 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6456 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6466 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6469 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6470 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6488 cmd_free(h, c); in hpsa_passthru_ioctl()
6494 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, in hpsa_big_passthru_ioctl() argument
6549 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6561 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6563 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6567 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6578 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6581 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6582 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6605 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6618 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6623 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6632 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl() local
6639 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6642 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6644 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6652 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6654 rc = hpsa_passthru_ioctl(h, &iocommand); in hpsa_ioctl()
6655 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6666 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6668 rc = hpsa_big_passthru_ioctl(h, &ioc); in hpsa_ioctl()
6669 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6679 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6683 c = cmd_alloc(h); in hpsa_send_host_reset()
6686 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6690 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6698 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6861 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6897 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6902 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6919 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6937 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6939 return h->access.command_completed(h, q); in get_next_completion()
6942 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6944 return h->access.intr_pending(h); in interrupt_pending()
6947 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6949 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6950 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6953 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6956 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6957 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6965 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6974 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6981 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6982 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6992 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6997 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
7000 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
7007 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7008 * Relies on (h-q[x] == x) being true for x such that
7018 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
7022 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
7025 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
7027 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7028 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
7029 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
7031 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
7038 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
7042 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
7045 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7046 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
7048 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7054 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7058 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7060 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7061 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7062 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7064 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7065 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7073 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7077 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7078 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7080 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7081 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7208 * CSR=00h. The software off state is D3, CSR=03h. To reset in hpsa_controller_hard_reset()
7483 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7485 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7486 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7489 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7494 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7495 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7500 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7506 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7512 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7518 switch (h->board_id) { in hpsa_interrupt_mode()
7525 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7528 h->msix_vectors = ret; in hpsa_interrupt_mode()
7536 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7631 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7633 if (h->transtable) { in hpsa_free_cfgtables()
7634 iounmap(h->transtable); in hpsa_free_cfgtables()
7635 h->transtable = NULL; in hpsa_free_cfgtables()
7637 if (h->cfgtable) { in hpsa_free_cfgtables()
7638 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7639 h->cfgtable = NULL; in hpsa_free_cfgtables()
7646 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7654 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7658 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7659 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7660 if (!h->cfgtable) { in hpsa_find_cfgtables()
7661 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7664 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7668 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7669 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7671 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7672 if (!h->transtable) { in hpsa_find_cfgtables()
7673 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7674 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7680 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7685 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7688 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7689 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7691 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7692 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7694 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7696 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7704 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7706 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7713 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7715 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7716 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7717 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7718 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7719 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7721 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7722 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7723 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7730 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7731 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7732 h->chainsize = 0; in hpsa_find_board_params()
7736 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7737 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7738 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7739 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7740 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7741 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7742 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7745 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7747 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7748 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7754 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7758 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7764 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7770 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7774 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7776 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7778 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7781 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7788 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7789 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7790 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7801 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7812 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7814 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7815 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7816 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7828 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7832 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7836 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7839 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7840 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7841 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7842 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7844 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7845 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7847 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7850 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7855 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7857 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7858 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7859 h->vaddr = NULL; in hpsa_free_pci_init()
7860 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7865 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7866 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7870 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7875 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7878 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7879 h->access = *(products[prod_index].access); in hpsa_pci_init()
7880 h->legacy_board = legacy_board; in hpsa_pci_init()
7881 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7884 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7886 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7887 pci_disable_device(h->pdev); in hpsa_pci_init()
7891 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7893 dev_err(&h->pdev->dev, in hpsa_pci_init()
7895 pci_disable_device(h->pdev); in hpsa_pci_init()
7899 pci_set_master(h->pdev); in hpsa_pci_init()
7901 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7906 hpsa_setup_reply_map(h); in hpsa_pci_init()
7908 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7911 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7912 if (!h->vaddr) { in hpsa_pci_init()
7913 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7917 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7920 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7923 hpsa_find_board_params(h); in hpsa_pci_init()
7925 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7929 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7930 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7931 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7937 hpsa_free_cfgtables(h); in hpsa_pci_init()
7939 iounmap(h->vaddr); in hpsa_pci_init()
7940 h->vaddr = NULL; in hpsa_pci_init()
7942 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7948 pci_disable_device(h->pdev); in hpsa_pci_init()
7949 pci_release_regions(h->pdev); in hpsa_pci_init()
7953 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7958 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7959 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7961 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7962 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7964 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7965 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
8031 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
8033 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8034 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8035 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8036 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8037 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8038 h->cmd_pool, in hpsa_free_cmd_pool()
8039 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8040 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8041 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8043 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8044 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8045 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8046 h->errinfo_pool, in hpsa_free_cmd_pool()
8047 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8048 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8049 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8053 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8055 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); 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 hpda_free_ctlr_info(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()
9114 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9178 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9232 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9233 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9237 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9239 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9242 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9243 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9244 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9245 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9247 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9248 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9249 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9250 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9253 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9254 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9260 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9261 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9265 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9266 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9267 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9271 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9273 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9278 h->access = access; in hpsa_enter_performant_mode()
9279 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9287 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9288 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9289 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9290 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9292 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9293 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9294 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9297 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9298 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9300 h->reply_queue_size); in hpsa_enter_performant_mode()
9305 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9306 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9309 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9320 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9327 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9330 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9331 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9332 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9333 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9336 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9337 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9341 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9343 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9345 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9346 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9347 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9355 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9357 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9358 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9359 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9360 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9361 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9362 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9363 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9365 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9366 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9370 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9372 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9373 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9385 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9386 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9388 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9389 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9392 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9393 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9396 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9397 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9401 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9406 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9408 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9410 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9411 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9412 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9413 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9414 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9415 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9416 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9418 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9419 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9423 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9429 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9431 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9438 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9439 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9441 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9442 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9445 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9446 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9451 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9455 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9456 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9460 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9465 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9467 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9468 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9469 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9470 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9471 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9477 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9485 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9491 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9495 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9500 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9501 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9503 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9505 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9506 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9507 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9508 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9510 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9514 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9515 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9516 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9520 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9522 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9527 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9533 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9534 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9536 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9537 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9538 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9547 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9555 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9556 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9560 cmd_free(h, c); in hpsa_drain_accel_commands()
9732 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9738 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9739 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9749 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9757 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9763 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9779 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9794 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9796 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9852 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9858 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9860 if (!h) in hpsa_sas_get_enclosure_identifier()
9863 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()