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},
338 unsigned long *priv = shost_priv(sdev->host); in sdev_to_hba()
350 return c->scsi_cmd == SCSI_CMD_IDLE; in hpsa_is_cmd_idle()
353 /* extract sense key, asc, and ascq from sense data. -1 means invalid. */
360 *sense_key = -1; in decode_sense_data()
361 *asc = -1; in decode_sense_data()
362 *ascq = -1; in decode_sense_data()
381 if (c->err_info->SenseLen > sizeof(c->err_info->SenseInfo)) in check_for_unit_attention()
382 sense_len = sizeof(c->err_info->SenseInfo); in check_for_unit_attention()
384 sense_len = c->err_info->SenseLen; in check_for_unit_attention()
386 decode_sense_data(c->err_info->SenseInfo, sense_len, in check_for_unit_attention()
393 dev_warn(&h->pdev->dev, in check_for_unit_attention()
395 h->devname); in check_for_unit_attention()
398 dev_warn(&h->pdev->dev, in check_for_unit_attention()
399 "%s: LUN failure detected\n", h->devname); in check_for_unit_attention()
402 dev_warn(&h->pdev->dev, in check_for_unit_attention()
403 "%s: report LUN data changed\n", h->devname); in check_for_unit_attention()
410 dev_warn(&h->pdev->dev, in check_for_unit_attention()
412 h->devname); in check_for_unit_attention()
415 dev_warn(&h->pdev->dev, in check_for_unit_attention()
417 h->devname); in check_for_unit_attention()
420 dev_warn(&h->pdev->dev, in check_for_unit_attention()
422 h->devname); in check_for_unit_attention()
430 if (c->err_info->CommandStatus != CMD_TARGET_STATUS || in check_for_busy()
431 (c->err_info->ScsiStatus != SAM_STAT_BUSY && in check_for_busy()
432 c->err_info->ScsiStatus != SAM_STAT_TASK_SET_FULL)) in check_for_busy()
434 dev_warn(&h->pdev->dev, HPSA "device busy"); in check_for_busy()
461 return -EACCES; in host_store_hp_ssd_smart_path_status()
463 return -EINVAL; in host_store_hp_ssd_smart_path_status()
465 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
466 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
468 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
481 return -EACCES; in host_store_raid_offload_debug()
483 return -EINVAL; in host_store_raid_offload_debug()
487 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
488 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
489 h->raid_offload_debug); in host_store_raid_offload_debug()
500 hpsa_scan_start(h->scsi_host); in host_store_rescan()
506 device->offload_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
507 device->offload_to_be_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
518 if (!h->hba_inquiry_data) in host_show_firmware_revision()
520 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
532 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
543 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
555 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
593 * which share a battery backed cache module. One controls the
638 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
656 #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
657 #define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)
661 return !device->physical_device; in is_logical_device()
676 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
677 hdev = sdev->hostdata; in raid_level_show()
679 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
680 return -ENODEV; in raid_level_show()
685 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
690 rlevel = hdev->raid_level; in raid_level_show()
691 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
709 spin_lock_irqsave(&h->lock, flags); in lunid_show()
710 hdev = sdev->hostdata; in lunid_show()
712 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
713 return -ENODEV; in lunid_show()
715 memcpy(lunid, hdev->scsi3addr, sizeof(lunid)); in lunid_show()
716 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
731 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
732 hdev = sdev->hostdata; in unique_id_show()
734 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
735 return -ENODEV; in unique_id_show()
737 memcpy(sn, hdev->device_id, sizeof(sn)); in unique_id_show()
738 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
759 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
760 hdev = sdev->hostdata; in sas_address_show()
761 if (!hdev || is_logical_device(hdev) || !hdev->expose_device) { in sas_address_show()
762 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
763 return -ENODEV; in sas_address_show()
765 sas_address = hdev->sas_address; in sas_address_show()
766 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
782 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
783 hdev = sdev->hostdata; in host_show_hp_ssd_smart_path_enabled()
785 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
786 return -ENODEV; in host_show_hp_ssd_smart_path_enabled()
788 offload_enabled = hdev->offload_enabled; in host_show_hp_ssd_smart_path_enabled()
789 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
791 if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) in host_show_hp_ssd_smart_path_enabled()
816 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
817 hdev = sdev->hostdata; in path_info_show()
819 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
820 return -ENODEV; in path_info_show()
823 bay = hdev->bay; in path_info_show()
826 if (i == hdev->active_path_index) in path_info_show()
828 else if (hdev->path_map & path_map_index) in path_info_show()
834 PAGE_SIZE - output_len, in path_info_show()
836 h->scsi_host->host_no, in path_info_show()
837 hdev->bus, hdev->target, hdev->lun, in path_info_show()
838 scsi_device_type(hdev->devtype)); in path_info_show()
840 if (hdev->devtype == TYPE_RAID || is_logical_device(hdev)) { in path_info_show()
842 PAGE_SIZE - output_len, in path_info_show()
847 box = hdev->box[i]; in path_info_show()
848 memcpy(&phys_connector, &hdev->phys_connector[i], in path_info_show()
855 PAGE_SIZE - output_len, in path_info_show()
858 if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) && in path_info_show()
859 hdev->expose_device) { in path_info_show()
862 PAGE_SIZE - output_len, in path_info_show()
867 PAGE_SIZE - output_len, in path_info_show()
873 PAGE_SIZE - output_len, "BOX: %hhu %s\n", in path_info_show()
877 PAGE_SIZE - output_len, "%s\n", active); in path_info_show()
880 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
891 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
901 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
971 .this_id = -1,
989 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
991 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
992 return h->access.command_completed(h, q); in next_command()
994 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
995 return h->access.command_completed(h, q); in next_command()
997 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) { in next_command()
998 a = rq->head[rq->current_entry]; in next_command()
999 rq->current_entry++; in next_command()
1000 atomic_dec(&h->commands_outstanding); in next_command()
1005 if (rq->current_entry == h->max_commands) { in next_command()
1006 rq->current_entry = 0; in next_command()
1007 rq->wraparound ^= 1; in next_command()
1019 * bits 1-3 = block fetch table entry
1020 * bits 4-6 = command type (== 0)
1024 * bits 1-3 = block fetch table entry
1025 * bits 4-6 = command type (== 110)
1033 * bits 1-4 = block fetch table entry (note extra bit)
1034 * bits 4-6 = not needed, because ioaccel2 mode has
1040 * set bit 0 for pull model, bits 3-1 for block fetch
1043 #define DEFAULT_REPLY_QUEUE (-1)
1047 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1048 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1049 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1051 c->Header.ReplyQueue = reply_queue; in set_performant_mode()
1059 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1065 cp->ReplyQueue = reply_queue; in set_ioaccel1_performant_mode()
1068 * - performant mode bit (bit 0) in set_ioaccel1_performant_mode()
1069 * - pull count (bits 1-3) in set_ioaccel1_performant_mode()
1070 * - command type (bits 4-6) in set_ioaccel1_performant_mode()
1072 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1081 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1086 cp->reply_queue = reply_queue; in set_ioaccel2_tmf_performant_mode()
1088 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_tmf_performant_mode()
1089 * - pull count (bits 0-3) in set_ioaccel2_tmf_performant_mode()
1090 * - command type isn't needed for ioaccel2 in set_ioaccel2_tmf_performant_mode()
1092 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1099 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1105 cp->reply_queue = reply_queue; in set_ioaccel2_performant_mode()
1108 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_performant_mode()
1109 * - pull count (bits 0-3) in set_ioaccel2_performant_mode()
1110 * - command type isn't needed for ioaccel2 in set_ioaccel2_performant_mode()
1112 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1131 if (!is_firmware_flash_cmd(c->Request.CDB)) in dial_down_lockup_detection_during_fw_flash()
1133 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1134 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1140 if (is_firmware_flash_cmd(c->Request.CDB) && in dial_up_lockup_detection_on_fw_flash_complete()
1141 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1142 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1149 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1153 if (c->device && !c->retry_pending) in __enqueue_cmd_and_start_io()
1154 atomic_inc(&c->device->commands_outstanding); in __enqueue_cmd_and_start_io()
1156 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1157 switch (c->cmd_type) { in __enqueue_cmd_and_start_io()
1160 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1164 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1168 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1172 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1188 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1190 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1199 * assumes h->devlock is held in hpsa_find_target_lun()
1206 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1207 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1208 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1227 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1230 switch (dev->devtype) { in hpsa_show_dev_msg()
1239 if (dev->external) in hpsa_show_dev_msg()
1241 else if (!is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_show_dev_msg()
1245 snprintf(label, LABEL_SIZE, "RAID-%s", in hpsa_show_dev_msg()
1246 dev->raid_level > RAID_UNKNOWN ? "?" : in hpsa_show_dev_msg()
1247 raid_label[dev->raid_level]); in hpsa_show_dev_msg()
1263 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1265 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1267 scsi_device_type(dev->devtype), in hpsa_show_dev_msg()
1268 dev->vendor, in hpsa_show_dev_msg()
1269 dev->model, in hpsa_show_dev_msg()
1271 dev->offload_config ? '+' : '-', in hpsa_show_dev_msg()
1272 dev->offload_to_be_enabled ? '+' : '-', in hpsa_show_dev_msg()
1273 dev->expose_device); in hpsa_show_dev_msg()
1276 /* Add an entry into h->dev[] array. */
1281 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1282 int n = h->ndevices; in hpsa_scsi_add_entry()
1288 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1290 return -1; in hpsa_scsi_add_entry()
1294 if (device->lun != -1) in hpsa_scsi_add_entry()
1298 /* If this device a non-zero lun of a multi-lun device in hpsa_scsi_add_entry()
1299 * byte 4 of the 8-byte LUN addr will contain the logical in hpsa_scsi_add_entry()
1302 if (device->scsi3addr[4] == 0) { in hpsa_scsi_add_entry()
1303 /* This is not a non-zero lun of a multi-lun device */ in hpsa_scsi_add_entry()
1304 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1305 device->bus, &device->target, &device->lun) != 0) in hpsa_scsi_add_entry()
1306 return -1; in hpsa_scsi_add_entry()
1310 /* This is a non-zero lun of a multi-lun device. in hpsa_scsi_add_entry()
1316 memcpy(addr1, device->scsi3addr, 8); in hpsa_scsi_add_entry()
1320 sd = h->dev[i]; in hpsa_scsi_add_entry()
1321 memcpy(addr2, sd->scsi3addr, 8); in hpsa_scsi_add_entry()
1326 device->bus = sd->bus; in hpsa_scsi_add_entry()
1327 device->target = sd->target; in hpsa_scsi_add_entry()
1328 device->lun = device->scsi3addr[4]; in hpsa_scsi_add_entry()
1332 if (device->lun == -1) { in hpsa_scsi_add_entry()
1333 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1336 return -1; in hpsa_scsi_add_entry()
1341 h->dev[n] = device; in hpsa_scsi_add_entry()
1342 h->ndevices++; in hpsa_scsi_add_entry()
1346 device->expose_device ? "added" : "masked"); in hpsa_scsi_add_entry()
1353 * Update an entry in h->dev[] array.
1358 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1362 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1367 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1370 if (new_entry->offload_config && new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1377 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1379 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1380 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1382 if (new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1383 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1386 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1387 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1388 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1389 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1393 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1396 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1401 if (!new_entry->offload_to_be_enabled) in hpsa_scsi_update_entry()
1402 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1404 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1407 /* Replace an entry from h->dev[] array. */
1413 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1415 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1422 if (new_entry->target == -1) { in hpsa_scsi_replace_entry()
1423 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1424 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1427 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1434 /* Remove an entry from h->dev[] array. */
1438 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1444 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1445 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1448 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1449 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1450 h->ndevices--; in hpsa_scsi_remove_entry()
1467 /* called when scsi_add_device fails in order to re-adjust in fixup_botched_add()
1468 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1473 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1474 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1475 if (h->dev[i] == added) { in fixup_botched_add()
1476 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1477 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1478 h->ndevices--; in fixup_botched_add()
1482 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1493 if (memcmp(dev1->scsi3addr, dev2->scsi3addr, in device_is_the_same()
1494 sizeof(dev1->scsi3addr)) != 0) in device_is_the_same()
1496 if (memcmp(dev1->device_id, dev2->device_id, in device_is_the_same()
1497 sizeof(dev1->device_id)) != 0) in device_is_the_same()
1499 if (memcmp(dev1->model, dev2->model, sizeof(dev1->model)) != 0) in device_is_the_same()
1501 if (memcmp(dev1->vendor, dev2->vendor, sizeof(dev1->vendor)) != 0) in device_is_the_same()
1503 if (dev1->devtype != dev2->devtype) in device_is_the_same()
1505 if (dev1->bus != dev2->bus) in device_is_the_same()
1517 if (dev1->raid_level != dev2->raid_level) in device_updated()
1519 if (dev1->offload_config != dev2->offload_config) in device_updated()
1521 if (dev1->offload_to_be_enabled != dev2->offload_to_be_enabled) in device_updated()
1523 if (!is_logical_dev_addr_mode(dev1->scsi3addr)) in device_updated()
1524 if (dev1->queue_depth != dev2->queue_depth) in device_updated()
1535 if (dev1->ioaccel_handle != dev2->ioaccel_handle) in device_updated()
1563 if (SCSI3ADDR_EQ(needle->scsi3addr, haystack[i]->scsi3addr)) { in hpsa_scsi_find_entry()
1571 if (needle->volume_offline) in hpsa_scsi_find_entry()
1577 *index = -1; in hpsa_scsi_find_entry()
1588 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1589 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1590 if (memcmp(device->scsi3addr, scsi3addr, in hpsa_monitor_offline_device()
1591 sizeof(device->scsi3addr)) == 0) { in hpsa_monitor_offline_device()
1592 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1596 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1603 memcpy(device->scsi3addr, scsi3addr, sizeof(device->scsi3addr)); in hpsa_monitor_offline_device()
1604 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1605 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1606 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1613 if (sd->volume_offline == HPSA_VPD_LV_STATUS_UNSUPPORTED) in hpsa_show_volume_status()
1614 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1616 h->scsi_host->host_no, in hpsa_show_volume_status()
1617 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1618 switch (sd->volume_offline) { in hpsa_show_volume_status()
1622 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1624 h->scsi_host->host_no, in hpsa_show_volume_status()
1625 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1628 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1630 h->scsi_host->host_no, in hpsa_show_volume_status()
1631 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1634 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1636 h->scsi_host->host_no, in hpsa_show_volume_status()
1637 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1640 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1642 h->scsi_host->host_no, in hpsa_show_volume_status()
1643 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1646 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1648 h->scsi_host->host_no, in hpsa_show_volume_status()
1649 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1652 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1653 …d Volume is not encrypted and cannot be accessed because controller is in encryption-only mode.\n", in hpsa_show_volume_status()
1654 h->scsi_host->host_no, in hpsa_show_volume_status()
1655 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1658 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1660 h->scsi_host->host_no, in hpsa_show_volume_status()
1661 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1664 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1665 "C%d:B%d:T%d:L%d Volume is undergoing encryption re-keying process.\n", in hpsa_show_volume_status()
1666 h->scsi_host->host_no, in hpsa_show_volume_status()
1667 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1670 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1672 h->scsi_host->host_no, in hpsa_show_volume_status()
1673 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1676 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1678 h->scsi_host->host_no, in hpsa_show_volume_status()
1679 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1682 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1684 h->scsi_host->host_no, in hpsa_show_volume_status()
1685 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1698 struct raid_map_data *map = &logical_drive->raid_map; in hpsa_figure_phys_disk_ptrs()
1699 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_figure_phys_disk_ptrs()
1701 int total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_figure_phys_disk_ptrs()
1702 le16_to_cpu(map->metadata_disks_per_row); in hpsa_figure_phys_disk_ptrs()
1703 int nraid_map_entries = le16_to_cpu(map->row_cnt) * in hpsa_figure_phys_disk_ptrs()
1704 le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1706 int nphys_disk = le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1713 logical_drive->nphysical_disks = nraid_map_entries; in hpsa_figure_phys_disk_ptrs()
1717 logical_drive->phys_disk[i] = NULL; in hpsa_figure_phys_disk_ptrs()
1718 if (!logical_drive->offload_config) in hpsa_figure_phys_disk_ptrs()
1723 if (dev[j]->devtype != TYPE_DISK && in hpsa_figure_phys_disk_ptrs()
1724 dev[j]->devtype != TYPE_ZBC) in hpsa_figure_phys_disk_ptrs()
1728 if (dev[j]->ioaccel_handle != dd[i].ioaccel_handle) in hpsa_figure_phys_disk_ptrs()
1731 logical_drive->phys_disk[i] = dev[j]; in hpsa_figure_phys_disk_ptrs()
1733 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1734 logical_drive->phys_disk[i]->queue_depth); in hpsa_figure_phys_disk_ptrs()
1745 if (!logical_drive->phys_disk[i]) { in hpsa_figure_phys_disk_ptrs()
1746 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1749 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1750 logical_drive->target, logical_drive->lun); in hpsa_figure_phys_disk_ptrs()
1752 logical_drive->queue_depth = 8; in hpsa_figure_phys_disk_ptrs()
1760 logical_drive->queue_depth = qdepth; in hpsa_figure_phys_disk_ptrs()
1762 if (logical_drive->external) in hpsa_figure_phys_disk_ptrs()
1763 logical_drive->queue_depth = EXTERNAL_QD; in hpsa_figure_phys_disk_ptrs()
1765 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1777 if (dev[i]->devtype != TYPE_DISK && in hpsa_update_log_drive_phys_drive_ptrs()
1778 dev[i]->devtype != TYPE_ZBC) in hpsa_update_log_drive_phys_drive_ptrs()
1790 * re-configured and thus underwent a transformation, or in hpsa_update_log_drive_phys_drive_ptrs()
1802 if (!dev[i]->offload_enabled && dev[i]->offload_to_be_enabled) in hpsa_update_log_drive_phys_drive_ptrs()
1811 if (!h->scsi_host) in hpsa_add_device()
1815 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1816 device->target, device->lun); in hpsa_add_device()
1818 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1829 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1830 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1831 int refcount = atomic_inc_return(&c->refcount); in hpsa_find_outstanding_commands_for_dev()
1834 dev->scsi3addr)) { in hpsa_find_outstanding_commands_for_dev()
1837 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1840 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1857 if (device->external) in hpsa_wait_for_outstanding_commands_for_dev()
1870 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1873 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1874 device->bus, device->target, device->lun, cmds); in hpsa_wait_for_outstanding_commands_for_dev()
1883 if (!h->scsi_host) in hpsa_remove_device()
1889 device->removed = 1; in hpsa_remove_device()
1893 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1894 device->target, device->lun); in hpsa_remove_device()
1918 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1928 * re-schedule the scan to see what happened. in adjust_hpsa_scsi_table()
1930 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1931 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1932 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1933 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1936 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1942 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1947 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1949 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1950 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1959 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1960 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1981 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
1989 * as the SCSI mid-layer does not handle such devices well. in adjust_hpsa_scsi_table()
1993 if (sd[i]->volume_offline) { in adjust_hpsa_scsi_table()
1999 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2000 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2009 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2014 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2017 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2024 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2025 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2027 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2030 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2033 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2034 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2039 if (sd[i]->volume_offline) in adjust_hpsa_scsi_table()
2040 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2054 if (removed[i]->expose_device) in adjust_hpsa_scsi_table()
2066 if (!(added[i]->expose_device)) in adjust_hpsa_scsi_table()
2071 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2073 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2077 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2087 * Assume's h->devlock is held.
2095 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2096 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2097 if (sd->bus == bus && sd->target == target && sd->lun == lun) in lookup_hpsa_scsi_dev()
2110 spin_lock_irqsave(&h->devlock, flags); in hpsa_sdev_init()
2119 sd->target = sdev_id(sdev); in hpsa_sdev_init()
2120 sd->lun = sdev->lun; in hpsa_sdev_init()
2125 sdev_id(sdev), sdev->lun); in hpsa_sdev_init()
2127 if (sd && sd->expose_device) { in hpsa_sdev_init()
2128 atomic_set(&sd->ioaccel_cmds_out, 0); in hpsa_sdev_init()
2129 sdev->hostdata = sd; in hpsa_sdev_init()
2131 sdev->hostdata = NULL; in hpsa_sdev_init()
2132 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_sdev_init()
2136 /* configure scsi device based on internal per-device structure */
2144 sd = sdev->hostdata; in hpsa_sdev_configure()
2145 sdev->no_uld_attach = !sd || !sd->expose_device; in hpsa_sdev_configure()
2148 sd->was_removed = 0; in hpsa_sdev_configure()
2149 queue_depth = sd->queue_depth != 0 ? in hpsa_sdev_configure()
2150 sd->queue_depth : sdev->host->can_queue; in hpsa_sdev_configure()
2151 if (sd->external) { in hpsa_sdev_configure()
2153 sdev->eh_timeout = HPSA_EH_PTRAID_TIMEOUT; in hpsa_sdev_configure()
2154 blk_queue_rq_timeout(sdev->request_queue, in hpsa_sdev_configure()
2157 if (is_hba_lunid(sd->scsi3addr)) { in hpsa_sdev_configure()
2158 sdev->eh_timeout = CTLR_TIMEOUT; in hpsa_sdev_configure()
2159 blk_queue_rq_timeout(sdev->request_queue, CTLR_TIMEOUT); in hpsa_sdev_configure()
2162 queue_depth = sdev->host->can_queue; in hpsa_sdev_configure()
2174 hdev = sdev->hostdata; in hpsa_sdev_destroy()
2177 hdev->was_removed = 1; in hpsa_sdev_destroy()
2184 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2186 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2187 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2188 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2190 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2191 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2198 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2201 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2202 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2204 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2205 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2206 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2207 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2208 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2211 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2218 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2225 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2227 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2228 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2229 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2231 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2232 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2239 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2242 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2244 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2245 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2247 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2248 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2249 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2251 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2259 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2269 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2270 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_map_ioaccel2_sg_chain_block()
2271 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2273 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2275 cp->sg->address = 0; in hpsa_map_ioaccel2_sg_chain_block()
2276 return -1; in hpsa_map_ioaccel2_sg_chain_block()
2278 cp->sg->address = cpu_to_le64(temp64); in hpsa_map_ioaccel2_sg_chain_block()
2289 chain_sg = cp->sg; in hpsa_unmap_ioaccel2_sg_chain_block()
2290 temp64 = le64_to_cpu(chain_sg->address); in hpsa_unmap_ioaccel2_sg_chain_block()
2291 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_unmap_ioaccel2_sg_chain_block()
2292 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2302 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2303 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2304 chain_sg->Ext = cpu_to_le32(HPSA_SG_CHAIN); in hpsa_map_sg_chain_block()
2306 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2307 chain_sg->Len = cpu_to_le32(chain_len); in hpsa_map_sg_chain_block()
2308 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2310 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2312 chain_sg->Addr = cpu_to_le64(0); in hpsa_map_sg_chain_block()
2313 return -1; in hpsa_map_sg_chain_block()
2315 chain_sg->Addr = cpu_to_le64(temp64); in hpsa_map_sg_chain_block()
2324 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2327 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2328 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2329 le32_to_cpu(chain_sg->Len), DMA_TO_DEVICE); in hpsa_unmap_sg_chain_block()
2347 switch (c2->error_data.serv_response) { in handle_ioaccel_mode2_error()
2349 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2352 cmd->result = 0; in handle_ioaccel_mode2_error()
2355 cmd->result |= SAM_STAT_CHECK_CONDITION; in handle_ioaccel_mode2_error()
2356 if (c2->error_data.data_present != in handle_ioaccel_mode2_error()
2358 memset(cmd->sense_buffer, 0, in handle_ioaccel_mode2_error()
2363 data_len = c2->error_data.sense_data_len; in handle_ioaccel_mode2_error()
2366 if (data_len > sizeof(c2->error_data.sense_data_buff)) in handle_ioaccel_mode2_error()
2368 sizeof(c2->error_data.sense_data_buff); in handle_ioaccel_mode2_error()
2369 memcpy(cmd->sense_buffer, in handle_ioaccel_mode2_error()
2370 c2->error_data.sense_data_buff, data_len); in handle_ioaccel_mode2_error()
2391 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2398 cmd->result = (DID_OK << 16); /* host byte */ in handle_ioaccel_mode2_error()
2400 &c2->error_data.resid_cnt[0]); in handle_ioaccel_mode2_error()
2411 * from going down. This allows the potential re-insert in handle_ioaccel_mode2_error()
2414 if (dev->physical_device && dev->expose_device) { in handle_ioaccel_mode2_error()
2415 cmd->result = DID_NO_CONNECT << 16; in handle_ioaccel_mode2_error()
2416 dev->removed = 1; in handle_ioaccel_mode2_error()
2417 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2418 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2446 if (dev->in_reset) in handle_ioaccel_mode2_error()
2455 struct hpsa_scsi_dev_t *dev = c->device; in hpsa_cmd_resolve_events()
2458 * Reset c->scsi_cmd here so that the reset handler will know in hpsa_cmd_resolve_events()
2462 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_resolve_events()
2465 atomic_dec(&dev->commands_outstanding); in hpsa_cmd_resolve_events()
2466 if (dev->in_reset && in hpsa_cmd_resolve_events()
2467 atomic_read(&dev->commands_outstanding) <= 0) in hpsa_cmd_resolve_events()
2468 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2489 INIT_WORK(&c->work, hpsa_command_resubmit_worker); in hpsa_retry_cmd()
2490 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2497 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2500 if (likely(c2->error_data.serv_response == 0 && in process_ioaccel2_completion()
2501 c2->error_data.status == 0)) { in process_ioaccel2_completion()
2502 cmd->result = 0; in process_ioaccel2_completion()
2512 c2->error_data.serv_response == in process_ioaccel2_completion()
2514 if (c2->error_data.status == in process_ioaccel2_completion()
2519 if (dev->in_reset) { in process_ioaccel2_completion()
2520 cmd->result = DID_RESET << 16; in process_ioaccel2_completion()
2537 u8 tmf_status = cp->err_info->ScsiStatus; in hpsa_evaluate_tmf_status()
2543 * ei->CommandStatus == 0 for this case. in hpsa_evaluate_tmf_status()
2554 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2558 return -tmf_status; in hpsa_evaluate_tmf_status()
2574 ei = cp->err_info; in complete_scsi_command()
2575 cmd = cp->scsi_cmd; in complete_scsi_command()
2576 h = cp->h; in complete_scsi_command()
2578 if (!cmd->device) { in complete_scsi_command()
2579 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2583 dev = cmd->device->hostdata; in complete_scsi_command()
2585 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2588 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2591 if ((cp->cmd_type == CMD_SCSI) && in complete_scsi_command()
2592 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2595 if ((cp->cmd_type == CMD_IOACCEL2) && in complete_scsi_command()
2596 (c2->sg[0].chain_indicator == IOACCEL2_CHAIN)) in complete_scsi_command()
2599 cmd->result = (DID_OK << 16); /* host byte */ in complete_scsi_command()
2602 if (dev->was_removed) { in complete_scsi_command()
2607 if (cp->cmd_type == CMD_IOACCEL2 || cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2608 if (dev->physical_device && dev->expose_device && in complete_scsi_command()
2609 dev->removed) { in complete_scsi_command()
2610 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2613 if (likely(cp->phys_disk != NULL)) in complete_scsi_command()
2614 atomic_dec(&cp->phys_disk->ioaccel_cmds_out); in complete_scsi_command()
2622 if (unlikely(ei->CommandStatus == CMD_CTLR_LOCKUP)) { in complete_scsi_command()
2624 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2628 if (cp->cmd_type == CMD_IOACCEL2) in complete_scsi_command()
2631 scsi_set_resid(cmd, ei->ResidualCnt); in complete_scsi_command()
2632 if (ei->CommandStatus == 0) in complete_scsi_command()
2638 if (cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2639 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2640 cp->Header.SGList = scsi_sg_count(cmd); in complete_scsi_command()
2641 cp->Header.SGTotal = cpu_to_le16(cp->Header.SGList); in complete_scsi_command()
2642 cp->Request.CDBLen = le16_to_cpu(c->io_flags) & in complete_scsi_command()
2644 cp->Header.tag = c->tag; in complete_scsi_command()
2645 memcpy(cp->Header.LUN.LunAddrBytes, c->CISS_LUN, 8); in complete_scsi_command()
2646 memcpy(cp->Request.CDB, c->CDB, cp->Request.CDBLen); in complete_scsi_command()
2653 if (ei->CommandStatus == CMD_IOACCEL_DISABLED) in complete_scsi_command()
2654 dev->offload_enabled = 0; in complete_scsi_command()
2660 switch (ei->CommandStatus) { in complete_scsi_command()
2663 cmd->result |= ei->ScsiStatus; in complete_scsi_command()
2665 if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo)) in complete_scsi_command()
2668 sense_data_size = sizeof(ei->SenseInfo); in complete_scsi_command()
2669 if (ei->SenseLen < sense_data_size) in complete_scsi_command()
2670 sense_data_size = ei->SenseLen; in complete_scsi_command()
2671 memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size); in complete_scsi_command()
2672 if (ei->ScsiStatus) in complete_scsi_command()
2673 decode_sense_data(ei->SenseInfo, sense_data_size, in complete_scsi_command()
2675 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) { in complete_scsi_command()
2678 cmd->result |= DID_SOFT_ERROR << 16; in complete_scsi_command()
2682 h->drv_req_rescan = 1; in complete_scsi_command()
2686 dev->removed = 1; in complete_scsi_command()
2687 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2696 if (ei->ScsiStatus) { in complete_scsi_command()
2697 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2700 cp, ei->ScsiStatus, in complete_scsi_command()
2702 cmd->result); in complete_scsi_command()
2704 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2719 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2726 dev_warn(&h->pdev->dev, in complete_scsi_command()
2727 "CDB %16phN data overrun\n", cp->Request.CDB); in complete_scsi_command()
2732 /* We get CMD_INVALID if you address a non-existent device in complete_scsi_command()
2738 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2742 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2743 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2744 cp->Request.CDB); in complete_scsi_command()
2747 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2748 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2749 cp->Request.CDB); in complete_scsi_command()
2752 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2753 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2754 cp->Request.CDB); in complete_scsi_command()
2757 cmd->result = DID_ABORT << 16; in complete_scsi_command()
2760 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2761 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2762 cp->Request.CDB); in complete_scsi_command()
2765 cmd->result = DID_SOFT_ERROR << 16; /* retry the command */ in complete_scsi_command()
2766 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2767 cp->Request.CDB); in complete_scsi_command()
2770 cmd->result = DID_TIME_OUT << 16; in complete_scsi_command()
2771 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2772 cp->Request.CDB); in complete_scsi_command()
2775 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2776 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2780 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2783 /* This only handles the direct pass-through case since RAID in complete_scsi_command()
2786 cmd->result = DID_SOFT_ERROR << 16; in complete_scsi_command()
2787 dev_warn(&h->pdev->dev, in complete_scsi_command()
2791 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2792 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2793 cp, ei->CommandStatus); in complete_scsi_command()
2805 dma_unmap_single(&pdev->dev, le64_to_cpu(c->SG[i].Addr), in hpsa_pci_unmap()
2806 le32_to_cpu(c->SG[i].Len), in hpsa_pci_unmap()
2819 cp->Header.SGList = 0; in hpsa_map_one()
2820 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2824 addr64 = dma_map_single(&pdev->dev, buf, buflen, data_direction); in hpsa_map_one()
2825 if (dma_mapping_error(&pdev->dev, addr64)) { in hpsa_map_one()
2827 cp->Header.SGList = 0; in hpsa_map_one()
2828 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2829 return -1; in hpsa_map_one()
2831 cp->SG[0].Addr = cpu_to_le64(addr64); in hpsa_map_one()
2832 cp->SG[0].Len = cpu_to_le32(buflen); in hpsa_map_one()
2833 cp->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* we are not chaining */ in hpsa_map_one()
2834 cp->Header.SGList = 1; /* no. SGs contig in this cmd */ in hpsa_map_one()
2835 cp->Header.SGTotal = cpu_to_le16(1); /* total sgs in cmd list */ in hpsa_map_one()
2839 #define NO_TIMEOUT ((unsigned long) -1)
2846 c->waiting = &wait; in hpsa_scsi_do_simple_cmd_core()
2849 /* TODO: get rid of this no-timeout thing */ in hpsa_scsi_do_simple_cmd_core()
2855 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2856 return -ETIMEDOUT; in hpsa_scsi_do_simple_cmd_core()
2865 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in hpsa_scsi_do_simple_cmd()
2877 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2892 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_scsi_do_simple_cmd_with_retry()
2906 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2908 rc = -EIO; in hpsa_scsi_do_simple_cmd_with_retry()
2915 const u8 *cdb = c->Request.CDB; in hpsa_print_cmd()
2916 const u8 *lun = c->Header.LUN.LunAddrBytes; in hpsa_print_cmd()
2918 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2925 const struct ErrorInfo *ei = cp->err_info; in hpsa_scsi_interpret_error()
2926 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2930 switch (ei->CommandStatus) { in hpsa_scsi_interpret_error()
2932 if (ei->SenseLen > sizeof(ei->SenseInfo)) in hpsa_scsi_interpret_error()
2933 sense_len = sizeof(ei->SenseInfo); in hpsa_scsi_interpret_error()
2935 sense_len = ei->SenseLen; in hpsa_scsi_interpret_error()
2936 decode_sense_data(ei->SenseInfo, sense_len, in hpsa_scsi_interpret_error()
2939 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) in hpsa_scsi_interpret_error()
2943 dev_warn(d, "SCSI Status = 0x%02x\n", ei->ScsiStatus); in hpsa_scsi_interpret_error()
2944 if (ei->ScsiStatus == 0) in hpsa_scsi_interpret_error()
2957 * to non-existent targets as invalid commands. in hpsa_scsi_interpret_error()
2993 ei->CommandStatus); in hpsa_scsi_interpret_error()
3007 rc = -1; in hpsa_do_receive_diagnostic()
3014 ei = c->err_info; in hpsa_do_receive_diagnostic()
3015 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_do_receive_diagnostic()
3017 rc = -1; in hpsa_do_receive_diagnostic()
3060 rc = -1; in hpsa_scsi_do_inquiry()
3067 ei = c->err_info; in hpsa_scsi_do_inquiry()
3068 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_inquiry()
3070 rc = -1; in hpsa_scsi_do_inquiry()
3085 c->device = dev; in hpsa_send_reset()
3088 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3091 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3096 ei = c->err_info; in hpsa_send_reset()
3097 if (ei->CommandStatus != 0) { in hpsa_send_reset()
3099 rc = -1; in hpsa_send_reset()
3112 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3118 switch (c->cmd_type) { in hpsa_cmd_dev_match()
3121 match = !memcmp(scsi3addr, &c->Header.LUN.LunAddrBytes, in hpsa_cmd_dev_match()
3122 sizeof(c->Header.LUN.LunAddrBytes)); in hpsa_cmd_dev_match()
3127 if (c->phys_disk == dev) { in hpsa_cmd_dev_match()
3131 /* Possible RAID mode -- check each phys dev. */ in hpsa_cmd_dev_match()
3135 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3138 * match = dev->phys_disk[i]->ioaccel_handle in hpsa_cmd_dev_match()
3139 * == c2->scsi_nexus; */ in hpsa_cmd_dev_match()
3140 match = dev->phys_disk[i] == c->phys_disk; in hpsa_cmd_dev_match()
3146 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3147 match = dev->phys_disk[i]->ioaccel_handle == in hpsa_cmd_dev_match()
3148 le32_to_cpu(ac->it_nexus); in hpsa_cmd_dev_match()
3157 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3158 c->cmd_type); in hpsa_cmd_dev_match()
3171 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3172 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3173 return -EINTR; in hpsa_do_reset()
3179 atomic_dec(&dev->commands_outstanding); in hpsa_do_reset()
3180 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3181 atomic_read(&dev->commands_outstanding) <= 0 || in hpsa_do_reset()
3186 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3188 rc = -ENODEV; in hpsa_do_reset()
3192 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3194 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3230 struct raid_map_disk_data *dd = &map_buff->data[0]; in hpsa_debug_map_buff()
3238 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3241 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3242 le32_to_cpu(map_buff->structure_size)); in hpsa_debug_map_buff()
3243 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3244 le32_to_cpu(map_buff->volume_blk_size)); in hpsa_debug_map_buff()
3245 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3246 le64_to_cpu(map_buff->volume_blk_cnt)); in hpsa_debug_map_buff()
3247 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3248 map_buff->phys_blk_shift); in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3250 map_buff->parity_rotation_shift); in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3252 le16_to_cpu(map_buff->strip_size)); in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3254 le64_to_cpu(map_buff->disk_starting_blk)); in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3256 le64_to_cpu(map_buff->disk_blk_cnt)); in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3258 le16_to_cpu(map_buff->data_disks_per_row)); in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3260 le16_to_cpu(map_buff->metadata_disks_per_row)); in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3262 le16_to_cpu(map_buff->row_cnt)); in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3264 le16_to_cpu(map_buff->layout_map_count)); in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3266 le16_to_cpu(map_buff->flags)); in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3268 le16_to_cpu(map_buff->flags) & in hpsa_debug_map_buff()
3270 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3271 le16_to_cpu(map_buff->dekindex)); in hpsa_debug_map_buff()
3272 map_cnt = le16_to_cpu(map_buff->layout_map_count); in hpsa_debug_map_buff()
3274 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3275 row_cnt = le16_to_cpu(map_buff->row_cnt); in hpsa_debug_map_buff()
3277 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3279 le16_to_cpu(map_buff->data_disks_per_row); in hpsa_debug_map_buff()
3281 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3283 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3284 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3286 le16_to_cpu(map_buff->metadata_disks_per_row); in hpsa_debug_map_buff()
3288 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3290 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3291 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3312 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3313 sizeof(this_device->raid_map), 0, in hpsa_get_raid_map()
3315 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3317 return -1; in hpsa_get_raid_map()
3323 ei = c->err_info; in hpsa_get_raid_map()
3324 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_raid_map()
3326 rc = -1; in hpsa_get_raid_map()
3332 if (le32_to_cpu(this_device->raid_map.structure_size) > in hpsa_get_raid_map()
3333 sizeof(this_device->raid_map)) { in hpsa_get_raid_map()
3334 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3335 rc = -1; in hpsa_get_raid_map()
3337 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3359 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_sense_subsystem_information()
3360 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_sense_subsystem_information()
3366 ei = c->err_info; in hpsa_bmic_sense_subsystem_information()
3367 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_sense_subsystem_information()
3369 rc = -1; in hpsa_bmic_sense_subsystem_information()
3394 ei = c->err_info; in hpsa_bmic_id_controller()
3395 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_controller()
3397 rc = -1; in hpsa_bmic_id_controller()
3418 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_id_physical_device()
3419 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_id_physical_device()
3423 ei = c->err_info; in hpsa_bmic_id_physical_device()
3424 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_physical_device()
3426 rc = -1; in hpsa_bmic_id_physical_device()
3436 * struct ReportExtendedLUNdata *rlep - Used for BMIC drive number
3437 * struct hpsa_scsi_dev_t *encl_dev - device entry for enclosure
3445 int rc = -1; in hpsa_get_enclosure_info()
3456 rle = &rlep->LUN[rle_index]; in hpsa_get_enclosure_info()
3458 encl_dev->eli = in hpsa_get_enclosure_info()
3461 bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); in hpsa_get_enclosure_info()
3463 if (encl_dev->target == -1 || encl_dev->lun == -1) { in hpsa_get_enclosure_info()
3468 if (bmic_device_index == 0xFF00 || MASKED_DEVICE(&rle->lunid[0])) { in hpsa_get_enclosure_info()
3484 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3485 __func__, encl_dev->external, bmic_device_index); in hpsa_get_enclosure_info()
3497 if (id_phys->phys_connector[1] == 'E') in hpsa_get_enclosure_info()
3498 c->Request.CDB[5] = id_phys->box_index; in hpsa_get_enclosure_info()
3500 c->Request.CDB[5] = 0; in hpsa_get_enclosure_info()
3507 ei = c->err_info; in hpsa_get_enclosure_info()
3508 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_enclosure_info()
3509 rc = -1; in hpsa_get_enclosure_info()
3513 encl_dev->box[id_phys->active_path_number] = bssbp->phys_box_on_port; in hpsa_get_enclosure_info()
3514 memcpy(&encl_dev->phys_connector[id_phys->active_path_number], in hpsa_get_enclosure_info()
3515 bssbp->phys_connector, sizeof(bssbp->phys_connector)); in hpsa_get_enclosure_info()
3543 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3547 nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24; in hpsa_get_sas_address_from_report_physical()
3550 if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8)) { in hpsa_get_sas_address_from_report_physical()
3551 sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]); in hpsa_get_sas_address_from_report_physical()
3576 sa = get_unaligned_be64(ssi->primary_world_wide_id); in hpsa_get_sas_address()
3577 h->sas_address = sa; in hpsa_get_sas_address()
3584 dev->sas_address = sa; in hpsa_get_sas_address()
3593 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3596 nphysicals = (get_unaligned_be32(physdev->LUNListLength) / 24) + 1; in hpsa_ext_ctrl_present()
3599 if (physdev->LUN[i].device_type == in hpsa_ext_ctrl_present()
3601 && !is_hba_lunid(physdev->LUN[i].lunid)) { in hpsa_ext_ctrl_present()
3602 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3605 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3669 this_device->offload_config = 0; in hpsa_get_ioaccel_status()
3670 this_device->offload_enabled = 0; in hpsa_get_ioaccel_status()
3671 this_device->offload_to_be_enabled = 0; in hpsa_get_ioaccel_status()
3687 this_device->offload_config = in hpsa_get_ioaccel_status()
3689 if (this_device->offload_config) { in hpsa_get_ioaccel_status()
3699 this_device->offload_to_be_enabled = 1; in hpsa_get_ioaccel_status()
3721 return -ENOMEM; in hpsa_get_device_id()
3733 return rc; /*0 - got id, otherwise, didn't */ in hpsa_get_device_id()
3751 rc = -EAGAIN; in hpsa_scsi_do_report_luns()
3755 c->Request.CDB[1] = extended_response; in hpsa_scsi_do_report_luns()
3760 ei = c->err_info; in hpsa_scsi_do_report_luns()
3761 if (ei->CommandStatus != 0 && in hpsa_scsi_do_report_luns()
3762 ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_report_luns()
3764 rc = -EIO; in hpsa_scsi_do_report_luns()
3768 if (rld->extended_response_flag != extended_response) { in hpsa_scsi_do_report_luns()
3769 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3770 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3773 rld->extended_response_flag); in hpsa_scsi_do_report_luns()
3774 rc = -EINVAL; in hpsa_scsi_do_report_luns()
3776 rc = -EOPNOTSUPP; in hpsa_scsi_do_report_luns()
3792 if (!rc || rc != -EOPNOTSUPP) in hpsa_scsi_do_report_phys_luns()
3798 return -ENOMEM; in hpsa_scsi_do_report_phys_luns()
3807 nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 8; in hpsa_scsi_do_report_phys_luns()
3809 memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8); in hpsa_scsi_do_report_phys_luns()
3824 device->bus = bus; in hpsa_set_bus_target_lun()
3825 device->target = target; in hpsa_set_bus_target_lun()
3826 device->lun = lun; in hpsa_set_bus_target_lun()
3895 sense = c->err_info->SenseInfo; in hpsa_volume_offline()
3896 if (c->err_info->SenseLen > sizeof(c->err_info->SenseInfo)) in hpsa_volume_offline()
3897 sense_len = sizeof(c->err_info->SenseInfo); in hpsa_volume_offline()
3899 sense_len = c->err_info->SenseLen; in hpsa_volume_offline()
3939 #define OBDR_TAPE_SIG "$DR-10" in hpsa_update_device_info()
3940 #define OBDR_SIG_LEN (sizeof(OBDR_TAPE_SIG) - 1) in hpsa_update_device_info()
3949 rc = -ENOMEM; in hpsa_update_device_info()
3956 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3966 this_device->devtype = (inq_buff[0] & 0x1f); in hpsa_update_device_info()
3967 memcpy(this_device->scsi3addr, scsi3addr, 8); in hpsa_update_device_info()
3968 memcpy(this_device->vendor, &inq_buff[8], in hpsa_update_device_info()
3969 sizeof(this_device->vendor)); in hpsa_update_device_info()
3970 memcpy(this_device->model, &inq_buff[16], in hpsa_update_device_info()
3971 sizeof(this_device->model)); in hpsa_update_device_info()
3972 this_device->rev = inq_buff[2]; in hpsa_update_device_info()
3973 memset(this_device->device_id, 0, in hpsa_update_device_info()
3974 sizeof(this_device->device_id)); in hpsa_update_device_info()
3975 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3976 sizeof(this_device->device_id)) < 0) { in hpsa_update_device_info()
3977 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3979 h->ctlr, __func__, in hpsa_update_device_info()
3980 h->scsi_host->host_no, in hpsa_update_device_info()
3981 this_device->bus, this_device->target, in hpsa_update_device_info()
3982 this_device->lun, in hpsa_update_device_info()
3983 scsi_device_type(this_device->devtype), in hpsa_update_device_info()
3984 this_device->model); in hpsa_update_device_info()
3989 if ((this_device->devtype == TYPE_DISK || in hpsa_update_device_info()
3990 this_device->devtype == TYPE_ZBC) && in hpsa_update_device_info()
3994 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
3995 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
3999 h->legacy_board) { in hpsa_update_device_info()
4003 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4005 this_device->target, this_device->lun); in hpsa_update_device_info()
4008 this_device->volume_offline = volume_offline; in hpsa_update_device_info()
4011 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4017 this_device->raid_level = RAID_UNKNOWN; in hpsa_update_device_info()
4018 this_device->offload_config = 0; in hpsa_update_device_info()
4020 this_device->hba_ioaccel_enabled = 0; in hpsa_update_device_info()
4021 this_device->volume_offline = 0; in hpsa_update_device_info()
4022 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4025 if (this_device->external) in hpsa_update_device_info()
4026 this_device->queue_depth = EXTERNAL_QD; in hpsa_update_device_info()
4029 /* See if this is a One-Button-Disaster-Recovery device in hpsa_update_device_info()
4030 * by looking for "$DR-10" at offset 43 in inquiry data. in hpsa_update_device_info()
4033 *is_OBDR_device = (this_device->devtype == TYPE_ROM && in hpsa_update_device_info()
4061 if (!device->rev) in figure_bus_target_lun()
4068 HPSA_PHYSICAL_DEVICE_BUS, -1, -1); in figure_bus_target_lun()
4072 if (device->external) { in figure_bus_target_lun()
4097 if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals) in figure_external_status()
4107 * Returns 0 on success, -1 otherwise.
4114 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4115 return -1; in hpsa_gather_lun_info()
4117 *nphysicals = be32_to_cpu(*((__be32 *)physdev->LUNListLength)) / 24; in hpsa_gather_lun_info()
4119 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4120 HPSA_MAX_PHYS_LUN, *nphysicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4124 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4125 return -1; in hpsa_gather_lun_info()
4127 *nlogicals = be32_to_cpu(*((__be32 *) logdev->LUNListLength)) / 8; in hpsa_gather_lun_info()
4130 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4133 *nlogicals - HPSA_MAX_LUN); in hpsa_gather_lun_info()
4137 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4140 *nphysicals + *nlogicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4141 *nlogicals = HPSA_MAX_PHYS_LUN - *nphysicals; in hpsa_gather_lun_info()
4163 return &physdev_list->LUN[i - in figure_lunaddrbytes()
4167 return &logdev_list->LUN[i - nphysicals - in figure_lunaddrbytes()
4185 rle = &rlep->LUN[rle_index]; in hpsa_get_ioaccel_drive_info()
4187 dev->ioaccel_handle = rle->ioaccel_handle; in hpsa_get_ioaccel_drive_info()
4188 if ((rle->device_flags & 0x08) && dev->ioaccel_handle) in hpsa_get_ioaccel_drive_info()
4189 dev->hba_ioaccel_enabled = 1; in hpsa_get_ioaccel_drive_info()
4191 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4192 GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]), id_phys, in hpsa_get_ioaccel_drive_info()
4198 dev->queue_depth = in hpsa_get_ioaccel_drive_info()
4199 le16_to_cpu(id_phys->current_queue_depth_limit) - in hpsa_get_ioaccel_drive_info()
4202 dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */ in hpsa_get_ioaccel_drive_info()
4214 rle = &rlep->LUN[rle_index]; in hpsa_get_path_info()
4216 if ((rle->device_flags & 0x08) && this_device->ioaccel_handle) in hpsa_get_path_info()
4217 this_device->hba_ioaccel_enabled = 1; in hpsa_get_path_info()
4219 memcpy(&this_device->active_path_index, in hpsa_get_path_info()
4220 &id_phys->active_path_number, in hpsa_get_path_info()
4221 sizeof(this_device->active_path_index)); in hpsa_get_path_info()
4222 memcpy(&this_device->path_map, in hpsa_get_path_info()
4223 &id_phys->redundant_path_present_map, in hpsa_get_path_info()
4224 sizeof(this_device->path_map)); in hpsa_get_path_info()
4225 memcpy(&this_device->box, in hpsa_get_path_info()
4226 &id_phys->alternate_paths_phys_box_on_port, in hpsa_get_path_info()
4227 sizeof(this_device->box)); in hpsa_get_path_info()
4228 memcpy(&this_device->phys_connector, in hpsa_get_path_info()
4229 &id_phys->alternate_paths_phys_connector, in hpsa_get_path_info()
4230 sizeof(this_device->phys_connector)); in hpsa_get_path_info()
4231 memcpy(&this_device->bay, in hpsa_get_path_info()
4232 &id_phys->phys_bay_in_box, in hpsa_get_path_info()
4233 sizeof(this_device->bay)); in hpsa_get_path_info()
4244 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4246 return -ENOMEM; in hpsa_set_local_logical_count()
4251 if (id_ctlr->configured_logical_drive_count < 255) in hpsa_set_local_logical_count()
4252 *nlocals = id_ctlr->configured_logical_drive_count; in hpsa_set_local_logical_count()
4255 id_ctlr->extended_logical_unit_count); in hpsa_set_local_logical_count()
4257 *nlocals = -1; in hpsa_set_local_logical_count()
4276 is_spare = (id_phys->more_flags >> 6) & 0x01; in hpsa_is_disk_spare()
4297 device_flags = rle->device_flags; in hpsa_skip_device()
4298 device_type = rle->device_type; in hpsa_skip_device()
4361 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4365 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4369 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4375 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4391 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4393 ndevs_to_allocate - HPSA_MAX_DEVICES); in hpsa_update_scsi_devices()
4399 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4414 int phys_dev_index = i - (raid_ctlr_position == 0); in hpsa_update_scsi_devices()
4426 tmpdevice->external = in hpsa_update_scsi_devices()
4433 if (phys_dev_index >= 0 && !tmpdevice->external && in hpsa_update_scsi_devices()
4436 &physdev_list->LUN[phys_dev_index]); in hpsa_update_scsi_devices()
4444 if (rc == -ENOMEM) { in hpsa_update_scsi_devices()
4445 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4447 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4451 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4459 this_device->physical_device = physical_device; in hpsa_update_scsi_devices()
4465 if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device) in hpsa_update_scsi_devices()
4466 this_device->expose_device = 0; in hpsa_update_scsi_devices()
4468 this_device->expose_device = 1; in hpsa_update_scsi_devices()
4474 if (this_device->physical_device && this_device->expose_device) in hpsa_update_scsi_devices()
4477 switch (this_device->devtype) { in hpsa_update_scsi_devices()
4479 /* We don't *really* support actual CD-ROM devices, in hpsa_update_scsi_devices()
4481 * which temporarily pretends to be a CD-ROM drive. in hpsa_update_scsi_devices()
4483 * device by checking for "$DR-10" in bytes 43-48 of in hpsa_update_scsi_devices()
4491 if (this_device->physical_device) { in hpsa_update_scsi_devices()
4494 this_device->offload_enabled = 0; in hpsa_update_scsi_devices()
4507 if (!this_device->external) in hpsa_update_scsi_devices()
4530 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4535 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4559 desc->Addr = cpu_to_le64(addr64); in hpsa_set_sg_descriptor()
4560 desc->Len = cpu_to_le32(len); in hpsa_set_sg_descriptor()
4561 desc->Ext = 0; in hpsa_set_sg_descriptor()
4577 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4593 curr_sg = cp->SG; in hpsa_scatter_gather()
4594 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4595 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4608 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4609 sg_limit = use_sg - sg_limit; in hpsa_scatter_gather()
4617 (curr_sg - 1)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scatter_gather()
4619 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4620 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4623 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4624 cp->Header.SGTotal = cpu_to_le16(use_sg + 1); in hpsa_scatter_gather()
4627 return -1; in hpsa_scatter_gather()
4634 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */ in hpsa_scatter_gather()
4635 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in cmd list */ in hpsa_scatter_gather()
4643 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4644 "%s: Blocking zero-length request: CDB:%*phN\n", in warn_zero_length_transfer()
4649 /* zero-length transfers trigger hardware errors. */
4654 /* Block zero-length transfer sizes on certain commands. */ in is_zero_length_transfer()
4729 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel1_queue_command()
4730 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4740 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4741 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4745 BUG_ON(cmd->cmd_len > IOACCEL1_IOFLAGS_CDBLEN_MAX); in hpsa_scsi_ioaccel1_queue_command()
4749 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4754 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4758 c->cmd_type = CMD_IOACCEL1; in hpsa_scsi_ioaccel1_queue_command()
4761 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4762 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel1_queue_command()
4763 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel1_queue_command()
4767 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4772 curr_sg = cp->SG; in hpsa_scsi_ioaccel1_queue_command()
4777 curr_sg->Addr = cpu_to_le64(addr64); in hpsa_scsi_ioaccel1_queue_command()
4778 curr_sg->Len = cpu_to_le32(len); in hpsa_scsi_ioaccel1_queue_command()
4779 curr_sg->Ext = cpu_to_le32(0); in hpsa_scsi_ioaccel1_queue_command()
4782 (--curr_sg)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scsi_ioaccel1_queue_command()
4784 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel1_queue_command()
4795 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4796 cmd->sc_data_direction); in hpsa_scsi_ioaccel1_queue_command()
4804 c->Header.SGList = use_sg; in hpsa_scsi_ioaccel1_queue_command()
4806 cp->dev_handle = cpu_to_le16(ioaccel_handle & 0xFFFF); in hpsa_scsi_ioaccel1_queue_command()
4807 cp->transfer_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel1_queue_command()
4808 cp->io_flags = cpu_to_le16(IOACCEL1_IOFLAGS_IO_REQ | in hpsa_scsi_ioaccel1_queue_command()
4810 cp->control = cpu_to_le32(control); in hpsa_scsi_ioaccel1_queue_command()
4811 memcpy(cp->CDB, cdb, cdb_len); in hpsa_scsi_ioaccel1_queue_command()
4812 memcpy(cp->CISS_LUN, scsi3addr, 8); in hpsa_scsi_ioaccel1_queue_command()
4825 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_direct_map()
4826 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_direct_map()
4829 return -1; in hpsa_scsi_ioaccel_direct_map()
4831 c->phys_disk = dev; in hpsa_scsi_ioaccel_direct_map()
4833 if (dev->in_reset) in hpsa_scsi_ioaccel_direct_map()
4834 return -1; in hpsa_scsi_ioaccel_direct_map()
4836 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4837 cmd->cmnd, cmd->cmd_len, dev->scsi3addr, dev); in hpsa_scsi_ioaccel_direct_map()
4846 struct scsi_cmnd *cmd = c->scsi_cmd; in set_encrypt_ioaccel2()
4847 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in set_encrypt_ioaccel2()
4848 struct raid_map_data *map = &dev->raid_map; in set_encrypt_ioaccel2()
4852 if (!(le16_to_cpu(map->flags) & RAID_MAP_FLAG_ENCRYPT_ON)) in set_encrypt_ioaccel2()
4855 cp->dekindex = map->dekindex; in set_encrypt_ioaccel2()
4858 cp->direction |= IOACCEL2_DIRECTION_ENCRYPT_MASK; in set_encrypt_ioaccel2()
4864 switch (cmd->cmnd[0]) { in set_encrypt_ioaccel2()
4865 /* Required? 6-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4868 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in set_encrypt_ioaccel2()
4869 (cmd->cmnd[2] << 8) | in set_encrypt_ioaccel2()
4870 cmd->cmnd[3]); in set_encrypt_ioaccel2()
4874 /* Required? 12-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4877 first_block = get_unaligned_be32(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4881 first_block = get_unaligned_be64(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4884 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4886 __func__, cmd->cmnd[0]); in set_encrypt_ioaccel2()
4891 if (le32_to_cpu(map->volume_blk_size) != 512) in set_encrypt_ioaccel2()
4893 le32_to_cpu(map->volume_blk_size)/512; in set_encrypt_ioaccel2()
4895 cp->tweak_lower = cpu_to_le32(first_block); in set_encrypt_ioaccel2()
4896 cp->tweak_upper = cpu_to_le32(first_block >> 32); in set_encrypt_ioaccel2()
4903 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel2_queue_command()
4904 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4912 if (!cmd->device) in hpsa_scsi_ioaccel2_queue_command()
4913 return -1; in hpsa_scsi_ioaccel2_queue_command()
4915 if (!cmd->device->hostdata) in hpsa_scsi_ioaccel2_queue_command()
4916 return -1; in hpsa_scsi_ioaccel2_queue_command()
4918 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4922 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4927 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4931 c->cmd_type = CMD_IOACCEL2; in hpsa_scsi_ioaccel2_queue_command()
4933 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4934 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel2_queue_command()
4935 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel2_queue_command()
4938 cp->IU_type = IOACCEL2_IU_TYPE; in hpsa_scsi_ioaccel2_queue_command()
4942 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4947 curr_sg = cp->sg; in hpsa_scsi_ioaccel2_queue_command()
4948 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4950 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4951 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4952 curr_sg->length = 0; in hpsa_scsi_ioaccel2_queue_command()
4953 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4954 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4955 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4956 curr_sg->chain_indicator = IOACCEL2_CHAIN; in hpsa_scsi_ioaccel2_queue_command()
4958 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4964 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4965 curr_sg->length = cpu_to_le32(len); in hpsa_scsi_ioaccel2_queue_command()
4966 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4967 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4968 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4969 curr_sg->chain_indicator = 0; in hpsa_scsi_ioaccel2_queue_command()
4976 (curr_sg - 1)->chain_indicator = IOACCEL2_LAST_SG; in hpsa_scsi_ioaccel2_queue_command()
4978 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel2_queue_command()
4980 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4981 cp->direction |= IOACCEL2_DIR_DATA_OUT; in hpsa_scsi_ioaccel2_queue_command()
4984 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4985 cp->direction |= IOACCEL2_DIR_DATA_IN; in hpsa_scsi_ioaccel2_queue_command()
4988 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4989 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
4992 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
4993 cmd->sc_data_direction); in hpsa_scsi_ioaccel2_queue_command()
4998 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4999 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
5005 cp->scsi_nexus = cpu_to_le32(ioaccel_handle); in hpsa_scsi_ioaccel2_queue_command()
5006 cp->Tag = cpu_to_le32(c->cmdindex << DIRECT_LOOKUP_SHIFT); in hpsa_scsi_ioaccel2_queue_command()
5007 memcpy(cp->cdb, cdb, sizeof(cp->cdb)); in hpsa_scsi_ioaccel2_queue_command()
5009 cp->data_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel2_queue_command()
5010 cp->err_ptr = cpu_to_le64(c->busaddr + in hpsa_scsi_ioaccel2_queue_command()
5012 cp->err_len = cpu_to_le32(sizeof(cp->error_data)); in hpsa_scsi_ioaccel2_queue_command()
5015 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5016 cp->sg_count = 1; in hpsa_scsi_ioaccel2_queue_command()
5017 cp->sg[0].length = cpu_to_le32(use_sg * sizeof(cp->sg[0])); in hpsa_scsi_ioaccel2_queue_command()
5019 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
5021 return -1; in hpsa_scsi_ioaccel2_queue_command()
5024 cp->sg_count = (u8) use_sg; in hpsa_scsi_ioaccel2_queue_command()
5026 if (phys_disk->in_reset) { in hpsa_scsi_ioaccel2_queue_command()
5027 cmd->result = DID_RESET << 16; in hpsa_scsi_ioaccel2_queue_command()
5028 return -1; in hpsa_scsi_ioaccel2_queue_command()
5042 if (!c->scsi_cmd->device) in hpsa_scsi_ioaccel_queue_command()
5043 return -1; in hpsa_scsi_ioaccel_queue_command()
5045 if (!c->scsi_cmd->device->hostdata) in hpsa_scsi_ioaccel_queue_command()
5046 return -1; in hpsa_scsi_ioaccel_queue_command()
5048 if (phys_disk->in_reset) in hpsa_scsi_ioaccel_queue_command()
5049 return -1; in hpsa_scsi_ioaccel_queue_command()
5052 if (atomic_inc_return(&phys_disk->ioaccel_cmds_out) > in hpsa_scsi_ioaccel_queue_command()
5053 phys_disk->queue_depth) { in hpsa_scsi_ioaccel_queue_command()
5054 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel_queue_command()
5057 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5072 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5078 le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5081 if (*current_group < le16_to_cpu(map->layout_map_count) - 1) { in raid_map_helper()
5083 *map_index += le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5087 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5099 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_raid_map()
5100 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_raid_map()
5101 struct raid_map_data *map = &dev->raid_map; in hpsa_scsi_ioaccel_raid_map()
5102 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_scsi_ioaccel_raid_map()
5132 return -1; in hpsa_scsi_ioaccel_raid_map()
5134 if (dev->in_reset) in hpsa_scsi_ioaccel_raid_map()
5135 return -1; in hpsa_scsi_ioaccel_raid_map()
5138 switch (cmd->cmnd[0]) { in hpsa_scsi_ioaccel_raid_map()
5143 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in hpsa_scsi_ioaccel_raid_map()
5144 (cmd->cmnd[2] << 8) | in hpsa_scsi_ioaccel_raid_map()
5145 cmd->cmnd[3]); in hpsa_scsi_ioaccel_raid_map()
5146 block_cnt = cmd->cmnd[4]; in hpsa_scsi_ioaccel_raid_map()
5155 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5156 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5157 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5158 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5160 (((u32) cmd->cmnd[7]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5161 cmd->cmnd[8]; in hpsa_scsi_ioaccel_raid_map()
5168 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5169 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5170 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5171 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5173 (((u32) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5174 (((u32) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5175 (((u32) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5176 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5183 (((u64) cmd->cmnd[2]) << 56) | in hpsa_scsi_ioaccel_raid_map()
5184 (((u64) cmd->cmnd[3]) << 48) | in hpsa_scsi_ioaccel_raid_map()
5185 (((u64) cmd->cmnd[4]) << 40) | in hpsa_scsi_ioaccel_raid_map()
5186 (((u64) cmd->cmnd[5]) << 32) | in hpsa_scsi_ioaccel_raid_map()
5187 (((u64) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5188 (((u64) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5189 (((u64) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5190 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5192 (((u32) cmd->cmnd[10]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5193 (((u32) cmd->cmnd[11]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5194 (((u32) cmd->cmnd[12]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5195 cmd->cmnd[13]; in hpsa_scsi_ioaccel_raid_map()
5200 last_block = first_block + block_cnt - 1; in hpsa_scsi_ioaccel_raid_map()
5202 /* check for write to non-RAID-0 */ in hpsa_scsi_ioaccel_raid_map()
5203 if (is_write && dev->raid_level != 0) in hpsa_scsi_ioaccel_raid_map()
5207 if (last_block >= le64_to_cpu(map->volume_blk_cnt) || in hpsa_scsi_ioaccel_raid_map()
5212 blocks_per_row = le16_to_cpu(map->data_disks_per_row) * in hpsa_scsi_ioaccel_raid_map()
5213 le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5214 strip_size = le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5222 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5223 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5233 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5234 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5244 total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_scsi_ioaccel_raid_map()
5245 le16_to_cpu(map->metadata_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5246 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5247 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5250 switch (dev->raid_level) { in hpsa_scsi_ioaccel_raid_map()
5255 * (2-drive R1 and R10 with even # of drives.) in hpsa_scsi_ioaccel_raid_map()
5259 if (le16_to_cpu(map->layout_map_count) != 2) { in hpsa_scsi_ioaccel_raid_map()
5263 if (dev->offload_to_mirror) in hpsa_scsi_ioaccel_raid_map()
5264 map_index += le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5265 dev->offload_to_mirror = !dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5268 /* Handles N-way mirrors (R1-ADM) in hpsa_scsi_ioaccel_raid_map()
5272 if (le16_to_cpu(map->layout_map_count) != 3) { in hpsa_scsi_ioaccel_raid_map()
5277 offload_to_mirror = dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5283 le16_to_cpu(map->layout_map_count) - 1) in hpsa_scsi_ioaccel_raid_map()
5285 dev->offload_to_mirror = offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5286 /* Avoid direct use of dev->offload_to_mirror within this in hpsa_scsi_ioaccel_raid_map()
5288 * increment it beyond the range of dev->layout_map_count -1. in hpsa_scsi_ioaccel_raid_map()
5293 if (le16_to_cpu(map->layout_map_count) <= 1) in hpsa_scsi_ioaccel_raid_map()
5298 le16_to_cpu(map->strip_size) * in hpsa_scsi_ioaccel_raid_map()
5299 le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5305 le16_to_cpu(map->layout_map_count); in hpsa_scsi_ioaccel_raid_map()
5353 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5356 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5368 r5or6_first_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5370 r5or6_last_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5376 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5377 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5380 (le16_to_cpu(map->row_cnt) * total_disks_per_row)) + in hpsa_scsi_ioaccel_raid_map()
5390 c->phys_disk = dev->phys_disk[map_index]; in hpsa_scsi_ioaccel_raid_map()
5391 if (!c->phys_disk) in hpsa_scsi_ioaccel_raid_map()
5395 disk_block = le64_to_cpu(map->disk_starting_blk) + in hpsa_scsi_ioaccel_raid_map()
5396 first_row * le16_to_cpu(map->strip_size) + in hpsa_scsi_ioaccel_raid_map()
5397 (first_row_offset - first_column * in hpsa_scsi_ioaccel_raid_map()
5398 le16_to_cpu(map->strip_size)); in hpsa_scsi_ioaccel_raid_map()
5402 if (map->phys_blk_shift) { in hpsa_scsi_ioaccel_raid_map()
5403 disk_block <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5404 disk_block_cnt <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5441 dev->scsi3addr, in hpsa_scsi_ioaccel_raid_map()
5442 dev->phys_disk[map_index]); in hpsa_scsi_ioaccel_raid_map()
5454 cmd->host_scribble = (unsigned char *) c; in hpsa_ciss_submit()
5455 c->cmd_type = CMD_SCSI; in hpsa_ciss_submit()
5456 c->scsi_cmd = cmd; in hpsa_ciss_submit()
5457 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_ciss_submit()
5458 memcpy(&c->Header.LUN.LunAddrBytes[0], &dev->scsi3addr[0], 8); in hpsa_ciss_submit()
5459 c->Header.tag = cpu_to_le64((c->cmdindex << DIRECT_LOOKUP_SHIFT)); in hpsa_ciss_submit()
5463 c->Request.Timeout = 0; in hpsa_ciss_submit()
5464 BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB)); in hpsa_ciss_submit()
5465 c->Request.CDBLen = cmd->cmd_len; in hpsa_ciss_submit()
5466 memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len); in hpsa_ciss_submit()
5467 switch (cmd->sc_data_direction) { in hpsa_ciss_submit()
5469 c->Request.type_attr_dir = in hpsa_ciss_submit()
5473 c->Request.type_attr_dir = in hpsa_ciss_submit()
5477 c->Request.type_attr_dir = in hpsa_ciss_submit()
5482 * and sets both inlen and outlen to non-zero. ( see in hpsa_ciss_submit()
5486 c->Request.type_attr_dir = in hpsa_ciss_submit()
5490 * response, but non-fibre backends appear to let it in hpsa_ciss_submit()
5499 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5500 cmd->sc_data_direction); in hpsa_ciss_submit()
5510 if (dev->in_reset) { in hpsa_ciss_submit()
5515 c->device = dev; in hpsa_ciss_submit()
5529 c->Header.tag = cpu_to_le64((u64) (index << DIRECT_LOOKUP_SHIFT)); in hpsa_cmd_init()
5530 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5531 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5532 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_init()
5533 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5534 + index * sizeof(*c->err_info); in hpsa_cmd_init()
5535 c->cmdindex = index; in hpsa_cmd_init()
5536 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_init()
5537 c->ErrDesc.Addr = cpu_to_le64((u64) err_dma_handle); in hpsa_cmd_init()
5538 c->ErrDesc.Len = cpu_to_le32((u32) sizeof(*c->err_info)); in hpsa_cmd_init()
5539 c->h = h; in hpsa_cmd_init()
5540 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_init()
5547 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5548 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5551 atomic_set(&c->refcount, 0); in hpsa_preinitialize_commands()
5558 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5560 BUG_ON(c->cmdindex != index); in hpsa_cmd_partial_init()
5562 memset(c->Request.CDB, 0, sizeof(c->Request.CDB)); in hpsa_cmd_partial_init()
5563 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_partial_init()
5564 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_partial_init()
5571 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_ioaccel_submit()
5577 if (dev->in_reset) in hpsa_ioaccel_submit()
5583 cmd->host_scribble = (unsigned char *) c; in hpsa_ioaccel_submit()
5585 if (dev->offload_enabled) { in hpsa_ioaccel_submit()
5586 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5587 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5588 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5589 c->device = dev; in hpsa_ioaccel_submit()
5590 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5591 c->retry_pending = true; in hpsa_ioaccel_submit()
5595 } else if (dev->hba_ioaccel_enabled) { in hpsa_ioaccel_submit()
5596 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5597 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5598 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5599 c->device = dev; in hpsa_ioaccel_submit()
5600 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5601 c->retry_pending = true; in hpsa_ioaccel_submit()
5615 cmd = c->scsi_cmd; in hpsa_command_resubmit_worker()
5616 dev = cmd->device->hostdata; in hpsa_command_resubmit_worker()
5618 cmd->result = DID_NO_CONNECT << 16; in hpsa_command_resubmit_worker()
5619 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5622 if (dev->in_reset) { in hpsa_command_resubmit_worker()
5623 cmd->result = DID_RESET << 16; in hpsa_command_resubmit_worker()
5624 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5627 if (c->cmd_type == CMD_IOACCEL2) { in hpsa_command_resubmit_worker()
5628 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker()
5629 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5632 if (c2->error_data.serv_response == in hpsa_command_resubmit_worker()
5644 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5650 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5659 c->retry_pending = true; in hpsa_command_resubmit_worker()
5660 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5669 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5674 /* Running in struct Scsi_Host->host_lock less mode */
5682 /* Get the ptr to our adapter structure out of cmd->host. */ in hpsa_scsi_queue_command()
5683 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5685 BUG_ON(scsi_cmd_to_rq(cmd)->tag < 0); in hpsa_scsi_queue_command()
5687 dev = cmd->device->hostdata; in hpsa_scsi_queue_command()
5689 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5694 if (dev->removed) { in hpsa_scsi_queue_command()
5695 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5701 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5706 if (dev->in_reset) in hpsa_scsi_queue_command()
5717 cmd->result = 0; in hpsa_scsi_queue_command()
5722 * Note: If cmd->retries is non-zero, then this is a SML in hpsa_scsi_queue_command()
5725 * and is therefore a brand-new command. in hpsa_scsi_queue_command()
5727 if (likely(cmd->retries == 0 && in hpsa_scsi_queue_command()
5729 h->acciopath_status)) { in hpsa_scsi_queue_command()
5746 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5747 h->scan_finished = 1; in hpsa_scan_complete()
5748 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5749 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5769 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5770 if (h->scan_waiting) { in hpsa_scan_start()
5771 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5775 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5779 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5780 if (h->scan_finished) in hpsa_scan_start()
5782 h->scan_waiting = 1; in hpsa_scan_start()
5783 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5784 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5791 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5792 h->scan_waiting = 0; in hpsa_scan_start()
5793 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5801 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5802 if (h->reset_in_progress) { in hpsa_scan_start()
5803 h->drv_req_rescan = 1; in hpsa_scan_start()
5804 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5808 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5817 struct hpsa_scsi_dev_t *logical_drive = sdev->hostdata; in hpsa_change_queue_depth()
5820 return -ENODEV; in hpsa_change_queue_depth()
5824 else if (qdepth > logical_drive->queue_depth) in hpsa_change_queue_depth()
5825 qdepth = logical_drive->queue_depth; in hpsa_change_queue_depth()
5837 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5838 finished = h->scan_finished; in hpsa_scan_finished()
5839 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5849 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5850 return -ENOMEM; in hpsa_scsi_host_alloc()
5853 sh->io_port = 0; in hpsa_scsi_host_alloc()
5854 sh->n_io_port = 0; in hpsa_scsi_host_alloc()
5855 sh->this_id = -1; in hpsa_scsi_host_alloc()
5856 sh->max_channel = 3; in hpsa_scsi_host_alloc()
5857 sh->max_cmd_len = MAX_COMMAND_SIZE; in hpsa_scsi_host_alloc()
5858 sh->max_lun = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5859 sh->max_id = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5860 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5861 sh->cmd_per_lun = sh->can_queue; in hpsa_scsi_host_alloc()
5862 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5863 sh->transportt = hpsa_sas_transport_template; in hpsa_scsi_host_alloc()
5864 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5865 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5866 sh->unique_id = sh->irq; in hpsa_scsi_host_alloc()
5868 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5876 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5878 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5881 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5887 * small-integer tag for this request. We use an offset from that value as
5889 * low-numbered entries for our own uses.)
5893 int idx = scsi_cmd_to_rq(scmd)->tag; in hpsa_get_cmd_index()
5904 * reply queue; returns zero if the unit is ready, and non-zero otherwise.
5921 if (c->err_info->CommandStatus == CMD_SUCCESS) in hpsa_send_test_unit_ready()
5929 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in hpsa_send_test_unit_ready()
5930 c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION && in hpsa_send_test_unit_ready()
5931 (c->err_info->SenseInfo[2] == NO_SENSE || in hpsa_send_test_unit_ready()
5932 c->err_info->SenseInfo[2] == UNIT_ATTENTION)) in hpsa_send_test_unit_ready()
5940 * returns zero when the unit is ready, and non-zero when giving up.
5967 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
5994 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6007 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6009 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6016 * complaining. Doing a host- or bus-reset can't do anything good here.
6029 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6033 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6034 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6035 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6042 dev = scsicmd->device->hostdata; in hpsa_eh_device_reset_handler()
6044 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6049 if (dev->devtype == TYPE_ENCLOSURE) { in hpsa_eh_device_reset_handler()
6075 if (is_hba_lunid(dev->scsi3addr)) { in hpsa_eh_device_reset_handler()
6080 if (is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_eh_device_reset_handler()
6092 dev->in_reset = true; /* block any new cmds from OS for this device */ in hpsa_eh_device_reset_handler()
6094 if (atomic_read(&dev->commands_outstanding) > 0) in hpsa_eh_device_reset_handler()
6113 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6114 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6116 dev->in_reset = false; in hpsa_eh_device_reset_handler()
6117 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6132 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6134 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6135 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6136 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6150 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6151 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6155 h->last_collision_tag = idx; in cmd_tagged_alloc()
6160 atomic_inc(&c->refcount); in cmd_tagged_alloc()
6167 c->retry_pending = false; in cmd_tagged_alloc()
6178 (void)atomic_dec(&c->refcount); in cmd_tagged_free()
6197 * There is some *extremely* small but non-zero chance that that in cmd_alloc()
6211 * reserved for driver-initiated requests, while requests from the block in cmd_alloc()
6216 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6223 c = h->cmd_pool + i; in cmd_alloc()
6224 refcount = atomic_inc_return(&c->refcount); in cmd_alloc()
6230 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6234 c->device = NULL; in cmd_alloc()
6240 c->retry_pending = false; in cmd_alloc()
6248 * cmd_tagged_alloc() in which case the ref-count decrement does the trick and
6249 * the clear-bit is harmless.
6253 if (atomic_dec_and_test(&c->refcount)) { in cmd_free()
6256 i = c - h->cmd_pool; in cmd_free()
6257 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6273 return -EINVAL; in hpsa_ioctl32_passthru()
6277 return -EFAULT; in hpsa_ioctl32_passthru()
6278 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_passthru()
6279 return -EFAULT; in hpsa_ioctl32_passthru()
6282 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6283 return -EAGAIN; in hpsa_ioctl32_passthru()
6285 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6288 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_passthru()
6289 sizeof(arg32->error_info))) in hpsa_ioctl32_passthru()
6290 return -EFAULT; in hpsa_ioctl32_passthru()
6304 return -EINVAL; in hpsa_ioctl32_big_passthru()
6308 return -EFAULT; in hpsa_ioctl32_big_passthru()
6309 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_big_passthru()
6310 return -EFAULT; in hpsa_ioctl32_big_passthru()
6313 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6314 return -EAGAIN; in hpsa_ioctl32_big_passthru()
6316 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6319 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_big_passthru()
6320 sizeof(arg32->error_info))) in hpsa_ioctl32_big_passthru()
6321 return -EFAULT; in hpsa_ioctl32_big_passthru()
6352 return -ENOIOCTLCMD; in hpsa_compat_ioctl()
6362 return -EINVAL; in hpsa_getpciinfo_ioctl()
6363 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6364 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6365 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6366 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6368 return -EFAULT; in hpsa_getpciinfo_ioctl()
6381 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6389 return -EINVAL; in hpsa_getdrivver_ioctl()
6391 return -EFAULT; in hpsa_getdrivver_ioctl()
6404 return -EPERM; in hpsa_passthru_ioctl()
6405 if ((iocommand->buf_size < 1) && in hpsa_passthru_ioctl()
6406 (iocommand->Request.Type.Direction != XFER_NONE)) { in hpsa_passthru_ioctl()
6407 return -EINVAL; in hpsa_passthru_ioctl()
6409 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6410 buff = kmalloc(iocommand->buf_size, GFP_KERNEL); in hpsa_passthru_ioctl()
6412 return -ENOMEM; in hpsa_passthru_ioctl()
6413 if (iocommand->Request.Type.Direction & XFER_WRITE) { in hpsa_passthru_ioctl()
6415 if (copy_from_user(buff, iocommand->buf, in hpsa_passthru_ioctl()
6416 iocommand->buf_size)) { in hpsa_passthru_ioctl()
6417 rc = -EFAULT; in hpsa_passthru_ioctl()
6421 memset(buff, 0, iocommand->buf_size); in hpsa_passthru_ioctl()
6427 c->cmd_type = CMD_IOCTL_PEND; in hpsa_passthru_ioctl()
6428 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_passthru_ioctl()
6430 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_passthru_ioctl()
6431 if (iocommand->buf_size > 0) { /* buffer to fill */ in hpsa_passthru_ioctl()
6432 c->Header.SGList = 1; in hpsa_passthru_ioctl()
6433 c->Header.SGTotal = cpu_to_le16(1); in hpsa_passthru_ioctl()
6435 c->Header.SGList = 0; in hpsa_passthru_ioctl()
6436 c->Header.SGTotal = cpu_to_le16(0); in hpsa_passthru_ioctl()
6438 memcpy(&c->Header.LUN, &iocommand->LUN_info, sizeof(c->Header.LUN)); in hpsa_passthru_ioctl()
6441 memcpy(&c->Request, &iocommand->Request, in hpsa_passthru_ioctl()
6442 sizeof(c->Request)); in hpsa_passthru_ioctl()
6445 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6446 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6447 iocommand->buf_size, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6448 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6449 c->SG[0].Addr = cpu_to_le64(0); in hpsa_passthru_ioctl()
6450 c->SG[0].Len = cpu_to_le32(0); in hpsa_passthru_ioctl()
6451 rc = -ENOMEM; in hpsa_passthru_ioctl()
6454 c->SG[0].Addr = cpu_to_le64(temp64); in hpsa_passthru_ioctl()
6455 c->SG[0].Len = cpu_to_le32(iocommand->buf_size); in hpsa_passthru_ioctl()
6456 c->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* not chaining */ in hpsa_passthru_ioctl()
6460 if (iocommand->buf_size > 0) in hpsa_passthru_ioctl()
6461 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6464 rc = -EIO; in hpsa_passthru_ioctl()
6469 memcpy(&iocommand->error_info, c->err_info, in hpsa_passthru_ioctl()
6470 sizeof(iocommand->error_info)); in hpsa_passthru_ioctl()
6471 if ((iocommand->Request.Type.Direction & XFER_READ) && in hpsa_passthru_ioctl()
6472 iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6474 if (copy_to_user(iocommand->buf, buff, iocommand->buf_size)) { in hpsa_passthru_ioctl()
6475 rc = -EFAULT; in hpsa_passthru_ioctl()
6500 return -EPERM; in hpsa_big_passthru_ioctl()
6502 if ((ioc->buf_size < 1) && in hpsa_big_passthru_ioctl()
6503 (ioc->Request.Type.Direction != XFER_NONE)) in hpsa_big_passthru_ioctl()
6504 return -EINVAL; in hpsa_big_passthru_ioctl()
6506 if (ioc->malloc_size > MAX_KMALLOC_SIZE) in hpsa_big_passthru_ioctl()
6507 return -EINVAL; in hpsa_big_passthru_ioctl()
6508 if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD) in hpsa_big_passthru_ioctl()
6509 return -EINVAL; in hpsa_big_passthru_ioctl()
6512 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6517 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6520 left = ioc->buf_size; in hpsa_big_passthru_ioctl()
6521 data_ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6523 sz = (left > ioc->malloc_size) ? ioc->malloc_size : left; in hpsa_big_passthru_ioctl()
6527 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6530 if (ioc->Request.Type.Direction & XFER_WRITE) { in hpsa_big_passthru_ioctl()
6532 status = -EFAULT; in hpsa_big_passthru_ioctl()
6537 left -= sz; in hpsa_big_passthru_ioctl()
6543 c->cmd_type = CMD_IOCTL_PEND; in hpsa_big_passthru_ioctl()
6544 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_big_passthru_ioctl()
6545 c->Header.ReplyQueue = 0; in hpsa_big_passthru_ioctl()
6546 c->Header.SGList = (u8) sg_used; in hpsa_big_passthru_ioctl()
6547 c->Header.SGTotal = cpu_to_le16(sg_used); in hpsa_big_passthru_ioctl()
6548 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN)); in hpsa_big_passthru_ioctl()
6549 memcpy(&c->Request, &ioc->Request, sizeof(c->Request)); in hpsa_big_passthru_ioctl()
6550 if (ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6553 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6555 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6557 c->SG[i].Addr = cpu_to_le64(0); in hpsa_big_passthru_ioctl()
6558 c->SG[i].Len = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6559 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6561 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6564 c->SG[i].Addr = cpu_to_le64(temp64); in hpsa_big_passthru_ioctl()
6565 c->SG[i].Len = cpu_to_le32(buff_size[i]); in hpsa_big_passthru_ioctl()
6566 c->SG[i].Ext = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6568 c->SG[--i].Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_big_passthru_ioctl()
6573 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6576 status = -EIO; in hpsa_big_passthru_ioctl()
6581 memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info)); in hpsa_big_passthru_ioctl()
6582 if ((ioc->Request.Type.Direction & XFER_READ) && ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6586 BYTE __user *ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6589 status = -EFAULT; in hpsa_big_passthru_ioctl()
6613 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in check_ioctl_unit_attention()
6614 c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) in check_ioctl_unit_attention()
6631 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6641 return -EINVAL; in hpsa_ioctl()
6643 return -EFAULT; in hpsa_ioctl()
6644 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6645 return -EAGAIN; in hpsa_ioctl()
6647 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6649 rc = -EFAULT; in hpsa_ioctl()
6655 return -EINVAL; in hpsa_ioctl()
6657 return -EFAULT; in hpsa_ioctl()
6658 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6659 return -EAGAIN; in hpsa_ioctl()
6661 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6663 rc = -EFAULT; in hpsa_ioctl()
6667 return -ENOTTY; in hpsa_ioctl()
6680 c->Request.CDB[1] = reset_type; /* fill_cmd defaults to target reset */ in hpsa_send_host_reset()
6681 c->waiting = NULL; in hpsa_send_host_reset()
6685 * re-initializing everything, so it doesn't matter and won't leak. in hpsa_send_host_reset()
6696 c->cmd_type = CMD_IOCTL_PEND; in fill_cmd()
6697 c->scsi_cmd = SCSI_CMD_BUSY; in fill_cmd()
6698 c->Header.ReplyQueue = 0; in fill_cmd()
6700 c->Header.SGList = 1; in fill_cmd()
6701 c->Header.SGTotal = cpu_to_le16(1); in fill_cmd()
6703 c->Header.SGList = 0; in fill_cmd()
6704 c->Header.SGTotal = cpu_to_le16(0); in fill_cmd()
6706 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8); in fill_cmd()
6713 c->Request.CDB[1] = 0x01; in fill_cmd()
6714 c->Request.CDB[2] = (page_code & 0xff); in fill_cmd()
6716 c->Request.CDBLen = 6; in fill_cmd()
6717 c->Request.type_attr_dir = in fill_cmd()
6719 c->Request.Timeout = 0; in fill_cmd()
6720 c->Request.CDB[0] = HPSA_INQUIRY; in fill_cmd()
6721 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6724 c->Request.CDBLen = 6; in fill_cmd()
6725 c->Request.type_attr_dir = in fill_cmd()
6727 c->Request.Timeout = 0; in fill_cmd()
6728 c->Request.CDB[0] = cmd; in fill_cmd()
6729 c->Request.CDB[1] = 1; in fill_cmd()
6730 c->Request.CDB[2] = 1; in fill_cmd()
6731 c->Request.CDB[3] = (size >> 8) & 0xFF; in fill_cmd()
6732 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6739 c->Request.CDBLen = 12; in fill_cmd()
6740 c->Request.type_attr_dir = in fill_cmd()
6742 c->Request.Timeout = 0; in fill_cmd()
6743 c->Request.CDB[0] = cmd; in fill_cmd()
6744 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6745 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6746 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6747 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6750 c->Request.CDBLen = 16; in fill_cmd()
6751 c->Request.type_attr_dir = in fill_cmd()
6753 c->Request.Timeout = 0; in fill_cmd()
6755 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6756 c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS; in fill_cmd()
6759 c->Request.CDBLen = 16; in fill_cmd()
6760 c->Request.type_attr_dir = in fill_cmd()
6763 c->Request.Timeout = 0; in fill_cmd()
6764 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6765 c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS; in fill_cmd()
6768 c->Request.CDBLen = 12; in fill_cmd()
6769 c->Request.type_attr_dir = in fill_cmd()
6772 c->Request.Timeout = 0; in fill_cmd()
6773 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6774 c->Request.CDB[6] = BMIC_CACHE_FLUSH; in fill_cmd()
6775 c->Request.CDB[7] = (size >> 8) & 0xFF; in fill_cmd()
6776 c->Request.CDB[8] = size & 0xFF; in fill_cmd()
6779 c->Request.CDBLen = 6; in fill_cmd()
6780 c->Request.type_attr_dir = in fill_cmd()
6782 c->Request.Timeout = 0; in fill_cmd()
6785 c->Request.CDBLen = 12; in fill_cmd()
6786 c->Request.type_attr_dir = in fill_cmd()
6788 c->Request.Timeout = 0; in fill_cmd()
6789 c->Request.CDB[0] = HPSA_CISS_READ; in fill_cmd()
6790 c->Request.CDB[1] = cmd; in fill_cmd()
6791 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6792 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6793 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6794 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6797 c->Request.CDBLen = 10; in fill_cmd()
6798 c->Request.type_attr_dir = in fill_cmd()
6800 c->Request.Timeout = 0; in fill_cmd()
6801 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6802 c->Request.CDB[6] = BMIC_SENSE_CONTROLLER_PARAMETERS; in fill_cmd()
6803 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6804 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6807 c->Request.CDBLen = 10; in fill_cmd()
6808 c->Request.type_attr_dir = in fill_cmd()
6810 c->Request.Timeout = 0; in fill_cmd()
6811 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6812 c->Request.CDB[6] = BMIC_IDENTIFY_PHYSICAL_DEVICE; in fill_cmd()
6813 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6814 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6817 c->Request.CDBLen = 10; in fill_cmd()
6818 c->Request.type_attr_dir = in fill_cmd()
6820 c->Request.Timeout = 0; in fill_cmd()
6821 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6822 c->Request.CDB[6] = BMIC_SENSE_SUBSYSTEM_INFORMATION; in fill_cmd()
6823 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6824 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6827 c->Request.CDBLen = 10; in fill_cmd()
6828 c->Request.type_attr_dir = in fill_cmd()
6830 c->Request.Timeout = 0; in fill_cmd()
6831 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6832 c->Request.CDB[6] = BMIC_SENSE_STORAGE_BOX_PARAMS; in fill_cmd()
6833 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6834 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6837 c->Request.CDBLen = 10; in fill_cmd()
6838 c->Request.type_attr_dir = in fill_cmd()
6840 c->Request.Timeout = 0; in fill_cmd()
6841 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6842 c->Request.CDB[1] = 0; in fill_cmd()
6843 c->Request.CDB[2] = 0; in fill_cmd()
6844 c->Request.CDB[3] = 0; in fill_cmd()
6845 c->Request.CDB[4] = 0; in fill_cmd()
6846 c->Request.CDB[5] = 0; in fill_cmd()
6847 c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER; in fill_cmd()
6848 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6849 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6850 c->Request.CDB[9] = 0; in fill_cmd()
6853 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6860 c->Request.CDBLen = 16; in fill_cmd()
6861 c->Request.type_attr_dir = in fill_cmd()
6863 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6864 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6865 c->Request.CDB[0] = HPSA_RESET; in fill_cmd()
6866 c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE; in fill_cmd()
6867 /* Physical target reset needs no control bytes 4-7*/ in fill_cmd()
6868 c->Request.CDB[4] = 0x00; in fill_cmd()
6869 c->Request.CDB[5] = 0x00; in fill_cmd()
6870 c->Request.CDB[6] = 0x00; in fill_cmd()
6871 c->Request.CDB[7] = 0x00; in fill_cmd()
6874 c->Request.CDBLen = 16; in fill_cmd()
6875 c->Request.type_attr_dir = in fill_cmd()
6877 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6878 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6879 c->Request.CDB[0] = cmd; in fill_cmd()
6880 c->Request.CDB[1] = HPSA_RESET_TYPE_LUN; in fill_cmd()
6881 /* If bytes 4-7 are zero, it means reset the */ in fill_cmd()
6883 c->Request.CDB[4] = 0x00; in fill_cmd()
6884 c->Request.CDB[5] = 0x00; in fill_cmd()
6885 c->Request.CDB[6] = 0x00; in fill_cmd()
6886 c->Request.CDB[7] = 0x00; in fill_cmd()
6889 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6894 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6898 switch (GET_DIR(c->Request.type_attr_dir)) { in fill_cmd()
6911 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6912 return -1; in fill_cmd()
6922 ulong page_offs = ((ulong) base) - page_base; in remap_pci_mem()
6931 return h->access.command_completed(h, q); in get_next_completion()
6936 return h->access.intr_pending(h); in interrupt_pending()
6941 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6942 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6948 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6949 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6957 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6958 if (likely(c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_SCSI in finish_cmd()
6959 || c->cmd_type == CMD_IOACCEL2)) in finish_cmd()
6961 else if (c->cmd_type == CMD_IOCTL_PEND || c->cmd_type == IOACCEL2_TMF) in finish_cmd()
6962 complete(c->waiting); in finish_cmd()
6974 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6989 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
6992 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
6999 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7000 * Relies on (h-q[x] == x) being true for x such that
7005 return container_of((queue - *queue), struct ctlr_info, q[0]); in queue_to_hba()
7019 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7037 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7052 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7069 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7092 sizeof(cmd->ErrorDescriptor); in hpsa_message()
7101 return -ENOMEM; in hpsa_message()
7103 /* The Inbound Post Queue only accepts 32-bit physical addresses for the in hpsa_message()
7107 err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_message()
7113 cmd = dma_alloc_coherent(&pdev->dev, cmd_sz, &paddr64, GFP_KERNEL); in hpsa_message()
7116 return -ENOMEM; in hpsa_message()
7119 /* This must fit, because of the 32-bit consistent DMA mask. Also, in hpsa_message()
7121 * least 4-byte aligned (most likely, it's page-aligned). in hpsa_message()
7125 cmd->CommandHeader.ReplyQueue = 0; in hpsa_message()
7126 cmd->CommandHeader.SGList = 0; in hpsa_message()
7127 cmd->CommandHeader.SGTotal = cpu_to_le16(0); in hpsa_message()
7128 cmd->CommandHeader.tag = cpu_to_le64(paddr64); in hpsa_message()
7129 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8); in hpsa_message()
7131 cmd->Request.CDBLen = 16; in hpsa_message()
7132 cmd->Request.type_attr_dir = in hpsa_message()
7134 cmd->Request.Timeout = 0; /* Don't time out */ in hpsa_message()
7135 cmd->Request.CDB[0] = opcode; in hpsa_message()
7136 cmd->Request.CDB[1] = type; in hpsa_message()
7137 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */ in hpsa_message()
7138 cmd->ErrorDescriptor.Addr = in hpsa_message()
7140 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo)); in hpsa_message()
7157 dev_err(&pdev->dev, "controller message %02x:%02x timed out\n", in hpsa_message()
7159 return -ETIMEDOUT; in hpsa_message()
7162 dma_free_coherent(&pdev->dev, cmd_sz, cmd, paddr64); in hpsa_message()
7165 dev_err(&pdev->dev, "controller message %02x:%02x failed\n", in hpsa_message()
7167 return -EIO; in hpsa_message()
7170 dev_info(&pdev->dev, "controller message %02x:%02x succeeded\n", in hpsa_message()
7186 dev_info(&pdev->dev, "using doorbell to reset controller\n"); in hpsa_controller_hard_reset()
7207 dev_info(&pdev->dev, "using PCI PM to reset controller\n"); in hpsa_controller_hard_reset()
7239 int i, size = sizeof(cfgtable->driver_version); in write_driver_ver_to_cfgtable()
7243 return -ENOMEM; in write_driver_ver_to_cfgtable()
7247 writeb(driver_version[i], &cfgtable->driver_version[i]); in write_driver_ver_to_cfgtable()
7257 for (i = 0; i < sizeof(cfgtable->driver_version); i++) in read_driver_ver_from_cfgtable()
7258 driver_ver[i] = readb(&cfgtable->driver_version[i]); in read_driver_ver_from_cfgtable()
7265 int rc, size = sizeof(cfgtable->driver_version); in controller_reset_failed()
7269 return -ENOMEM; in controller_reset_failed()
7311 dev_warn(&pdev->dev, "Controller not resettable\n"); in hpsa_kdump_hard_reset_controller()
7312 return -ENODEV; in hpsa_kdump_hard_reset_controller()
7315 /* if controller is soft- but not hard resettable... */ in hpsa_kdump_hard_reset_controller()
7317 return -ENOTSUPP; /* try soft reset later. */ in hpsa_kdump_hard_reset_controller()
7329 return -ENOMEM; in hpsa_kdump_hard_reset_controller()
7339 rc = -ENOMEM; in hpsa_kdump_hard_reset_controller()
7349 misc_fw_support = readl(&cfgtable->misc_fw_support); in hpsa_kdump_hard_reset_controller()
7356 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7358 rc = -ENOTSUPP; /* try soft reset */ in hpsa_kdump_hard_reset_controller()
7376 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7385 dev_warn(&pdev->dev, "Unable to successfully reset " in hpsa_kdump_hard_reset_controller()
7387 rc = -ENOTSUPP; in hpsa_kdump_hard_reset_controller()
7389 dev_info(&pdev->dev, "board ready after hard reset.\n"); in hpsa_kdump_hard_reset_controller()
7412 dev_info(dev, "------------------------------------\n"); in print_cfg_table()
7414 temp_name[i] = readb(&(tb->Signature[i])); in print_cfg_table()
7417 dev_info(dev, " Spec Number = %d\n", readl(&(tb->SpecValence))); in print_cfg_table()
7419 readl(&(tb->TransportSupport))); in print_cfg_table()
7421 readl(&(tb->TransportActive))); in print_cfg_table()
7423 readl(&(tb->HostWrite.TransportRequest))); in print_cfg_table()
7425 readl(&(tb->HostWrite.CoalIntDelay))); in print_cfg_table()
7427 readl(&(tb->HostWrite.CoalIntCount))); in print_cfg_table()
7429 readl(&(tb->CmdsOutMax))); in print_cfg_table()
7430 dev_info(dev, " Bus Types = 0x%x\n", readl(&(tb->BusTypes))); in print_cfg_table()
7432 temp_name[i] = readb(&(tb->ServerName[i])); in print_cfg_table()
7436 readl(&(tb->HeartBeat))); in print_cfg_table()
7463 dev_warn(&pdev->dev, in find_PCI_BAR_index()
7465 return -1; in find_PCI_BAR_index()
7468 if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) in find_PCI_BAR_index()
7471 return -1; in find_PCI_BAR_index()
7476 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7477 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7485 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7486 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7491 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7497 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7500 /* If MSI/MSI-X is supported by the kernel we will try to enable it on
7509 switch (h->board_id) { in hpsa_interrupt_mode()
7516 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7519 h->msix_vectors = ret; in hpsa_interrupt_mode()
7527 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7539 subsystem_vendor_id = pdev->subsystem_vendor; in hpsa_lookup_board_id()
7540 subsystem_device_id = pdev->subsystem_device; in hpsa_lookup_board_id()
7551 dev_warn(&pdev->dev, in hpsa_lookup_board_id()
7559 dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x\n", *board_id); in hpsa_lookup_board_id()
7562 return ARRAY_SIZE(products) - 1; /* generic unknown smart array */ in hpsa_lookup_board_id()
7574 dev_dbg(&pdev->dev, "memory BAR = %lx\n", in hpsa_pci_find_memory_BAR()
7578 dev_warn(&pdev->dev, "no memory BAR found\n"); in hpsa_pci_find_memory_BAR()
7579 return -ENODEV; in hpsa_pci_find_memory_BAR()
7603 dev_warn(&pdev->dev, "board not ready, timed out.\n"); in hpsa_wait_for_board_state()
7604 return -ENODEV; in hpsa_wait_for_board_state()
7615 if (*cfg_base_addr_index == -1) { in hpsa_find_cfg_addrs()
7616 dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n"); in hpsa_find_cfg_addrs()
7617 return -ENODEV; in hpsa_find_cfg_addrs()
7624 if (h->transtable) { in hpsa_free_cfgtables()
7625 iounmap(h->transtable); in hpsa_free_cfgtables()
7626 h->transtable = NULL; in hpsa_free_cfgtables()
7628 if (h->cfgtable) { in hpsa_free_cfgtables()
7629 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7630 h->cfgtable = NULL; in hpsa_free_cfgtables()
7645 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7649 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7650 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7651 if (!h->cfgtable) { in hpsa_find_cfgtables()
7652 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7653 return -ENOMEM; in hpsa_find_cfgtables()
7655 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7659 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7660 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7662 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7663 if (!h->transtable) { in hpsa_find_cfgtables()
7664 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7666 return -ENOMEM; in hpsa_find_cfgtables()
7676 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7679 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7680 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7682 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7683 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7685 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7687 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7697 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7707 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7708 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7709 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7711 /* Limit in-command s/g elements to 32 save dma'able memory. */ in hpsa_find_board_params()
7712 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7713 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7714 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7721 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7722 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7723 h->chainsize = 0; in hpsa_find_board_params()
7727 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7728 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7729 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7730 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7731 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7732 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7733 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7738 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7739 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7749 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7755 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7765 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7767 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7769 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7779 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7780 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7781 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7787 return -ENODEV; in hpsa_wait_for_clear_event_notify_ack()
7803 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7805 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7806 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7807 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7813 return -ENODEV; in hpsa_wait_for_mode_change_ack()
7818 /* return -ENODEV or other reason on error, 0 on success */
7823 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7825 return -ENOTSUPP; in hpsa_enter_simple_mode()
7827 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7830 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7831 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7832 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7835 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7836 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7838 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7841 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7842 return -ENODEV; in hpsa_enter_simple_mode()
7849 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7850 h->vaddr = NULL; in hpsa_free_pci_init()
7854 * Documentation/driver-api/pci/pci.rst in hpsa_free_pci_init()
7856 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7857 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7866 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7869 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7870 h->access = *(products[prod_index].access); in hpsa_pci_init()
7871 h->legacy_board = legacy_board; in hpsa_pci_init()
7872 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7875 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7877 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7878 pci_disable_device(h->pdev); in hpsa_pci_init()
7882 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7884 dev_err(&h->pdev->dev, in hpsa_pci_init()
7886 pci_disable_device(h->pdev); in hpsa_pci_init()
7890 pci_set_master(h->pdev); in hpsa_pci_init()
7899 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7902 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7903 if (!h->vaddr) { in hpsa_pci_init()
7904 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7905 err = -ENOMEM; in hpsa_pci_init()
7908 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7917 err = -ENODEV; in hpsa_pci_init()
7930 iounmap(h->vaddr); in hpsa_pci_init()
7931 h->vaddr = NULL; in hpsa_pci_init()
7937 * Documentation/driver-api/pci/pci.rst in hpsa_pci_init()
7939 pci_disable_device(h->pdev); in hpsa_pci_init()
7940 pci_release_regions(h->pdev); in hpsa_pci_init()
7949 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7950 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7953 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7955 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7956 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
7969 * the pci interface. The dev->enable_cnt is equal zero in hpsa_init_reset_devices()
7974 dev_warn(&pdev->dev, "Failed to enable PCI device\n"); in hpsa_init_reset_devices()
7975 return -ENODEV; in hpsa_init_reset_devices()
7981 dev_warn(&pdev->dev, "failed to enable device.\n"); in hpsa_init_reset_devices()
7982 return -ENODEV; in hpsa_init_reset_devices()
7989 rc = -ENOMEM; in hpsa_init_reset_devices()
7995 /* Reset the controller with a PCI power-cycle or via doorbell */ in hpsa_init_reset_devices()
7998 /* -ENOTSUPP here means we cannot reset the controller in hpsa_init_reset_devices()
8006 /* Now try to get the controller to respond to a no-op */ in hpsa_init_reset_devices()
8007 dev_info(&pdev->dev, "Waiting for controller to respond to no-op\n"); in hpsa_init_reset_devices()
8012 dev_warn(&pdev->dev, "no-op failed%s\n", in hpsa_init_reset_devices()
8013 (i < 11 ? "; re-trying" : "")); in hpsa_init_reset_devices()
8024 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8025 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8026 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8027 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8028 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8029 h->cmd_pool, in hpsa_free_cmd_pool()
8030 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8031 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8032 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8034 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8035 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8036 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8037 h->errinfo_pool, in hpsa_free_cmd_pool()
8038 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8039 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8040 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8046 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8047 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8048 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8049 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8050 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8051 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8052 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8053 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8054 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8055 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8056 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8063 return -ENOMEM; in hpsa_alloc_cmd_pool()
8066 /* clear affinity hints and free MSI-X, MSI, or legacy INTx vectors */
8073 irq_vector = h->intr_mode; in hpsa_free_irqs()
8075 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8077 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8078 &h->q[h->intr_mode]); in hpsa_free_irqs()
8079 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8083 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8084 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8085 h->q[i] = 0; in hpsa_free_irqs()
8088 h->q[i] = 0; in hpsa_free_irqs()
8091 /* returns 0 on success; cleans up and returns -Enn on error */
8100 irq_vector = h->intr_mode; in hpsa_request_irqs()
8103 * initialize h->q[x] = x so that interrupt handlers know which in hpsa_request_irqs()
8107 h->q[i] = (u8) i; in hpsa_request_irqs()
8109 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8110 /* If performant mode and MSI-X, use multiple reply queues */ in hpsa_request_irqs()
8111 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8112 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8113 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8114 0, h->intrname[i], in hpsa_request_irqs()
8115 &h->q[i]); in hpsa_request_irqs()
8119 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8121 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8123 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8124 h->q[j] = 0; in hpsa_request_irqs()
8127 h->q[j] = 0; in hpsa_request_irqs()
8133 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8134 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8135 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8136 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8138 h->intrname[0], in hpsa_request_irqs()
8139 &h->q[h->intr_mode]); in hpsa_request_irqs()
8141 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8142 "%s-intx", h->devname); in hpsa_request_irqs()
8143 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8145 h->intrname[0], in hpsa_request_irqs()
8146 &h->q[h->intr_mode]); in hpsa_request_irqs()
8150 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8151 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8153 return -ENODEV; in hpsa_request_irqs()
8163 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8164 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8166 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8170 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8171 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8173 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8185 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8186 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8188 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8189 h->reply_queue_size, in hpsa_free_reply_queues()
8190 h->reply_queue[i].head, in hpsa_free_reply_queues()
8191 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8192 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8193 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8195 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8204 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8205 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8207 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8208 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8209 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8210 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8211 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8213 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8214 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8215 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8217 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8218 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8219 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8232 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8233 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8234 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8235 refcount = atomic_inc_return(&c->refcount); in fail_all_outstanding_cmds()
8237 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in fail_all_outstanding_cmds()
8239 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8244 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8254 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8257 wmb(); /* be sure the per-cpu variables are out to memory */ in set_lockup_detected_for_all_cpus()
8265 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8266 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8267 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8270 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8272 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8276 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8277 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8278 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8280 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8281 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8283 pci_disable_device(h->pdev); in controller_lockup_detected()
8295 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8296 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8304 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8305 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8309 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8310 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8311 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8312 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8318 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8319 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8350 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8354 device = h->dev[i]; in hpsa_set_ioaccel_status()
8358 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8364 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8386 * If ioaccel is to be re-enabled, re-enable later during the in hpsa_set_ioaccel_status()
8396 * transformation - change to the LVs of an Array. in hpsa_set_ioaccel_status()
8397 * degraded volume - component failure in hpsa_set_ioaccel_status()
8409 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8413 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8415 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8416 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8418 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8420 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8423 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8427 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8429 h->events, event_type); in hpsa_ack_ctlr_events()
8430 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8432 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8435 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8438 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8439 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8448 * Also check flag for driver-initiated rescan.
8452 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8453 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8457 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8460 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8461 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8473 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8474 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8477 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8478 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8479 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8480 list_del(&d->offline_list); in hpsa_offline_devices_ready()
8481 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8484 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8486 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8499 if (!h->lastlogicals) in hpsa_luns_changed()
8507 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8511 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8512 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8514 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8531 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8532 if (h->reset_in_progress) { in hpsa_perform_rescan()
8533 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8534 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8537 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8539 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8543 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8556 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8557 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8558 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8561 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8568 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8569 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8570 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8572 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8581 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8582 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8583 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8586 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8588 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8590 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8592 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8597 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8598 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8599 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8600 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8601 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8614 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8615 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8616 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8617 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8618 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8626 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8628 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8635 kfree(h->reply_map); in hpda_free_ctlr_info()
8647 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8648 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8668 dev_warn(&pdev->dev, "Board ID not found\n"); in hpsa_init_one()
8674 if (rc != -ENOTSUPP) in hpsa_init_one()
8677 * a proper hard reset, so returns -ENOTSUPP) we can try to do in hpsa_init_one()
8687 /* Command structures must be aligned on a 32-byte boundary because in hpsa_init_one()
8694 dev_err(&pdev->dev, "Failed to allocate controller head\n"); in hpsa_init_one()
8695 return -ENOMEM; in hpsa_init_one()
8698 h->pdev = pdev; in hpsa_init_one()
8700 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8701 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8702 spin_lock_init(&h->lock); in hpsa_init_one()
8703 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8704 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8705 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8706 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8708 /* Allocate and clear per-cpu variable lockup_detected */ in hpsa_init_one()
8709 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8710 if (!h->lockup_detected) { in hpsa_init_one()
8711 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8712 rc = -ENOMEM; in hpsa_init_one()
8721 /* relies on h-> settings made by hpsa_pci_init, including in hpsa_init_one()
8722 * interrupt_mode h->intr */ in hpsa_init_one()
8727 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8728 h->ctlr = number_of_controllers; in hpsa_init_one()
8732 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); in hpsa_init_one()
8734 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_init_one()
8736 dev_err(&pdev->dev, "no suitable DMA available\n"); in hpsa_init_one()
8742 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8753 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8754 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8755 mutex_init(&h->reset_mutex); in hpsa_init_one()
8756 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8757 h->scan_waiting = 0; in hpsa_init_one()
8760 h->ndevices = 0; in hpsa_init_one()
8762 spin_lock_init(&h->devlock); in hpsa_init_one()
8768 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8769 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8770 rc = -ENOMEM; in hpsa_init_one()
8774 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8775 if (!h->resubmit_wq) { in hpsa_init_one()
8776 rc = -ENOMEM; in hpsa_init_one()
8780 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8781 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8782 rc = -ENOMEM; in hpsa_init_one()
8800 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8801 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8802 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8807 dev_warn(&h->pdev->dev, in hpsa_init_one()
8828 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8829 dev_info(&h->pdev->dev, in hpsa_init_one()
8831 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8833 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8835 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8837 dev_info(&h->pdev->dev, in hpsa_init_one()
8840 /* since the controller's reset, we have to go back and re-init in hpsa_init_one()
8848 return -ENODEV; in hpsa_init_one()
8854 h->acciopath_status = 1; in hpsa_init_one()
8856 h->discovery_polling = 0; in hpsa_init_one()
8860 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8864 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8865 if (!h->lastlogicals) in hpsa_init_one()
8866 dev_info(&h->pdev->dev, in hpsa_init_one()
8875 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8876 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8877 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8878 h->heartbeat_sample_interval); in hpsa_init_one()
8879 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8880 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8881 h->heartbeat_sample_interval); in hpsa_init_one()
8882 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8883 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8888 kfree(h->lastlogicals); in hpsa_init_one()
8891 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8899 scsi_host_put(h->scsi_host); in hpsa_init_one()
8900 h->scsi_host = NULL; in hpsa_init_one()
8904 if (h->lockup_detected) { in hpsa_init_one()
8905 free_percpu(h->lockup_detected); in hpsa_init_one()
8906 h->lockup_detected = NULL; in hpsa_init_one()
8909 if (h->resubmit_wq) { in hpsa_init_one()
8910 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8911 h->resubmit_wq = NULL; in hpsa_init_one()
8913 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8914 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8915 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8917 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8918 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8919 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8947 if (c->err_info->CommandStatus != 0) in hpsa_flush_cache()
8949 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8965 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8981 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
8993 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9003 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9010 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9024 * To write all data in the battery backed cache to disks in __hpsa_shutdown()
9027 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9042 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9043 kfree(h->dev[i]); in hpsa_free_device_info()
9044 h->dev[i] = NULL; in hpsa_free_device_info()
9054 dev_err(&pdev->dev, "unable to remove device\n"); in hpsa_remove_one()
9060 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9061 h->remove_in_progress = 1; in hpsa_remove_one()
9062 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9063 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9064 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9065 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9066 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9067 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9068 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9078 if (h->scsi_host) in hpsa_remove_one()
9079 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9080 /* includes hpsa_free_irqs - init_one 4 */ in hpsa_remove_one()
9081 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9086 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9087 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9092 kfree(h->lastlogicals); in hpsa_remove_one()
9096 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9097 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9099 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9102 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9103 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9111 return -ENOSYS; in hpsa_suspend()
9117 return -ENOSYS; in hpsa_resume()
9166 * return -ENODEV on err, 0 on success (or no action)
9188 * with the number of 16-byte blocks a command of that size requires. in hpsa_enter_performant_mode()
9190 * the largest command possible requires SG_ENTRIES_IN_CMD + 4 16-byte in hpsa_enter_performant_mode()
9223 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9224 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9228 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9230 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9233 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9234 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9235 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9236 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9238 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9239 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9240 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9241 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9244 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9245 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9251 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9252 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9256 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9258 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9259 "performant mode problem - doorbell timeout\n"); in hpsa_enter_performant_mode()
9260 return -ENODEV; in hpsa_enter_performant_mode()
9262 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9264 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9265 "performant mode problem - transport not active\n"); in hpsa_enter_performant_mode()
9266 return -ENODEV; in hpsa_enter_performant_mode()
9269 h->access = access; in hpsa_enter_performant_mode()
9270 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9278 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9279 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9280 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9281 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9283 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9284 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9285 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9288 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9289 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9291 h->reply_queue_size); in hpsa_enter_performant_mode()
9296 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9297 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9299 cp->function = IOACCEL1_FUNCTION_SCSIIO; in hpsa_enter_performant_mode()
9300 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9302 cp->err_info_len = sizeof(struct ErrorInfo); in hpsa_enter_performant_mode()
9303 cp->sgl_offset = IOACCEL1_SGLOFFSET; in hpsa_enter_performant_mode()
9304 cp->host_context_flags = in hpsa_enter_performant_mode()
9306 cp->timeout_sec = 0; in hpsa_enter_performant_mode()
9307 cp->ReplyQueue = 0; in hpsa_enter_performant_mode()
9308 cp->tag = in hpsa_enter_performant_mode()
9310 cp->host_addr = in hpsa_enter_performant_mode()
9311 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9318 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9321 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9322 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9323 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9324 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9327 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9328 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9332 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9334 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9336 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9338 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9339 "performant mode problem - enabling ioaccel mode\n"); in hpsa_enter_performant_mode()
9340 return -ENODEV; in hpsa_enter_performant_mode()
9348 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9349 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9350 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9351 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9352 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9353 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9354 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9356 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9357 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9363 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9364 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9365 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9366 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9368 /* Command structures must be aligned on a 128-byte boundary in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9376 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9377 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9379 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9380 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9387 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9388 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9393 return -ENOMEM; in hpsa_alloc_ioaccel1_cmd_and_bft()
9401 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9402 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9403 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9404 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9405 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9406 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9407 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9409 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9410 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9420 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9421 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9422 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9423 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9427 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9428 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9429 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9433 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9438 rc = -ENOMEM; in hpsa_alloc_ioaccel2_cmd_and_bft()
9446 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9447 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9458 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9459 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9465 /* return -ENODEV on error, 0 on success (or no action)
9476 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9491 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9494 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9496 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9497 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9498 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9499 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9501 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9502 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9505 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9506 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9507 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9511 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9513 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9514 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9524 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9525 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9535 return c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_IOACCEL2; in is_accelerated_cmd()
9546 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9547 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9548 refcount = atomic_inc_return(&c->refcount); in hpsa_drain_accel_commands()
9569 phy = sas_phy_alloc(hpsa_sas_port->parent_node->parent_dev, in hpsa_alloc_sas_phy()
9570 hpsa_sas_port->next_phy_index); in hpsa_alloc_sas_phy()
9576 hpsa_sas_port->next_phy_index++; in hpsa_alloc_sas_phy()
9577 hpsa_sas_phy->phy = phy; in hpsa_alloc_sas_phy()
9578 hpsa_sas_phy->parent_port = hpsa_sas_port; in hpsa_alloc_sas_phy()
9585 struct sas_phy *phy = hpsa_sas_phy->phy; in hpsa_free_sas_phy()
9587 sas_port_delete_phy(hpsa_sas_phy->parent_port->port, phy); in hpsa_free_sas_phy()
9588 if (hpsa_sas_phy->added_to_port) in hpsa_free_sas_phy()
9589 list_del(&hpsa_sas_phy->phy_list_entry); in hpsa_free_sas_phy()
9601 hpsa_sas_port = hpsa_sas_phy->parent_port; in hpsa_sas_port_add_phy()
9602 phy = hpsa_sas_phy->phy; in hpsa_sas_port_add_phy()
9604 identify = &phy->identify; in hpsa_sas_port_add_phy()
9606 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_phy()
9607 identify->device_type = SAS_END_DEVICE; in hpsa_sas_port_add_phy()
9608 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9609 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9610 phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9611 phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9612 phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9613 phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9614 phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9616 rc = sas_phy_add(hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9620 sas_port_add_phy(hpsa_sas_port->port, hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9621 list_add_tail(&hpsa_sas_phy->phy_list_entry, in hpsa_sas_port_add_phy()
9622 &hpsa_sas_port->phy_list_head); in hpsa_sas_port_add_phy()
9623 hpsa_sas_phy->added_to_port = true; in hpsa_sas_port_add_phy()
9634 identify = &rphy->identify; in hpsa_sas_port_add_rphy()
9635 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_rphy()
9636 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9637 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9654 INIT_LIST_HEAD(&hpsa_sas_port->phy_list_head); in hpsa_alloc_sas_port()
9655 hpsa_sas_port->parent_node = hpsa_sas_node; in hpsa_alloc_sas_port()
9657 port = sas_port_alloc_num(hpsa_sas_node->parent_dev); in hpsa_alloc_sas_port()
9665 hpsa_sas_port->port = port; in hpsa_alloc_sas_port()
9666 hpsa_sas_port->sas_address = sas_address; in hpsa_alloc_sas_port()
9667 list_add_tail(&hpsa_sas_port->port_list_entry, in hpsa_alloc_sas_port()
9668 &hpsa_sas_node->port_list_head); in hpsa_alloc_sas_port()
9686 &hpsa_sas_port->phy_list_head, phy_list_entry) in hpsa_free_sas_port()
9689 sas_port_delete(hpsa_sas_port->port); in hpsa_free_sas_port()
9690 list_del(&hpsa_sas_port->port_list_entry); in hpsa_free_sas_port()
9700 hpsa_sas_node->parent_dev = parent_dev; in hpsa_alloc_sas_node()
9701 INIT_LIST_HEAD(&hpsa_sas_node->port_list_head); in hpsa_alloc_sas_node()
9716 &hpsa_sas_node->port_list_head, port_list_entry) in hpsa_free_sas_node()
9729 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9730 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9731 if (!device->sas_port) in hpsa_find_device_by_sas_rphy()
9733 if (device->sas_port->rphy == rphy) in hpsa_find_device_by_sas_rphy()
9748 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9752 return -ENOMEM; in hpsa_add_sas_host()
9754 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9756 rc = -ENODEV; in hpsa_add_sas_host()
9762 rc = -ENODEV; in hpsa_add_sas_host()
9770 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9775 sas_phy_free(hpsa_sas_phy->phy); in hpsa_add_sas_host()
9787 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9797 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, device->sas_address); in hpsa_add_sas_device()
9799 return -ENOMEM; in hpsa_add_sas_device()
9801 rphy = sas_end_device_alloc(hpsa_sas_port->port); in hpsa_add_sas_device()
9803 rc = -ENODEV; in hpsa_add_sas_device()
9807 hpsa_sas_port->rphy = rphy; in hpsa_add_sas_device()
9808 device->sas_port = hpsa_sas_port; in hpsa_add_sas_device()
9820 device->sas_port = NULL; in hpsa_add_sas_device()
9827 if (device->sas_port) { in hpsa_remove_sas_device()
9828 hpsa_free_sas_port(device->sas_port); in hpsa_remove_sas_device()
9829 device->sas_port = NULL; in hpsa_remove_sas_device()
9847 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9852 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9856 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9858 *identifier = sd->eli; in hpsa_sas_get_enclosure_identifier()
9866 return -ENXIO; in hpsa_sas_get_bay_identifier()
9895 return -EINVAL; in hpsa_sas_phy_speed()
9920 return -ENODEV; in hpsa_init()