Lines Matching +full:sml +full:- +full:size
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},
273 void *buff, size_t size, u16 page_code, unsigned char *scsi3addr,
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()
462 return -EACCES; in host_store_hp_ssd_smart_path_status()
463 len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count; in host_store_hp_ssd_smart_path_status()
467 return -EINVAL; in host_store_hp_ssd_smart_path_status()
469 h->acciopath_status = !!status; in host_store_hp_ssd_smart_path_status()
470 dev_warn(&h->pdev->dev, in host_store_hp_ssd_smart_path_status()
472 h->acciopath_status ? "enabled" : "disabled"); in host_store_hp_ssd_smart_path_status()
486 return -EACCES; in host_store_raid_offload_debug()
487 len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count; in host_store_raid_offload_debug()
491 return -EINVAL; in host_store_raid_offload_debug()
495 h->raid_offload_debug = debug_level; in host_store_raid_offload_debug()
496 dev_warn(&h->pdev->dev, "hpsa: Set raid_offload_debug level = %d\n", in host_store_raid_offload_debug()
497 h->raid_offload_debug); in host_store_raid_offload_debug()
508 hpsa_scan_start(h->scsi_host); in host_store_rescan()
514 device->offload_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
515 device->offload_to_be_enabled = 0; in hpsa_turn_off_ioaccel_for_device()
526 if (!h->hba_inquiry_data) in host_show_firmware_revision()
528 fwrev = &h->hba_inquiry_data[32]; in host_show_firmware_revision()
540 atomic_read(&h->commands_outstanding)); in host_show_commands_outstanding()
551 h->transMethod & CFGTBL_Trans_Performant ? in host_show_transport_mode()
563 (h->acciopath_status == 1) ? "enabled" : "disabled"); in host_show_hp_ssd_smart_path_status()
646 return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); in host_show_resettable()
664 #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 2)
665 #define PHYSICAL_DRIVE (ARRAY_SIZE(raid_label) - 1)
669 return !device->physical_device; in is_logical_device()
684 spin_lock_irqsave(&h->lock, flags); in raid_level_show()
685 hdev = sdev->hostdata; in raid_level_show()
687 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
688 return -ENODEV; in raid_level_show()
693 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
698 rlevel = hdev->raid_level; in raid_level_show()
699 spin_unlock_irqrestore(&h->lock, flags); in raid_level_show()
717 spin_lock_irqsave(&h->lock, flags); in lunid_show()
718 hdev = sdev->hostdata; in lunid_show()
720 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
721 return -ENODEV; in lunid_show()
723 memcpy(lunid, hdev->scsi3addr, sizeof(lunid)); in lunid_show()
724 spin_unlock_irqrestore(&h->lock, flags); in lunid_show()
739 spin_lock_irqsave(&h->lock, flags); in unique_id_show()
740 hdev = sdev->hostdata; in unique_id_show()
742 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
743 return -ENODEV; in unique_id_show()
745 memcpy(sn, hdev->device_id, sizeof(sn)); in unique_id_show()
746 spin_unlock_irqrestore(&h->lock, flags); in unique_id_show()
767 spin_lock_irqsave(&h->lock, flags); in sas_address_show()
768 hdev = sdev->hostdata; in sas_address_show()
769 if (!hdev || is_logical_device(hdev) || !hdev->expose_device) { in sas_address_show()
770 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
771 return -ENODEV; in sas_address_show()
773 sas_address = hdev->sas_address; in sas_address_show()
774 spin_unlock_irqrestore(&h->lock, flags); in sas_address_show()
790 spin_lock_irqsave(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
791 hdev = sdev->hostdata; in host_show_hp_ssd_smart_path_enabled()
793 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
794 return -ENODEV; in host_show_hp_ssd_smart_path_enabled()
796 offload_enabled = hdev->offload_enabled; in host_show_hp_ssd_smart_path_enabled()
797 spin_unlock_irqrestore(&h->lock, flags); in host_show_hp_ssd_smart_path_enabled()
799 if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) in host_show_hp_ssd_smart_path_enabled()
824 spin_lock_irqsave(&h->devlock, flags); in path_info_show()
825 hdev = sdev->hostdata; in path_info_show()
827 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
828 return -ENODEV; in path_info_show()
831 bay = hdev->bay; in path_info_show()
834 if (i == hdev->active_path_index) in path_info_show()
836 else if (hdev->path_map & path_map_index) in path_info_show()
842 PAGE_SIZE - output_len, in path_info_show()
844 h->scsi_host->host_no, in path_info_show()
845 hdev->bus, hdev->target, hdev->lun, in path_info_show()
846 scsi_device_type(hdev->devtype)); in path_info_show()
848 if (hdev->devtype == TYPE_RAID || is_logical_device(hdev)) { in path_info_show()
850 PAGE_SIZE - output_len, in path_info_show()
855 box = hdev->box[i]; in path_info_show()
856 memcpy(&phys_connector, &hdev->phys_connector[i], in path_info_show()
863 PAGE_SIZE - output_len, in path_info_show()
866 if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) && in path_info_show()
867 hdev->expose_device) { in path_info_show()
870 PAGE_SIZE - output_len, in path_info_show()
875 PAGE_SIZE - output_len, in path_info_show()
881 PAGE_SIZE - output_len, "BOX: %hhu %s\n", in path_info_show()
885 PAGE_SIZE - output_len, "%s\n", active); in path_info_show()
888 spin_unlock_irqrestore(&h->devlock, flags); in path_info_show()
899 return snprintf(buf, 20, "%d\n", h->ctlr); in host_show_ctlr_num()
909 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); in host_show_legacy_board()
979 .this_id = -1,
997 struct reply_queue_buffer *rq = &h->reply_queue[q]; in next_command()
999 if (h->transMethod & CFGTBL_Trans_io_accel1) in next_command()
1000 return h->access.command_completed(h, q); in next_command()
1002 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) in next_command()
1003 return h->access.command_completed(h, q); in next_command()
1005 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) { in next_command()
1006 a = rq->head[rq->current_entry]; in next_command()
1007 rq->current_entry++; in next_command()
1008 atomic_dec(&h->commands_outstanding); in next_command()
1013 if (rq->current_entry == h->max_commands) { in next_command()
1014 rq->current_entry = 0; in next_command()
1015 rq->wraparound ^= 1; in next_command()
1027 * bits 1-3 = block fetch table entry
1028 * bits 4-6 = command type (== 0)
1032 * bits 1-3 = block fetch table entry
1033 * bits 4-6 = command type (== 110)
1041 * bits 1-4 = block fetch table entry (note extra bit)
1042 * bits 4-6 = not needed, because ioaccel2 mode has
1048 * set bit 0 for pull model, bits 3-1 for block fetch
1051 #define DEFAULT_REPLY_QUEUE (-1)
1055 if (likely(h->transMethod & CFGTBL_Trans_Performant)) { in set_performant_mode()
1056 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); in set_performant_mode()
1057 if (unlikely(!h->msix_vectors)) in set_performant_mode()
1059 c->Header.ReplyQueue = reply_queue; in set_performant_mode()
1067 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in set_ioaccel1_performant_mode()
1073 cp->ReplyQueue = reply_queue; in set_ioaccel1_performant_mode()
1076 * - performant mode bit (bit 0) in set_ioaccel1_performant_mode()
1077 * - pull count (bits 1-3) in set_ioaccel1_performant_mode()
1078 * - command type (bits 4-6) in set_ioaccel1_performant_mode()
1080 c->busaddr |= 1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] << 1) | in set_ioaccel1_performant_mode()
1089 &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_tmf_performant_mode()
1094 cp->reply_queue = reply_queue; in set_ioaccel2_tmf_performant_mode()
1096 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_tmf_performant_mode()
1097 * - pull count (bits 0-3) in set_ioaccel2_tmf_performant_mode()
1098 * - command type isn't needed for ioaccel2 in set_ioaccel2_tmf_performant_mode()
1100 c->busaddr |= h->ioaccel2_blockFetchTable[0]; in set_ioaccel2_tmf_performant_mode()
1107 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in set_ioaccel2_performant_mode()
1113 cp->reply_queue = reply_queue; in set_ioaccel2_performant_mode()
1116 * - performant mode bit not used in ioaccel mode 2 in set_ioaccel2_performant_mode()
1117 * - pull count (bits 0-3) in set_ioaccel2_performant_mode()
1118 * - command type isn't needed for ioaccel2 in set_ioaccel2_performant_mode()
1120 c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); in set_ioaccel2_performant_mode()
1139 if (!is_firmware_flash_cmd(c->Request.CDB)) in dial_down_lockup_detection_during_fw_flash()
1141 atomic_inc(&h->firmware_flash_in_progress); in dial_down_lockup_detection_during_fw_flash()
1142 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL_DURING_FLASH; in dial_down_lockup_detection_during_fw_flash()
1148 if (is_firmware_flash_cmd(c->Request.CDB) && in dial_up_lockup_detection_on_fw_flash_complete()
1149 atomic_dec_and_test(&h->firmware_flash_in_progress)) in dial_up_lockup_detection_on_fw_flash_complete()
1150 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in dial_up_lockup_detection_on_fw_flash_complete()
1157 atomic_inc(&h->commands_outstanding); in __enqueue_cmd_and_start_io()
1161 if (c->device && !c->retry_pending) in __enqueue_cmd_and_start_io()
1162 atomic_inc(&c->device->commands_outstanding); in __enqueue_cmd_and_start_io()
1164 reply_queue = h->reply_map[raw_smp_processor_id()]; in __enqueue_cmd_and_start_io()
1165 switch (c->cmd_type) { in __enqueue_cmd_and_start_io()
1168 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); in __enqueue_cmd_and_start_io()
1172 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1176 writel(c->busaddr, h->vaddr + IOACCEL2_INBOUND_POSTQ_32); in __enqueue_cmd_and_start_io()
1180 h->access.submit_command(h, c); in __enqueue_cmd_and_start_io()
1196 if (!h->hba_inquiry_data) in is_scsi_rev_5()
1198 if ((h->hba_inquiry_data[2] & 0x07) == 5) in is_scsi_rev_5()
1207 * assumes h->devlock is held in hpsa_find_target_lun()
1214 for (i = 0; i < h->ndevices; i++) { in hpsa_find_target_lun()
1215 if (h->dev[i]->bus == bus && h->dev[i]->target != -1) in hpsa_find_target_lun()
1216 __set_bit(h->dev[i]->target, lun_taken); in hpsa_find_target_lun()
1235 if (h == NULL || h->pdev == NULL || h->scsi_host == NULL) in hpsa_show_dev_msg()
1238 switch (dev->devtype) { in hpsa_show_dev_msg()
1247 if (dev->external) in hpsa_show_dev_msg()
1249 else if (!is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_show_dev_msg()
1253 snprintf(label, LABEL_SIZE, "RAID-%s", in hpsa_show_dev_msg()
1254 dev->raid_level > RAID_UNKNOWN ? "?" : in hpsa_show_dev_msg()
1255 raid_label[dev->raid_level]); in hpsa_show_dev_msg()
1271 dev_printk(level, &h->pdev->dev, in hpsa_show_dev_msg()
1273 h->scsi_host->host_no, dev->bus, dev->target, dev->lun, in hpsa_show_dev_msg()
1275 scsi_device_type(dev->devtype), in hpsa_show_dev_msg()
1276 dev->vendor, in hpsa_show_dev_msg()
1277 dev->model, in hpsa_show_dev_msg()
1279 dev->offload_config ? '+' : '-', in hpsa_show_dev_msg()
1280 dev->offload_to_be_enabled ? '+' : '-', in hpsa_show_dev_msg()
1281 dev->expose_device); in hpsa_show_dev_msg()
1284 /* Add an entry into h->dev[] array. */
1289 /* assumes h->devlock is held */ in hpsa_scsi_add_entry()
1290 int n = h->ndevices; in hpsa_scsi_add_entry()
1296 dev_err(&h->pdev->dev, "too many devices, some will be " in hpsa_scsi_add_entry()
1298 return -1; in hpsa_scsi_add_entry()
1302 if (device->lun != -1) in hpsa_scsi_add_entry()
1306 /* If this device a non-zero lun of a multi-lun device in hpsa_scsi_add_entry()
1307 * byte 4 of the 8-byte LUN addr will contain the logical in hpsa_scsi_add_entry()
1310 if (device->scsi3addr[4] == 0) { in hpsa_scsi_add_entry()
1311 /* This is not a non-zero lun of a multi-lun device */ in hpsa_scsi_add_entry()
1312 if (hpsa_find_target_lun(h, device->scsi3addr, in hpsa_scsi_add_entry()
1313 device->bus, &device->target, &device->lun) != 0) in hpsa_scsi_add_entry()
1314 return -1; in hpsa_scsi_add_entry()
1318 /* This is a non-zero lun of a multi-lun device. in hpsa_scsi_add_entry()
1324 memcpy(addr1, device->scsi3addr, 8); in hpsa_scsi_add_entry()
1328 sd = h->dev[i]; in hpsa_scsi_add_entry()
1329 memcpy(addr2, sd->scsi3addr, 8); in hpsa_scsi_add_entry()
1334 device->bus = sd->bus; in hpsa_scsi_add_entry()
1335 device->target = sd->target; in hpsa_scsi_add_entry()
1336 device->lun = device->scsi3addr[4]; in hpsa_scsi_add_entry()
1340 if (device->lun == -1) { in hpsa_scsi_add_entry()
1341 dev_warn(&h->pdev->dev, "physical device with no LUN=0," in hpsa_scsi_add_entry()
1344 return -1; in hpsa_scsi_add_entry()
1349 h->dev[n] = device; in hpsa_scsi_add_entry()
1350 h->ndevices++; in hpsa_scsi_add_entry()
1354 device->expose_device ? "added" : "masked"); in hpsa_scsi_add_entry()
1361 * Update an entry in h->dev[] array.
1366 /* assumes h->devlock is held */ in hpsa_scsi_update_entry()
1370 h->dev[entry]->raid_level = new_entry->raid_level; in hpsa_scsi_update_entry()
1375 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1378 if (new_entry->offload_config && new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1385 * h->dev[entry]->offload_enabled is currently 0. in hpsa_scsi_update_entry()
1387 h->dev[entry]->raid_map = new_entry->raid_map; in hpsa_scsi_update_entry()
1388 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1390 if (new_entry->offload_to_be_enabled) { in hpsa_scsi_update_entry()
1391 h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; in hpsa_scsi_update_entry()
1394 h->dev[entry]->hba_ioaccel_enabled = new_entry->hba_ioaccel_enabled; in hpsa_scsi_update_entry()
1395 h->dev[entry]->offload_config = new_entry->offload_config; in hpsa_scsi_update_entry()
1396 h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; in hpsa_scsi_update_entry()
1397 h->dev[entry]->queue_depth = new_entry->queue_depth; in hpsa_scsi_update_entry()
1401 * ioaccel on until we can update h->dev[entry]->phys_disk[], but we in hpsa_scsi_update_entry()
1404 h->dev[entry]->offload_to_be_enabled = new_entry->offload_to_be_enabled; in hpsa_scsi_update_entry()
1409 if (!new_entry->offload_to_be_enabled) in hpsa_scsi_update_entry()
1410 h->dev[entry]->offload_enabled = 0; in hpsa_scsi_update_entry()
1412 hpsa_show_dev_msg(KERN_INFO, h, h->dev[entry], "updated"); in hpsa_scsi_update_entry()
1415 /* Replace an entry from h->dev[] array. */
1421 /* assumes h->devlock is held */ in hpsa_scsi_replace_entry()
1423 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_replace_entry()
1430 if (new_entry->target == -1) { in hpsa_scsi_replace_entry()
1431 new_entry->target = h->dev[entry]->target; in hpsa_scsi_replace_entry()
1432 new_entry->lun = h->dev[entry]->lun; in hpsa_scsi_replace_entry()
1435 h->dev[entry] = new_entry; in hpsa_scsi_replace_entry()
1442 /* Remove an entry from h->dev[] array. */
1446 /* assumes h->devlock is held */ in hpsa_scsi_remove_entry()
1452 sd = h->dev[entry]; in hpsa_scsi_remove_entry()
1453 removed[*nremoved] = h->dev[entry]; in hpsa_scsi_remove_entry()
1456 for (i = entry; i < h->ndevices-1; i++) in hpsa_scsi_remove_entry()
1457 h->dev[i] = h->dev[i+1]; in hpsa_scsi_remove_entry()
1458 h->ndevices--; in hpsa_scsi_remove_entry()
1475 /* called when scsi_add_device fails in order to re-adjust in fixup_botched_add()
1476 * h->dev[] to match the mid layer's view. in fixup_botched_add()
1481 spin_lock_irqsave(&h->lock, flags); in fixup_botched_add()
1482 for (i = 0; i < h->ndevices; i++) { in fixup_botched_add()
1483 if (h->dev[i] == added) { in fixup_botched_add()
1484 for (j = i; j < h->ndevices-1; j++) in fixup_botched_add()
1485 h->dev[j] = h->dev[j+1]; in fixup_botched_add()
1486 h->ndevices--; in fixup_botched_add()
1490 spin_unlock_irqrestore(&h->lock, flags); in fixup_botched_add()
1501 if (memcmp(dev1->scsi3addr, dev2->scsi3addr, in device_is_the_same()
1502 sizeof(dev1->scsi3addr)) != 0) in device_is_the_same()
1504 if (memcmp(dev1->device_id, dev2->device_id, in device_is_the_same()
1505 sizeof(dev1->device_id)) != 0) in device_is_the_same()
1507 if (memcmp(dev1->model, dev2->model, sizeof(dev1->model)) != 0) in device_is_the_same()
1509 if (memcmp(dev1->vendor, dev2->vendor, sizeof(dev1->vendor)) != 0) in device_is_the_same()
1511 if (dev1->devtype != dev2->devtype) in device_is_the_same()
1513 if (dev1->bus != dev2->bus) in device_is_the_same()
1525 if (dev1->raid_level != dev2->raid_level) in device_updated()
1527 if (dev1->offload_config != dev2->offload_config) in device_updated()
1529 if (dev1->offload_to_be_enabled != dev2->offload_to_be_enabled) in device_updated()
1531 if (!is_logical_dev_addr_mode(dev1->scsi3addr)) in device_updated()
1532 if (dev1->queue_depth != dev2->queue_depth) in device_updated()
1543 if (dev1->ioaccel_handle != dev2->ioaccel_handle) in device_updated()
1571 if (SCSI3ADDR_EQ(needle->scsi3addr, haystack[i]->scsi3addr)) { in hpsa_scsi_find_entry()
1579 if (needle->volume_offline) in hpsa_scsi_find_entry()
1585 *index = -1; in hpsa_scsi_find_entry()
1596 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1597 list_for_each_entry(device, &h->offline_device_list, offline_list) { in hpsa_monitor_offline_device()
1598 if (memcmp(device->scsi3addr, scsi3addr, in hpsa_monitor_offline_device()
1599 sizeof(device->scsi3addr)) == 0) { in hpsa_monitor_offline_device()
1600 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1604 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1611 memcpy(device->scsi3addr, scsi3addr, sizeof(device->scsi3addr)); in hpsa_monitor_offline_device()
1612 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1613 list_add_tail(&device->offline_list, &h->offline_device_list); in hpsa_monitor_offline_device()
1614 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_monitor_offline_device()
1621 if (sd->volume_offline == HPSA_VPD_LV_STATUS_UNSUPPORTED) 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()
1626 switch (sd->volume_offline) { in hpsa_show_volume_status()
1630 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1632 h->scsi_host->host_no, in hpsa_show_volume_status()
1633 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1636 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1638 h->scsi_host->host_no, in hpsa_show_volume_status()
1639 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1642 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1644 h->scsi_host->host_no, in hpsa_show_volume_status()
1645 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1648 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1650 h->scsi_host->host_no, in hpsa_show_volume_status()
1651 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1654 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1656 h->scsi_host->host_no, in hpsa_show_volume_status()
1657 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1660 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1661 …d Volume is not encrypted and cannot be accessed because controller is in encryption-only mode.\n", in hpsa_show_volume_status()
1662 h->scsi_host->host_no, in hpsa_show_volume_status()
1663 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1666 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1668 h->scsi_host->host_no, in hpsa_show_volume_status()
1669 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1672 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1673 "C%d:B%d:T%d:L%d Volume is undergoing encryption re-keying process.\n", in hpsa_show_volume_status()
1674 h->scsi_host->host_no, in hpsa_show_volume_status()
1675 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1678 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1680 h->scsi_host->host_no, in hpsa_show_volume_status()
1681 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1684 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1686 h->scsi_host->host_no, in hpsa_show_volume_status()
1687 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1690 dev_info(&h->pdev->dev, in hpsa_show_volume_status()
1692 h->scsi_host->host_no, in hpsa_show_volume_status()
1693 sd->bus, sd->target, sd->lun); in hpsa_show_volume_status()
1706 struct raid_map_data *map = &logical_drive->raid_map; in hpsa_figure_phys_disk_ptrs()
1707 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_figure_phys_disk_ptrs()
1709 int total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_figure_phys_disk_ptrs()
1710 le16_to_cpu(map->metadata_disks_per_row); in hpsa_figure_phys_disk_ptrs()
1711 int nraid_map_entries = le16_to_cpu(map->row_cnt) * in hpsa_figure_phys_disk_ptrs()
1712 le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1714 int nphys_disk = le16_to_cpu(map->layout_map_count) * in hpsa_figure_phys_disk_ptrs()
1721 logical_drive->nphysical_disks = nraid_map_entries; in hpsa_figure_phys_disk_ptrs()
1725 logical_drive->phys_disk[i] = NULL; in hpsa_figure_phys_disk_ptrs()
1726 if (!logical_drive->offload_config) in hpsa_figure_phys_disk_ptrs()
1731 if (dev[j]->devtype != TYPE_DISK && in hpsa_figure_phys_disk_ptrs()
1732 dev[j]->devtype != TYPE_ZBC) in hpsa_figure_phys_disk_ptrs()
1736 if (dev[j]->ioaccel_handle != dd[i].ioaccel_handle) in hpsa_figure_phys_disk_ptrs()
1739 logical_drive->phys_disk[i] = dev[j]; in hpsa_figure_phys_disk_ptrs()
1741 qdepth = min(h->nr_cmds, qdepth + in hpsa_figure_phys_disk_ptrs()
1742 logical_drive->phys_disk[i]->queue_depth); in hpsa_figure_phys_disk_ptrs()
1753 if (!logical_drive->phys_disk[i]) { in hpsa_figure_phys_disk_ptrs()
1754 dev_warn(&h->pdev->dev, in hpsa_figure_phys_disk_ptrs()
1757 h->scsi_host->host_no, logical_drive->bus, in hpsa_figure_phys_disk_ptrs()
1758 logical_drive->target, logical_drive->lun); in hpsa_figure_phys_disk_ptrs()
1760 logical_drive->queue_depth = 8; in hpsa_figure_phys_disk_ptrs()
1768 logical_drive->queue_depth = qdepth; in hpsa_figure_phys_disk_ptrs()
1770 if (logical_drive->external) in hpsa_figure_phys_disk_ptrs()
1771 logical_drive->queue_depth = EXTERNAL_QD; in hpsa_figure_phys_disk_ptrs()
1773 logical_drive->queue_depth = h->nr_cmds; in hpsa_figure_phys_disk_ptrs()
1785 if (dev[i]->devtype != TYPE_DISK && in hpsa_update_log_drive_phys_drive_ptrs()
1786 dev[i]->devtype != TYPE_ZBC) in hpsa_update_log_drive_phys_drive_ptrs()
1798 * re-configured and thus underwent a transformation, or in hpsa_update_log_drive_phys_drive_ptrs()
1810 if (!dev[i]->offload_enabled && dev[i]->offload_to_be_enabled) in hpsa_update_log_drive_phys_drive_ptrs()
1819 if (!h->scsi_host) in hpsa_add_device()
1823 rc = scsi_add_device(h->scsi_host, device->bus, in hpsa_add_device()
1824 device->target, device->lun); in hpsa_add_device()
1826 rc = hpsa_add_sas_device(h->sas_host, device); in hpsa_add_device()
1837 for (i = 0; i < h->nr_cmds; i++) { in hpsa_find_outstanding_commands_for_dev()
1838 struct CommandList *c = h->cmd_pool + i; in hpsa_find_outstanding_commands_for_dev()
1839 int refcount = atomic_inc_return(&c->refcount); in hpsa_find_outstanding_commands_for_dev()
1842 dev->scsi3addr)) { in hpsa_find_outstanding_commands_for_dev()
1845 spin_lock_irqsave(&h->lock, flags); /* Implied MB */ in hpsa_find_outstanding_commands_for_dev()
1848 spin_unlock_irqrestore(&h->lock, flags); in hpsa_find_outstanding_commands_for_dev()
1865 if (device->external) in hpsa_wait_for_outstanding_commands_for_dev()
1878 dev_warn(&h->pdev->dev, in hpsa_wait_for_outstanding_commands_for_dev()
1881 h->scsi_host->host_no, in hpsa_wait_for_outstanding_commands_for_dev()
1882 device->bus, device->target, device->lun, cmds); in hpsa_wait_for_outstanding_commands_for_dev()
1891 if (!h->scsi_host) in hpsa_remove_device()
1897 device->removed = 1; in hpsa_remove_device()
1901 sdev = scsi_device_lookup(h->scsi_host, device->bus, in hpsa_remove_device()
1902 device->target, device->lun); in hpsa_remove_device()
1926 * reality and updates h->dev[] to reflect that reality. in adjust_hpsa_scsi_table()
1936 * re-schedule the scan to see what happened. in adjust_hpsa_scsi_table()
1938 spin_lock_irqsave(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1939 if (h->reset_in_progress) { in adjust_hpsa_scsi_table()
1940 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
1941 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1944 spin_unlock_irqrestore(&h->reset_lock, flags); in adjust_hpsa_scsi_table()
1950 dev_warn(&h->pdev->dev, "out of memory in " in adjust_hpsa_scsi_table()
1955 spin_lock_irqsave(&h->devlock, flags); in adjust_hpsa_scsi_table()
1957 /* find any devices in h->dev[] that are not in in adjust_hpsa_scsi_table()
1958 * sd[] and remove them from h->dev[], and for any in adjust_hpsa_scsi_table()
1967 while (i < h->ndevices) { in adjust_hpsa_scsi_table()
1968 csd = h->dev[i]; in adjust_hpsa_scsi_table()
1989 * listed in h->dev[], adding them if they aren't found in adjust_hpsa_scsi_table()
1997 * as the SCSI mid-layer does not handle such devices well. in adjust_hpsa_scsi_table()
2001 if (sd[i]->volume_offline) { in adjust_hpsa_scsi_table()
2007 device_change = hpsa_scsi_find_entry(sd[i], h->dev, in adjust_hpsa_scsi_table()
2008 h->ndevices, &entry); in adjust_hpsa_scsi_table()
2017 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2022 hpsa_update_log_drive_phys_drive_ptrs(h, h->dev, h->ndevices); in adjust_hpsa_scsi_table()
2025 * Now that h->dev[]->phys_disk[] is coherent, we can enable in adjust_hpsa_scsi_table()
2032 for (i = 0; i < h->ndevices; i++) { in adjust_hpsa_scsi_table()
2033 if (h->dev[i] == NULL) in adjust_hpsa_scsi_table()
2035 h->dev[i]->offload_enabled = h->dev[i]->offload_to_be_enabled; in adjust_hpsa_scsi_table()
2038 spin_unlock_irqrestore(&h->devlock, flags); in adjust_hpsa_scsi_table()
2041 * brought online later. This must be done without holding h->devlock, in adjust_hpsa_scsi_table()
2042 * so don't touch h->dev[] in adjust_hpsa_scsi_table()
2047 if (sd[i]->volume_offline) in adjust_hpsa_scsi_table()
2048 hpsa_monitor_offline_device(h, sd[i]->scsi3addr); in adjust_hpsa_scsi_table()
2062 if (removed[i]->expose_device) in adjust_hpsa_scsi_table()
2074 if (!(added[i]->expose_device)) in adjust_hpsa_scsi_table()
2079 dev_warn(&h->pdev->dev, in adjust_hpsa_scsi_table()
2081 /* now we have to remove it from h->dev, in adjust_hpsa_scsi_table()
2085 h->drv_req_rescan = 1; in adjust_hpsa_scsi_table()
2095 * Assume's h->devlock is held.
2103 for (i = 0; i < h->ndevices; i++) { in lookup_hpsa_scsi_dev()
2104 sd = h->dev[i]; in lookup_hpsa_scsi_dev()
2105 if (sd->bus == bus && sd->target == target && sd->lun == lun) in lookup_hpsa_scsi_dev()
2118 spin_lock_irqsave(&h->devlock, flags); in hpsa_sdev_init()
2127 sd->target = sdev_id(sdev); in hpsa_sdev_init()
2128 sd->lun = sdev->lun; in hpsa_sdev_init()
2133 sdev_id(sdev), sdev->lun); in hpsa_sdev_init()
2135 if (sd && sd->expose_device) { in hpsa_sdev_init()
2136 atomic_set(&sd->ioaccel_cmds_out, 0); in hpsa_sdev_init()
2137 sdev->hostdata = sd; in hpsa_sdev_init()
2139 sdev->hostdata = NULL; in hpsa_sdev_init()
2140 spin_unlock_irqrestore(&h->devlock, flags); in hpsa_sdev_init()
2144 /* configure scsi device based on internal per-device structure */
2152 sd = sdev->hostdata; in hpsa_sdev_configure()
2153 sdev->no_uld_attach = !sd || !sd->expose_device; in hpsa_sdev_configure()
2156 sd->was_removed = 0; in hpsa_sdev_configure()
2157 queue_depth = sd->queue_depth != 0 ? in hpsa_sdev_configure()
2158 sd->queue_depth : sdev->host->can_queue; in hpsa_sdev_configure()
2159 if (sd->external) { in hpsa_sdev_configure()
2161 sdev->eh_timeout = HPSA_EH_PTRAID_TIMEOUT; in hpsa_sdev_configure()
2162 blk_queue_rq_timeout(sdev->request_queue, in hpsa_sdev_configure()
2165 if (is_hba_lunid(sd->scsi3addr)) { in hpsa_sdev_configure()
2166 sdev->eh_timeout = CTLR_TIMEOUT; in hpsa_sdev_configure()
2167 blk_queue_rq_timeout(sdev->request_queue, CTLR_TIMEOUT); in hpsa_sdev_configure()
2170 queue_depth = sdev->host->can_queue; in hpsa_sdev_configure()
2182 hdev = sdev->hostdata; in hpsa_sdev_destroy()
2185 hdev->was_removed = 1; in hpsa_sdev_destroy()
2192 if (!h->ioaccel2_cmd_sg_list) in hpsa_free_ioaccel2_sg_chain_blocks()
2194 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_ioaccel2_sg_chain_blocks()
2195 kfree(h->ioaccel2_cmd_sg_list[i]); in hpsa_free_ioaccel2_sg_chain_blocks()
2196 h->ioaccel2_cmd_sg_list[i] = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2198 kfree(h->ioaccel2_cmd_sg_list); in hpsa_free_ioaccel2_sg_chain_blocks()
2199 h->ioaccel2_cmd_sg_list = NULL; in hpsa_free_ioaccel2_sg_chain_blocks()
2206 if (h->chainsize <= 0) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2209 h->ioaccel2_cmd_sg_list = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2210 kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2212 if (!h->ioaccel2_cmd_sg_list) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2213 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2214 for (i = 0; i < h->nr_cmds; i++) { in hpsa_allocate_ioaccel2_sg_chain_blocks()
2215 h->ioaccel2_cmd_sg_list[i] = in hpsa_allocate_ioaccel2_sg_chain_blocks()
2216 kmalloc_array(h->maxsgentries, in hpsa_allocate_ioaccel2_sg_chain_blocks()
2217 sizeof(*h->ioaccel2_cmd_sg_list[i]), in hpsa_allocate_ioaccel2_sg_chain_blocks()
2219 if (!h->ioaccel2_cmd_sg_list[i]) in hpsa_allocate_ioaccel2_sg_chain_blocks()
2226 return -ENOMEM; in hpsa_allocate_ioaccel2_sg_chain_blocks()
2233 if (!h->cmd_sg_list) in hpsa_free_sg_chain_blocks()
2235 for (i = 0; i < h->nr_cmds; i++) { in hpsa_free_sg_chain_blocks()
2236 kfree(h->cmd_sg_list[i]); in hpsa_free_sg_chain_blocks()
2237 h->cmd_sg_list[i] = NULL; in hpsa_free_sg_chain_blocks()
2239 kfree(h->cmd_sg_list); in hpsa_free_sg_chain_blocks()
2240 h->cmd_sg_list = NULL; in hpsa_free_sg_chain_blocks()
2247 if (h->chainsize <= 0) in hpsa_alloc_sg_chain_blocks()
2250 h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), in hpsa_alloc_sg_chain_blocks()
2252 if (!h->cmd_sg_list) in hpsa_alloc_sg_chain_blocks()
2253 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2255 for (i = 0; i < h->nr_cmds; i++) { in hpsa_alloc_sg_chain_blocks()
2256 h->cmd_sg_list[i] = kmalloc_array(h->chainsize, in hpsa_alloc_sg_chain_blocks()
2257 sizeof(*h->cmd_sg_list[i]), in hpsa_alloc_sg_chain_blocks()
2259 if (!h->cmd_sg_list[i]) in hpsa_alloc_sg_chain_blocks()
2267 return -ENOMEM; in hpsa_alloc_sg_chain_blocks()
2277 chain_block = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_map_ioaccel2_sg_chain_block()
2278 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_map_ioaccel2_sg_chain_block()
2279 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_size, in hpsa_map_ioaccel2_sg_chain_block()
2281 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_ioaccel2_sg_chain_block()
2283 cp->sg->address = 0; in hpsa_map_ioaccel2_sg_chain_block()
2284 return -1; in hpsa_map_ioaccel2_sg_chain_block()
2286 cp->sg->address = cpu_to_le64(temp64); in hpsa_map_ioaccel2_sg_chain_block()
2297 chain_sg = cp->sg; in hpsa_unmap_ioaccel2_sg_chain_block()
2298 temp64 = le64_to_cpu(chain_sg->address); in hpsa_unmap_ioaccel2_sg_chain_block()
2299 chain_size = le32_to_cpu(cp->sg[0].length); in hpsa_unmap_ioaccel2_sg_chain_block()
2300 dma_unmap_single(&h->pdev->dev, temp64, chain_size, DMA_TO_DEVICE); in hpsa_unmap_ioaccel2_sg_chain_block()
2310 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_map_sg_chain_block()
2311 chain_block = h->cmd_sg_list[c->cmdindex]; in hpsa_map_sg_chain_block()
2312 chain_sg->Ext = cpu_to_le32(HPSA_SG_CHAIN); in hpsa_map_sg_chain_block()
2314 (le16_to_cpu(c->Header.SGTotal) - h->max_cmd_sg_entries); in hpsa_map_sg_chain_block()
2315 chain_sg->Len = cpu_to_le32(chain_len); in hpsa_map_sg_chain_block()
2316 temp64 = dma_map_single(&h->pdev->dev, chain_block, chain_len, in hpsa_map_sg_chain_block()
2318 if (dma_mapping_error(&h->pdev->dev, temp64)) { in hpsa_map_sg_chain_block()
2320 chain_sg->Addr = cpu_to_le64(0); in hpsa_map_sg_chain_block()
2321 return -1; in hpsa_map_sg_chain_block()
2323 chain_sg->Addr = cpu_to_le64(temp64); in hpsa_map_sg_chain_block()
2332 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries) in hpsa_unmap_sg_chain_block()
2335 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; in hpsa_unmap_sg_chain_block()
2336 dma_unmap_single(&h->pdev->dev, le64_to_cpu(chain_sg->Addr), in hpsa_unmap_sg_chain_block()
2337 le32_to_cpu(chain_sg->Len), DMA_TO_DEVICE); in hpsa_unmap_sg_chain_block()
2355 switch (c2->error_data.serv_response) { in handle_ioaccel_mode2_error()
2357 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2360 cmd->result = 0; in handle_ioaccel_mode2_error()
2363 cmd->result |= SAM_STAT_CHECK_CONDITION; in handle_ioaccel_mode2_error()
2364 if (c2->error_data.data_present != in handle_ioaccel_mode2_error()
2366 memset(cmd->sense_buffer, 0, in handle_ioaccel_mode2_error()
2371 data_len = c2->error_data.sense_data_len; in handle_ioaccel_mode2_error()
2374 if (data_len > sizeof(c2->error_data.sense_data_buff)) in handle_ioaccel_mode2_error()
2376 sizeof(c2->error_data.sense_data_buff); in handle_ioaccel_mode2_error()
2377 memcpy(cmd->sense_buffer, in handle_ioaccel_mode2_error()
2378 c2->error_data.sense_data_buff, data_len); in handle_ioaccel_mode2_error()
2399 switch (c2->error_data.status) { in handle_ioaccel_mode2_error()
2406 cmd->result = (DID_OK << 16); /* host byte */ in handle_ioaccel_mode2_error()
2408 &c2->error_data.resid_cnt[0]); in handle_ioaccel_mode2_error()
2419 * from going down. This allows the potential re-insert in handle_ioaccel_mode2_error()
2422 if (dev->physical_device && dev->expose_device) { in handle_ioaccel_mode2_error()
2423 cmd->result = DID_NO_CONNECT << 16; in handle_ioaccel_mode2_error()
2424 dev->removed = 1; in handle_ioaccel_mode2_error()
2425 h->drv_req_rescan = 1; in handle_ioaccel_mode2_error()
2426 dev_warn(&h->pdev->dev, in handle_ioaccel_mode2_error()
2454 if (dev->in_reset) in handle_ioaccel_mode2_error()
2463 struct hpsa_scsi_dev_t *dev = c->device; in hpsa_cmd_resolve_events()
2466 * Reset c->scsi_cmd here so that the reset handler will know in hpsa_cmd_resolve_events()
2470 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_resolve_events()
2473 atomic_dec(&dev->commands_outstanding); in hpsa_cmd_resolve_events()
2474 if (dev->in_reset && in hpsa_cmd_resolve_events()
2475 atomic_read(&dev->commands_outstanding) <= 0) in hpsa_cmd_resolve_events()
2476 wake_up_all(&h->event_sync_wait_queue); in hpsa_cmd_resolve_events()
2497 INIT_WORK(&c->work, hpsa_command_resubmit_worker); in hpsa_retry_cmd()
2498 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); in hpsa_retry_cmd()
2505 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in process_ioaccel2_completion()
2508 if (likely(c2->error_data.serv_response == 0 && in process_ioaccel2_completion()
2509 c2->error_data.status == 0)) { in process_ioaccel2_completion()
2510 cmd->result = 0; in process_ioaccel2_completion()
2520 c2->error_data.serv_response == in process_ioaccel2_completion()
2522 if (c2->error_data.status == in process_ioaccel2_completion()
2527 if (dev->in_reset) { in process_ioaccel2_completion()
2528 cmd->result = DID_RESET << 16; in process_ioaccel2_completion()
2545 u8 tmf_status = cp->err_info->ScsiStatus; in hpsa_evaluate_tmf_status()
2551 * ei->CommandStatus == 0 for this case. in hpsa_evaluate_tmf_status()
2562 dev_warn(&h->pdev->dev, "Unknown TMF status: 0x%02x\n", in hpsa_evaluate_tmf_status()
2566 return -tmf_status; in hpsa_evaluate_tmf_status()
2582 ei = cp->err_info; in complete_scsi_command()
2583 cmd = cp->scsi_cmd; in complete_scsi_command()
2584 h = cp->h; in complete_scsi_command()
2586 if (!cmd->device) { in complete_scsi_command()
2587 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2591 dev = cmd->device->hostdata; in complete_scsi_command()
2593 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2596 c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2599 if ((cp->cmd_type == CMD_SCSI) && in complete_scsi_command()
2600 (le16_to_cpu(cp->Header.SGTotal) > h->max_cmd_sg_entries)) in complete_scsi_command()
2603 if ((cp->cmd_type == CMD_IOACCEL2) && in complete_scsi_command()
2604 (c2->sg[0].chain_indicator == IOACCEL2_CHAIN)) in complete_scsi_command()
2607 cmd->result = (DID_OK << 16); /* host byte */ in complete_scsi_command()
2609 /* SCSI command has already been cleaned up in SML */ in complete_scsi_command()
2610 if (dev->was_removed) { in complete_scsi_command()
2615 if (cp->cmd_type == CMD_IOACCEL2 || cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2616 if (dev->physical_device && dev->expose_device && in complete_scsi_command()
2617 dev->removed) { in complete_scsi_command()
2618 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2621 if (likely(cp->phys_disk != NULL)) in complete_scsi_command()
2622 atomic_dec(&cp->phys_disk->ioaccel_cmds_out); in complete_scsi_command()
2630 if (unlikely(ei->CommandStatus == CMD_CTLR_LOCKUP)) { in complete_scsi_command()
2632 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2636 if (cp->cmd_type == CMD_IOACCEL2) in complete_scsi_command()
2639 scsi_set_resid(cmd, ei->ResidualCnt); in complete_scsi_command()
2640 if (ei->CommandStatus == 0) in complete_scsi_command()
2646 if (cp->cmd_type == CMD_IOACCEL1) { in complete_scsi_command()
2647 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; in complete_scsi_command()
2648 cp->Header.SGList = scsi_sg_count(cmd); in complete_scsi_command()
2649 cp->Header.SGTotal = cpu_to_le16(cp->Header.SGList); in complete_scsi_command()
2650 cp->Request.CDBLen = le16_to_cpu(c->io_flags) & in complete_scsi_command()
2652 cp->Header.tag = c->tag; in complete_scsi_command()
2653 memcpy(cp->Header.LUN.LunAddrBytes, c->CISS_LUN, 8); in complete_scsi_command()
2654 memcpy(cp->Request.CDB, c->CDB, cp->Request.CDBLen); in complete_scsi_command()
2661 if (ei->CommandStatus == CMD_IOACCEL_DISABLED) in complete_scsi_command()
2662 dev->offload_enabled = 0; in complete_scsi_command()
2668 switch (ei->CommandStatus) { in complete_scsi_command()
2671 cmd->result |= ei->ScsiStatus; in complete_scsi_command()
2673 if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo)) in complete_scsi_command()
2676 sense_data_size = sizeof(ei->SenseInfo); in complete_scsi_command()
2677 if (ei->SenseLen < sense_data_size) in complete_scsi_command()
2678 sense_data_size = ei->SenseLen; in complete_scsi_command()
2679 memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size); in complete_scsi_command()
2680 if (ei->ScsiStatus) in complete_scsi_command()
2681 decode_sense_data(ei->SenseInfo, sense_data_size, in complete_scsi_command()
2683 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) { in complete_scsi_command()
2686 cmd->result |= DID_SOFT_ERROR << 16; in complete_scsi_command()
2690 h->drv_req_rescan = 1; in complete_scsi_command()
2694 dev->removed = 1; in complete_scsi_command()
2695 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2704 if (ei->ScsiStatus) { in complete_scsi_command()
2705 dev_warn(&h->pdev->dev, "cp %p has status 0x%x " in complete_scsi_command()
2708 cp, ei->ScsiStatus, in complete_scsi_command()
2710 cmd->result); in complete_scsi_command()
2712 dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. " in complete_scsi_command()
2727 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2734 dev_warn(&h->pdev->dev, in complete_scsi_command()
2735 "CDB %16phN data overrun\n", cp->Request.CDB); in complete_scsi_command()
2740 /* We get CMD_INVALID if you address a non-existent device in complete_scsi_command()
2746 cmd->result = DID_NO_CONNECT << 16; in complete_scsi_command()
2750 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2751 dev_warn(&h->pdev->dev, "CDB %16phN : protocol error\n", in complete_scsi_command()
2752 cp->Request.CDB); in complete_scsi_command()
2755 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2756 dev_warn(&h->pdev->dev, "CDB %16phN : hardware error\n", in complete_scsi_command()
2757 cp->Request.CDB); in complete_scsi_command()
2760 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2761 dev_warn(&h->pdev->dev, "CDB %16phN : connection lost\n", in complete_scsi_command()
2762 cp->Request.CDB); in complete_scsi_command()
2765 cmd->result = DID_ABORT << 16; in complete_scsi_command()
2768 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2769 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", in complete_scsi_command()
2770 cp->Request.CDB); in complete_scsi_command()
2773 cmd->result = DID_SOFT_ERROR << 16; /* retry the command */ in complete_scsi_command()
2774 dev_warn(&h->pdev->dev, "CDB %16phN : unsolicited abort\n", in complete_scsi_command()
2775 cp->Request.CDB); in complete_scsi_command()
2778 cmd->result = DID_TIME_OUT << 16; in complete_scsi_command()
2779 dev_warn(&h->pdev->dev, "CDB %16phN timed out\n", in complete_scsi_command()
2780 cp->Request.CDB); in complete_scsi_command()
2783 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2784 dev_warn(&h->pdev->dev, "Command unabortable\n"); in complete_scsi_command()
2788 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2791 /* This only handles the direct pass-through case since RAID in complete_scsi_command()
2794 cmd->result = DID_SOFT_ERROR << 16; in complete_scsi_command()
2795 dev_warn(&h->pdev->dev, in complete_scsi_command()
2799 cmd->result = DID_ERROR << 16; in complete_scsi_command()
2800 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", in complete_scsi_command()
2801 cp, ei->CommandStatus); in complete_scsi_command()
2813 dma_unmap_single(&pdev->dev, le64_to_cpu(c->SG[i].Addr), in hpsa_pci_unmap()
2814 le32_to_cpu(c->SG[i].Len), in hpsa_pci_unmap()
2827 cp->Header.SGList = 0; in hpsa_map_one()
2828 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2832 addr64 = dma_map_single(&pdev->dev, buf, buflen, data_direction); in hpsa_map_one()
2833 if (dma_mapping_error(&pdev->dev, addr64)) { in hpsa_map_one()
2835 cp->Header.SGList = 0; in hpsa_map_one()
2836 cp->Header.SGTotal = cpu_to_le16(0); in hpsa_map_one()
2837 return -1; in hpsa_map_one()
2839 cp->SG[0].Addr = cpu_to_le64(addr64); in hpsa_map_one()
2840 cp->SG[0].Len = cpu_to_le32(buflen); in hpsa_map_one()
2841 cp->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* we are not chaining */ in hpsa_map_one()
2842 cp->Header.SGList = 1; /* no. SGs contig in this cmd */ in hpsa_map_one()
2843 cp->Header.SGTotal = cpu_to_le16(1); /* total sgs in cmd list */ in hpsa_map_one()
2847 #define NO_TIMEOUT ((unsigned long) -1)
2854 c->waiting = &wait; in hpsa_scsi_do_simple_cmd_core()
2857 /* TODO: get rid of this no-timeout thing */ in hpsa_scsi_do_simple_cmd_core()
2863 dev_warn(&h->pdev->dev, "Command timed out.\n"); in hpsa_scsi_do_simple_cmd_core()
2864 return -ETIMEDOUT; in hpsa_scsi_do_simple_cmd_core()
2873 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in hpsa_scsi_do_simple_cmd()
2885 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in lockup_detected()
2900 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_scsi_do_simple_cmd_with_retry()
2914 hpsa_pci_unmap(h->pdev, c, 1, data_direction); in hpsa_scsi_do_simple_cmd_with_retry()
2916 rc = -EIO; in hpsa_scsi_do_simple_cmd_with_retry()
2923 const u8 *cdb = c->Request.CDB; in hpsa_print_cmd()
2924 const u8 *lun = c->Header.LUN.LunAddrBytes; in hpsa_print_cmd()
2926 dev_warn(&h->pdev->dev, "%s: LUN:%8phN CDB:%16phN\n", in hpsa_print_cmd()
2933 const struct ErrorInfo *ei = cp->err_info; in hpsa_scsi_interpret_error()
2934 struct device *d = &cp->h->pdev->dev; in hpsa_scsi_interpret_error()
2938 switch (ei->CommandStatus) { in hpsa_scsi_interpret_error()
2940 if (ei->SenseLen > sizeof(ei->SenseInfo)) in hpsa_scsi_interpret_error()
2941 sense_len = sizeof(ei->SenseInfo); in hpsa_scsi_interpret_error()
2943 sense_len = ei->SenseLen; in hpsa_scsi_interpret_error()
2944 decode_sense_data(ei->SenseInfo, sense_len, in hpsa_scsi_interpret_error()
2947 if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) in hpsa_scsi_interpret_error()
2951 dev_warn(d, "SCSI Status = 0x%02x\n", ei->ScsiStatus); in hpsa_scsi_interpret_error()
2952 if (ei->ScsiStatus == 0) in hpsa_scsi_interpret_error()
2965 * to non-existent targets as invalid commands. in hpsa_scsi_interpret_error()
3001 ei->CommandStatus); in hpsa_scsi_interpret_error()
3015 rc = -1; in hpsa_do_receive_diagnostic()
3022 ei = c->err_info; in hpsa_do_receive_diagnostic()
3023 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_do_receive_diagnostic()
3025 rc = -1; in hpsa_do_receive_diagnostic()
3068 rc = -1; in hpsa_scsi_do_inquiry()
3075 ei = c->err_info; in hpsa_scsi_do_inquiry()
3076 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_inquiry()
3078 rc = -1; in hpsa_scsi_do_inquiry()
3093 c->device = dev; in hpsa_send_reset()
3096 (void) fill_cmd(c, reset_type, h, NULL, 0, 0, dev->scsi3addr, TYPE_MSG); in hpsa_send_reset()
3099 dev_warn(&h->pdev->dev, "Failed to send reset command\n"); in hpsa_send_reset()
3104 ei = c->err_info; in hpsa_send_reset()
3105 if (ei->CommandStatus != 0) { in hpsa_send_reset()
3107 rc = -1; in hpsa_send_reset()
3120 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_cmd_dev_match()
3126 switch (c->cmd_type) { in hpsa_cmd_dev_match()
3129 match = !memcmp(scsi3addr, &c->Header.LUN.LunAddrBytes, in hpsa_cmd_dev_match()
3130 sizeof(c->Header.LUN.LunAddrBytes)); in hpsa_cmd_dev_match()
3135 if (c->phys_disk == dev) { in hpsa_cmd_dev_match()
3139 /* Possible RAID mode -- check each phys dev. */ in hpsa_cmd_dev_match()
3143 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3146 * match = dev->phys_disk[i]->ioaccel_handle in hpsa_cmd_dev_match()
3147 * == c2->scsi_nexus; */ in hpsa_cmd_dev_match()
3148 match = dev->phys_disk[i] == c->phys_disk; in hpsa_cmd_dev_match()
3154 for (i = 0; i < dev->nphysical_disks && !match; i++) { in hpsa_cmd_dev_match()
3155 match = dev->phys_disk[i]->ioaccel_handle == in hpsa_cmd_dev_match()
3156 le32_to_cpu(ac->it_nexus); in hpsa_cmd_dev_match()
3165 dev_err(&h->pdev->dev, "unexpected cmd_type: %d\n", in hpsa_cmd_dev_match()
3166 c->cmd_type); in hpsa_cmd_dev_match()
3179 if (mutex_lock_interruptible(&h->reset_mutex) == -EINTR) { in hpsa_do_reset()
3180 dev_warn(&h->pdev->dev, "concurrent reset wait interrupted.\n"); in hpsa_do_reset()
3181 return -EINTR; in hpsa_do_reset()
3187 atomic_dec(&dev->commands_outstanding); in hpsa_do_reset()
3188 wait_event(h->event_sync_wait_queue, in hpsa_do_reset()
3189 atomic_read(&dev->commands_outstanding) <= 0 || in hpsa_do_reset()
3194 dev_warn(&h->pdev->dev, in hpsa_do_reset()
3196 rc = -ENODEV; in hpsa_do_reset()
3200 rc = wait_for_device_to_become_ready(h, dev->scsi3addr, 0); in hpsa_do_reset()
3202 mutex_unlock(&h->reset_mutex); in hpsa_do_reset()
3238 struct raid_map_disk_data *dd = &map_buff->data[0]; in hpsa_debug_map_buff()
3246 if (h->raid_offload_debug < 2) in hpsa_debug_map_buff()
3249 dev_info(&h->pdev->dev, "structure_size = %u\n", in hpsa_debug_map_buff()
3250 le32_to_cpu(map_buff->structure_size)); in hpsa_debug_map_buff()
3251 dev_info(&h->pdev->dev, "volume_blk_size = %u\n", in hpsa_debug_map_buff()
3252 le32_to_cpu(map_buff->volume_blk_size)); in hpsa_debug_map_buff()
3253 dev_info(&h->pdev->dev, "volume_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3254 le64_to_cpu(map_buff->volume_blk_cnt)); in hpsa_debug_map_buff()
3255 dev_info(&h->pdev->dev, "physicalBlockShift = %u\n", in hpsa_debug_map_buff()
3256 map_buff->phys_blk_shift); in hpsa_debug_map_buff()
3257 dev_info(&h->pdev->dev, "parity_rotation_shift = %u\n", in hpsa_debug_map_buff()
3258 map_buff->parity_rotation_shift); in hpsa_debug_map_buff()
3259 dev_info(&h->pdev->dev, "strip_size = %u\n", in hpsa_debug_map_buff()
3260 le16_to_cpu(map_buff->strip_size)); in hpsa_debug_map_buff()
3261 dev_info(&h->pdev->dev, "disk_starting_blk = 0x%llx\n", in hpsa_debug_map_buff()
3262 le64_to_cpu(map_buff->disk_starting_blk)); in hpsa_debug_map_buff()
3263 dev_info(&h->pdev->dev, "disk_blk_cnt = 0x%llx\n", in hpsa_debug_map_buff()
3264 le64_to_cpu(map_buff->disk_blk_cnt)); in hpsa_debug_map_buff()
3265 dev_info(&h->pdev->dev, "data_disks_per_row = %u\n", in hpsa_debug_map_buff()
3266 le16_to_cpu(map_buff->data_disks_per_row)); in hpsa_debug_map_buff()
3267 dev_info(&h->pdev->dev, "metadata_disks_per_row = %u\n", in hpsa_debug_map_buff()
3268 le16_to_cpu(map_buff->metadata_disks_per_row)); in hpsa_debug_map_buff()
3269 dev_info(&h->pdev->dev, "row_cnt = %u\n", in hpsa_debug_map_buff()
3270 le16_to_cpu(map_buff->row_cnt)); in hpsa_debug_map_buff()
3271 dev_info(&h->pdev->dev, "layout_map_count = %u\n", in hpsa_debug_map_buff()
3272 le16_to_cpu(map_buff->layout_map_count)); in hpsa_debug_map_buff()
3273 dev_info(&h->pdev->dev, "flags = 0x%x\n", in hpsa_debug_map_buff()
3274 le16_to_cpu(map_buff->flags)); in hpsa_debug_map_buff()
3275 dev_info(&h->pdev->dev, "encryption = %s\n", in hpsa_debug_map_buff()
3276 le16_to_cpu(map_buff->flags) & in hpsa_debug_map_buff()
3278 dev_info(&h->pdev->dev, "dekindex = %u\n", in hpsa_debug_map_buff()
3279 le16_to_cpu(map_buff->dekindex)); in hpsa_debug_map_buff()
3280 map_cnt = le16_to_cpu(map_buff->layout_map_count); in hpsa_debug_map_buff()
3282 dev_info(&h->pdev->dev, "Map%u:\n", map); in hpsa_debug_map_buff()
3283 row_cnt = le16_to_cpu(map_buff->row_cnt); in hpsa_debug_map_buff()
3285 dev_info(&h->pdev->dev, " Row%u:\n", row); in hpsa_debug_map_buff()
3287 le16_to_cpu(map_buff->data_disks_per_row); in hpsa_debug_map_buff()
3289 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3291 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3292 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3294 le16_to_cpu(map_buff->metadata_disks_per_row); in hpsa_debug_map_buff()
3296 dev_info(&h->pdev->dev, in hpsa_debug_map_buff()
3298 col, dd->ioaccel_handle, in hpsa_debug_map_buff()
3299 dd->xor_mult[0], dd->xor_mult[1]); in hpsa_debug_map_buff()
3320 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, in hpsa_get_raid_map()
3321 sizeof(this_device->raid_map), 0, in hpsa_get_raid_map()
3323 dev_warn(&h->pdev->dev, "hpsa_get_raid_map fill_cmd failed\n"); in hpsa_get_raid_map()
3325 return -1; in hpsa_get_raid_map()
3331 ei = c->err_info; in hpsa_get_raid_map()
3332 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_raid_map()
3334 rc = -1; in hpsa_get_raid_map()
3340 if (le32_to_cpu(this_device->raid_map.structure_size) > in hpsa_get_raid_map()
3341 sizeof(this_device->raid_map)) { in hpsa_get_raid_map()
3342 dev_warn(&h->pdev->dev, "RAID map size is too large!\n"); in hpsa_get_raid_map()
3343 rc = -1; in hpsa_get_raid_map()
3345 hpsa_debug_map_buff(h, rc, &this_device->raid_map); in hpsa_get_raid_map()
3367 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_sense_subsystem_information()
3368 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_sense_subsystem_information()
3374 ei = c->err_info; in hpsa_bmic_sense_subsystem_information()
3375 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_sense_subsystem_information()
3377 rc = -1; in hpsa_bmic_sense_subsystem_information()
3402 ei = c->err_info; in hpsa_bmic_id_controller()
3403 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_controller()
3405 rc = -1; in hpsa_bmic_id_controller()
3426 c->Request.CDB[2] = bmic_device_index & 0xff; in hpsa_bmic_id_physical_device()
3427 c->Request.CDB[9] = (bmic_device_index >> 8) & 0xff; in hpsa_bmic_id_physical_device()
3431 ei = c->err_info; in hpsa_bmic_id_physical_device()
3432 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_bmic_id_physical_device()
3434 rc = -1; in hpsa_bmic_id_physical_device()
3444 * struct ReportExtendedLUNdata *rlep - Used for BMIC drive number
3445 * struct hpsa_scsi_dev_t *encl_dev - device entry for enclosure
3453 int rc = -1; in hpsa_get_enclosure_info()
3464 rle = &rlep->LUN[rle_index]; in hpsa_get_enclosure_info()
3466 encl_dev->eli = in hpsa_get_enclosure_info()
3469 bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); in hpsa_get_enclosure_info()
3471 if (encl_dev->target == -1 || encl_dev->lun == -1) { in hpsa_get_enclosure_info()
3476 if (bmic_device_index == 0xFF00 || MASKED_DEVICE(&rle->lunid[0])) { in hpsa_get_enclosure_info()
3492 dev_warn(&h->pdev->dev, "%s: id_phys failed %d bdi[0x%x]\n", in hpsa_get_enclosure_info()
3493 __func__, encl_dev->external, bmic_device_index); in hpsa_get_enclosure_info()
3505 if (id_phys->phys_connector[1] == 'E') in hpsa_get_enclosure_info()
3506 c->Request.CDB[5] = id_phys->box_index; in hpsa_get_enclosure_info()
3508 c->Request.CDB[5] = 0; in hpsa_get_enclosure_info()
3515 ei = c->err_info; in hpsa_get_enclosure_info()
3516 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_get_enclosure_info()
3517 rc = -1; in hpsa_get_enclosure_info()
3521 encl_dev->box[id_phys->active_path_number] = bssbp->phys_box_on_port; in hpsa_get_enclosure_info()
3522 memcpy(&encl_dev->phys_connector[id_phys->active_path_number], in hpsa_get_enclosure_info()
3523 bssbp->phys_connector, sizeof(bssbp->phys_connector)); in hpsa_get_enclosure_info()
3551 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_get_sas_address_from_report_physical()
3555 nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24; in hpsa_get_sas_address_from_report_physical()
3558 if (!memcmp(&physdev->LUN[i].lunid[0], scsi3addr, 8)) { in hpsa_get_sas_address_from_report_physical()
3559 sa = get_unaligned_be64(&physdev->LUN[i].wwid[0]); in hpsa_get_sas_address_from_report_physical()
3584 sa = get_unaligned_be64(ssi->primary_world_wide_id); in hpsa_get_sas_address()
3585 h->sas_address = sa; in hpsa_get_sas_address()
3592 dev->sas_address = sa; in hpsa_get_sas_address()
3601 if (h->discovery_polling) in hpsa_ext_ctrl_present()
3604 nphysicals = (get_unaligned_be32(physdev->LUNListLength) / 24) + 1; in hpsa_ext_ctrl_present()
3607 if (physdev->LUN[i].device_type == in hpsa_ext_ctrl_present()
3609 && !is_hba_lunid(physdev->LUN[i].lunid)) { in hpsa_ext_ctrl_present()
3610 dev_info(&h->pdev->dev, in hpsa_ext_ctrl_present()
3613 h->discovery_polling = 1; in hpsa_ext_ctrl_present()
3632 /* Get the size of the page list first */ in hpsa_vpd_page_supported()
3677 this_device->offload_config = 0; in hpsa_get_ioaccel_status()
3678 this_device->offload_enabled = 0; in hpsa_get_ioaccel_status()
3679 this_device->offload_to_be_enabled = 0; in hpsa_get_ioaccel_status()
3695 this_device->offload_config = in hpsa_get_ioaccel_status()
3697 if (this_device->offload_config) { in hpsa_get_ioaccel_status()
3707 this_device->offload_to_be_enabled = 1; in hpsa_get_ioaccel_status()
3729 return -ENOMEM; in hpsa_get_device_id()
3741 return rc; /*0 - got id, otherwise, didn't */ in hpsa_get_device_id()
3759 rc = -EAGAIN; in hpsa_scsi_do_report_luns()
3763 c->Request.CDB[1] = extended_response; in hpsa_scsi_do_report_luns()
3768 ei = c->err_info; in hpsa_scsi_do_report_luns()
3769 if (ei->CommandStatus != 0 && in hpsa_scsi_do_report_luns()
3770 ei->CommandStatus != CMD_DATA_UNDERRUN) { in hpsa_scsi_do_report_luns()
3772 rc = -EIO; in hpsa_scsi_do_report_luns()
3776 if (rld->extended_response_flag != extended_response) { in hpsa_scsi_do_report_luns()
3777 if (!h->legacy_board) { in hpsa_scsi_do_report_luns()
3778 dev_err(&h->pdev->dev, in hpsa_scsi_do_report_luns()
3781 rld->extended_response_flag); in hpsa_scsi_do_report_luns()
3782 rc = -EINVAL; in hpsa_scsi_do_report_luns()
3784 rc = -EOPNOTSUPP; in hpsa_scsi_do_report_luns()
3800 if (!rc || rc != -EOPNOTSUPP) in hpsa_scsi_do_report_phys_luns()
3806 return -ENOMEM; in hpsa_scsi_do_report_phys_luns()
3815 nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 8; in hpsa_scsi_do_report_phys_luns()
3817 memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8); in hpsa_scsi_do_report_phys_luns()
3832 device->bus = bus; in hpsa_set_bus_target_lun()
3833 device->target = target; in hpsa_set_bus_target_lun()
3834 device->lun = lun; in hpsa_set_bus_target_lun()
3843 int size; in hpsa_get_volume_status() local
3854 /* Get the size of the VPD return buffer */ in hpsa_get_volume_status()
3859 size = buf[3]; in hpsa_get_volume_status()
3863 buf, size + HPSA_VPD_HEADER_SZ); in hpsa_get_volume_status()
3903 sense = c->err_info->SenseInfo; in hpsa_volume_offline()
3904 if (c->err_info->SenseLen > sizeof(c->err_info->SenseInfo)) in hpsa_volume_offline()
3905 sense_len = sizeof(c->err_info->SenseInfo); in hpsa_volume_offline()
3907 sense_len = c->err_info->SenseLen; in hpsa_volume_offline()
3947 #define OBDR_TAPE_SIG "$DR-10" in hpsa_update_device_info()
3948 #define OBDR_SIG_LEN (sizeof(OBDR_TAPE_SIG) - 1) in hpsa_update_device_info()
3957 rc = -ENOMEM; in hpsa_update_device_info()
3964 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3974 this_device->devtype = (inq_buff[0] & 0x1f); in hpsa_update_device_info()
3975 memcpy(this_device->scsi3addr, scsi3addr, 8); in hpsa_update_device_info()
3976 memcpy(this_device->vendor, &inq_buff[8], in hpsa_update_device_info()
3977 sizeof(this_device->vendor)); in hpsa_update_device_info()
3978 memcpy(this_device->model, &inq_buff[16], in hpsa_update_device_info()
3979 sizeof(this_device->model)); in hpsa_update_device_info()
3980 this_device->rev = inq_buff[2]; in hpsa_update_device_info()
3981 memset(this_device->device_id, 0, in hpsa_update_device_info()
3982 sizeof(this_device->device_id)); in hpsa_update_device_info()
3983 if (hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8, in hpsa_update_device_info()
3984 sizeof(this_device->device_id)) < 0) { in hpsa_update_device_info()
3985 dev_err(&h->pdev->dev, in hpsa_update_device_info()
3987 h->ctlr, __func__, in hpsa_update_device_info()
3988 h->scsi_host->host_no, in hpsa_update_device_info()
3989 this_device->bus, this_device->target, in hpsa_update_device_info()
3990 this_device->lun, in hpsa_update_device_info()
3991 scsi_device_type(this_device->devtype), in hpsa_update_device_info()
3992 this_device->model); in hpsa_update_device_info()
3997 if ((this_device->devtype == TYPE_DISK || in hpsa_update_device_info()
3998 this_device->devtype == TYPE_ZBC) && in hpsa_update_device_info()
4002 hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); in hpsa_update_device_info()
4003 if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) in hpsa_update_device_info()
4007 h->legacy_board) { in hpsa_update_device_info()
4011 dev_info(&h->pdev->dev, in hpsa_update_device_info()
4013 this_device->target, this_device->lun); in hpsa_update_device_info()
4016 this_device->volume_offline = volume_offline; in hpsa_update_device_info()
4019 dev_err(&h->pdev->dev, in hpsa_update_device_info()
4025 this_device->raid_level = RAID_UNKNOWN; in hpsa_update_device_info()
4026 this_device->offload_config = 0; in hpsa_update_device_info()
4028 this_device->hba_ioaccel_enabled = 0; in hpsa_update_device_info()
4029 this_device->volume_offline = 0; in hpsa_update_device_info()
4030 this_device->queue_depth = h->nr_cmds; in hpsa_update_device_info()
4033 if (this_device->external) in hpsa_update_device_info()
4034 this_device->queue_depth = EXTERNAL_QD; in hpsa_update_device_info()
4037 /* See if this is a One-Button-Disaster-Recovery device in hpsa_update_device_info()
4038 * by looking for "$DR-10" at offset 43 in inquiry data. in hpsa_update_device_info()
4041 *is_OBDR_device = (this_device->devtype == TYPE_ROM && in hpsa_update_device_info()
4069 if (!device->rev) in figure_bus_target_lun()
4076 HPSA_PHYSICAL_DEVICE_BUS, -1, -1); in figure_bus_target_lun()
4080 if (device->external) { in figure_bus_target_lun()
4105 if ((i - nphysicals - (raid_ctlr_position == 0)) < nlocal_logicals) in figure_external_status()
4115 * Returns 0 on success, -1 otherwise.
4122 dev_err(&h->pdev->dev, "report physical LUNs failed.\n"); in hpsa_gather_lun_info()
4123 return -1; in hpsa_gather_lun_info()
4125 *nphysicals = be32_to_cpu(*((__be32 *)physdev->LUNListLength)) / 24; in hpsa_gather_lun_info()
4127 dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded. %d LUNs ignored.\n", in hpsa_gather_lun_info()
4128 HPSA_MAX_PHYS_LUN, *nphysicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4132 dev_err(&h->pdev->dev, "report logical LUNs failed.\n"); in hpsa_gather_lun_info()
4133 return -1; in hpsa_gather_lun_info()
4135 *nlogicals = be32_to_cpu(*((__be32 *) logdev->LUNListLength)) / 8; in hpsa_gather_lun_info()
4138 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4141 *nlogicals - HPSA_MAX_LUN); in hpsa_gather_lun_info()
4145 dev_warn(&h->pdev->dev, in hpsa_gather_lun_info()
4148 *nphysicals + *nlogicals - HPSA_MAX_PHYS_LUN); in hpsa_gather_lun_info()
4149 *nlogicals = HPSA_MAX_PHYS_LUN - *nphysicals; in hpsa_gather_lun_info()
4171 return &physdev_list->LUN[i - in figure_lunaddrbytes()
4175 return &logdev_list->LUN[i - nphysicals - in figure_lunaddrbytes()
4193 rle = &rlep->LUN[rle_index]; in hpsa_get_ioaccel_drive_info()
4195 dev->ioaccel_handle = rle->ioaccel_handle; in hpsa_get_ioaccel_drive_info()
4196 if ((rle->device_flags & 0x08) && dev->ioaccel_handle) in hpsa_get_ioaccel_drive_info()
4197 dev->hba_ioaccel_enabled = 1; in hpsa_get_ioaccel_drive_info()
4199 rc = hpsa_bmic_id_physical_device(h, &rle->lunid[0], in hpsa_get_ioaccel_drive_info()
4200 GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]), id_phys, in hpsa_get_ioaccel_drive_info()
4206 dev->queue_depth = in hpsa_get_ioaccel_drive_info()
4207 le16_to_cpu(id_phys->current_queue_depth_limit) - in hpsa_get_ioaccel_drive_info()
4210 dev->queue_depth = DRIVE_QUEUE_DEPTH; /* conservative */ in hpsa_get_ioaccel_drive_info()
4222 rle = &rlep->LUN[rle_index]; in hpsa_get_path_info()
4224 if ((rle->device_flags & 0x08) && this_device->ioaccel_handle) in hpsa_get_path_info()
4225 this_device->hba_ioaccel_enabled = 1; in hpsa_get_path_info()
4227 memcpy(&this_device->active_path_index, in hpsa_get_path_info()
4228 &id_phys->active_path_number, in hpsa_get_path_info()
4229 sizeof(this_device->active_path_index)); in hpsa_get_path_info()
4230 memcpy(&this_device->path_map, in hpsa_get_path_info()
4231 &id_phys->redundant_path_present_map, in hpsa_get_path_info()
4232 sizeof(this_device->path_map)); in hpsa_get_path_info()
4233 memcpy(&this_device->box, in hpsa_get_path_info()
4234 &id_phys->alternate_paths_phys_box_on_port, in hpsa_get_path_info()
4235 sizeof(this_device->box)); in hpsa_get_path_info()
4236 memcpy(&this_device->phys_connector, in hpsa_get_path_info()
4237 &id_phys->alternate_paths_phys_connector, in hpsa_get_path_info()
4238 sizeof(this_device->phys_connector)); in hpsa_get_path_info()
4239 memcpy(&this_device->bay, in hpsa_get_path_info()
4240 &id_phys->phys_bay_in_box, in hpsa_get_path_info()
4241 sizeof(this_device->bay)); in hpsa_get_path_info()
4252 dev_warn(&h->pdev->dev, "%s: id_ctlr buffer is NULL.\n", in hpsa_set_local_logical_count()
4254 return -ENOMEM; in hpsa_set_local_logical_count()
4259 if (id_ctlr->configured_logical_drive_count < 255) in hpsa_set_local_logical_count()
4260 *nlocals = id_ctlr->configured_logical_drive_count; in hpsa_set_local_logical_count()
4263 id_ctlr->extended_logical_unit_count); in hpsa_set_local_logical_count()
4265 *nlocals = -1; in hpsa_set_local_logical_count()
4284 is_spare = (id_phys->more_flags >> 6) & 0x01; in hpsa_is_disk_spare()
4305 device_flags = rle->device_flags; in hpsa_skip_device()
4306 device_type = rle->device_type; in hpsa_skip_device()
4369 dev_err(&h->pdev->dev, "out of memory\n"); in hpsa_update_scsi_devices()
4373 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ in hpsa_update_scsi_devices()
4377 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4383 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4399 dev_warn(&h->pdev->dev, "maximum devices (%d) exceeded." in hpsa_update_scsi_devices()
4401 ndevs_to_allocate - HPSA_MAX_DEVICES); in hpsa_update_scsi_devices()
4407 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4422 int phys_dev_index = i - (raid_ctlr_position == 0); in hpsa_update_scsi_devices()
4434 tmpdevice->external = in hpsa_update_scsi_devices()
4441 if (phys_dev_index >= 0 && !tmpdevice->external && in hpsa_update_scsi_devices()
4444 &physdev_list->LUN[phys_dev_index]); in hpsa_update_scsi_devices()
4452 if (rc == -ENOMEM) { in hpsa_update_scsi_devices()
4453 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4455 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4459 h->drv_req_rescan = 1; in hpsa_update_scsi_devices()
4467 this_device->physical_device = physical_device; in hpsa_update_scsi_devices()
4473 if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device) in hpsa_update_scsi_devices()
4474 this_device->expose_device = 0; in hpsa_update_scsi_devices()
4476 this_device->expose_device = 1; in hpsa_update_scsi_devices()
4482 if (this_device->physical_device && this_device->expose_device) in hpsa_update_scsi_devices()
4485 switch (this_device->devtype) { in hpsa_update_scsi_devices()
4487 /* We don't *really* support actual CD-ROM devices, in hpsa_update_scsi_devices()
4489 * which temporarily pretends to be a CD-ROM drive. in hpsa_update_scsi_devices()
4491 * device by checking for "$DR-10" in bytes 43-48 of in hpsa_update_scsi_devices()
4499 if (this_device->physical_device) { in hpsa_update_scsi_devices()
4502 this_device->offload_enabled = 0; in hpsa_update_scsi_devices()
4515 if (!this_device->external) in hpsa_update_scsi_devices()
4538 if (h->sas_host == NULL) { in hpsa_update_scsi_devices()
4543 dev_warn(&h->pdev->dev, in hpsa_update_scsi_devices()
4567 desc->Addr = cpu_to_le64(addr64); in hpsa_set_sg_descriptor()
4568 desc->Len = cpu_to_le32(len); in hpsa_set_sg_descriptor()
4569 desc->Ext = 0; in hpsa_set_sg_descriptor()
4585 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scatter_gather()
4601 curr_sg = cp->SG; in hpsa_scatter_gather()
4602 chained = use_sg > h->max_cmd_sg_entries; in hpsa_scatter_gather()
4603 sg_limit = chained ? h->max_cmd_sg_entries - 1 : use_sg; in hpsa_scatter_gather()
4616 curr_sg = h->cmd_sg_list[cp->cmdindex]; in hpsa_scatter_gather()
4617 sg_limit = use_sg - sg_limit; in hpsa_scatter_gather()
4625 (curr_sg - 1)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scatter_gather()
4627 if (use_sg + chained > h->maxSG) in hpsa_scatter_gather()
4628 h->maxSG = use_sg + chained; in hpsa_scatter_gather()
4631 cp->Header.SGList = h->max_cmd_sg_entries; in hpsa_scatter_gather()
4632 cp->Header.SGTotal = cpu_to_le16(use_sg + 1); in hpsa_scatter_gather()
4635 return -1; in hpsa_scatter_gather()
4642 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */ in hpsa_scatter_gather()
4643 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in cmd list */ in hpsa_scatter_gather()
4651 dev_warn(&h->pdev->dev, in warn_zero_length_transfer()
4652 "%s: Blocking zero-length request: CDB:%*phN\n", in warn_zero_length_transfer()
4657 /* zero-length transfers trigger hardware errors. */
4662 /* Block zero-length transfer sizes on certain commands. */ in is_zero_length_transfer()
4737 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel1_queue_command()
4738 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel1_queue_command()
4748 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel1_queue_command()
4749 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4753 BUG_ON(cmd->cmd_len > IOACCEL1_IOFLAGS_CDBLEN_MAX); in hpsa_scsi_ioaccel1_queue_command()
4757 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4762 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4766 c->cmd_type = CMD_IOACCEL1; in hpsa_scsi_ioaccel1_queue_command()
4769 c->busaddr = (u32) h->ioaccel_cmd_pool_dhandle + in hpsa_scsi_ioaccel1_queue_command()
4770 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel1_queue_command()
4771 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel1_queue_command()
4775 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel1_queue_command()
4780 curr_sg = cp->SG; in hpsa_scsi_ioaccel1_queue_command()
4785 curr_sg->Addr = cpu_to_le64(addr64); in hpsa_scsi_ioaccel1_queue_command()
4786 curr_sg->Len = cpu_to_le32(len); in hpsa_scsi_ioaccel1_queue_command()
4787 curr_sg->Ext = cpu_to_le32(0); in hpsa_scsi_ioaccel1_queue_command()
4790 (--curr_sg)->Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_scsi_ioaccel1_queue_command()
4792 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel1_queue_command()
4803 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel1_queue_command()
4804 cmd->sc_data_direction); in hpsa_scsi_ioaccel1_queue_command()
4812 c->Header.SGList = use_sg; in hpsa_scsi_ioaccel1_queue_command()
4814 cp->dev_handle = cpu_to_le16(ioaccel_handle & 0xFFFF); in hpsa_scsi_ioaccel1_queue_command()
4815 cp->transfer_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel1_queue_command()
4816 cp->io_flags = cpu_to_le16(IOACCEL1_IOFLAGS_IO_REQ | in hpsa_scsi_ioaccel1_queue_command()
4818 cp->control = cpu_to_le32(control); in hpsa_scsi_ioaccel1_queue_command()
4819 memcpy(cp->CDB, cdb, cdb_len); in hpsa_scsi_ioaccel1_queue_command()
4820 memcpy(cp->CISS_LUN, scsi3addr, 8); in hpsa_scsi_ioaccel1_queue_command()
4833 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_direct_map()
4834 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_direct_map()
4837 return -1; in hpsa_scsi_ioaccel_direct_map()
4839 c->phys_disk = dev; in hpsa_scsi_ioaccel_direct_map()
4841 if (dev->in_reset) in hpsa_scsi_ioaccel_direct_map()
4842 return -1; in hpsa_scsi_ioaccel_direct_map()
4844 return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, in hpsa_scsi_ioaccel_direct_map()
4845 cmd->cmnd, cmd->cmd_len, dev->scsi3addr, dev); in hpsa_scsi_ioaccel_direct_map()
4854 struct scsi_cmnd *cmd = c->scsi_cmd; in set_encrypt_ioaccel2()
4855 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in set_encrypt_ioaccel2()
4856 struct raid_map_data *map = &dev->raid_map; in set_encrypt_ioaccel2()
4860 if (!(le16_to_cpu(map->flags) & RAID_MAP_FLAG_ENCRYPT_ON)) in set_encrypt_ioaccel2()
4863 cp->dekindex = map->dekindex; in set_encrypt_ioaccel2()
4866 cp->direction |= IOACCEL2_DIRECTION_ENCRYPT_MASK; in set_encrypt_ioaccel2()
4869 * If block size is 512, tweak value is LBA. in set_encrypt_ioaccel2()
4870 * For other block sizes, tweak is (LBA * block size)/ 512) in set_encrypt_ioaccel2()
4872 switch (cmd->cmnd[0]) { in set_encrypt_ioaccel2()
4873 /* Required? 6-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4876 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in set_encrypt_ioaccel2()
4877 (cmd->cmnd[2] << 8) | in set_encrypt_ioaccel2()
4878 cmd->cmnd[3]); in set_encrypt_ioaccel2()
4882 /* Required? 12-byte cdbs eliminated by fixup_ioaccel_cdb */ in set_encrypt_ioaccel2()
4885 first_block = get_unaligned_be32(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4889 first_block = get_unaligned_be64(&cmd->cmnd[2]); in set_encrypt_ioaccel2()
4892 dev_err(&h->pdev->dev, in set_encrypt_ioaccel2()
4893 "ERROR: %s: size (0x%x) not supported for encryption\n", in set_encrypt_ioaccel2()
4894 __func__, cmd->cmnd[0]); in set_encrypt_ioaccel2()
4899 if (le32_to_cpu(map->volume_blk_size) != 512) in set_encrypt_ioaccel2()
4901 le32_to_cpu(map->volume_blk_size)/512; in set_encrypt_ioaccel2()
4903 cp->tweak_lower = cpu_to_le32(first_block); in set_encrypt_ioaccel2()
4904 cp->tweak_upper = cpu_to_le32(first_block >> 32); in set_encrypt_ioaccel2()
4911 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel2_queue_command()
4912 struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4920 if (!cmd->device) in hpsa_scsi_ioaccel2_queue_command()
4921 return -1; in hpsa_scsi_ioaccel2_queue_command()
4923 if (!cmd->device->hostdata) in hpsa_scsi_ioaccel2_queue_command()
4924 return -1; in hpsa_scsi_ioaccel2_queue_command()
4926 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); in hpsa_scsi_ioaccel2_queue_command()
4930 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4935 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4939 c->cmd_type = CMD_IOACCEL2; in hpsa_scsi_ioaccel2_queue_command()
4941 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle + in hpsa_scsi_ioaccel2_queue_command()
4942 (c->cmdindex * sizeof(*cp)); in hpsa_scsi_ioaccel2_queue_command()
4943 BUG_ON(c->busaddr & 0x0000007F); in hpsa_scsi_ioaccel2_queue_command()
4946 cp->IU_type = IOACCEL2_IU_TYPE; in hpsa_scsi_ioaccel2_queue_command()
4950 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
4955 curr_sg = cp->sg; in hpsa_scsi_ioaccel2_queue_command()
4956 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
4958 h->ioaccel2_cmd_sg_list[c->cmdindex]->address); in hpsa_scsi_ioaccel2_queue_command()
4959 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4960 curr_sg->length = 0; in hpsa_scsi_ioaccel2_queue_command()
4961 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4962 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4963 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4964 curr_sg->chain_indicator = IOACCEL2_CHAIN; in hpsa_scsi_ioaccel2_queue_command()
4966 curr_sg = h->ioaccel2_cmd_sg_list[c->cmdindex]; in hpsa_scsi_ioaccel2_queue_command()
4972 curr_sg->address = cpu_to_le64(addr64); in hpsa_scsi_ioaccel2_queue_command()
4973 curr_sg->length = cpu_to_le32(len); in hpsa_scsi_ioaccel2_queue_command()
4974 curr_sg->reserved[0] = 0; in hpsa_scsi_ioaccel2_queue_command()
4975 curr_sg->reserved[1] = 0; in hpsa_scsi_ioaccel2_queue_command()
4976 curr_sg->reserved[2] = 0; in hpsa_scsi_ioaccel2_queue_command()
4977 curr_sg->chain_indicator = 0; in hpsa_scsi_ioaccel2_queue_command()
4984 (curr_sg - 1)->chain_indicator = IOACCEL2_LAST_SG; in hpsa_scsi_ioaccel2_queue_command()
4986 switch (cmd->sc_data_direction) { in hpsa_scsi_ioaccel2_queue_command()
4988 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4989 cp->direction |= IOACCEL2_DIR_DATA_OUT; in hpsa_scsi_ioaccel2_queue_command()
4992 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4993 cp->direction |= IOACCEL2_DIR_DATA_IN; in hpsa_scsi_ioaccel2_queue_command()
4996 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
4997 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
5000 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_scsi_ioaccel2_queue_command()
5001 cmd->sc_data_direction); in hpsa_scsi_ioaccel2_queue_command()
5006 cp->direction &= ~IOACCEL2_DIRECTION_MASK; in hpsa_scsi_ioaccel2_queue_command()
5007 cp->direction |= IOACCEL2_DIR_NO_DATA; in hpsa_scsi_ioaccel2_queue_command()
5013 cp->scsi_nexus = cpu_to_le32(ioaccel_handle); in hpsa_scsi_ioaccel2_queue_command()
5014 cp->Tag = cpu_to_le32(c->cmdindex << DIRECT_LOOKUP_SHIFT); in hpsa_scsi_ioaccel2_queue_command()
5015 memcpy(cp->cdb, cdb, sizeof(cp->cdb)); in hpsa_scsi_ioaccel2_queue_command()
5017 cp->data_len = cpu_to_le32(total_len); in hpsa_scsi_ioaccel2_queue_command()
5018 cp->err_ptr = cpu_to_le64(c->busaddr + in hpsa_scsi_ioaccel2_queue_command()
5020 cp->err_len = cpu_to_le32(sizeof(cp->error_data)); in hpsa_scsi_ioaccel2_queue_command()
5023 if (use_sg > h->ioaccel_maxsg) { in hpsa_scsi_ioaccel2_queue_command()
5024 cp->sg_count = 1; in hpsa_scsi_ioaccel2_queue_command()
5025 cp->sg[0].length = cpu_to_le32(use_sg * sizeof(cp->sg[0])); in hpsa_scsi_ioaccel2_queue_command()
5027 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel2_queue_command()
5029 return -1; in hpsa_scsi_ioaccel2_queue_command()
5032 cp->sg_count = (u8) use_sg; in hpsa_scsi_ioaccel2_queue_command()
5034 if (phys_disk->in_reset) { in hpsa_scsi_ioaccel2_queue_command()
5035 cmd->result = DID_RESET << 16; in hpsa_scsi_ioaccel2_queue_command()
5036 return -1; in hpsa_scsi_ioaccel2_queue_command()
5050 if (!c->scsi_cmd->device) in hpsa_scsi_ioaccel_queue_command()
5051 return -1; in hpsa_scsi_ioaccel_queue_command()
5053 if (!c->scsi_cmd->device->hostdata) in hpsa_scsi_ioaccel_queue_command()
5054 return -1; in hpsa_scsi_ioaccel_queue_command()
5056 if (phys_disk->in_reset) in hpsa_scsi_ioaccel_queue_command()
5057 return -1; in hpsa_scsi_ioaccel_queue_command()
5060 if (atomic_inc_return(&phys_disk->ioaccel_cmds_out) > in hpsa_scsi_ioaccel_queue_command()
5061 phys_disk->queue_depth) { in hpsa_scsi_ioaccel_queue_command()
5062 atomic_dec(&phys_disk->ioaccel_cmds_out); in hpsa_scsi_ioaccel_queue_command()
5065 if (h->transMethod & CFGTBL_Trans_io_accel1) in hpsa_scsi_ioaccel_queue_command()
5080 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5086 le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5089 if (*current_group < le16_to_cpu(map->layout_map_count) - 1) { in raid_map_helper()
5091 *map_index += le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5095 *map_index %= le16_to_cpu(map->data_disks_per_row); in raid_map_helper()
5107 struct scsi_cmnd *cmd = c->scsi_cmd; in hpsa_scsi_ioaccel_raid_map()
5108 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_scsi_ioaccel_raid_map()
5109 struct raid_map_data *map = &dev->raid_map; in hpsa_scsi_ioaccel_raid_map()
5110 struct raid_map_disk_data *dd = &map->data[0]; in hpsa_scsi_ioaccel_raid_map()
5140 return -1; in hpsa_scsi_ioaccel_raid_map()
5142 if (dev->in_reset) in hpsa_scsi_ioaccel_raid_map()
5143 return -1; in hpsa_scsi_ioaccel_raid_map()
5146 switch (cmd->cmnd[0]) { in hpsa_scsi_ioaccel_raid_map()
5151 first_block = (((cmd->cmnd[1] & 0x1F) << 16) | in hpsa_scsi_ioaccel_raid_map()
5152 (cmd->cmnd[2] << 8) | in hpsa_scsi_ioaccel_raid_map()
5153 cmd->cmnd[3]); in hpsa_scsi_ioaccel_raid_map()
5154 block_cnt = cmd->cmnd[4]; in hpsa_scsi_ioaccel_raid_map()
5163 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5164 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5165 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5166 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5168 (((u32) cmd->cmnd[7]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5169 cmd->cmnd[8]; in hpsa_scsi_ioaccel_raid_map()
5176 (((u64) cmd->cmnd[2]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5177 (((u64) cmd->cmnd[3]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5178 (((u64) cmd->cmnd[4]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5179 cmd->cmnd[5]; in hpsa_scsi_ioaccel_raid_map()
5181 (((u32) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5182 (((u32) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5183 (((u32) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5184 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5191 (((u64) cmd->cmnd[2]) << 56) | in hpsa_scsi_ioaccel_raid_map()
5192 (((u64) cmd->cmnd[3]) << 48) | in hpsa_scsi_ioaccel_raid_map()
5193 (((u64) cmd->cmnd[4]) << 40) | in hpsa_scsi_ioaccel_raid_map()
5194 (((u64) cmd->cmnd[5]) << 32) | in hpsa_scsi_ioaccel_raid_map()
5195 (((u64) cmd->cmnd[6]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5196 (((u64) cmd->cmnd[7]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5197 (((u64) cmd->cmnd[8]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5198 cmd->cmnd[9]; in hpsa_scsi_ioaccel_raid_map()
5200 (((u32) cmd->cmnd[10]) << 24) | in hpsa_scsi_ioaccel_raid_map()
5201 (((u32) cmd->cmnd[11]) << 16) | in hpsa_scsi_ioaccel_raid_map()
5202 (((u32) cmd->cmnd[12]) << 8) | in hpsa_scsi_ioaccel_raid_map()
5203 cmd->cmnd[13]; in hpsa_scsi_ioaccel_raid_map()
5208 last_block = first_block + block_cnt - 1; in hpsa_scsi_ioaccel_raid_map()
5210 /* check for write to non-RAID-0 */ in hpsa_scsi_ioaccel_raid_map()
5211 if (is_write && dev->raid_level != 0) in hpsa_scsi_ioaccel_raid_map()
5215 if (last_block >= le64_to_cpu(map->volume_blk_cnt) || in hpsa_scsi_ioaccel_raid_map()
5220 blocks_per_row = le16_to_cpu(map->data_disks_per_row) * in hpsa_scsi_ioaccel_raid_map()
5221 le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5222 strip_size = le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5230 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5231 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5241 first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5242 last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); in hpsa_scsi_ioaccel_raid_map()
5252 total_disks_per_row = le16_to_cpu(map->data_disks_per_row) + in hpsa_scsi_ioaccel_raid_map()
5253 le16_to_cpu(map->metadata_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5254 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5255 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5258 switch (dev->raid_level) { in hpsa_scsi_ioaccel_raid_map()
5263 * (2-drive R1 and R10 with even # of drives.) in hpsa_scsi_ioaccel_raid_map()
5267 if (le16_to_cpu(map->layout_map_count) != 2) { in hpsa_scsi_ioaccel_raid_map()
5271 if (dev->offload_to_mirror) in hpsa_scsi_ioaccel_raid_map()
5272 map_index += le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5273 dev->offload_to_mirror = !dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5276 /* Handles N-way mirrors (R1-ADM) in hpsa_scsi_ioaccel_raid_map()
5280 if (le16_to_cpu(map->layout_map_count) != 3) { in hpsa_scsi_ioaccel_raid_map()
5285 offload_to_mirror = dev->offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5291 le16_to_cpu(map->layout_map_count) - 1) in hpsa_scsi_ioaccel_raid_map()
5293 dev->offload_to_mirror = offload_to_mirror; in hpsa_scsi_ioaccel_raid_map()
5294 /* Avoid direct use of dev->offload_to_mirror within this in hpsa_scsi_ioaccel_raid_map()
5296 * increment it beyond the range of dev->layout_map_count -1. in hpsa_scsi_ioaccel_raid_map()
5301 if (le16_to_cpu(map->layout_map_count) <= 1) in hpsa_scsi_ioaccel_raid_map()
5306 le16_to_cpu(map->strip_size) * in hpsa_scsi_ioaccel_raid_map()
5307 le16_to_cpu(map->data_disks_per_row); in hpsa_scsi_ioaccel_raid_map()
5313 le16_to_cpu(map->layout_map_count); in hpsa_scsi_ioaccel_raid_map()
5361 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5364 (void) do_div(tmpdiv, map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5376 r5or6_first_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5378 r5or6_last_row_offset / le16_to_cpu(map->strip_size); in hpsa_scsi_ioaccel_raid_map()
5384 map_row = ((u32)(first_row >> map->parity_rotation_shift)) % in hpsa_scsi_ioaccel_raid_map()
5385 le16_to_cpu(map->row_cnt); in hpsa_scsi_ioaccel_raid_map()
5388 (le16_to_cpu(map->row_cnt) * total_disks_per_row)) + in hpsa_scsi_ioaccel_raid_map()
5398 c->phys_disk = dev->phys_disk[map_index]; in hpsa_scsi_ioaccel_raid_map()
5399 if (!c->phys_disk) in hpsa_scsi_ioaccel_raid_map()
5403 disk_block = le64_to_cpu(map->disk_starting_blk) + in hpsa_scsi_ioaccel_raid_map()
5404 first_row * le16_to_cpu(map->strip_size) + in hpsa_scsi_ioaccel_raid_map()
5405 (first_row_offset - first_column * in hpsa_scsi_ioaccel_raid_map()
5406 le16_to_cpu(map->strip_size)); in hpsa_scsi_ioaccel_raid_map()
5410 if (map->phys_blk_shift) { in hpsa_scsi_ioaccel_raid_map()
5411 disk_block <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5412 disk_block_cnt <<= map->phys_blk_shift; in hpsa_scsi_ioaccel_raid_map()
5449 dev->scsi3addr, in hpsa_scsi_ioaccel_raid_map()
5450 dev->phys_disk[map_index]); in hpsa_scsi_ioaccel_raid_map()
5462 cmd->host_scribble = (unsigned char *) c; in hpsa_ciss_submit()
5463 c->cmd_type = CMD_SCSI; in hpsa_ciss_submit()
5464 c->scsi_cmd = cmd; in hpsa_ciss_submit()
5465 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_ciss_submit()
5466 memcpy(&c->Header.LUN.LunAddrBytes[0], &dev->scsi3addr[0], 8); in hpsa_ciss_submit()
5467 c->Header.tag = cpu_to_le64((c->cmdindex << DIRECT_LOOKUP_SHIFT)); in hpsa_ciss_submit()
5471 c->Request.Timeout = 0; in hpsa_ciss_submit()
5472 BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB)); in hpsa_ciss_submit()
5473 c->Request.CDBLen = cmd->cmd_len; in hpsa_ciss_submit()
5474 memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len); in hpsa_ciss_submit()
5475 switch (cmd->sc_data_direction) { in hpsa_ciss_submit()
5477 c->Request.type_attr_dir = in hpsa_ciss_submit()
5481 c->Request.type_attr_dir = in hpsa_ciss_submit()
5485 c->Request.type_attr_dir = in hpsa_ciss_submit()
5490 * and sets both inlen and outlen to non-zero. ( see in hpsa_ciss_submit()
5494 c->Request.type_attr_dir = in hpsa_ciss_submit()
5498 * response, but non-fibre backends appear to let it in hpsa_ciss_submit()
5507 dev_err(&h->pdev->dev, "unknown data direction: %d\n", in hpsa_ciss_submit()
5508 cmd->sc_data_direction); in hpsa_ciss_submit()
5518 if (dev->in_reset) { in hpsa_ciss_submit()
5523 c->device = dev; in hpsa_ciss_submit()
5537 c->Header.tag = cpu_to_le64((u64) (index << DIRECT_LOOKUP_SHIFT)); in hpsa_cmd_init()
5538 cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_init()
5539 c->err_info = h->errinfo_pool + index; in hpsa_cmd_init()
5540 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_init()
5541 err_dma_handle = h->errinfo_pool_dhandle in hpsa_cmd_init()
5542 + index * sizeof(*c->err_info); in hpsa_cmd_init()
5543 c->cmdindex = index; in hpsa_cmd_init()
5544 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_init()
5545 c->ErrDesc.Addr = cpu_to_le64((u64) err_dma_handle); in hpsa_cmd_init()
5546 c->ErrDesc.Len = cpu_to_le32((u32) sizeof(*c->err_info)); in hpsa_cmd_init()
5547 c->h = h; in hpsa_cmd_init()
5548 c->scsi_cmd = SCSI_CMD_IDLE; in hpsa_cmd_init()
5555 for (i = 0; i < h->nr_cmds; i++) { in hpsa_preinitialize_commands()
5556 struct CommandList *c = h->cmd_pool + i; in hpsa_preinitialize_commands()
5559 atomic_set(&c->refcount, 0); in hpsa_preinitialize_commands()
5566 dma_addr_t cmd_dma_handle = h->cmd_pool_dhandle + index * sizeof(*c); in hpsa_cmd_partial_init()
5568 BUG_ON(c->cmdindex != index); in hpsa_cmd_partial_init()
5570 memset(c->Request.CDB, 0, sizeof(c->Request.CDB)); in hpsa_cmd_partial_init()
5571 memset(c->err_info, 0, sizeof(*c->err_info)); in hpsa_cmd_partial_init()
5572 c->busaddr = (u32) cmd_dma_handle; in hpsa_cmd_partial_init()
5579 struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; in hpsa_ioaccel_submit()
5585 if (dev->in_reset) in hpsa_ioaccel_submit()
5591 cmd->host_scribble = (unsigned char *) c; in hpsa_ioaccel_submit()
5593 if (dev->offload_enabled) { in hpsa_ioaccel_submit()
5594 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5595 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5596 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5597 c->device = dev; in hpsa_ioaccel_submit()
5598 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5599 c->retry_pending = true; in hpsa_ioaccel_submit()
5603 } else if (dev->hba_ioaccel_enabled) { in hpsa_ioaccel_submit()
5604 hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */ in hpsa_ioaccel_submit()
5605 c->cmd_type = CMD_SCSI; in hpsa_ioaccel_submit()
5606 c->scsi_cmd = cmd; in hpsa_ioaccel_submit()
5607 c->device = dev; in hpsa_ioaccel_submit()
5608 if (retry) /* Resubmit but do not increment device->commands_outstanding. */ in hpsa_ioaccel_submit()
5609 c->retry_pending = true; in hpsa_ioaccel_submit()
5623 cmd = c->scsi_cmd; in hpsa_command_resubmit_worker()
5624 dev = cmd->device->hostdata; in hpsa_command_resubmit_worker()
5626 cmd->result = DID_NO_CONNECT << 16; in hpsa_command_resubmit_worker()
5627 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5630 if (dev->in_reset) { in hpsa_command_resubmit_worker()
5631 cmd->result = DID_RESET << 16; in hpsa_command_resubmit_worker()
5632 return hpsa_cmd_free_and_done(c->h, c, cmd); in hpsa_command_resubmit_worker()
5635 if (c->cmd_type == CMD_IOACCEL2) { in hpsa_command_resubmit_worker()
5636 struct ctlr_info *h = c->h; in hpsa_command_resubmit_worker()
5637 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; in hpsa_command_resubmit_worker()
5640 if (c2->error_data.serv_response == in hpsa_command_resubmit_worker()
5652 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5658 hpsa_cmd_partial_init(c->h, c->cmdindex, c); in hpsa_command_resubmit_worker()
5662 * retry attempt (I.E. not a SML retry). in hpsa_command_resubmit_worker()
5667 c->retry_pending = true; in hpsa_command_resubmit_worker()
5668 if (hpsa_ciss_submit(c->h, c, cmd, dev)) { in hpsa_command_resubmit_worker()
5677 cmd->result = DID_IMM_RETRY << 16; in hpsa_command_resubmit_worker()
5682 /* Running in struct Scsi_Host->host_lock less mode */
5690 /* Get the ptr to our adapter structure out of cmd->host. */ in hpsa_scsi_queue_command()
5691 h = sdev_to_hba(cmd->device); in hpsa_scsi_queue_command()
5693 BUG_ON(scsi_cmd_to_rq(cmd)->tag < 0); in hpsa_scsi_queue_command()
5695 dev = cmd->device->hostdata; in hpsa_scsi_queue_command()
5697 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5702 if (dev->removed) { in hpsa_scsi_queue_command()
5703 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5709 cmd->result = DID_NO_CONNECT << 16; in hpsa_scsi_queue_command()
5714 if (dev->in_reset) in hpsa_scsi_queue_command()
5722 * This is necessary because the SML doesn't zero out this field during in hpsa_scsi_queue_command()
5725 cmd->result = 0; in hpsa_scsi_queue_command()
5730 * Note: If cmd->retries is non-zero, then this is a SML in hpsa_scsi_queue_command()
5733 * and is therefore a brand-new command. in hpsa_scsi_queue_command()
5735 if (likely(cmd->retries == 0 && in hpsa_scsi_queue_command()
5737 h->acciopath_status)) { in hpsa_scsi_queue_command()
5754 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_complete()
5755 h->scan_finished = 1; in hpsa_scan_complete()
5756 wake_up(&h->scan_wait_queue); in hpsa_scan_complete()
5757 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_complete()
5777 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5778 if (h->scan_waiting) { in hpsa_scan_start()
5779 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5783 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5787 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_start()
5788 if (h->scan_finished) in hpsa_scan_start()
5790 h->scan_waiting = 1; in hpsa_scan_start()
5791 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5792 wait_event(h->scan_wait_queue, h->scan_finished); in hpsa_scan_start()
5799 h->scan_finished = 0; /* mark scan as in progress */ in hpsa_scan_start()
5800 h->scan_waiting = 0; in hpsa_scan_start()
5801 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_start()
5809 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_scan_start()
5810 if (h->reset_in_progress) { in hpsa_scan_start()
5811 h->drv_req_rescan = 1; in hpsa_scan_start()
5812 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5816 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_scan_start()
5825 struct hpsa_scsi_dev_t *logical_drive = sdev->hostdata; in hpsa_change_queue_depth()
5828 return -ENODEV; in hpsa_change_queue_depth()
5832 else if (qdepth > logical_drive->queue_depth) in hpsa_change_queue_depth()
5833 qdepth = logical_drive->queue_depth; in hpsa_change_queue_depth()
5845 spin_lock_irqsave(&h->scan_lock, flags); in hpsa_scan_finished()
5846 finished = h->scan_finished; in hpsa_scan_finished()
5847 spin_unlock_irqrestore(&h->scan_lock, flags); in hpsa_scan_finished()
5857 dev_err(&h->pdev->dev, "scsi_host_alloc failed\n"); in hpsa_scsi_host_alloc()
5858 return -ENOMEM; in hpsa_scsi_host_alloc()
5861 sh->io_port = 0; in hpsa_scsi_host_alloc()
5862 sh->n_io_port = 0; in hpsa_scsi_host_alloc()
5863 sh->this_id = -1; in hpsa_scsi_host_alloc()
5864 sh->max_channel = 3; in hpsa_scsi_host_alloc()
5865 sh->max_cmd_len = MAX_COMMAND_SIZE; in hpsa_scsi_host_alloc()
5866 sh->max_lun = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5867 sh->max_id = HPSA_MAX_LUN; in hpsa_scsi_host_alloc()
5868 sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; in hpsa_scsi_host_alloc()
5869 sh->cmd_per_lun = sh->can_queue; in hpsa_scsi_host_alloc()
5870 sh->sg_tablesize = h->maxsgentries; in hpsa_scsi_host_alloc()
5871 sh->transportt = hpsa_sas_transport_template; in hpsa_scsi_host_alloc()
5872 sh->hostdata[0] = (unsigned long) h; in hpsa_scsi_host_alloc()
5873 sh->irq = pci_irq_vector(h->pdev, 0); in hpsa_scsi_host_alloc()
5874 sh->unique_id = sh->irq; in hpsa_scsi_host_alloc()
5876 h->scsi_host = sh; in hpsa_scsi_host_alloc()
5884 rv = scsi_add_host(h->scsi_host, &h->pdev->dev); in hpsa_scsi_add_host()
5886 dev_err(&h->pdev->dev, "scsi_add_host failed\n"); in hpsa_scsi_add_host()
5889 scsi_scan_host(h->scsi_host); in hpsa_scsi_add_host()
5895 * small-integer tag for this request. We use an offset from that value as
5897 * low-numbered entries for our own uses.)
5901 int idx = scsi_cmd_to_rq(scmd)->tag; in hpsa_get_cmd_index()
5912 * reply queue; returns zero if the unit is ready, and non-zero otherwise.
5929 if (c->err_info->CommandStatus == CMD_SUCCESS) in hpsa_send_test_unit_ready()
5937 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in hpsa_send_test_unit_ready()
5938 c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION && in hpsa_send_test_unit_ready()
5939 (c->err_info->SenseInfo[2] == NO_SENSE || in hpsa_send_test_unit_ready()
5940 c->err_info->SenseInfo[2] == UNIT_ATTENTION)) in hpsa_send_test_unit_ready()
5948 * returns zero when the unit is ready, and non-zero when giving up.
5975 dev_warn(&h->pdev->dev, in hpsa_wait_for_test_unit_ready()
6002 last_queue = h->nreply_queues - 1; in wait_for_device_to_become_ready()
6015 dev_warn(&h->pdev->dev, "giving up on device.\n"); in wait_for_device_to_become_ready()
6017 dev_warn(&h->pdev->dev, "device is ready.\n"); in wait_for_device_to_become_ready()
6024 * complaining. Doing a host- or bus-reset can't do anything good here.
6037 h = sdev_to_hba(scsicmd->device); in hpsa_eh_device_reset_handler()
6041 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6042 h->reset_in_progress = 1; in hpsa_eh_device_reset_handler()
6043 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6050 dev = scsicmd->device->hostdata; in hpsa_eh_device_reset_handler()
6052 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); in hpsa_eh_device_reset_handler()
6057 if (dev->devtype == TYPE_ENCLOSURE) { in hpsa_eh_device_reset_handler()
6083 if (is_hba_lunid(dev->scsi3addr)) { in hpsa_eh_device_reset_handler()
6088 if (is_logical_dev_addr_mode(dev->scsi3addr)) in hpsa_eh_device_reset_handler()
6100 dev->in_reset = true; /* block any new cmds from OS for this device */ in hpsa_eh_device_reset_handler()
6102 if (atomic_read(&dev->commands_outstanding) > 0) in hpsa_eh_device_reset_handler()
6121 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6122 h->reset_in_progress = 0; in hpsa_eh_device_reset_handler()
6124 dev->in_reset = false; in hpsa_eh_device_reset_handler()
6125 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_eh_device_reset_handler()
6140 struct CommandList *c = h->cmd_pool + idx; in cmd_tagged_alloc()
6142 if (idx < HPSA_NRESERVED_CMDS || idx >= h->nr_cmds) { in cmd_tagged_alloc()
6143 dev_err(&h->pdev->dev, "Bad block tag: %d not in [%d..%d]\n", in cmd_tagged_alloc()
6144 idx, HPSA_NRESERVED_CMDS, h->nr_cmds - 1); in cmd_tagged_alloc()
6158 if (idx != h->last_collision_tag) { /* Print once per tag */ in cmd_tagged_alloc()
6159 dev_warn(&h->pdev->dev, in cmd_tagged_alloc()
6163 h->last_collision_tag = idx; in cmd_tagged_alloc()
6168 atomic_inc(&c->refcount); in cmd_tagged_alloc()
6175 c->retry_pending = false; in cmd_tagged_alloc()
6186 (void)atomic_dec(&c->refcount); in cmd_tagged_free()
6205 * There is some *extremely* small but non-zero chance that that in cmd_alloc()
6219 * reserved for driver-initiated requests, while requests from the block in cmd_alloc()
6224 i = find_next_zero_bit(h->cmd_pool_bits, in cmd_alloc()
6231 c = h->cmd_pool + i; in cmd_alloc()
6232 refcount = atomic_inc_return(&c->refcount); in cmd_alloc()
6238 set_bit(i, h->cmd_pool_bits); in cmd_alloc()
6242 c->device = NULL; in cmd_alloc()
6248 c->retry_pending = false; in cmd_alloc()
6256 * cmd_tagged_alloc() in which case the ref-count decrement does the trick and
6257 * the clear-bit is harmless.
6261 if (atomic_dec_and_test(&c->refcount)) { in cmd_free()
6264 i = c - h->cmd_pool; in cmd_free()
6265 clear_bit(i, h->cmd_pool_bits); in cmd_free()
6281 return -EINVAL; in hpsa_ioctl32_passthru()
6285 return -EFAULT; in hpsa_ioctl32_passthru()
6286 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_passthru()
6287 return -EFAULT; in hpsa_ioctl32_passthru()
6290 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_passthru()
6291 return -EAGAIN; in hpsa_ioctl32_passthru()
6293 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_passthru()
6296 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_passthru()
6297 sizeof(arg32->error_info))) in hpsa_ioctl32_passthru()
6298 return -EFAULT; in hpsa_ioctl32_passthru()
6312 return -EINVAL; in hpsa_ioctl32_big_passthru()
6316 return -EFAULT; in hpsa_ioctl32_big_passthru()
6317 if (get_user(cp, &arg32->buf)) in hpsa_ioctl32_big_passthru()
6318 return -EFAULT; in hpsa_ioctl32_big_passthru()
6321 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl32_big_passthru()
6322 return -EAGAIN; in hpsa_ioctl32_big_passthru()
6324 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl32_big_passthru()
6327 if (copy_to_user(&arg32->error_info, &arg64.error_info, in hpsa_ioctl32_big_passthru()
6328 sizeof(arg32->error_info))) in hpsa_ioctl32_big_passthru()
6329 return -EFAULT; in hpsa_ioctl32_big_passthru()
6360 return -ENOIOCTLCMD; in hpsa_compat_ioctl()
6370 return -EINVAL; in hpsa_getpciinfo_ioctl()
6371 pciinfo.domain = pci_domain_nr(h->pdev->bus); in hpsa_getpciinfo_ioctl()
6372 pciinfo.bus = h->pdev->bus->number; in hpsa_getpciinfo_ioctl()
6373 pciinfo.dev_fn = h->pdev->devfn; in hpsa_getpciinfo_ioctl()
6374 pciinfo.board_id = h->board_id; in hpsa_getpciinfo_ioctl()
6376 return -EFAULT; in hpsa_getpciinfo_ioctl()
6389 dev_info(&h->pdev->dev, "driver version string '%s' " in hpsa_getdrivver_ioctl()
6397 return -EINVAL; in hpsa_getdrivver_ioctl()
6399 return -EFAULT; in hpsa_getdrivver_ioctl()
6412 return -EPERM; in hpsa_passthru_ioctl()
6413 if ((iocommand->buf_size < 1) && in hpsa_passthru_ioctl()
6414 (iocommand->Request.Type.Direction != XFER_NONE)) { in hpsa_passthru_ioctl()
6415 return -EINVAL; in hpsa_passthru_ioctl()
6417 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6418 buff = kmalloc(iocommand->buf_size, GFP_KERNEL); in hpsa_passthru_ioctl()
6420 return -ENOMEM; in hpsa_passthru_ioctl()
6421 if (iocommand->Request.Type.Direction & XFER_WRITE) { in hpsa_passthru_ioctl()
6423 if (copy_from_user(buff, iocommand->buf, in hpsa_passthru_ioctl()
6424 iocommand->buf_size)) { in hpsa_passthru_ioctl()
6425 rc = -EFAULT; in hpsa_passthru_ioctl()
6429 memset(buff, 0, iocommand->buf_size); in hpsa_passthru_ioctl()
6435 c->cmd_type = CMD_IOCTL_PEND; in hpsa_passthru_ioctl()
6436 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_passthru_ioctl()
6438 c->Header.ReplyQueue = 0; /* unused in simple mode */ in hpsa_passthru_ioctl()
6439 if (iocommand->buf_size > 0) { /* buffer to fill */ in hpsa_passthru_ioctl()
6440 c->Header.SGList = 1; in hpsa_passthru_ioctl()
6441 c->Header.SGTotal = cpu_to_le16(1); in hpsa_passthru_ioctl()
6443 c->Header.SGList = 0; in hpsa_passthru_ioctl()
6444 c->Header.SGTotal = cpu_to_le16(0); in hpsa_passthru_ioctl()
6446 memcpy(&c->Header.LUN, &iocommand->LUN_info, sizeof(c->Header.LUN)); in hpsa_passthru_ioctl()
6449 memcpy(&c->Request, &iocommand->Request, in hpsa_passthru_ioctl()
6450 sizeof(c->Request)); in hpsa_passthru_ioctl()
6453 if (iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6454 temp64 = dma_map_single(&h->pdev->dev, buff, in hpsa_passthru_ioctl()
6455 iocommand->buf_size, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6456 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) { in hpsa_passthru_ioctl()
6457 c->SG[0].Addr = cpu_to_le64(0); in hpsa_passthru_ioctl()
6458 c->SG[0].Len = cpu_to_le32(0); in hpsa_passthru_ioctl()
6459 rc = -ENOMEM; in hpsa_passthru_ioctl()
6462 c->SG[0].Addr = cpu_to_le64(temp64); in hpsa_passthru_ioctl()
6463 c->SG[0].Len = cpu_to_le32(iocommand->buf_size); in hpsa_passthru_ioctl()
6464 c->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* not chaining */ in hpsa_passthru_ioctl()
6468 if (iocommand->buf_size > 0) in hpsa_passthru_ioctl()
6469 hpsa_pci_unmap(h->pdev, c, 1, DMA_BIDIRECTIONAL); in hpsa_passthru_ioctl()
6472 rc = -EIO; in hpsa_passthru_ioctl()
6477 memcpy(&iocommand->error_info, c->err_info, in hpsa_passthru_ioctl()
6478 sizeof(iocommand->error_info)); in hpsa_passthru_ioctl()
6479 if ((iocommand->Request.Type.Direction & XFER_READ) && in hpsa_passthru_ioctl()
6480 iocommand->buf_size > 0) { in hpsa_passthru_ioctl()
6482 if (copy_to_user(iocommand->buf, buff, iocommand->buf_size)) { in hpsa_passthru_ioctl()
6483 rc = -EFAULT; in hpsa_passthru_ioctl()
6508 return -EPERM; in hpsa_big_passthru_ioctl()
6510 if ((ioc->buf_size < 1) && in hpsa_big_passthru_ioctl()
6511 (ioc->Request.Type.Direction != XFER_NONE)) in hpsa_big_passthru_ioctl()
6512 return -EINVAL; in hpsa_big_passthru_ioctl()
6514 if (ioc->malloc_size > MAX_KMALLOC_SIZE) in hpsa_big_passthru_ioctl()
6515 return -EINVAL; in hpsa_big_passthru_ioctl()
6516 if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD) in hpsa_big_passthru_ioctl()
6517 return -EINVAL; in hpsa_big_passthru_ioctl()
6520 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6525 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6528 left = ioc->buf_size; in hpsa_big_passthru_ioctl()
6529 data_ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6531 sz = (left > ioc->malloc_size) ? ioc->malloc_size : left; in hpsa_big_passthru_ioctl()
6535 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6538 if (ioc->Request.Type.Direction & XFER_WRITE) { in hpsa_big_passthru_ioctl()
6540 status = -EFAULT; in hpsa_big_passthru_ioctl()
6545 left -= sz; in hpsa_big_passthru_ioctl()
6551 c->cmd_type = CMD_IOCTL_PEND; in hpsa_big_passthru_ioctl()
6552 c->scsi_cmd = SCSI_CMD_BUSY; in hpsa_big_passthru_ioctl()
6553 c->Header.ReplyQueue = 0; in hpsa_big_passthru_ioctl()
6554 c->Header.SGList = (u8) sg_used; in hpsa_big_passthru_ioctl()
6555 c->Header.SGTotal = cpu_to_le16(sg_used); in hpsa_big_passthru_ioctl()
6556 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN)); in hpsa_big_passthru_ioctl()
6557 memcpy(&c->Request, &ioc->Request, sizeof(c->Request)); in hpsa_big_passthru_ioctl()
6558 if (ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6561 temp64 = dma_map_single(&h->pdev->dev, buff[i], in hpsa_big_passthru_ioctl()
6563 if (dma_mapping_error(&h->pdev->dev, in hpsa_big_passthru_ioctl()
6565 c->SG[i].Addr = cpu_to_le64(0); in hpsa_big_passthru_ioctl()
6566 c->SG[i].Len = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6567 hpsa_pci_unmap(h->pdev, c, i, in hpsa_big_passthru_ioctl()
6569 status = -ENOMEM; in hpsa_big_passthru_ioctl()
6572 c->SG[i].Addr = cpu_to_le64(temp64); in hpsa_big_passthru_ioctl()
6573 c->SG[i].Len = cpu_to_le32(buff_size[i]); in hpsa_big_passthru_ioctl()
6574 c->SG[i].Ext = cpu_to_le32(0); in hpsa_big_passthru_ioctl()
6576 c->SG[--i].Ext = cpu_to_le32(HPSA_SG_LAST); in hpsa_big_passthru_ioctl()
6581 hpsa_pci_unmap(h->pdev, c, sg_used, DMA_BIDIRECTIONAL); in hpsa_big_passthru_ioctl()
6584 status = -EIO; in hpsa_big_passthru_ioctl()
6589 memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info)); in hpsa_big_passthru_ioctl()
6590 if ((ioc->Request.Type.Direction & XFER_READ) && ioc->buf_size > 0) { in hpsa_big_passthru_ioctl()
6594 BYTE __user *ptr = ioc->buf; in hpsa_big_passthru_ioctl()
6597 status = -EFAULT; in hpsa_big_passthru_ioctl()
6621 if (c->err_info->CommandStatus == CMD_TARGET_STATUS && in check_ioctl_unit_attention()
6622 c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) in check_ioctl_unit_attention()
6639 hpsa_scan_start(h->scsi_host); in hpsa_ioctl()
6649 return -EINVAL; in hpsa_ioctl()
6651 return -EFAULT; in hpsa_ioctl()
6652 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6653 return -EAGAIN; in hpsa_ioctl()
6655 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6657 rc = -EFAULT; in hpsa_ioctl()
6663 return -EINVAL; in hpsa_ioctl()
6665 return -EFAULT; in hpsa_ioctl()
6666 if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) in hpsa_ioctl()
6667 return -EAGAIN; in hpsa_ioctl()
6669 atomic_inc(&h->passthru_cmds_avail); in hpsa_ioctl()
6671 rc = -EFAULT; in hpsa_ioctl()
6675 return -ENOTTY; in hpsa_ioctl()
6688 c->Request.CDB[1] = reset_type; /* fill_cmd defaults to target reset */ in hpsa_send_host_reset()
6689 c->waiting = NULL; in hpsa_send_host_reset()
6693 * re-initializing everything, so it doesn't matter and won't leak. in hpsa_send_host_reset()
6699 void *buff, size_t size, u16 page_code, unsigned char *scsi3addr, in fill_cmd() argument
6704 c->cmd_type = CMD_IOCTL_PEND; in fill_cmd()
6705 c->scsi_cmd = SCSI_CMD_BUSY; in fill_cmd()
6706 c->Header.ReplyQueue = 0; in fill_cmd()
6707 if (buff != NULL && size > 0) { in fill_cmd()
6708 c->Header.SGList = 1; in fill_cmd()
6709 c->Header.SGTotal = cpu_to_le16(1); in fill_cmd()
6711 c->Header.SGList = 0; in fill_cmd()
6712 c->Header.SGTotal = cpu_to_le16(0); in fill_cmd()
6714 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8); in fill_cmd()
6721 c->Request.CDB[1] = 0x01; in fill_cmd()
6722 c->Request.CDB[2] = (page_code & 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] = HPSA_INQUIRY; in fill_cmd()
6729 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6732 c->Request.CDBLen = 6; in fill_cmd()
6733 c->Request.type_attr_dir = in fill_cmd()
6735 c->Request.Timeout = 0; in fill_cmd()
6736 c->Request.CDB[0] = cmd; in fill_cmd()
6737 c->Request.CDB[1] = 1; in fill_cmd()
6738 c->Request.CDB[2] = 1; in fill_cmd()
6739 c->Request.CDB[3] = (size >> 8) & 0xFF; in fill_cmd()
6740 c->Request.CDB[4] = size & 0xFF; in fill_cmd()
6747 c->Request.CDBLen = 12; in fill_cmd()
6748 c->Request.type_attr_dir = in fill_cmd()
6750 c->Request.Timeout = 0; in fill_cmd()
6751 c->Request.CDB[0] = cmd; in fill_cmd()
6752 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6753 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6754 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6755 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6758 c->Request.CDBLen = 16; in fill_cmd()
6759 c->Request.type_attr_dir = in fill_cmd()
6761 c->Request.Timeout = 0; in fill_cmd()
6763 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6764 c->Request.CDB[6] = BMIC_SENSE_DIAG_OPTIONS; in fill_cmd()
6767 c->Request.CDBLen = 16; in fill_cmd()
6768 c->Request.type_attr_dir = in fill_cmd()
6771 c->Request.Timeout = 0; in fill_cmd()
6772 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6773 c->Request.CDB[6] = BMIC_SET_DIAG_OPTIONS; in fill_cmd()
6776 c->Request.CDBLen = 12; in fill_cmd()
6777 c->Request.type_attr_dir = in fill_cmd()
6780 c->Request.Timeout = 0; in fill_cmd()
6781 c->Request.CDB[0] = BMIC_WRITE; in fill_cmd()
6782 c->Request.CDB[6] = BMIC_CACHE_FLUSH; in fill_cmd()
6783 c->Request.CDB[7] = (size >> 8) & 0xFF; in fill_cmd()
6784 c->Request.CDB[8] = size & 0xFF; in fill_cmd()
6787 c->Request.CDBLen = 6; in fill_cmd()
6788 c->Request.type_attr_dir = in fill_cmd()
6790 c->Request.Timeout = 0; in fill_cmd()
6793 c->Request.CDBLen = 12; in fill_cmd()
6794 c->Request.type_attr_dir = in fill_cmd()
6796 c->Request.Timeout = 0; in fill_cmd()
6797 c->Request.CDB[0] = HPSA_CISS_READ; in fill_cmd()
6798 c->Request.CDB[1] = cmd; in fill_cmd()
6799 c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */ in fill_cmd()
6800 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6801 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6802 c->Request.CDB[9] = size & 0xFF; in fill_cmd()
6805 c->Request.CDBLen = 10; in fill_cmd()
6806 c->Request.type_attr_dir = in fill_cmd()
6808 c->Request.Timeout = 0; in fill_cmd()
6809 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6810 c->Request.CDB[6] = BMIC_SENSE_CONTROLLER_PARAMETERS; in fill_cmd()
6811 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6812 c->Request.CDB[8] = (size >> 8) & 0xFF; in fill_cmd()
6815 c->Request.CDBLen = 10; in fill_cmd()
6816 c->Request.type_attr_dir = in fill_cmd()
6818 c->Request.Timeout = 0; in fill_cmd()
6819 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6820 c->Request.CDB[6] = BMIC_IDENTIFY_PHYSICAL_DEVICE; in fill_cmd()
6821 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6822 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6825 c->Request.CDBLen = 10; in fill_cmd()
6826 c->Request.type_attr_dir = in fill_cmd()
6828 c->Request.Timeout = 0; in fill_cmd()
6829 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6830 c->Request.CDB[6] = BMIC_SENSE_SUBSYSTEM_INFORMATION; in fill_cmd()
6831 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6832 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6835 c->Request.CDBLen = 10; in fill_cmd()
6836 c->Request.type_attr_dir = in fill_cmd()
6838 c->Request.Timeout = 0; in fill_cmd()
6839 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6840 c->Request.CDB[6] = BMIC_SENSE_STORAGE_BOX_PARAMS; in fill_cmd()
6841 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6842 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6845 c->Request.CDBLen = 10; in fill_cmd()
6846 c->Request.type_attr_dir = in fill_cmd()
6848 c->Request.Timeout = 0; in fill_cmd()
6849 c->Request.CDB[0] = BMIC_READ; in fill_cmd()
6850 c->Request.CDB[1] = 0; in fill_cmd()
6851 c->Request.CDB[2] = 0; in fill_cmd()
6852 c->Request.CDB[3] = 0; in fill_cmd()
6853 c->Request.CDB[4] = 0; in fill_cmd()
6854 c->Request.CDB[5] = 0; in fill_cmd()
6855 c->Request.CDB[6] = BMIC_IDENTIFY_CONTROLLER; in fill_cmd()
6856 c->Request.CDB[7] = (size >> 16) & 0xFF; in fill_cmd()
6857 c->Request.CDB[8] = (size >> 8) & 0XFF; in fill_cmd()
6858 c->Request.CDB[9] = 0; in fill_cmd()
6861 dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd); in fill_cmd()
6868 c->Request.CDBLen = 16; in fill_cmd()
6869 c->Request.type_attr_dir = in fill_cmd()
6871 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6872 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6873 c->Request.CDB[0] = HPSA_RESET; in fill_cmd()
6874 c->Request.CDB[1] = HPSA_TARGET_RESET_TYPE; in fill_cmd()
6875 /* Physical target reset needs no control bytes 4-7*/ in fill_cmd()
6876 c->Request.CDB[4] = 0x00; in fill_cmd()
6877 c->Request.CDB[5] = 0x00; in fill_cmd()
6878 c->Request.CDB[6] = 0x00; in fill_cmd()
6879 c->Request.CDB[7] = 0x00; in fill_cmd()
6882 c->Request.CDBLen = 16; in fill_cmd()
6883 c->Request.type_attr_dir = in fill_cmd()
6885 c->Request.Timeout = 0; /* Don't time out */ in fill_cmd()
6886 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); in fill_cmd()
6887 c->Request.CDB[0] = cmd; in fill_cmd()
6888 c->Request.CDB[1] = HPSA_RESET_TYPE_LUN; in fill_cmd()
6889 /* If bytes 4-7 are zero, it means reset the */ in fill_cmd()
6891 c->Request.CDB[4] = 0x00; in fill_cmd()
6892 c->Request.CDB[5] = 0x00; in fill_cmd()
6893 c->Request.CDB[6] = 0x00; in fill_cmd()
6894 c->Request.CDB[7] = 0x00; in fill_cmd()
6897 dev_warn(&h->pdev->dev, "unknown message type %d\n", in fill_cmd()
6902 dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type); in fill_cmd()
6906 switch (GET_DIR(c->Request.type_attr_dir)) { in fill_cmd()
6919 if (hpsa_map_one(h->pdev, c, buff, size, dir)) in fill_cmd()
6920 return -1; in fill_cmd()
6927 static void __iomem *remap_pci_mem(ulong base, ulong size) in remap_pci_mem() argument
6930 ulong page_offs = ((ulong) base) - page_base; in remap_pci_mem()
6932 page_offs + size); in remap_pci_mem()
6939 return h->access.command_completed(h, q); in get_next_completion()
6944 return h->access.intr_pending(h); in interrupt_pending()
6949 return (h->access.intr_pending(h) == 0) || in interrupt_not_for_us()
6950 (h->interrupts_enabled == 0); in interrupt_not_for_us()
6956 if (unlikely(tag_index >= h->nr_cmds)) { in bad_tag()
6957 dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag); in bad_tag()
6965 dial_up_lockup_detection_on_fw_flash_complete(c->h, c); in finish_cmd()
6966 if (likely(c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_SCSI in finish_cmd()
6967 || c->cmd_type == CMD_IOACCEL2)) in finish_cmd()
6969 else if (c->cmd_type == CMD_IOCTL_PEND || c->cmd_type == IOACCEL2_TMF) in finish_cmd()
6970 complete(c->waiting); in finish_cmd()
6982 c = h->cmd_pool + tag_index; in process_indexed_cmd()
6997 if (likely(h->interrupts_enabled)) in ignore_bogus_interrupt()
7000 dev_info(&h->pdev->dev, "Received interrupt while interrupts disabled " in ignore_bogus_interrupt()
7007 * Convert &h->q[x] (passed to interrupt handlers) back to h.
7008 * Relies on (h-q[x] == x) being true for x such that
7013 return container_of((queue - *queue), struct ctlr_info, q[0]); in queue_to_hba()
7027 h->last_intr_timestamp = get_jiffies_64(); in hpsa_intx_discard_completions()
7045 h->last_intr_timestamp = get_jiffies_64(); in hpsa_msix_discard_completions()
7060 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_intx()
7077 h->last_intr_timestamp = get_jiffies_64(); in do_hpsa_intr_msi()
7100 sizeof(cmd->ErrorDescriptor); in hpsa_message()
7109 return -ENOMEM; in hpsa_message()
7111 /* The Inbound Post Queue only accepts 32-bit physical addresses for the in hpsa_message()
7115 err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_message()
7121 cmd = dma_alloc_coherent(&pdev->dev, cmd_sz, &paddr64, GFP_KERNEL); in hpsa_message()
7124 return -ENOMEM; in hpsa_message()
7127 /* This must fit, because of the 32-bit consistent DMA mask. Also, in hpsa_message()
7129 * least 4-byte aligned (most likely, it's page-aligned). in hpsa_message()
7133 cmd->CommandHeader.ReplyQueue = 0; in hpsa_message()
7134 cmd->CommandHeader.SGList = 0; in hpsa_message()
7135 cmd->CommandHeader.SGTotal = cpu_to_le16(0); in hpsa_message()
7136 cmd->CommandHeader.tag = cpu_to_le64(paddr64); in hpsa_message()
7137 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8); in hpsa_message()
7139 cmd->Request.CDBLen = 16; in hpsa_message()
7140 cmd->Request.type_attr_dir = in hpsa_message()
7142 cmd->Request.Timeout = 0; /* Don't time out */ in hpsa_message()
7143 cmd->Request.CDB[0] = opcode; in hpsa_message()
7144 cmd->Request.CDB[1] = type; in hpsa_message()
7145 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */ in hpsa_message()
7146 cmd->ErrorDescriptor.Addr = in hpsa_message()
7148 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo)); in hpsa_message()
7165 dev_err(&pdev->dev, "controller message %02x:%02x timed out\n", in hpsa_message()
7167 return -ETIMEDOUT; in hpsa_message()
7170 dma_free_coherent(&pdev->dev, cmd_sz, cmd, paddr64); in hpsa_message()
7173 dev_err(&pdev->dev, "controller message %02x:%02x failed\n", in hpsa_message()
7175 return -EIO; in hpsa_message()
7178 dev_info(&pdev->dev, "controller message %02x:%02x succeeded\n", in hpsa_message()
7194 dev_info(&pdev->dev, "using doorbell to reset controller\n"); in hpsa_controller_hard_reset()
7215 dev_info(&pdev->dev, "using PCI PM to reset controller\n"); in hpsa_controller_hard_reset()
7242 strncpy(driver_version, HPSA " " HPSA_DRIVER_VERSION, len - 1); in init_driver_version()
7248 int i, size = sizeof(cfgtable->driver_version); in write_driver_ver_to_cfgtable() local
7250 driver_version = kmalloc(size, GFP_KERNEL); in write_driver_ver_to_cfgtable()
7252 return -ENOMEM; in write_driver_ver_to_cfgtable()
7254 init_driver_version(driver_version, size); in write_driver_ver_to_cfgtable()
7255 for (i = 0; i < size; i++) in write_driver_ver_to_cfgtable()
7256 writeb(driver_version[i], &cfgtable->driver_version[i]); in write_driver_ver_to_cfgtable()
7266 for (i = 0; i < sizeof(cfgtable->driver_version); i++) in read_driver_ver_from_cfgtable()
7267 driver_ver[i] = readb(&cfgtable->driver_version[i]); in read_driver_ver_from_cfgtable()
7274 int rc, size = sizeof(cfgtable->driver_version); in controller_reset_failed() local
7276 old_driver_ver = kmalloc_array(2, size, GFP_KERNEL); in controller_reset_failed()
7278 return -ENOMEM; in controller_reset_failed()
7279 driver_ver = old_driver_ver + size; in controller_reset_failed()
7284 init_driver_version(old_driver_ver, size); in controller_reset_failed()
7286 rc = !memcmp(driver_ver, old_driver_ver, size); in controller_reset_failed()
7320 dev_warn(&pdev->dev, "Controller not resettable\n"); in hpsa_kdump_hard_reset_controller()
7321 return -ENODEV; in hpsa_kdump_hard_reset_controller()
7324 /* if controller is soft- but not hard resettable... */ in hpsa_kdump_hard_reset_controller()
7326 return -ENOTSUPP; /* try soft reset later. */ in hpsa_kdump_hard_reset_controller()
7338 return -ENOMEM; in hpsa_kdump_hard_reset_controller()
7348 rc = -ENOMEM; in hpsa_kdump_hard_reset_controller()
7358 misc_fw_support = readl(&cfgtable->misc_fw_support); in hpsa_kdump_hard_reset_controller()
7365 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7367 rc = -ENOTSUPP; /* try soft reset */ in hpsa_kdump_hard_reset_controller()
7385 dev_warn(&pdev->dev, in hpsa_kdump_hard_reset_controller()
7394 dev_warn(&pdev->dev, "Unable to successfully reset " in hpsa_kdump_hard_reset_controller()
7396 rc = -ENOTSUPP; in hpsa_kdump_hard_reset_controller()
7398 dev_info(&pdev->dev, "board ready after hard reset.\n"); in hpsa_kdump_hard_reset_controller()
7421 dev_info(dev, "------------------------------------\n"); in print_cfg_table()
7423 temp_name[i] = readb(&(tb->Signature[i])); in print_cfg_table()
7426 dev_info(dev, " Spec Number = %d\n", readl(&(tb->SpecValence))); in print_cfg_table()
7428 readl(&(tb->TransportSupport))); in print_cfg_table()
7430 readl(&(tb->TransportActive))); in print_cfg_table()
7432 readl(&(tb->HostWrite.TransportRequest))); in print_cfg_table()
7434 readl(&(tb->HostWrite.CoalIntDelay))); in print_cfg_table()
7436 readl(&(tb->HostWrite.CoalIntCount))); in print_cfg_table()
7438 readl(&(tb->CmdsOutMax))); in print_cfg_table()
7439 dev_info(dev, " Bus Types = 0x%x\n", readl(&(tb->BusTypes))); in print_cfg_table()
7441 temp_name[i] = readb(&(tb->ServerName[i])); in print_cfg_table()
7445 readl(&(tb->HeartBeat))); in print_cfg_table()
7472 dev_warn(&pdev->dev, in find_PCI_BAR_index()
7474 return -1; in find_PCI_BAR_index()
7477 if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) in find_PCI_BAR_index()
7480 return -1; in find_PCI_BAR_index()
7485 pci_free_irq_vectors(h->pdev); in hpsa_disable_interrupt_mode()
7486 h->msix_vectors = 0; in hpsa_disable_interrupt_mode()
7494 for (queue = 0; queue < h->msix_vectors; queue++) { in hpsa_setup_reply_map()
7495 mask = pci_irq_get_affinity(h->pdev, queue); in hpsa_setup_reply_map()
7500 h->reply_map[cpu] = queue; in hpsa_setup_reply_map()
7506 h->reply_map[cpu] = 0; in hpsa_setup_reply_map()
7509 /* If MSI/MSI-X is supported by the kernel we will try to enable it on
7518 switch (h->board_id) { in hpsa_interrupt_mode()
7525 ret = pci_alloc_irq_vectors(h->pdev, 1, MAX_REPLY_QUEUES, in hpsa_interrupt_mode()
7528 h->msix_vectors = ret; in hpsa_interrupt_mode()
7536 ret = pci_alloc_irq_vectors(h->pdev, 1, 1, flags); in hpsa_interrupt_mode()
7548 subsystem_vendor_id = pdev->subsystem_vendor; in hpsa_lookup_board_id()
7549 subsystem_device_id = pdev->subsystem_device; in hpsa_lookup_board_id()
7560 dev_warn(&pdev->dev, in hpsa_lookup_board_id()
7568 dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x\n", *board_id); in hpsa_lookup_board_id()
7571 return ARRAY_SIZE(products) - 1; /* generic unknown smart array */ in hpsa_lookup_board_id()
7583 dev_dbg(&pdev->dev, "memory BAR = %lx\n", in hpsa_pci_find_memory_BAR()
7587 dev_warn(&pdev->dev, "no memory BAR found\n"); in hpsa_pci_find_memory_BAR()
7588 return -ENODEV; in hpsa_pci_find_memory_BAR()
7612 dev_warn(&pdev->dev, "board not ready, timed out.\n"); in hpsa_wait_for_board_state()
7613 return -ENODEV; in hpsa_wait_for_board_state()
7624 if (*cfg_base_addr_index == -1) { in hpsa_find_cfg_addrs()
7625 dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n"); in hpsa_find_cfg_addrs()
7626 return -ENODEV; in hpsa_find_cfg_addrs()
7633 if (h->transtable) { in hpsa_free_cfgtables()
7634 iounmap(h->transtable); in hpsa_free_cfgtables()
7635 h->transtable = NULL; in hpsa_free_cfgtables()
7637 if (h->cfgtable) { in hpsa_free_cfgtables()
7638 iounmap(h->cfgtable); in hpsa_free_cfgtables()
7639 h->cfgtable = NULL; in hpsa_free_cfgtables()
7654 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_find_cfgtables()
7658 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7659 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable)); in hpsa_find_cfgtables()
7660 if (!h->cfgtable) { in hpsa_find_cfgtables()
7661 dev_err(&h->pdev->dev, "Failed mapping cfgtable\n"); in hpsa_find_cfgtables()
7662 return -ENOMEM; in hpsa_find_cfgtables()
7664 rc = write_driver_ver_to_cfgtable(h->cfgtable); in hpsa_find_cfgtables()
7668 trans_offset = readl(&h->cfgtable->TransMethodOffset); in hpsa_find_cfgtables()
7669 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, in hpsa_find_cfgtables()
7671 sizeof(*h->transtable)); in hpsa_find_cfgtables()
7672 if (!h->transtable) { in hpsa_find_cfgtables()
7673 dev_err(&h->pdev->dev, "Failed mapping transfer table\n"); in hpsa_find_cfgtables()
7675 return -ENOMEM; in hpsa_find_cfgtables()
7685 h->max_commands = readl(&h->cfgtable->MaxPerformantModeCommands); in hpsa_get_max_perf_mode_cmds()
7688 if (reset_devices && h->max_commands > 32) in hpsa_get_max_perf_mode_cmds()
7689 h->max_commands = 32; in hpsa_get_max_perf_mode_cmds()
7691 if (h->max_commands < MIN_MAX_COMMANDS) { in hpsa_get_max_perf_mode_cmds()
7692 dev_warn(&h->pdev->dev, in hpsa_get_max_perf_mode_cmds()
7694 h->max_commands, in hpsa_get_max_perf_mode_cmds()
7696 h->max_commands = MIN_MAX_COMMANDS; in hpsa_get_max_perf_mode_cmds()
7706 return h->maxsgentries > 512; in hpsa_supports_chained_sg_blocks()
7711 * SG chain block size, etc.
7716 h->nr_cmds = h->max_commands; in hpsa_find_board_params()
7717 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); in hpsa_find_board_params()
7718 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); in hpsa_find_board_params()
7720 /* Limit in-command s/g elements to 32 save dma'able memory. */ in hpsa_find_board_params()
7721 h->max_cmd_sg_entries = 32; in hpsa_find_board_params()
7722 h->chainsize = h->maxsgentries - h->max_cmd_sg_entries; in hpsa_find_board_params()
7723 h->maxsgentries--; /* save one for chain pointer */ in hpsa_find_board_params()
7730 h->max_cmd_sg_entries = 31; in hpsa_find_board_params()
7731 h->maxsgentries = 31; /* default to traditional values */ in hpsa_find_board_params()
7732 h->chainsize = 0; in hpsa_find_board_params()
7736 h->TMFSupportFlags = readl(&(h->cfgtable->TMFSupportFlags)); in hpsa_find_board_params()
7737 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7738 dev_warn(&h->pdev->dev, "Physical aborts not supported\n"); in hpsa_find_board_params()
7739 if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) in hpsa_find_board_params()
7740 dev_warn(&h->pdev->dev, "Logical aborts not supported\n"); in hpsa_find_board_params()
7741 if (!(HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags)) in hpsa_find_board_params()
7742 dev_warn(&h->pdev->dev, "HP SSD Smart Path aborts not supported\n"); in hpsa_find_board_params()
7747 if (!check_signature(h->cfgtable->Signature, "CISS", 4)) { in hpsa_CISS_signature_present()
7748 dev_err(&h->pdev->dev, "not a valid CISS config table\n"); in hpsa_CISS_signature_present()
7758 driver_support = readl(&(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7764 writel(driver_support, &(h->cfgtable->driver_support)); in hpsa_set_driver_support_bits()
7774 if (h->board_id != 0x3225103C) in hpsa_p600_dma_prefetch_quirk()
7776 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7778 writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG); in hpsa_p600_dma_prefetch_quirk()
7788 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7789 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_clear_event_notify_ack()
7790 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_clear_event_notify_ack()
7796 return -ENODEV; in hpsa_wait_for_clear_event_notify_ack()
7812 if (h->remove_in_progress) in hpsa_wait_for_mode_change_ack()
7814 spin_lock_irqsave(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7815 doorbell_value = readl(h->vaddr + SA5_DOORBELL); in hpsa_wait_for_mode_change_ack()
7816 spin_unlock_irqrestore(&h->lock, flags); in hpsa_wait_for_mode_change_ack()
7822 return -ENODEV; in hpsa_wait_for_mode_change_ack()
7827 /* return -ENODEV or other reason on error, 0 on success */
7832 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_enter_simple_mode()
7834 return -ENOTSUPP; in hpsa_enter_simple_mode()
7836 h->max_commands = readl(&(h->cfgtable->CmdsOutMax)); in hpsa_enter_simple_mode()
7839 writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_simple_mode()
7840 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_simple_mode()
7841 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_simple_mode()
7844 print_cfg_table(&h->pdev->dev, h->cfgtable); in hpsa_enter_simple_mode()
7845 if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) in hpsa_enter_simple_mode()
7847 h->transMethod = CFGTBL_Trans_Simple; in hpsa_enter_simple_mode()
7850 dev_err(&h->pdev->dev, "failed to enter simple mode\n"); in hpsa_enter_simple_mode()
7851 return -ENODEV; in hpsa_enter_simple_mode()
7858 iounmap(h->vaddr); /* pci_init 3 */ in hpsa_free_pci_init()
7859 h->vaddr = NULL; in hpsa_free_pci_init()
7863 * Documentation/driver-api/pci/pci.rst in hpsa_free_pci_init()
7865 pci_disable_device(h->pdev); /* pci_init 1 */ in hpsa_free_pci_init()
7866 pci_release_regions(h->pdev); /* pci_init 2 */ in hpsa_free_pci_init()
7875 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id, &legacy_board); in hpsa_pci_init()
7878 h->product_name = products[prod_index].product_name; in hpsa_pci_init()
7879 h->access = *(products[prod_index].access); in hpsa_pci_init()
7880 h->legacy_board = legacy_board; in hpsa_pci_init()
7881 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | in hpsa_pci_init()
7884 err = pci_enable_device(h->pdev); in hpsa_pci_init()
7886 dev_err(&h->pdev->dev, "failed to enable PCI device\n"); in hpsa_pci_init()
7887 pci_disable_device(h->pdev); in hpsa_pci_init()
7891 err = pci_request_regions(h->pdev, HPSA); in hpsa_pci_init()
7893 dev_err(&h->pdev->dev, in hpsa_pci_init()
7895 pci_disable_device(h->pdev); in hpsa_pci_init()
7899 pci_set_master(h->pdev); in hpsa_pci_init()
7908 err = hpsa_pci_find_memory_BAR(h->pdev, &h->paddr); in hpsa_pci_init()
7911 h->vaddr = remap_pci_mem(h->paddr, 0x250); in hpsa_pci_init()
7912 if (!h->vaddr) { in hpsa_pci_init()
7913 dev_err(&h->pdev->dev, "failed to remap PCI mem\n"); in hpsa_pci_init()
7914 err = -ENOMEM; in hpsa_pci_init()
7917 err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_pci_init()
7926 err = -ENODEV; in hpsa_pci_init()
7939 iounmap(h->vaddr); in hpsa_pci_init()
7940 h->vaddr = NULL; in hpsa_pci_init()
7946 * Documentation/driver-api/pci/pci.rst in hpsa_pci_init()
7948 pci_disable_device(h->pdev); in hpsa_pci_init()
7949 pci_release_regions(h->pdev); in hpsa_pci_init()
7958 h->hba_inquiry_data = kmalloc(HBA_INQUIRY_BYTE_COUNT, GFP_KERNEL); in hpsa_hba_inquiry()
7959 if (!h->hba_inquiry_data) in hpsa_hba_inquiry()
7962 h->hba_inquiry_data, HBA_INQUIRY_BYTE_COUNT); in hpsa_hba_inquiry()
7964 kfree(h->hba_inquiry_data); in hpsa_hba_inquiry()
7965 h->hba_inquiry_data = NULL; in hpsa_hba_inquiry()
7978 * the pci interface. The dev->enable_cnt is equal zero in hpsa_init_reset_devices()
7983 dev_warn(&pdev->dev, "Failed to enable PCI device\n"); in hpsa_init_reset_devices()
7984 return -ENODEV; in hpsa_init_reset_devices()
7990 dev_warn(&pdev->dev, "failed to enable device.\n"); in hpsa_init_reset_devices()
7991 return -ENODEV; in hpsa_init_reset_devices()
7998 rc = -ENOMEM; in hpsa_init_reset_devices()
8004 /* Reset the controller with a PCI power-cycle or via doorbell */ in hpsa_init_reset_devices()
8007 /* -ENOTSUPP here means we cannot reset the controller in hpsa_init_reset_devices()
8015 /* Now try to get the controller to respond to a no-op */ in hpsa_init_reset_devices()
8016 dev_info(&pdev->dev, "Waiting for controller to respond to no-op\n"); in hpsa_init_reset_devices()
8021 dev_warn(&pdev->dev, "no-op failed%s\n", in hpsa_init_reset_devices()
8022 (i < 11 ? "; re-trying" : "")); in hpsa_init_reset_devices()
8033 bitmap_free(h->cmd_pool_bits); in hpsa_free_cmd_pool()
8034 h->cmd_pool_bits = NULL; in hpsa_free_cmd_pool()
8035 if (h->cmd_pool) { in hpsa_free_cmd_pool()
8036 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8037 h->nr_cmds * sizeof(struct CommandList), in hpsa_free_cmd_pool()
8038 h->cmd_pool, in hpsa_free_cmd_pool()
8039 h->cmd_pool_dhandle); in hpsa_free_cmd_pool()
8040 h->cmd_pool = NULL; in hpsa_free_cmd_pool()
8041 h->cmd_pool_dhandle = 0; in hpsa_free_cmd_pool()
8043 if (h->errinfo_pool) { in hpsa_free_cmd_pool()
8044 dma_free_coherent(&h->pdev->dev, in hpsa_free_cmd_pool()
8045 h->nr_cmds * sizeof(struct ErrorInfo), in hpsa_free_cmd_pool()
8046 h->errinfo_pool, in hpsa_free_cmd_pool()
8047 h->errinfo_pool_dhandle); in hpsa_free_cmd_pool()
8048 h->errinfo_pool = NULL; in hpsa_free_cmd_pool()
8049 h->errinfo_pool_dhandle = 0; in hpsa_free_cmd_pool()
8055 h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8056 h->cmd_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8057 h->nr_cmds * sizeof(*h->cmd_pool), in hpsa_alloc_cmd_pool()
8058 &h->cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8059 h->errinfo_pool = dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_cmd_pool()
8060 h->nr_cmds * sizeof(*h->errinfo_pool), in hpsa_alloc_cmd_pool()
8061 &h->errinfo_pool_dhandle, GFP_KERNEL); in hpsa_alloc_cmd_pool()
8062 if ((h->cmd_pool_bits == NULL) in hpsa_alloc_cmd_pool()
8063 || (h->cmd_pool == NULL) in hpsa_alloc_cmd_pool()
8064 || (h->errinfo_pool == NULL)) { in hpsa_alloc_cmd_pool()
8065 dev_err(&h->pdev->dev, "out of memory in %s", __func__); in hpsa_alloc_cmd_pool()
8072 return -ENOMEM; in hpsa_alloc_cmd_pool()
8075 /* clear affinity hints and free MSI-X, MSI, or legacy INTx vectors */
8082 irq_vector = h->intr_mode; in hpsa_free_irqs()
8084 if (!h->msix_vectors || h->intr_mode != PERF_MODE_INT) { in hpsa_free_irqs()
8086 free_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_free_irqs()
8087 &h->q[h->intr_mode]); in hpsa_free_irqs()
8088 h->q[h->intr_mode] = 0; in hpsa_free_irqs()
8092 for (i = 0; i < h->msix_vectors; i++) { in hpsa_free_irqs()
8093 free_irq(pci_irq_vector(h->pdev, i), &h->q[i]); in hpsa_free_irqs()
8094 h->q[i] = 0; in hpsa_free_irqs()
8097 h->q[i] = 0; in hpsa_free_irqs()
8100 /* returns 0 on success; cleans up and returns -Enn on error */
8109 irq_vector = h->intr_mode; in hpsa_request_irqs()
8112 * initialize h->q[x] = x so that interrupt handlers know which in hpsa_request_irqs()
8116 h->q[i] = (u8) i; in hpsa_request_irqs()
8118 if (h->intr_mode == PERF_MODE_INT && h->msix_vectors > 0) { in hpsa_request_irqs()
8119 /* If performant mode and MSI-X, use multiple reply queues */ in hpsa_request_irqs()
8120 for (i = 0; i < h->msix_vectors; i++) { in hpsa_request_irqs()
8121 sprintf(h->intrname[i], "%s-msix%d", h->devname, i); in hpsa_request_irqs()
8122 rc = request_irq(pci_irq_vector(h->pdev, i), msixhandler, in hpsa_request_irqs()
8123 0, h->intrname[i], in hpsa_request_irqs()
8124 &h->q[i]); in hpsa_request_irqs()
8128 dev_err(&h->pdev->dev, in hpsa_request_irqs()
8130 pci_irq_vector(h->pdev, i), h->devname); in hpsa_request_irqs()
8132 free_irq(pci_irq_vector(h->pdev, j), &h->q[j]); in hpsa_request_irqs()
8133 h->q[j] = 0; in hpsa_request_irqs()
8136 h->q[j] = 0; in hpsa_request_irqs()
8142 if (h->msix_vectors > 0 || h->pdev->msi_enabled) { in hpsa_request_irqs()
8143 sprintf(h->intrname[0], "%s-msi%s", h->devname, in hpsa_request_irqs()
8144 h->msix_vectors ? "x" : ""); in hpsa_request_irqs()
8145 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8147 h->intrname[0], in hpsa_request_irqs()
8148 &h->q[h->intr_mode]); in hpsa_request_irqs()
8150 sprintf(h->intrname[h->intr_mode], in hpsa_request_irqs()
8151 "%s-intx", h->devname); in hpsa_request_irqs()
8152 rc = request_irq(pci_irq_vector(h->pdev, irq_vector), in hpsa_request_irqs()
8154 h->intrname[0], in hpsa_request_irqs()
8155 &h->q[h->intr_mode]); in hpsa_request_irqs()
8159 dev_err(&h->pdev->dev, "failed to get irq %d for %s\n", in hpsa_request_irqs()
8160 pci_irq_vector(h->pdev, irq_vector), h->devname); in hpsa_request_irqs()
8162 return -ENODEV; in hpsa_request_irqs()
8172 dev_info(&h->pdev->dev, "Waiting for board to soft reset.\n"); in hpsa_kdump_soft_reset()
8173 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_NOT_READY); in hpsa_kdump_soft_reset()
8175 dev_warn(&h->pdev->dev, "Soft reset had no effect.\n"); in hpsa_kdump_soft_reset()
8179 dev_info(&h->pdev->dev, "Board reset, awaiting READY status.\n"); in hpsa_kdump_soft_reset()
8180 rc = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY); in hpsa_kdump_soft_reset()
8182 dev_warn(&h->pdev->dev, "Board failed to become ready " in hpsa_kdump_soft_reset()
8194 for (i = 0; i < h->nreply_queues; i++) { in hpsa_free_reply_queues()
8195 if (!h->reply_queue[i].head) in hpsa_free_reply_queues()
8197 dma_free_coherent(&h->pdev->dev, in hpsa_free_reply_queues()
8198 h->reply_queue_size, in hpsa_free_reply_queues()
8199 h->reply_queue[i].head, in hpsa_free_reply_queues()
8200 h->reply_queue[i].busaddr); in hpsa_free_reply_queues()
8201 h->reply_queue[i].head = NULL; in hpsa_free_reply_queues()
8202 h->reply_queue[i].busaddr = 0; in hpsa_free_reply_queues()
8204 h->reply_queue_size = 0; in hpsa_free_reply_queues()
8213 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8214 h->scsi_host = NULL; /* init_one 3 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8216 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8217 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8218 if (h->resubmit_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8219 destroy_workqueue(h->resubmit_wq); /* init_one 1 */ in hpsa_undo_allocations_after_kdump_soft_reset()
8220 h->resubmit_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8222 if (h->rescan_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8223 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8224 h->rescan_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8226 if (h->monitor_ctlr_wq) { in hpsa_undo_allocations_after_kdump_soft_reset()
8227 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_undo_allocations_after_kdump_soft_reset()
8228 h->monitor_ctlr_wq = NULL; in hpsa_undo_allocations_after_kdump_soft_reset()
8241 flush_workqueue(h->resubmit_wq); /* ensure all cmds are fully built */ in fail_all_outstanding_cmds()
8242 for (i = 0; i < h->nr_cmds; i++) { in fail_all_outstanding_cmds()
8243 c = h->cmd_pool + i; in fail_all_outstanding_cmds()
8244 refcount = atomic_inc_return(&c->refcount); in fail_all_outstanding_cmds()
8246 c->err_info->CommandStatus = CMD_CTLR_LOCKUP; in fail_all_outstanding_cmds()
8248 atomic_dec(&h->commands_outstanding); in fail_all_outstanding_cmds()
8253 dev_warn(&h->pdev->dev, in fail_all_outstanding_cmds()
8263 lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); in set_lockup_detected_for_all_cpus()
8266 wmb(); /* be sure the per-cpu variables are out to memory */ in set_lockup_detected_for_all_cpus()
8274 h->access.set_intr_mask(h, HPSA_INTR_OFF); in controller_lockup_detected()
8275 spin_lock_irqsave(&h->lock, flags); in controller_lockup_detected()
8276 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); in controller_lockup_detected()
8279 dev_warn(&h->pdev->dev, in controller_lockup_detected()
8281 h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8285 spin_unlock_irqrestore(&h->lock, flags); in controller_lockup_detected()
8286 dev_warn(&h->pdev->dev, "Controller lockup detected: 0x%08x after %d\n", in controller_lockup_detected()
8287 lockup_detected, h->heartbeat_sample_interval / HZ); in controller_lockup_detected()
8289 dev_warn(&h->pdev->dev, "Telling controller to do a CHKPT\n"); in controller_lockup_detected()
8290 writel(DOORBELL_GENERATE_CHKPT, h->vaddr + SA5_DOORBELL); in controller_lockup_detected()
8292 pci_disable_device(h->pdev); in controller_lockup_detected()
8304 if (time_after64(h->last_intr_timestamp + in detect_controller_lockup()
8305 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8313 if (time_after64(h->last_heartbeat_timestamp + in detect_controller_lockup()
8314 (h->heartbeat_sample_interval), now)) in detect_controller_lockup()
8318 spin_lock_irqsave(&h->lock, flags); in detect_controller_lockup()
8319 heartbeat = readl(&h->cfgtable->HeartBeat); in detect_controller_lockup()
8320 spin_unlock_irqrestore(&h->lock, flags); in detect_controller_lockup()
8321 if (h->last_heartbeat == heartbeat) { in detect_controller_lockup()
8327 h->last_heartbeat = heartbeat; in detect_controller_lockup()
8328 h->last_heartbeat_timestamp = now; in detect_controller_lockup()
8359 for (i = 0; i < h->ndevices; i++) { in hpsa_set_ioaccel_status()
8363 device = h->dev[i]; in hpsa_set_ioaccel_status()
8367 if (!hpsa_vpd_page_supported(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8373 rc = hpsa_scsi_do_inquiry(h, device->scsi3addr, in hpsa_set_ioaccel_status()
8395 * If ioaccel is to be re-enabled, re-enable later during the in hpsa_set_ioaccel_status()
8405 * transformation - change to the LVs of an Array. in hpsa_set_ioaccel_status()
8406 * degraded volume - component failure in hpsa_set_ioaccel_status()
8418 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ack_ctlr_events()
8422 if ((h->transMethod & (CFGTBL_Trans_io_accel1 in hpsa_ack_ctlr_events()
8424 (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || in hpsa_ack_ctlr_events()
8425 h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE)) { in hpsa_ack_ctlr_events()
8427 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE) in hpsa_ack_ctlr_events()
8429 if (h->events & HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE) in hpsa_ack_ctlr_events()
8432 scsi_block_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8436 dev_warn(&h->pdev->dev, in hpsa_ack_ctlr_events()
8438 h->events, event_type); in hpsa_ack_ctlr_events()
8439 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8441 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8444 scsi_unblock_requests(h->scsi_host); in hpsa_ack_ctlr_events()
8447 writel(h->events, &(h->cfgtable->clear_event_notify)); in hpsa_ack_ctlr_events()
8448 writel(DOORBELL_CLEAR_EVENTS, h->vaddr + SA5_DOORBELL); in hpsa_ack_ctlr_events()
8457 * Also check flag for driver-initiated rescan.
8461 if (h->drv_req_rescan) { in hpsa_ctlr_needs_rescan()
8462 h->drv_req_rescan = 0; in hpsa_ctlr_needs_rescan()
8466 if (!(h->fw_support & MISC_FW_EVENT_NOTIFY)) in hpsa_ctlr_needs_rescan()
8469 h->events = readl(&(h->cfgtable->event_notify)); in hpsa_ctlr_needs_rescan()
8470 return h->events & RESCAN_REQUIRED_EVENT_BITS; in hpsa_ctlr_needs_rescan()
8482 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8483 list_for_each_safe(this, tmp, &h->offline_device_list) { in hpsa_offline_devices_ready()
8486 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8487 if (!hpsa_volume_offline(h, d->scsi3addr)) { in hpsa_offline_devices_ready()
8488 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8489 list_del(&d->offline_list); in hpsa_offline_devices_ready()
8490 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8493 spin_lock_irqsave(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8495 spin_unlock_irqrestore(&h->offline_device_lock, flags); in hpsa_offline_devices_ready()
8508 if (!h->lastlogicals) in hpsa_luns_changed()
8516 dev_warn(&h->pdev->dev, in hpsa_luns_changed()
8520 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) { in hpsa_luns_changed()
8521 dev_info(&h->pdev->dev, in hpsa_luns_changed()
8523 memcpy(h->lastlogicals, logdev, sizeof(*logdev)); in hpsa_luns_changed()
8540 spin_lock_irqsave(&h->reset_lock, flags); in hpsa_perform_rescan()
8541 if (h->reset_in_progress) { in hpsa_perform_rescan()
8542 h->drv_req_rescan = 1; in hpsa_perform_rescan()
8543 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8546 spin_unlock_irqrestore(&h->reset_lock, flags); in hpsa_perform_rescan()
8548 sh = scsi_host_get(h->scsi_host); in hpsa_perform_rescan()
8552 h->drv_req_rescan = 0; in hpsa_perform_rescan()
8565 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8566 if (h->remove_in_progress) { in hpsa_event_monitor_worker()
8567 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8570 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8577 spin_lock_irqsave(&h->lock, flags); in hpsa_event_monitor_worker()
8578 if (!h->remove_in_progress) in hpsa_event_monitor_worker()
8579 queue_delayed_work(h->monitor_ctlr_wq, &h->event_monitor_work, in hpsa_event_monitor_worker()
8581 spin_unlock_irqrestore(&h->lock, flags); in hpsa_event_monitor_worker()
8590 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8591 if (h->remove_in_progress) { in hpsa_rescan_ctlr_worker()
8592 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8595 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8597 if (h->drv_req_rescan || hpsa_offline_devices_ready(h)) { in hpsa_rescan_ctlr_worker()
8599 } else if (h->discovery_polling) { in hpsa_rescan_ctlr_worker()
8601 dev_info(&h->pdev->dev, in hpsa_rescan_ctlr_worker()
8606 spin_lock_irqsave(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8607 if (!h->remove_in_progress) in hpsa_rescan_ctlr_worker()
8608 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_rescan_ctlr_worker()
8609 h->heartbeat_sample_interval); in hpsa_rescan_ctlr_worker()
8610 spin_unlock_irqrestore(&h->lock, flags); in hpsa_rescan_ctlr_worker()
8623 spin_lock_irqsave(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8624 if (!h->remove_in_progress) in hpsa_monitor_ctlr_worker()
8625 queue_delayed_work(h->monitor_ctlr_wq, &h->monitor_ctlr_work, in hpsa_monitor_ctlr_worker()
8626 h->heartbeat_sample_interval); in hpsa_monitor_ctlr_worker()
8627 spin_unlock_irqrestore(&h->lock, flags); in hpsa_monitor_ctlr_worker()
8635 wq = alloc_ordered_workqueue("%s_%d_hpsa", 0, name, h->ctlr); in hpsa_create_controller_wq()
8637 dev_err(&h->pdev->dev, "failed to create %s workqueue\n", name); in hpsa_create_controller_wq()
8644 kfree(h->reply_map); in hpda_free_ctlr_info()
8656 h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); in hpda_alloc_ctlr_info()
8657 if (!h->reply_map) { in hpda_alloc_ctlr_info()
8677 dev_warn(&pdev->dev, "Board ID not found\n"); in hpsa_init_one()
8683 if (rc != -ENOTSUPP) in hpsa_init_one()
8686 * a proper hard reset, so returns -ENOTSUPP) we can try to do in hpsa_init_one()
8696 /* Command structures must be aligned on a 32-byte boundary because in hpsa_init_one()
8703 dev_err(&pdev->dev, "Failed to allocate controller head\n"); in hpsa_init_one()
8704 return -ENOMEM; in hpsa_init_one()
8707 h->pdev = pdev; in hpsa_init_one()
8709 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; in hpsa_init_one()
8710 INIT_LIST_HEAD(&h->offline_device_list); in hpsa_init_one()
8711 spin_lock_init(&h->lock); in hpsa_init_one()
8712 spin_lock_init(&h->offline_device_lock); in hpsa_init_one()
8713 spin_lock_init(&h->scan_lock); in hpsa_init_one()
8714 spin_lock_init(&h->reset_lock); in hpsa_init_one()
8715 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); in hpsa_init_one()
8717 /* Allocate and clear per-cpu variable lockup_detected */ in hpsa_init_one()
8718 h->lockup_detected = alloc_percpu(u32); in hpsa_init_one()
8719 if (!h->lockup_detected) { in hpsa_init_one()
8720 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); in hpsa_init_one()
8721 rc = -ENOMEM; in hpsa_init_one()
8730 /* relies on h-> settings made by hpsa_pci_init, including in hpsa_init_one()
8731 * interrupt_mode h->intr */ in hpsa_init_one()
8736 sprintf(h->devname, HPSA "%d", h->scsi_host->host_no); in hpsa_init_one()
8737 h->ctlr = number_of_controllers; in hpsa_init_one()
8741 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); in hpsa_init_one()
8743 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in hpsa_init_one()
8745 dev_err(&pdev->dev, "no suitable DMA available\n"); in hpsa_init_one()
8751 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8762 init_waitqueue_head(&h->scan_wait_queue); in hpsa_init_one()
8763 init_waitqueue_head(&h->event_sync_wait_queue); in hpsa_init_one()
8764 mutex_init(&h->reset_mutex); in hpsa_init_one()
8765 h->scan_finished = 1; /* no scan currently in progress */ in hpsa_init_one()
8766 h->scan_waiting = 0; in hpsa_init_one()
8769 h->ndevices = 0; in hpsa_init_one()
8771 spin_lock_init(&h->devlock); in hpsa_init_one()
8777 h->rescan_ctlr_wq = hpsa_create_controller_wq(h, "rescan"); in hpsa_init_one()
8778 if (!h->rescan_ctlr_wq) { in hpsa_init_one()
8779 rc = -ENOMEM; in hpsa_init_one()
8783 h->resubmit_wq = hpsa_create_controller_wq(h, "resubmit"); in hpsa_init_one()
8784 if (!h->resubmit_wq) { in hpsa_init_one()
8785 rc = -ENOMEM; in hpsa_init_one()
8789 h->monitor_ctlr_wq = hpsa_create_controller_wq(h, "monitor"); in hpsa_init_one()
8790 if (!h->monitor_ctlr_wq) { in hpsa_init_one()
8791 rc = -ENOMEM; in hpsa_init_one()
8809 spin_lock_irqsave(&h->lock, flags); in hpsa_init_one()
8810 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8811 spin_unlock_irqrestore(&h->lock, flags); in hpsa_init_one()
8816 dev_warn(&h->pdev->dev, in hpsa_init_one()
8837 dev_info(&h->pdev->dev, "Board READY.\n"); in hpsa_init_one()
8838 dev_info(&h->pdev->dev, in hpsa_init_one()
8840 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8842 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8844 rc = controller_reset_failed(h->cfgtable); in hpsa_init_one()
8846 dev_info(&h->pdev->dev, in hpsa_init_one()
8849 /* since the controller's reset, we have to go back and re-init in hpsa_init_one()
8857 return -ENODEV; in hpsa_init_one()
8863 h->acciopath_status = 1; in hpsa_init_one()
8865 h->discovery_polling = 0; in hpsa_init_one()
8869 h->access.set_intr_mask(h, HPSA_INTR_ON); in hpsa_init_one()
8873 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL); in hpsa_init_one()
8874 if (!h->lastlogicals) in hpsa_init_one()
8875 dev_info(&h->pdev->dev, in hpsa_init_one()
8884 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; in hpsa_init_one()
8885 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker); in hpsa_init_one()
8886 schedule_delayed_work(&h->monitor_ctlr_work, in hpsa_init_one()
8887 h->heartbeat_sample_interval); in hpsa_init_one()
8888 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker); in hpsa_init_one()
8889 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work, in hpsa_init_one()
8890 h->heartbeat_sample_interval); in hpsa_init_one()
8891 INIT_DELAYED_WORK(&h->event_monitor_work, hpsa_event_monitor_worker); in hpsa_init_one()
8892 schedule_delayed_work(&h->event_monitor_work, in hpsa_init_one()
8897 kfree(h->lastlogicals); in hpsa_init_one()
8900 h->access.set_intr_mask(h, HPSA_INTR_OFF); in hpsa_init_one()
8908 scsi_host_put(h->scsi_host); in hpsa_init_one()
8909 h->scsi_host = NULL; in hpsa_init_one()
8913 if (h->lockup_detected) { in hpsa_init_one()
8914 free_percpu(h->lockup_detected); in hpsa_init_one()
8915 h->lockup_detected = NULL; in hpsa_init_one()
8918 if (h->resubmit_wq) { in hpsa_init_one()
8919 destroy_workqueue(h->resubmit_wq); in hpsa_init_one()
8920 h->resubmit_wq = NULL; in hpsa_init_one()
8922 if (h->rescan_ctlr_wq) { in hpsa_init_one()
8923 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_init_one()
8924 h->rescan_ctlr_wq = NULL; in hpsa_init_one()
8926 if (h->monitor_ctlr_wq) { in hpsa_init_one()
8927 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_init_one()
8928 h->monitor_ctlr_wq = NULL; in hpsa_init_one()
8956 if (c->err_info->CommandStatus != 0) in hpsa_flush_cache()
8958 dev_warn(&h->pdev->dev, in hpsa_flush_cache()
8974 if (unlikely(h->lockup_detected)) in hpsa_disable_rld_caching()
8990 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9002 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9012 if ((rc != 0) || (c->err_info->CommandStatus != 0)) in hpsa_disable_rld_caching()
9019 dev_err(&h->pdev->dev, in hpsa_disable_rld_caching()
9036 h->access.set_intr_mask(h, HPSA_INTR_OFF); in __hpsa_shutdown()
9051 for (i = 0; i < h->ndevices; i++) { in hpsa_free_device_info()
9052 kfree(h->dev[i]); in hpsa_free_device_info()
9053 h->dev[i] = NULL; in hpsa_free_device_info()
9063 dev_err(&pdev->dev, "unable to remove device\n"); in hpsa_remove_one()
9069 spin_lock_irqsave(&h->lock, flags); in hpsa_remove_one()
9070 h->remove_in_progress = 1; in hpsa_remove_one()
9071 spin_unlock_irqrestore(&h->lock, flags); in hpsa_remove_one()
9072 cancel_delayed_work_sync(&h->monitor_ctlr_work); in hpsa_remove_one()
9073 cancel_delayed_work_sync(&h->rescan_ctlr_work); in hpsa_remove_one()
9074 cancel_delayed_work_sync(&h->event_monitor_work); in hpsa_remove_one()
9075 destroy_workqueue(h->rescan_ctlr_wq); in hpsa_remove_one()
9076 destroy_workqueue(h->resubmit_wq); in hpsa_remove_one()
9077 destroy_workqueue(h->monitor_ctlr_wq); in hpsa_remove_one()
9087 if (h->scsi_host) in hpsa_remove_one()
9088 scsi_remove_host(h->scsi_host); /* init_one 8 */ in hpsa_remove_one()
9089 /* includes hpsa_free_irqs - init_one 4 */ in hpsa_remove_one()
9090 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9095 kfree(h->hba_inquiry_data); /* init_one 10 */ in hpsa_remove_one()
9096 h->hba_inquiry_data = NULL; /* init_one 10 */ in hpsa_remove_one()
9101 kfree(h->lastlogicals); in hpsa_remove_one()
9105 scsi_host_put(h->scsi_host); /* init_one 3 */ in hpsa_remove_one()
9106 h->scsi_host = NULL; /* init_one 3 */ in hpsa_remove_one()
9108 /* includes hpsa_disable_interrupt_mode - pci_init 2 */ in hpsa_remove_one()
9111 free_percpu(h->lockup_detected); /* init_one 2 */ in hpsa_remove_one()
9112 h->lockup_detected = NULL; /* init_one 2 */ in hpsa_remove_one()
9120 return -ENOSYS; in hpsa_suspend()
9126 return -ENOSYS; in hpsa_resume()
9149 * command, with the DMA transfer size encoded in the lower
9155 int i, j, b, size; in calc_bucket_map() local
9159 /* Compute size of a command with i SG entries */ in calc_bucket_map()
9160 size = i + min_blocks; in calc_bucket_map()
9164 if (bucket[j] >= size) { in calc_bucket_map()
9175 * return -ENODEV on err, 0 on success (or no action)
9194 * which of the eight sizes that command fits within. The size of in hpsa_enter_performant_mode()
9197 * with the number of 16-byte blocks a command of that size requires. in hpsa_enter_performant_mode()
9199 * the largest command possible requires SG_ENTRIES_IN_CMD + 4 16-byte in hpsa_enter_performant_mode()
9232 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9233 memset(h->reply_queue[i].head, 0, h->reply_queue_size); in hpsa_enter_performant_mode()
9237 SG_ENTRIES_IN_CMD, 4, h->blockFetchTable); in hpsa_enter_performant_mode()
9239 writel(bft[i], &h->transtable->BlockFetch[i]); in hpsa_enter_performant_mode()
9241 /* size of controller ring buffer */ in hpsa_enter_performant_mode()
9242 writel(h->max_commands, &h->transtable->RepQSize); in hpsa_enter_performant_mode()
9243 writel(h->nreply_queues, &h->transtable->RepQCount); in hpsa_enter_performant_mode()
9244 writel(0, &h->transtable->RepQCtrAddrLow32); in hpsa_enter_performant_mode()
9245 writel(0, &h->transtable->RepQCtrAddrHigh32); in hpsa_enter_performant_mode()
9247 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9248 writel(0, &h->transtable->RepQAddr[i].upper); in hpsa_enter_performant_mode()
9249 writel(h->reply_queue[i].busaddr, in hpsa_enter_performant_mode()
9250 &h->transtable->RepQAddr[i].lower); in hpsa_enter_performant_mode()
9253 writel(0, &h->cfgtable->HostWrite.command_pool_addr_hi); in hpsa_enter_performant_mode()
9254 writel(transMethod, &(h->cfgtable->HostWrite.TransportRequest)); in hpsa_enter_performant_mode()
9260 writel(10, &h->cfgtable->HostWrite.CoalIntDelay); in hpsa_enter_performant_mode()
9261 writel(4, &h->cfgtable->HostWrite.CoalIntCount); in hpsa_enter_performant_mode()
9265 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9267 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9268 "performant mode problem - doorbell timeout\n"); in hpsa_enter_performant_mode()
9269 return -ENODEV; in hpsa_enter_performant_mode()
9271 register_value = readl(&(h->cfgtable->TransportActive)); in hpsa_enter_performant_mode()
9273 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9274 "performant mode problem - transport not active\n"); in hpsa_enter_performant_mode()
9275 return -ENODEV; in hpsa_enter_performant_mode()
9278 h->access = access; in hpsa_enter_performant_mode()
9279 h->transMethod = transMethod; in hpsa_enter_performant_mode()
9287 for (i = 0; i < h->nreply_queues; i++) { in hpsa_enter_performant_mode()
9288 writel(i, h->vaddr + IOACCEL_MODE1_REPLY_QUEUE_INDEX); in hpsa_enter_performant_mode()
9289 h->reply_queue[i].current_entry = in hpsa_enter_performant_mode()
9290 readl(h->vaddr + IOACCEL_MODE1_PRODUCER_INDEX); in hpsa_enter_performant_mode()
9292 bft[7] = h->ioaccel_maxsg + 8; in hpsa_enter_performant_mode()
9293 calc_bucket_map(bft, ARRAY_SIZE(bft), h->ioaccel_maxsg, 8, in hpsa_enter_performant_mode()
9294 h->ioaccel1_blockFetchTable); in hpsa_enter_performant_mode()
9297 for (i = 0; i < h->nreply_queues; i++) in hpsa_enter_performant_mode()
9298 memset(h->reply_queue[i].head, in hpsa_enter_performant_mode()
9300 h->reply_queue_size); in hpsa_enter_performant_mode()
9305 for (i = 0; i < h->nr_cmds; i++) { in hpsa_enter_performant_mode()
9306 struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; in hpsa_enter_performant_mode()
9308 cp->function = IOACCEL1_FUNCTION_SCSIIO; in hpsa_enter_performant_mode()
9309 cp->err_info = (u32) (h->errinfo_pool_dhandle + in hpsa_enter_performant_mode()
9311 cp->err_info_len = sizeof(struct ErrorInfo); in hpsa_enter_performant_mode()
9312 cp->sgl_offset = IOACCEL1_SGLOFFSET; in hpsa_enter_performant_mode()
9313 cp->host_context_flags = in hpsa_enter_performant_mode()
9315 cp->timeout_sec = 0; in hpsa_enter_performant_mode()
9316 cp->ReplyQueue = 0; in hpsa_enter_performant_mode()
9317 cp->tag = in hpsa_enter_performant_mode()
9319 cp->host_addr = in hpsa_enter_performant_mode()
9320 cpu_to_le64(h->ioaccel_cmd_pool_dhandle + in hpsa_enter_performant_mode()
9327 hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr, in hpsa_enter_performant_mode()
9330 bft2[15] = h->ioaccel_maxsg + HPSA_IOACCEL2_HEADER_SZ; in hpsa_enter_performant_mode()
9331 calc_bucket_map(bft2, ARRAY_SIZE(bft2), h->ioaccel_maxsg, in hpsa_enter_performant_mode()
9332 4, h->ioaccel2_blockFetchTable); in hpsa_enter_performant_mode()
9333 bft2_offset = readl(&h->cfgtable->io_accel_request_size_offset); in hpsa_enter_performant_mode()
9336 h->ioaccel2_bft2_regs = in hpsa_enter_performant_mode()
9337 remap_pci_mem(pci_resource_start(h->pdev, in hpsa_enter_performant_mode()
9341 sizeof(*h->ioaccel2_bft2_regs)); in hpsa_enter_performant_mode()
9343 writel(bft2[i], &h->ioaccel2_bft2_regs[i]); in hpsa_enter_performant_mode()
9345 writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); in hpsa_enter_performant_mode()
9347 dev_err(&h->pdev->dev, in hpsa_enter_performant_mode()
9348 "performant mode problem - enabling ioaccel mode\n"); in hpsa_enter_performant_mode()
9349 return -ENODEV; in hpsa_enter_performant_mode()
9357 if (h->ioaccel_cmd_pool) { in hpsa_free_ioaccel1_cmd_and_bft()
9358 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel1_cmd_and_bft()
9359 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_free_ioaccel1_cmd_and_bft()
9360 h->ioaccel_cmd_pool, in hpsa_free_ioaccel1_cmd_and_bft()
9361 h->ioaccel_cmd_pool_dhandle); in hpsa_free_ioaccel1_cmd_and_bft()
9362 h->ioaccel_cmd_pool = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9363 h->ioaccel_cmd_pool_dhandle = 0; in hpsa_free_ioaccel1_cmd_and_bft()
9365 kfree(h->ioaccel1_blockFetchTable); in hpsa_free_ioaccel1_cmd_and_bft()
9366 h->ioaccel1_blockFetchTable = NULL; in hpsa_free_ioaccel1_cmd_and_bft()
9372 h->ioaccel_maxsg = in hpsa_alloc_ioaccel1_cmd_and_bft()
9373 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9374 if (h->ioaccel_maxsg > IOACCEL1_MAXSGENTRIES) in hpsa_alloc_ioaccel1_cmd_and_bft()
9375 h->ioaccel_maxsg = IOACCEL1_MAXSGENTRIES; in hpsa_alloc_ioaccel1_cmd_and_bft()
9377 /* Command structures must be aligned on a 128-byte boundary in hpsa_alloc_ioaccel1_cmd_and_bft()
9383 h->ioaccel_cmd_pool = in hpsa_alloc_ioaccel1_cmd_and_bft()
9384 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel1_cmd_and_bft()
9385 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool), in hpsa_alloc_ioaccel1_cmd_and_bft()
9386 &h->ioaccel_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel1_cmd_and_bft()
9388 h->ioaccel1_blockFetchTable = in hpsa_alloc_ioaccel1_cmd_and_bft()
9389 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel1_cmd_and_bft()
9392 if ((h->ioaccel_cmd_pool == NULL) || in hpsa_alloc_ioaccel1_cmd_and_bft()
9393 (h->ioaccel1_blockFetchTable == NULL)) in hpsa_alloc_ioaccel1_cmd_and_bft()
9396 memset(h->ioaccel_cmd_pool, 0, in hpsa_alloc_ioaccel1_cmd_and_bft()
9397 h->nr_cmds * sizeof(*h->ioaccel_cmd_pool)); in hpsa_alloc_ioaccel1_cmd_and_bft()
9402 return -ENOMEM; in hpsa_alloc_ioaccel1_cmd_and_bft()
9410 if (h->ioaccel2_cmd_pool) { in hpsa_free_ioaccel2_cmd_and_bft()
9411 dma_free_coherent(&h->pdev->dev, in hpsa_free_ioaccel2_cmd_and_bft()
9412 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_free_ioaccel2_cmd_and_bft()
9413 h->ioaccel2_cmd_pool, in hpsa_free_ioaccel2_cmd_and_bft()
9414 h->ioaccel2_cmd_pool_dhandle); in hpsa_free_ioaccel2_cmd_and_bft()
9415 h->ioaccel2_cmd_pool = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9416 h->ioaccel2_cmd_pool_dhandle = 0; in hpsa_free_ioaccel2_cmd_and_bft()
9418 kfree(h->ioaccel2_blockFetchTable); in hpsa_free_ioaccel2_cmd_and_bft()
9419 h->ioaccel2_blockFetchTable = NULL; in hpsa_free_ioaccel2_cmd_and_bft()
9429 h->ioaccel_maxsg = in hpsa_alloc_ioaccel2_cmd_and_bft()
9430 readl(&(h->cfgtable->io_accel_max_embedded_sg_count)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9431 if (h->ioaccel_maxsg > IOACCEL2_MAXSGENTRIES) in hpsa_alloc_ioaccel2_cmd_and_bft()
9432 h->ioaccel_maxsg = IOACCEL2_MAXSGENTRIES; in hpsa_alloc_ioaccel2_cmd_and_bft()
9436 h->ioaccel2_cmd_pool = in hpsa_alloc_ioaccel2_cmd_and_bft()
9437 dma_alloc_coherent(&h->pdev->dev, in hpsa_alloc_ioaccel2_cmd_and_bft()
9438 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool), in hpsa_alloc_ioaccel2_cmd_and_bft()
9439 &h->ioaccel2_cmd_pool_dhandle, GFP_KERNEL); in hpsa_alloc_ioaccel2_cmd_and_bft()
9441 h->ioaccel2_blockFetchTable = in hpsa_alloc_ioaccel2_cmd_and_bft()
9442 kmalloc(((h->ioaccel_maxsg + 1) * in hpsa_alloc_ioaccel2_cmd_and_bft()
9445 if ((h->ioaccel2_cmd_pool == NULL) || in hpsa_alloc_ioaccel2_cmd_and_bft()
9446 (h->ioaccel2_blockFetchTable == NULL)) { in hpsa_alloc_ioaccel2_cmd_and_bft()
9447 rc = -ENOMEM; in hpsa_alloc_ioaccel2_cmd_and_bft()
9455 memset(h->ioaccel2_cmd_pool, 0, in hpsa_alloc_ioaccel2_cmd_and_bft()
9456 h->nr_cmds * sizeof(*h->ioaccel2_cmd_pool)); in hpsa_alloc_ioaccel2_cmd_and_bft()
9467 kfree(h->blockFetchTable); in hpsa_free_performant_mode()
9468 h->blockFetchTable = NULL; in hpsa_free_performant_mode()
9474 /* return -ENODEV on error, 0 on success (or no action)
9485 trans_support = readl(&(h->cfgtable->TransportSupport)); in hpsa_put_ctlr_into_performant_mode()
9500 h->nreply_queues = h->msix_vectors > 0 ? h->msix_vectors : 1; in hpsa_put_ctlr_into_performant_mode()
9503 h->reply_queue_size = h->max_commands * sizeof(u64); in hpsa_put_ctlr_into_performant_mode()
9505 for (i = 0; i < h->nreply_queues; i++) { in hpsa_put_ctlr_into_performant_mode()
9506 h->reply_queue[i].head = dma_alloc_coherent(&h->pdev->dev, in hpsa_put_ctlr_into_performant_mode()
9507 h->reply_queue_size, in hpsa_put_ctlr_into_performant_mode()
9508 &h->reply_queue[i].busaddr, in hpsa_put_ctlr_into_performant_mode()
9510 if (!h->reply_queue[i].head) { in hpsa_put_ctlr_into_performant_mode()
9511 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9514 h->reply_queue[i].size = h->max_commands; in hpsa_put_ctlr_into_performant_mode()
9515 h->reply_queue[i].wraparound = 1; /* spec: init to 1 */ in hpsa_put_ctlr_into_performant_mode()
9516 h->reply_queue[i].current_entry = 0; in hpsa_put_ctlr_into_performant_mode()
9520 h->blockFetchTable = kmalloc(((SG_ENTRIES_IN_CMD + 1) * in hpsa_put_ctlr_into_performant_mode()
9522 if (!h->blockFetchTable) { in hpsa_put_ctlr_into_performant_mode()
9523 rc = -ENOMEM; in hpsa_put_ctlr_into_performant_mode()
9533 kfree(h->blockFetchTable); in hpsa_put_ctlr_into_performant_mode()
9534 h->blockFetchTable = NULL; in hpsa_put_ctlr_into_performant_mode()
9544 return c->cmd_type == CMD_IOACCEL1 || c->cmd_type == CMD_IOACCEL2; in is_accelerated_cmd()
9555 for (i = 0; i < h->nr_cmds; i++) { in hpsa_drain_accel_commands()
9556 c = h->cmd_pool + i; in hpsa_drain_accel_commands()
9557 refcount = atomic_inc_return(&c->refcount); in hpsa_drain_accel_commands()
9578 phy = sas_phy_alloc(hpsa_sas_port->parent_node->parent_dev, in hpsa_alloc_sas_phy()
9579 hpsa_sas_port->next_phy_index); in hpsa_alloc_sas_phy()
9585 hpsa_sas_port->next_phy_index++; in hpsa_alloc_sas_phy()
9586 hpsa_sas_phy->phy = phy; in hpsa_alloc_sas_phy()
9587 hpsa_sas_phy->parent_port = hpsa_sas_port; in hpsa_alloc_sas_phy()
9594 struct sas_phy *phy = hpsa_sas_phy->phy; in hpsa_free_sas_phy()
9596 sas_port_delete_phy(hpsa_sas_phy->parent_port->port, phy); in hpsa_free_sas_phy()
9597 if (hpsa_sas_phy->added_to_port) in hpsa_free_sas_phy()
9598 list_del(&hpsa_sas_phy->phy_list_entry); in hpsa_free_sas_phy()
9610 hpsa_sas_port = hpsa_sas_phy->parent_port; in hpsa_sas_port_add_phy()
9611 phy = hpsa_sas_phy->phy; in hpsa_sas_port_add_phy()
9613 identify = &phy->identify; in hpsa_sas_port_add_phy()
9615 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_phy()
9616 identify->device_type = SAS_END_DEVICE; in hpsa_sas_port_add_phy()
9617 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9618 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_phy()
9619 phy->minimum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9620 phy->maximum_linkrate_hw = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9621 phy->minimum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9622 phy->maximum_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9623 phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in hpsa_sas_port_add_phy()
9625 rc = sas_phy_add(hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9629 sas_port_add_phy(hpsa_sas_port->port, hpsa_sas_phy->phy); in hpsa_sas_port_add_phy()
9630 list_add_tail(&hpsa_sas_phy->phy_list_entry, in hpsa_sas_port_add_phy()
9631 &hpsa_sas_port->phy_list_head); in hpsa_sas_port_add_phy()
9632 hpsa_sas_phy->added_to_port = true; in hpsa_sas_port_add_phy()
9643 identify = &rphy->identify; in hpsa_sas_port_add_rphy()
9644 identify->sas_address = hpsa_sas_port->sas_address; in hpsa_sas_port_add_rphy()
9645 identify->initiator_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9646 identify->target_port_protocols = SAS_PROTOCOL_STP; in hpsa_sas_port_add_rphy()
9663 INIT_LIST_HEAD(&hpsa_sas_port->phy_list_head); in hpsa_alloc_sas_port()
9664 hpsa_sas_port->parent_node = hpsa_sas_node; in hpsa_alloc_sas_port()
9666 port = sas_port_alloc_num(hpsa_sas_node->parent_dev); in hpsa_alloc_sas_port()
9674 hpsa_sas_port->port = port; in hpsa_alloc_sas_port()
9675 hpsa_sas_port->sas_address = sas_address; in hpsa_alloc_sas_port()
9676 list_add_tail(&hpsa_sas_port->port_list_entry, in hpsa_alloc_sas_port()
9677 &hpsa_sas_node->port_list_head); in hpsa_alloc_sas_port()
9695 &hpsa_sas_port->phy_list_head, phy_list_entry) in hpsa_free_sas_port()
9698 sas_port_delete(hpsa_sas_port->port); in hpsa_free_sas_port()
9699 list_del(&hpsa_sas_port->port_list_entry); in hpsa_free_sas_port()
9709 hpsa_sas_node->parent_dev = parent_dev; in hpsa_alloc_sas_node()
9710 INIT_LIST_HEAD(&hpsa_sas_node->port_list_head); in hpsa_alloc_sas_node()
9725 &hpsa_sas_node->port_list_head, port_list_entry) in hpsa_free_sas_node()
9738 for (i = 0; i < h->ndevices; i++) { in hpsa_find_device_by_sas_rphy()
9739 device = h->dev[i]; in hpsa_find_device_by_sas_rphy()
9740 if (!device->sas_port) in hpsa_find_device_by_sas_rphy()
9742 if (device->sas_port->rphy == rphy) in hpsa_find_device_by_sas_rphy()
9757 parent_dev = &h->scsi_host->shost_dev; in hpsa_add_sas_host()
9761 return -ENOMEM; in hpsa_add_sas_host()
9763 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, h->sas_address); in hpsa_add_sas_host()
9765 rc = -ENODEV; in hpsa_add_sas_host()
9771 rc = -ENODEV; in hpsa_add_sas_host()
9779 h->sas_host = hpsa_sas_node; in hpsa_add_sas_host()
9784 sas_phy_free(hpsa_sas_phy->phy); in hpsa_add_sas_host()
9796 hpsa_free_sas_node(h->sas_host); in hpsa_delete_sas_host()
9806 hpsa_sas_port = hpsa_alloc_sas_port(hpsa_sas_node, device->sas_address); in hpsa_add_sas_device()
9808 return -ENOMEM; in hpsa_add_sas_device()
9810 rphy = sas_end_device_alloc(hpsa_sas_port->port); in hpsa_add_sas_device()
9812 rc = -ENODEV; in hpsa_add_sas_device()
9816 hpsa_sas_port->rphy = rphy; in hpsa_add_sas_device()
9817 device->sas_port = hpsa_sas_port; in hpsa_add_sas_device()
9829 device->sas_port = NULL; in hpsa_add_sas_device()
9836 if (device->sas_port) { in hpsa_remove_sas_device()
9837 hpsa_free_sas_port(device->sas_port); in hpsa_remove_sas_device()
9838 device->sas_port = NULL; in hpsa_remove_sas_device()
9856 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9861 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9865 return -ENXIO; in hpsa_sas_get_enclosure_identifier()
9867 *identifier = sd->eli; in hpsa_sas_get_enclosure_identifier()
9875 return -ENXIO; in hpsa_sas_get_bay_identifier()
9904 return -EINVAL; in hpsa_sas_phy_speed()
9929 return -ENODEV; in hpsa_init()