Lines Matching +full:battery +full:- +full:backed
3 * Copyright (c) 2019-2020 Microchip Technology Inc. and its subsidiaries
5 * Copyright 2014-2015 PMC-Sierra, Inc.
6 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P.
36 #include <linux/dma-mapping.h>
52 #include <linux/percpu-defs.h>
60 * HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.'
61 * with an optional trailing '-' followed by a byte value (0-255).
63 #define HPSA_DRIVER_VERSION "3.4.20-200"
79 /* Embedded module documentation macros - see modules.h */
80 MODULE_AUTHOR("Hewlett-Packard Company");
223 {0x05809005, "SmartHBA-SA", &SA5_access},
224 {0x05819005, "SmartHBA-SA 8i", &SA5_access},
225 {0x05829005, "SmartHBA-SA 8i8e", &SA5_access},
226 {0x05839005, "SmartHBA-SA 8e", &SA5_access},
227 {0x05849005, "SmartHBA-SA 16i", &SA5_access},
228 {0x05859005, "SmartHBA-SA 4i4e", &SA5_access},
337 unsigned long *priv = shost_priv(sdev->host); in sdev_to_hba()
349 return c->scsi_cmd == SCSI_CMD_IDLE; in hpsa_is_cmd_idle()
352 /* extract sense key, asc, and ascq from sense data. -1 means invalid. */
359 *sense_key = -1; in decode_sense_data()
360 *asc = -1; in decode_sense_data()
361 *ascq = -1; in decode_sense_data()
380 if (c->err_info->SenseLen > sizeof(c->err_info->SenseInfo)) in check_for_unit_attention()
381 sense_len = sizeof(c->err_info->SenseInfo); in check_for_unit_attention()
383 sense_len = c->err_info->SenseLen; in check_for_unit_attention()
385 decode_sense_data(c->err_info->SenseInfo, sense_len, in check_for_unit_attention()
392 dev_warn(&h->pdev->dev, in check_for_unit_attention()
394 h->devname); in check_for_unit_attention()
397 dev_warn(&h->pdev->dev, in check_for_unit_attention()
398 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
401 dev_warn(&h->pdev->dev, in check_for_unit_attention()
402 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
409 dev_warn(&h->pdev->dev, in check_for_unit_attention()
411 h->devname); in check_for_unit_attention()
414 dev_warn(&h->pdev->dev, in check_for_unit_attention()
416 h->devname); in check_for_unit_attention()
419 dev_warn(&h->pdev->dev, in check_for_unit_attention()
421 h->devname); in check_for_unit_attention()
429 if (c->err_info->CommandStatus != CMD_TARGET_STATUS || in check_for_busy()
430 (c->err_info->ScsiStatus != SAM_STAT_BUSY && in check_for_busy()
431 c->err_info->ScsiStatus != SAM_STAT_TASK_SET_FULL)) in check_for_busy()
433 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
461 return -EACCES; in host_store_hp_ssd_smart_path_status()
462 len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count; in host_store_hp_ssd_smart_path_status()
466 return -EINVAL; in host_store_hp_ssd_smart_path_status()
468 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
469 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
471 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
485 return -EACCES; in host_store_raid_offload_debug()
486 len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count; in host_store_raid_offload_debug()
490 return -EINVAL; in host_store_raid_offload_debug()
494 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
495 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
496 h->raid_offload_debug); in host_store_raid_offload_debug()
507 hpsa_scan_start(h->scsi_host); in host_store_rescan()
513 device->offload_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
514 device->offload_to_be_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
525 if (!h->hba_inquiry_data) in host_show_firmware_revision()
527 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
539 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
550 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
562 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
600 * which share a battery backed cache module. One controls the
645 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
663 #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
664 #define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)
668 return !device->physical_device; in is_logical_device()
683 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
684 hdev = sdev->hostdata; in raid_level_show()
686 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
687 return -ENODEV; in raid_level_show()
692 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
697 rlevel = hdev->raid_level; in raid_level_show()
698 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
716 spin_lock_irqsave(&h->lock, flags); in lunid_show()
717 hdev = sdev->hostdata; in lunid_show()
719 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
720 return -ENODEV; in lunid_show()
722 memcpy(lunid, hdev->scsi3addr, sizeof(lunid)); in lunid_show()
723 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
738 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
739 hdev = sdev->hostdata; in unique_id_show()
741 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
742 return -ENODEV; in unique_id_show()
744 memcpy(sn, hdev->device_id, sizeof(sn)); in unique_id_show()
745 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
766 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
767 hdev = sdev->hostdata; in sas_address_show()
768 if (!hdev || is_logical_device(hdev) || !hdev->expose_device) { in sas_address_show()
769 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
770 return -ENODEV; in sas_address_show()
772 sas_address = hdev->sas_address; in sas_address_show()
773 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
789 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
790 hdev = sdev->hostdata; in host_show_hp_ssd_smart_path_enabled()
792 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
793 return -ENODEV; in host_show_hp_ssd_smart_path_enabled()
795 offload_enabled = hdev->offload_enabled; in host_show_hp_ssd_smart_path_enabled()
796 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
798 if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) in host_show_hp_ssd_smart_path_enabled()
823 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
824 hdev = sdev->hostdata; in path_info_show()
826 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
827 return -ENODEV; in path_info_show()
830 bay = hdev->bay; in path_info_show()
833 if (i == hdev->active_path_index) in path_info_show()
835 else if (hdev->path_map & path_map_index) in path_info_show()
841 PAGE_SIZE - output_len, in path_info_show()
843 h->scsi_host->host_no, in path_info_show()
844 hdev->bus, hdev->target, hdev->lun, in path_info_show()
845 scsi_device_type(hdev->devtype)); in path_info_show()
847 if (hdev->devtype == TYPE_RAID || is_logical_device(hdev)) { in path_info_show()
849 PAGE_SIZE - output_len, in path_info_show()
854 box = hdev->box[i]; in path_info_show()
855 memcpy(&phys_connector, &hdev->phys_connector[i], in path_info_show()
862 PAGE_SIZE - output_len, in path_info_show()
865 if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) && in path_info_show()
866 hdev->expose_device) { in path_info_show()
869 PAGE_SIZE - output_len, in path_info_show()
874 PAGE_SIZE - output_len, in path_info_show()
880 PAGE_SIZE - output_len, "BOX: %hhu %s\n", in path_info_show()
884 PAGE_SIZE - output_len, "%s\n", active); in path_info_show()
887 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
898 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
908 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
978 .this_id = -1,
996 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
998 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
999 return h->access.command_completed(h, q); in next_command()
1001 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
1002 return h->access.command_completed(h, q); in next_command()
1004 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) { in next_command()
1005 a = rq->head[rq->current_entry]; in next_command()
1006 rq->current_entry++; in next_command()
1007 atomic_dec(&h->commands_outstanding); in next_command()
1012 if (rq->current_entry == h->max_commands) { in next_command()
1013 rq->current_entry = 0; in next_command()
1014 rq->wraparound ^= 1; in next_command()
1026 * bits 1-3 = block fetch table entry
1027 * bits 4-6 = command type (== 0)
1031 * bits 1-3 = block fetch table entry
1032 * bits 4-6 = command type (== 110)
1040 * bits 1-4 = block fetch table entry (note extra bit)
1041 * bits 4-6 = not needed, because ioaccel2 mode has
1047 * set bit 0 for pull model, bits 3-1 for block fetch
1050 #define DEFAULT_REPLY_QUEUE (-1)
1054 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1055 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1056 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1058 c->Header.ReplyQueue = reply_queue; in set_performant_mode()
1066 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1072 cp->ReplyQueue = reply_queue; in set_ioaccel1_performant_mode()
1075 * - performant mode bit (bit 0) in set_ioaccel1_performant_mode()
1076 * - pull count (bits 1-3) in set_ioaccel1_performant_mode()
1077 * - command type (bits 4-6) in set_ioaccel1_performant_mode()
1079 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1088 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1093 cp->reply_queue = reply_queue; in set_ioaccel2_tmf_performant_mode()
1095 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_tmf_performant_mode()
1096 * - pull count (bits 0-3) in set_ioaccel2_tmf_performant_mode()
1097 * - command type isn't needed for ioaccel2 in set_ioaccel2_tmf_performant_mode()
1099 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1106 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1112 cp->reply_queue = reply_queue; in set_ioaccel2_performant_mode()
1115 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_performant_mode()
1116 * - pull count (bits 0-3) in set_ioaccel2_performant_mode()
1117 * - command type isn't needed for ioaccel2 in set_ioaccel2_performant_mode()
1119 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1138 if (!is_firmware_flash_cmd(c->Request.CDB)) in dial_down_lockup_detection_during_fw_flash()
1140 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1141 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1147 if (is_firmware_flash_cmd(c->Request.CDB) && in dial_up_lockup_detection_on_fw_flash_complete()
1148 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1149 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1156 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1160 if (c->device && !c->retry_pending) in __enqueue_cmd_and_start_io()
1161 atomic_inc(&c->device->commands_outstanding); in __enqueue_cmd_and_start_io()
1163 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1164 switch (c->cmd_type) { in __enqueue_cmd_and_start_io()
1167 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1171 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1175 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1179 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1195 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1197 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1206 * assumes h->devlock is held in hpsa_find_target_lun()
1213 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1214 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1215 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1234 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1237 switch (dev->devtype) { in hpsa_show_dev_msg()
1246 if (dev->external) in hpsa_show_dev_msg()
1248 else if (!is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_show_dev_msg()
1252 snprintf(label, LABEL_SIZE, "RAID-%s", in hpsa_show_dev_msg()
1253 dev->raid_level > RAID_UNKNOWN ? "?" : in hpsa_show_dev_msg()
1254 raid_label[dev->raid_level]); in hpsa_show_dev_msg()
1270 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1272 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1274 scsi_device_type(dev->devtype), in hpsa_show_dev_msg()
1275 dev->vendor, in hpsa_show_dev_msg()
1276 dev->model, in hpsa_show_dev_msg()
1278 dev->offload_config ? '+' : '-', in hpsa_show_dev_msg()
1279 dev->offload_to_be_enabled ? '+' : '-', in hpsa_show_dev_msg()
1280 dev->expose_device); in hpsa_show_dev_msg()
1283 /* Add an entry into h->dev[] array. */
1288 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1289 int n = h->ndevices; in hpsa_scsi_add_entry()
1295 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1297 return -1; in hpsa_scsi_add_entry()
1301 if (device->lun != -1) in hpsa_scsi_add_entry()
1305 /* If this device a non-zero lun of a multi-lun device in hpsa_scsi_add_entry()
1306 * byte 4 of the 8-byte LUN addr will contain the logical in hpsa_scsi_add_entry()
1309 if (device->scsi3addr[4] == 0) { in hpsa_scsi_add_entry()
1310 /* This is not a non-zero lun of a multi-lun device */ in hpsa_scsi_add_entry()
1311 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1312 device->bus, &device->target, &device->lun) != 0) in hpsa_scsi_add_entry()
1313 return -1; in hpsa_scsi_add_entry()
1317 /* This is a non-zero lun of a multi-lun device. in hpsa_scsi_add_entry()
1323 memcpy(addr1, device->scsi3addr, 8); in hpsa_scsi_add_entry()
1327 sd = h->dev[i]; in hpsa_scsi_add_entry()
1328 memcpy(addr2, sd->scsi3addr, 8); in hpsa_scsi_add_entry()
1333 device->bus = sd->bus; in hpsa_scsi_add_entry()
1334 device->target = sd->target; in hpsa_scsi_add_entry()
1335 device->lun = device->scsi3addr[4]; in hpsa_scsi_add_entry()
1339 if (device->lun == -1) { in hpsa_scsi_add_entry()
1340 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1343 return -1; in hpsa_scsi_add_entry()
1348 h->dev[n] = device; in hpsa_scsi_add_entry()
1349 h->ndevices++; in hpsa_scsi_add_entry()
1353 device->expose_device ? "added" : "masked"); in hpsa_scsi_add_entry()
1360 * Update an entry in h->dev[] array.
1365 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1369 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1374 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1377 if (new_entry->offload_config && new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1384 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1386 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1387 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1389 if (new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1390 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1393 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1394 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1395 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1396 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1400 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1403 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1408 if (!new_entry->offload_to_be_enabled) in hpsa_scsi_update_entry()
1409 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1411 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1414 /* Replace an entry from h->dev[] array. */
1420 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1422 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1429 if (new_entry->target == -1) { in hpsa_scsi_replace_entry()
1430 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1431 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1434 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1441 /* Remove an entry from h->dev[] array. */
1445 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1451 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1452 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1455 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1456 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1457 h->ndevices--; in hpsa_scsi_remove_entry()
1474 /* called when scsi_add_device fails in order to re-adjust in fixup_botched_add()
1475 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1480 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1481 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1482 if (h->dev[i] == added) { in fixup_botched_add()
1483 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1484 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1485 h->ndevices--; in fixup_botched_add()
1489 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1500 if (memcmp(dev1->scsi3addr, dev2->scsi3addr, in device_is_the_same()
1501 sizeof(dev1->scsi3addr)) != 0) in device_is_the_same()
1503 if (memcmp(dev1->device_id, dev2->device_id, in device_is_the_same()
1504 sizeof(dev1->device_id)) != 0) in device_is_the_same()
1506 if (memcmp(dev1->model, dev2->model, sizeof(dev1->model)) != 0) in device_is_the_same()
1508 if (memcmp(dev1->vendor, dev2->vendor, sizeof(dev1->vendor)) != 0) in device_is_the_same()
1510 if (dev1->devtype != dev2->devtype) in device_is_the_same()
1512 if (dev1->bus != dev2->bus) in device_is_the_same()
1524 if (dev1->raid_level != dev2->raid_level) in device_updated()
1526 if (dev1->offload_config != dev2->offload_config) in device_updated()
1528 if (dev1->offload_to_be_enabled != dev2->offload_to_be_enabled) in device_updated()
1530 if (!is_logical_dev_addr_mode(dev1->scsi3addr)) in device_updated()
1531 if (dev1->queue_depth != dev2->queue_depth) in device_updated()
1542 if (dev1->ioaccel_handle != dev2->ioaccel_handle) in device_updated()
1570 if (SCSI3ADDR_EQ(needle->scsi3addr, haystack[i]->scsi3addr)) { in hpsa_scsi_find_entry()
1578 if (needle->volume_offline) in hpsa_scsi_find_entry()
1584 *index = -1; in hpsa_scsi_find_entry()
1595 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1596 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1597 if (memcmp(device->scsi3addr, scsi3addr, in hpsa_monitor_offline_device()
1598 sizeof(device->scsi3addr)) == 0) { in hpsa_monitor_offline_device()
1599 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1603 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1610 memcpy(device->scsi3addr, scsi3addr, sizeof(device->scsi3addr)); in hpsa_monitor_offline_device()
1611 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1612 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1613 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1620 if (sd->volume_offline == HPSA_VPD_LV_STATUS_UNSUPPORTED) in hpsa_show_volume_status()
1621 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1623 h->scsi_host->host_no, in hpsa_show_volume_status()
1624 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1625 switch (sd->volume_offline) { in hpsa_show_volume_status()
1629 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1631 h->scsi_host->host_no, in hpsa_show_volume_status()
1632 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1635 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1637 h->scsi_host->host_no, in hpsa_show_volume_status()
1638 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1641 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1643 h->scsi_host->host_no, in hpsa_show_volume_status()
1644 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1647 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1649 h->scsi_host->host_no, in hpsa_show_volume_status()
1650 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1653 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1655 h->scsi_host->host_no, in hpsa_show_volume_status()
1656 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1659 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1660 …d Volume is not encrypted and cannot be accessed because controller is in encryption-only mode.\n", in hpsa_show_volume_status()
1661 h->scsi_host->host_no, in hpsa_show_volume_status()
1662 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1665 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1667 h->scsi_host->host_no, in hpsa_show_volume_status()
1668 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1671 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1672 "C%d:B%d:T%d:L%d Volume is undergoing encryption re-keying process.\n", in hpsa_show_volume_status()
1673 h->scsi_host->host_no, in hpsa_show_volume_status()
1674 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1677 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1679 h->scsi_host->host_no, in hpsa_show_volume_status()
1680 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1683 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1685 h->scsi_host->host_no, in hpsa_show_volume_status()
1686 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1689 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1691 h->scsi_host->host_no, in hpsa_show_volume_status()
1692 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1705 struct raid_map_data *map = &logical_drive->raid_map; in hpsa_figure_phys_disk_ptrs()
1706 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_figure_phys_disk_ptrs()
1708 int total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_figure_phys_disk_ptrs()
1709 le16_to_cpu(map->metadata_disks_per_row); in hpsa_figure_phys_disk_ptrs()
1710 int nraid_map_entries = le16_to_cpu(map->row_cnt) * in hpsa_figure_phys_disk_ptrs()
1711 le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1713 int nphys_disk = le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1720 logical_drive->nphysical_disks = nraid_map_entries; in hpsa_figure_phys_disk_ptrs()
1724 logical_drive->phys_disk[i] = NULL; in hpsa_figure_phys_disk_ptrs()
1725 if (!logical_drive->offload_config) in hpsa_figure_phys_disk_ptrs()
1730 if (dev[j]->devtype != TYPE_DISK && in hpsa_figure_phys_disk_ptrs()
1731 dev[j]->devtype != TYPE_ZBC) in hpsa_figure_phys_disk_ptrs()
1735 if (dev[j]->ioaccel_handle != dd[i].ioaccel_handle) in hpsa_figure_phys_disk_ptrs()
1738 logical_drive->phys_disk[i] = dev[j]; in hpsa_figure_phys_disk_ptrs()
1740 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1741 logical_drive->phys_disk[i]->queue_depth); in hpsa_figure_phys_disk_ptrs()
1752 if (!logical_drive->phys_disk[i]) { in hpsa_figure_phys_disk_ptrs()
1753 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1756 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1757 logical_drive->target, logical_drive->lun); in hpsa_figure_phys_disk_ptrs()
1759 logical_drive->queue_depth = 8; in hpsa_figure_phys_disk_ptrs()
1767 logical_drive->queue_depth = qdepth; in hpsa_figure_phys_disk_ptrs()
1769 if (logical_drive->external) in hpsa_figure_phys_disk_ptrs()
1770 logical_drive->queue_depth = EXTERNAL_QD; in hpsa_figure_phys_disk_ptrs()
1772 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1784 if (dev[i]->devtype != TYPE_DISK && in hpsa_update_log_drive_phys_drive_ptrs()
1785 dev[i]->devtype != TYPE_ZBC) in hpsa_update_log_drive_phys_drive_ptrs()
1797 * re-configured and thus underwent a transformation, or in hpsa_update_log_drive_phys_drive_ptrs()
1809 if (!dev[i]->offload_enabled && dev[i]->offload_to_be_enabled) in hpsa_update_log_drive_phys_drive_ptrs()
1818 if (!h->scsi_host) in hpsa_add_device()
1822 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1823 device->target, device->lun); in hpsa_add_device()
1825 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1836 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1837 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1838 int refcount = atomic_inc_return(&c->refcount); in hpsa_find_outstanding_commands_for_dev()
1841 dev->scsi3addr)) { in hpsa_find_outstanding_commands_for_dev()
1844 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1847 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1864 if (device->external) in hpsa_wait_for_outstanding_commands_for_dev()
1877 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1880 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1881 device->bus, device->target, device->lun, cmds); in hpsa_wait_for_outstanding_commands_for_dev()
1890 if (!h->scsi_host) in hpsa_remove_device()
1896 device->removed = 1; in hpsa_remove_device()
1900 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1901 device->target, device->lun); in hpsa_remove_device()
1925 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1935 * re-schedule the scan to see what happened. in adjust_hpsa_scsi_table()
1937 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1938 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1939 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1940 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1943 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1949 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1954 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1956 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1957 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1966 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1967 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1988 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
1996 * as the SCSI mid-layer does not handle such devices well. in adjust_hpsa_scsi_table()
2000 if (sd[i]->volume_offline) { in adjust_hpsa_scsi_table()
2006 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2007 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2016 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2021 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2024 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2031 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2032 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2034 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2037 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2040 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2041 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2046 if (sd[i]->volume_offline) in adjust_hpsa_scsi_table()
2047 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2061 if (removed[i]->expose_device) in adjust_hpsa_scsi_table()
2073 if (!(added[i]->expose_device)) in adjust_hpsa_scsi_table()
2078 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2080 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2084 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2094 * Assume's h->devlock is held.
2102 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2103 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2104 if (sd->bus == bus && sd->target == target && sd->lun == lun) in lookup_hpsa_scsi_dev()
2117 spin_lock_irqsave(&h->devlock, flags); in hpsa_slave_alloc()
2126 sd->target = sdev_id(sdev); in hpsa_slave_alloc()
2127 sd->lun = sdev->lun; in hpsa_slave_alloc()
2132 sdev_id(sdev), sdev->lun); in hpsa_slave_alloc()
2134 if (sd && sd->expose_device) { in hpsa_slave_alloc()
2135 atomic_set(&sd->ioaccel_cmds_out, 0); in hpsa_slave_alloc()
2136 sdev->hostdata = sd; in hpsa_slave_alloc()
2138 sdev->hostdata = NULL; in hpsa_slave_alloc()
2139 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_slave_alloc()
2143 /* configure scsi device based on internal per-device structure */
2150 sd = sdev->hostdata; in hpsa_slave_configure()
2151 sdev->no_uld_attach = !sd || !sd->expose_device; in hpsa_slave_configure()
2154 sd->was_removed = 0; in hpsa_slave_configure()
2155 queue_depth = sd->queue_depth != 0 ? in hpsa_slave_configure()
2156 sd->queue_depth : sdev->host->can_queue; in hpsa_slave_configure()
2157 if (sd->external) { in hpsa_slave_configure()
2159 sdev->eh_timeout = HPSA_EH_PTRAID_TIMEOUT; in hpsa_slave_configure()
2160 blk_queue_rq_timeout(sdev->request_queue, in hpsa_slave_configure()
2163 if (is_hba_lunid(sd->scsi3addr)) { in hpsa_slave_configure()
2164 sdev->eh_timeout = CTLR_TIMEOUT; in hpsa_slave_configure()
2165 blk_queue_rq_timeout(sdev->request_queue, CTLR_TIMEOUT); in hpsa_slave_configure()
2168 queue_depth = sdev->host->can_queue; in hpsa_slave_configure()
2180 hdev = sdev->hostdata; in hpsa_slave_destroy()
2183 hdev->was_removed = 1; in hpsa_slave_destroy()
2190 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2192 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2193 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2194 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2196 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2197 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2204 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2207 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2210 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2211 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2212 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2213 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2214 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2215 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2224 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2231 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2233 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2234 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2235 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2237 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2238 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2245 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2248 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2250 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2251 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2253 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2254 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2255 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2257 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2265 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2275 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2276 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_map_ioaccel2_sg_chain_block()
2277 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2279 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2281 cp->sg->address = 0; in hpsa_map_ioaccel2_sg_chain_block()
2282 return -1; in hpsa_map_ioaccel2_sg_chain_block()
2284 cp->sg->address = cpu_to_le64(temp64); in hpsa_map_ioaccel2_sg_chain_block()
2295 chain_sg = cp->sg; in hpsa_unmap_ioaccel2_sg_chain_block()
2296 temp64 = le64_to_cpu(chain_sg->address); in hpsa_unmap_ioaccel2_sg_chain_block()
2297 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_unmap_ioaccel2_sg_chain_block()
2298 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2308 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2309 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2310 chain_sg->Ext = cpu_to_le32(HPSA_SG_CHAIN); in hpsa_map_sg_chain_block()
2312 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2313 chain_sg->Len = cpu_to_le32(chain_len); in hpsa_map_sg_chain_block()
2314 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2316 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2318 chain_sg->Addr = cpu_to_le64(0); in hpsa_map_sg_chain_block()
2319 return -1; in hpsa_map_sg_chain_block()
2321 chain_sg->Addr = cpu_to_le64(temp64); in hpsa_map_sg_chain_block()
2330 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2333 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2334 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2335 le32_to_cpu(chain_sg->Len), DMA_TO_DEVICE); in hpsa_unmap_sg_chain_block()
2353 switch (c2->error_data.serv_response) { in handle_ioaccel_mode2_error()
2355 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2358 cmd->result = 0; in handle_ioaccel_mode2_error()
2361 cmd->result |= SAM_STAT_CHECK_CONDITION; in handle_ioaccel_mode2_error()
2362 if (c2->error_data.data_present != in handle_ioaccel_mode2_error()
2364 memset(cmd->sense_buffer, 0, in handle_ioaccel_mode2_error()
2369 data_len = c2->error_data.sense_data_len; in handle_ioaccel_mode2_error()
2372 if (data_len > sizeof(c2->error_data.sense_data_buff)) in handle_ioaccel_mode2_error()
2374 sizeof(c2->error_data.sense_data_buff); in handle_ioaccel_mode2_error()
2375 memcpy(cmd->sense_buffer, in handle_ioaccel_mode2_error()
2376 c2->error_data.sense_data_buff, data_len); in handle_ioaccel_mode2_error()
2397 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2404 cmd->result = (DID_OK << 16); /* host byte */ in handle_ioaccel_mode2_error()
2406 &c2->error_data.resid_cnt[0]); in handle_ioaccel_mode2_error()
2417 * from going down. This allows the potential re-insert in handle_ioaccel_mode2_error()
2420 if (dev->physical_device && dev->expose_device) { in handle_ioaccel_mode2_error()
2421 cmd->result = DID_NO_CONNECT << 16; in handle_ioaccel_mode2_error()
2422 dev->removed = 1; in handle_ioaccel_mode2_error()
2423 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2424 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2452 if (dev->in_reset) in handle_ioaccel_mode2_error()
2461 struct hpsa_scsi_dev_t *dev = c->device; in hpsa_cmd_resolve_events()
2464 * Reset c->scsi_cmd here so that the reset handler will know in hpsa_cmd_resolve_events()
2468 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_resolve_events()
2471 atomic_dec(&dev->commands_outstanding); in hpsa_cmd_resolve_events()
2472 if (dev->in_reset && in hpsa_cmd_resolve_events()
2473 atomic_read(&dev->commands_outstanding) <= 0) in hpsa_cmd_resolve_events()
2474 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2495 INIT_WORK(&c->work, hpsa_command_resubmit_worker); in hpsa_retry_cmd()
2496 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2503 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2506 if (likely(c2->error_data.serv_response == 0 && in process_ioaccel2_completion()
2507 c2->error_data.status == 0)) { in process_ioaccel2_completion()
2508 cmd->result = 0; in process_ioaccel2_completion()
2518 c2->error_data.serv_response == in process_ioaccel2_completion()
2520 if (c2->error_data.status == in process_ioaccel2_completion()
2525 if (dev->in_reset) { in process_ioaccel2_completion()
2526 cmd->result = DID_RESET << 16; in process_ioaccel2_completion()
2543 u8 tmf_status = cp->err_info->ScsiStatus; in hpsa_evaluate_tmf_status()
2549 * ei->CommandStatus == 0 for this case. in hpsa_evaluate_tmf_status()
2560 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2564 return -tmf_status; in hpsa_evaluate_tmf_status()
2580 ei = cp->err_info; in complete_scsi_command()
2581 cmd = cp->scsi_cmd; in complete_scsi_command()
2582 h = cp->h; in complete_scsi_command()
2584 if (!cmd->device) { in complete_scsi_command()
2585 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2589 dev = cmd->device->hostdata; in complete_scsi_command()
2591 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2594 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2597 if ((cp->cmd_type == CMD_SCSI) && in complete_scsi_command()
2598 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2601 if ((cp->cmd_type == CMD_IOACCEL2) && in complete_scsi_command()
2602 (c2->sg[0].chain_indicator == IOACCEL2_CHAIN)) in complete_scsi_command()
2605 cmd->result = (DID_OK << 16); /* host byte */ in complete_scsi_command()
2608 if (dev->was_removed) { in complete_scsi_command()
2613 if (cp->cmd_type == CMD_IOACCEL2 || cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2614 if (dev->physical_device && dev->expose_device && in complete_scsi_command()
2615 dev->removed) { in complete_scsi_command()
2616 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2619 if (likely(cp->phys_disk != NULL)) in complete_scsi_command()
2620 atomic_dec(&cp->phys_disk->ioaccel_cmds_out); in complete_scsi_command()
2628 if (unlikely(ei->CommandStatus == CMD_CTLR_LOCKUP)) { in complete_scsi_command()
2630 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2634 if (cp->cmd_type == CMD_IOACCEL2) in complete_scsi_command()
2637 scsi_set_resid(cmd, ei->ResidualCnt); in complete_scsi_command()
2638 if (ei->CommandStatus == 0) in complete_scsi_command()
2644 if (cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2645 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2646 cp->Header.SGList = scsi_sg_count(cmd); in complete_scsi_command()
2647 cp->Header.SGTotal = cpu_to_le16(cp->Header.SGList); in complete_scsi_command()
2648 cp->Request.CDBLen = le16_to_cpu(c->io_flags) & in complete_scsi_command()
2650 cp->Header.tag = c->tag; in complete_scsi_command()
2651 memcpy(cp->Header.LUN.LunAddrBytes, c->CISS_LUN, 8); in complete_scsi_command()
2652 memcpy(cp->Request.CDB, c->CDB, cp->Request.CDBLen); in complete_scsi_command()
2659 if (ei->CommandStatus == CMD_IOACCEL_DISABLED) in complete_scsi_command()
2660 dev->offload_enabled = 0; in complete_scsi_command()
2666 switch (ei->CommandStatus) { in complete_scsi_command()
2669 cmd->result |= ei->ScsiStatus; in complete_scsi_command()
2671 if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo)) in complete_scsi_command()
2674 sense_data_size = sizeof(ei->SenseInfo); in complete_scsi_command()
2675 if (ei->SenseLen < sense_data_size) in complete_scsi_command()
2676 sense_data_size = ei->SenseLen; in complete_scsi_command()
2677 memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size); in complete_scsi_command()
2678 if (ei->ScsiStatus) in complete_scsi_command()
2679 decode_sense_data(ei->SenseInfo, sense_data_size, in complete_scsi_command()
2681 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) { in complete_scsi_command()
2684 cmd->result |= DID_SOFT_ERROR << 16; in complete_scsi_command()
2688 h->drv_req_rescan = 1; in complete_scsi_command()
2692 dev->removed = 1; in complete_scsi_command()
2693 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2702 if (ei->ScsiStatus) { in complete_scsi_command()
2703 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2706 cp, ei->ScsiStatus, in complete_scsi_command()
2708 cmd->result); in complete_scsi_command()
2710 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2725 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2732 dev_warn(&h->pdev->dev, in complete_scsi_command()
2733 "CDB %16phN data overrun\n", cp->Request.CDB); in complete_scsi_command()
2738 /* We get CMD_INVALID if you address a non-existent device in complete_scsi_command()
2744 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2748 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2749 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2750 cp->Request.CDB); in complete_scsi_command()
2753 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2754 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2755 cp->Request.CDB); in complete_scsi_command()
2758 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2759 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2760 cp->Request.CDB); in complete_scsi_command()
2763 cmd->result = DID_ABORT << 16; in complete_scsi_command()
2766 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2767 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2768 cp->Request.CDB); in complete_scsi_command()
2771 cmd->result = DID_SOFT_ERROR << 16; /* retry the command */ in complete_scsi_command()
2772 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2773 cp->Request.CDB); in complete_scsi_command()
2776 cmd->result = DID_TIME_OUT << 16; in complete_scsi_command()
2777 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2778 cp->Request.CDB); in complete_scsi_command()
2781 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2782 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2786 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2789 /* This only handles the direct pass-through case since RAID in complete_scsi_command()
2792 cmd->result = DID_SOFT_ERROR << 16; in complete_scsi_command()
2793 dev_warn(&h->pdev->dev, in complete_scsi_command()
2797 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2798 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2799 cp, ei->CommandStatus); in complete_scsi_command()
2811 dma_unmap_single(&pdev->dev, le64_to_cpu(c->SG[i].Addr), in hpsa_pci_unmap()
2812 le32_to_cpu(c->SG[i].Len), in hpsa_pci_unmap()
2825 cp->Header.SGList = 0; in hpsa_map_one()
2826 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2830 addr64 = dma_map_single(&pdev->dev, buf, buflen, data_direction); in hpsa_map_one()
2831 if (dma_mapping_error(&pdev->dev, addr64)) { in hpsa_map_one()
2833 cp->Header.SGList = 0; in hpsa_map_one()
2834 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2835 return -1; in hpsa_map_one()
2837 cp->SG[0].Addr = cpu_to_le64(addr64); in hpsa_map_one()
2838 cp->SG[0].Len = cpu_to_le32(buflen); in hpsa_map_one()
2839 cp->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* we are not chaining */ in hpsa_map_one()
2840 cp->Header.SGList = 1; /* no. SGs contig in this cmd */ in hpsa_map_one()
2841 cp->Header.SGTotal = cpu_to_le16(1); /* total sgs in cmd list */ in hpsa_map_one()
2845 #define NO_TIMEOUT ((unsigned long) -1)
2852 c->waiting = &wait; in hpsa_scsi_do_simple_cmd_core()
2855 /* TODO: get rid of this no-timeout thing */ in hpsa_scsi_do_simple_cmd_core()
2861 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2862 return -ETIMEDOUT; in hpsa_scsi_do_simple_cmd_core()
2871 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in hpsa_scsi_do_simple_cmd()
2883 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2898 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_scsi_do_simple_cmd_with_retry()
2912 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2914 rc = -EIO; in hpsa_scsi_do_simple_cmd_with_retry()
2921 const u8 *cdb = c->Request.CDB; in hpsa_print_cmd()
2922 const u8 *lun = c->Header.LUN.LunAddrBytes; in hpsa_print_cmd()
2924 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2931 const struct ErrorInfo *ei = cp->err_info; in hpsa_scsi_interpret_error()
2932 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2936 switch (ei->CommandStatus) { in hpsa_scsi_interpret_error()
2938 if (ei->SenseLen > sizeof(ei->SenseInfo)) in hpsa_scsi_interpret_error()
2939 sense_len = sizeof(ei->SenseInfo); in hpsa_scsi_interpret_error()
2941 sense_len = ei->SenseLen; in hpsa_scsi_interpret_error()
2942 decode_sense_data(ei->SenseInfo, sense_len, in hpsa_scsi_interpret_error()
2945 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) in hpsa_scsi_interpret_error()
2949 dev_warn(d, "SCSI Status = 0x%02x\n", ei->ScsiStatus); in hpsa_scsi_interpret_error()
2950 if (ei->ScsiStatus == 0) in hpsa_scsi_interpret_error()
2963 * to non-existent targets as invalid commands. in hpsa_scsi_interpret_error()
2999 ei->CommandStatus); in hpsa_scsi_interpret_error()
3013 rc = -1; in hpsa_do_receive_diagnostic()
3020 ei = c->err_info; in hpsa_do_receive_diagnostic()
3021 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_do_receive_diagnostic()
3023 rc = -1; in hpsa_do_receive_diagnostic()
3066 rc = -1; in hpsa_scsi_do_inquiry()
3073 ei = c->err_info; in hpsa_scsi_do_inquiry()
3074 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_inquiry()
3076 rc = -1; in hpsa_scsi_do_inquiry()
3091 c->device = dev; in hpsa_send_reset()
3094 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3097 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3102 ei = c->err_info; in hpsa_send_reset()
3103 if (ei->CommandStatus != 0) { in hpsa_send_reset()
3105 rc = -1; in hpsa_send_reset()
3118 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3124 switch (c->cmd_type) { in hpsa_cmd_dev_match()
3127 match = !memcmp(scsi3addr, &c->Header.LUN.LunAddrBytes, in hpsa_cmd_dev_match()
3128 sizeof(c->Header.LUN.LunAddrBytes)); in hpsa_cmd_dev_match()
3133 if (c->phys_disk == dev) { in hpsa_cmd_dev_match()
3137 /* Possible RAID mode -- check each phys dev. */ in hpsa_cmd_dev_match()
3141 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3144 * match = dev->phys_disk[i]->ioaccel_handle in hpsa_cmd_dev_match()
3145 * == c2->scsi_nexus; */ in hpsa_cmd_dev_match()
3146 match = dev->phys_disk[i] == c->phys_disk; in hpsa_cmd_dev_match()
3152 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3153 match = dev->phys_disk[i]->ioaccel_handle == in hpsa_cmd_dev_match()
3154 le32_to_cpu(ac->it_nexus); in hpsa_cmd_dev_match()
3163 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3164 c->cmd_type); in hpsa_cmd_dev_match()
3177 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3178 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3179 return -EINTR; in hpsa_do_reset()
3185 atomic_dec(&dev->commands_outstanding); in hpsa_do_reset()
3186 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3187 atomic_read(&dev->commands_outstanding) <= 0 || in hpsa_do_reset()
3192 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3194 rc = -ENODEV; in hpsa_do_reset()
3198 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3200 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3236 struct raid_map_disk_data *dd = &map_buff->data[0]; in hpsa_debug_map_buff()
3244 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3248 le32_to_cpu(map_buff->structure_size)); in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3250 le32_to_cpu(map_buff->volume_blk_size)); in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3252 le64_to_cpu(map_buff->volume_blk_cnt)); in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3254 map_buff->phys_blk_shift); in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3256 map_buff->parity_rotation_shift); in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3258 le16_to_cpu(map_buff->strip_size)); in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3260 le64_to_cpu(map_buff->disk_starting_blk)); in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3262 le64_to_cpu(map_buff->disk_blk_cnt)); in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3264 le16_to_cpu(map_buff->data_disks_per_row)); in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3266 le16_to_cpu(map_buff->metadata_disks_per_row)); in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3268 le16_to_cpu(map_buff->row_cnt)); in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3270 le16_to_cpu(map_buff->layout_map_count)); in hpsa_debug_map_buff()
3271 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3272 le16_to_cpu(map_buff->flags)); in hpsa_debug_map_buff()
3273 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3274 le16_to_cpu(map_buff->flags) & in hpsa_debug_map_buff()
3276 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3277 le16_to_cpu(map_buff->dekindex)); in hpsa_debug_map_buff()
3278 map_cnt = le16_to_cpu(map_buff->layout_map_count); in hpsa_debug_map_buff()
3280 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3281 row_cnt = le16_to_cpu(map_buff->row_cnt); in hpsa_debug_map_buff()
3283 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3285 le16_to_cpu(map_buff->data_disks_per_row); in hpsa_debug_map_buff()
3287 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3289 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3290 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3292 le16_to_cpu(map_buff->metadata_disks_per_row); in hpsa_debug_map_buff()
3294 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3296 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3297 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3318 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3319 sizeof(this_device->raid_map), 0, in hpsa_get_raid_map()
3321 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3323 return -1; in hpsa_get_raid_map()
3329 ei = c->err_info; in hpsa_get_raid_map()
3330 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_raid_map()
3332 rc = -1; in hpsa_get_raid_map()
3338 if (le32_to_cpu(this_device->raid_map.structure_size) > in hpsa_get_raid_map()
3339 sizeof(this_device->raid_map)) { in hpsa_get_raid_map()
3340 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3341 rc = -1; in hpsa_get_raid_map()
3343 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3365 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_sense_subsystem_information()
3366 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_sense_subsystem_information()
3372 ei = c->err_info; in hpsa_bmic_sense_subsystem_information()
3373 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_sense_subsystem_information()
3375 rc = -1; in hpsa_bmic_sense_subsystem_information()
3400 ei = c->err_info; in hpsa_bmic_id_controller()
3401 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_controller()
3403 rc = -1; in hpsa_bmic_id_controller()
3424 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_id_physical_device()
3425 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_id_physical_device()
3429 ei = c->err_info; in hpsa_bmic_id_physical_device()
3430 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_physical_device()
3432 rc = -1; in hpsa_bmic_id_physical_device()
3442 * struct ReportExtendedLUNdata *rlep - Used for BMIC drive number
3443 * struct hpsa_scsi_dev_t *encl_dev - device entry for enclosure
3451 int rc = -1; in hpsa_get_enclosure_info()
3462 rle = &rlep->LUN[rle_index]; in hpsa_get_enclosure_info()
3464 encl_dev->eli = in hpsa_get_enclosure_info()
3467 bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); in hpsa_get_enclosure_info()
3469 if (encl_dev->target == -1 || encl_dev->lun == -1) { in hpsa_get_enclosure_info()
3474 if (bmic_device_index == 0xFF00 || MASKED_DEVICE(&rle->lunid[0])) { in hpsa_get_enclosure_info()
3490 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3491 __func__, encl_dev->external, bmic_device_index); in hpsa_get_enclosure_info()
3503 if (id_phys->phys_connector[1] == 'E') in hpsa_get_enclosure_info()
3504 c->Request.CDB[5] = id_phys->box_index; in hpsa_get_enclosure_info()
3506 c->Request.CDB[5] = 0; in hpsa_get_enclosure_info()
3513 ei = c->err_info; in hpsa_get_enclosure_info()
3514 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_enclosure_info()
3515 rc = -1; in hpsa_get_enclosure_info()
3519 encl_dev->box[id_phys->active_path_number] = bssbp->phys_box_on_port; in hpsa_get_enclosure_info()
3520 memcpy(&encl_dev->phys_connector[id_phys->active_path_number], in hpsa_get_enclosure_info()
3521 bssbp->phys_connector, sizeof(bssbp->phys_connector)); in hpsa_get_enclosure_info()
3549 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3553 nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24; in hpsa_get_sas_address_from_report_physical()
3556 if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8)) { in hpsa_get_sas_address_from_report_physical()
3557 sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]); in hpsa_get_sas_address_from_report_physical()
3582 sa = get_unaligned_be64(ssi->primary_world_wide_id); in hpsa_get_sas_address()
3583 h->sas_address = sa; in hpsa_get_sas_address()
3590 dev->sas_address = sa; in hpsa_get_sas_address()
3599 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3602 nphysicals = (get_unaligned_be32(physdev->LUNListLength) / 24) + 1; in hpsa_ext_ctrl_present()
3605 if (physdev->LUN[i].device_type == in hpsa_ext_ctrl_present()
3607 && !is_hba_lunid(physdev->LUN[i].lunid)) { in hpsa_ext_ctrl_present()
3608 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3611 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3675 this_device->offload_config = 0; in hpsa_get_ioaccel_status()
3676 this_device->offload_enabled = 0; in hpsa_get_ioaccel_status()
3677 this_device->offload_to_be_enabled = 0; in hpsa_get_ioaccel_status()
3693 this_device->offload_config = in hpsa_get_ioaccel_status()
3695 if (this_device->offload_config) { in hpsa_get_ioaccel_status()
3705 this_device->offload_to_be_enabled = 1; in hpsa_get_ioaccel_status()
3727 return -ENOMEM; in hpsa_get_device_id()
3739 return rc; /*0 - got id, otherwise, didn't */ in hpsa_get_device_id()
3757 rc = -EAGAIN; in hpsa_scsi_do_report_luns()
3761 c->Request.CDB[1] = extended_response; in hpsa_scsi_do_report_luns()
3766 ei = c->err_info; in hpsa_scsi_do_report_luns()
3767 if (ei->CommandStatus != 0 && in hpsa_scsi_do_report_luns()
3768 ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_report_luns()
3770 rc = -EIO; in hpsa_scsi_do_report_luns()
3774 if (rld->extended_response_flag != extended_response) { in hpsa_scsi_do_report_luns()
3775 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3776 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3779 rld->extended_response_flag); in hpsa_scsi_do_report_luns()
3780 rc = -EINVAL; in hpsa_scsi_do_report_luns()
3782 rc = -EOPNOTSUPP; in hpsa_scsi_do_report_luns()
3798 if (!rc || rc != -EOPNOTSUPP) in hpsa_scsi_do_report_phys_luns()
3804 return -ENOMEM; in hpsa_scsi_do_report_phys_luns()
3813 nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 8; in hpsa_scsi_do_report_phys_luns()
3815 memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8); in hpsa_scsi_do_report_phys_luns()
3830 device->bus = bus; in hpsa_set_bus_target_lun()
3831 device->target = target; in hpsa_set_bus_target_lun()
3832 device->lun = lun; in hpsa_set_bus_target_lun()
3901 sense = c->err_info->SenseInfo; in hpsa_volume_offline()
3902 if (c->err_info->SenseLen > sizeof(c->err_info->SenseInfo)) in hpsa_volume_offline()
3903 sense_len = sizeof(c->err_info->SenseInfo); in hpsa_volume_offline()
3905 sense_len = c->err_info->SenseLen; in hpsa_volume_offline()
3945 #define OBDR_TAPE_SIG "$DR-10" in hpsa_update_device_info()
3946 #define OBDR_SIG_LEN (sizeof(OBDR_TAPE_SIG) - 1) in hpsa_update_device_info()
3955 rc = -ENOMEM; in hpsa_update_device_info()
3962 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3972 this_device->devtype = (inq_buff[0] & 0x1f); in hpsa_update_device_info()
3973 memcpy(this_device->scsi3addr, scsi3addr, 8); in hpsa_update_device_info()
3974 memcpy(this_device->vendor, &inq_buff[8], in hpsa_update_device_info()
3975 sizeof(this_device->vendor)); in hpsa_update_device_info()
3976 memcpy(this_device->model, &inq_buff[16], in hpsa_update_device_info()
3977 sizeof(this_device->model)); in hpsa_update_device_info()
3978 this_device->rev = inq_buff[2]; in hpsa_update_device_info()
3979 memset(this_device->device_id, 0, in hpsa_update_device_info()
3980 sizeof(this_device->device_id)); in hpsa_update_device_info()
3981 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3982 sizeof(this_device->device_id)) < 0) { in hpsa_update_device_info()
3983 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3985 h->ctlr, __func__, in hpsa_update_device_info()
3986 h->scsi_host->host_no, in hpsa_update_device_info()
3987 this_device->bus, this_device->target, in hpsa_update_device_info()
3988 this_device->lun, in hpsa_update_device_info()
3989 scsi_device_type(this_device->devtype), in hpsa_update_device_info()
3990 this_device->model); in hpsa_update_device_info()
3995 if ((this_device->devtype == TYPE_DISK || in hpsa_update_device_info()
3996 this_device->devtype == TYPE_ZBC) && in hpsa_update_device_info()
4000 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
4001 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
4005 h->legacy_board) { in hpsa_update_device_info()
4009 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4011 this_device->target, this_device->lun); in hpsa_update_device_info()
4014 this_device->volume_offline = volume_offline; in hpsa_update_device_info()
4017 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4023 this_device->raid_level = RAID_UNKNOWN; in hpsa_update_device_info()
4024 this_device->offload_config = 0; in hpsa_update_device_info()
4026 this_device->hba_ioaccel_enabled = 0; in hpsa_update_device_info()
4027 this_device->volume_offline = 0; in hpsa_update_device_info()
4028 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4031 if (this_device->external) in hpsa_update_device_info()
4032 this_device->queue_depth = EXTERNAL_QD; in hpsa_update_device_info()
4035 /* See if this is a One-Button-Disaster-Recovery device in hpsa_update_device_info()
4036 * by looking for "$DR-10" at offset 43 in inquiry data. in hpsa_update_device_info()
4039 *is_OBDR_device = (this_device->devtype == TYPE_ROM && in hpsa_update_device_info()
4067 if (!device->rev) in figure_bus_target_lun()
4074 HPSA_PHYSICAL_DEVICE_BUS, -1, -1); in figure_bus_target_lun()
4078 if (device->external) { in figure_bus_target_lun()
4103 if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals) in figure_external_status()
4113 * Returns 0 on success, -1 otherwise.
4120 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4121 return -1; in hpsa_gather_lun_info()
4123 *nphysicals = be32_to_cpu(*((__be32 *)physdev->LUNListLength)) / 24; in hpsa_gather_lun_info()
4125 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4126 HPSA_MAX_PHYS_LUN, *nphysicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4130 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4131 return -1; in hpsa_gather_lun_info()
4133 *nlogicals = be32_to_cpu(*((__be32 *) logdev->LUNListLength)) / 8; in hpsa_gather_lun_info()
4136 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4139 *nlogicals - HPSA_MAX_LUN); in hpsa_gather_lun_info()
4143 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4146 *nphysicals + *nlogicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4147 *nlogicals = HPSA_MAX_PHYS_LUN - *nphysicals; in hpsa_gather_lun_info()
4169 return &physdev_list->LUN[i - in figure_lunaddrbytes()
4173 return &logdev_list->LUN[i - nphysicals - in figure_lunaddrbytes()
4191 rle = &rlep->LUN[rle_index]; in hpsa_get_ioaccel_drive_info()
4193 dev->ioaccel_handle = rle->ioaccel_handle; in hpsa_get_ioaccel_drive_info()
4194 if ((rle->device_flags & 0x08) && dev->ioaccel_handle) in hpsa_get_ioaccel_drive_info()
4195 dev->hba_ioaccel_enabled = 1; in hpsa_get_ioaccel_drive_info()
4197 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4198 GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]), id_phys, in hpsa_get_ioaccel_drive_info()
4204 dev->queue_depth = in hpsa_get_ioaccel_drive_info()
4205 le16_to_cpu(id_phys->current_queue_depth_limit) - in hpsa_get_ioaccel_drive_info()
4208 dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */ in hpsa_get_ioaccel_drive_info()
4220 rle = &rlep->LUN[rle_index]; in hpsa_get_path_info()
4222 if ((rle->device_flags & 0x08) && this_device->ioaccel_handle) in hpsa_get_path_info()
4223 this_device->hba_ioaccel_enabled = 1; in hpsa_get_path_info()
4225 memcpy(&this_device->active_path_index, in hpsa_get_path_info()
4226 &id_phys->active_path_number, in hpsa_get_path_info()
4227 sizeof(this_device->active_path_index)); in hpsa_get_path_info()
4228 memcpy(&this_device->path_map, in hpsa_get_path_info()
4229 &id_phys->redundant_path_present_map, in hpsa_get_path_info()
4230 sizeof(this_device->path_map)); in hpsa_get_path_info()
4231 memcpy(&this_device->box, in hpsa_get_path_info()
4232 &id_phys->alternate_paths_phys_box_on_port, in hpsa_get_path_info()
4233 sizeof(this_device->box)); in hpsa_get_path_info()
4234 memcpy(&this_device->phys_connector, in hpsa_get_path_info()
4235 &id_phys->alternate_paths_phys_connector, in hpsa_get_path_info()
4236 sizeof(this_device->phys_connector)); in hpsa_get_path_info()
4237 memcpy(&this_device->bay, in hpsa_get_path_info()
4238 &id_phys->phys_bay_in_box, in hpsa_get_path_info()
4239 sizeof(this_device->bay)); in hpsa_get_path_info()
4250 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4252 return -ENOMEM; in hpsa_set_local_logical_count()
4257 if (id_ctlr->configured_logical_drive_count < 255) in hpsa_set_local_logical_count()
4258 *nlocals = id_ctlr->configured_logical_drive_count; in hpsa_set_local_logical_count()
4261 id_ctlr->extended_logical_unit_count); in hpsa_set_local_logical_count()
4263 *nlocals = -1; in hpsa_set_local_logical_count()
4282 is_spare = (id_phys->more_flags >> 6) & 0x01; in hpsa_is_disk_spare()
4303 device_flags = rle->device_flags; in hpsa_skip_device()
4304 device_type = rle->device_type; in hpsa_skip_device()
4367 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4371 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4375 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4381 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4397 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4399 ndevs_to_allocate - HPSA_MAX_DEVICES); in hpsa_update_scsi_devices()
4405 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4420 int phys_dev_index = i - (raid_ctlr_position == 0); in hpsa_update_scsi_devices()
4432 tmpdevice->external = in hpsa_update_scsi_devices()
4439 if (phys_dev_index >= 0 && !tmpdevice->external && in hpsa_update_scsi_devices()
4442 &physdev_list->LUN[phys_dev_index]); in hpsa_update_scsi_devices()
4450 if (rc == -ENOMEM) { in hpsa_update_scsi_devices()
4451 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4453 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4457 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4465 this_device->physical_device = physical_device; in hpsa_update_scsi_devices()
4471 if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device) in hpsa_update_scsi_devices()
4472 this_device->expose_device = 0; in hpsa_update_scsi_devices()
4474 this_device->expose_device = 1; in hpsa_update_scsi_devices()
4480 if (this_device->physical_device && this_device->expose_device) in hpsa_update_scsi_devices()
4483 switch (this_device->devtype) { in hpsa_update_scsi_devices()
4485 /* We don't *really* support actual CD-ROM devices, in hpsa_update_scsi_devices()
4487 * which temporarily pretends to be a CD-ROM drive. in hpsa_update_scsi_devices()
4489 * device by checking for "$DR-10" in bytes 43-48 of in hpsa_update_scsi_devices()
4497 if (this_device->physical_device) { in hpsa_update_scsi_devices()
4500 this_device->offload_enabled = 0; in hpsa_update_scsi_devices()
4513 if (!this_device->external) in hpsa_update_scsi_devices()
4536 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4541 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4565 desc->Addr = cpu_to_le64(addr64); in hpsa_set_sg_descriptor()
4566 desc->Len = cpu_to_le32(len); in hpsa_set_sg_descriptor()
4567 desc->Ext = 0; in hpsa_set_sg_descriptor()
4583 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4599 curr_sg = cp->SG; in hpsa_scatter_gather()
4600 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4601 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4614 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4615 sg_limit = use_sg - sg_limit; in hpsa_scatter_gather()
4623 (curr_sg - 1)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scatter_gather()
4625 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4626 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4629 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4630 cp->Header.SGTotal = cpu_to_le16(use_sg + 1); in hpsa_scatter_gather()
4633 return -1; in hpsa_scatter_gather()
4640 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */ in hpsa_scatter_gather()
4641 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in cmd list */ in hpsa_scatter_gather()
4649 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4650 "%s: Blocking zero-length request: CDB:%*phN\n", in warn_zero_length_transfer()
4655 /* zero-length transfers trigger hardware errors. */
4660 /* Block zero-length transfer sizes on certain commands. */ in is_zero_length_transfer()
4735 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel1_queue_command()
4736 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4746 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4747 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4751 BUG_ON(cmd->cmd_len > IOACCEL1_IOFLAGS_CDBLEN_MAX); in hpsa_scsi_ioaccel1_queue_command()
4755 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4760 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4764 c->cmd_type = CMD_IOACCEL1; in hpsa_scsi_ioaccel1_queue_command()
4767 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4768 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel1_queue_command()
4769 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel1_queue_command()
4773 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4778 curr_sg = cp->SG; in hpsa_scsi_ioaccel1_queue_command()
4783 curr_sg->Addr = cpu_to_le64(addr64); in hpsa_scsi_ioaccel1_queue_command()
4784 curr_sg->Len = cpu_to_le32(len); in hpsa_scsi_ioaccel1_queue_command()
4785 curr_sg->Ext = cpu_to_le32(0); in hpsa_scsi_ioaccel1_queue_command()
4788 (--curr_sg)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scsi_ioaccel1_queue_command()
4790 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel1_queue_command()
4801 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4802 cmd->sc_data_direction); in hpsa_scsi_ioaccel1_queue_command()
4810 c->Header.SGList = use_sg; in hpsa_scsi_ioaccel1_queue_command()
4812 cp->dev_handle = cpu_to_le16(ioaccel_handle & 0xFFFF); in hpsa_scsi_ioaccel1_queue_command()
4813 cp->transfer_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel1_queue_command()
4814 cp->io_flags = cpu_to_le16(IOACCEL1_IOFLAGS_IO_REQ | in hpsa_scsi_ioaccel1_queue_command()
4816 cp->control = cpu_to_le32(control); in hpsa_scsi_ioaccel1_queue_command()
4817 memcpy(cp->CDB, cdb, cdb_len); in hpsa_scsi_ioaccel1_queue_command()
4818 memcpy(cp->CISS_LUN, scsi3addr, 8); in hpsa_scsi_ioaccel1_queue_command()
4831 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_direct_map()
4832 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_direct_map()
4835 return -1; in hpsa_scsi_ioaccel_direct_map()
4837 c->phys_disk = dev; in hpsa_scsi_ioaccel_direct_map()
4839 if (dev->in_reset) in hpsa_scsi_ioaccel_direct_map()
4840 return -1; in hpsa_scsi_ioaccel_direct_map()
4842 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4843 cmd->cmnd, cmd->cmd_len, dev->scsi3addr, dev); in hpsa_scsi_ioaccel_direct_map()
4852 struct scsi_cmnd *cmd = c->scsi_cmd; in set_encrypt_ioaccel2()
4853 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in set_encrypt_ioaccel2()
4854 struct raid_map_data *map = &dev->raid_map; in set_encrypt_ioaccel2()
4858 if (!(le16_to_cpu(map->flags) & RAID_MAP_FLAG_ENCRYPT_ON)) in set_encrypt_ioaccel2()
4861 cp->dekindex = map->dekindex; in set_encrypt_ioaccel2()
4864 cp->direction |= IOACCEL2_DIRECTION_ENCRYPT_MASK; in set_encrypt_ioaccel2()
4870 switch (cmd->cmnd[0]) { in set_encrypt_ioaccel2()
4871 /* Required? 6-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4874 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in set_encrypt_ioaccel2()
4875 (cmd->cmnd[2] << 8) | in set_encrypt_ioaccel2()
4876 cmd->cmnd[3]); in set_encrypt_ioaccel2()
4880 /* Required? 12-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4883 first_block = get_unaligned_be32(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4887 first_block = get_unaligned_be64(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4890 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4892 __func__, cmd->cmnd[0]); in set_encrypt_ioaccel2()
4897 if (le32_to_cpu(map->volume_blk_size) != 512) in set_encrypt_ioaccel2()
4899 le32_to_cpu(map->volume_blk_size)/512; in set_encrypt_ioaccel2()
4901 cp->tweak_lower = cpu_to_le32(first_block); in set_encrypt_ioaccel2()
4902 cp->tweak_upper = cpu_to_le32(first_block >> 32); in set_encrypt_ioaccel2()
4909 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel2_queue_command()
4910 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4918 if (!cmd->device) in hpsa_scsi_ioaccel2_queue_command()
4919 return -1; in hpsa_scsi_ioaccel2_queue_command()
4921 if (!cmd->device->hostdata) in hpsa_scsi_ioaccel2_queue_command()
4922 return -1; in hpsa_scsi_ioaccel2_queue_command()
4924 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4928 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4933 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4937 c->cmd_type = CMD_IOACCEL2; in hpsa_scsi_ioaccel2_queue_command()
4939 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4940 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel2_queue_command()
4941 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel2_queue_command()
4944 cp->IU_type = IOACCEL2_IU_TYPE; in hpsa_scsi_ioaccel2_queue_command()
4948 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4953 curr_sg = cp->sg; in hpsa_scsi_ioaccel2_queue_command()
4954 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4956 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4957 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4958 curr_sg->length = 0; in hpsa_scsi_ioaccel2_queue_command()
4959 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4960 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4961 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4962 curr_sg->chain_indicator = IOACCEL2_CHAIN; in hpsa_scsi_ioaccel2_queue_command()
4964 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4970 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4971 curr_sg->length = cpu_to_le32(len); in hpsa_scsi_ioaccel2_queue_command()
4972 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4973 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4974 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4975 curr_sg->chain_indicator = 0; in hpsa_scsi_ioaccel2_queue_command()
4982 (curr_sg - 1)->chain_indicator = IOACCEL2_LAST_SG; in hpsa_scsi_ioaccel2_queue_command()
4984 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel2_queue_command()
4986 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4987 cp->direction |= IOACCEL2_DIR_DATA_OUT; in hpsa_scsi_ioaccel2_queue_command()
4990 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4991 cp->direction |= IOACCEL2_DIR_DATA_IN; in hpsa_scsi_ioaccel2_queue_command()
4994 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4995 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
4998 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
4999 cmd->sc_data_direction); in hpsa_scsi_ioaccel2_queue_command()
5004 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
5005 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
5011 cp->scsi_nexus = cpu_to_le32(ioaccel_handle); in hpsa_scsi_ioaccel2_queue_command()
5012 cp->Tag = cpu_to_le32(c->cmdindex << DIRECT_LOOKUP_SHIFT); in hpsa_scsi_ioaccel2_queue_command()
5013 memcpy(cp->cdb, cdb, sizeof(cp->cdb)); in hpsa_scsi_ioaccel2_queue_command()
5015 cp->data_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel2_queue_command()
5016 cp->err_ptr = cpu_to_le64(c->busaddr + in hpsa_scsi_ioaccel2_queue_command()
5018 cp->err_len = cpu_to_le32(sizeof(cp->error_data)); in hpsa_scsi_ioaccel2_queue_command()
5021 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5022 cp->sg_count = 1; in hpsa_scsi_ioaccel2_queue_command()
5023 cp->sg[0].length = cpu_to_le32(use_sg * sizeof(cp->sg[0])); in hpsa_scsi_ioaccel2_queue_command()
5025 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
5027 return -1; in hpsa_scsi_ioaccel2_queue_command()
5030 cp->sg_count = (u8) use_sg; in hpsa_scsi_ioaccel2_queue_command()
5032 if (phys_disk->in_reset) { in hpsa_scsi_ioaccel2_queue_command()
5033 cmd->result = DID_RESET << 16; in hpsa_scsi_ioaccel2_queue_command()
5034 return -1; in hpsa_scsi_ioaccel2_queue_command()
5048 if (!c->scsi_cmd->device) in hpsa_scsi_ioaccel_queue_command()
5049 return -1; in hpsa_scsi_ioaccel_queue_command()
5051 if (!c->scsi_cmd->device->hostdata) in hpsa_scsi_ioaccel_queue_command()
5052 return -1; in hpsa_scsi_ioaccel_queue_command()
5054 if (phys_disk->in_reset) in hpsa_scsi_ioaccel_queue_command()
5055 return -1; in hpsa_scsi_ioaccel_queue_command()
5058 if (atomic_inc_return(&phys_disk->ioaccel_cmds_out) > in hpsa_scsi_ioaccel_queue_command()
5059 phys_disk->queue_depth) { in hpsa_scsi_ioaccel_queue_command()
5060 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel_queue_command()
5063 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5078 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5084 le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5087 if (*current_group < le16_to_cpu(map->layout_map_count) - 1) { in raid_map_helper()
5089 *map_index += le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5093 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5105 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_raid_map()
5106 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_raid_map()
5107 struct raid_map_data *map = &dev->raid_map; in hpsa_scsi_ioaccel_raid_map()
5108 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_scsi_ioaccel_raid_map()
5138 return -1; in hpsa_scsi_ioaccel_raid_map()
5140 if (dev->in_reset) in hpsa_scsi_ioaccel_raid_map()
5141 return -1; in hpsa_scsi_ioaccel_raid_map()
5144 switch (cmd->cmnd[0]) { in hpsa_scsi_ioaccel_raid_map()
5149 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in hpsa_scsi_ioaccel_raid_map()
5150 (cmd->cmnd[2] << 8) | in hpsa_scsi_ioaccel_raid_map()
5151 cmd->cmnd[3]); in hpsa_scsi_ioaccel_raid_map()
5152 block_cnt = cmd->cmnd[4]; in hpsa_scsi_ioaccel_raid_map()
5161 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5162 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5163 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5164 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5166 (((u32) cmd->cmnd[7]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5167 cmd->cmnd[8]; in hpsa_scsi_ioaccel_raid_map()
5174 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5175 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5176 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5177 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5179 (((u32) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5180 (((u32) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5181 (((u32) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5182 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5189 (((u64) cmd->cmnd[2]) << 56) | in hpsa_scsi_ioaccel_raid_map()
5190 (((u64) cmd->cmnd[3]) << 48) | in hpsa_scsi_ioaccel_raid_map()
5191 (((u64) cmd->cmnd[4]) << 40) | in hpsa_scsi_ioaccel_raid_map()
5192 (((u64) cmd->cmnd[5]) << 32) | in hpsa_scsi_ioaccel_raid_map()
5193 (((u64) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5194 (((u64) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5195 (((u64) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5196 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5198 (((u32) cmd->cmnd[10]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5199 (((u32) cmd->cmnd[11]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5200 (((u32) cmd->cmnd[12]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5201 cmd->cmnd[13]; in hpsa_scsi_ioaccel_raid_map()
5206 last_block = first_block + block_cnt - 1; in hpsa_scsi_ioaccel_raid_map()
5208 /* check for write to non-RAID-0 */ in hpsa_scsi_ioaccel_raid_map()
5209 if (is_write && dev->raid_level != 0) in hpsa_scsi_ioaccel_raid_map()
5213 if (last_block >= le64_to_cpu(map->volume_blk_cnt) || in hpsa_scsi_ioaccel_raid_map()
5218 blocks_per_row = le16_to_cpu(map->data_disks_per_row) * in hpsa_scsi_ioaccel_raid_map()
5219 le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5220 strip_size = le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5228 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5229 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5239 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5240 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5250 total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_scsi_ioaccel_raid_map()
5251 le16_to_cpu(map->metadata_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5252 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5253 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5256 switch (dev->raid_level) { in hpsa_scsi_ioaccel_raid_map()
5261 * (2-drive R1 and R10 with even # of drives.) in hpsa_scsi_ioaccel_raid_map()
5265 if (le16_to_cpu(map->layout_map_count) != 2) { in hpsa_scsi_ioaccel_raid_map()
5269 if (dev->offload_to_mirror) in hpsa_scsi_ioaccel_raid_map()
5270 map_index += le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5271 dev->offload_to_mirror = !dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5274 /* Handles N-way mirrors (R1-ADM) in hpsa_scsi_ioaccel_raid_map()
5278 if (le16_to_cpu(map->layout_map_count) != 3) { in hpsa_scsi_ioaccel_raid_map()
5283 offload_to_mirror = dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5289 le16_to_cpu(map->layout_map_count) - 1) in hpsa_scsi_ioaccel_raid_map()
5291 dev->offload_to_mirror = offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5292 /* Avoid direct use of dev->offload_to_mirror within this in hpsa_scsi_ioaccel_raid_map()
5294 * increment it beyond the range of dev->layout_map_count -1. in hpsa_scsi_ioaccel_raid_map()
5299 if (le16_to_cpu(map->layout_map_count) <= 1) in hpsa_scsi_ioaccel_raid_map()
5304 le16_to_cpu(map->strip_size) * in hpsa_scsi_ioaccel_raid_map()
5305 le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5311 le16_to_cpu(map->layout_map_count); in hpsa_scsi_ioaccel_raid_map()
5359 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5362 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5374 r5or6_first_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5376 r5or6_last_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5382 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5383 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5386 (le16_to_cpu(map->row_cnt) * total_disks_per_row)) + in hpsa_scsi_ioaccel_raid_map()
5396 c->phys_disk = dev->phys_disk[map_index]; in hpsa_scsi_ioaccel_raid_map()
5397 if (!c->phys_disk) in hpsa_scsi_ioaccel_raid_map()
5401 disk_block = le64_to_cpu(map->disk_starting_blk) + in hpsa_scsi_ioaccel_raid_map()
5402 first_row * le16_to_cpu(map->strip_size) + in hpsa_scsi_ioaccel_raid_map()
5403 (first_row_offset - first_column * in hpsa_scsi_ioaccel_raid_map()
5404 le16_to_cpu(map->strip_size)); in hpsa_scsi_ioaccel_raid_map()
5408 if (map->phys_blk_shift) { in hpsa_scsi_ioaccel_raid_map()
5409 disk_block <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5410 disk_block_cnt <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5447 dev->scsi3addr, in hpsa_scsi_ioaccel_raid_map()
5448 dev->phys_disk[map_index]); in hpsa_scsi_ioaccel_raid_map()
5460 cmd->host_scribble = (unsigned char *) c; in hpsa_ciss_submit()
5461 c->cmd_type = CMD_SCSI; in hpsa_ciss_submit()
5462 c->scsi_cmd = cmd; in hpsa_ciss_submit()
5463 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_ciss_submit()
5464 memcpy(&c->Header.LUN.LunAddrBytes[0], &dev->scsi3addr[0], 8); in hpsa_ciss_submit()
5465 c->Header.tag = cpu_to_le64((c->cmdindex << DIRECT_LOOKUP_SHIFT)); in hpsa_ciss_submit()
5469 c->Request.Timeout = 0; in hpsa_ciss_submit()
5470 BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB)); in hpsa_ciss_submit()
5471 c->Request.CDBLen = cmd->cmd_len; in hpsa_ciss_submit()
5472 memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len); in hpsa_ciss_submit()
5473 switch (cmd->sc_data_direction) { in hpsa_ciss_submit()
5475 c->Request.type_attr_dir = in hpsa_ciss_submit()
5479 c->Request.type_attr_dir = in hpsa_ciss_submit()
5483 c->Request.type_attr_dir = in hpsa_ciss_submit()
5488 * and sets both inlen and outlen to non-zero. ( see in hpsa_ciss_submit()
5492 c->Request.type_attr_dir = in hpsa_ciss_submit()
5496 * response, but non-fibre backends appear to let it in hpsa_ciss_submit()
5505 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5506 cmd->sc_data_direction); in hpsa_ciss_submit()
5516 if (dev->in_reset) { in hpsa_ciss_submit()
5521 c->device = dev; in hpsa_ciss_submit()
5535 c->Header.tag = cpu_to_le64((u64) (index << DIRECT_LOOKUP_SHIFT)); in hpsa_cmd_init()
5536 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5537 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5538 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_init()
5539 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5540 + index * sizeof(*c->err_info); in hpsa_cmd_init()
5541 c->cmdindex = index; in hpsa_cmd_init()
5542 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_init()
5543 c->ErrDesc.Addr = cpu_to_le64((u64) err_dma_handle); in hpsa_cmd_init()
5544 c->ErrDesc.Len = cpu_to_le32((u32) sizeof(*c->err_info)); in hpsa_cmd_init()
5545 c->h = h; in hpsa_cmd_init()
5546 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_init()
5553 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5554 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5557 atomic_set(&c->refcount, 0); in hpsa_preinitialize_commands()
5564 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5566 BUG_ON(c->cmdindex != index); in hpsa_cmd_partial_init()
5568 memset(c->Request.CDB, 0, sizeof(c->Request.CDB)); in hpsa_cmd_partial_init()
5569 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_partial_init()
5570 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_partial_init()
5577 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_ioaccel_submit()
5583 if (dev->in_reset) in hpsa_ioaccel_submit()
5589 cmd->host_scribble = (unsigned char *) c; in hpsa_ioaccel_submit()
5591 if (dev->offload_enabled) { in hpsa_ioaccel_submit()
5592 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5593 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5594 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5595 c->device = dev; in hpsa_ioaccel_submit()
5596 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5597 c->retry_pending = true; in hpsa_ioaccel_submit()
5601 } else if (dev->hba_ioaccel_enabled) { in hpsa_ioaccel_submit()
5602 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5603 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5604 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5605 c->device = dev; in hpsa_ioaccel_submit()
5606 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5607 c->retry_pending = true; in hpsa_ioaccel_submit()
5621 cmd = c->scsi_cmd; in hpsa_command_resubmit_worker()
5622 dev = cmd->device->hostdata; in hpsa_command_resubmit_worker()
5624 cmd->result = DID_NO_CONNECT << 16; in hpsa_command_resubmit_worker()
5625 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5628 if (dev->in_reset) { in hpsa_command_resubmit_worker()
5629 cmd->result = DID_RESET << 16; in hpsa_command_resubmit_worker()
5630 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5633 if (c->cmd_type == CMD_IOACCEL2) { in hpsa_command_resubmit_worker()
5634 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker()
5635 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5638 if (c2->error_data.serv_response == in hpsa_command_resubmit_worker()
5650 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5656 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5665 c->retry_pending = true; in hpsa_command_resubmit_worker()
5666 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5675 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5680 /* Running in struct Scsi_Host->host_lock less mode */
5688 /* Get the ptr to our adapter structure out of cmd->host. */ in hpsa_scsi_queue_command()
5689 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5691 BUG_ON(scsi_cmd_to_rq(cmd)->tag < 0); in hpsa_scsi_queue_command()
5693 dev = cmd->device->hostdata; in hpsa_scsi_queue_command()
5695 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5700 if (dev->removed) { in hpsa_scsi_queue_command()
5701 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5707 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5712 if (dev->in_reset) in hpsa_scsi_queue_command()
5723 cmd->result = 0; in hpsa_scsi_queue_command()
5728 * Note: If cmd->retries is non-zero, then this is a SML in hpsa_scsi_queue_command()
5731 * and is therefore a brand-new command. in hpsa_scsi_queue_command()
5733 if (likely(cmd->retries == 0 && in hpsa_scsi_queue_command()
5735 h->acciopath_status)) { in hpsa_scsi_queue_command()
5752 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5753 h->scan_finished = 1; in hpsa_scan_complete()
5754 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5755 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5775 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5776 if (h->scan_waiting) { in hpsa_scan_start()
5777 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5781 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5785 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5786 if (h->scan_finished) in hpsa_scan_start()
5788 h->scan_waiting = 1; in hpsa_scan_start()
5789 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5790 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5797 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5798 h->scan_waiting = 0; in hpsa_scan_start()
5799 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5807 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5808 if (h->reset_in_progress) { in hpsa_scan_start()
5809 h->drv_req_rescan = 1; in hpsa_scan_start()
5810 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5814 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5823 struct hpsa_scsi_dev_t *logical_drive = sdev->hostdata; in hpsa_change_queue_depth()
5826 return -ENODEV; in hpsa_change_queue_depth()
5830 else if (qdepth > logical_drive->queue_depth) in hpsa_change_queue_depth()
5831 qdepth = logical_drive->queue_depth; in hpsa_change_queue_depth()
5843 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5844 finished = h->scan_finished; in hpsa_scan_finished()
5845 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5855 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5856 return -ENOMEM; in hpsa_scsi_host_alloc()
5859 sh->io_port = 0; in hpsa_scsi_host_alloc()
5860 sh->n_io_port = 0; in hpsa_scsi_host_alloc()
5861 sh->this_id = -1; in hpsa_scsi_host_alloc()
5862 sh->max_channel = 3; in hpsa_scsi_host_alloc()
5863 sh->max_cmd_len = MAX_COMMAND_SIZE; in hpsa_scsi_host_alloc()
5864 sh->max_lun = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5865 sh->max_id = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5866 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5867 sh->cmd_per_lun = sh->can_queue; in hpsa_scsi_host_alloc()
5868 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5869 sh->transportt = hpsa_sas_transport_template; in hpsa_scsi_host_alloc()
5870 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5871 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5872 sh->unique_id = sh->irq; in hpsa_scsi_host_alloc()
5874 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5882 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5884 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5887 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5893 * small-integer tag for this request. We use an offset from that value as
5895 * low-numbered entries for our own uses.)
5899 int idx = scsi_cmd_to_rq(scmd)->tag; in hpsa_get_cmd_index()
5910 * reply queue; returns zero if the unit is ready, and non-zero otherwise.
5927 if (c->err_info->CommandStatus == CMD_SUCCESS) in hpsa_send_test_unit_ready()
5935 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in hpsa_send_test_unit_ready()
5936 c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION && in hpsa_send_test_unit_ready()
5937 (c->err_info->SenseInfo[2] == NO_SENSE || in hpsa_send_test_unit_ready()
5938 c->err_info->SenseInfo[2] == UNIT_ATTENTION)) in hpsa_send_test_unit_ready()
5946 * returns zero when the unit is ready, and non-zero when giving up.
5973 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
6000 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6013 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6015 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6022 * complaining. Doing a host- or bus-reset can't do anything good here.
6035 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6039 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6040 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6041 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6048 dev = scsicmd->device->hostdata; in hpsa_eh_device_reset_handler()
6050 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6055 if (dev->devtype == TYPE_ENCLOSURE) { in hpsa_eh_device_reset_handler()
6081 if (is_hba_lunid(dev->scsi3addr)) { in hpsa_eh_device_reset_handler()
6086 if (is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_eh_device_reset_handler()
6098 dev->in_reset = true; /* block any new cmds from OS for this device */ in hpsa_eh_device_reset_handler()
6100 if (atomic_read(&dev->commands_outstanding) > 0) in hpsa_eh_device_reset_handler()
6119 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6120 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6122 dev->in_reset = false; in hpsa_eh_device_reset_handler()
6123 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6138 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6140 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6141 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6142 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6156 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6157 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6161 h->last_collision_tag = idx; in cmd_tagged_alloc()
6166 atomic_inc(&c->refcount); in cmd_tagged_alloc()
6173 c->retry_pending = false; in cmd_tagged_alloc()
6184 (void)atomic_dec(&c->refcount); in cmd_tagged_free()
6203 * There is some *extremely* small but non-zero chance that that in cmd_alloc()
6217 * reserved for driver-initiated requests, while requests from the block in cmd_alloc()
6222 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6229 c = h->cmd_pool + i; in cmd_alloc()
6230 refcount = atomic_inc_return(&c->refcount); in cmd_alloc()
6236 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6240 c->device = NULL; in cmd_alloc()
6246 c->retry_pending = false; in cmd_alloc()
6254 * cmd_tagged_alloc() in which case the ref-count decrement does the trick and
6255 * the clear-bit is harmless.
6259 if (atomic_dec_and_test(&c->refcount)) { in cmd_free()
6262 i = c - h->cmd_pool; in cmd_free()
6263 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6279 return -EINVAL; in hpsa_ioctl32_passthru()
6283 return -EFAULT; in hpsa_ioctl32_passthru()
6284 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_passthru()
6285 return -EFAULT; in hpsa_ioctl32_passthru()
6288 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6289 return -EAGAIN; in hpsa_ioctl32_passthru()
6291 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6294 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_passthru()
6295 sizeof(arg32->error_info))) in hpsa_ioctl32_passthru()
6296 return -EFAULT; in hpsa_ioctl32_passthru()
6310 return -EINVAL; in hpsa_ioctl32_big_passthru()
6314 return -EFAULT; in hpsa_ioctl32_big_passthru()
6315 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_big_passthru()
6316 return -EFAULT; in hpsa_ioctl32_big_passthru()
6319 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6320 return -EAGAIN; in hpsa_ioctl32_big_passthru()
6322 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6325 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_big_passthru()
6326 sizeof(arg32->error_info))) in hpsa_ioctl32_big_passthru()
6327 return -EFAULT; in hpsa_ioctl32_big_passthru()
6358 return -ENOIOCTLCMD; in hpsa_compat_ioctl()
6368 return -EINVAL; in hpsa_getpciinfo_ioctl()
6369 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6370 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6371 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6372 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6374 return -EFAULT; in hpsa_getpciinfo_ioctl()
6387 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6395 return -EINVAL; in hpsa_getdrivver_ioctl()
6397 return -EFAULT; in hpsa_getdrivver_ioctl()
6410 return -EPERM; in hpsa_passthru_ioctl()
6411 if ((iocommand->buf_size < 1) && in hpsa_passthru_ioctl()
6412 (iocommand->Request.Type.Direction != XFER_NONE)) { in hpsa_passthru_ioctl()
6413 return -EINVAL; in hpsa_passthru_ioctl()
6415 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6416 buff = kmalloc(iocommand->buf_size, GFP_KERNEL); in hpsa_passthru_ioctl()
6418 return -ENOMEM; in hpsa_passthru_ioctl()
6419 if (iocommand->Request.Type.Direction & XFER_WRITE) { in hpsa_passthru_ioctl()
6421 if (copy_from_user(buff, iocommand->buf, in hpsa_passthru_ioctl()
6422 iocommand->buf_size)) { in hpsa_passthru_ioctl()
6423 rc = -EFAULT; in hpsa_passthru_ioctl()
6427 memset(buff, 0, iocommand->buf_size); in hpsa_passthru_ioctl()
6433 c->cmd_type = CMD_IOCTL_PEND; in hpsa_passthru_ioctl()
6434 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_passthru_ioctl()
6436 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_passthru_ioctl()
6437 if (iocommand->buf_size > 0) { /* buffer to fill */ in hpsa_passthru_ioctl()
6438 c->Header.SGList = 1; in hpsa_passthru_ioctl()
6439 c->Header.SGTotal = cpu_to_le16(1); in hpsa_passthru_ioctl()
6441 c->Header.SGList = 0; in hpsa_passthru_ioctl()
6442 c->Header.SGTotal = cpu_to_le16(0); in hpsa_passthru_ioctl()
6444 memcpy(&c->Header.LUN, &iocommand->LUN_info, sizeof(c->Header.LUN)); in hpsa_passthru_ioctl()
6447 memcpy(&c->Request, &iocommand->Request, in hpsa_passthru_ioctl()
6448 sizeof(c->Request)); in hpsa_passthru_ioctl()
6451 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6452 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6453 iocommand->buf_size, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6454 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6455 c->SG[0].Addr = cpu_to_le64(0); in hpsa_passthru_ioctl()
6456 c->SG[0].Len = cpu_to_le32(0); in hpsa_passthru_ioctl()
6457 rc = -ENOMEM; in hpsa_passthru_ioctl()
6460 c->SG[0].Addr = cpu_to_le64(temp64); in hpsa_passthru_ioctl()
6461 c->SG[0].Len = cpu_to_le32(iocommand->buf_size); in hpsa_passthru_ioctl()
6462 c->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* not chaining */ in hpsa_passthru_ioctl()
6466 if (iocommand->buf_size > 0) in hpsa_passthru_ioctl()
6467 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6470 rc = -EIO; in hpsa_passthru_ioctl()
6475 memcpy(&iocommand->error_info, c->err_info, in hpsa_passthru_ioctl()
6476 sizeof(iocommand->error_info)); in hpsa_passthru_ioctl()
6477 if ((iocommand->Request.Type.Direction & XFER_READ) && in hpsa_passthru_ioctl()
6478 iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6480 if (copy_to_user(iocommand->buf, buff, iocommand->buf_size)) { in hpsa_passthru_ioctl()
6481 rc = -EFAULT; in hpsa_passthru_ioctl()
6506 return -EPERM; in hpsa_big_passthru_ioctl()
6508 if ((ioc->buf_size < 1) && in hpsa_big_passthru_ioctl()
6509 (ioc->Request.Type.Direction != XFER_NONE)) in hpsa_big_passthru_ioctl()
6510 return -EINVAL; in hpsa_big_passthru_ioctl()
6512 if (ioc->malloc_size > MAX_KMALLOC_SIZE) in hpsa_big_passthru_ioctl()
6513 return -EINVAL; in hpsa_big_passthru_ioctl()
6514 if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD) in hpsa_big_passthru_ioctl()
6515 return -EINVAL; in hpsa_big_passthru_ioctl()
6518 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6523 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6526 left = ioc->buf_size; in hpsa_big_passthru_ioctl()
6527 data_ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6529 sz = (left > ioc->malloc_size) ? ioc->malloc_size : left; in hpsa_big_passthru_ioctl()
6533 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6536 if (ioc->Request.Type.Direction & XFER_WRITE) { in hpsa_big_passthru_ioctl()
6538 status = -EFAULT; in hpsa_big_passthru_ioctl()
6543 left -= sz; in hpsa_big_passthru_ioctl()
6549 c->cmd_type = CMD_IOCTL_PEND; in hpsa_big_passthru_ioctl()
6550 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_big_passthru_ioctl()
6551 c->Header.ReplyQueue = 0; in hpsa_big_passthru_ioctl()
6552 c->Header.SGList = (u8) sg_used; in hpsa_big_passthru_ioctl()
6553 c->Header.SGTotal = cpu_to_le16(sg_used); in hpsa_big_passthru_ioctl()
6554 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN)); in hpsa_big_passthru_ioctl()
6555 memcpy(&c->Request, &ioc->Request, sizeof(c->Request)); in hpsa_big_passthru_ioctl()
6556 if (ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6559 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6561 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6563 c->SG[i].Addr = cpu_to_le64(0); in hpsa_big_passthru_ioctl()
6564 c->SG[i].Len = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6565 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6567 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6570 c->SG[i].Addr = cpu_to_le64(temp64); in hpsa_big_passthru_ioctl()
6571 c->SG[i].Len = cpu_to_le32(buff_size[i]); in hpsa_big_passthru_ioctl()
6572 c->SG[i].Ext = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6574 c->SG[--i].Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_big_passthru_ioctl()
6579 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6582 status = -EIO; in hpsa_big_passthru_ioctl()
6587 memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info)); in hpsa_big_passthru_ioctl()
6588 if ((ioc->Request.Type.Direction & XFER_READ) && ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6592 BYTE __user *ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6595 status = -EFAULT; in hpsa_big_passthru_ioctl()
6619 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in check_ioctl_unit_attention()
6620 c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) in check_ioctl_unit_attention()
6637 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6647 return -EINVAL; in hpsa_ioctl()
6649 return -EFAULT; in hpsa_ioctl()
6650 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6651 return -EAGAIN; in hpsa_ioctl()
6653 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6655 rc = -EFAULT; in hpsa_ioctl()
6661 return -EINVAL; in hpsa_ioctl()
6663 return -EFAULT; in hpsa_ioctl()
6664 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6665 return -EAGAIN; in hpsa_ioctl()
6667 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6669 rc = -EFAULT; in hpsa_ioctl()
6673 return -ENOTTY; in hpsa_ioctl()
6686 c->Request.CDB[1] = reset_type; /* fill_cmd defaults to target reset */ in hpsa_send_host_reset()
6687 c->waiting = NULL; in hpsa_send_host_reset()
6691 * re-initializing everything, so it doesn't matter and won't leak. in hpsa_send_host_reset()
6702 c->cmd_type = CMD_IOCTL_PEND; in fill_cmd()
6703 c->scsi_cmd = SCSI_CMD_BUSY; in fill_cmd()
6704 c->Header.ReplyQueue = 0; in fill_cmd()
6706 c->Header.SGList = 1; in fill_cmd()
6707 c->Header.SGTotal = cpu_to_le16(1); in fill_cmd()
6709 c->Header.SGList = 0; in fill_cmd()
6710 c->Header.SGTotal = cpu_to_le16(0); in fill_cmd()
6712 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8); in fill_cmd()
6719 c->Request.CDB[1] = 0x01; in fill_cmd()
6720 c->Request.CDB[2] = (page_code & 0xff); in fill_cmd()
6722 c->Request.CDBLen = 6; in fill_cmd()
6723 c->Request.type_attr_dir = in fill_cmd()
6725 c->Request.Timeout = 0; in fill_cmd()
6726 c->Request.CDB[0] = HPSA_INQUIRY; in fill_cmd()
6727 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6730 c->Request.CDBLen = 6; in fill_cmd()
6731 c->Request.type_attr_dir = in fill_cmd()
6733 c->Request.Timeout = 0; in fill_cmd()
6734 c->Request.CDB[0] = cmd; in fill_cmd()
6735 c->Request.CDB[1] = 1; in fill_cmd()
6736 c->Request.CDB[2] = 1; in fill_cmd()
6737 c->Request.CDB[3] = (size >> 8) & 0xFF; in fill_cmd()
6738 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6745 c->Request.CDBLen = 12; in fill_cmd()
6746 c->Request.type_attr_dir = in fill_cmd()
6748 c->Request.Timeout = 0; in fill_cmd()
6749 c->Request.CDB[0] = cmd; in fill_cmd()
6750 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6751 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6752 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6753 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6756 c->Request.CDBLen = 16; in fill_cmd()
6757 c->Request.type_attr_dir = in fill_cmd()
6759 c->Request.Timeout = 0; in fill_cmd()
6761 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6762 c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS; in fill_cmd()
6765 c->Request.CDBLen = 16; in fill_cmd()
6766 c->Request.type_attr_dir = in fill_cmd()
6769 c->Request.Timeout = 0; in fill_cmd()
6770 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6771 c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS; in fill_cmd()
6774 c->Request.CDBLen = 12; in fill_cmd()
6775 c->Request.type_attr_dir = in fill_cmd()
6778 c->Request.Timeout = 0; in fill_cmd()
6779 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6780 c->Request.CDB[6] = BMIC_CACHE_FLUSH; in fill_cmd()
6781 c->Request.CDB[7] = (size >> 8) & 0xFF; in fill_cmd()
6782 c->Request.CDB[8] = size & 0xFF; in fill_cmd()
6785 c->Request.CDBLen = 6; in fill_cmd()
6786 c->Request.type_attr_dir = in fill_cmd()
6788 c->Request.Timeout = 0; in fill_cmd()
6791 c->Request.CDBLen = 12; in fill_cmd()
6792 c->Request.type_attr_dir = in fill_cmd()
6794 c->Request.Timeout = 0; in fill_cmd()
6795 c->Request.CDB[0] = HPSA_CISS_READ; in fill_cmd()
6796 c->Request.CDB[1] = cmd; in fill_cmd()
6797 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6798 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6799 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6800 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6803 c->Request.CDBLen = 10; in fill_cmd()
6804 c->Request.type_attr_dir = in fill_cmd()
6806 c->Request.Timeout = 0; in fill_cmd()
6807 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6808 c->Request.CDB[6] = BMIC_SENSE_CONTROLLER_PARAMETERS; in fill_cmd()
6809 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6810 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6813 c->Request.CDBLen = 10; in fill_cmd()
6814 c->Request.type_attr_dir = in fill_cmd()
6816 c->Request.Timeout = 0; in fill_cmd()
6817 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6818 c->Request.CDB[6] = BMIC_IDENTIFY_PHYSICAL_DEVICE; in fill_cmd()
6819 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6820 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6823 c->Request.CDBLen = 10; in fill_cmd()
6824 c->Request.type_attr_dir = in fill_cmd()
6826 c->Request.Timeout = 0; in fill_cmd()
6827 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6828 c->Request.CDB[6] = BMIC_SENSE_SUBSYSTEM_INFORMATION; in fill_cmd()
6829 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6830 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6833 c->Request.CDBLen = 10; in fill_cmd()
6834 c->Request.type_attr_dir = in fill_cmd()
6836 c->Request.Timeout = 0; in fill_cmd()
6837 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6838 c->Request.CDB[6] = BMIC_SENSE_STORAGE_BOX_PARAMS; in fill_cmd()
6839 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6840 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6843 c->Request.CDBLen = 10; in fill_cmd()
6844 c->Request.type_attr_dir = in fill_cmd()
6846 c->Request.Timeout = 0; in fill_cmd()
6847 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6848 c->Request.CDB[1] = 0; in fill_cmd()
6849 c->Request.CDB[2] = 0; in fill_cmd()
6850 c->Request.CDB[3] = 0; in fill_cmd()
6851 c->Request.CDB[4] = 0; in fill_cmd()
6852 c->Request.CDB[5] = 0; in fill_cmd()
6853 c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER; in fill_cmd()
6854 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6855 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6856 c->Request.CDB[9] = 0; in fill_cmd()
6859 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6866 c->Request.CDBLen = 16; in fill_cmd()
6867 c->Request.type_attr_dir = in fill_cmd()
6869 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6870 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6871 c->Request.CDB[0] = HPSA_RESET; in fill_cmd()
6872 c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE; in fill_cmd()
6873 /* Physical target reset needs no control bytes 4-7*/ in fill_cmd()
6874 c->Request.CDB[4] = 0x00; in fill_cmd()
6875 c->Request.CDB[5] = 0x00; in fill_cmd()
6876 c->Request.CDB[6] = 0x00; in fill_cmd()
6877 c->Request.CDB[7] = 0x00; in fill_cmd()
6880 c->Request.CDBLen = 16; in fill_cmd()
6881 c->Request.type_attr_dir = in fill_cmd()
6883 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6884 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6885 c->Request.CDB[0] = cmd; in fill_cmd()
6886 c->Request.CDB[1] = HPSA_RESET_TYPE_LUN; in fill_cmd()
6887 /* If bytes 4-7 are zero, it means reset the */ in fill_cmd()
6889 c->Request.CDB[4] = 0x00; in fill_cmd()
6890 c->Request.CDB[5] = 0x00; in fill_cmd()
6891 c->Request.CDB[6] = 0x00; in fill_cmd()
6892 c->Request.CDB[7] = 0x00; in fill_cmd()
6895 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6900 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6904 switch (GET_DIR(c->Request.type_attr_dir)) { in fill_cmd()
6917 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6918 return -1; in fill_cmd()
6928 ulong page_offs = ((ulong) base) - page_base; in remap_pci_mem()
6937 return h->access.command_completed(h, q); in get_next_completion()
6942 return h->access.intr_pending(h); in interrupt_pending()
6947 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6948 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6954 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6955 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6963 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6964 if (likely(c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_SCSI in finish_cmd()
6965 || c->cmd_type == CMD_IOACCEL2)) in finish_cmd()
6967 else if (c->cmd_type == CMD_IOCTL_PEND || c->cmd_type == IOACCEL2_TMF) in finish_cmd()
6968 complete(c->waiting); in finish_cmd()
6980 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6995 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6998 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
7005 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7006 * Relies on (h-q[x] == x) being true for x such that
7011 return container_of((queue - *queue), struct ctlr_info, q[0]); in queue_to_hba()
7025 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7043 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7058 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7075 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7098 sizeof(cmd->ErrorDescriptor); in hpsa_message()
7107 return -ENOMEM; in hpsa_message()
7109 /* The Inbound Post Queue only accepts 32-bit physical addresses for the in hpsa_message()
7113 err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_message()
7119 cmd = dma_alloc_coherent(&pdev->dev, cmd_sz, &paddr64, GFP_KERNEL); in hpsa_message()
7122 return -ENOMEM; in hpsa_message()
7125 /* This must fit, because of the 32-bit consistent DMA mask. Also, in hpsa_message()
7127 * least 4-byte aligned (most likely, it's page-aligned). in hpsa_message()
7131 cmd->CommandHeader.ReplyQueue = 0; in hpsa_message()
7132 cmd->CommandHeader.SGList = 0; in hpsa_message()
7133 cmd->CommandHeader.SGTotal = cpu_to_le16(0); in hpsa_message()
7134 cmd->CommandHeader.tag = cpu_to_le64(paddr64); in hpsa_message()
7135 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8); in hpsa_message()
7137 cmd->Request.CDBLen = 16; in hpsa_message()
7138 cmd->Request.type_attr_dir = in hpsa_message()
7140 cmd->Request.Timeout = 0; /* Don't time out */ in hpsa_message()
7141 cmd->Request.CDB[0] = opcode; in hpsa_message()
7142 cmd->Request.CDB[1] = type; in hpsa_message()
7143 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */ in hpsa_message()
7144 cmd->ErrorDescriptor.Addr = in hpsa_message()
7146 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo)); in hpsa_message()
7163 dev_err(&pdev->dev, "controller message %02x:%02x timed out\n", in hpsa_message()
7165 return -ETIMEDOUT; in hpsa_message()
7168 dma_free_coherent(&pdev->dev, cmd_sz, cmd, paddr64); in hpsa_message()
7171 dev_err(&pdev->dev, "controller message %02x:%02x failed\n", in hpsa_message()
7173 return -EIO; in hpsa_message()
7176 dev_info(&pdev->dev, "controller message %02x:%02x succeeded\n", in hpsa_message()
7192 dev_info(&pdev->dev, "using doorbell to reset controller\n"); in hpsa_controller_hard_reset()
7213 dev_info(&pdev->dev, "using PCI PM to reset controller\n"); in hpsa_controller_hard_reset()
7240 strncpy(driver_version, HPSA " " HPSA_DRIVER_VERSION, len - 1); in init_driver_version()
7246 int i, size = sizeof(cfgtable->driver_version); in write_driver_ver_to_cfgtable()
7250 return -ENOMEM; in write_driver_ver_to_cfgtable()
7254 writeb(driver_version[i], &cfgtable->driver_version[i]); in write_driver_ver_to_cfgtable()
7264 for (i = 0; i < sizeof(cfgtable->driver_version); i++) in read_driver_ver_from_cfgtable()
7265 driver_ver[i] = readb(&cfgtable->driver_version[i]); in read_driver_ver_from_cfgtable()
7272 int rc, size = sizeof(cfgtable->driver_version); in controller_reset_failed()
7276 return -ENOMEM; in controller_reset_failed()
7318 dev_warn(&pdev->dev, "Controller not resettable\n"); in hpsa_kdump_hard_reset_controller()
7319 return -ENODEV; in hpsa_kdump_hard_reset_controller()
7322 /* if controller is soft- but not hard resettable... */ in hpsa_kdump_hard_reset_controller()
7324 return -ENOTSUPP; /* try soft reset later. */ in hpsa_kdump_hard_reset_controller()
7336 return -ENOMEM; in hpsa_kdump_hard_reset_controller()
7346 rc = -ENOMEM; in hpsa_kdump_hard_reset_controller()
7356 misc_fw_support = readl(&cfgtable->misc_fw_support); in hpsa_kdump_hard_reset_controller()
7363 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7365 rc = -ENOTSUPP; /* try soft reset */ in hpsa_kdump_hard_reset_controller()
7383 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7392 dev_warn(&pdev->dev, "Unable to successfully reset " in hpsa_kdump_hard_reset_controller()
7394 rc = -ENOTSUPP; in hpsa_kdump_hard_reset_controller()
7396 dev_info(&pdev->dev, "board ready after hard reset.\n"); in hpsa_kdump_hard_reset_controller()
7419 dev_info(dev, "------------------------------------\n"); in print_cfg_table()
7421 temp_name[i] = readb(&(tb->Signature[i])); in print_cfg_table()
7424 dev_info(dev, " Spec Number = %d\n", readl(&(tb->SpecValence))); in print_cfg_table()
7426 readl(&(tb->TransportSupport))); in print_cfg_table()
7428 readl(&(tb->TransportActive))); in print_cfg_table()
7430 readl(&(tb->HostWrite.TransportRequest))); in print_cfg_table()
7432 readl(&(tb->HostWrite.CoalIntDelay))); in print_cfg_table()
7434 readl(&(tb->HostWrite.CoalIntCount))); in print_cfg_table()
7436 readl(&(tb->CmdsOutMax))); in print_cfg_table()
7437 dev_info(dev, " Bus Types = 0x%x\n", readl(&(tb->BusTypes))); in print_cfg_table()
7439 temp_name[i] = readb(&(tb->ServerName[i])); in print_cfg_table()
7443 readl(&(tb->HeartBeat))); in print_cfg_table()
7470 dev_warn(&pdev->dev, in find_PCI_BAR_index()
7472 return -1; in find_PCI_BAR_index()
7475 if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) in find_PCI_BAR_index()
7478 return -1; in find_PCI_BAR_index()
7483 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7484 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7492 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7493 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7498 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7504 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7507 /* If MSI/MSI-X is supported by the kernel we will try to enable it on
7516 switch (h->board_id) { in hpsa_interrupt_mode()
7523 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7526 h->msix_vectors = ret; in hpsa_interrupt_mode()
7534 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7546 subsystem_vendor_id = pdev->subsystem_vendor; in hpsa_lookup_board_id()
7547 subsystem_device_id = pdev->subsystem_device; in hpsa_lookup_board_id()
7558 dev_warn(&pdev->dev, in hpsa_lookup_board_id()
7566 dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x\n", *board_id); in hpsa_lookup_board_id()
7569 return ARRAY_SIZE(products) - 1; /* generic unknown smart array */ in hpsa_lookup_board_id()
7581 dev_dbg(&pdev->dev, "memory BAR = %lx\n", in hpsa_pci_find_memory_BAR()
7585 dev_warn(&pdev->dev, "no memory BAR found\n"); in hpsa_pci_find_memory_BAR()
7586 return -ENODEV; in hpsa_pci_find_memory_BAR()
7610 dev_warn(&pdev->dev, "board not ready, timed out.\n"); in hpsa_wait_for_board_state()
7611 return -ENODEV; in hpsa_wait_for_board_state()
7622 if (*cfg_base_addr_index == -1) { in hpsa_find_cfg_addrs()
7623 dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n"); in hpsa_find_cfg_addrs()
7624 return -ENODEV; in hpsa_find_cfg_addrs()
7631 if (h->transtable) { in hpsa_free_cfgtables()
7632 iounmap(h->transtable); in hpsa_free_cfgtables()
7633 h->transtable = NULL; in hpsa_free_cfgtables()
7635 if (h->cfgtable) { in hpsa_free_cfgtables()
7636 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7637 h->cfgtable = NULL; in hpsa_free_cfgtables()
7652 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7656 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7657 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7658 if (!h->cfgtable) { in hpsa_find_cfgtables()
7659 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7660 return -ENOMEM; in hpsa_find_cfgtables()
7662 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7666 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7667 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7669 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7670 if (!h->transtable) { in hpsa_find_cfgtables()
7671 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7673 return -ENOMEM; in hpsa_find_cfgtables()
7683 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7686 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7687 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7689 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7690 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7692 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7694 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7704 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7714 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7715 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7716 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7718 /* Limit in-command s/g elements to 32 save dma'able memory. */ in hpsa_find_board_params()
7719 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7720 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7721 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7728 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7729 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7730 h->chainsize = 0; in hpsa_find_board_params()
7734 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7735 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7736 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7737 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7738 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7739 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7740 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7745 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7746 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7756 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7762 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7772 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7774 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7776 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7786 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7787 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7788 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7794 return -ENODEV; in hpsa_wait_for_clear_event_notify_ack()
7810 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7812 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7813 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7814 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7820 return -ENODEV; in hpsa_wait_for_mode_change_ack()
7825 /* return -ENODEV or other reason on error, 0 on success */
7830 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7832 return -ENOTSUPP; in hpsa_enter_simple_mode()
7834 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7837 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7838 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7839 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7842 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7843 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7845 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7848 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7849 return -ENODEV; in hpsa_enter_simple_mode()
7856 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7857 h->vaddr = NULL; in hpsa_free_pci_init()
7861 * Documentation/driver-api/pci/pci.rst in hpsa_free_pci_init()
7863 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7864 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7873 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7876 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7877 h->access = *(products[prod_index].access); in hpsa_pci_init()
7878 h->legacy_board = legacy_board; in hpsa_pci_init()
7879 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7882 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7885 pci_disable_device(h->pdev); in hpsa_pci_init()
7889 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7891 dev_err(&h->pdev->dev, in hpsa_pci_init()
7893 pci_disable_device(h->pdev); in hpsa_pci_init()
7897 pci_set_master(h->pdev); in hpsa_pci_init()
7906 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7909 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7910 if (!h->vaddr) { in hpsa_pci_init()
7911 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7912 err = -ENOMEM; in hpsa_pci_init()
7915 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7924 err = -ENODEV; in hpsa_pci_init()
7937 iounmap(h->vaddr); in hpsa_pci_init()
7938 h->vaddr = NULL; in hpsa_pci_init()
7944 * Documentation/driver-api/pci/pci.rst in hpsa_pci_init()
7946 pci_disable_device(h->pdev); in hpsa_pci_init()
7947 pci_release_regions(h->pdev); in hpsa_pci_init()
7956 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7957 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7960 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7962 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7963 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
7976 * the pci interface. The dev->enable_cnt is equal zero in hpsa_init_reset_devices()
7981 dev_warn(&pdev->dev, "Failed to enable PCI device\n"); in hpsa_init_reset_devices()
7982 return -ENODEV; in hpsa_init_reset_devices()
7988 dev_warn(&pdev->dev, "failed to enable device.\n"); in hpsa_init_reset_devices()
7989 return -ENODEV; in hpsa_init_reset_devices()
7996 rc = -ENOMEM; in hpsa_init_reset_devices()
8002 /* Reset the controller with a PCI power-cycle or via doorbell */ in hpsa_init_reset_devices()
8005 /* -ENOTSUPP here means we cannot reset the controller in hpsa_init_reset_devices()
8013 /* Now try to get the controller to respond to a no-op */ in hpsa_init_reset_devices()
8014 dev_info(&pdev->dev, "Waiting for controller to respond to no-op\n"); in hpsa_init_reset_devices()
8019 dev_warn(&pdev->dev, "no-op failed%s\n", in hpsa_init_reset_devices()
8020 (i < 11 ? "; re-trying" : "")); in hpsa_init_reset_devices()
8031 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8032 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8033 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8034 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8035 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8036 h->cmd_pool, in hpsa_free_cmd_pool()
8037 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8038 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8039 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8041 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8042 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8043 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8044 h->errinfo_pool, in hpsa_free_cmd_pool()
8045 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8046 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8047 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8053 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8054 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8055 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8056 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8057 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8058 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8059 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8060 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8061 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8062 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8063 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8070 return -ENOMEM; in hpsa_alloc_cmd_pool()
8073 /* clear affinity hints and free MSI-X, MSI, or legacy INTx vectors */
8080 irq_vector = h->intr_mode; in hpsa_free_irqs()
8082 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8084 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8085 &h->q[h->intr_mode]); in hpsa_free_irqs()
8086 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8090 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8091 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8092 h->q[i] = 0; in hpsa_free_irqs()
8095 h->q[i] = 0; in hpsa_free_irqs()
8098 /* returns 0 on success; cleans up and returns -Enn on error */
8107 irq_vector = h->intr_mode; in hpsa_request_irqs()
8110 * initialize h->q[x] = x so that interrupt handlers know which in hpsa_request_irqs()
8114 h->q[i] = (u8) i; in hpsa_request_irqs()
8116 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8117 /* If performant mode and MSI-X, use multiple reply queues */ in hpsa_request_irqs()
8118 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8119 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8120 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8121 0, h->intrname[i], in hpsa_request_irqs()
8122 &h->q[i]); in hpsa_request_irqs()
8126 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8128 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8130 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8131 h->q[j] = 0; in hpsa_request_irqs()
8134 h->q[j] = 0; in hpsa_request_irqs()
8140 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8141 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8142 h->msix_vectors ? "x" : ""); 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()
8148 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8149 "%s-intx", h->devname); in hpsa_request_irqs()
8150 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8152 h->intrname[0], in hpsa_request_irqs()
8153 &h->q[h->intr_mode]); in hpsa_request_irqs()
8157 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8158 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8160 return -ENODEV; in hpsa_request_irqs()
8170 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8171 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8173 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8177 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8178 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8180 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8192 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8193 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8195 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8196 h->reply_queue_size, in hpsa_free_reply_queues()
8197 h->reply_queue[i].head, in hpsa_free_reply_queues()
8198 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8199 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8200 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8202 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8211 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8212 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8214 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8215 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8216 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8217 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8218 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8220 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8221 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8222 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8224 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8225 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8226 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8239 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8240 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8241 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8242 refcount = atomic_inc_return(&c->refcount); in fail_all_outstanding_cmds()
8244 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in fail_all_outstanding_cmds()
8246 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8251 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8261 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8264 wmb(); /* be sure the per-cpu variables are out to memory */ in set_lockup_detected_for_all_cpus()
8272 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8273 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8274 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8277 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8279 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8283 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8284 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8285 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8287 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8288 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8290 pci_disable_device(h->pdev); in controller_lockup_detected()
8302 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8303 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8311 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8312 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8316 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8317 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8318 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8319 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8325 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8326 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8357 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8361 device = h->dev[i]; in hpsa_set_ioaccel_status()
8365 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8371 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8393 * If ioaccel is to be re-enabled, re-enable later during the in hpsa_set_ioaccel_status()
8403 * transformation - change to the LVs of an Array. in hpsa_set_ioaccel_status()
8404 * degraded volume - component failure in hpsa_set_ioaccel_status()
8416 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8420 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8422 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8423 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8425 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8427 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8430 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8434 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8436 h->events, event_type); in hpsa_ack_ctlr_events()
8437 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()
8442 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8445 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8446 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8455 * Also check flag for driver-initiated rescan.
8459 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8460 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8464 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8467 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8468 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8480 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8481 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8484 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8485 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8486 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8487 list_del(&d->offline_list); in hpsa_offline_devices_ready()
8488 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8491 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8493 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8506 if (!h->lastlogicals) in hpsa_luns_changed()
8514 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8518 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8519 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8521 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8538 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8539 if (h->reset_in_progress) { in hpsa_perform_rescan()
8540 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8541 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8544 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8546 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8550 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8563 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8564 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8565 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8568 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8575 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8576 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8577 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8579 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8588 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8589 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8590 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8593 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8595 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8597 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8599 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8604 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8605 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8606 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8607 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8608 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8621 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8622 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8623 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8624 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8625 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8633 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8635 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8642 kfree(h->reply_map); in hpda_free_ctlr_info()
8654 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8655 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8675 dev_warn(&pdev->dev, "Board ID not found\n"); in hpsa_init_one()
8681 if (rc != -ENOTSUPP) in hpsa_init_one()
8684 * a proper hard reset, so returns -ENOTSUPP) we can try to do in hpsa_init_one()
8694 /* Command structures must be aligned on a 32-byte boundary because in hpsa_init_one()
8701 dev_err(&pdev->dev, "Failed to allocate controller head\n"); in hpsa_init_one()
8702 return -ENOMEM; in hpsa_init_one()
8705 h->pdev = pdev; in hpsa_init_one()
8707 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8708 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8709 spin_lock_init(&h->lock); in hpsa_init_one()
8710 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8711 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8712 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8713 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8715 /* Allocate and clear per-cpu variable lockup_detected */ in hpsa_init_one()
8716 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8717 if (!h->lockup_detected) { in hpsa_init_one()
8718 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8719 rc = -ENOMEM; in hpsa_init_one()
8728 /* relies on h-> settings made by hpsa_pci_init, including in hpsa_init_one()
8729 * interrupt_mode h->intr */ in hpsa_init_one()
8734 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8735 h->ctlr = number_of_controllers; in hpsa_init_one()
8739 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); in hpsa_init_one()
8741 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_init_one()
8743 dev_err(&pdev->dev, "no suitable DMA available\n"); in hpsa_init_one()
8749 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8760 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8761 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8762 mutex_init(&h->reset_mutex); in hpsa_init_one()
8763 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8764 h->scan_waiting = 0; in hpsa_init_one()
8767 h->ndevices = 0; in hpsa_init_one()
8769 spin_lock_init(&h->devlock); in hpsa_init_one()
8775 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8776 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8777 rc = -ENOMEM; in hpsa_init_one()
8781 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8782 if (!h->resubmit_wq) { in hpsa_init_one()
8783 rc = -ENOMEM; in hpsa_init_one()
8787 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8788 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8789 rc = -ENOMEM; in hpsa_init_one()
8807 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8808 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8809 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8814 dev_warn(&h->pdev->dev, in hpsa_init_one()
8835 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8836 dev_info(&h->pdev->dev, in hpsa_init_one()
8838 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8840 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8842 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8844 dev_info(&h->pdev->dev, in hpsa_init_one()
8847 /* since the controller's reset, we have to go back and re-init in hpsa_init_one()
8855 return -ENODEV; in hpsa_init_one()
8861 h->acciopath_status = 1; in hpsa_init_one()
8863 h->discovery_polling = 0; in hpsa_init_one()
8867 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8871 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8872 if (!h->lastlogicals) in hpsa_init_one()
8873 dev_info(&h->pdev->dev, in hpsa_init_one()
8882 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8883 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8884 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8885 h->heartbeat_sample_interval); in hpsa_init_one()
8886 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8887 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8888 h->heartbeat_sample_interval); in hpsa_init_one()
8889 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8890 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8895 kfree(h->lastlogicals); in hpsa_init_one()
8898 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8906 scsi_host_put(h->scsi_host); in hpsa_init_one()
8907 h->scsi_host = NULL; in hpsa_init_one()
8911 if (h->lockup_detected) { in hpsa_init_one()
8912 free_percpu(h->lockup_detected); in hpsa_init_one()
8913 h->lockup_detected = NULL; in hpsa_init_one()
8916 if (h->resubmit_wq) { in hpsa_init_one()
8917 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8918 h->resubmit_wq = NULL; in hpsa_init_one()
8920 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8921 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8922 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8924 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8925 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8926 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8954 if (c->err_info->CommandStatus != 0) in hpsa_flush_cache()
8956 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8972 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8988 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9000 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9010 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9017 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9031 * To write all data in the battery backed cache to disks in __hpsa_shutdown()
9034 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9049 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9050 kfree(h->dev[i]); in hpsa_free_device_info()
9051 h->dev[i] = NULL; in hpsa_free_device_info()
9061 dev_err(&pdev->dev, "unable to remove device\n"); in hpsa_remove_one()
9067 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9068 h->remove_in_progress = 1; in hpsa_remove_one()
9069 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9070 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9071 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9072 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9073 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9074 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9075 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9085 if (h->scsi_host) in hpsa_remove_one()
9086 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9087 /* includes hpsa_free_irqs - init_one 4 */ in hpsa_remove_one()
9088 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9093 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9094 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9099 kfree(h->lastlogicals); in hpsa_remove_one()
9103 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9104 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9106 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9109 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9110 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9118 return -ENOSYS; in hpsa_suspend()
9124 return -ENOSYS; in hpsa_resume()
9173 * return -ENODEV on err, 0 on success (or no action)
9195 * with the number of 16-byte blocks a command of that size requires. in hpsa_enter_performant_mode()
9197 * the largest command possible requires SG_ENTRIES_IN_CMD + 4 16-byte in hpsa_enter_performant_mode()
9230 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9231 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9235 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9237 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9240 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9241 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9242 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9243 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9245 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9246 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9247 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9248 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9251 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9252 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9258 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9259 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9263 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9265 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9266 "performant mode problem - doorbell timeout\n"); in hpsa_enter_performant_mode()
9267 return -ENODEV; in hpsa_enter_performant_mode()
9269 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9271 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9272 "performant mode problem - transport not active\n"); in hpsa_enter_performant_mode()
9273 return -ENODEV; in hpsa_enter_performant_mode()
9276 h->access = access; in hpsa_enter_performant_mode()
9277 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9285 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9286 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9287 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9288 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9290 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9291 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9292 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9295 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9296 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9298 h->reply_queue_size); in hpsa_enter_performant_mode()
9303 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9304 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9306 cp->function = IOACCEL1_FUNCTION_SCSIIO; in hpsa_enter_performant_mode()
9307 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9309 cp->err_info_len = sizeof(struct ErrorInfo); in hpsa_enter_performant_mode()
9310 cp->sgl_offset = IOACCEL1_SGLOFFSET; in hpsa_enter_performant_mode()
9311 cp->host_context_flags = in hpsa_enter_performant_mode()
9313 cp->timeout_sec = 0; in hpsa_enter_performant_mode()
9314 cp->ReplyQueue = 0; in hpsa_enter_performant_mode()
9315 cp->tag = in hpsa_enter_performant_mode()
9317 cp->host_addr = in hpsa_enter_performant_mode()
9318 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9325 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9328 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9329 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9330 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9331 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9334 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9335 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9339 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9341 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9343 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9345 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9346 "performant mode problem - enabling ioaccel mode\n"); in hpsa_enter_performant_mode()
9347 return -ENODEV; in hpsa_enter_performant_mode()
9355 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9356 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9357 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9358 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9359 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9360 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9361 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9363 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9364 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9370 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9371 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9372 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9373 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 /* Command structures must be aligned on a 128-byte boundary in hpsa_alloc_ioaccel1_cmd_and_bft()
9381 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9382 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9386 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9387 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9390 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9391 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9394 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9395 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9400 return -ENOMEM; in hpsa_alloc_ioaccel1_cmd_and_bft()
9408 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9409 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9410 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9411 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9412 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9413 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9414 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9416 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9417 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9427 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9428 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9429 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9434 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9435 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9439 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9440 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9443 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9444 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9445 rc = -ENOMEM; in hpsa_alloc_ioaccel2_cmd_and_bft()
9453 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9454 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9465 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9466 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9472 /* return -ENODEV on error, 0 on success (or no action)
9483 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9498 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9501 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9503 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9504 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9505 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9506 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9508 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9509 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9512 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9513 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9514 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9518 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9520 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9521 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9531 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9532 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9542 return c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_IOACCEL2; in is_accelerated_cmd()
9553 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9554 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9555 refcount = atomic_inc_return(&c->refcount); in hpsa_drain_accel_commands()
9576 phy = sas_phy_alloc(hpsa_sas_port->parent_node->parent_dev, in hpsa_alloc_sas_phy()
9577 hpsa_sas_port->next_phy_index); in hpsa_alloc_sas_phy()
9583 hpsa_sas_port->next_phy_index++; in hpsa_alloc_sas_phy()
9584 hpsa_sas_phy->phy = phy; in hpsa_alloc_sas_phy()
9585 hpsa_sas_phy->parent_port = hpsa_sas_port; in hpsa_alloc_sas_phy()
9592 struct sas_phy *phy = hpsa_sas_phy->phy; in hpsa_free_sas_phy()
9594 sas_port_delete_phy(hpsa_sas_phy->parent_port->port, phy); in hpsa_free_sas_phy()
9595 if (hpsa_sas_phy->added_to_port) in hpsa_free_sas_phy()
9596 list_del(&hpsa_sas_phy->phy_list_entry); in hpsa_free_sas_phy()
9608 hpsa_sas_port = hpsa_sas_phy->parent_port; in hpsa_sas_port_add_phy()
9609 phy = hpsa_sas_phy->phy; in hpsa_sas_port_add_phy()
9611 identify = &phy->identify; in hpsa_sas_port_add_phy()
9613 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_phy()
9614 identify->device_type = SAS_END_DEVICE; in hpsa_sas_port_add_phy()
9615 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9616 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9617 phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9618 phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9619 phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9620 phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9621 phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9623 rc = sas_phy_add(hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9627 sas_port_add_phy(hpsa_sas_port->port, hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9628 list_add_tail(&hpsa_sas_phy->phy_list_entry, in hpsa_sas_port_add_phy()
9629 &hpsa_sas_port->phy_list_head); in hpsa_sas_port_add_phy()
9630 hpsa_sas_phy->added_to_port = true; in hpsa_sas_port_add_phy()
9641 identify = &rphy->identify; in hpsa_sas_port_add_rphy()
9642 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_rphy()
9643 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9644 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9661 INIT_LIST_HEAD(&hpsa_sas_port->phy_list_head); in hpsa_alloc_sas_port()
9662 hpsa_sas_port->parent_node = hpsa_sas_node; in hpsa_alloc_sas_port()
9664 port = sas_port_alloc_num(hpsa_sas_node->parent_dev); in hpsa_alloc_sas_port()
9672 hpsa_sas_port->port = port; in hpsa_alloc_sas_port()
9673 hpsa_sas_port->sas_address = sas_address; in hpsa_alloc_sas_port()
9674 list_add_tail(&hpsa_sas_port->port_list_entry, in hpsa_alloc_sas_port()
9675 &hpsa_sas_node->port_list_head); in hpsa_alloc_sas_port()
9693 &hpsa_sas_port->phy_list_head, phy_list_entry) in hpsa_free_sas_port()
9696 sas_port_delete(hpsa_sas_port->port); in hpsa_free_sas_port()
9697 list_del(&hpsa_sas_port->port_list_entry); in hpsa_free_sas_port()
9707 hpsa_sas_node->parent_dev = parent_dev; in hpsa_alloc_sas_node()
9708 INIT_LIST_HEAD(&hpsa_sas_node->port_list_head); in hpsa_alloc_sas_node()
9723 &hpsa_sas_node->port_list_head, port_list_entry) in hpsa_free_sas_node()
9736 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9737 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9738 if (!device->sas_port) in hpsa_find_device_by_sas_rphy()
9740 if (device->sas_port->rphy == rphy) in hpsa_find_device_by_sas_rphy()
9755 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9759 return -ENOMEM; in hpsa_add_sas_host()
9761 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9763 rc = -ENODEV; in hpsa_add_sas_host()
9769 rc = -ENODEV; in hpsa_add_sas_host()
9777 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9782 sas_phy_free(hpsa_sas_phy->phy); in hpsa_add_sas_host()
9794 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9804 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, device->sas_address); in hpsa_add_sas_device()
9806 return -ENOMEM; in hpsa_add_sas_device()
9808 rphy = sas_end_device_alloc(hpsa_sas_port->port); in hpsa_add_sas_device()
9810 rc = -ENODEV; in hpsa_add_sas_device()
9814 hpsa_sas_port->rphy = rphy; in hpsa_add_sas_device()
9815 device->sas_port = hpsa_sas_port; in hpsa_add_sas_device()
9827 device->sas_port = NULL; in hpsa_add_sas_device()
9834 if (device->sas_port) { in hpsa_remove_sas_device()
9835 hpsa_free_sas_port(device->sas_port); in hpsa_remove_sas_device()
9836 device->sas_port = NULL; in hpsa_remove_sas_device()
9854 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9859 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9863 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9865 *identifier = sd->eli; in hpsa_sas_get_enclosure_identifier()
9873 return -ENXIO; in hpsa_sas_get_bay_identifier()
9902 return -EINVAL; in hpsa_sas_phy_speed()
9927 return -ENODEV; in hpsa_init()