44 #include <linux/module.h>
45 #include <linux/kernel.h>
47 #include <linux/errno.h>
49 #include <linux/sched.h>
52 #include <linux/pci.h>
56 #include <linux/slab.h>
65 #define RAID_CHANNEL 1
81 static u8 scsi_io_cb_idx = -1;
82 static u8 tm_cb_idx = -1;
83 static u8 ctl_cb_idx = -1;
84 static u8 base_cb_idx = -1;
85 static u8 port_enable_cb_idx = -1;
86 static u8 transport_cb_idx = -1;
87 static u8 scsih_cb_idx = -1;
88 static u8 config_cb_idx = -1;
91 static u8 tm_tr_cb_idx = -1 ;
92 static u8 tm_tr_volume_cb_idx = -1 ;
93 static u8 tm_sas_control_cb_idx = -1;
96 static u32 logging_level;
97 MODULE_PARM_DESC(logging_level,
" bits for enabling additional logging info "
100 static ushort max_sectors = 0xFFFF;
102 MODULE_PARM_DESC(max_sectors,
"max sectors, range 64 to 32767 default=32767");
105 #define MPT2SAS_MAX_LUN (16895)
117 static int diag_buffer_enable = -1;
120 "(TRACE=1/SNAPSHOT=2/EXTENDED=4/default=0)");
122 static int disable_discovery = -1;
127 static int prot_mask = 0;
144 #define MPT2SAS_TURN_ON_FAULT_LED (0xFFFC)
145 #define MPT2SAS_PORT_ENABLE_COMPLETE (0xFFFD)
146 #define MPT2SAS_REMOVE_UNRESPONDING_DEVICES (0xFFFF)
294 &logging_level, 0644);
304 _scsih_srch_boot_sas_address(
u64 sas_address,
307 return (sas_address ==
le64_to_cpu(boot_device->SASAddress)) ? 1 : 0;
336 return (enclosure_logical_id ==
le64_to_cpu(boot_device->
337 EnclosureLogicalID) && slot_number ==
le16_to_cpu(boot_device->
338 SlotNumber)) ? 1 : 0;
353 _scsih_is_boot_device(
u64 sas_address,
u64 device_name,
363 rc = _scsih_srch_boot_sas_address(
364 sas_address, &boot_device->
SasWwid);
367 if (!enclosure_logical_id)
369 rc = _scsih_srch_boot_encl_slot(
370 enclosure_logical_id,
376 rc = _scsih_srch_boot_device_name(
403 *sas_address = ioc->
sas_hba.sas_address;
410 __FILE__, __LINE__, __func__);
425 "failure at %s:%d/%s()!\n", ioc->
name, handle, ioc_status,
426 __FILE__, __LINE__, __func__);
451 u64 enclosure_logical_id;
467 slot = sas_device->
slot;
469 raid_device = device;
470 sas_address = raid_device->
wwid;
472 enclosure_logical_id = 0;
477 if (_scsih_is_boot_device(sas_address, device_name,
478 enclosure_logical_id, slot,
483 "%s: req_boot_device(0x%016llx)\n",
485 (
unsigned long long)sas_address));
492 if (_scsih_is_boot_device(sas_address, device_name,
493 enclosure_logical_id, slot,
498 "%s: req_alt_boot_device(0x%016llx)\n",
500 (
unsigned long long)sas_address));
507 if (_scsih_is_boot_device(sas_address, device_name,
508 enclosure_logical_id, slot,
513 "%s: current_boot_device(0x%016llx)\n",
515 (
unsigned long long)sas_address));
563 if (sas_device->handle == handle)
567 if (sas_device->handle == handle)
593 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
612 "(0x%04x), sas_addr(0x%016llx)\n", ioc->
name, __func__,
621 _scsih_sas_device_remove(ioc, sas_device);
622 }
else if (!sas_device->
starget) {
631 _scsih_sas_device_remove(ioc, sas_device);
650 "(0x%04x), sas_addr(0x%016llx)\n", ioc->
name, __func__,
655 _scsih_determine_boot_device(ioc, sas_device, 0);
676 if (raid_device->
id ==
id && raid_device->
channel == channel) {
702 if (raid_device->
handle != handle)
728 if (raid_device->
wwid != wwid)
752 "(0x%04x), wwid(0x%016llx)\n", ioc->
name, __func__,
753 raid_device->
handle, (
unsigned long long)raid_device->
wwid));
794 if (sas_expander->
handle != handle)
958 ioc->
scsi_lookup[i].scmd->device->channel == channel)) {
981 unsigned int lun,
int channel)
992 ioc->
scsi_lookup[i].scmd->device->channel == channel &&
1014 unsigned long flags;
1020 "available\n", ioc->
name));
1051 void *sg_local, *
chain;
1056 u32 sges_in_segment;
1058 u32 sgl_flags_last_element;
1059 u32 sgl_flags_end_buffer;
1075 sg_scmd = scsi_sglist(scmd);
1077 if (sges_left < 0) {
1079 " failed: request for %d bytes!\n", scsi_bufflen(scmd));
1083 sg_local = &mpi_request->
SGL;
1085 if (sges_left <= sges_in_segment)
1086 goto fill_in_last_segment;
1089 (sges_in_segment * ioc->
sge_size))/4;
1092 while (sges_in_segment) {
1093 if (sges_in_segment == 1)
1095 sgl_flags_last_element |
sg_dma_len(sg_scmd),
1108 chain_req = _scsih_get_chain_buffer_tracker(ioc, smid);
1114 sges_in_segment = (sges_left <=
1117 chain_offset = (sges_left == sges_in_segment) ?
1118 0 : (sges_in_segment * ioc->
sge_size)/4;
1119 chain_length = sges_in_segment * ioc->
sge_size;
1121 chain_offset = chain_offset <<
1126 chain_length, chain_dma);
1129 goto fill_in_last_segment;
1132 while (sges_in_segment) {
1133 if (sges_in_segment == 1)
1135 sgl_flags_last_element |
1148 chain_req = _scsih_get_chain_buffer_tracker(ioc, smid);
1156 fill_in_last_segment:
1183 _scsih_adjust_queue_depth(
struct scsi_device *sdev,
int qdepth)
1191 unsigned long flags;
1196 sas_device_priv_data = sdev->
hostdata;
1197 if (!sas_device_priv_data)
1199 sas_target_priv_data = sas_device_priv_data->
sas_target;
1200 if (!sas_target_priv_data)
1206 sas_device_priv_data->
sas_target->sas_address);
1216 if (qdepth > max_depth)
1234 _scsih_adjust_queue_depth(sdev, qdepth);
1242 "simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n",
1261 scsi_set_tag_type(sdev, tag_type);
1287 unsigned long flags;
1291 if (!sas_target_priv_data)
1294 starget->
hostdata = sas_target_priv_data;
1295 sas_target_priv_data->
starget = starget;
1301 raid_device = _scsih_raid_device_find_by_id(ioc, starget->
id,
1309 raid_device->
starget = starget;
1324 sas_device->
starget = starget;
1325 sas_device->
id = starget->
id;
1328 sas_target_priv_data->
flags |=
1343 _scsih_target_destroy(
struct scsi_target *starget)
1350 unsigned long flags;
1353 sas_target_priv_data = starget->
hostdata;
1354 if (!sas_target_priv_data)
1359 raid_device = _scsih_raid_device_find_by_id(ioc, starget->
id,
1373 if (sas_device && (sas_device->
starget == starget) &&
1374 (sas_device->
id == starget->
id) &&
1381 kfree(sas_target_priv_data);
1401 unsigned long flags;
1404 if (!sas_device_priv_data)
1407 sas_device_priv_data->
lun = sdev->
lun;
1411 sas_target_priv_data = starget->
hostdata;
1413 sas_device_priv_data->
sas_target = sas_target_priv_data;
1414 sdev->
hostdata = sas_device_priv_data;
1418 shost = dev_to_shost(&starget->
dev);
1419 ioc = shost_priv(shost);
1422 raid_device = _scsih_raid_device_find_by_id(ioc,
1446 unsigned long flags;
1452 sas_target_priv_data = starget->
hostdata;
1455 shost = dev_to_shost(&starget->
dev);
1456 ioc = shost_priv(shost);
1462 if (sas_device && !sas_target_priv_data->
num_luns)
1490 ioc->
name, __FILE__, __LINE__, __func__);
1498 ioc->
name, __FILE__, __LINE__, __func__);
1506 "atapi(%s), ncq(%s), asyn_notify(%s), smart(%s), fua(%s), "
1507 "sw_preserve(%s)\n",
1522 _scsih_is_raid(
struct device *
dev)
1537 _scsih_get_resync(
struct device *dev)
1542 unsigned long flags;
1545 u32 volume_status_flags;
1549 percent_complete = 0;
1555 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->
id,
1558 handle = raid_device->
handle;
1570 ioc->
name, __FILE__, __LINE__, __func__);
1571 percent_complete = 0;
1576 if (!(volume_status_flags &
1578 percent_complete = 0;
1581 raid_set_resync(mpt2sas_raid_template, dev, percent_complete);
1589 _scsih_get_state(
struct device *dev)
1594 unsigned long flags;
1602 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->
id,
1605 handle = raid_device->
handle;
1615 ioc->
name, __FILE__, __LINE__, __func__);
1639 raid_set_state(mpt2sas_raid_template, dev, state);
1652 switch (volume_type) {
1667 raid_set_level(mpt2sas_raid_template, &sdev->sdev_gendev, level);
1689 &num_pds)) || !num_pds) {
1691 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__, __LINE__,
1702 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__, __LINE__,
1710 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__, __LINE__,
1747 unsigned long flags;
1758 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
1809 u8 stripe_exp, block_exp;
1817 "globally as drives are exposed\n", ioc->
name);
1820 if (_scsih_get_num_volumes(ioc) > 1) {
1821 _scsih_disable_ddio(ioc);
1823 "globally as number of drives > 1\n", ioc->
name);
1827 &num_pds)) || !num_pds) {
1829 "Failure in computing number of drives\n", ioc->
name);
1838 "Memory allocation failure for RVPG0\n", ioc->
name);
1845 "Failure in retrieving RVPG0\n", ioc->
name);
1856 "for the drive with handle(0x%04x): num_mem=%d, "
1857 "max_mem_allowed=%d\n", ioc->
name, raid_device->
handle,
1862 for (count = 0; count <
num_pds; count++) {
1869 "disabled for the drive with handle(0x%04x) member"
1870 "handle retrieval failed for member number=%d\n",
1877 if (dev_max_lba >> 32) {
1879 "disabled for the drive with handle(0x%04x) member"
1880 "handle (0x%04x) unsupported max lba 0x%016llx\n",
1883 (
unsigned long long)dev_max_lba);
1896 "for the drive with handle(0x%04x): type=%d, "
1897 "s_sz=%uK, blk_size=%u\n", ioc->
name,
1907 if (stripe_exp == 32) {
1909 "for the drive with handle(0x%04x) invalid stripe sz %uK\n",
1918 if (block_exp == 16) {
1920 "for the drive with handle(0x%04x) invalid block sz %u\n",
1929 " with handle(0x%04x)\n", ioc->
name, raid_device->
handle);
1944 for (count = 0; count <
num_pds; count++)
1992 unsigned long flags;
1998 u64 volume_wwid = 0;
2001 sas_device_priv_data = sdev->
hostdata;
2004 sas_target_priv_data = sas_device_priv_data->
sas_target;
2005 handle = sas_target_priv_data->
handle;
2011 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
2015 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__,
2016 __LINE__, __func__));
2020 if (_scsih_get_volume_capabilities(ioc, raid_device)) {
2022 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__,
2023 __LINE__, __func__));
2029 _scsih_init_warpdrive_properties(ioc, raid_device);
2037 MPI2_SAS_DEVICE_INFO_SSP_TARGET) {
2080 "wwid(0x%016llx), pd_count(%d), type(%s)\n",
2081 r_level, raid_device->
handle,
2082 (
unsigned long long)raid_device->
wwid,
2096 "failure at %s:%d/%s()!\n", ioc->
name,
2097 __FILE__, __LINE__, __func__));
2101 volume_handle, &volume_wwid)) {
2103 "failure at %s:%d/%s()!\n", ioc->
name,
2104 __FILE__, __LINE__, __func__));
2111 sas_device_priv_data->
sas_target->sas_address);
2115 "failure at %s:%d/%s()!\n", ioc->
name, __FILE__,
2116 __LINE__, __func__));
2121 if (sas_device->
device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) {
2127 if (sas_device->
device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET)
2134 "sas_addr(0x%016llx), phy(%d), device_name(0x%016llx)\n",
2140 "enclosure_logical_id(0x%016llx), slot(%d)\n", ds,
2146 _scsih_display_sata_capabilities(ioc, handle, sdev);
2153 _scsih_enable_tlr(ioc, sdev);
2190 if ((
ulong)capacity >= 0x200000) {
2218 switch (response_code) {
2220 desc =
"task management request completed";
2223 desc =
"invalid frame";
2226 desc =
"task management request not supported";
2229 desc =
"task management request failed";
2232 desc =
"task management request succeeded";
2235 desc =
"invalid lun";
2238 desc =
"overlapped tag attempted";
2241 desc =
"task queued, however not sent to target";
2248 ioc->
name, response_code, desc);
2271 if (ioc->
tm_cmds.smid != smid)
2302 sas_device_priv_data = sdev->
hostdata;
2303 if (!sas_device_priv_data)
2305 if (sas_device_priv_data->
sas_target->handle == handle) {
2306 sas_device_priv_data->
sas_target->tm_busy = 1;
2330 sas_device_priv_data = sdev->
hostdata;
2331 if (!sas_device_priv_data)
2333 if (sas_device_priv_data->
sas_target->handle == handle) {
2334 sas_device_priv_data->
sas_target->tm_busy = 0;
2371 unsigned long timeleft;
2379 __func__, ioc->
name);
2387 __func__, ioc->
name);
2395 "active!\n", ioc->
name));
2414 ioc->
name, __func__);
2423 " task_type(0x%02x), smid(%d)\n", ioc->
name, handle, type,
2436 init_completion(&ioc->
tm_cmds.done);
2441 ioc->
name, __func__);
2455 mpi_reply = ioc->
tm_cmds.reply;
2457 "ioc_status(0x%04x), loginfo(0x%08x), term_count(0x%08x)\n",
2472 if (scsi_lookup->
scmd == NULL)
2478 if (_scsih_scsi_lookup_find_by_target(ioc,
id, channel))
2486 if (_scsih_scsi_lookup_find_by_lun(ioc,
id, lun, channel))
2525 unsigned long flags;
2526 char *device_str =
NULL;
2531 device_str =
"WarpDrive";
2533 device_str =
"volume";
2538 "%s wwid(0x%016llx)\n", device_str, priv_target->
handle,
2539 device_str, (
unsigned long long)priv_target->
sas_address);
2545 if (priv_target->
flags &
2548 "volume handle(0x%04x), "
2549 "volume wwid(0x%016llx)\n",
2554 "handle(0x%04x), sas_address(0x%016llx), phy(%d)\n",
2559 "enclosure_logical_id(0x%016llx), slot(%d)\n",
2583 "scmd(%p)\n", scmd);
2584 _scsih_tm_display_info(ioc, scmd);
2586 sas_device_priv_data = scmd->
device->hostdata;
2587 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target) {
2589 "scmd(%p)\n", scmd);
2597 smid = _scsih_scsi_lookup_find_by_scmd(ioc, scmd);
2605 if (sas_device_priv_data->
sas_target->flags &
2615 handle = sas_device_priv_data->
sas_target->handle;
2623 ((r ==
SUCCESS) ?
"SUCCESS" :
"FAILED"), scmd);
2634 _scsih_dev_reset(
struct scsi_cmnd *scmd)
2639 unsigned long flags;
2646 "scmd(%p)\n", scmd);
2647 _scsih_tm_display_info(ioc, scmd);
2649 sas_device_priv_data = scmd->
device->hostdata;
2650 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target) {
2652 "scmd(%p)\n", scmd);
2661 if (sas_device_priv_data->
sas_target->flags &
2664 sas_device = _scsih_sas_device_find_by_handle(ioc,
2670 handle = sas_device_priv_data->
sas_target->handle;
2685 ((r ==
SUCCESS) ?
"SUCCESS" :
"FAILED"), scmd);
2696 _scsih_target_reset(
struct scsi_cmnd *scmd)
2701 unsigned long flags;
2707 "scmd(%p)\n", scmd);
2708 _scsih_tm_display_info(ioc, scmd);
2710 sas_device_priv_data = scmd->
device->hostdata;
2711 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target) {
2713 "scmd(%p)\n", scmd);
2722 if (sas_device_priv_data->
sas_target->flags &
2725 sas_device = _scsih_sas_device_find_by_handle(ioc,
2731 handle = sas_device_priv_data->
sas_target->handle;
2745 ((r ==
SUCCESS) ?
"SUCCESS" :
"FAILED"), scmd);
2756 _scsih_host_reset(
struct scsi_cmnd *scmd)
2769 ioc->
name, ((r ==
SUCCESS) ?
"SUCCESS" :
"FAILED"), scmd);
2788 unsigned long flags;
2815 unsigned long flags;
2845 _scsih_fw_event_add(ioc, fw_event);
2864 _scsih_fw_event_add(ioc, fw_event);
2887 _scsih_fw_event_free(ioc, fw_event);
2907 sas_device_priv_data = sdev->
hostdata;
2908 if (!sas_device_priv_data)
2910 if (!sas_device_priv_data->
block)
2912 sas_device_priv_data->
block = 0;
2933 sas_device_priv_data = sdev->
hostdata;
2934 if (!sas_device_priv_data)
2936 if (!sas_device_priv_data->
block)
2938 if (sas_device_priv_data->
sas_target->sas_address ==
2942 "sas address(0x%016llx)\n", ioc->
name,
2943 (
unsigned long long)sas_address));
2944 sas_device_priv_data->
block = 0;
2964 sas_device_priv_data = sdev->
hostdata;
2965 if (!sas_device_priv_data)
2967 if (sas_device_priv_data->
block)
2969 sas_device_priv_data->
block = 1;
2992 sas_device_priv_data = sdev->
hostdata;
2993 if (!sas_device_priv_data)
2995 if (sas_device_priv_data->
block)
2997 if (sas_device_priv_data->
sas_target->handle == handle) {
3000 "handle(0x%04x)\n", ioc->
name, handle));
3001 sas_device_priv_data->
block = 1;
3017 _scsih_block_io_to_children_attached_to_ex(
struct MPT2SAS_ADAPTER *ioc,
3023 unsigned long flags;
3053 _scsih_block_io_to_children_attached_to_ex(ioc,
3068 _scsih_block_io_to_children_attached_directly(
struct MPT2SAS_ADAPTER *ioc,
3076 for (i = 0; i < event_data->
NumEntries; i++) {
3084 _scsih_block_io_device(ioc, handle);
3110 u64 sas_address = 0;
3111 unsigned long flags;
3117 "removed: handle(0x%04x)\n", __func__, ioc->
name, handle));
3121 "error recovery: handle(0x%04x)\n", __func__, ioc->
name,
3128 "operational: handle(0x%04x)\n", __func__, ioc->
name,
3138 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
3139 if (sas_device && sas_device->
starget &&
3140 sas_device->
starget->hostdata) {
3141 sas_target_priv_data = sas_device->
starget->hostdata;
3142 sas_target_priv_data->
deleted = 1;
3147 if (sas_target_priv_data) {
3149 "handle(0x%04x), sas_addr(0x%016llx)\n", ioc->
name, handle,
3150 (
unsigned long long)sas_address));
3151 _scsih_ublock_io_device(ioc, sas_address);
3157 delayed_tr = kzalloc(
sizeof(*delayed_tr),
GFP_ATOMIC);
3160 INIT_LIST_HEAD(&delayed_tr->
list);
3164 "DELAYED:tr:handle(0x%04x), (open)\n",
3165 ioc->
name, handle));
3170 "(open), smid(%d), cb(%d)\n", ioc->
name, handle, smid,
3199 u8 msix_index,
u32 reply)
3205 "sc_complete:handle(0x%04x), (open) "
3206 "smid(%d), ioc_status(0x%04x), loginfo(0x%08x)\n",
3212 ioc->
name, __FILE__, __LINE__, __func__);
3237 "progress!\n", __func__, ioc->
name));
3243 delayed_tr = kzalloc(
sizeof(*delayed_tr),
GFP_ATOMIC);
3246 INIT_LIST_HEAD(&delayed_tr->
list);
3250 "DELAYED:tr:handle(0x%04x), (open)\n",
3251 ioc->
name, handle));
3256 "(open), smid(%d), cb(%d)\n", ioc->
name, handle, smid,
3279 u8 msix_index,
u32 reply)
3289 "progress!\n", __func__, ioc->
name));
3294 ioc->
name, __FILE__, __LINE__, __func__);
3301 "handle(0x%04x:0x%04x), smid(%d)!!!\n", handle,
3307 "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), "
3308 "loginfo(0x%08x), completed(%d)\n", ioc->
name,
3313 return _scsih_check_for_pending_tm(ioc, smid);
3346 "removed\n", __func__, ioc->
name));
3350 "error recovery\n", __func__, ioc->
name));
3356 "operational\n", __func__, ioc->
name));
3361 ioc->
name, __FILE__, __LINE__, __func__);
3368 "handle(0x%04x:0x%04x), smid(%d)!!!\n", ioc->
name, handle,
3374 "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), "
3375 "loginfo(0x%08x), completed(%d)\n", ioc->
name,
3381 if (!smid_sas_ctrl) {
3383 ioc->
name, __func__);
3388 "(open), smid(%d), cb(%d)\n", ioc->
name, handle, smid_sas_ctrl,
3397 return _scsih_check_for_pending_tm(ioc, smid);
3420 _scsih_tm_tr_volume_send(ioc, delayed_tr->
handle);
3430 _scsih_tm_tr_send(ioc, delayed_tr->
handle);
3458 u16 expander_handle;
3460 unsigned long flags;
3464 for (i = 0 ; i < event_data->
NumEntries; i++) {
3471 _scsih_tm_tr_send(ioc, handle);
3475 if (expander_handle < ioc->sas_hba.num_phys) {
3476 _scsih_block_io_to_children_attached_directly(ioc, event_data);
3485 _scsih_block_io_to_children_attached_to_ex(ioc, sas_expander);
3489 ioc->
facts.MaxDevHandle);
3491 _scsih_block_io_device(ioc, handle);
3494 _scsih_block_io_to_children_attached_directly(ioc, event_data);
3513 "setting ignoring flag\n", ioc->
name));
3534 unsigned long flags;
3537 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
3538 if (raid_device && raid_device->
starget &&
3539 raid_device->
starget->hostdata) {
3540 sas_target_priv_data =
3541 raid_device->
starget->hostdata;
3542 sas_target_priv_data->
deleted = 1;
3544 "setting delete flag: handle(0x%04x), "
3545 "wwid(0x%016llx)\n", ioc->
name, handle,
3546 (
unsigned long long) raid_device->
wwid));
3562 _scsih_set_volume_handle_for_tr(
u16 handle,
u16 *
a,
u16 *
b)
3564 if (!handle || handle == *a || handle == *b)
3609 _scsih_set_volume_delete_flag(ioc, volume_handle);
3610 _scsih_set_volume_handle_for_tr(volume_handle, &a, &b);
3622 _scsih_set_volume_handle_for_tr(volume_handle, &a, &b);
3627 _scsih_tm_tr_volume_send(ioc, a);
3629 _scsih_tm_tr_volume_send(ioc, b);
3640 _scsih_tm_tr_send(ioc, handle);
3641 else if (volume_handle == a || volume_handle == b) {
3642 delayed_tr = kzalloc(
sizeof(*delayed_tr),
GFP_ATOMIC);
3644 INIT_LIST_HEAD(&delayed_tr->
list);
3648 "DELAYED:tr:handle(0x%04x), (open)\n", ioc->
name,
3651 _scsih_tm_tr_send(ioc, handle);
3679 _scsih_set_volume_delete_flag(ioc,
3700 scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
3729 unsigned char prot_op = scsi_get_prot_op(scmd);
3730 unsigned char prot_type = scsi_get_prot_type(scmd);
3742 switch (prot_type) {
3753 mpi_request->
CDB.
EEDP32.PrimaryReferenceTag =
3777 _scsih_eedp_error_handling(
struct scsi_cmnd *scmd,
u16 ioc_status)
3781 switch (ioc_status) {
3845 u32 stripe_sz, stripe_exp;
3846 u8 num_pds, *cdb_ptr,
i;
3857 if ((cdb0 <
READ_16) || !(cdb_ptr[2] | cdb_ptr[3] | cdb_ptr[4]
3859 io_size = scsi_bufflen(scmd) >>
3865 if (((
u64)v_lba + (
u64)io_size - 1) <=
3869 stripe_off = v_lba & (stripe_sz - 1);
3872 if ((stripe_off + io_size) <= stripe_sz) {
3873 num_pds = raid_device->
num_pds;
3874 p_lba = v_lba >> stripe_exp;
3875 stripe_unit = p_lba / num_pds;
3876 column = p_lba % num_pds;
3877 p_lba = (stripe_unit << stripe_exp) +
3882 (*(
__be32 *)(&cdb_ptr[i])) =
3887 _scsih_scsi_direct_io_set(ioc, smid, 1);
3891 io_size = scsi_bufflen(scmd) >>
3896 if ((v_llba + (
u64)io_size - 1) <=
3900 stripe_off = (
u32) (v_llba & (stripe_sz - 1));
3903 if ((stripe_off + io_size) <= stripe_sz) {
3904 num_pds = raid_device->
num_pds;
3905 p_lba = (
u32)(v_llba >> stripe_exp);
3906 stripe_unit = p_lba / num_pds;
3907 column = p_lba % num_pds;
3908 p_lba = (stripe_unit << stripe_exp) +
3913 (*(
__be64 *)(&cdb_ptr[2])) =
3918 _scsih_scsi_direct_io_set(ioc, smid, 1);
3948 sas_device_priv_data = scmd->
device->hostdata;
3949 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target) {
3961 sas_target_priv_data = sas_device_priv_data->
sas_target;
3973 else if (sas_device_priv_data->
block || sas_target_priv_data->
tm_busy)
3976 else if (sas_target_priv_data->
deleted) {
3991 if (scmd->
device->tagged_supported) {
3992 if (scmd->
device->ordered_tags)
4000 mpi_control |= (0x500);
4014 ioc->
name, __func__);
4019 _scsih_setup_eedp(scmd, mpi_request);
4023 if (sas_device_priv_data->
sas_target->flags &
4040 mpi_request->
VF_ID = 0;
4041 mpi_request->
VP_ID = 0;
4049 if (_scsih_build_scatter_gather(ioc, scmd, smid)) {
4057 _scsih_setup_direct_io(ioc, scmd, raid_device, mpi_request,
4083 if ((sense_buffer[0] & 0x7F) >= 0x72) {
4085 data->skey = sense_buffer[1] & 0x0F;
4086 data->asc = sense_buffer[2];
4087 data->ascq = sense_buffer[3];
4090 data->skey = sense_buffer[2] & 0x0F;
4091 data->asc = sense_buffer[12];
4092 data->ascq = sense_buffer[13];
4096 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4119 char *desc_ioc_state =
NULL;
4120 char *desc_scsi_status =
NULL;
4124 unsigned long flags;
4127 char *device_str =
NULL;
4133 device_str =
"WarpDrive";
4135 device_str =
"volume";
4137 if (log_info == 0x31170000)
4140 switch (ioc_status) {
4142 desc_ioc_state =
"success";
4145 desc_ioc_state =
"invalid function";
4148 desc_ioc_state =
"scsi recovered error";
4151 desc_ioc_state =
"scsi invalid dev handle";
4154 desc_ioc_state =
"scsi device not there";
4157 desc_ioc_state =
"scsi data overrun";
4160 desc_ioc_state =
"scsi data underrun";
4163 desc_ioc_state =
"scsi io data error";
4166 desc_ioc_state =
"scsi protocol error";
4169 desc_ioc_state =
"scsi task terminated";
4172 desc_ioc_state =
"scsi residual mismatch";
4175 desc_ioc_state =
"scsi task mgmt failed";
4178 desc_ioc_state =
"scsi ioc terminated";
4181 desc_ioc_state =
"scsi ext terminated";
4184 desc_ioc_state =
"eedp guard error";
4187 desc_ioc_state =
"eedp ref tag error";
4190 desc_ioc_state =
"eedp app tag error";
4193 desc_ioc_state =
"unknown";
4197 switch (scsi_status) {
4199 desc_scsi_status =
"good";
4202 desc_scsi_status =
"check condition";
4205 desc_scsi_status =
"condition met";
4208 desc_scsi_status =
"busy";
4211 desc_scsi_status =
"intermediate";
4214 desc_scsi_status =
"intermediate condmet";
4217 desc_scsi_status =
"reservation conflict";
4220 desc_scsi_status =
"command terminated";
4223 desc_scsi_status =
"task set full";
4226 desc_scsi_status =
"aca active";
4229 desc_scsi_status =
"task aborted";
4232 desc_scsi_status =
"unknown";
4236 desc_scsi_state[0] =
'\0';
4238 desc_scsi_state =
" ";
4240 strcat(desc_scsi_state,
"response info ");
4242 strcat(desc_scsi_state,
"state terminated ");
4244 strcat(desc_scsi_state,
"no status ");
4246 strcat(desc_scsi_state,
"autosense failed ");
4248 strcat(desc_scsi_state,
"autosense valid ");
4254 device_str, (
unsigned long long)priv_target->
sas_address);
4264 "\tenclosure_logical_id(0x%016llx), slot(%d)\n",
4273 desc_ioc_state, ioc_status, smid);
4275 "resid(%d)\n", ioc->
name, scsi_bufflen(scmd), scmd->
underflow,
4276 scsi_get_resid(scmd));
4281 "scsi_state(%s)(0x%02x)\n", ioc->
name, desc_scsi_status,
4282 scsi_status, desc_scsi_state, scsi_state);
4284 if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
4288 "[0x%02x,0x%02x,0x%02x], count(%d)\n", ioc->
name, data.skey,
4292 if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
4294 response_bytes = (
u8 *)&response_info;
4295 _scsih_response_code(ioc, response_bytes[0]);
4322 &mpi_request)) != 0) {
4324 __FILE__, __LINE__, __func__);
4330 "ioc_status (0x%04x), loginfo(0x%08x)\n", ioc->
name,
4356 _scsih_fw_event_add(ioc, fw_event);
4376 unsigned long flags;
4380 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
4385 starget = sas_device->
starget;
4386 sas_target_priv_data = starget->
hostdata;
4397 _scsih_send_event_to_turn_on_fault_led(ioc, handle);
4405 ioc->
name, __FILE__, __LINE__, __func__);
4410 event_reply->
Event =
4418 event_data->
ASC = 0x5D;
4449 u32 response_code = 0;
4450 unsigned long flags;
4453 scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
4459 if (mpi_reply == NULL) {
4464 sas_device_priv_data = scmd->
device->hostdata;
4465 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target ||
4475 if (_scsih_scsi_direct_io_get(ioc, smid) &&
4480 _scsih_scsi_direct_io_set(ioc, smid, 0);
4493 if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
4510 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
4525 if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
4534 if (data.asc == 0x5D)
4535 _scsih_smart_predicted_fault(ioc,
4539 switch (ioc_status) {
4550 if (sas_device_priv_data->
block) {
4562 if ((xfer_cnt == 0) || (scmd->
underflow > xfer_cnt))
4571 if ((scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID))
4574 if (xfer_cnt < scmd->underflow) {
4579 }
else if (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED |
4580 MPI2_SCSI_STATE_NO_SCSI_STATUS))
4582 else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
4597 scsi_set_resid(scmd, 0);
4601 if (response_code ==
4603 (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED |
4604 MPI2_SCSI_STATE_NO_SCSI_STATUS)))
4606 else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
4613 _scsih_eedp_error_handling(scmd, ioc_status);
4629 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4631 _scsih_scsi_ioc_info(ioc , scmd, mpi_reply, smid);
4659 u16 attached_handle;
4663 "updating handles for sas_host(0x%016llx)\n",
4664 ioc->
name, (
unsigned long long)ioc->
sas_hba.sas_address));
4669 if (!sas_iounit_pg0) {
4671 ioc->
name, __FILE__, __LINE__, __func__);
4676 sas_iounit_pg0, sz)) != 0)
4681 for (i = 0; i < ioc->
sas_hba.num_phys ; i++) {
4685 PhyData[0].ControllerDevHandle);
4692 attached_handle, i, link_rate);
4695 kfree(sas_iounit_pg0);
4718 u16 device_missing_delay;
4723 ioc->
name, __FILE__, __LINE__, __func__);
4731 if (!sas_iounit_pg0) {
4733 ioc->
name, __FILE__, __LINE__, __func__);
4737 sas_iounit_pg0, sz))) {
4739 ioc->
name, __FILE__, __LINE__, __func__);
4746 ioc->
name, __FILE__, __LINE__, __func__);
4754 if (!sas_iounit_pg1) {
4756 ioc->
name, __FILE__, __LINE__, __func__);
4760 sas_iounit_pg1, sz))) {
4762 ioc->
name, __FILE__, __LINE__, __func__);
4769 ioc->
name, __FILE__, __LINE__, __func__);
4775 device_missing_delay =
4789 ioc->
name, __FILE__, __LINE__, __func__);
4792 for (i = 0; i < ioc->
sas_hba.num_phys ; i++) {
4796 ioc->
name, __FILE__, __LINE__, __func__);
4803 ioc->
name, __FILE__, __LINE__, __func__);
4809 PhyData[0].ControllerDevHandle);
4813 phy_pg0, ioc->
sas_hba.parent_dev);
4818 ioc->
name, __FILE__, __LINE__, __func__);
4821 ioc->
sas_hba.enclosure_handle =
4825 "sas_addr(0x%016llx), phys(%d)\n", ioc->
name, ioc->
sas_hba.handle,
4826 (
unsigned long long) ioc->
sas_hba.sas_address,
4829 if (ioc->
sas_hba.enclosure_handle) {
4833 ioc->
sas_hba.enclosure_handle))) {
4834 ioc->
sas_hba.enclosure_logical_id =
4840 kfree(sas_iounit_pg1);
4841 kfree(sas_iounit_pg0);
4865 unsigned long flags;
4878 ioc->
name, __FILE__, __LINE__, __func__);
4886 ioc->
name, __FILE__, __LINE__, __func__);
4892 if (_scsih_get_sas_address(ioc, parent_handle, &sas_address_parent)
4895 ioc->
name, __FILE__, __LINE__, __func__);
4898 if (sas_address_parent != ioc->
sas_hba.sas_address) {
4901 sas_address_parent);
4903 if (!sas_expander) {
4904 rc = _scsih_expander_add(ioc, parent_handle);
4919 sas_expander = kzalloc(
sizeof(
struct _sas_node),
4921 if (!sas_expander) {
4923 ioc->
name, __FILE__, __LINE__, __func__);
4933 " parent(0x%04x), sas_addr(0x%016llx), phys(%d)\n", ioc->
name,
4934 handle, parent_handle, (
unsigned long long)
4939 sas_expander->
phy = kcalloc(sas_expander->
num_phys,
4941 if (!sas_expander->
phy) {
4943 ioc->
name, __FILE__, __LINE__, __func__);
4950 sas_address_parent);
4951 if (!mpt2sas_port) {
4953 ioc->
name, __FILE__, __LINE__, __func__);
4959 for (i = 0 ; i < sas_expander->
num_phys ; i++) {
4961 &expander_pg1, i, handle))) {
4963 ioc->
name, __FILE__, __LINE__, __func__);
4968 sas_expander->
phy[
i].phy_id =
i;
4971 &sas_expander->
phy[i], expander_pg1,
4974 ioc->
name, __FILE__, __LINE__, __func__);
4989 _scsih_expander_node_add(ioc, sas_expander);
4996 sas_address_parent);
4997 kfree(sas_expander);
5046 unsigned long flags;
5058 _scsih_expander_node_remove(ioc, sas_expander);
5072 u16 handle,
u8 access_status)
5077 switch (access_status) {
5083 desc =
"sata capability failed";
5086 desc =
"sata affiliation conflict";
5089 desc =
"route not addressable";
5092 desc =
"smp error not addressable";
5095 desc =
"device blocked";
5109 desc =
"sata initialization failed";
5120 "handle(0x%04x)\n", ioc->
name, desc,
5121 (
unsigned long long)sas_address, handle);
5132 unsigned long flags;
5149 if (!(_scsih_is_end_device(device_info)))
5159 "handle(0x%04x), no sas_device!!!\n", ioc->
name, handle);
5165 starget = sas_device->
starget;
5166 sas_target_priv_data = starget->
hostdata;
5168 " to (0x%04x)!!!\n", sas_device->
handle, handle);
5177 "handle(0x%04x), flags!!!\n", ioc->
name, handle);
5183 if (_scsih_check_access_status(ioc, sas_address, handle,
5189 _scsih_ublock_io_device(ioc, sas_address);
5214 unsigned long flags;
5219 ioc->
name, __FILE__, __LINE__, __func__);
5227 ioc->
name, __FILE__, __LINE__, __func__);
5237 ioc->
name, __FILE__, __LINE__, __func__);
5244 if (_scsih_check_access_status(ioc, sas_address, handle,
5250 if (!(_scsih_is_end_device(device_info))) {
5252 ioc->
name, __FILE__, __LINE__, __func__);
5269 ioc->
name, __FILE__, __LINE__, __func__);
5278 ioc->
name, __FILE__, __LINE__, __func__);
5285 sas_device->
phy = sas_device_pg0.
PhyNum;
5298 _scsih_sas_device_init_add(ioc, sas_device);
5300 _scsih_sas_device_add(ioc, sas_device);
5319 "handle(0x%04x), sas_addr(0x%016llx)\n", ioc->
name, __func__,
5320 sas_device->
handle, (
unsigned long long)
5324 sas_target_priv_data = sas_device->
starget->hostdata;
5325 sas_target_priv_data->
deleted = 1;
5326 _scsih_ublock_io_device(ioc, sas_device->
sas_address);
5327 sas_target_priv_data->
handle =
5337 "(0x%016llx)\n", ioc->
name, sas_device->
handle,
5341 "handle(0x%04x), sas_addr(0x%016llx)\n", ioc->
name, __func__,
5342 sas_device->
handle, (
unsigned long long)
5357 unsigned long flags;
5363 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
5368 _scsih_remove_device(ioc, sas_device);
5383 unsigned long flags;
5395 _scsih_remove_device(ioc, sas_device);
5397 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5412 char *status_str =
NULL;
5420 status_str =
"remove";
5424 status_str =
"responding";
5427 status_str =
"remove delay";
5430 status_str =
"unknown status";
5434 ioc->
name, status_str);
5436 "start_phy(%02d), count(%d)\n",
5440 for (i = 0; i < event_data->
NumEntries; i++) {
5447 switch (reason_code) {
5449 status_str =
"target add";
5452 status_str =
"target remove";
5455 status_str =
"delay target remove";
5458 status_str =
"link rate change";
5461 status_str =
"target responding";
5464 status_str =
"unknown";
5470 " link rate: new(0x%02x), old(0x%02x)\n", phy_number,
5471 handle, status_str, link_rate, prev_link_rate);
5491 u8 phy_number, max_phys;
5494 unsigned long flags;
5498 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5500 _scsih_sas_topology_change_event_debug(ioc, event_data);
5507 _scsih_sas_host_add(ioc);
5509 _scsih_sas_host_refresh(ioc);
5513 "event\n", ioc->
name));
5521 if (_scsih_expander_add(ioc, parent_handle) != 0)
5530 }
else if (parent_handle < ioc->sas_hba.num_phys) {
5531 sas_address = ioc->
sas_hba.sas_address;
5532 max_phys = ioc->
sas_hba.num_phys;
5540 for (i = 0; i < event_data->
NumEntries; i++) {
5543 "expander event\n", ioc->
name));
5550 if (phy_number >= max_phys)
5563 switch (reason_code) {
5569 if (link_rate == prev_link_rate)
5573 handle, phy_number, link_rate);
5578 _scsih_check_device(ioc, handle);
5586 handle, phy_number, link_rate);
5588 _scsih_add_device(ioc, handle, phy_number, 0);
5592 _scsih_device_remove_by_handle(ioc, handle);
5604 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5613 _scsih_sas_device_status_change_event_debug(
struct MPT2SAS_ADAPTER *ioc,
5616 char *reason_str =
NULL;
5620 reason_str =
"smart data";
5623 reason_str =
"unsupported device discovered";
5626 reason_str =
"internal device reset";
5629 reason_str =
"internal task abort";
5632 reason_str =
"internal task abort set";
5635 reason_str =
"internal clear task set";
5638 reason_str =
"internal query task";
5641 reason_str =
"sata init failure";
5644 reason_str =
"internal device reset complete";
5647 reason_str =
"internal task abort complete";
5650 reason_str =
"internal async notification";
5653 reason_str =
"expander reduced functionality";
5656 reason_str =
"expander reduced functionality complete";
5659 reason_str =
"unknown reason";
5663 "\thandle(0x%04x), sas address(0x%016llx), tag(%d)",
5669 event_data->
ASC, event_data->
ASCQ);
5689 unsigned long flags;
5693 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5695 _scsih_sas_device_status_change_event_debug(ioc,
5702 if ((ioc->
facts.HeaderVersion >> 8) < 0xC)
5716 if (!sas_device || !sas_device->
starget) {
5721 target_priv_data = sas_device->
starget->hostdata;
5722 if (!target_priv_data) {
5729 target_priv_data->
tm_busy = 1;
5731 target_priv_data->
tm_busy = 0;
5735 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5745 _scsih_sas_enclosure_dev_status_change_event_debug(
struct MPT2SAS_ADAPTER *ioc,
5748 char *reason_str =
NULL;
5752 reason_str =
"enclosure add";
5755 reason_str =
"enclosure remove";
5758 reason_str =
"unknown reason";
5763 "\thandle(0x%04x), enclosure logical id(0x%016llx)"
5764 " number slots(%d)\n", ioc->
name, reason_str,
5780 _scsih_sas_enclosure_dev_status_change_event(
struct MPT2SAS_ADAPTER *ioc,
5783 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5785 _scsih_sas_enclosure_dev_status_change_event_debug(ioc,
5807 u32 termination_count;
5812 unsigned long flags;
5815 u8 task_abort_retries;
5819 "width(%d)\n", ioc->
name, __func__, event_data->
PhyNum,
5822 _scsih_block_io_all_device(ioc);
5825 mpi_reply = ioc->
tm_cmds.reply;
5826 broadcast_aen_retry:
5829 if (max_retries++ == 5) {
5831 ioc->
name, __func__));
5833 }
else if (max_retries > 1)
5835 ioc->
name, __func__, max_retries - 1));
5837 termination_count = 0;
5842 scmd = _scsih_scsi_lookup_get(ioc, smid);
5846 sas_device_priv_data = sdev->
hostdata;
5847 if (!sas_device_priv_data || !sas_device_priv_data->
sas_target)
5850 if (sas_device_priv_data->
sas_target->flags &
5854 if (sas_device_priv_data->
sas_target->flags &
5858 handle = sas_device_priv_data->
sas_target->handle;
5859 lun = sas_device_priv_data->
lun;
5871 "mpt2sas_scsih_issue_tm: FAILED when sending "
5872 "QUERY_TASK: scmd(%p)\n", scmd);
5874 goto broadcast_aen_retry;
5880 "with IOCSTATUS(0x%04x), scmd(%p)\n", ioc_status,
5883 goto broadcast_aen_retry;
5894 task_abort_retries = 0;
5896 if (task_abort_retries++ == 60) {
5898 "%s: ABORT_TASK: giving up\n", ioc->
name,
5901 goto broadcast_aen_retry;
5912 "mpt2sas_scsih_issue_tm: ABORT_TASK: FAILED : "
5913 "scmd(%p)\n", scmd);
5917 if (task_abort_retries > 1)
5919 "mpt2sas_scsih_issue_tm: ABORT_TASK: RETRIES (%d):"
5921 task_abort_retries - 1, scmd);
5929 " pending AEN\n", ioc->
name, __func__));
5931 goto broadcast_aen_retry;
5939 "%s - exit, query_count = %d termination_count = %d\n",
5940 ioc->
name, __func__, query_count, termination_count));
5944 _scsih_ublock_io_all_device(ioc);
5962 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
5968 printk(
"discovery_status(0x%08x)",
5981 _scsih_sas_host_add(ioc);
5999 rc = scsi_device_reprobe(sdev);
6015 unsigned long flags;
6023 "failure at %s:%d/%s()!\n", ioc->
name,
6024 __FILE__, __LINE__, __func__);
6029 raid_device = _scsih_raid_device_find_by_wwid(ioc, wwid);
6038 "failure at %s:%d/%s()!\n", ioc->
name,
6039 __FILE__, __LINE__, __func__);
6047 _scsih_raid_device_add(ioc, raid_device);
6050 raid_device->
id, 0);
6052 _scsih_raid_device_remove(ioc, raid_device);
6055 _scsih_determine_boot_device(ioc, raid_device, 1);
6072 unsigned long flags;
6077 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
6080 starget = raid_device->
starget;
6081 sas_target_priv_data = starget->
hostdata;
6082 sas_target_priv_data->
deleted = 1;
6085 "(0x%016llx)\n", ioc->
name, raid_device->
handle,
6086 (
unsigned long long) raid_device->
wwid);
6110 unsigned long flags;
6114 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
6120 starget = sas_device->
starget;
6121 sas_target_priv_data = starget->
hostdata;
6122 sas_target_priv_data->
flags &=
6150 unsigned long flags;
6152 u16 volume_handle = 0;
6153 u64 volume_wwid = 0;
6161 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
6165 starget = sas_device->
starget;
6166 sas_target_priv_data = starget->
hostdata;
6167 sas_target_priv_data->
flags |=
6196 _scsih_device_remove_by_handle(ioc, handle);
6212 unsigned long flags;
6223 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
6231 ioc->
name, __FILE__, __LINE__, __func__);
6239 ioc->
name, __FILE__, __LINE__, __func__);
6244 if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address))
6248 _scsih_add_device(ioc, handle, 0, 1);
6251 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
6267 char *reason_str =
NULL, *element_str =
NULL;
6275 for (i = 0; i < event_data->
NumElements; i++, element++) {
6281 reason_str =
"remove";
6284 reason_str =
"no change";
6287 reason_str =
"hide";
6290 reason_str =
"unhide";
6293 reason_str =
"volume_created";
6296 reason_str =
"volume_deleted";
6299 reason_str =
"pd_created";
6302 reason_str =
"pd_deleted";
6305 reason_str =
"unknown reason";
6310 switch (element_type) {
6312 element_str =
"volume";
6315 element_str =
"phys disk";
6318 element_str =
"hot spare";
6321 element_str =
"unknown element";
6325 "pd handle(0x%04x), pd num(0x%02x)\n", element_str,
6350 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
6353 _scsih_sas_ir_config_change_event_debug(ioc, event_data);
6369 if (!foreign_config)
6370 _scsih_sas_volume_add(ioc, element);
6374 if (!foreign_config)
6375 _scsih_sas_volume_delete(ioc,
6380 _scsih_sas_pd_hide(ioc, element);
6384 _scsih_sas_pd_expose(ioc, element);
6388 _scsih_sas_pd_add(ioc, element);
6392 _scsih_sas_pd_delete(ioc, element);
6411 unsigned long flags;
6428 "old(0x%08x), new(0x%08x)\n", ioc->
name, __func__, handle,
6434 _scsih_sas_volume_delete(ioc, handle);
6442 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
6451 "failure at %s:%d/%s()!\n", ioc->
name,
6452 __FILE__, __LINE__, __func__);
6459 "failure at %s:%d/%s()!\n", ioc->
name,
6460 __FILE__, __LINE__, __func__);
6468 _scsih_raid_device_add(ioc, raid_device);
6470 raid_device->
id, 0);
6472 _scsih_raid_device_remove(ioc, raid_device);
6496 unsigned long flags;
6514 "old(0x%08x), new(0x%08x)\n", ioc->
name, __func__, handle,
6528 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
6538 ioc->
name, __FILE__, __LINE__, __func__);
6546 ioc->
name, __FILE__, __LINE__, __func__);
6551 if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address))
6555 _scsih_add_device(ioc, handle, 0, 1);
6567 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
6577 _scsih_sas_ir_operation_status_event_debug(
struct MPT2SAS_ADAPTER *ioc,
6580 char *reason_str =
NULL;
6584 reason_str =
"resync";
6587 reason_str =
"online capacity expansion";
6590 reason_str =
"consistency check";
6593 reason_str =
"background init";
6596 reason_str =
"make data consistent";
6604 "\thandle(0x%04x), percent complete(%d)\n",
6605 ioc->
name, reason_str,
6625 unsigned long flags;
6628 #ifdef CONFIG_SCSI_MPT2SAS_LOGGING
6631 _scsih_sas_ir_operation_status_event_debug(ioc,
6640 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
6662 sas_device_priv_data = sdev->
hostdata;
6663 if (sas_device_priv_data && sas_device_priv_data->
sas_target)
6664 sas_device_priv_data->
sas_target->deleted = 1;
6687 unsigned long flags;
6692 sas_device->
slot == slot) {
6694 starget = sas_device->
starget;
6695 if (starget && starget->
hostdata) {
6696 sas_target_priv_data = starget->
hostdata;
6697 sas_target_priv_data->
tm_busy = 0;
6698 sas_target_priv_data->
deleted = 0;
6700 sas_target_priv_data =
NULL;
6703 "handle(0x%04x), sas_addr(0x%016llx), "
6704 "enclosure logical id(0x%016llx), "
6705 "slot(%d)\n", handle,
6707 (
unsigned long long)
6710 if (sas_device->
handle == handle)
6715 if (sas_target_priv_data)
6759 if (!(_scsih_is_end_device(device_info)))
6763 _scsih_mark_responding_sas_device(ioc, sas_address, slot,
6789 unsigned long flags;
6793 if (raid_device->
wwid == wwid && raid_device->
starget) {
6794 starget = raid_device->
starget;
6795 if (starget && starget->
hostdata) {
6796 sas_target_priv_data = starget->
hostdata;
6797 sas_target_priv_data->
deleted = 0;
6799 sas_target_priv_data =
NULL;
6803 "handle(0x%04x), wwid(0x%016llx)\n", handle,
6804 (
unsigned long long)raid_device->
wwid);
6810 _scsih_init_warpdrive_properties(ioc, raid_device);
6812 if (raid_device->
handle == handle) {
6820 if (sas_target_priv_data)
6876 _scsih_mark_responding_raid_device(ioc,
6882 phys_disk_num = 0xFF;
6898 "complete\n", ioc->
name);
6917 unsigned long flags;
6925 if (sas_expander->
handle == handle)
6928 " from(0x%04x) to (0x%04x)!!!\n",
6930 sas_expander->
handle, handle);
6932 for (i = 0 ; i < sas_expander->
num_phys ; i++)
6933 sas_expander->
phy[i].handle = handle;
6975 "sas_addr(0x%016llx)\n", handle,
6976 (
unsigned long long)sas_address);
6977 _scsih_mark_responding_expander(ioc, sas_address, handle);
6994 struct _sas_node *sas_expander, *sas_expander_next;
6997 unsigned long flags;
7017 "volumes\n", ioc->
name);
7021 _scsih_sas_volume_delete(ioc,
7031 INIT_LIST_HEAD(&tmp_list);
7035 list_move_tail(&sas_expander->
list, &tmp_list);
7043 _scsih_expander_node_remove(ioc, sas_expander);
7048 _scsih_ublock_io_all_device(ioc);
7059 for (i = 0 ; i < sas_expander->
num_phys ; i++) {
7061 &expander_pg1, i, handle))) {
7063 ioc->
name, __FILE__, __LINE__, __func__);
7096 unsigned long flags;
7100 _scsih_sas_host_refresh(ioc);
7115 if (expander_device)
7116 _scsih_refresh_expander_links(ioc, expander_device,
7119 _scsih_expander_add(ioc, handle);
7126 phys_disk_num = 0xFF;
7137 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
7146 if (!_scsih_get_sas_address(ioc, parent_handle,
7149 handle, sas_device_pg0.
PhyNum,
7152 _scsih_add_device(ioc, handle, 0, 1);
7166 raid_device = _scsih_raid_device_find_by_wwid(ioc,
7181 _scsih_sas_volume_add(ioc, &element);
7197 if (!(_scsih_is_end_device(
7207 if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address)) {
7210 _scsih_add_device(ioc, handle, 0, 0);
7233 switch (reset_phase) {
7236 "MPT2_IOC_PRE_RESET\n", ioc->
name, __func__));
7240 "MPT2_IOC_AFTER_RESET\n", ioc->
name, __func__));
7251 _scsih_fw_event_cleanup_queue(ioc);
7252 _scsih_flush_running_cmds(ioc);
7256 "MPT2_IOC_DONE_RESET\n", ioc->
name, __func__));
7257 _scsih_sas_host_refresh(ioc);
7258 _scsih_prep_device_scan(ioc);
7259 _scsih_search_responding_sas_devices(ioc);
7260 _scsih_search_responding_raid_devices(ioc);
7261 _scsih_search_responding_expanders(ioc);
7264 _scsih_prep_device_scan(ioc);
7265 _scsih_search_responding_sas_devices(ioc);
7266 _scsih_search_responding_raid_devices(ioc);
7267 _scsih_search_responding_expanders(ioc);
7268 _scsih_error_recovery_delete_devices(ioc);
7292 _scsih_fw_event_free(ioc, fw_event);
7296 switch (fw_event->
event) {
7300 _scsih_remove_unresponding_sas_devices(ioc);
7301 _scsih_scan_for_devices_after_reset(ioc);
7309 "from worker thread\n", ioc->
name));
7315 _scsih_sas_topology_change_event(ioc, fw_event);
7318 _scsih_sas_device_status_change_event(ioc,
7322 _scsih_sas_discovery_event(ioc,
7326 _scsih_sas_broadcast_primitive_event(ioc,
7330 _scsih_sas_enclosure_dev_status_change_event(ioc,
7334 _scsih_sas_ir_config_change_event(ioc, fw_event);
7337 _scsih_sas_ir_volume_event(ioc, fw_event);
7340 _scsih_sas_ir_physical_disk_event(ioc, fw_event);
7343 _scsih_sas_ir_operation_status_event(ioc, fw_event);
7346 _scsih_fw_event_free(ioc, fw_event);
7379 ioc->
name, __FILE__, __LINE__, __func__);
7406 _scsih_check_topo_delete_events(ioc,
7411 _scsih_check_ir_config_unhide_events(ioc,
7416 _scsih_check_volume_delete_events(ioc,
7439 "IO Throttling has occurred in the WarpDrive "
7440 "subsystem. Check WarpDrive documentation for "
7441 "additional details.\n", ioc->
name);
7445 "Program/Erase Cycles for the WarpDrive subsystem "
7446 "in degraded range. Check WarpDrive documentation "
7447 "for additional details.\n", ioc->
name);
7451 "There are no Program/Erase Cycles for the "
7452 "WarpDrive subsystem. The storage device will be "
7453 "in read-only mode. Check WarpDrive documentation "
7454 "for additional details.\n", ioc->
name);
7458 "The Backup Rail Monitor has failed on the "
7459 "WarpDrive subsystem. Check WarpDrive "
7460 "documentation for additional details.\n",
7481 ioc->
name, __FILE__, __LINE__, __func__);
7488 ioc->
name, __FILE__, __LINE__, __func__);
7499 _scsih_fw_event_add(ioc, fw_event);
7506 .name =
"Fusion MPT SAS Host",
7508 .queuecommand = _scsih_qcmd,
7509 .target_alloc = _scsih_target_alloc,
7510 .slave_alloc = _scsih_slave_alloc,
7511 .slave_configure = _scsih_slave_configure,
7512 .target_destroy = _scsih_target_destroy,
7513 .slave_destroy = _scsih_slave_destroy,
7514 .scan_finished = _scsih_scan_finished,
7515 .scan_start = _scsih_scan_start,
7516 .change_queue_depth = _scsih_change_queue_depth,
7517 .change_queue_type = _scsih_change_queue_type,
7518 .eh_abort_handler = _scsih_abort,
7519 .eh_device_reset_handler = _scsih_dev_reset,
7520 .eh_target_reset_handler = _scsih_target_reset,
7521 .eh_host_reset_handler = _scsih_host_reset,
7522 .bios_param = _scsih_bios_param,
7526 .max_sectors = 32767,
7571 "(0x%04x), sas_addr(0x%016llx)\n", ioc->
name,
7572 sas_expander->
handle, (
unsigned long long)
7576 kfree(sas_expander);
7607 ioc->
name, __func__);
7615 ioc->
name, __func__);
7635 ioc->
name, __func__);
7644 "ioc_status(0x%04x), loginfo(0x%08x)\n",
7661 _scsih_shutdown(
struct pci_dev *pdev)
7663 struct Scsi_Host *shost = pci_get_drvdata(pdev);
7666 unsigned long flags;
7669 _scsih_fw_event_cleanup_queue(ioc);
7678 _scsih_ir_shutdown(ioc);
7690 _scsih_remove(
struct pci_dev *pdev)
7692 struct Scsi_Host *shost = pci_get_drvdata(pdev);
7694 struct _sas_port *mpt2sas_port, *next_port;
7698 unsigned long flags;
7701 _scsih_fw_event_cleanup_queue(ioc);
7711 _scsih_ir_shutdown(ioc);
7715 sas_target_priv_data =
7716 raid_device->
starget->hostdata;
7717 sas_target_priv_data->
deleted = 1;
7721 "(0x%016llx)\n", ioc->
name, raid_device->
handle,
7722 (
unsigned long long) raid_device->
wwid);
7723 _scsih_raid_device_remove(ioc, raid_device);
7771 u64 sas_address_parent;
7773 unsigned long flags;
7797 raid_device = device;
7799 raid_device->
id, 0);
7801 _scsih_raid_device_remove(ioc, raid_device);
7804 sas_device = device;
7805 handle = sas_device->
handle;
7815 _scsih_sas_device_remove(ioc, sas_device);
7816 }
else if (!sas_device->
starget) {
7819 sas_address_parent);
7820 _scsih_sas_device_remove(ioc, sas_device);
7842 raid_device->
id, 0);
7844 _scsih_raid_device_remove(ioc, raid_device);
7858 unsigned long flags;
7872 }
else if (!sas_device->
starget) {
7897 u16 volume_mapping_flags;
7902 _scsih_probe_boot_devices(ioc);
7905 volume_mapping_flags =
7908 if (volume_mapping_flags ==
7910 _scsih_probe_raid(ioc);
7911 _scsih_probe_sas(ioc);
7913 _scsih_probe_sas(ioc);
7914 _scsih_probe_raid(ioc);
7917 _scsih_probe_sas(ioc);
7930 _scsih_scan_start(
struct Scsi_Host *shost)
7935 if (diag_buffer_enable != -1 && diag_buffer_enable != 0)
7938 if (disable_discovery > 0)
7958 _scsih_scan_finished(
struct Scsi_Host *shost,
unsigned long time)
7962 if (disable_discovery > 0) {
7968 if (time >= (300 *
HZ)) {
7971 "(timeout=300s)\n", ioc->
name);
7993 _scsih_probe_devices(ioc);
8020 ioc = shost_priv(shost);
8022 INIT_LIST_HEAD(&ioc->
list);
8025 ioc->
id = mpt_ids++;
8060 INIT_LIST_HEAD(&ioc->
sas_hba.sas_port_list);
8074 "for max_sectors, range is 64 to 32767. Assigning "\
8079 "for max_sectors, range is 64 to 8192. Assigning "
8080 "default value of 32767.\n", ioc->
name,
8089 if ((scsi_add_host(shost, &pdev->
dev))) {
8091 ioc->
name, __FILE__, __LINE__, __func__);
8093 goto out_add_shost_fail;
8098 scsi_host_set_prot(shost, prot_mask);
8108 "fw_event%d", ioc->
id);
8113 ioc->
name, __FILE__, __LINE__, __func__);
8114 goto out_thread_fail;
8120 ioc->
name, __FILE__, __LINE__, __func__);
8121 goto out_attach_fail;
8130 if (_scsih_get_num_volumes(ioc))
8162 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8170 "operating state [D%d]\n", ioc->
name, pdev,
8171 pci_name(pdev), device_state);
8187 _scsih_resume(
struct pci_dev *pdev)
8189 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8195 "operating state [D%d]\n", ioc->
name, pdev,
8196 pci_name(pdev), device_state);
8199 pci_enable_wake(pdev,
PCI_D0, 0);
8226 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8246 _scsih_flush_running_cmds(ioc);
8261 _scsih_pci_slot_reset(
struct pci_dev *pdev)
8263 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8282 (rc == 0) ?
"success" :
"failed");
8299 _scsih_pci_resume(
struct pci_dev *pdev)
8301 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8316 _scsih_pci_mmio_enabled(
struct pci_dev *pdev)
8318 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8331 .error_detected = _scsih_pci_error_detected,
8332 .mmio_enabled = _scsih_pci_mmio_enabled,
8333 .slot_reset = _scsih_pci_slot_reset,
8334 .resume = _scsih_pci_resume,
8339 .id_table = scsih_pci_table,
8340 .probe = _scsih_probe,
8342 .shutdown = _scsih_shutdown,
8343 .err_handler = &_scsih_err_handler,
8345 .suspend = _scsih_suspend,
8352 .cookie = &scsih_driver_template,
8353 .is_raid = _scsih_is_raid,
8354 .get_resync = _scsih_get_resync,
8355 .get_state = _scsih_get_state,
8378 if (!mpt2sas_raid_template) {
8411 _scsih_tm_tr_complete);
8414 _scsih_tm_volume_tr_complete);
8417 _scsih_sas_control_complete);
8421 error = pci_register_driver(&scsih_driver);