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
464 h = shost_to_hba(shost); in host_store_hp_ssd_smart_path_status()
465 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
466 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
468 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
477 struct ctlr_info *h; in host_store_raid_offload_debug() local
486 h = shost_to_hba(shost); in host_store_raid_offload_debug()
487 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
488 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
489 h->raid_offload_debug); in host_store_raid_offload_debug()
497 struct ctlr_info *h; in host_store_rescan() local
499 h = shost_to_hba(shost); in host_store_rescan()
500 hpsa_scan_start(h->scsi_host); in host_store_rescan()
513 struct ctlr_info *h; in host_show_firmware_revision() local
517 h = shost_to_hba(shost); in host_show_firmware_revision()
518 if (!h->hba_inquiry_data) in host_show_firmware_revision()
520 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
529 struct ctlr_info *h = shost_to_hba(shost); in host_show_commands_outstanding() local
532 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
538 struct ctlr_info *h; in host_show_transport_mode() local
541 h = shost_to_hba(shost); in host_show_transport_mode()
543 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
550 struct ctlr_info *h; in host_show_hp_ssd_smart_path_status() local
553 h = shost_to_hba(shost); in host_show_hp_ssd_smart_path_status()
555 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
634 struct ctlr_info *h; in host_show_resettable() local
637 h = shost_to_hba(shost); in host_show_resettable()
638 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
669 struct ctlr_info *h; in raid_level_show() local
675 h = sdev_to_hba(sdev); in raid_level_show()
676 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
679 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
685 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
691 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
701 struct ctlr_info *h; in lunid_show() local
708 h = sdev_to_hba(sdev); in lunid_show()
709 spin_lock_irqsave(&h->lock, flags); in lunid_show()
712 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
716 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
723 struct ctlr_info *h; in unique_id_show() local
730 h = sdev_to_hba(sdev); in unique_id_show()
731 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
734 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
738 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
751 struct ctlr_info *h; in sas_address_show() local
758 h = sdev_to_hba(sdev); in sas_address_show()
759 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
762 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
766 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
774 struct ctlr_info *h; in host_show_hp_ssd_smart_path_enabled() local
781 h = sdev_to_hba(sdev); in host_show_hp_ssd_smart_path_enabled()
782 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
785 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
789 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
802 struct ctlr_info *h; in path_info_show() local
815 h = sdev_to_hba(sdev); in path_info_show()
816 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
819 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
836 h->scsi_host->host_no, in path_info_show()
880 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
887 struct ctlr_info *h; in host_show_ctlr_num() local
890 h = shost_to_hba(shost); in host_show_ctlr_num()
891 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
897 struct ctlr_info *h; in host_show_legacy_board() local
900 h = shost_to_hba(shost); in host_show_legacy_board()
901 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
986 static inline u32 next_command(struct ctlr_info *h, u8 q) in next_command() argument
989 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
991 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
992 return h->access.command_completed(h, q); in next_command()
994 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
995 return h->access.command_completed(h, q); in next_command()
1000 atomic_dec(&h->commands_outstanding); in next_command()
1005 if (rq->current_entry == h->max_commands) { in next_command()
1044 static void set_performant_mode(struct ctlr_info *h, struct CommandList *c, in set_performant_mode() argument
1047 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1048 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1049 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1055 static void set_ioaccel1_performant_mode(struct ctlr_info *h, in set_ioaccel1_performant_mode() argument
1059 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1072 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1076 static void set_ioaccel2_tmf_performant_mode(struct ctlr_info *h, in set_ioaccel2_tmf_performant_mode() argument
1081 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1092 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1095 static void set_ioaccel2_performant_mode(struct ctlr_info *h, in set_ioaccel2_performant_mode() argument
1099 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1112 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1128 static void dial_down_lockup_detection_during_fw_flash(struct ctlr_info *h, in dial_down_lockup_detection_during_fw_flash() argument
1133 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1134 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1137 static void dial_up_lockup_detection_on_fw_flash_complete(struct ctlr_info *h, in dial_up_lockup_detection_on_fw_flash_complete() argument
1141 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1142 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1145 static void __enqueue_cmd_and_start_io(struct ctlr_info *h, in __enqueue_cmd_and_start_io() argument
1148 dial_down_lockup_detection_during_fw_flash(h, c); in __enqueue_cmd_and_start_io()
1149 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1156 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1159 set_ioaccel1_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1160 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1163 set_ioaccel2_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1164 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1167 set_ioaccel2_tmf_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1168 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1171 set_performant_mode(h, c, reply_queue); in __enqueue_cmd_and_start_io()
1172 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1176 static void enqueue_cmd_and_start_io(struct ctlr_info *h, struct CommandList *c) in enqueue_cmd_and_start_io() argument
1178 __enqueue_cmd_and_start_io(h, c, DEFAULT_REPLY_QUEUE); in enqueue_cmd_and_start_io()
1186 static inline int is_scsi_rev_5(struct ctlr_info *h) in is_scsi_rev_5() argument
1188 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1190 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1195 static int hpsa_find_target_lun(struct ctlr_info *h, in hpsa_find_target_lun() argument
1199 * assumes h->devlock is held in hpsa_find_target_lun()
1206 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1207 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1208 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1221 static void hpsa_show_dev_msg(const char *level, struct ctlr_info *h, in hpsa_show_dev_msg() argument
1227 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1263 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1265 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1276 /* Add an entry into h->dev[] array. */
1277 static int hpsa_scsi_add_entry(struct ctlr_info *h, in hpsa_scsi_add_entry() argument
1281 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1282 int n = h->ndevices; in hpsa_scsi_add_entry()
1288 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1304 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1320 sd = h->dev[i]; in hpsa_scsi_add_entry()
1333 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1341 h->dev[n] = device; in hpsa_scsi_add_entry()
1342 h->ndevices++; in hpsa_scsi_add_entry()
1345 hpsa_show_dev_msg(KERN_INFO, h, device, in hpsa_scsi_add_entry()
1353 * Update an entry in h->dev[] array.
1355 static void hpsa_scsi_update_entry(struct ctlr_info *h, in hpsa_scsi_update_entry() argument
1358 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1362 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1367 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1377 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1379 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1380 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1383 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1386 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1387 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1388 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1389 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1393 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1396 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1402 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1404 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1407 /* Replace an entry from h->dev[] array. */
1408 static void hpsa_scsi_replace_entry(struct ctlr_info *h, in hpsa_scsi_replace_entry() argument
1413 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1415 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1423 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1424 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1427 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1431 hpsa_show_dev_msg(KERN_INFO, h, new_entry, "replaced"); in hpsa_scsi_replace_entry()
1434 /* Remove an entry from h->dev[] array. */
1435 static void hpsa_scsi_remove_entry(struct ctlr_info *h, int entry, in hpsa_scsi_remove_entry() argument
1438 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1444 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1445 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1448 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1449 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1450 h->ndevices--; in hpsa_scsi_remove_entry()
1451 hpsa_show_dev_msg(KERN_INFO, h, sd, "removed"); in hpsa_scsi_remove_entry()
1464 static void fixup_botched_add(struct ctlr_info *h, in fixup_botched_add() argument
1468 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1473 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1474 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1475 if (h->dev[i] == added) { in fixup_botched_add()
1476 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1477 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1478 h->ndevices--; in fixup_botched_add()
1482 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1581 static void hpsa_monitor_offline_device(struct ctlr_info *h, in hpsa_monitor_offline_device() argument
1588 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1589 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1592 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1596 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1604 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1605 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1606 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1610 static void hpsa_show_volume_status(struct ctlr_info *h, in hpsa_show_volume_status() argument
1614 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1616 h->scsi_host->host_no, in hpsa_show_volume_status()
1622 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1624 h->scsi_host->host_no, in hpsa_show_volume_status()
1628 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1630 h->scsi_host->host_no, in hpsa_show_volume_status()
1634 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1636 h->scsi_host->host_no, in hpsa_show_volume_status()
1640 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1642 h->scsi_host->host_no, in hpsa_show_volume_status()
1646 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1648 h->scsi_host->host_no, in hpsa_show_volume_status()
1652 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1654 h->scsi_host->host_no, in hpsa_show_volume_status()
1658 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1660 h->scsi_host->host_no, in hpsa_show_volume_status()
1664 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1666 h->scsi_host->host_no, in hpsa_show_volume_status()
1670 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1672 h->scsi_host->host_no, in hpsa_show_volume_status()
1676 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1678 h->scsi_host->host_no, in hpsa_show_volume_status()
1682 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1684 h->scsi_host->host_no, in hpsa_show_volume_status()
1694 static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, in hpsa_figure_phys_disk_ptrs() argument
1733 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1746 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1749 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1765 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1769 static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, in hpsa_update_log_drive_phys_drive_ptrs() argument
1803 hpsa_figure_phys_disk_ptrs(h, dev, ndevices, dev[i]); in hpsa_update_log_drive_phys_drive_ptrs()
1807 static int hpsa_add_device(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) in hpsa_add_device() argument
1811 if (!h->scsi_host) in hpsa_add_device()
1815 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1818 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1823 static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_find_outstanding_commands_for_dev() argument
1829 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1830 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1833 if (refcount > 1 && hpsa_cmd_dev_match(h, c, dev, in hpsa_find_outstanding_commands_for_dev()
1837 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1840 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1843 cmd_free(h, c); in hpsa_find_outstanding_commands_for_dev()
1850 static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h, in hpsa_wait_for_outstanding_commands_for_dev() argument
1861 cmds = hpsa_find_outstanding_commands_for_dev(h, device); in hpsa_wait_for_outstanding_commands_for_dev()
1870 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1873 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1878 static void hpsa_remove_device(struct ctlr_info *h, in hpsa_remove_device() argument
1883 if (!h->scsi_host) in hpsa_remove_device()
1890 hpsa_wait_for_outstanding_commands_for_dev(h, device); in hpsa_remove_device()
1893 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1904 hpsa_show_dev_msg(KERN_WARNING, h, device, in hpsa_remove_device()
1913 static void adjust_hpsa_scsi_table(struct ctlr_info *h, in adjust_hpsa_scsi_table() argument
1918 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1930 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1931 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1932 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1933 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1936 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1942 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1947 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1949 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1950 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1959 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1960 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1964 hpsa_scsi_remove_entry(h, i, removed, &nremoved); in adjust_hpsa_scsi_table()
1968 hpsa_scsi_replace_entry(h, i, sd[entry], in adjust_hpsa_scsi_table()
1975 hpsa_scsi_update_entry(h, i, sd[entry]); in adjust_hpsa_scsi_table()
1981 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
1994 hpsa_show_volume_status(h, sd[i]); in adjust_hpsa_scsi_table()
1995 hpsa_show_dev_msg(KERN_INFO, h, sd[i], "offline"); in adjust_hpsa_scsi_table()
1999 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2000 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2003 if (hpsa_scsi_add_entry(h, sd[i], added, &nadded) != 0) in adjust_hpsa_scsi_table()
2009 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2014 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2017 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2024 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2025 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2027 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2030 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2033 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2034 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2040 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2055 hpsa_remove_device(h, removed[i]); in adjust_hpsa_scsi_table()
2068 rc = hpsa_add_device(h, added[i]); in adjust_hpsa_scsi_table()
2071 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2073 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2076 fixup_botched_add(h, added[i]); in adjust_hpsa_scsi_table()
2077 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2087 * Assume's h->devlock is held.
2089 static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h, in lookup_hpsa_scsi_dev() argument
2095 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2096 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2107 struct ctlr_info *h; in hpsa_sdev_init() local
2109 h = sdev_to_hba(sdev); in hpsa_sdev_init()
2110 spin_lock_irqsave(&h->devlock, flags); in hpsa_sdev_init()
2117 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sdev_init()
2124 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev), in hpsa_sdev_init()
2132 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_sdev_init()
2180 static void hpsa_free_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_ioaccel2_sg_chain_blocks() argument
2184 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2186 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2187 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2188 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2190 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2191 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2194 static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) in hpsa_allocate_ioaccel2_sg_chain_blocks() argument
2198 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2201 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2202 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2204 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2206 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2207 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2211 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_allocate_ioaccel2_sg_chain_blocks()
2221 static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) in hpsa_free_sg_chain_blocks() argument
2225 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2227 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2228 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2229 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2231 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2232 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2235 static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) in hpsa_alloc_sg_chain_blocks() argument
2239 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2242 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2244 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2247 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2248 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2249 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2251 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2258 hpsa_free_sg_chain_blocks(h); in hpsa_alloc_sg_chain_blocks()
2262 static int hpsa_map_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_map_ioaccel2_sg_chain_block() argument
2269 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2271 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2273 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2282 static void hpsa_unmap_ioaccel2_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_ioaccel2_sg_chain_block() argument
2292 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2295 static int hpsa_map_sg_chain_block(struct ctlr_info *h, in hpsa_map_sg_chain_block() argument
2302 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2303 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2306 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2308 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2310 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2319 static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, in hpsa_unmap_sg_chain_block() argument
2324 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2327 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2328 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2337 static int handle_ioaccel_mode2_error(struct ctlr_info *h, in handle_ioaccel_mode2_error() argument
2417 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2418 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2452 static void hpsa_cmd_resolve_events(struct ctlr_info *h, in hpsa_cmd_resolve_events() argument
2468 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2472 static void hpsa_cmd_resolve_and_free(struct ctlr_info *h, in hpsa_cmd_resolve_and_free() argument
2475 hpsa_cmd_resolve_events(h, c); in hpsa_cmd_resolve_and_free()
2476 cmd_tagged_free(h, c); in hpsa_cmd_resolve_and_free()
2479 static void hpsa_cmd_free_and_done(struct ctlr_info *h, in hpsa_cmd_free_and_done() argument
2482 hpsa_cmd_resolve_and_free(h, c); in hpsa_cmd_free_and_done()
2487 static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c) in hpsa_retry_cmd() argument
2490 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2493 static void process_ioaccel2_completion(struct ctlr_info *h, in process_ioaccel2_completion() argument
2497 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2503 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2521 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2524 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2527 if (handle_ioaccel_mode2_error(h, c, cmd, c2, dev)) in process_ioaccel2_completion()
2528 return hpsa_retry_cmd(h, c); in process_ioaccel2_completion()
2530 return hpsa_cmd_free_and_done(h, c, cmd); in process_ioaccel2_completion()
2534 static int hpsa_evaluate_tmf_status(struct ctlr_info *h, in hpsa_evaluate_tmf_status() argument
2554 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2564 struct ctlr_info *h; in complete_scsi_command() local
2576 h = cp->h; in complete_scsi_command()
2580 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2586 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2588 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2592 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2593 hpsa_unmap_sg_chain_block(h, cp); in complete_scsi_command()
2597 hpsa_unmap_ioaccel2_sg_chain_block(h, c2); in complete_scsi_command()
2603 hpsa_cmd_resolve_and_free(h, cp); in complete_scsi_command()
2611 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2625 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2629 return process_ioaccel2_completion(h, cp, cmd, dev); in complete_scsi_command()
2633 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2639 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2655 return hpsa_retry_cmd(h, cp); in complete_scsi_command()
2682 h->drv_req_rescan = 1; in complete_scsi_command()
2697 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2704 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2726 dev_warn(&h->pdev->dev, in complete_scsi_command()
2743 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2748 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2753 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2761 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2766 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2771 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2776 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2779 if (hpsa_evaluate_tmf_status(h, cp)) /* TMF failed? */ in complete_scsi_command()
2787 dev_warn(&h->pdev->dev, in complete_scsi_command()
2792 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2796 return hpsa_cmd_free_and_done(h, cp, cmd); in complete_scsi_command()
2841 static int hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_core() argument
2847 __enqueue_cmd_and_start_io(h, c, reply_queue); in hpsa_scsi_do_simple_cmd_core()
2855 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2861 static int hpsa_scsi_do_simple_cmd(struct ctlr_info *h, struct CommandList *c, in hpsa_scsi_do_simple_cmd() argument
2864 if (unlikely(lockup_detected(h))) { in hpsa_scsi_do_simple_cmd()
2868 return hpsa_scsi_do_simple_cmd_core(h, c, reply_queue, timeout_msecs); in hpsa_scsi_do_simple_cmd()
2871 static u32 lockup_detected(struct ctlr_info *h) in lockup_detected() argument
2877 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2884 static int hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h, in hpsa_scsi_do_simple_cmd_with_retry() argument
2893 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_scsi_do_simple_cmd_with_retry()
2903 } while ((check_for_unit_attention(h, c) || in hpsa_scsi_do_simple_cmd_with_retry()
2904 check_for_busy(h, c)) && in hpsa_scsi_do_simple_cmd_with_retry()
2906 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2912 static void hpsa_print_cmd(struct ctlr_info *h, char *txt, in hpsa_print_cmd() argument
2918 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2922 static void hpsa_scsi_interpret_error(struct ctlr_info *h, in hpsa_scsi_interpret_error() argument
2926 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2938 hpsa_print_cmd(h, "SCSI status", cp); in hpsa_scsi_interpret_error()
2953 hpsa_print_cmd(h, "overrun condition", cp); in hpsa_scsi_interpret_error()
2959 hpsa_print_cmd(h, "invalid command", cp); in hpsa_scsi_interpret_error()
2964 hpsa_print_cmd(h, "protocol error", cp); in hpsa_scsi_interpret_error()
2967 hpsa_print_cmd(h, "hardware error", cp); in hpsa_scsi_interpret_error()
2970 hpsa_print_cmd(h, "connection lost", cp); in hpsa_scsi_interpret_error()
2973 hpsa_print_cmd(h, "aborted", cp); in hpsa_scsi_interpret_error()
2976 hpsa_print_cmd(h, "abort failed", cp); in hpsa_scsi_interpret_error()
2979 hpsa_print_cmd(h, "unsolicited abort", cp); in hpsa_scsi_interpret_error()
2982 hpsa_print_cmd(h, "timed out", cp); in hpsa_scsi_interpret_error()
2985 hpsa_print_cmd(h, "unabortable", cp); in hpsa_scsi_interpret_error()
2988 hpsa_print_cmd(h, "controller lockup detected", cp); in hpsa_scsi_interpret_error()
2991 hpsa_print_cmd(h, "unknown status", cp); in hpsa_scsi_interpret_error()
2997 static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, in hpsa_do_receive_diagnostic() argument
3004 c = cmd_alloc(h); in hpsa_do_receive_diagnostic()
3005 if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, in hpsa_do_receive_diagnostic()
3010 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_do_receive_diagnostic()
3016 hpsa_scsi_interpret_error(h, c); in hpsa_do_receive_diagnostic()
3020 cmd_free(h, c); in hpsa_do_receive_diagnostic()
3024 static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, in hpsa_get_enclosure_logical_identifier() argument
3035 rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, in hpsa_get_enclosure_logical_identifier()
3048 static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_scsi_do_inquiry() argument
3056 c = cmd_alloc(h); in hpsa_scsi_do_inquiry()
3058 if (fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, in hpsa_scsi_do_inquiry()
3063 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_inquiry()
3069 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_inquiry()
3073 cmd_free(h, c); in hpsa_scsi_do_inquiry()
3077 static int hpsa_send_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_send_reset() argument
3084 c = cmd_alloc(h); in hpsa_send_reset()
3088 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3089 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_reset()
3091 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3098 hpsa_scsi_interpret_error(h, c); in hpsa_send_reset()
3102 cmd_free(h, c); in hpsa_send_reset()
3106 static bool hpsa_cmd_dev_match(struct ctlr_info *h, struct CommandList *c, in hpsa_cmd_dev_match() argument
3112 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3157 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3165 static int hpsa_do_reset(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev, in hpsa_do_reset() argument
3171 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3172 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3176 rc = hpsa_send_reset(h, dev, reset_type, reply_queue); in hpsa_do_reset()
3180 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3182 lockup_detected(h)); in hpsa_do_reset()
3185 if (unlikely(lockup_detected(h))) { in hpsa_do_reset()
3186 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3192 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3194 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3198 static void hpsa_get_raid_level(struct ctlr_info *h, in hpsa_get_raid_level() argument
3209 if (!hpsa_vpd_page_supported(h, scsi3addr, in hpsa_get_raid_level()
3213 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_raid_level()
3227 static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, in hpsa_debug_map_buff() argument
3238 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3241 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3270 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3274 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3277 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3281 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3282 " D%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3288 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3289 " M%02u: h=0x%04x xor=%u,%u\n", in hpsa_debug_map_buff()
3296 static void hpsa_debug_map_buff(__attribute__((unused)) struct ctlr_info *h, in hpsa_debug_map_buff() argument
3303 static int hpsa_get_raid_map(struct ctlr_info *h, in hpsa_get_raid_map() argument
3310 c = cmd_alloc(h); in hpsa_get_raid_map()
3312 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3315 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3316 cmd_free(h, c); in hpsa_get_raid_map()
3319 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_raid_map()
3325 hpsa_scsi_interpret_error(h, c); in hpsa_get_raid_map()
3329 cmd_free(h, c); in hpsa_get_raid_map()
3334 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3337 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3340 cmd_free(h, c); in hpsa_get_raid_map()
3344 static int hpsa_bmic_sense_subsystem_information(struct ctlr_info *h, in hpsa_bmic_sense_subsystem_information() argument
3352 c = cmd_alloc(h); in hpsa_bmic_sense_subsystem_information()
3354 rc = fill_cmd(c, BMIC_SENSE_SUBSYSTEM_INFORMATION, h, buf, bufsize, in hpsa_bmic_sense_subsystem_information()
3362 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_sense_subsystem_information()
3368 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_sense_subsystem_information()
3372 cmd_free(h, c); in hpsa_bmic_sense_subsystem_information()
3376 static int hpsa_bmic_id_controller(struct ctlr_info *h, in hpsa_bmic_id_controller() argument
3383 c = cmd_alloc(h); in hpsa_bmic_id_controller()
3385 rc = fill_cmd(c, BMIC_IDENTIFY_CONTROLLER, h, buf, bufsize, in hpsa_bmic_id_controller()
3390 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_controller()
3396 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_controller()
3400 cmd_free(h, c); in hpsa_bmic_id_controller()
3404 static int hpsa_bmic_id_physical_device(struct ctlr_info *h, in hpsa_bmic_id_physical_device() argument
3412 c = cmd_alloc(h); in hpsa_bmic_id_physical_device()
3413 rc = fill_cmd(c, BMIC_IDENTIFY_PHYSICAL_DEVICE, h, buf, bufsize, in hpsa_bmic_id_physical_device()
3421 hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_bmic_id_physical_device()
3425 hpsa_scsi_interpret_error(h, c); in hpsa_bmic_id_physical_device()
3429 cmd_free(h, c); in hpsa_bmic_id_physical_device()
3440 static void hpsa_get_enclosure_info(struct ctlr_info *h, in hpsa_get_enclosure_info() argument
3459 hpsa_get_enclosure_logical_identifier(h, scsi3addr); in hpsa_get_enclosure_info()
3481 rc = hpsa_bmic_id_physical_device(h, scsi3addr, bmic_device_index, in hpsa_get_enclosure_info()
3484 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3489 c = cmd_alloc(h); in hpsa_get_enclosure_info()
3491 rc = fill_cmd(c, BMIC_SENSE_STORAGE_BOX_PARAMS, h, bssbp, in hpsa_get_enclosure_info()
3502 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_get_enclosure_info()
3523 cmd_free(h, c); in hpsa_get_enclosure_info()
3526 hpsa_show_dev_msg(KERN_INFO, h, encl_dev, in hpsa_get_enclosure_info()
3530 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h, in hpsa_get_sas_address_from_report_physical() argument
3542 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_get_sas_address_from_report_physical()
3543 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3560 static void hpsa_get_sas_address(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_sas_address() argument
3573 rc = hpsa_bmic_sense_subsystem_information(h, in hpsa_get_sas_address()
3577 h->sas_address = sa; in hpsa_get_sas_address()
3582 sa = hpsa_get_sas_address_from_report_physical(h, scsi3addr); in hpsa_get_sas_address()
3587 static void hpsa_ext_ctrl_present(struct ctlr_info *h, in hpsa_ext_ctrl_present() argument
3593 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3602 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3604 hpsa_disable_rld_caching(h); in hpsa_ext_ctrl_present()
3605 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3612 static bool hpsa_vpd_page_supported(struct ctlr_info *h, in hpsa_vpd_page_supported() argument
3625 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3637 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_vpd_page_supported()
3662 static void hpsa_get_ioaccel_status(struct ctlr_info *h, in hpsa_get_ioaccel_status() argument
3676 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS)) in hpsa_get_ioaccel_status()
3678 rc = hpsa_scsi_do_inquiry(h, scsi3addr, in hpsa_get_ioaccel_status()
3696 rc = hpsa_get_raid_map(h, scsi3addr, this_device); in hpsa_get_ioaccel_status()
3709 static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, in hpsa_get_device_id() argument
3716 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_DEVICE_ID)) in hpsa_get_device_id()
3723 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | in hpsa_get_device_id()
3736 static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, in hpsa_scsi_do_report_luns() argument
3745 c = cmd_alloc(h); in hpsa_scsi_do_report_luns()
3749 if (fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h, in hpsa_scsi_do_report_luns()
3756 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_scsi_do_report_luns()
3763 hpsa_scsi_interpret_error(h, c); in hpsa_scsi_do_report_luns()
3769 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3770 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3780 cmd_free(h, c); in hpsa_scsi_do_report_luns()
3784 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h, in hpsa_scsi_do_report_phys_luns() argument
3790 rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize, in hpsa_scsi_do_report_phys_luns()
3800 rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0); in hpsa_scsi_do_report_phys_luns()
3815 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h, in hpsa_scsi_do_report_log_luns() argument
3818 return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0); in hpsa_scsi_do_report_log_luns()
3830 static int hpsa_get_volume_status(struct ctlr_info *h, in hpsa_get_volume_status() argument
3843 if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_STATUS)) in hpsa_get_volume_status()
3847 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3854 rc = hpsa_scsi_do_inquiry(h, scsi3addr, VPD_PAGE | HPSA_VPD_LV_STATUS, in hpsa_get_volume_status()
3874 static unsigned char hpsa_volume_offline(struct ctlr_info *h, in hpsa_volume_offline() argument
3886 c = cmd_alloc(h); in hpsa_volume_offline()
3888 (void) fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, scsi3addr, TYPE_CMD); in hpsa_volume_offline()
3889 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_volume_offline()
3892 cmd_free(h, c); in hpsa_volume_offline()
3901 cmd_free(h, c); in hpsa_volume_offline()
3904 ldstat = hpsa_get_volume_status(h, scsi3addr); in hpsa_volume_offline()
3933 static int hpsa_update_device_info(struct ctlr_info *h, in hpsa_update_device_info() argument
3954 if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, in hpsa_update_device_info()
3956 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3975 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3977 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3979 h->ctlr, __func__, in hpsa_update_device_info()
3980 h->scsi_host->host_no, in hpsa_update_device_info()
3994 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
3995 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
3996 hpsa_get_ioaccel_status(h, scsi3addr, this_device); in hpsa_update_device_info()
3997 volume_offline = hpsa_volume_offline(h, scsi3addr); in hpsa_update_device_info()
3999 h->legacy_board) { in hpsa_update_device_info()
4003 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4011 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4022 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4051 static void figure_bus_target_lun(struct ctlr_info *h, in figure_bus_target_lun() argument
4082 static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, in figure_external_status() argument
4109 static int hpsa_gather_lun_info(struct ctlr_info *h, in hpsa_gather_lun_info() argument
4113 if (hpsa_scsi_do_report_phys_luns(h, physdev, sizeof(*physdev))) { in hpsa_gather_lun_info()
4114 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4119 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4123 if (hpsa_scsi_do_report_log_luns(h, logdev, sizeof(*logdev))) { in hpsa_gather_lun_info()
4124 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4130 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4137 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4146 static u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, in figure_lunaddrbytes() argument
4174 static void hpsa_get_ioaccel_drive_info(struct ctlr_info *h, in hpsa_get_ioaccel_drive_info() argument
4191 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4237 static int hpsa_set_local_logical_count(struct ctlr_info *h, in hpsa_set_local_logical_count() argument
4244 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4249 rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr)); in hpsa_set_local_logical_count()
4261 static bool hpsa_is_disk_spare(struct ctlr_info *h, u8 *lunaddrbytes) in hpsa_is_disk_spare() argument
4271 rc = hpsa_bmic_id_physical_device(h, in hpsa_is_disk_spare()
4288 static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes, in hpsa_skip_device() argument
4320 if (hpsa_is_disk_spare(h, lunaddrbytes)) in hpsa_skip_device()
4326 static void hpsa_update_scsi_devices(struct ctlr_info *h) in hpsa_update_scsi_devices() argument
4361 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4365 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4367 if (hpsa_gather_lun_info(h, physdev_list, &nphysicals, in hpsa_update_scsi_devices()
4369 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4374 if (hpsa_set_local_logical_count(h, id_ctlr, &nlocal_logicals)) { in hpsa_update_scsi_devices()
4375 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4386 hpsa_ext_ctrl_present(h, physdev_list); in hpsa_update_scsi_devices()
4391 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4399 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4405 if (is_scsi_rev_5(h)) in hpsa_update_scsi_devices()
4422 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, in hpsa_update_scsi_devices()
4427 figure_external_status(h, raid_ctlr_position, i, in hpsa_update_scsi_devices()
4435 skip_device = hpsa_skip_device(h, lunaddrbytes, in hpsa_update_scsi_devices()
4442 rc = hpsa_update_device_info(h, lunaddrbytes, tmpdevice, in hpsa_update_scsi_devices()
4445 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4447 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4451 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4455 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); in hpsa_update_scsi_devices()
4475 hpsa_get_sas_address(h, lunaddrbytes, this_device); in hpsa_update_scsi_devices()
4495 hpsa_get_ioaccel_drive_info(h, this_device, in hpsa_update_scsi_devices()
4508 hpsa_get_enclosure_info(h, lunaddrbytes, in hpsa_update_scsi_devices()
4530 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4533 rc = hpsa_add_sas_host(h); in hpsa_update_scsi_devices()
4535 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4541 adjust_hpsa_scsi_table(h, currentsd, ncurrent); in hpsa_update_scsi_devices()
4569 static int hpsa_scatter_gather(struct ctlr_info *h, in hpsa_scatter_gather() argument
4577 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4594 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4595 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4608 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4619 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4620 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4623 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4625 if (hpsa_map_sg_chain_block(h, cp)) { in hpsa_scatter_gather()
4639 static inline void warn_zero_length_transfer(struct ctlr_info *h, in warn_zero_length_transfer() argument
4643 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4725 static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel1_queue_command() argument
4730 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4740 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4748 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel1_queue_command()
4761 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4795 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4814 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel1_queue_command()
4822 static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_direct_map() argument
4836 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4843 static void set_encrypt_ioaccel2(struct ctlr_info *h, in set_encrypt_ioaccel2() argument
4884 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4899 static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel2_queue_command() argument
4904 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4918 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4921 warn_zero_length_transfer(h, cdb, cdb_len, __func__); in hpsa_scsi_ioaccel2_queue_command()
4933 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4948 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4950 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4958 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4992 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5003 set_encrypt_ioaccel2(h, c, cp); in hpsa_scsi_ioaccel2_queue_command()
5015 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5018 if (hpsa_map_ioaccel2_sg_chain_block(h, cp, c)) { in hpsa_scsi_ioaccel2_queue_command()
5031 enqueue_cmd_and_start_io(h, c); in hpsa_scsi_ioaccel2_queue_command()
5038 static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, in hpsa_scsi_ioaccel_queue_command() argument
5057 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5058 return hpsa_scsi_ioaccel1_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5062 return hpsa_scsi_ioaccel2_queue_command(h, c, ioaccel_handle, in hpsa_scsi_ioaccel_queue_command()
5096 static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, in hpsa_scsi_ioaccel_raid_map() argument
5440 return hpsa_scsi_ioaccel_queue_command(h, c, disk_handle, cdb, cdb_len, in hpsa_scsi_ioaccel_raid_map()
5450 static int hpsa_ciss_submit(struct ctlr_info *h, in hpsa_ciss_submit() argument
5499 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5505 if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ in hpsa_ciss_submit()
5506 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5511 hpsa_cmd_resolve_and_free(h, c); in hpsa_ciss_submit()
5517 enqueue_cmd_and_start_io(h, c); in hpsa_ciss_submit()
5522 static void hpsa_cmd_init(struct ctlr_info *h, int index, in hpsa_cmd_init() argument
5530 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5531 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5533 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5539 c->h = h; in hpsa_cmd_init()
5543 static void hpsa_preinitialize_commands(struct ctlr_info *h) in hpsa_preinitialize_commands() argument
5547 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5548 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5550 hpsa_cmd_init(h, i, c); in hpsa_preinitialize_commands()
5555 static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index, in hpsa_cmd_partial_init() argument
5558 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5567 static int hpsa_ioaccel_submit(struct ctlr_info *h, in hpsa_ioaccel_submit() argument
5586 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5592 rc = hpsa_scsi_ioaccel_raid_map(h, c); in hpsa_ioaccel_submit()
5596 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5602 rc = hpsa_scsi_ioaccel_direct_map(h, c); in hpsa_ioaccel_submit()
5619 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5624 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5628 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker() local
5629 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5635 rc = hpsa_ioaccel_submit(h, c, cmd, true); in hpsa_command_resubmit_worker()
5645 return hpsa_cmd_free_and_done(h, c, cmd); in hpsa_command_resubmit_worker()
5650 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5660 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5677 struct ctlr_info *h; in hpsa_scsi_queue_command() local
5683 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5700 if (unlikely(lockup_detected(h))) { in hpsa_scsi_queue_command()
5709 c = cmd_tagged_alloc(h, cmd); in hpsa_scsi_queue_command()
5729 h->acciopath_status)) { in hpsa_scsi_queue_command()
5731 rc = hpsa_ioaccel_submit(h, c, cmd, false); in hpsa_scsi_queue_command()
5735 hpsa_cmd_resolve_and_free(h, c); in hpsa_scsi_queue_command()
5739 return hpsa_ciss_submit(h, c, cmd, dev); in hpsa_scsi_queue_command()
5742 static void hpsa_scan_complete(struct ctlr_info *h) in hpsa_scan_complete() argument
5746 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5747 h->scan_finished = 1; in hpsa_scan_complete()
5748 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5749 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5754 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_start() local
5763 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5764 return hpsa_scan_complete(h); in hpsa_scan_start()
5769 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5770 if (h->scan_waiting) { in hpsa_scan_start()
5771 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5775 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5779 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5780 if (h->scan_finished) in hpsa_scan_start()
5782 h->scan_waiting = 1; in hpsa_scan_start()
5783 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5784 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5791 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5792 h->scan_waiting = 0; in hpsa_scan_start()
5793 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5795 if (unlikely(lockup_detected(h))) in hpsa_scan_start()
5796 return hpsa_scan_complete(h); in hpsa_scan_start()
5801 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5802 if (h->reset_in_progress) { in hpsa_scan_start()
5803 h->drv_req_rescan = 1; in hpsa_scan_start()
5804 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5805 hpsa_scan_complete(h); in hpsa_scan_start()
5808 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5810 hpsa_update_scsi_devices(h); in hpsa_scan_start()
5812 hpsa_scan_complete(h); in hpsa_scan_start()
5833 struct ctlr_info *h = shost_to_hba(sh); in hpsa_scan_finished() local
5837 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5838 finished = h->scan_finished; in hpsa_scan_finished()
5839 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5843 static int hpsa_scsi_host_alloc(struct ctlr_info *h) in hpsa_scsi_host_alloc() argument
5849 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5860 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5862 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5864 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5865 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5868 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5872 static int hpsa_scsi_add_host(struct ctlr_info *h) in hpsa_scsi_add_host() argument
5876 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5878 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5881 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5906 static int hpsa_send_test_unit_ready(struct ctlr_info *h, in hpsa_send_test_unit_ready() argument
5913 (void) fill_cmd(c, TEST_UNIT_READY, h, in hpsa_send_test_unit_ready()
5915 rc = hpsa_scsi_do_simple_cmd(h, c, reply_queue, NO_TIMEOUT); in hpsa_send_test_unit_ready()
5942 static int hpsa_wait_for_test_unit_ready(struct ctlr_info *h, in hpsa_wait_for_test_unit_ready() argument
5959 rc = hpsa_send_test_unit_ready(h, c, lunaddr, reply_queue); in hpsa_wait_for_test_unit_ready()
5967 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5975 static int wait_for_device_to_become_ready(struct ctlr_info *h, in wait_for_device_to_become_ready() argument
5985 c = cmd_alloc(h); in wait_for_device_to_become_ready()
5994 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6001 rc = hpsa_wait_for_test_unit_ready(h, c, lunaddr, rq); in wait_for_device_to_become_ready()
6007 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6009 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6011 cmd_free(h, c); in wait_for_device_to_become_ready()
6022 struct ctlr_info *h; in hpsa_eh_device_reset_handler() local
6029 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6030 if (h == NULL) /* paranoia */ in hpsa_eh_device_reset_handler()
6033 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6034 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6035 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6037 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6044 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6055 if (lockup_detected(h)) { in hpsa_eh_device_reset_handler()
6059 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6065 if (detect_controller_lockup(h)) { in hpsa_eh_device_reset_handler()
6069 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6087 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6101 rc = hpsa_do_reset(h, dev, reset_type, DEFAULT_REPLY_QUEUE); in hpsa_eh_device_reset_handler()
6110 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); in hpsa_eh_device_reset_handler()
6113 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6114 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6117 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6128 static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h, in cmd_tagged_alloc() argument
6132 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6134 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6135 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6136 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6150 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6151 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6155 h->last_collision_tag = idx; in cmd_tagged_alloc()
6161 hpsa_cmd_partial_init(h, idx, c); in cmd_tagged_alloc()
6172 static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c) in cmd_tagged_free() argument
6190 static struct CommandList *cmd_alloc(struct ctlr_info *h) in cmd_alloc() argument
6216 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6223 c = h->cmd_pool + i; in cmd_alloc()
6226 cmd_free(h, c); /* already in use */ in cmd_alloc()
6230 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6233 hpsa_cmd_partial_init(h, i, c); in cmd_alloc()
6251 static void cmd_free(struct ctlr_info *h, struct CommandList *c) in cmd_free() argument
6256 i = c - h->cmd_pool; in cmd_free()
6257 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6266 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_passthru() local
6282 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6284 err = hpsa_passthru_ioctl(h, &arg64); in hpsa_ioctl32_passthru()
6285 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6297 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl32_big_passthru() local
6313 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6315 err = hpsa_big_passthru_ioctl(h, &arg64); in hpsa_ioctl32_big_passthru()
6316 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6357 static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getpciinfo_ioctl() argument
6363 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6364 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6365 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6366 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6372 static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp) in hpsa_getdrivver_ioctl() argument
6381 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6395 static int hpsa_passthru_ioctl(struct ctlr_info *h, in hpsa_passthru_ioctl() argument
6424 c = cmd_alloc(h); in hpsa_passthru_ioctl()
6446 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6448 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6458 rc = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_passthru_ioctl()
6461 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6462 check_ioctl_unit_attention(h, c); in hpsa_passthru_ioctl()
6480 cmd_free(h, c); in hpsa_passthru_ioctl()
6486 static int hpsa_big_passthru_ioctl(struct ctlr_info *h, in hpsa_big_passthru_ioctl() argument
6541 c = cmd_alloc(h); in hpsa_big_passthru_ioctl()
6553 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6555 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6559 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6570 status = hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE, in hpsa_big_passthru_ioctl()
6573 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6574 check_ioctl_unit_attention(h, c); in hpsa_big_passthru_ioctl()
6597 cmd_free(h, c); in hpsa_big_passthru_ioctl()
6610 static void check_ioctl_unit_attention(struct ctlr_info *h, in check_ioctl_unit_attention() argument
6615 (void) check_for_unit_attention(h, c); in check_ioctl_unit_attention()
6624 struct ctlr_info *h = sdev_to_hba(dev); in hpsa_ioctl() local
6631 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6634 return hpsa_getpciinfo_ioctl(h, argp); in hpsa_ioctl()
6636 return hpsa_getdrivver_ioctl(h, argp); in hpsa_ioctl()
6644 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6646 rc = hpsa_passthru_ioctl(h, &iocommand); in hpsa_ioctl()
6647 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6658 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6660 rc = hpsa_big_passthru_ioctl(h, &ioc); in hpsa_ioctl()
6661 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6671 static void hpsa_send_host_reset(struct ctlr_info *h, u8 reset_type) in hpsa_send_host_reset() argument
6675 c = cmd_alloc(h); in hpsa_send_host_reset()
6678 (void) fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, in hpsa_send_host_reset()
6682 enqueue_cmd_and_start_io(h, c); in hpsa_send_host_reset()
6690 static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, in fill_cmd() argument
6853 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6889 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6894 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6911 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6929 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q) in get_next_completion() argument
6931 return h->access.command_completed(h, q); in get_next_completion()
6934 static inline bool interrupt_pending(struct ctlr_info *h) in interrupt_pending() argument
6936 return h->access.intr_pending(h); in interrupt_pending()
6939 static inline long interrupt_not_for_us(struct ctlr_info *h) in interrupt_not_for_us() argument
6941 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6942 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6945 static inline int bad_tag(struct ctlr_info *h, u32 tag_index, in bad_tag() argument
6948 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6949 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6957 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6966 static inline void process_indexed_cmd(struct ctlr_info *h, in process_indexed_cmd() argument
6973 if (!bad_tag(h, tag_index, raw_tag)) { in process_indexed_cmd()
6974 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6984 static int ignore_bogus_interrupt(struct ctlr_info *h) in ignore_bogus_interrupt() argument
6989 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6992 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
6999 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7000 * Relies on (h-q[x] == x) being true for x such that
7010 struct ctlr_info *h = queue_to_hba(queue); in hpsa_intx_discard_completions() local
7014 if (ignore_bogus_interrupt(h)) in hpsa_intx_discard_completions()
7017 if (interrupt_not_for_us(h)) in hpsa_intx_discard_completions()
7019 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7020 while (interrupt_pending(h)) { in hpsa_intx_discard_completions()
7021 raw_tag = get_next_completion(h, q); in hpsa_intx_discard_completions()
7023 raw_tag = next_command(h, q); in hpsa_intx_discard_completions()
7030 struct ctlr_info *h = queue_to_hba(queue); in hpsa_msix_discard_completions() local
7034 if (ignore_bogus_interrupt(h)) in hpsa_msix_discard_completions()
7037 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7038 raw_tag = get_next_completion(h, q); in hpsa_msix_discard_completions()
7040 raw_tag = next_command(h, q); in hpsa_msix_discard_completions()
7046 struct ctlr_info *h = queue_to_hba((u8 *) queue); in do_hpsa_intr_intx() local
7050 if (interrupt_not_for_us(h)) in do_hpsa_intr_intx()
7052 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7053 while (interrupt_pending(h)) { in do_hpsa_intr_intx()
7054 raw_tag = get_next_completion(h, q); in do_hpsa_intr_intx()
7056 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_intx()
7057 raw_tag = next_command(h, q); in do_hpsa_intr_intx()
7065 struct ctlr_info *h = queue_to_hba(queue); in do_hpsa_intr_msi() local
7069 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7070 raw_tag = get_next_completion(h, q); in do_hpsa_intr_msi()
7072 process_indexed_cmd(h, raw_tag); in do_hpsa_intr_msi()
7073 raw_tag = next_command(h, q); in do_hpsa_intr_msi()
7200 * CSR=00h. The software off state is D3, CSR=03h. To reset in hpsa_controller_hard_reset()
7474 static void hpsa_disable_interrupt_mode(struct ctlr_info *h) in hpsa_disable_interrupt_mode() argument
7476 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7477 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7480 static void hpsa_setup_reply_map(struct ctlr_info *h) in hpsa_setup_reply_map() argument
7485 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7486 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7491 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7497 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7503 static int hpsa_interrupt_mode(struct ctlr_info *h) in hpsa_interrupt_mode() argument
7509 switch (h->board_id) { in hpsa_interrupt_mode()
7516 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7519 h->msix_vectors = ret; in hpsa_interrupt_mode()
7527 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7622 static void hpsa_free_cfgtables(struct ctlr_info *h) in hpsa_free_cfgtables() argument
7624 if (h->transtable) { in hpsa_free_cfgtables()
7625 iounmap(h->transtable); in hpsa_free_cfgtables()
7626 h->transtable = NULL; in hpsa_free_cfgtables()
7628 if (h->cfgtable) { in hpsa_free_cfgtables()
7629 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7630 h->cfgtable = NULL; in hpsa_free_cfgtables()
7637 static int hpsa_find_cfgtables(struct ctlr_info *h) in hpsa_find_cfgtables() argument
7645 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7649 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7650 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7651 if (!h->cfgtable) { in hpsa_find_cfgtables()
7652 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7655 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7659 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7660 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7662 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7663 if (!h->transtable) { in hpsa_find_cfgtables()
7664 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7665 hpsa_free_cfgtables(h); in hpsa_find_cfgtables()
7671 static void hpsa_get_max_perf_mode_cmds(struct ctlr_info *h) in hpsa_get_max_perf_mode_cmds() argument
7676 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7679 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7680 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7682 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7683 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7685 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7687 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7695 static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h) in hpsa_supports_chained_sg_blocks() argument
7697 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7704 static void hpsa_find_board_params(struct ctlr_info *h) in hpsa_find_board_params() argument
7706 hpsa_get_max_perf_mode_cmds(h); in hpsa_find_board_params()
7707 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7708 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7709 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7710 if (hpsa_supports_chained_sg_blocks(h)) { in hpsa_find_board_params()
7712 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7713 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7714 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7721 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7722 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7723 h->chainsize = 0; in hpsa_find_board_params()
7727 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7728 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7729 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7730 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7731 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7732 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7733 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7736 static inline bool hpsa_CISS_signature_present(struct ctlr_info *h) in hpsa_CISS_signature_present() argument
7738 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7739 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7745 static inline void hpsa_set_driver_support_bits(struct ctlr_info *h) in hpsa_set_driver_support_bits() argument
7749 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7755 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7761 static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h) in hpsa_p600_dma_prefetch_quirk() argument
7765 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7767 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7769 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7772 static int hpsa_wait_for_clear_event_notify_ack(struct ctlr_info *h) in hpsa_wait_for_clear_event_notify_ack() argument
7779 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7780 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7781 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7792 static int hpsa_wait_for_mode_change_ack(struct ctlr_info *h) in hpsa_wait_for_mode_change_ack() argument
7803 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7805 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7806 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7807 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7819 static int hpsa_enter_simple_mode(struct ctlr_info *h) in hpsa_enter_simple_mode() argument
7823 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7827 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7830 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7831 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7832 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7833 if (hpsa_wait_for_mode_change_ack(h)) in hpsa_enter_simple_mode()
7835 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7836 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7838 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7841 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7846 static void hpsa_free_pci_init(struct ctlr_info *h) in hpsa_free_pci_init() argument
7848 hpsa_free_cfgtables(h); /* pci_init 4 */ in hpsa_free_pci_init()
7849 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7850 h->vaddr = NULL; in hpsa_free_pci_init()
7851 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in hpsa_free_pci_init()
7856 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7857 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7861 static int hpsa_pci_init(struct ctlr_info *h) in hpsa_pci_init() argument
7866 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7869 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7870 h->access = *(products[prod_index].access); in hpsa_pci_init()
7871 h->legacy_board = legacy_board; in hpsa_pci_init()
7872 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7875 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7877 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7878 pci_disable_device(h->pdev); in hpsa_pci_init()
7882 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, in hpsa_pci_init()
7886 pci_disable_device(h->pdev); in hpsa_pci_init()
7890 pci_set_master(h->pdev); in hpsa_pci_init()
7892 err = hpsa_interrupt_mode(h); in hpsa_pci_init()
7897 hpsa_setup_reply_map(h); in hpsa_pci_init()
7899 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7902 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7903 if (!h->vaddr) { in hpsa_pci_init()
7904 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7908 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7911 err = hpsa_find_cfgtables(h); in hpsa_pci_init()
7914 hpsa_find_board_params(h); in hpsa_pci_init()
7916 if (!hpsa_CISS_signature_present(h)) { in hpsa_pci_init()
7920 hpsa_set_driver_support_bits(h); in hpsa_pci_init()
7921 hpsa_p600_dma_prefetch_quirk(h); in hpsa_pci_init()
7922 err = hpsa_enter_simple_mode(h); in hpsa_pci_init()
7928 hpsa_free_cfgtables(h); in hpsa_pci_init()
7930 iounmap(h->vaddr); in hpsa_pci_init()
7931 h->vaddr = NULL; in hpsa_pci_init()
7933 hpsa_disable_interrupt_mode(h); in hpsa_pci_init()
7939 pci_disable_device(h->pdev); in hpsa_pci_init()
7940 pci_release_regions(h->pdev); in hpsa_pci_init()
7944 static void hpsa_hba_inquiry(struct ctlr_info *h) in hpsa_hba_inquiry() argument
7949 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7950 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7952 rc = hpsa_scsi_do_inquiry(h, RAID_CTLR_LUNID, 0, in hpsa_hba_inquiry()
7953 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7955 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7956 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
8022 static void hpsa_free_cmd_pool(struct ctlr_info *h) in hpsa_free_cmd_pool() argument
8024 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8025 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8026 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8027 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8028 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8029 h->cmd_pool, in hpsa_free_cmd_pool()
8030 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8031 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8032 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8034 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8035 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8036 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8037 h->errinfo_pool, in hpsa_free_cmd_pool()
8038 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8039 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8040 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8044 static int hpsa_alloc_cmd_pool(struct ctlr_info *h) in hpsa_alloc_cmd_pool() argument
8046 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8047 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8048 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8049 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8050 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8051 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8052 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8053 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8054 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8055 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8056 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8059 hpsa_preinitialize_commands(h); in hpsa_alloc_cmd_pool()
8062 hpsa_free_cmd_pool(h); in hpsa_alloc_cmd_pool()
8067 static void hpsa_free_irqs(struct ctlr_info *h) in hpsa_free_irqs() argument
8073 irq_vector = h->intr_mode; in hpsa_free_irqs()
8075 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8077 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8078 &h->q[h->intr_mode]); in hpsa_free_irqs()
8079 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8083 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8084 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8085 h->q[i] = 0; in hpsa_free_irqs()
8088 h->q[i] = 0; in hpsa_free_irqs()
8092 static int hpsa_request_irqs(struct ctlr_info *h, in hpsa_request_irqs() argument
8100 irq_vector = h->intr_mode; in hpsa_request_irqs()
8103 * initialize h->q[x] = x so that interrupt handlers know which in hpsa_request_irqs()
8107 h->q[i] = (u8) i; in hpsa_request_irqs()
8109 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8111 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8112 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8113 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8114 0, h->intrname[i], in hpsa_request_irqs()
8115 &h->q[i]); in hpsa_request_irqs()
8119 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8121 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8123 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8124 h->q[j] = 0; in hpsa_request_irqs()
8127 h->q[j] = 0; in hpsa_request_irqs()
8133 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8134 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8135 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8136 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8138 h->intrname[0], in hpsa_request_irqs()
8139 &h->q[h->intr_mode]); in hpsa_request_irqs()
8141 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8142 "%s-intx", h->devname); in hpsa_request_irqs()
8143 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8145 h->intrname[0], in hpsa_request_irqs()
8146 &h->q[h->intr_mode]); in hpsa_request_irqs()
8150 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8151 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8152 hpsa_free_irqs(h); in hpsa_request_irqs()
8158 static int hpsa_kdump_soft_reset(struct ctlr_info *h) in hpsa_kdump_soft_reset() argument
8161 hpsa_send_host_reset(h, HPSA_RESET_TYPE_CONTROLLER); in hpsa_kdump_soft_reset()
8163 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8164 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8166 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8170 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8171 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8173 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8181 static void hpsa_free_reply_queues(struct ctlr_info *h) in hpsa_free_reply_queues() argument
8185 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8186 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8188 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8189 h->reply_queue_size, in hpsa_free_reply_queues()
8190 h->reply_queue[i].head, in hpsa_free_reply_queues()
8191 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8192 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8193 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8195 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8198 static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h) in hpsa_undo_allocations_after_kdump_soft_reset() argument
8200 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8201 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8202 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8203 hpsa_free_irqs(h); /* init_one 4 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8204 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8205 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8206 hpsa_free_pci_init(h); /* init_one 2_5 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8207 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8208 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8209 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8210 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8211 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8213 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8214 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8215 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8217 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8218 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8219 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8222 kfree(h); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8226 static void fail_all_outstanding_cmds(struct ctlr_info *h) in fail_all_outstanding_cmds() argument
8232 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8233 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8234 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8239 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8242 cmd_free(h, c); in fail_all_outstanding_cmds()
8244 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8248 static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) in set_lockup_detected_for_all_cpus() argument
8254 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8260 static void controller_lockup_detected(struct ctlr_info *h) in controller_lockup_detected() argument
8265 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8266 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8267 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8270 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8272 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8275 set_lockup_detected_for_all_cpus(h, lockup_detected); in controller_lockup_detected()
8276 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8277 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8278 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8280 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8281 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8283 pci_disable_device(h->pdev); in controller_lockup_detected()
8284 fail_all_outstanding_cmds(h); in controller_lockup_detected()
8287 static int detect_controller_lockup(struct ctlr_info *h) in detect_controller_lockup() argument
8295 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8296 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8304 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8305 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8309 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8310 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8311 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8312 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8313 controller_lockup_detected(h); in detect_controller_lockup()
8318 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8319 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8332 static void hpsa_set_ioaccel_status(struct ctlr_info *h) in hpsa_set_ioaccel_status() argument
8340 if (!h) in hpsa_set_ioaccel_status()
8350 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8354 device = h->dev[i]; in hpsa_set_ioaccel_status()
8358 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8364 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8405 static void hpsa_ack_ctlr_events(struct ctlr_info *h) in hpsa_ack_ctlr_events() argument
8409 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8413 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8415 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8416 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8418 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8420 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8423 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8424 hpsa_set_ioaccel_status(h); in hpsa_ack_ctlr_events()
8425 hpsa_drain_accel_commands(h); in hpsa_ack_ctlr_events()
8427 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8429 h->events, event_type); in hpsa_ack_ctlr_events()
8430 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8432 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8434 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8435 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8438 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8439 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8440 hpsa_wait_for_clear_event_notify_ack(h); in hpsa_ack_ctlr_events()
8450 static int hpsa_ctlr_needs_rescan(struct ctlr_info *h) in hpsa_ctlr_needs_rescan() argument
8452 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8453 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8457 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8460 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8461 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8467 static int hpsa_offline_devices_ready(struct ctlr_info *h) in hpsa_offline_devices_ready() argument
8473 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8474 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8477 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8478 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8479 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8481 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8484 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8486 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8490 static int hpsa_luns_changed(struct ctlr_info *h) in hpsa_luns_changed() argument
8499 if (!h->lastlogicals) in hpsa_luns_changed()
8506 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) { in hpsa_luns_changed()
8507 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8511 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8512 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8514 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8523 static void hpsa_perform_rescan(struct ctlr_info *h) in hpsa_perform_rescan() argument
8531 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8532 if (h->reset_in_progress) { in hpsa_perform_rescan()
8533 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8534 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8537 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8539 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8543 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8552 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_event_monitor_worker() local
8556 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8557 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8558 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8561 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8563 if (hpsa_ctlr_needs_rescan(h)) { in hpsa_event_monitor_worker()
8564 hpsa_ack_ctlr_events(h); in hpsa_event_monitor_worker()
8565 hpsa_perform_rescan(h); in hpsa_event_monitor_worker()
8568 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8569 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8570 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8572 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8578 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_rescan_ctlr_worker() local
8581 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8582 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8583 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8586 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8588 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8589 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8590 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8591 if (hpsa_luns_changed(h)) { in hpsa_rescan_ctlr_worker()
8592 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8594 hpsa_perform_rescan(h); in hpsa_rescan_ctlr_worker()
8597 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8598 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8599 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8600 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8601 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8607 struct ctlr_info *h = container_of(to_delayed_work(work), in hpsa_monitor_ctlr_worker() local
8610 detect_controller_lockup(h); in hpsa_monitor_ctlr_worker()
8611 if (lockup_detected(h)) in hpsa_monitor_ctlr_worker()
8614 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8615 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8616 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8617 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8618 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8621 static struct workqueue_struct *hpsa_create_controller_wq(struct ctlr_info *h, in hpsa_create_controller_wq() argument
8626 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8628 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8633 static void hpda_free_ctlr_info(struct ctlr_info *h) in hpda_free_ctlr_info() argument
8635 kfree(h->reply_map); in hpda_free_ctlr_info()
8636 kfree(h); in hpda_free_ctlr_info()
8641 struct ctlr_info *h; in hpda_alloc_ctlr_info() local
8643 h = kzalloc(sizeof(*h), GFP_KERNEL); in hpda_alloc_ctlr_info()
8644 if (!h) in hpda_alloc_ctlr_info()
8647 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8648 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8649 kfree(h); in hpda_alloc_ctlr_info()
8652 return h; in hpda_alloc_ctlr_info()
8658 struct ctlr_info *h; in hpsa_init_one() local
8689 * the driver. See comments in hpsa.h for more info. in hpsa_init_one()
8692 h = hpda_alloc_ctlr_info(); in hpsa_init_one()
8693 if (!h) { in hpsa_init_one()
8698 h->pdev = pdev; in hpsa_init_one()
8700 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8701 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8702 spin_lock_init(&h->lock); in hpsa_init_one()
8703 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8704 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8705 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8706 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8709 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8710 if (!h->lockup_detected) { in hpsa_init_one()
8711 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8713 goto clean1; /* aer/h */ in hpsa_init_one()
8715 set_lockup_detected_for_all_cpus(h, 0); in hpsa_init_one()
8717 rc = hpsa_pci_init(h); in hpsa_init_one()
8719 goto clean2; /* lu, aer/h */ in hpsa_init_one()
8721 /* relies on h-> settings made by hpsa_pci_init, including in hpsa_init_one()
8722 * interrupt_mode h->intr */ in hpsa_init_one()
8723 rc = hpsa_scsi_host_alloc(h); in hpsa_init_one()
8725 goto clean2_5; /* pci, lu, aer/h */ in hpsa_init_one()
8727 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8728 h->ctlr = number_of_controllers; in hpsa_init_one()
8737 goto clean3; /* shost, pci, lu, aer/h */ in hpsa_init_one()
8742 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8744 rc = hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx); in hpsa_init_one()
8746 goto clean3; /* shost, pci, lu, aer/h */ in hpsa_init_one()
8747 rc = hpsa_alloc_cmd_pool(h); in hpsa_init_one()
8749 goto clean4; /* irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8750 rc = hpsa_alloc_sg_chain_blocks(h); in hpsa_init_one()
8752 goto clean5; /* cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8753 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8754 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8755 mutex_init(&h->reset_mutex); in hpsa_init_one()
8756 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8757 h->scan_waiting = 0; in hpsa_init_one()
8759 pci_set_drvdata(pdev, h); in hpsa_init_one()
8760 h->ndevices = 0; in hpsa_init_one()
8762 spin_lock_init(&h->devlock); in hpsa_init_one()
8763 rc = hpsa_put_ctlr_into_performant_mode(h); in hpsa_init_one()
8765 goto clean6; /* sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8768 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8769 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8774 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8775 if (!h->resubmit_wq) { in hpsa_init_one()
8777 goto clean7; /* aer/h */ in hpsa_init_one()
8780 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8781 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8800 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8801 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8802 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8803 hpsa_free_irqs(h); in hpsa_init_one()
8804 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions, in hpsa_init_one()
8807 dev_warn(&h->pdev->dev, in hpsa_init_one()
8813 hpsa_free_performant_mode(h); /* clean7 */ in hpsa_init_one()
8814 hpsa_free_sg_chain_blocks(h); /* clean6 */ in hpsa_init_one()
8815 hpsa_free_cmd_pool(h); /* clean5 */ in hpsa_init_one()
8817 * skip hpsa_free_irqs(h) clean4 since that in hpsa_init_one()
8823 rc = hpsa_kdump_soft_reset(h); in hpsa_init_one()
8828 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8829 dev_info(&h->pdev->dev, in hpsa_init_one()
8831 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8833 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8835 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8837 dev_info(&h->pdev->dev, in hpsa_init_one()
8844 hpsa_undo_allocations_after_kdump_soft_reset(h); in hpsa_init_one()
8854 h->acciopath_status = 1; in hpsa_init_one()
8856 h->discovery_polling = 0; in hpsa_init_one()
8860 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8862 hpsa_hba_inquiry(h); in hpsa_init_one()
8864 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8865 if (!h->lastlogicals) in hpsa_init_one()
8866 dev_info(&h->pdev->dev, in hpsa_init_one()
8870 rc = hpsa_scsi_add_host(h); in hpsa_init_one()
8872 goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8875 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8876 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8877 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8878 h->heartbeat_sample_interval); in hpsa_init_one()
8879 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8880 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8881 h->heartbeat_sample_interval); in hpsa_init_one()
8882 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8883 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8887 clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8888 kfree(h->lastlogicals); in hpsa_init_one()
8889 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8890 hpsa_free_performant_mode(h); in hpsa_init_one()
8891 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8892 clean6: /* sg, cmd, irq, pci, lockup, wq/aer/h */ in hpsa_init_one()
8893 hpsa_free_sg_chain_blocks(h); in hpsa_init_one()
8894 clean5: /* cmd, irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8895 hpsa_free_cmd_pool(h); in hpsa_init_one()
8896 clean4: /* irq, shost, pci, lu, aer/h */ in hpsa_init_one()
8897 hpsa_free_irqs(h); in hpsa_init_one()
8898 clean3: /* shost, pci, lu, aer/h */ in hpsa_init_one()
8899 scsi_host_put(h->scsi_host); in hpsa_init_one()
8900 h->scsi_host = NULL; in hpsa_init_one()
8901 clean2_5: /* pci, lu, aer/h */ in hpsa_init_one()
8902 hpsa_free_pci_init(h); in hpsa_init_one()
8903 clean2: /* lu, aer/h */ in hpsa_init_one()
8904 if (h->lockup_detected) { in hpsa_init_one()
8905 free_percpu(h->lockup_detected); in hpsa_init_one()
8906 h->lockup_detected = NULL; in hpsa_init_one()
8908 clean1: /* wq/aer/h */ in hpsa_init_one()
8909 if (h->resubmit_wq) { in hpsa_init_one()
8910 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8911 h->resubmit_wq = NULL; in hpsa_init_one()
8913 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8914 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8915 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8917 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8918 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8919 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8921 hpda_free_ctlr_info(h); in hpsa_init_one()
8925 static void hpsa_flush_cache(struct ctlr_info *h) in hpsa_flush_cache() argument
8931 if (unlikely(lockup_detected(h))) in hpsa_flush_cache()
8937 c = cmd_alloc(h); in hpsa_flush_cache()
8939 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, in hpsa_flush_cache()
8943 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_flush_cache()
8949 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8951 cmd_free(h, c); in hpsa_flush_cache()
8958 static void hpsa_disable_rld_caching(struct ctlr_info *h) in hpsa_disable_rld_caching() argument
8965 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8972 c = cmd_alloc(h); in hpsa_disable_rld_caching()
8975 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8979 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
8987 if (fill_cmd(c, BMIC_SET_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
8991 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_TO_DEVICE, in hpsa_disable_rld_caching()
8997 if (fill_cmd(c, BMIC_SENSE_DIAG_OPTIONS, h, options, 4, 0, in hpsa_disable_rld_caching()
9001 rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, DMA_FROM_DEVICE, in hpsa_disable_rld_caching()
9010 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9013 cmd_free(h, c); in hpsa_disable_rld_caching()
9019 struct ctlr_info *h; in __hpsa_shutdown() local
9021 h = pci_get_drvdata(pdev); in __hpsa_shutdown()
9026 hpsa_flush_cache(h); in __hpsa_shutdown()
9027 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9028 hpsa_free_irqs(h); /* init_one 4 */ in __hpsa_shutdown()
9029 hpsa_disable_interrupt_mode(h); /* pci_init 2 */ in __hpsa_shutdown()
9038 static void hpsa_free_device_info(struct ctlr_info *h) in hpsa_free_device_info() argument
9042 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9043 kfree(h->dev[i]); in hpsa_free_device_info()
9044 h->dev[i] = NULL; in hpsa_free_device_info()
9050 struct ctlr_info *h; in hpsa_remove_one() local
9057 h = pci_get_drvdata(pdev); in hpsa_remove_one()
9060 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9061 h->remove_in_progress = 1; in hpsa_remove_one()
9062 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9063 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9064 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9065 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9066 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9067 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9068 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9070 hpsa_delete_sas_host(h); in hpsa_remove_one()
9078 if (h->scsi_host) in hpsa_remove_one()
9079 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9084 hpsa_free_device_info(h); /* scan */ in hpsa_remove_one()
9086 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9087 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9088 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_remove_one()
9089 hpsa_free_performant_mode(h); /* init_one 7 */ in hpsa_remove_one()
9090 hpsa_free_sg_chain_blocks(h); /* init_one 6 */ in hpsa_remove_one()
9091 hpsa_free_cmd_pool(h); /* init_one 5 */ in hpsa_remove_one()
9092 kfree(h->lastlogicals); in hpsa_remove_one()
9096 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9097 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9100 hpsa_free_pci_init(h); /* init_one 2.5 */ in hpsa_remove_one()
9102 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9103 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9105 hpda_free_ctlr_info(h); /* init_one 1 */ in hpsa_remove_one()
9169 static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) in hpsa_enter_performant_mode() argument
9223 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9224 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9228 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9230 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9233 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9234 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9235 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9236 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9238 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9239 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9240 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9241 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9244 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9245 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9251 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9252 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9256 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9257 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9258 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9262 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9264 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9269 h->access = access; in hpsa_enter_performant_mode()
9270 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9278 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9279 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9280 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9281 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9283 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9284 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9285 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9288 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9289 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9291 h->reply_queue_size); in hpsa_enter_performant_mode()
9296 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9297 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9300 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9311 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9318 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9321 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9322 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9323 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9324 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9327 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9328 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9332 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9334 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9336 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9337 if (hpsa_wait_for_mode_change_ack(h)) { in hpsa_enter_performant_mode()
9338 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9346 static void hpsa_free_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel1_cmd_and_bft() argument
9348 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9349 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9350 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9351 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9352 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9353 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9354 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9356 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9357 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9361 static int hpsa_alloc_ioaccel1_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel1_cmd_and_bft() argument
9363 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9364 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9365 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9366 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9376 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9377 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9379 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9380 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9387 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9388 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9392 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_alloc_ioaccel1_cmd_and_bft()
9397 static void hpsa_free_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_free_ioaccel2_cmd_and_bft() argument
9399 hpsa_free_ioaccel2_sg_chain_blocks(h); in hpsa_free_ioaccel2_cmd_and_bft()
9401 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9402 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9403 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9404 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9405 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9406 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9407 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9409 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9410 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9414 static int hpsa_alloc_ioaccel2_cmd_and_bft(struct ctlr_info *h) in hpsa_alloc_ioaccel2_cmd_and_bft() argument
9420 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9421 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9422 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9423 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9427 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9428 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9429 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9433 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9442 rc = hpsa_allocate_ioaccel2_sg_chain_blocks(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9446 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9447 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9451 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_alloc_ioaccel2_cmd_and_bft()
9456 static void hpsa_free_performant_mode(struct ctlr_info *h) in hpsa_free_performant_mode() argument
9458 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9459 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9460 hpsa_free_reply_queues(h); in hpsa_free_performant_mode()
9461 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_free_performant_mode()
9462 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_free_performant_mode()
9468 static int hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) in hpsa_put_ctlr_into_performant_mode() argument
9476 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9482 rc = hpsa_alloc_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9486 rc = hpsa_alloc_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9491 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9492 hpsa_get_max_perf_mode_cmds(h); in hpsa_put_ctlr_into_performant_mode()
9494 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9496 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9497 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9498 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9499 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9501 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9505 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9506 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9507 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9511 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9513 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9518 rc = hpsa_enter_performant_mode(h, trans_support); in hpsa_put_ctlr_into_performant_mode()
9524 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9525 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9527 hpsa_free_reply_queues(h); in hpsa_put_ctlr_into_performant_mode()
9528 hpsa_free_ioaccel1_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9529 hpsa_free_ioaccel2_cmd_and_bft(h); in hpsa_put_ctlr_into_performant_mode()
9538 static void hpsa_drain_accel_commands(struct ctlr_info *h) in hpsa_drain_accel_commands() argument
9546 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9547 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9551 cmd_free(h, c); in hpsa_drain_accel_commands()
9723 *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, in hpsa_find_device_by_sas_rphy() argument
9729 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9730 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9740 static int hpsa_add_sas_host(struct ctlr_info *h) in hpsa_add_sas_host() argument
9748 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9754 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9770 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9785 static void hpsa_delete_sas_host(struct ctlr_info *h) in hpsa_delete_sas_host() argument
9787 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9843 struct ctlr_info *h; in hpsa_sas_get_enclosure_identifier() local
9849 h = shost_to_hba(shost); in hpsa_sas_get_enclosure_identifier()
9851 if (!h) in hpsa_sas_get_enclosure_identifier()
9854 sd = hpsa_find_device_by_sas_rphy(h, rphy); in hpsa_sas_get_enclosure_identifier()