Lines Matching +full:sml +full:- +full:size

5  * Copyright (C) 2012-2014  LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
93 static u8 scsi_io_cb_idx = -1;
94 static u8 tm_cb_idx = -1;
95 static u8 ctl_cb_idx = -1;
96 static u8 base_cb_idx = -1;
97 static u8 port_enable_cb_idx = -1;
98 static u8 transport_cb_idx = -1;
99 static u8 scsih_cb_idx = -1;
100 static u8 config_cb_idx = -1;
104 static u8 tm_tr_cb_idx = -1 ;
105 static u8 tm_tr_volume_cb_idx = -1 ;
106 static u8 tm_sas_control_cb_idx = -1;
119 static int missing_delay[2] = {-1, -1};
123 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
132 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
133 1 - enumerates only SAS 2.0 generation HBAs\n \
134 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
143 static int diag_buffer_enable = -1;
147 static int disable_discovery = -1;
153 static int prot_mask = -1;
162 static int multipath_on_hba = -1;
168 "\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
169 "\t SAS 3.5 HBA - This will be enabled)");
182 * struct sense_info - common structure for obtaining sense keys
207 * struct fw_event_work - firmware event struct
209 * @work: work object (ioc->fault_reset_work_q)
219 * This object stored on ioc->fw_event_list.
242 kref_get(&fw_work->refcount); in fw_event_work_get()
247 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
258 kref_init(&fw_event->refcount); in alloc_fw_event_work()
263 * struct _scsi_io_transfer - scsi io transfer
311 * _scsih_set_debug_level - global setting of ioc->logging_level.
329 ioc->logging_level = logging_level; in _scsih_set_debug_level()
337 * _scsih_srch_boot_sas_address - search based on sas_address
347 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
351 * _scsih_srch_boot_device_name - search based on device name
361 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
365 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
376 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
377 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
382 * mpt3sas_get_port_by_id - get hba port entry corresponding to provided
403 if (!ioc->multipath_on_hba) in mpt3sas_get_port_by_id()
407 &ioc->port_table_list, list) { in mpt3sas_get_port_by_id()
408 if (port->port_id != port_id) in mpt3sas_get_port_by_id()
412 if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) in mpt3sas_get_port_by_id()
422 if (!ioc->multipath_on_hba) { in mpt3sas_get_port_by_id()
427 port->port_id = port_id; in mpt3sas_get_port_by_id()
430 port, port->port_id); in mpt3sas_get_port_by_id()
431 list_add_tail(&port->list, in mpt3sas_get_port_by_id()
432 &ioc->port_table_list); in mpt3sas_get_port_by_id()
439 * mpt3sas_get_vphy_by_phy - get virtual_phy object corresponding to phy number
452 if (!port->vphys_mask) in mpt3sas_get_vphy_by_phy()
455 list_for_each_entry_safe(vphy, vphy_next, &port->vphys_list, list) { in mpt3sas_get_vphy_by_phy()
456 if (vphy->phy_mask & (1 << phy)) in mpt3sas_get_vphy_by_phy()
463 * _scsih_is_boot_device - search for matching boot device.
485 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
492 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
498 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
508 * _scsih_get_sas_address - set the sas_address for given device handle
513 * Return: 0 success, non-zero when failure
529 return -ENXIO; in _scsih_get_sas_address()
537 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
540 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
548 return -ENXIO; in _scsih_get_sas_address()
553 return -EIO; in _scsih_get_sas_address()
557 * _scsih_determine_boot_device - determine boot device.
563 * to scsi-ml or sas transport, this purpose is for persistent boot device.
582 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
586 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
591 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
597 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
603 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
604 device_name = sas_device->device_name; in _scsih_determine_boot_device()
605 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
606 slot = sas_device->slot; in _scsih_determine_boot_device()
609 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
612 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
614 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
618 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
619 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
623 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
626 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
628 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
632 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
633 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
637 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
640 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
642 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
646 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
647 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
658 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
660 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
674 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
676 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
687 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
689 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
697 * mpt3sas_get_pdev_from_target - pcie device search
701 * Context: This function will acquire ioc->pcie_device_lock and will release
713 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
715 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
722 * __mpt3sas_get_sdev_by_rphy - sas device search
726 * Context: This function will acquire ioc->sas_device_lock and will release
738 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_rphy()
740 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_rphy()
741 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
748 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_rphy()
749 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
759 * __mpt3sas_get_sdev_by_addr - get _sas_device object corresponding to provided
777 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
779 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_addr()
780 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
782 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
788 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_addr()
789 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
791 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
801 * mpt3sas_get_sdev_by_addr - sas device search
805 * Context: Calling function should acquire ioc->sas_device_lock
817 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
820 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
830 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
832 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
833 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
836 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
837 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
848 * mpt3sas_get_sdev_by_handle - sas device search
851 * Context: Calling function should acquire ioc->sas_device_lock
862 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
864 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
870 * _scsih_display_enclosure_chassis_info - display device location info
882 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
886 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
887 sas_device->slot); in _scsih_display_enclosure_chassis_info()
888 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
891 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
892 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
893 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
895 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
897 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
901 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
902 sas_device->slot); in _scsih_display_enclosure_chassis_info()
903 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
906 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
907 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
908 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
911 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
913 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
915 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
916 sas_device->slot); in _scsih_display_enclosure_chassis_info()
917 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
919 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
920 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
921 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
923 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
928 * _scsih_sas_device_remove - remove sas_device from list.
931 * Context: This function will acquire ioc->sas_device_lock.
944 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
952 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
953 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
954 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
957 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
961 * _scsih_device_remove_by_handle - removing device object by handle
971 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
974 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
977 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
980 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
988 * mpt3sas_device_remove_by_sas_address - removing device object by
1003 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
1006 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1009 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
1012 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1020 * _scsih_sas_device_add - insert sas_device to the list.
1023 * Context: This function will acquire ioc->sas_device_lock.
1025 * Adding new object to the ioc->sas_device_list.
1035 __func__, sas_device->handle, in _scsih_sas_device_add()
1036 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
1041 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1043 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
1044 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1046 if (ioc->hide_drives) { in _scsih_sas_device_add()
1047 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1051 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
1052 sas_device->sas_address_parent, sas_device->port)) { in _scsih_sas_device_add()
1054 } else if (!sas_device->starget) { in _scsih_sas_device_add()
1058 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
1060 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
1062 sas_device->sas_address, in _scsih_sas_device_add()
1063 sas_device->sas_address_parent, in _scsih_sas_device_add()
1064 sas_device->port); in _scsih_sas_device_add()
1068 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1072 * _scsih_sas_device_init_add - insert sas_device to the list.
1075 * Context: This function will acquire ioc->sas_device_lock.
1077 * Adding new object at driver load time to the ioc->sas_device_init_list.
1087 __func__, sas_device->handle, in _scsih_sas_device_init_add()
1088 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
1093 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1095 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
1097 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1106 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
1108 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
1109 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1112 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
1113 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1125 * mpt3sas_get_pdev_by_wwid - pcie device search
1129 * Context: This function will acquire ioc->pcie_device_lock and will release
1140 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1142 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1154 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
1156 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
1157 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1160 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
1161 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1176 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1178 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1179 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1182 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1183 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1195 * mpt3sas_get_pdev_by_handle - pcie device search
1199 * Context: This function will acquire ioc->pcie_device_lock and will release
1211 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1213 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1219 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1221 * Context: This function will acquire ioc->pcie_device_lock
1223 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1234 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1235 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1236 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1237 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1239 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1242 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1243 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1247 * _scsih_pcie_device_remove - remove pcie_device from list.
1250 * Context: This function will acquire ioc->pcie_device_lock.
1265 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1266 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1268 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1269 pcie_device->slot); in _scsih_pcie_device_remove()
1270 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1272 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1273 pcie_device->connector_name); in _scsih_pcie_device_remove()
1275 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1276 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1277 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1280 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1282 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1284 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1299 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1311 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1314 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1317 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1318 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1322 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1325 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1341 * _scsih_pcie_device_add - add pcie_device object
1356 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1357 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1361 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1362 pcie_device->slot)); in _scsih_pcie_device_add()
1363 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1366 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1367 pcie_device->connector_name)); in _scsih_pcie_device_add()
1369 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1371 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1372 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1374 if (pcie_device->access_status == in _scsih_pcie_device_add()
1376 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1379 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1381 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1382 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1383 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1384 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1387 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1391 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1394 * Context: This function will acquire ioc->pcie_device_lock.
1396 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1407 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1408 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1412 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1413 pcie_device->slot)); in _scsih_pcie_device_init_add()
1414 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1417 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1418 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1420 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1422 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1423 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1426 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1429 * _scsih_raid_device_find_by_id - raid device search
1433 * Context: Calling function should acquire ioc->raid_device_lock
1444 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1445 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1456 * mpt3sas_raid_device_find_by_handle - raid device search
1459 * Context: Calling function should acquire ioc->raid_device_lock
1470 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1471 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1482 * _scsih_raid_device_find_by_wwid - raid device search
1485 * Context: Calling function should acquire ioc->raid_device_lock
1496 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1497 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1508 * _scsih_raid_device_add - add raid_device object
1523 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1525 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1526 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1527 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1531 * _scsih_raid_device_remove - delete raid_device object
1542 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1543 list_del(&raid_device->list); in _scsih_raid_device_remove()
1545 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1549 * mpt3sas_scsih_expander_find_by_handle - expander device search
1552 * Context: Calling function should acquire ioc->sas_device_lock
1563 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1564 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1574 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1577 * Context: Calling function should acquire ioc->sas_device_lock
1588 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1589 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1598 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1602 * Context: Calling function should acquire ioc->sas_node_lock.
1616 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1617 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1619 if (sas_expander->port != port) in mpt3sas_scsih_expander_find_by_sas_address()
1629 * _scsih_expander_node_add - insert expander device to the list.
1632 * Context: This function will acquire ioc->sas_node_lock.
1634 * Adding new object to the ioc->sas_expander_list.
1642 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1643 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1644 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1648 * _scsih_is_end_device - determines if device is an end device
1667 * _scsih_is_nvme_pciescsi_device - determines if
1687 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1691 * Context: This function will acquire ioc->scsi_lookup_lock.
1704 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1708 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1709 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1716 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1721 * Context: This function will acquire ioc->scsi_lookup_lock.
1733 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1738 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1739 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1740 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1747 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1760 u16 tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1763 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1765 ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag; in mpt3sas_scsih_scsi_lookup_get()
1771 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1775 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1778 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1781 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1789 * scsih_change_queue_depth - setting device queue depth
1798 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1806 max_depth = shost->can_queue; in scsih_change_queue_depth()
1812 if (ioc->enable_sdev_max_qd || ioc->is_gen35_ioc) in scsih_change_queue_depth()
1815 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1818 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1821 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1824 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1827 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1832 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1836 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1843 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1844 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1845 return sdev->queue_depth; in scsih_change_queue_depth()
1849 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1858 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1861 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1862 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1868 * scsih_target_alloc - target add routine
1877 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1889 return -ENOMEM; in scsih_target_alloc()
1891 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1892 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1893 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1896 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1897 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1898 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1899 starget->channel); in scsih_target_alloc()
1901 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1902 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1903 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1904 if (ioc->is_warpdrive) in scsih_target_alloc()
1905 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1906 raid_device->starget = starget; in scsih_target_alloc()
1908 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1913 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1914 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1915 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1916 starget->channel); in scsih_target_alloc()
1918 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1919 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1920 sas_target_priv_data->port = NULL; in scsih_target_alloc()
1921 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1922 pcie_device->starget = starget; in scsih_target_alloc()
1923 pcie_device->id = starget->id; in scsih_target_alloc()
1924 pcie_device->channel = starget->channel; in scsih_target_alloc()
1925 sas_target_priv_data->flags |= in scsih_target_alloc()
1927 if (pcie_device->fast_path) in scsih_target_alloc()
1928 sas_target_priv_data->flags |= in scsih_target_alloc()
1931 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1936 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1937 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1941 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1942 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1943 sas_target_priv_data->port = sas_device->port; in scsih_target_alloc()
1944 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1945 sas_device->starget = starget; in scsih_target_alloc()
1946 sas_device->id = starget->id; in scsih_target_alloc()
1947 sas_device->channel = starget->channel; in scsih_target_alloc()
1948 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1949 sas_target_priv_data->flags |= in scsih_target_alloc()
1951 if (sas_device->fast_path) in scsih_target_alloc()
1952 sas_target_priv_data->flags |= in scsih_target_alloc()
1955 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1961 * scsih_target_destroy - target destroy routine
1967 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1975 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1979 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1980 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1981 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1982 starget->channel); in scsih_target_destroy()
1984 raid_device->starget = NULL; in scsih_target_destroy()
1985 raid_device->sdev = NULL; in scsih_target_destroy()
1987 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1991 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1992 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1995 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1996 (pcie_device->id == starget->id) && in scsih_target_destroy()
1997 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1998 pcie_device->starget = NULL; in scsih_target_destroy()
2004 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
2008 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
2012 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2014 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
2015 (sas_device->id == starget->id) && in scsih_target_destroy()
2016 (sas_device->channel == starget->channel)) in scsih_target_destroy()
2017 sas_device->starget = NULL; in scsih_target_destroy()
2023 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
2028 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2032 starget->hostdata = NULL; in scsih_target_destroy()
2036 * scsih_sdev_init - device add routine
2058 return -ENOMEM; in scsih_sdev_init()
2060 sas_device_priv_data->lun = sdev->lun; in scsih_sdev_init()
2061 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_sdev_init()
2064 sas_target_priv_data = starget->hostdata; in scsih_sdev_init()
2065 sas_target_priv_data->num_luns++; in scsih_sdev_init()
2066 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_sdev_init()
2067 sdev->hostdata = sas_device_priv_data; in scsih_sdev_init()
2068 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_sdev_init()
2069 sdev->no_uld_attach = 1; in scsih_sdev_init()
2071 shost = dev_to_shost(&starget->dev); in scsih_sdev_init()
2073 if (starget->channel == RAID_CHANNEL) { in scsih_sdev_init()
2074 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_sdev_init()
2076 starget->id, starget->channel); in scsih_sdev_init()
2078 raid_device->sdev = sdev; /* raid is single lun */ in scsih_sdev_init()
2079 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_sdev_init()
2081 if (starget->channel == PCIE_CHANNEL) { in scsih_sdev_init()
2082 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_init()
2084 sas_target_priv_data->sas_address); in scsih_sdev_init()
2085 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_sdev_init()
2087 "%s : pcie_device->starget set to starget @ %d\n", in scsih_sdev_init()
2089 pcie_device->starget = starget; in scsih_sdev_init()
2094 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_init()
2096 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_sdev_init()
2097 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_init()
2099 sas_target_priv_data->sas_address, in scsih_sdev_init()
2100 sas_target_priv_data->port); in scsih_sdev_init()
2101 if (sas_device && (sas_device->starget == NULL)) { in scsih_sdev_init()
2103 "%s : sas_device->starget set to starget @ %d\n", in scsih_sdev_init()
2105 sas_device->starget = starget; in scsih_sdev_init()
2111 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_init()
2118 * scsih_sdev_destroy - device destroy routine
2132 if (!sdev->hostdata) in scsih_sdev_destroy()
2136 sas_target_priv_data = starget->hostdata; in scsih_sdev_destroy()
2137 sas_target_priv_data->num_luns--; in scsih_sdev_destroy()
2139 shost = dev_to_shost(&starget->dev); in scsih_sdev_destroy()
2142 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_sdev_destroy()
2143 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_destroy()
2146 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_sdev_destroy()
2147 pcie_device->starget = NULL; in scsih_sdev_destroy()
2152 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_destroy()
2154 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_sdev_destroy()
2155 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_destroy()
2158 if (sas_device && !sas_target_priv_data->num_luns) in scsih_sdev_destroy()
2159 sas_device->starget = NULL; in scsih_sdev_destroy()
2163 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_destroy()
2166 kfree(sdev->hostdata); in scsih_sdev_destroy()
2167 sdev->hostdata = NULL; in scsih_sdev_destroy()
2171 * _scsih_display_sata_capabilities - sata capabilities
2217 * raid transport support -
2219 * unloading the driver followed by a load - I believe that the subroutine
2224 * scsih_is_raid - return boolean indicating device is raid volume
2231 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2233 if (ioc->is_warpdrive) in scsih_is_raid()
2235 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2243 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2247 * scsih_get_resync - get raid volume resync percent complete
2254 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2265 if (ioc->is_warpdrive) in scsih_get_resync()
2268 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2269 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2270 sdev->channel); in scsih_get_resync()
2272 handle = raid_device->handle; in scsih_get_resync()
2273 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2275 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2296 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2308 * scsih_get_state - get raid volume level
2315 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2324 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2325 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2326 sdev->channel); in scsih_get_state()
2328 handle = raid_device->handle; in scsih_get_state()
2329 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2362 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2374 * _scsih_set_level - set raid level
2400 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2403 &sdev->sdev_gendev, level); in _scsih_set_level()
2408 &sdev->sdev_gendev, level); in _scsih_set_level()
2415 * _scsih_get_volume_capabilities - volume capabilities
2432 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2440 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2451 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2459 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2466 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2470 raid_device->device_info = in _scsih_get_volume_capabilities()
2480 * _scsih_enable_tlr - setting TLR flags
2493 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2496 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2507 * scsih_sdev_configure - device configure routine.
2517 struct Scsi_Host *shost = sdev->host; in scsih_sdev_configure()
2533 sas_device_priv_data = sdev->hostdata; in scsih_sdev_configure()
2534 sas_device_priv_data->configured_lun = 1; in scsih_sdev_configure()
2535 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_sdev_configure()
2536 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_sdev_configure()
2537 handle = sas_target_priv_data->handle; in scsih_sdev_configure()
2540 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_sdev_configure()
2542 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_sdev_configure()
2544 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_sdev_configure()
2569 if (raid_device->device_info & in scsih_sdev_configure()
2575 if (raid_device->device_info & in scsih_sdev_configure()
2582 switch (raid_device->volume_type) { in scsih_sdev_configure()
2588 if (ioc->manu_pg10.OEMIdentifier && in scsih_sdev_configure()
2589 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_sdev_configure()
2591 !(raid_device->num_pds % 2)) in scsih_sdev_configure()
2611 if (!ioc->hide_ir_msg) in scsih_sdev_configure()
2615 r_level, raid_device->handle, in scsih_sdev_configure()
2616 (unsigned long long)raid_device->wwid, in scsih_sdev_configure()
2617 raid_device->num_pds, ds); in scsih_sdev_configure()
2619 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_sdev_configure()
2620 lim->max_hw_sectors = MPT3SAS_RAID_MAX_SECTORS; in scsih_sdev_configure()
2629 if (!ioc->is_warpdrive) in scsih_sdev_configure()
2630 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_sdev_configure()
2634 /* non-raid handling */ in scsih_sdev_configure()
2635 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_sdev_configure()
2653 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_sdev_configure()
2654 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2656 sas_device_priv_data->sas_target->sas_address); in scsih_sdev_configure()
2658 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2665 qdepth = ioc->max_nvme_qd; in scsih_sdev_configure()
2669 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_sdev_configure()
2670 pcie_device->port_num); in scsih_sdev_configure()
2671 if (pcie_device->enclosure_handle != 0) in scsih_sdev_configure()
2675 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_sdev_configure()
2676 pcie_device->slot); in scsih_sdev_configure()
2677 if (pcie_device->connector_name[0] != '\0') in scsih_sdev_configure()
2681 pcie_device->enclosure_level, in scsih_sdev_configure()
2682 pcie_device->connector_name); in scsih_sdev_configure()
2684 if (pcie_device->nvme_mdts) in scsih_sdev_configure()
2685 lim->max_hw_sectors = pcie_device->nvme_mdts / 512; in scsih_sdev_configure()
2688 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2690 lim->virt_boundary_mask = ioc->page_size - 1; in scsih_sdev_configure()
2694 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2696 sas_device_priv_data->sas_target->sas_address, in scsih_sdev_configure()
2697 sas_device_priv_data->sas_target->port); in scsih_sdev_configure()
2699 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2706 sas_device->volume_handle = volume_handle; in scsih_sdev_configure()
2707 sas_device->volume_wwid = volume_wwid; in scsih_sdev_configure()
2708 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_sdev_configure()
2709 qdepth = (sas_device->port_type > 1) ? in scsih_sdev_configure()
2710 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_sdev_configure()
2712 if (sas_device->device_info & in scsih_sdev_configure()
2716 sas_device_priv_data->sas_target->handle); in scsih_sdev_configure()
2717 sas_device_priv_data->ignore_delay_remove = 1; in scsih_sdev_configure()
2722 qdepth = ioc->max_sata_qd; in scsih_sdev_configure()
2723 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_sdev_configure()
2725 else if (sas_device->device_info & in scsih_sdev_configure()
2732 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_sdev_configure()
2733 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_sdev_configure()
2738 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2755 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2758 * @capacity: device size (in 512 byte sectors)
2781 * Handle extended translation size for logical drives in scsih_bios_param()
2801 * _scsih_response_code - translation of device response code
2843 * _scsih_tm_done - tm completion routine
2860 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2862 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2864 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2867 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2868 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2870 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2871 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2876 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2889 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2892 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2895 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2896 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2898 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2904 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2917 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2920 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2923 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2924 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2926 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2932 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2948 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2964 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2965 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2966 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2968 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2969 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2970 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2978 * scsih_tm_post_processing - post processing of target & LUN reset
3012 * ReplyDescriptor pools before returning the FAILED status to SML. in scsih_tm_post_processing()
3022 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3037 * The callback index is set inside `ioc->tm_cb_idx`.
3055 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3057 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3062 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3063 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3088 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3097 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3099 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3101 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3102 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3103 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3104 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3107 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3108 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3109 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3111 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3112 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3113 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3114 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3116 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3129 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3131 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3134 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3135 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3136 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3137 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3138 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3139 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3154 * command is returned to the SML. If the command is not in mpt3sas_scsih_issue_tm()
3160 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3185 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3195 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3198 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3204 * _scsih_tm_display_info - displays info about the device
3213 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3214 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3222 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3228 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3231 device_str, priv_target->handle, in _scsih_tm_display_info()
3232 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3234 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3235 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3240 pcie_device->handle, in _scsih_tm_display_info()
3241 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3242 pcie_device->port_num); in _scsih_tm_display_info()
3243 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3247 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3248 pcie_device->slot); in _scsih_tm_display_info()
3249 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3252 pcie_device->enclosure_level, in _scsih_tm_display_info()
3253 pcie_device->connector_name); in _scsih_tm_display_info()
3256 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3259 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3262 if (priv_target->flags & in _scsih_tm_display_info()
3267 sas_device->volume_handle, in _scsih_tm_display_info()
3268 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3272 sas_device->handle, in _scsih_tm_display_info()
3273 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3274 sas_device->phy); in _scsih_tm_display_info()
3281 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3286 * scsih_abort - eh threads main abort routine
3294 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3302 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3304 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3305 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3308 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3309 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3310 ioc->remove_host) { in scsih_abort()
3311 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3313 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3320 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3321 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3323 scmd->result = DID_RESET << 16; in scsih_abort()
3329 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3331 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3332 scmd->result = DID_RESET << 16; in scsih_abort()
3339 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3341 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3342 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3343 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3344 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3345 scmd->device->id, scmd->device->lun, in scsih_abort()
3347 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3349 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3352 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3360 * scsih_dev_reset - eh threads main device reset routine
3368 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3377 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3378 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3380 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3384 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3385 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3386 ioc->remove_host) { in scsih_dev_reset()
3387 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3389 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3397 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3402 handle = sas_device->volume_handle; in scsih_dev_reset()
3404 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3407 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3414 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3415 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3416 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3421 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3422 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3426 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3429 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3441 * scsih_target_reset - eh threads main target reset routine
3449 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3457 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3458 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3464 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3465 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3466 ioc->remove_host) { in scsih_target_reset()
3469 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3477 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3482 handle = sas_device->volume_handle; in scsih_target_reset()
3484 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3487 scmd->result = DID_RESET << 16; in scsih_target_reset()
3494 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3495 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3496 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3500 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3501 scmd->device->id, 0, in scsih_target_reset()
3505 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3520 * scsih_host_reset - eh threads main host reset routine
3528 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3534 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3550 * _scsih_fw_event_add - insert and queue up fw_event
3553 * Context: This function will acquire ioc->fw_event_lock.
3563 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3566 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3568 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3569 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3570 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3572 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3573 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3577 * _scsih_fw_event_del_from_list - delete fw_event from the list
3580 * Context: This function will acquire ioc->fw_event_lock.
3590 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3591 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3592 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3595 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3600 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3611 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3617 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3618 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3619 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3625 * _scsih_error_recovery_delete_devices - remove devices not responding
3636 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3637 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3643 * mpt3sas_port_enable_complete - port enable completed (fake event)
3654 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3655 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3665 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3666 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3667 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3669 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3672 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3678 * _scsih_fw_event_cleanup_queue - cleanup event queue
3691 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3692 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3700 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3701 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3703 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3705 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3718 * the devices from SML. in _scsih_fw_event_cleanup_queue()
3721 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3722 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3724 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3729 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3736 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3737 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3738 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3749 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3753 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3757 * _scsih_internal_device_block - block the sdev device
3771 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3772 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3775 if (r == -EINVAL) in _scsih_internal_device_block()
3778 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3782 * _scsih_internal_device_unblock - unblock the sdev device
3796 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3797 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3799 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3808 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3809 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3814 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3816 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3821 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3826 * _scsih_ublock_io_all_device - unblock every device
3837 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3838 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3841 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3846 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3853 * _scsih_ublock_io_device - prepare device to be deleted
3867 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3868 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3869 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3871 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3874 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3876 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3883 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3894 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3895 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3898 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3900 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3903 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3911 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3926 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3927 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3930 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3932 if (sas_device_priv_data->block) in _scsih_block_io_device()
3934 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3936 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3939 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3971 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3972 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3974 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3976 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3977 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3979 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3980 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3983 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3988 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3990 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3992 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3996 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3997 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
4020 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4021 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4024 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4047 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4049 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4052 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4059 * _scsih_tm_tr_send - send task management request
4088 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4103 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4106 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4108 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4110 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4111 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4112 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4113 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4114 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4115 port = sas_device->port; in _scsih_tm_tr_send()
4117 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4119 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4121 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4122 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4123 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4124 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4125 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4127 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4128 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4130 pcie_device->device_info)))) in _scsih_tm_tr_send()
4141 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4144 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4145 sas_device->slot)); in _scsih_tm_tr_send()
4146 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4149 sas_device->enclosure_level, in _scsih_tm_tr_send()
4150 sas_device->connector_name)); in _scsih_tm_tr_send()
4152 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4155 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4156 pcie_device->slot)); in _scsih_tm_tr_send()
4157 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4160 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4161 pcie_device->connector_name)); in _scsih_tm_tr_send()
4164 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4167 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4172 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4173 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4174 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4183 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4186 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4187 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4188 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4189 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4190 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4191 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4202 * _scsih_tm_tr_complete -
4230 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4249 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4250 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4254 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4261 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4262 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4263 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4265 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4270 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4271 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4272 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4281 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4284 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4285 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4286 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4287 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4292 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4303 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4306 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4307 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4313 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4315 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4328 * _scsih_sas_control_complete - completion routine
4352 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4353 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4354 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4355 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4357 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4358 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4368 * _scsih_tm_tr_volume_send - send target reset request for volumes
4384 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4391 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4396 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4397 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4398 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4407 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4410 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4411 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4412 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4413 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4417 * _scsih_tm_volume_tr_complete - target reset completion
4436 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4449 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4450 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4453 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4460 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4461 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4462 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4468 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4474 * Context - processed in interrupt context.
4481 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4488 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4489 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4490 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4494 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4497 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4498 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4499 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4500 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4501 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4502 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4506 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4512 * Context - processed in interrupt context.
4520 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4523 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4528 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4546 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4547 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4548 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4552 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4555 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4556 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4557 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4558 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4562 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4580 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4581 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4584 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4585 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4590 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4591 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4594 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4595 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4603 * _scsih_check_for_pending_tm - check for pending task management
4618 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4619 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4622 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4623 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4628 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4629 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4632 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4633 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4642 * _scsih_check_topo_delete_events - sanity check on topo events
4664 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4665 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4668 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4674 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4675 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4679 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4682 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4686 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4688 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4689 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4690 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4692 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4693 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4696 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4700 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4701 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4702 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4703 fw_event->ignore) in _scsih_check_topo_delete_events()
4706 fw_event->event_data; in _scsih_check_topo_delete_events()
4707 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4709 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4711 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4715 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4719 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4723 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4743 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4745 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4748 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4753 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4760 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4762 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4767 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4771 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4772 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4773 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4774 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4778 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4779 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4781 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4783 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4787 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4791 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4795 * _scsih_set_volume_delete_flag - setting volume delete flag
4808 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4810 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4811 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4813 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4814 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4817 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4819 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4823 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4830 * input handle is non-zero, or when a and b have not been set before.
4844 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4867 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4871 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4872 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4873 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4876 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4878 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4880 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4887 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4888 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4889 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4892 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4893 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4904 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4905 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4906 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4908 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4909 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4910 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4916 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4917 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4918 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4929 * _scsih_check_volume_delete_events - set delete flag for volumes
4944 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4946 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4950 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4954 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4964 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4966 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4967 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4968 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4969 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4970 event_data->SensorNum); in _scsih_temp_threshold_events()
4972 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4973 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4990 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4992 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4996 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4998 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5003 * _scsih_flush_running_cmds - completing outstanding commands.
5017 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5026 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5027 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5029 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5036 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5062 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5065 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5068 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5071 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5075 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5077 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5079 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5083 * _scsih_eedp_error_handling - return sense code for EEDP errors
5111 * scsih_qcmd - main scsi request entry point
5115 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5136 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5139 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5140 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5141 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5147 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5152 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5155 handle = sas_target_priv_data->handle; in scsih_qcmd()
5160 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5161 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5162 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5170 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5176 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5179 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5181 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5184 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5185 sas_device_priv_data->block) { in scsih_qcmd()
5196 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5200 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5202 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5210 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5218 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5219 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5220 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5223 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5230 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5233 if (scmd->cmd_len == 32) in scsih_qcmd()
5235 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5236 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5238 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5240 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5241 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5242 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5243 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5244 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5245 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5246 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5247 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5249 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5250 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5251 mpi_request->LUN); in scsih_qcmd()
5252 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5254 if (mpi_request->DataLength) { in scsih_qcmd()
5255 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5256 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5262 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5264 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5265 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5269 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5270 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5271 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5273 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5275 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5276 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5278 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5286 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5295 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5296 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5297 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5300 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5301 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5302 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5307 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5313 * scsi_status - SCSI Status code returned from target device
5314 * scsi_state - state info associated with SCSI_IO determined by ioc
5315 * ioc_status - ioc supplied status info
5323 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5325 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5326 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5329 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5330 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5333 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5334 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5339 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5462 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5464 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5465 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5469 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5470 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5472 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5473 pcie_device->slot); in _scsih_scsi_ioc_info()
5474 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5476 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5477 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5484 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5494 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5497 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5498 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5499 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5500 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5506 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5509 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5512 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5519 * _scsih_turn_on_pfa_led - illuminate PFA LED
5548 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5562 * _scsih_turn_off_pfa_led - turn off Fault LED
5578 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5580 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5599 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5612 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5613 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5614 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5620 * _scsih_smart_predicted_fault - process smart errors
5636 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5637 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5642 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5643 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5645 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5646 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5651 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5653 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5666 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5667 event_reply->Event = in _scsih_smart_predicted_fault()
5669 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5670 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5673 event_reply->EventData; in _scsih_smart_predicted_fault()
5674 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5675 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5676 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5677 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5686 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5691 * _scsih_io_done - scsi request callback
5728 scmd->result = DID_OK << 16; in _scsih_io_done()
5732 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5733 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5734 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5735 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5738 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5745 if (st->direct_io && in _scsih_io_done()
5748 st->direct_io = 0; in _scsih_io_done()
5749 st->scmd = scmd; in _scsih_io_done()
5750 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5751 mpi_request->DevHandle = in _scsih_io_done()
5752 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5753 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5754 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5758 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5761 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5762 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5763 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5764 if ((!ioc->is_warpdrive && in _scsih_io_done()
5765 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5766 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5767 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5769 sas_disable_tlr(scmd->device); in _scsih_io_done()
5770 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5774 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5775 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5777 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5781 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5795 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5796 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5797 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5801 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5804 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5805 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5806 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5807 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5813 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5817 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5821 if (sas_device_priv_data->block) { in _scsih_io_done()
5822 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5833 scmd->result = DID_IMM_RETRY << 16; in _scsih_io_done()
5837 if (scmd->retries > 2) { in _scsih_io_done()
5838 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5839 scsi_device_set_state(scmd->device, in _scsih_io_done()
5842 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5843 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5847 scmd->result = DID_RESET << 16; in _scsih_io_done()
5849 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5852 scmd->result = DID_RESET << 16; in _scsih_io_done()
5855 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5859 scmd->result = DID_RESET << 16; in _scsih_io_done()
5863 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5864 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5866 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5870 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5875 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5877 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5879 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5882 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5884 scmd->result = DID_RESET << 16; in _scsih_io_done()
5885 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5886 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5887 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5898 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5903 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5905 scmd->result = DID_RESET << 16; in _scsih_io_done()
5924 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5929 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5941 * _scsih_update_vphys_after_reset - update the Port's
5966 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5967 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5970 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5971 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5978 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_update_vphys_after_reset()
5994 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5998 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
6009 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6027 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6042 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6043 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6046 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6051 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6059 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6065 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6066 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6074 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6081 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6084 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6085 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6086 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6096 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6098 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6099 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6100 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6101 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6102 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6106 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6116 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6117 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6118 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6119 mport->flags &= in _scsih_update_vphys_after_reset()
6125 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6138 * _scsih_get_port_table_after_reset - Construct temporary port table
6156 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_get_port_table_after_reset()
6170 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6172 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6176 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6185 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6197 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6217 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6237 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6238 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6241 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6242 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6248 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6249 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6250 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6256 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6257 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6266 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6285 * _scsih_del_phy_part_of_anther_port - remove phy if it
6299 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6308 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6318 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6333 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6335 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6337 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6345 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6347 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6349 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6350 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6357 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6369 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6370 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6373 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6374 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6377 vphy, port->port_id, in _scsih_del_dirty_vphy()
6378 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6379 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6380 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6384 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6385 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6390 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6401 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6402 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6403 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6408 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6409 list_del(&port->list); in _scsih_del_dirty_port_entries()
6415 * _scsih_sas_port_refresh - Update HBA port table after host reset
6432 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6441 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6446 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6448 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6464 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6465 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6469 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6472 port_table_entry->port_id, in _scsih_sas_port_refresh()
6473 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6474 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6511 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6512 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6513 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6514 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6521 * _scsih_alloc_vphy - allocate virtual_phy object
6544 if (!port->vphys_mask) in _scsih_alloc_vphy()
6545 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6551 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6552 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6554 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6558 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6564 * _scsih_sas_host_refresh - refreshing sas host object contents
6587 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6589 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_refresh()
6603 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6604 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6606 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6607 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6608 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6614 port->port_id = port_id; in _scsih_sas_host_refresh()
6617 port, port->port_id); in _scsih_sas_host_refresh()
6618 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6619 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6620 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6625 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6644 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6651 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6665 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6667 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6668 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6671 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6672 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6676 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6678 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6680 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6686 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6687 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6688 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6689 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6692 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6700 * _scsih_sas_host_add - create sas host object
6703 * Creating host side data object, stored in ioc->sas_hba
6728 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6730 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6732 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6737 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6740 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6762 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6783 ioc->io_missing_delay = in _scsih_sas_host_add()
6784 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6786 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6788 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6791 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6794 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6795 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6811 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6814 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6820 port->port_id = port_id; in _scsih_sas_host_add()
6823 port, port->port_id); in _scsih_sas_host_add()
6824 list_add_tail(&port->list, in _scsih_sas_host_add()
6825 &ioc->port_table_list); in _scsih_sas_host_add()
6840 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6843 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6844 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6845 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6847 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6848 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6851 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6856 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6858 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6860 ioc->sas_hba.handle, in _scsih_sas_host_add()
6861 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6862 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6864 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6867 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6868 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6878 * _scsih_expander_add - creating expander object
6882 * Creating expander object, stored in ioc->sas_expander_list.
6905 return -1; in _scsih_expander_add()
6907 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6908 return -1; in _scsih_expander_add()
6914 return -1; in _scsih_expander_add()
6922 return -1; in _scsih_expander_add()
6931 return -1; in _scsih_expander_add()
6935 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6936 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6940 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6948 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6952 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6962 return -1; in _scsih_expander_add()
6965 sas_expander->handle = handle; in _scsih_expander_add()
6966 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6967 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6968 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6969 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6970 if (!sas_expander->port) { in _scsih_expander_add()
6973 rc = -1; in _scsih_expander_add()
6979 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6981 if (!sas_expander->num_phys) { in _scsih_expander_add()
6982 rc = -1; in _scsih_expander_add()
6985 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6987 if (!sas_expander->phy) { in _scsih_expander_add()
6990 rc = -1; in _scsih_expander_add()
6994 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6996 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7000 rc = -1; in _scsih_expander_add()
7003 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
7004 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
7006 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
7011 rc = -1; in _scsih_expander_add()
7014 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
7015 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
7016 sas_expander->phy[i].port = in _scsih_expander_add()
7020 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7021 sas_expander->parent_dev))) { in _scsih_expander_add()
7024 rc = -1; in _scsih_expander_add()
7029 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7032 sas_expander->enclosure_handle); in _scsih_expander_add()
7034 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7035 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7044 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7045 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7051 * mpt3sas_expander_remove - removing expander object
7063 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7069 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7072 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7078 * _scsih_done - internal SCSI_IO callback handler.
7085 * The callback index passed is `ioc->scsih_cb_idx`
7096 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7098 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7100 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7102 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7103 mpi_reply->MsgLength*4); in _scsih_done()
7104 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7106 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7107 complete(&ioc->scsih_cmds.done); in _scsih_done()
7118 * _scsih_check_access_status - check access flags
7181 * _scsih_check_device - checking device responsiveness
7223 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7234 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7235 starget = sas_device->starget; in _scsih_check_device()
7236 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7239 sas_device->handle, handle); in _scsih_check_device()
7240 sas_target_priv_data->handle = handle; in _scsih_check_device()
7241 sas_device->handle = handle; in _scsih_check_device()
7244 sas_device->enclosure_level = in _scsih_check_device()
7246 memcpy(sas_device->connector_name, in _scsih_check_device()
7248 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7250 sas_device->enclosure_level = 0; in _scsih_check_device()
7251 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7254 sas_device->enclosure_handle = in _scsih_check_device()
7256 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7258 sas_device->enclosure_handle); in _scsih_check_device()
7260 sas_device->enclosure_logical_id = in _scsih_check_device()
7261 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7262 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7264 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7265 sas_device->chassis_slot = in _scsih_check_device()
7266 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7284 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7292 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7298 * _scsih_add_device - creating sas device object
7304 * Creating end device object, stored in ioc->sas_device_list.
7306 * Return: 0 for success, non-zero for failure.
7325 return -1; in _scsih_add_device()
7333 return -1; in _scsih_add_device()
7339 return -1; in _scsih_add_device()
7340 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7348 return -1; in _scsih_add_device()
7354 return -1; in _scsih_add_device()
7360 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7362 return -1; in _scsih_add_device()
7382 kref_init(&sas_device->refcount); in _scsih_add_device()
7383 sas_device->handle = handle; in _scsih_add_device()
7386 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7389 sas_device->enclosure_handle = in _scsih_add_device()
7391 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7392 sas_device->slot = in _scsih_add_device()
7394 sas_device->device_info = device_info; in _scsih_add_device()
7395 sas_device->sas_address = sas_address; in _scsih_add_device()
7396 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7397 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7399 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7400 if (!sas_device->port) { in _scsih_add_device()
7408 sas_device->enclosure_level = in _scsih_add_device()
7410 memcpy(sas_device->connector_name, in _scsih_add_device()
7412 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7414 sas_device->enclosure_level = 0; in _scsih_add_device()
7415 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7418 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7420 sas_device->enclosure_logical_id = in _scsih_add_device()
7421 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7422 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7424 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7425 sas_device->chassis_slot = in _scsih_add_device()
7426 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7431 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7432 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7435 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7437 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7448 * _scsih_remove_device - removing sas device object
7458 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7459 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7461 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7467 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7472 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7473 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7474 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7475 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7476 sas_device->port); in _scsih_remove_device()
7477 sas_target_priv_data->handle = in _scsih_remove_device()
7481 if (!ioc->hide_drives) in _scsih_remove_device()
7483 sas_device->sas_address, in _scsih_remove_device()
7484 sas_device->sas_address_parent, in _scsih_remove_device()
7485 sas_device->port); in _scsih_remove_device()
7488 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7495 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7501 * _scsih_sas_topology_change_event_debug - debug for topology event
7517 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7538 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7539 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7540 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7541 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7542 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7545 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7546 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7568 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7569 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7578 * _scsih_sas_topology_change_event - handle topology changes
7599 fw_event->event_data; in _scsih_sas_topology_change_event()
7601 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7604 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7607 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7612 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7617 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7618 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7621 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7625 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7629 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7630 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7631 port = sas_expander->port; in _scsih_sas_topology_change_event()
7632 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7633 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7634 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7636 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7639 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7642 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7643 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7648 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7650 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7653 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7655 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7659 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7662 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7663 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7667 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7682 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7689 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7706 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7714 * _scsih_sas_device_status_change_event_debug - debug for device event
7725 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7770 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7771 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7772 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7773 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7775 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7780 * _scsih_sas_device_status_change_event - handle device status change
7797 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7800 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7802 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7806 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7807 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7810 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7812 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7815 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7819 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7821 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7823 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7825 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7828 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7829 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7835 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7840 * _scsih_check_pcie_access_status - check access flags
7928 * _scsih_pcie_device_remove_from_sml - removing pcie device
7929 * from SML and free up associated memory
7942 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7943 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7947 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7948 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7949 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7953 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7954 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7956 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7957 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7958 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7959 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7960 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7964 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7965 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7967 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7968 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7969 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7971 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7972 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7974 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7976 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7980 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7981 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7985 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7986 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7987 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7991 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7992 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7994 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7999 * _scsih_pcie_check_device - checking device responsiveness
8030 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8034 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8038 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8039 starget = pcie_device->starget; in _scsih_pcie_check_device()
8040 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8041 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8044 pcie_device->handle, handle); in _scsih_pcie_check_device()
8045 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8046 pcie_device->handle = handle; in _scsih_pcie_check_device()
8050 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8052 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8055 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8056 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8065 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8073 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8078 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8087 * _scsih_pcie_add_device - creating pcie device object
8091 * Creating end device object, stored in ioc->pcie_device_list.
8120 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8142 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8147 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8179 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8180 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8181 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8182 pcie_device->handle = handle; in _scsih_pcie_add_device()
8183 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8184 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8185 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8186 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8187 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8190 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8192 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8193 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8197 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8198 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8201 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8202 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8206 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8209 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8211 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8212 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8214 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8217 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8219 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8226 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8227 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8228 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8230 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8233 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8235 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8237 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8247 * _scsih_pcie_topology_change_event_debug - debug for topology
8264 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8285 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8286 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8287 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8288 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8290 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8293 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8294 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8315 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8317 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8326 * _scsih_pcie_topology_change_event - handle PCIe topology
8344 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8347 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8350 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8351 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8354 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8360 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8361 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8366 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8368 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8370 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8374 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8376 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8381 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8396 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8398 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8405 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8411 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8412 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8416 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8428 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8440 * _scsih_pcie_device_status_change_event_debug - debug for device event
8451 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8495 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8496 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8497 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8498 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8500 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8505 * _scsih_pcie_device_status_change_event - handle device status
8520 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8521 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8525 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8527 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8531 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8532 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8535 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8538 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8542 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8544 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8546 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8551 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8555 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8567 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8582 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8583 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8584 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8588 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8600 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8602 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8604 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8607 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8608 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8615 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8627 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8637 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8638 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8643 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8653 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8673 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8680 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8682 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8686 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8687 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8697 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8701 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8702 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8708 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8709 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8710 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8713 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8717 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8721 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8725 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8726 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8729 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8732 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8734 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8735 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8740 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8743 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8749 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8754 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8756 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8758 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8767 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8771 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8774 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8775 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8776 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8777 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8788 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8790 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8791 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8794 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8799 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8804 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8808 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8811 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8812 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8814 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8818 * _scsih_sas_discovery_event - handle discovery events
8828 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8830 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8832 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8834 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8836 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8840 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8841 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8842 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8844 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8852 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8863 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8865 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8868 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8869 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8870 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8874 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8875 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8876 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8884 * _scsih_pcie_enumeration_event - handle enumeration events
8894 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8896 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8900 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8902 event_data->Flags); in _scsih_pcie_enumeration_event()
8903 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8905 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8910 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8928 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8931 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8933 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8935 rc = -EAGAIN; in _scsih_ir_fastpath()
8938 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8940 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8943 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8944 rc = -EAGAIN; in _scsih_ir_fastpath()
8949 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8952 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8953 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8954 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8960 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8961 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8962 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8964 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8966 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8968 rc = -EFAULT; in _scsih_ir_fastpath()
8972 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8974 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8975 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8977 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8985 rc = -EFAULT; in _scsih_ir_fastpath()
8992 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8993 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
9001 * _scsih_reprobe_lun - reprobing lun
9003 * @no_uld_attach: sdev->no_uld_attach flag setting
9009 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
9011 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
9016 * _scsih_sas_volume_add - add new volume
9028 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
9038 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9040 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9052 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9053 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9054 raid_device->handle = handle; in _scsih_sas_volume_add()
9055 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9057 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9058 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9059 raid_device->id, 0); in _scsih_sas_volume_add()
9063 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9065 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9070 * _scsih_sas_volume_delete - delete volume
9083 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9086 if (raid_device->starget) { in _scsih_sas_volume_delete()
9087 starget = raid_device->starget; in _scsih_sas_volume_delete()
9088 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9089 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9092 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9093 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9096 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9098 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9102 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9115 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
9117 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9120 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9121 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9122 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9123 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9124 starget = sas_device->starget; in _scsih_sas_pd_expose()
9125 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9126 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9130 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9142 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9155 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
9164 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9167 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9168 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9169 starget = sas_device->starget; in _scsih_sas_pd_hide()
9170 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9171 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9173 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9174 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9177 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9182 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9191 * _scsih_sas_pd_delete - delete pd component
9200 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
9206 * _scsih_sas_pd_add - remove pd component
9216 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
9223 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9227 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9254 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9259 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9273 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9276 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9278 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9279 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9280 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9312 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9330 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9331 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9332 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9337 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9351 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9353 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9354 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9357 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9360 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9361 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9362 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9363 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9364 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9366 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9367 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9372 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9374 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9384 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9387 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9391 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9395 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9399 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9407 * _scsih_sas_ir_volume_event - IR volume event
9423 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9425 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9428 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9431 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9432 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9433 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9437 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9449 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9451 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9470 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9471 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9472 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9473 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9475 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9476 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9488 * _scsih_sas_ir_physical_disk_event - PD event
9504 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9507 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9510 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9513 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9514 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9516 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9520 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9530 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9531 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9575 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9586 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9609 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9610 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9614 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9625 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9630 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9631 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9636 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9638 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9639 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9642 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9643 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9644 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9649 * _scsih_prep_device_scan - initialize parameters prior to device scan
9661 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9662 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9663 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9664 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9669 * _scsih_update_device_qdepth - Update QD during Reset.
9683 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9684 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9685 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9686 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9687 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9688 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9689 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9691 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9692 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9693 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9695 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9696 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9705 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9722 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9724 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9727 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9730 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9732 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9733 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9734 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9735 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9737 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9739 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9741 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9742 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9743 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9744 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9745 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9746 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9752 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9754 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9756 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9760 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9761 sas_device->slot); in _scsih_mark_responding_sas_device()
9763 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9765 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9766 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9767 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9768 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9770 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9771 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9774 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9775 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9776 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9778 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9779 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9780 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9782 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9783 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9784 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9788 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9789 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9792 sas_device->handle); in _scsih_mark_responding_sas_device()
9793 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9794 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9796 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9797 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9801 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9805 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9831 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9840 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9841 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9843 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9848 * _scsih_search_responding_sas_devices -
9863 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9865 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9884 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9888 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9904 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9905 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9906 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9907 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9908 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9909 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9910 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9911 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9912 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9913 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9914 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9915 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9916 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9922 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9923 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9924 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9929 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9930 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9933 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9935 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9936 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9937 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9938 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9939 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9941 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9942 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9945 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9946 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9949 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9950 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9951 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9953 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9954 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9960 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9964 * _scsih_search_responding_pcie_devices -
9979 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9981 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
10003 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
10007 * _scsih_mark_responding_raid_device - mark a raid_device as responding
10024 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10025 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10026 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10027 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10028 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10029 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10030 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10033 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10034 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10035 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10037 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10041 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10045 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10046 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10047 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10052 raid_device->handle); in _scsih_mark_responding_raid_device()
10053 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10055 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10056 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10060 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10064 * _scsih_search_responding_raid_devices -
10081 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10086 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10111 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10113 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10123 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10131 * _scsih_mark_responding_expander - mark a expander as responding
10146 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
10147 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10148 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10150 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10157 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10158 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10159 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10161 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10163 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10166 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10167 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10168 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10169 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10172 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10176 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10177 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10178 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10179 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10180 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10184 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10188 * _scsih_search_responding_expanders -
10206 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10224 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10234 * _scsih_remove_unresponding_devices - removing unresponding devices
10251 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10253 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10256 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10263 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10264 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10269 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10270 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10271 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10273 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10275 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10282 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10286 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10288 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10294 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10295 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10300 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10301 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10302 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10304 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10306 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10310 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10315 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10318 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10319 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10321 raid_device->handle); in _scsih_remove_unresponding_devices()
10323 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10329 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10332 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10333 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10334 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10336 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10338 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10358 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10366 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10369 sas_expander->port); in _scsih_refresh_expander_links()
10374 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10417 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10422 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10439 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10485 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10517 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10520 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10638 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10649 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10660 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10661 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10662 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10663 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10665 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10666 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10667 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10668 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10671 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10672 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10673 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10679 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10688 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10689 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10704 * _mpt3sas_fw_work - delayed task for processing firmware events
10712 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10716 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10718 ioc->current_event = NULL; in _mpt3sas_fw_work()
10722 switch (fw_event->event) { in _mpt3sas_fw_work()
10726 fw_event->event_data); in _mpt3sas_fw_work()
10729 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10730 ioc->shost_recovery) { in _mpt3sas_fw_work()
10735 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10742 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10749 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10750 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10751 *- start the watchdog thread. in _mpt3sas_fw_work()
10755 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10760 ioc->start_scan = 0; in _mpt3sas_fw_work()
10761 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10768 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10774 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10777 fw_event->event_data); in _mpt3sas_fw_work()
10816 ioc->current_event = NULL; in _mpt3sas_fw_work()
10833 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10837 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10843 * This function merely adds a new work task into ioc->firmware_event_thread.
10860 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10871 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10882 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10884 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10888 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10889 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10892 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10899 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10908 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10914 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10915 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10921 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10926 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10933 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10937 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10938 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10940 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10952 …Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode. Check Warp… in mpt3sas_scsih_event_callback()
10964 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10978 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10982 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10983 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10986 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10991 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
10996 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
11008 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
11016 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
11017 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11018 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11019 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11020 fw_event->event = event; in mpt3sas_scsih_event_callback()
11027 * _scsih_expander_node_remove - removing expander device from list.
11032 * ioc->sas_expander_list.
11044 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11045 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11047 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11050 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11051 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11052 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11054 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11057 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11058 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11061 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11063 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11064 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11068 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11069 sas_expander->sas_address, in _scsih_expander_node_remove()
11072 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11073 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11074 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11076 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11081 * _scsih_nvme_shutdown - NVMe shutdown notification
11096 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11099 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11101 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11106 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11108 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11112 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11117 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11119 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11120 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11122 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11123 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11127 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11128 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11129 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11131 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11136 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11137 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11140 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11141 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11144 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11145 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11150 * _scsih_ir_shutdown - IR shutdown notification
11164 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11168 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11171 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11173 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11177 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11179 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11182 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11187 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11190 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11191 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11193 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11195 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11196 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11197 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11199 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11204 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11205 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11206 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11208 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11209 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11213 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11214 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11218 * _scsih_get_shost_and_ioc - get shost and ioc
11232 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11233 return -ENXIO; in _scsih_get_shost_and_ioc()
11238 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11239 return -ENXIO; in _scsih_get_shost_and_ioc()
11246 * scsih_remove - detach and remove add host
11267 ioc->remove_host = 1; in scsih_remove()
11276 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11277 wq = ioc->firmware_event_thread; in scsih_remove()
11278 ioc->firmware_event_thread = NULL; in scsih_remove()
11279 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11286 if (ioc->is_aero_ioc) in scsih_remove()
11288 &ioc->ioc_pg1_copy); in scsih_remove()
11293 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11295 if (raid_device->starget) { in scsih_remove()
11297 raid_device->starget->hostdata; in scsih_remove()
11298 sas_target_priv_data->deleted = 1; in scsih_remove()
11299 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11302 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11305 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11308 list_del_init(&pcie_device->list); in scsih_remove()
11314 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11315 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11318 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11319 mpt3sas_port->hba_port); in scsih_remove()
11320 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11322 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11325 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11326 mpt3sas_port->hba_port); in scsih_remove()
11330 &ioc->port_table_list, list) { in scsih_remove()
11331 list_del(&port->list); in scsih_remove()
11336 if (ioc->sas_hba.num_phys) { in scsih_remove()
11337 kfree(ioc->sas_hba.phy); in scsih_remove()
11338 ioc->sas_hba.phy = NULL; in scsih_remove()
11339 ioc->sas_hba.num_phys = 0; in scsih_remove()
11345 list_del(&ioc->list); in scsih_remove()
11351 * scsih_shutdown - routine call during system shutdown
11366 ioc->remove_host = 1; in scsih_shutdown()
11375 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11376 wq = ioc->firmware_event_thread; in scsih_shutdown()
11377 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11378 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11385 if (ioc->is_aero_ioc) in scsih_shutdown()
11387 &ioc->ioc_pg1_copy); in scsih_shutdown()
11393 ioc->shost_recovery = 1; in scsih_shutdown()
11395 ioc->shost_recovery = 0; in scsih_shutdown()
11402 * _scsih_probe_boot_devices - reports 1st device
11406 * device scsi-ml or sas transport for persistent boot device
11426 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11430 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11431 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11432 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11433 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11434 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11435 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11436 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11437 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11438 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11447 * If this boot vd is already registered with SML then in _scsih_probe_boot_devices()
11451 if (raid_device->starget) in _scsih_probe_boot_devices()
11453 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11454 raid_device->id, 0); in _scsih_probe_boot_devices()
11460 * If this boot NVMe device is already registered with SML then in _scsih_probe_boot_devices()
11464 if (pcie_device->starget) in _scsih_probe_boot_devices()
11466 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11467 tid = pcie_device->id; in _scsih_probe_boot_devices()
11468 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11469 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11470 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11476 * If this boot sas/sata device is already registered with SML in _scsih_probe_boot_devices()
11480 if (sas_device->starget) in _scsih_probe_boot_devices()
11482 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11483 handle = sas_device->handle; in _scsih_probe_boot_devices()
11484 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11485 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11486 port = sas_device->port; in _scsih_probe_boot_devices()
11487 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11488 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11490 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11499 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11500 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11511 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11523 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11524 if (raid_device->starget) in _scsih_probe_raid()
11526 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11527 raid_device->id, 0); in _scsih_probe_raid()
11538 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11539 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11540 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11544 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11554 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11564 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11565 list_del_init(&sas_device->list); in sas_device_make_active()
11570 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11572 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11576 * _scsih_probe_sas - reporting sas devices to sas transport
11586 if (ioc->hide_drives) in _scsih_probe_sas()
11590 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11591 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11595 } else if (!sas_device->starget) { in _scsih_probe_sas()
11599 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11602 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11604 sas_device->sas_address, in _scsih_probe_sas()
11605 sas_device->sas_address_parent, in _scsih_probe_sas()
11606 sas_device->port); in _scsih_probe_sas()
11618 * get_next_pcie_device - Get the next pcie device
11631 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11632 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11633 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11637 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11643 * pcie_device_make_active - Add pcie device to pcie_device_list list
11655 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11657 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11658 list_del_init(&pcie_device->list); in pcie_device_make_active()
11662 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11664 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11668 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11681 if (pcie_device->starget) { in _scsih_probe_pcie()
11685 if (pcie_device->access_status == in _scsih_probe_pcie()
11691 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11692 pcie_device->id, 0); in _scsih_probe_pcie()
11697 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11701 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11704 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11705 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11719 * _scsih_probe_devices - probing for devices
11729 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11734 if (ioc->ir_firmware) { in _scsih_probe_devices()
11736 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11753 * scsih_scan_start - scsi lld callback for .scan_start
11765 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11767 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11773 ioc->start_scan = 1; in scsih_scan_start()
11781 * _scsih_complete_devices_scanning - add the devices to sml and
11790 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11791 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11796 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11800 * scsih_scan_finished - scsi lld callback for .scan_finished
11816 ioc->is_driver_loading = 0; in scsih_scan_finished()
11817 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11822 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11824 ioc->is_driver_loading = 0; in scsih_scan_finished()
11828 if (ioc->start_scan) { in scsih_scan_finished()
11846 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11849 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11852 if (ioc->start_scan_failed) { in scsih_scan_finished()
11854 ioc->start_scan_failed); in scsih_scan_finished()
11855 ioc->is_driver_loading = 0; in scsih_scan_finished()
11856 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11857 ioc->remove_host = 1; in scsih_scan_finished()
11862 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11867 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11869 ioc->is_driver_loading = 0; in scsih_scan_finished()
11875 * scsih_map_queues - map reply queues with request queues
11881 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11884 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11885 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11887 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11890 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11891 map = &shost->tag_set.map[i]; in scsih_map_queues()
11892 map->nr_queues = 0; in scsih_map_queues()
11895 map->nr_queues = in scsih_map_queues()
11896 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11897 offset = ioc->high_iops_queues; in scsih_map_queues()
11899 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11901 if (!map->nr_queues) in scsih_map_queues()
11906 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11908 map->queue_offset = qoff; in scsih_map_queues()
11910 blk_mq_map_hw_queues(map, &ioc->pdev->dev, offset); in scsih_map_queues()
11914 qoff += map->nr_queues; in scsih_map_queues()
11938 .this_id = -1,
11976 .this_id = -1,
11998 * _scsih_determine_hba_mpi_version - determine in which MPI version class
12010 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12070 * _scsih_probe - attach and add scsi host
12088 return -ENODEV; in _scsih_probe()
12091 * for other generation HBA's return with -ENODEV in _scsih_probe()
12094 return -ENODEV; in _scsih_probe()
12097 * for other generation HBA's return with -ENODEV in _scsih_probe()
12101 return -ENODEV; in _scsih_probe()
12111 return -ENODEV; in _scsih_probe()
12114 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12115 ioc->id = mpt2_ids++; in _scsih_probe()
12116 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12117 switch (pdev->device) { in _scsih_probe()
12119 ioc->is_warpdrive = 1; in _scsih_probe()
12120 ioc->hide_ir_msg = 1; in _scsih_probe()
12124 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12127 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12131 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12132 ioc->multipath_on_hba = 0; in _scsih_probe()
12134 ioc->multipath_on_hba = 1; in _scsih_probe()
12143 return -ENODEV; in _scsih_probe()
12146 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12147 ioc->id = mpt3_ids++; in _scsih_probe()
12148 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12149 switch (pdev->device) { in _scsih_probe()
12158 ioc->is_gen35_ioc = 1; in _scsih_probe()
12162 dev_err(&pdev->dev, in _scsih_probe()
12164 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12165 pdev->subsystem_device); in _scsih_probe()
12169 dev_err(&pdev->dev, in _scsih_probe()
12171 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12172 pdev->subsystem_device); in _scsih_probe()
12176 dev_info(&pdev->dev, in _scsih_probe()
12181 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12184 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12186 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12187 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12188 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12189 ioc->combined_reply_queue = 1; in _scsih_probe()
12190 if (ioc->is_gen35_ioc) in _scsih_probe()
12191 ioc->combined_reply_index_count = in _scsih_probe()
12194 ioc->combined_reply_index_count = in _scsih_probe()
12198 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12200 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12201 ioc->multipath_on_hba = 0; in _scsih_probe()
12203 ioc->multipath_on_hba = 1; in _scsih_probe()
12206 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12207 ioc->multipath_on_hba = 1; in _scsih_probe()
12209 ioc->multipath_on_hba = 0; in _scsih_probe()
12217 return -ENODEV; in _scsih_probe()
12220 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12222 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12224 ioc->shost = shost; in _scsih_probe()
12225 ioc->pdev = pdev; in _scsih_probe()
12226 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12227 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12228 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12229 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12230 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12231 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12232 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12233 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12234 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12235 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12236 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12237 ioc->logging_level = logging_level; in _scsih_probe()
12238 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12240 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12244 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12246 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12248 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12251 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12252 mutex_init(&ioc->hostdiag_unlock_mutex); in _scsih_probe()
12254 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12255 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12256 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12257 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12258 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12259 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12260 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12261 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12262 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12264 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12265 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12266 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12267 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12268 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12269 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12270 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12271 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12272 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12273 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12274 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12275 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12276 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12277 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12278 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12280 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12283 shost->max_cmd_len = 32; in _scsih_probe()
12284 shost->max_lun = max_lun; in _scsih_probe()
12285 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12286 shost->unique_id = ioc->id; in _scsih_probe()
12288 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12290 shost->max_sectors = 128; in _scsih_probe()
12292 shost->max_sectors); in _scsih_probe()
12296 shost->max_sectors = 64; in _scsih_probe()
12300 shost->max_sectors = 32767; in _scsih_probe()
12304 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12306 shost->max_sectors); in _scsih_probe()
12321 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12322 "fw_event_%s%d", 0, ioc->driver_name, ioc->id); in _scsih_probe()
12323 if (!ioc->firmware_event_thread) { in _scsih_probe()
12326 rv = -ENODEV; in _scsih_probe()
12330 shost->host_tagset = 0; in _scsih_probe()
12332 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12333 shost->host_tagset = 1; in _scsih_probe()
12335 ioc->is_driver_loading = 1; in _scsih_probe()
12339 rv = -ENODEV; in _scsih_probe()
12343 if (ioc->is_warpdrive) { in _scsih_probe()
12344 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12345 ioc->hide_drives = 0; in _scsih_probe()
12346 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12347 ioc->hide_drives = 1; in _scsih_probe()
12350 ioc->hide_drives = 1; in _scsih_probe()
12352 ioc->hide_drives = 0; in _scsih_probe()
12355 ioc->hide_drives = 0; in _scsih_probe()
12357 shost->nr_hw_queues = 1; in _scsih_probe()
12359 if (shost->host_tagset) { in _scsih_probe()
12360 shost->nr_hw_queues = in _scsih_probe()
12361 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12364 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12366 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12368 dev_info(&ioc->pdev->dev, in _scsih_probe()
12370 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12373 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12386 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12389 list_del(&ioc->list); in _scsih_probe()
12396 * scsih_suspend - power management suspend main entry point
12424 * scsih_resume - power management resume main entry point
12435 pci_power_t device_state = pdev->current_state; in scsih_resume()
12445 ioc->pdev = pdev; in scsih_resume()
12457 * scsih_pci_error_detected - Called when a PCI error is detected.
12481 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12482 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12488 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12498 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12517 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12518 ioc->pdev = pdev; in scsih_pci_slot_reset()
12537 * scsih_pci_resume() - resume normal ops after PCI reset
12556 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12560 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12574 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12751 * scsih_init - main entry point for this driver.
12802 * scsih_exit - exit point for this driver (when it is a module).
12833 * _mpt3sas_init - main entry point for this driver.
12848 return -ENODEV; in _mpt3sas_init()
12858 return -ENODEV; in _mpt3sas_init()
12870 return -ENODEV; in _mpt3sas_init()
12892 * _mpt3sas_exit - exit point for this driver (when it is a module).