Lines Matching +full:alert +full:- +full:celsius
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;
168 * struct sense_info - common structure for obtaining sense keys
185 * struct fw_event_work - firmware event struct
187 * @work: work object (ioc->fault_reset_work_q)
197 * This object stored on ioc->fw_event_list.
220 kref_get(&fw_work->refcount); in fw_event_work_get()
225 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
236 kref_init(&fw_event->refcount); in alloc_fw_event_work()
241 * struct _scsi_io_transfer - scsi io transfer
289 * _scsih_set_debug_level - global setting of ioc->logging_level.
307 ioc->logging_level = logging_level; in _scsih_set_debug_level()
315 * _scsih_srch_boot_sas_address - search based on sas_address
325 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
329 * _scsih_srch_boot_device_name - search based on device name
339 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
343 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
354 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
355 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
360 * _scsih_is_boot_device - search for matching boot device.
382 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
389 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
395 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
405 * _scsih_get_sas_address - set the sas_address for given device handle
410 * Return: 0 success, non-zero when failure
426 return -ENXIO; in _scsih_get_sas_address()
434 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
437 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
445 return -ENXIO; in _scsih_get_sas_address()
450 return -EIO; in _scsih_get_sas_address()
454 * _scsih_determine_boot_device - determine boot device.
460 * to scsi-ml or sas transport, this purpose is for persistent boot device.
479 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
483 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
488 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
494 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
500 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
501 device_name = sas_device->device_name; in _scsih_determine_boot_device()
502 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
503 slot = sas_device->slot; in _scsih_determine_boot_device()
506 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
509 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
511 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
515 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
516 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
520 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
523 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
525 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
529 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
530 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
534 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
537 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
539 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
543 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
544 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
555 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
557 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
571 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
573 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
584 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
586 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
594 * mpt3sas_get_pdev_from_target - pcie device search
598 * Context: This function will acquire ioc->pcie_device_lock and will release
610 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
612 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
623 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
625 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_addr()
626 if (sas_device->sas_address == sas_address) in __mpt3sas_get_sdev_by_addr()
629 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_addr()
630 if (sas_device->sas_address == sas_address) in __mpt3sas_get_sdev_by_addr()
641 * mpt3sas_get_sdev_by_addr - sas device search
644 * Context: Calling function should acquire ioc->sas_device_lock
656 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
659 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
669 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
671 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
672 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
675 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
676 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
687 * mpt3sas_get_sdev_by_handle - sas device search
690 * Context: Calling function should acquire ioc->sas_device_lock
701 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
703 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
709 * _scsih_display_enclosure_chassis_info - display device location info
721 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
725 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
726 sas_device->slot); in _scsih_display_enclosure_chassis_info()
727 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
730 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
731 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
732 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
734 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
736 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
740 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
741 sas_device->slot); in _scsih_display_enclosure_chassis_info()
742 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
745 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
746 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
747 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
750 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
752 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
754 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
755 sas_device->slot); in _scsih_display_enclosure_chassis_info()
756 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
758 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
759 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
760 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
762 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
767 * _scsih_sas_device_remove - remove sas_device from list.
770 * Context: This function will acquire ioc->sas_device_lock.
783 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
791 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
792 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
793 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
796 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
800 * _scsih_device_remove_by_handle - removing device object by handle
810 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
813 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
816 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
819 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
827 * mpt3sas_device_remove_by_sas_address - removing device object by sas address
838 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
841 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
844 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
847 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
855 * _scsih_sas_device_add - insert sas_device to the list.
858 * Context: This function will acquire ioc->sas_device_lock.
860 * Adding new object to the ioc->sas_device_list.
870 __func__, sas_device->handle, in _scsih_sas_device_add()
871 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
876 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
878 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
879 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
881 if (ioc->hide_drives) { in _scsih_sas_device_add()
882 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
886 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
887 sas_device->sas_address_parent)) { in _scsih_sas_device_add()
889 } else if (!sas_device->starget) { in _scsih_sas_device_add()
893 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
895 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
897 sas_device->sas_address, in _scsih_sas_device_add()
898 sas_device->sas_address_parent); in _scsih_sas_device_add()
902 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
906 * _scsih_sas_device_init_add - insert sas_device to the list.
909 * Context: This function will acquire ioc->sas_device_lock.
911 * Adding new object at driver load time to the ioc->sas_device_init_list.
921 __func__, sas_device->handle, in _scsih_sas_device_init_add()
922 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
927 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
929 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
931 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
940 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
942 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
943 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
946 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
947 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
959 * mpt3sas_get_pdev_by_wwid - pcie device search
963 * Context: This function will acquire ioc->pcie_device_lock and will release
974 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
976 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
988 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
990 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
991 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
994 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
995 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1010 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1012 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1013 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1016 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1017 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1029 * mpt3sas_get_pdev_by_handle - pcie device search
1033 * Context: This function will acquire ioc->pcie_device_lock and will release
1045 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1047 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1053 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1055 * Context: This function will acquire ioc->pcie_device_lock
1057 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1068 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1069 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1070 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1071 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1073 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1076 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1077 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1081 * _scsih_pcie_device_remove - remove pcie_device from list.
1084 * Context: This function will acquire ioc->pcie_device_lock.
1099 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1100 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1102 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1103 pcie_device->slot); in _scsih_pcie_device_remove()
1104 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1106 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1107 pcie_device->connector_name); in _scsih_pcie_device_remove()
1109 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1110 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1111 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1114 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1116 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1118 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1133 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1145 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1148 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1151 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1152 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1156 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1159 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1175 * _scsih_pcie_device_add - add pcie_device object
1190 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1191 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1195 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1196 pcie_device->slot)); in _scsih_pcie_device_add()
1197 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1200 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1201 pcie_device->connector_name)); in _scsih_pcie_device_add()
1203 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1205 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1206 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1208 if (pcie_device->access_status == in _scsih_pcie_device_add()
1210 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1213 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1215 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1216 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1217 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1218 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1221 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1225 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1228 * Context: This function will acquire ioc->pcie_device_lock.
1230 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1241 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1242 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1246 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1247 pcie_device->slot)); in _scsih_pcie_device_init_add()
1248 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1251 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1252 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1254 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1256 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1257 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1260 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1263 * _scsih_raid_device_find_by_id - raid device search
1267 * Context: Calling function should acquire ioc->raid_device_lock
1278 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1279 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1290 * mpt3sas_raid_device_find_by_handle - raid device search
1293 * Context: Calling function should acquire ioc->raid_device_lock
1304 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1305 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1316 * _scsih_raid_device_find_by_wwid - raid device search
1319 * Context: Calling function should acquire ioc->raid_device_lock
1330 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1331 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1342 * _scsih_raid_device_add - add raid_device object
1357 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1359 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1360 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1361 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1365 * _scsih_raid_device_remove - delete raid_device object
1376 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1377 list_del(&raid_device->list); in _scsih_raid_device_remove()
1379 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1383 * mpt3sas_scsih_expander_find_by_handle - expander device search
1386 * Context: Calling function should acquire ioc->sas_device_lock
1397 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1398 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1408 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1411 * Context: Calling function should acquire ioc->sas_device_lock
1422 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1423 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1432 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1435 * Context: Calling function should acquire ioc->sas_node_lock.
1447 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1448 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1458 * _scsih_expander_node_add - insert expander device to the list.
1461 * Context: This function will acquire ioc->sas_node_lock.
1463 * Adding new object to the ioc->sas_expander_list.
1471 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1472 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1473 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1477 * _scsih_is_end_device - determines if device is an end device
1496 * _scsih_is_nvme_pciescsi_device - determines if
1516 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1520 * Context: This function will acquire ioc->scsi_lookup_lock.
1533 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1537 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1538 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1545 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1550 * Context: This function will acquire ioc->scsi_lookup_lock.
1562 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1567 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1568 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1569 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1576 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1591 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1592 u32 unique_tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1598 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1602 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1605 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1608 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1616 * scsih_change_queue_depth - setting device queue depth
1625 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1633 max_depth = shost->can_queue; in scsih_change_queue_depth()
1639 if (ioc->enable_sdev_max_qd) in scsih_change_queue_depth()
1642 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1645 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1648 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1651 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1654 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1659 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1663 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1670 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1671 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1672 return sdev->queue_depth; in scsih_change_queue_depth()
1676 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1685 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1688 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1689 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1695 * scsih_target_alloc - target add routine
1704 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1716 return -ENOMEM; in scsih_target_alloc()
1718 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1719 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1720 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1723 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1724 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1725 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1726 starget->channel); in scsih_target_alloc()
1728 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1729 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1730 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1731 if (ioc->is_warpdrive) in scsih_target_alloc()
1732 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1733 raid_device->starget = starget; in scsih_target_alloc()
1735 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1740 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1741 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1742 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1743 starget->channel); in scsih_target_alloc()
1745 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1746 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1747 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1748 pcie_device->starget = starget; in scsih_target_alloc()
1749 pcie_device->id = starget->id; in scsih_target_alloc()
1750 pcie_device->channel = starget->channel; in scsih_target_alloc()
1751 sas_target_priv_data->flags |= in scsih_target_alloc()
1753 if (pcie_device->fast_path) in scsih_target_alloc()
1754 sas_target_priv_data->flags |= in scsih_target_alloc()
1757 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1762 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1763 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1765 rphy->identify.sas_address); in scsih_target_alloc()
1768 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1769 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1770 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1771 sas_device->starget = starget; in scsih_target_alloc()
1772 sas_device->id = starget->id; in scsih_target_alloc()
1773 sas_device->channel = starget->channel; in scsih_target_alloc()
1774 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1775 sas_target_priv_data->flags |= in scsih_target_alloc()
1777 if (sas_device->fast_path) in scsih_target_alloc()
1778 sas_target_priv_data->flags |= in scsih_target_alloc()
1781 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1787 * scsih_target_destroy - target destroy routine
1793 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1801 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1805 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1806 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1807 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1808 starget->channel); in scsih_target_destroy()
1810 raid_device->starget = NULL; in scsih_target_destroy()
1811 raid_device->sdev = NULL; in scsih_target_destroy()
1813 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1817 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1818 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1821 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1822 (pcie_device->id == starget->id) && in scsih_target_destroy()
1823 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1824 pcie_device->starget = NULL; in scsih_target_destroy()
1830 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
1834 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1838 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
1840 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
1841 (sas_device->id == starget->id) && in scsih_target_destroy()
1842 (sas_device->channel == starget->channel)) in scsih_target_destroy()
1843 sas_device->starget = NULL; in scsih_target_destroy()
1849 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
1854 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
1858 starget->hostdata = NULL; in scsih_target_destroy()
1862 * scsih_slave_alloc - device add routine
1884 return -ENOMEM; in scsih_slave_alloc()
1886 sas_device_priv_data->lun = sdev->lun; in scsih_slave_alloc()
1887 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_slave_alloc()
1890 sas_target_priv_data = starget->hostdata; in scsih_slave_alloc()
1891 sas_target_priv_data->num_luns++; in scsih_slave_alloc()
1892 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_slave_alloc()
1893 sdev->hostdata = sas_device_priv_data; in scsih_slave_alloc()
1894 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_slave_alloc()
1895 sdev->no_uld_attach = 1; in scsih_slave_alloc()
1897 shost = dev_to_shost(&starget->dev); in scsih_slave_alloc()
1899 if (starget->channel == RAID_CHANNEL) { in scsih_slave_alloc()
1900 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
1902 starget->id, starget->channel); in scsih_slave_alloc()
1904 raid_device->sdev = sdev; /* raid is single lun */ in scsih_slave_alloc()
1905 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
1907 if (starget->channel == PCIE_CHANNEL) { in scsih_slave_alloc()
1908 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
1910 sas_target_priv_data->sas_address); in scsih_slave_alloc()
1911 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_slave_alloc()
1913 "%s : pcie_device->starget set to starget @ %d\n", in scsih_slave_alloc()
1915 pcie_device->starget = starget; in scsih_slave_alloc()
1920 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
1922 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_alloc()
1923 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
1925 sas_target_priv_data->sas_address); in scsih_slave_alloc()
1926 if (sas_device && (sas_device->starget == NULL)) { in scsih_slave_alloc()
1928 "%s : sas_device->starget set to starget @ %d\n", in scsih_slave_alloc()
1930 sas_device->starget = starget; in scsih_slave_alloc()
1936 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
1943 * scsih_slave_destroy - device destroy routine
1957 if (!sdev->hostdata) in scsih_slave_destroy()
1961 sas_target_priv_data = starget->hostdata; in scsih_slave_destroy()
1962 sas_target_priv_data->num_luns--; in scsih_slave_destroy()
1964 shost = dev_to_shost(&starget->dev); in scsih_slave_destroy()
1967 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_destroy()
1968 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
1971 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
1972 pcie_device->starget = NULL; in scsih_slave_destroy()
1977 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
1979 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_destroy()
1980 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
1983 if (sas_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
1984 sas_device->starget = NULL; in scsih_slave_destroy()
1988 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
1991 kfree(sdev->hostdata); in scsih_slave_destroy()
1992 sdev->hostdata = NULL; in scsih_slave_destroy()
1996 * _scsih_display_sata_capabilities - sata capabilities
2042 * raid transport support -
2044 * unloading the driver followed by a load - I believe that the subroutine
2049 * scsih_is_raid - return boolean indicating device is raid volume
2056 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2058 if (ioc->is_warpdrive) in scsih_is_raid()
2060 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2068 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2072 * scsih_get_resync - get raid volume resync percent complete
2079 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2090 if (ioc->is_warpdrive) in scsih_get_resync()
2093 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2094 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2095 sdev->channel); in scsih_get_resync()
2097 handle = raid_device->handle; in scsih_get_resync()
2098 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2100 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2121 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2133 * scsih_get_state - get raid volume level
2140 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2149 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2150 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2151 sdev->channel); in scsih_get_state()
2153 handle = raid_device->handle; in scsih_get_state()
2154 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2187 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2199 * _scsih_set_level - set raid level
2225 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2228 &sdev->sdev_gendev, level); in _scsih_set_level()
2233 &sdev->sdev_gendev, level); in _scsih_set_level()
2240 * _scsih_get_volume_capabilities - volume capabilities
2257 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2265 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2277 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2285 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2292 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2296 raid_device->device_info = in _scsih_get_volume_capabilities()
2306 * _scsih_enable_tlr - setting TLR flags
2319 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2322 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2333 * scsih_slave_configure - device configure routine.
2342 struct Scsi_Host *shost = sdev->host; in scsih_slave_configure()
2358 sas_device_priv_data = sdev->hostdata; in scsih_slave_configure()
2359 sas_device_priv_data->configured_lun = 1; in scsih_slave_configure()
2360 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_slave_configure()
2361 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_slave_configure()
2362 handle = sas_target_priv_data->handle; in scsih_slave_configure()
2365 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_slave_configure()
2367 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2369 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2394 if (raid_device->device_info & in scsih_slave_configure()
2400 if (raid_device->device_info & in scsih_slave_configure()
2407 switch (raid_device->volume_type) { in scsih_slave_configure()
2413 if (ioc->manu_pg10.OEMIdentifier && in scsih_slave_configure()
2414 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_slave_configure()
2416 !(raid_device->num_pds % 2)) in scsih_slave_configure()
2436 if (!ioc->hide_ir_msg) in scsih_slave_configure()
2440 r_level, raid_device->handle, in scsih_slave_configure()
2441 (unsigned long long)raid_device->wwid, in scsih_slave_configure()
2442 raid_device->num_pds, ds); in scsih_slave_configure()
2444 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_slave_configure()
2445 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2455 if (!ioc->is_warpdrive) in scsih_slave_configure()
2456 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_slave_configure()
2460 /* non-raid handling */ in scsih_slave_configure()
2461 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_slave_configure()
2479 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_configure()
2480 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2482 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2484 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2495 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_slave_configure()
2496 pcie_device->port_num); in scsih_slave_configure()
2497 if (pcie_device->enclosure_handle != 0) in scsih_slave_configure()
2501 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_slave_configure()
2502 pcie_device->slot); in scsih_slave_configure()
2503 if (pcie_device->connector_name[0] != '\0') in scsih_slave_configure()
2507 pcie_device->enclosure_level, in scsih_slave_configure()
2508 pcie_device->connector_name); in scsih_slave_configure()
2510 if (pcie_device->nvme_mdts) in scsih_slave_configure()
2511 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2512 pcie_device->nvme_mdts/512); in scsih_slave_configure()
2515 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2522 sdev->request_queue); in scsih_slave_configure()
2523 blk_queue_virt_boundary(sdev->request_queue, in scsih_slave_configure()
2524 ioc->page_size - 1); in scsih_slave_configure()
2528 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2530 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2532 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2539 sas_device->volume_handle = volume_handle; in scsih_slave_configure()
2540 sas_device->volume_wwid = volume_wwid; in scsih_slave_configure()
2541 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_slave_configure()
2544 if (sas_device->device_info & in scsih_slave_configure()
2548 sas_device_priv_data->sas_target->handle); in scsih_slave_configure()
2549 sas_device_priv_data->ignore_delay_remove = 1; in scsih_slave_configure()
2555 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_slave_configure()
2557 else if (sas_device->device_info & in scsih_slave_configure()
2564 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_slave_configure()
2565 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_slave_configure()
2570 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2587 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2633 * _scsih_response_code - translation of device response code
2675 * _scsih_tm_done - tm completion routine
2692 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2694 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2696 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2699 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2700 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2702 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2703 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2708 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2721 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2724 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2727 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2728 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2730 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2736 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2749 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2752 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2755 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2756 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2758 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2764 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2765 * @ioc - per adapter object
2766 * @channel - the channel assigned by the OS
2780 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2796 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2797 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2798 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2800 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2801 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2802 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2810 * scsih_tm_post_processing - post processing of target & LUN reset
2811 * @ioc - per adapter object
2813 * @channel - the channel assigned by the OS
2854 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
2869 * The callback index is set inside `ioc->tm_cb_idx`.
2887 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
2889 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
2894 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
2895 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
2920 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
2929 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
2931 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
2933 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
2934 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
2935 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
2936 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
2939 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
2940 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
2941 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
2943 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
2944 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
2945 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
2946 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
2948 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
2961 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
2963 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
2966 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
2967 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
2968 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
2969 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
2970 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
2971 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
2992 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3017 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3027 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3030 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3036 * _scsih_tm_display_info - displays info about the device
3045 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3046 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3054 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3060 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3063 device_str, priv_target->handle, in _scsih_tm_display_info()
3064 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3066 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3067 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3072 pcie_device->handle, in _scsih_tm_display_info()
3073 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3074 pcie_device->port_num); in _scsih_tm_display_info()
3075 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3079 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3080 pcie_device->slot); in _scsih_tm_display_info()
3081 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3084 pcie_device->enclosure_level, in _scsih_tm_display_info()
3085 pcie_device->connector_name); in _scsih_tm_display_info()
3088 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3091 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3094 if (priv_target->flags & in _scsih_tm_display_info()
3099 sas_device->volume_handle, in _scsih_tm_display_info()
3100 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3104 sas_device->handle, in _scsih_tm_display_info()
3105 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3106 sas_device->phy); in _scsih_tm_display_info()
3113 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3118 * scsih_abort - eh threads main abort routine
3126 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3134 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3136 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3137 (scmd->request->timeout / HZ) * 1000); in scsih_abort()
3140 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3141 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3142 ioc->remove_host) { in scsih_abort()
3143 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3145 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3146 scmd->scsi_done(scmd); in scsih_abort()
3152 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3153 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3155 scmd->result = DID_RESET << 16; in scsih_abort()
3161 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3163 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3164 scmd->result = DID_RESET << 16; in scsih_abort()
3171 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3173 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3174 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3175 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3176 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3177 scmd->device->id, scmd->device->lun, in scsih_abort()
3179 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3181 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3184 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3192 * scsih_dev_reset - eh threads main device reset routine
3200 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3209 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3210 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3212 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3216 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3217 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3218 ioc->remove_host) { in scsih_dev_reset()
3219 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3221 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3222 scmd->scsi_done(scmd); in scsih_dev_reset()
3229 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3234 handle = sas_device->volume_handle; in scsih_dev_reset()
3236 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3239 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3246 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3247 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3248 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3253 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3254 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3258 if (r == SUCCESS && atomic_read(&scmd->device->device_busy)) in scsih_dev_reset()
3261 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3273 * scsih_target_reset - eh threads main target reset routine
3281 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3289 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3290 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3296 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3297 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3298 ioc->remove_host) { in scsih_target_reset()
3301 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3302 scmd->scsi_done(scmd); in scsih_target_reset()
3309 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3314 handle = sas_device->volume_handle; in scsih_target_reset()
3316 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3319 scmd->result = DID_RESET << 16; in scsih_target_reset()
3326 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3327 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3328 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3332 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3333 scmd->device->id, 0, in scsih_target_reset()
3337 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3352 * scsih_host_reset - eh threads main host reset routine
3360 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3366 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3382 * _scsih_fw_event_add - insert and queue up fw_event
3385 * Context: This function will acquire ioc->fw_event_lock.
3395 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3398 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3400 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3401 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3402 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3404 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3405 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3409 * _scsih_fw_event_del_from_list - delete fw_event from the list
3412 * Context: This function will acquire ioc->fw_event_lock.
3422 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3423 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3424 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3427 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3432 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3443 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3449 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3450 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3451 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3457 * _scsih_error_recovery_delete_devices - remove devices not responding
3465 if (ioc->is_driver_loading) in _scsih_error_recovery_delete_devices()
3470 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3471 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3477 * mpt3sas_port_enable_complete - port enable completed (fake event)
3488 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3489 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3499 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3500 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3501 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3503 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3505 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3511 * _scsih_fw_event_cleanup_queue - cleanup event queue
3522 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3523 !ioc->firmware_event_thread || in_interrupt()) in _scsih_fw_event_cleanup_queue()
3526 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3528 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3537 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3542 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3546 * _scsih_internal_device_block - block the sdev device
3560 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3561 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3564 if (r == -EINVAL) in _scsih_internal_device_block()
3567 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3571 * _scsih_internal_device_unblock - unblock the sdev device
3585 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3586 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3588 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3597 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3598 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3603 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3605 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3610 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3615 * _scsih_ublock_io_all_device - unblock every device
3626 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3627 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3630 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3635 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3642 * _scsih_ublock_io_device - prepare device to be deleted
3654 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3655 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3658 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3661 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3668 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3679 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3680 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3683 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3685 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3688 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3696 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3711 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3712 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3715 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3717 if (sas_device_priv_data->block) in _scsih_block_io_device()
3719 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3721 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3724 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3756 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3757 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3759 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3761 mpt3sas_port->remote_identify.sas_address); in _scsih_block_io_to_children_attached_to_ex()
3763 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3764 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3767 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3772 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3774 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3776 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3780 ioc, mpt3sas_port->remote_identify.sas_address); in _scsih_block_io_to_children_attached_to_ex()
3803 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
3804 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
3807 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
3830 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
3832 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
3835 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
3842 * _scsih_tm_tr_send - send task management request
3870 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
3885 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
3888 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
3890 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
3892 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
3893 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
3894 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
3895 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
3896 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
3898 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
3900 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
3902 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
3903 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
3904 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
3905 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
3906 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
3908 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
3909 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
3911 pcie_device->device_info)))) in _scsih_tm_tr_send()
3922 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
3925 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
3926 sas_device->slot)); in _scsih_tm_tr_send()
3927 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
3930 sas_device->enclosure_level, in _scsih_tm_tr_send()
3931 sas_device->connector_name)); in _scsih_tm_tr_send()
3933 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
3936 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
3937 pcie_device->slot)); in _scsih_tm_tr_send()
3938 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
3941 pcie_device->enclosure_level, in _scsih_tm_tr_send()
3942 pcie_device->connector_name)); in _scsih_tm_tr_send()
3945 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
3948 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
3953 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
3954 delayed_tr->handle = handle; in _scsih_tm_tr_send()
3955 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
3964 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
3967 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
3968 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
3969 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
3970 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
3971 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
3972 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
3983 * _scsih_tm_tr_complete -
4011 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4030 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4031 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4035 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4042 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4043 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4044 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4046 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4051 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4052 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4053 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4062 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4065 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4066 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4067 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4068 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4073 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4084 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4087 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4088 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4094 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4096 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4109 * _scsih_sas_control_complete - completion routine
4133 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4134 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4135 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4136 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4138 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4139 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4149 * _scsih_tm_tr_volume_send - send target reset request for volumes
4165 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4172 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4177 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4178 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4179 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4188 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4191 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4192 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4193 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4194 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4198 * _scsih_tm_volume_tr_complete - target reset completion
4217 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4230 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4231 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4234 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4241 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4242 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4243 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4249 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4255 * Context - processed in interrupt context.
4262 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4269 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4270 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4271 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4275 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4278 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4279 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4280 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4281 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4282 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4283 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4287 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4293 * Context - processed in interrupt context.
4301 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4304 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4309 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4327 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4328 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4329 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4333 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4336 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4337 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4338 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4339 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4343 * _scsih_check_for_pending_internal_cmds - check for pending internal messages
4361 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4362 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4365 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4366 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4371 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4372 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4375 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4376 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4384 * _scsih_check_for_pending_tm - check for pending task management
4399 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4400 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4403 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4404 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4409 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4410 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4413 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4414 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4423 * _scsih_check_topo_delete_events - sanity check on topo events
4445 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4446 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4449 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4455 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4456 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4460 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4463 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4467 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4469 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4470 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4471 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4473 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4474 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4477 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4481 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4482 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4483 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4484 fw_event->ignore) in _scsih_check_topo_delete_events()
4487 fw_event->event_data; in _scsih_check_topo_delete_events()
4488 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4490 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4492 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4496 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4500 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4504 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4524 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4526 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4529 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4534 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4541 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4543 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4548 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4552 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4553 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4554 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4555 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4559 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4560 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4562 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4564 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4568 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4572 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4576 * _scsih_set_volume_delete_flag - setting volume delete flag
4589 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4591 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4592 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4594 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4595 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4598 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4600 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4604 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4611 * input handle is non-zero, or when a and b have not been set before.
4625 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4648 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4652 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4653 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4654 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4657 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4659 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4661 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4668 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4669 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4670 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4673 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4674 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4685 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4686 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4687 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4689 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4690 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4691 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4697 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4698 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4699 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4710 * _scsih_check_volume_delete_events - set delete flag for volumes
4725 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4727 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4731 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4735 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4745 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4747 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4748 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4749 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4750 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4751 event_data->SensorNum); in _scsih_temp_threshold_events()
4752 ioc_err(ioc, "Current Temp In Celsius: %d\n", in _scsih_temp_threshold_events()
4753 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4754 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4771 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4773 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4777 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4779 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4784 * _scsih_flush_running_cmds - completing outstanding commands.
4798 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
4807 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
4808 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
4810 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
4811 scmd->scsi_done(scmd); in _scsih_flush_running_cmds()
4817 * _scsih_setup_eedp - setup MPI request for EEDP transfer
4855 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
4856 cpu_to_be32(t10_pi_ref_tag(scmd->request)); in _scsih_setup_eedp()
4869 mpi_request_3v->EEDPBlockSize = in _scsih_setup_eedp()
4870 cpu_to_le16(scmd->device->sector_size); in _scsih_setup_eedp()
4872 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
4874 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
4878 * _scsih_eedp_error_handling - return sense code for EEDP errors
4901 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10, in _scsih_eedp_error_handling()
4903 scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) | in _scsih_eedp_error_handling()
4908 * scsih_qcmd - main scsi request entry point
4912 * The callback index is set inside `ioc->scsi_io_cb_idx`.
4925 struct request *rq = scmd->request; in scsih_qcmd()
4933 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
4936 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
4937 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
4938 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4939 scmd->scsi_done(scmd); in scsih_qcmd()
4944 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4945 scmd->scsi_done(scmd); in scsih_qcmd()
4949 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
4952 handle = sas_target_priv_data->handle; in scsih_qcmd()
4954 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4955 scmd->scsi_done(scmd); in scsih_qcmd()
4960 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
4963 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
4965 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4966 scmd->scsi_done(scmd); in scsih_qcmd()
4968 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
4969 sas_device_priv_data->block) { in scsih_qcmd()
4980 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
4984 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
4986 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
4994 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5002 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5003 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5004 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5007 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5014 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5017 if (scmd->cmd_len == 32) in scsih_qcmd()
5019 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5020 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5022 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5024 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5025 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5026 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5027 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5028 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5029 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5030 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5031 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5033 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5034 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5035 mpi_request->LUN); in scsih_qcmd()
5036 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5038 if (mpi_request->DataLength) { in scsih_qcmd()
5039 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5040 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5046 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5048 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5049 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5053 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5054 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5055 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5057 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5059 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5060 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5062 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5070 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5079 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5080 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5081 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5084 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5085 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5086 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5091 * _scsih_scsi_ioc_info - translated non-succesfull SCSI_IO request
5097 * scsi_status - SCSI Status code returned from target device
5098 * scsi_state - state info associated with SCSI_IO determined by ioc
5099 * ioc_status - ioc supplied status info
5107 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5109 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5110 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5113 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5114 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5117 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5118 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5123 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5246 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5248 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5249 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5253 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5254 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5256 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5257 pcie_device->slot); in _scsih_scsi_ioc_info()
5258 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5260 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5261 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5268 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5278 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5281 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5282 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5283 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5284 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5290 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5293 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5296 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5303 * _scsih_turn_on_pfa_led - illuminate PFA LED
5332 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5346 * _scsih_turn_off_pfa_led - turn off Fault LED
5362 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5364 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5383 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5396 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5397 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5398 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5404 * _scsih_smart_predicted_fault - process smart errors
5420 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5421 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5426 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5427 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5429 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5430 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5435 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5437 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5450 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5451 event_reply->Event = in _scsih_smart_predicted_fault()
5453 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5454 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5457 event_reply->EventData; in _scsih_smart_predicted_fault()
5458 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5459 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5460 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5461 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5470 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5475 * _scsih_io_done - scsi request callback
5512 scmd->result = DID_OK << 16; in _scsih_io_done()
5516 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5517 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5518 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5519 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5522 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5529 if (st->direct_io && in _scsih_io_done()
5532 st->direct_io = 0; in _scsih_io_done()
5533 st->scmd = scmd; in _scsih_io_done()
5534 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5535 mpi_request->DevHandle = in _scsih_io_done()
5536 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5537 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5538 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5542 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5545 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5546 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5547 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5548 if ((!ioc->is_warpdrive && in _scsih_io_done()
5549 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5550 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5551 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5553 sas_disable_tlr(scmd->device); in _scsih_io_done()
5554 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5558 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5559 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5561 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5565 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5579 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5580 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5581 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5585 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5588 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5589 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5590 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5591 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5597 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5601 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5605 if (sas_device_priv_data->block) { in _scsih_io_done()
5606 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5610 if (scmd->retries > 2) { in _scsih_io_done()
5611 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5612 scsi_device_set_state(scmd->device, in _scsih_io_done()
5615 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5616 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5620 scmd->result = DID_RESET << 16; in _scsih_io_done()
5622 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5625 scmd->result = DID_RESET << 16; in _scsih_io_done()
5628 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5632 scmd->result = DID_RESET << 16; in _scsih_io_done()
5636 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5637 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5639 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5643 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5648 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5650 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5652 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5655 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5657 scmd->result = DID_RESET << 16; in _scsih_io_done()
5658 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5659 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5660 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5661 scmd->result = (DRIVER_SENSE << 24) | in _scsih_io_done()
5663 scmd->sense_buffer[0] = 0x70; in _scsih_io_done()
5664 scmd->sense_buffer[2] = ILLEGAL_REQUEST; in _scsih_io_done()
5665 scmd->sense_buffer[12] = 0x20; in _scsih_io_done()
5666 scmd->sense_buffer[13] = 0; in _scsih_io_done()
5675 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5680 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5682 scmd->result = DID_RESET << 16; in _scsih_io_done()
5701 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5706 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5713 scmd->scsi_done(scmd); in _scsih_io_done()
5718 * _scsih_sas_host_refresh - refreshing sas host object contents
5739 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
5741 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_sas_host_refresh()
5756 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
5757 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
5759 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_refresh()
5761 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
5762 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
5766 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
5774 * _scsih_sas_host_add - create sas host object
5777 * Creating host side data object, stored in ioc->sas_hba
5800 ioc->sas_hba.phy = kcalloc(num_phys, in _scsih_sas_host_add()
5802 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
5807 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
5810 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
5833 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
5855 ioc->io_missing_delay = in _scsih_sas_host_add()
5856 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
5858 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
5860 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
5863 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
5866 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
5867 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
5883 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
5885 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
5886 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
5887 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
5888 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
5891 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
5896 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
5898 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
5900 ioc->sas_hba.handle, in _scsih_sas_host_add()
5901 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
5902 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
5904 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
5907 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
5908 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
5918 * _scsih_expander_add - creating expander object
5922 * Creating expander object, stored in ioc->sas_expander_list.
5944 return -1; in _scsih_expander_add()
5946 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
5947 return -1; in _scsih_expander_add()
5953 return -1; in _scsih_expander_add()
5961 return -1; in _scsih_expander_add()
5970 return -1; in _scsih_expander_add()
5972 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
5973 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
5976 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
5984 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
5988 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
5998 return -1; in _scsih_expander_add()
6001 sas_expander->handle = handle; in _scsih_expander_add()
6002 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6003 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6004 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6008 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6010 if (!sas_expander->num_phys) in _scsih_expander_add()
6012 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6014 if (!sas_expander->phy) { in _scsih_expander_add()
6017 rc = -1; in _scsih_expander_add()
6021 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6027 rc = -1; in _scsih_expander_add()
6030 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6032 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
6037 rc = -1; in _scsih_expander_add()
6040 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
6041 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
6044 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
6045 sas_expander->parent_dev))) { in _scsih_expander_add()
6048 rc = -1; in _scsih_expander_add()
6053 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
6056 sas_expander->enclosure_handle); in _scsih_expander_add()
6058 sas_expander->enclosure_logical_id = in _scsih_expander_add()
6059 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
6068 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
6075 * mpt3sas_expander_remove - removing expander object
6085 if (ioc->shost_recovery) in mpt3sas_expander_remove()
6088 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
6091 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
6097 * _scsih_done - internal SCSI_IO callback handler.
6104 * The callback index passed is `ioc->scsih_cb_idx`
6115 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
6117 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
6119 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
6121 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
6122 mpi_reply->MsgLength*4); in _scsih_done()
6123 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
6125 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
6126 complete(&ioc->scsih_cmds.done); in _scsih_done()
6137 * _scsih_check_access_status - check access flags
6200 * _scsih_check_device - checking device responsiveness
6241 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
6249 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
6250 starget = sas_device->starget; in _scsih_check_device()
6251 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
6254 sas_device->handle, handle); in _scsih_check_device()
6255 sas_target_priv_data->handle = handle; in _scsih_check_device()
6256 sas_device->handle = handle; in _scsih_check_device()
6259 sas_device->enclosure_level = in _scsih_check_device()
6261 memcpy(sas_device->connector_name, in _scsih_check_device()
6263 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
6265 sas_device->enclosure_level = 0; in _scsih_check_device()
6266 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
6269 sas_device->enclosure_handle = in _scsih_check_device()
6271 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
6273 sas_device->enclosure_handle); in _scsih_check_device()
6275 sas_device->enclosure_logical_id = in _scsih_check_device()
6276 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
6277 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
6279 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
6280 sas_device->chassis_slot = in _scsih_check_device()
6281 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
6299 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
6307 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
6313 * _scsih_add_device - creating sas device object
6319 * Creating end device object, stored in ioc->sas_device_list.
6321 * Return: 0 for success, non-zero for failure.
6339 return -1; in _scsih_add_device()
6347 return -1; in _scsih_add_device()
6353 return -1; in _scsih_add_device()
6354 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
6362 return -1; in _scsih_add_device()
6368 return -1; in _scsih_add_device()
6373 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
6375 return -1; in _scsih_add_device()
6395 kref_init(&sas_device->refcount); in _scsih_add_device()
6396 sas_device->handle = handle; in _scsih_add_device()
6399 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
6402 sas_device->enclosure_handle = in _scsih_add_device()
6404 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
6405 sas_device->slot = in _scsih_add_device()
6407 sas_device->device_info = device_info; in _scsih_add_device()
6408 sas_device->sas_address = sas_address; in _scsih_add_device()
6409 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
6410 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
6415 sas_device->enclosure_level = in _scsih_add_device()
6417 memcpy(sas_device->connector_name, in _scsih_add_device()
6419 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
6421 sas_device->enclosure_level = 0; in _scsih_add_device()
6422 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
6425 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
6427 sas_device->enclosure_logical_id = in _scsih_add_device()
6428 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
6429 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
6431 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
6432 sas_device->chassis_slot = in _scsih_add_device()
6433 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
6438 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
6440 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
6450 * _scsih_remove_device - removing sas device object
6460 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
6461 (sas_device->pfa_led_on)) { in _scsih_remove_device()
6463 sas_device->pfa_led_on = 0; in _scsih_remove_device()
6469 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
6474 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
6475 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
6476 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
6477 _scsih_ublock_io_device(ioc, sas_device->sas_address); in _scsih_remove_device()
6478 sas_target_priv_data->handle = in _scsih_remove_device()
6482 if (!ioc->hide_drives) in _scsih_remove_device()
6484 sas_device->sas_address, in _scsih_remove_device()
6485 sas_device->sas_address_parent); in _scsih_remove_device()
6488 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
6495 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
6501 * _scsih_sas_topology_change_event_debug - debug for topology event
6517 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
6538 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
6539 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
6540 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
6541 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
6542 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
6545 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
6546 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
6568 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
6569 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
6578 * _scsih_sas_topology_change_event - handle topology changes
6598 fw_event->event_data; in _scsih_sas_topology_change_event()
6600 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
6603 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
6606 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
6611 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
6616 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
6619 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
6623 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6627 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
6628 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
6629 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
6630 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
6631 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
6633 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6636 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6639 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
6640 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
6645 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
6647 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
6650 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
6652 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
6656 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
6659 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
6660 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
6664 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
6679 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
6686 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
6703 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
6711 * _scsih_sas_device_status_change_event_debug - debug for device event
6722 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
6767 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
6768 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
6769 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
6770 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
6772 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
6777 * _scsih_sas_device_status_change_event - handle device status change
6794 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
6797 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
6799 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
6803 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
6804 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
6808 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
6811 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
6815 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
6817 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
6819 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
6821 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
6824 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
6825 target_priv_data->handle); in _scsih_sas_device_status_change_event()
6831 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
6836 * _scsih_check_pcie_access_status - check access flags
6924 * _scsih_pcie_device_remove_from_sml - removing pcie device
6938 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
6939 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
6943 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
6944 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
6945 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
6949 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
6950 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
6952 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
6953 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
6954 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
6955 _scsih_ublock_io_device(ioc, pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
6956 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
6960 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
6961 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
6963 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
6964 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
6965 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
6967 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
6968 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
6970 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
6972 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
6976 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
6977 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
6981 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
6982 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
6983 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
6987 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
6988 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
6990 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
6995 * _scsih_pcie_check_device - checking device responsiveness
7026 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7030 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7034 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
7035 starget = pcie_device->starget; in _scsih_pcie_check_device()
7036 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
7037 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
7040 pcie_device->handle, handle); in _scsih_pcie_check_device()
7041 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
7042 pcie_device->handle = handle; in _scsih_pcie_check_device()
7046 pcie_device->enclosure_level = in _scsih_pcie_check_device()
7048 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
7051 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
7052 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
7061 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7069 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7074 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7083 * _scsih_pcie_add_device - creating pcie device object
7087 * Creating end device object, stored in ioc->pcie_device_list.
7116 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
7138 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
7143 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
7175 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
7176 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
7177 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
7178 pcie_device->handle = handle; in _scsih_pcie_add_device()
7179 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
7180 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
7181 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
7182 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
7183 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
7186 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
7188 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
7189 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
7193 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
7194 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
7197 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
7198 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
7202 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
7205 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
7207 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
7208 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
7210 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
7213 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
7215 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
7222 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
7223 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
7224 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
7226 pcie_device->reset_timeout = in _scsih_pcie_add_device()
7229 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
7231 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
7233 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
7243 * _scsih_pcie_topology_change_event_debug - debug for topology
7260 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
7281 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
7282 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
7283 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
7284 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
7286 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
7289 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
7290 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
7311 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
7313 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
7322 * _scsih_pcie_topology_change_event - handle PCIe topology
7340 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
7343 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
7346 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
7347 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
7350 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
7356 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
7357 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
7362 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
7364 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
7366 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
7370 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
7372 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
7377 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
7392 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
7394 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
7401 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
7407 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
7408 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
7412 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
7424 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
7436 * _scsih_pcie_device_status_change_event_debug - debug for device event
7447 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
7491 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
7492 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
7493 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
7494 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
7496 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
7501 * _scsih_pcie_device_status_change_event - handle device status
7516 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
7517 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
7521 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
7523 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
7527 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
7528 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
7531 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
7534 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
7538 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
7540 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
7542 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
7547 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
7551 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
7563 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
7578 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
7579 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
7580 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
7584 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
7596 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
7598 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
7600 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
7603 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
7604 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
7611 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
7623 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
7633 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
7634 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
7639 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
7649 * _scsih_sas_broadcast_primitive_event - handle broadcast events
7669 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
7676 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
7678 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
7682 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7683 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
7693 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
7697 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
7698 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7704 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
7705 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
7706 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
7709 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7713 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7717 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7721 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
7722 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
7725 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7728 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7730 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
7731 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
7736 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7739 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
7745 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7750 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
7752 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
7754 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7763 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7767 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7770 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
7771 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
7772 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
7773 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
7784 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
7786 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
7787 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7790 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
7795 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
7800 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7804 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
7807 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
7808 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7810 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
7814 * _scsih_sas_discovery_event - handle discovery events
7824 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
7826 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
7828 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
7830 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
7832 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
7836 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
7837 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
7838 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
7840 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
7848 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
7859 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
7861 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
7864 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
7865 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
7866 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
7870 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
7871 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
7872 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
7880 * _scsih_pcie_enumeration_event - handle enumeration events
7890 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
7892 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
7896 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
7898 event_data->Flags); in _scsih_pcie_enumeration_event()
7899 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
7901 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
7906 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
7924 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
7927 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
7929 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
7931 rc = -EAGAIN; in _scsih_ir_fastpath()
7934 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
7936 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
7939 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
7940 rc = -EAGAIN; in _scsih_ir_fastpath()
7945 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
7948 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
7949 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
7950 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
7956 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
7957 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
7958 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
7960 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
7962 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
7964 rc = -EFAULT; in _scsih_ir_fastpath()
7968 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
7970 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
7971 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
7973 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
7981 rc = -EFAULT; in _scsih_ir_fastpath()
7988 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
7989 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
7997 * _scsih_reprobe_lun - reprobing lun
7999 * @no_uld_attach: sdev->no_uld_attach flag setting
8005 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
8007 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
8012 * _scsih_sas_volume_add - add new volume
8024 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
8034 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8036 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8048 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
8049 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
8050 raid_device->handle = handle; in _scsih_sas_volume_add()
8051 raid_device->wwid = wwid; in _scsih_sas_volume_add()
8053 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
8054 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
8055 raid_device->id, 0); in _scsih_sas_volume_add()
8059 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8061 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8066 * _scsih_sas_volume_delete - delete volume
8079 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
8082 if (raid_device->starget) { in _scsih_sas_volume_delete()
8083 starget = raid_device->starget; in _scsih_sas_volume_delete()
8084 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
8085 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
8088 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
8089 list_del(&raid_device->list); in _scsih_sas_volume_delete()
8092 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
8094 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
8098 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
8111 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
8113 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
8116 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
8117 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
8118 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
8119 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
8120 starget = sas_device->starget; in _scsih_sas_pd_expose()
8121 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
8122 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
8126 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
8138 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
8151 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
8160 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
8163 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
8164 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
8165 starget = sas_device->starget; in _scsih_sas_pd_hide()
8166 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
8167 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
8169 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
8170 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
8173 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
8178 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
8187 * _scsih_sas_pd_delete - delete pd component
8196 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
8202 * _scsih_sas_pd_add - remove pd component
8212 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
8219 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
8223 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
8248 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
8253 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
8267 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
8270 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
8272 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
8273 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
8274 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
8306 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
8324 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
8325 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
8326 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
8331 * _scsih_sas_ir_config_change_event - handle ir configuration change events
8345 fw_event->event_data; in _scsih_sas_ir_config_change_event()
8347 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
8348 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
8351 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
8354 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
8355 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
8356 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
8357 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
8358 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
8360 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
8361 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
8366 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
8368 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
8378 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
8381 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8385 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8389 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8393 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8401 * _scsih_sas_ir_volume_event - IR volume event
8417 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
8419 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
8422 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
8425 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
8426 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
8427 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
8431 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
8443 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
8445 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
8464 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
8465 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
8466 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
8467 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
8469 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
8470 raid_device->id, 0); in _scsih_sas_ir_volume_event()
8482 * _scsih_sas_ir_physical_disk_event - PD event
8498 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
8501 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
8504 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
8507 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
8508 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
8510 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
8514 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
8524 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
8525 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
8567 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
8578 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
8601 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
8602 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
8606 * _scsih_sas_ir_operation_status_event - handle RAID operation events
8617 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
8622 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
8623 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
8628 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
8630 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
8631 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
8634 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
8635 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
8636 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
8641 * _scsih_prep_device_scan - initialize parameters prior to device scan
8653 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
8654 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
8655 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
8656 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
8661 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
8678 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
8681 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
8684 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
8686 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
8687 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
8688 if ((sas_device->sas_address == le64_to_cpu( in _scsih_mark_responding_sas_device()
8689 sas_device_pg0->SASAddress)) && (sas_device->slot == in _scsih_mark_responding_sas_device()
8690 le16_to_cpu(sas_device_pg0->Slot))) { in _scsih_mark_responding_sas_device()
8691 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
8692 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
8693 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
8694 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
8695 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
8696 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
8702 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
8704 sas_device->sas_address); in _scsih_mark_responding_sas_device()
8706 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
8711 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
8712 sas_device->slot); in _scsih_mark_responding_sas_device()
8714 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
8716 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
8717 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
8718 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
8719 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
8721 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
8722 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
8725 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
8726 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
8727 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
8729 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
8730 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
8731 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
8733 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
8734 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
8735 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
8739 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
8740 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
8743 sas_device->handle); in _scsih_mark_responding_sas_device()
8744 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
8745 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
8747 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
8748 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
8753 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
8757 * _scsih_create_enclosure_list_after_reset - Free Existing list,
8783 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
8792 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
8793 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
8795 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
8800 * _scsih_search_responding_sas_devices -
8815 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
8817 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
8836 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
8840 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
8856 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
8857 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
8858 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
8859 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
8860 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
8861 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
8862 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
8863 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
8864 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
8865 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
8866 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
8867 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
8868 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
8874 pcie_device->handle, in _scsih_mark_responding_pcie_device()
8875 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
8876 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
8881 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
8882 pcie_device->slot); in _scsih_mark_responding_pcie_device()
8885 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
8887 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
8888 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
8889 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
8890 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
8891 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
8893 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
8894 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
8897 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
8898 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
8901 pcie_device->handle); in _scsih_mark_responding_pcie_device()
8902 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
8903 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
8905 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
8906 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
8912 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
8916 * _scsih_search_responding_pcie_devices -
8931 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
8933 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
8955 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
8959 * _scsih_mark_responding_raid_device - mark a raid_device as responding
8976 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
8977 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
8978 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
8979 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
8980 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
8981 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
8982 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
8985 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
8986 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
8987 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
8989 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
8993 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
8997 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
8998 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
8999 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
9004 raid_device->handle); in _scsih_mark_responding_raid_device()
9005 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
9007 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
9008 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9012 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9016 * _scsih_search_responding_raid_devices -
9033 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
9038 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
9063 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
9065 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
9075 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
9083 * _scsih_mark_responding_expander - mark a expander as responding
9098 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
9099 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
9100 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
9107 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
9108 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
9109 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
9111 sas_expander->responding = 1; in _scsih_mark_responding_expander()
9114 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
9115 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
9116 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
9117 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
9120 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
9124 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
9125 sas_expander->handle, handle); in _scsih_mark_responding_expander()
9126 sas_expander->handle = handle; in _scsih_mark_responding_expander()
9127 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
9128 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
9132 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
9136 * _scsih_search_responding_expanders -
9153 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
9178 * _scsih_remove_unresponding_devices - removing unresponding devices
9195 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
9197 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
9200 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
9202 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
9203 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
9204 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
9206 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
9208 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
9215 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
9219 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
9221 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
9223 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
9224 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
9225 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
9227 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
9229 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
9233 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
9238 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
9241 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
9242 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
9244 raid_device->handle); in _scsih_remove_unresponding_devices()
9246 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
9252 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
9255 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
9256 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
9257 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
9259 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
9261 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
9281 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
9289 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
9296 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
9339 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
9342 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
9359 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
9403 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
9435 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
9438 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
9552 * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
9563 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
9574 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9575 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9576 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9577 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9579 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9580 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9581 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9582 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9585 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9586 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9587 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9593 * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
9602 if ((!ioc->is_driver_loading) && !(disable_discovery > 0 && in mpt3sas_scsih_reset_done_handler()
9603 !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
9615 * _mpt3sas_fw_work - delayed task for processing firmware events
9623 ioc->current_event = fw_event; in _mpt3sas_fw_work()
9627 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
9629 ioc->current_event = NULL; in _mpt3sas_fw_work()
9633 switch (fw_event->event) { in _mpt3sas_fw_work()
9637 fw_event->event_data); in _mpt3sas_fw_work()
9640 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
9641 ioc->shost_recovery) { in _mpt3sas_fw_work()
9646 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
9655 ioc->start_scan = 0; in _mpt3sas_fw_work()
9656 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
9663 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
9669 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
9672 fw_event->event_data); in _mpt3sas_fw_work()
9707 ioc->current_event = NULL; in _mpt3sas_fw_work()
9713 ioc->current_event = NULL; in _mpt3sas_fw_work()
9730 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
9734 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
9740 * This function merely adds a new work task into ioc->firmware_event_thread.
9757 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
9768 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
9779 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9781 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
9785 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
9786 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
9789 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
9796 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9801 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9806 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9811 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9818 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
9822 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9823 log_code = (u32 *)log_entry->LogData; in mpt3sas_scsih_event_callback()
9825 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
9837 …Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode. Check Warp… in mpt3sas_scsih_event_callback()
9849 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9863 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9867 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9868 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
9871 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
9875 ActiveCableEventData->ActiveCablePowerRequirement); in mpt3sas_scsih_event_callback()
9880 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
9892 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
9900 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
9901 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
9902 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
9903 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
9904 fw_event->event = event; in mpt3sas_scsih_event_callback()
9911 * _scsih_expander_node_remove - removing expander device from list.
9916 * ioc->sas_expander_list.
9927 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
9928 if (ioc->shost_recovery) in _scsih_expander_node_remove()
9930 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9933 mpt3sas_port->remote_identify.sas_address); in _scsih_expander_node_remove()
9934 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9936 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9939 mpt3sas_port->remote_identify.sas_address); in _scsih_expander_node_remove()
9942 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
9943 sas_expander->sas_address_parent); in _scsih_expander_node_remove()
9946 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
9947 sas_expander->sas_address); in _scsih_expander_node_remove()
9949 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
9950 list_del(&sas_expander->list); in _scsih_expander_node_remove()
9951 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
9953 kfree(sas_expander->phy); in _scsih_expander_node_remove()
9958 * _scsih_nvme_shutdown - NVMe shutdown notification
9961 * Sending IoUnitControl request with shutdown operation code to alert IOC that
9973 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
9976 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
9978 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
9983 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
9985 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
9989 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
9994 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
9996 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
9997 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
9999 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
10000 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
10004 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
10005 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
10006 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
10008 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
10013 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
10014 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
10017 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
10018 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
10021 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
10022 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
10027 * _scsih_ir_shutdown - IR shutdown notification
10030 * Sending RAID Action to alert the Integrated RAID subsystem of the IOC that
10041 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
10045 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
10048 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
10050 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
10054 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
10056 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
10059 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
10064 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
10067 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
10068 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
10070 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
10072 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
10073 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
10074 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
10076 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
10081 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
10082 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
10083 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
10085 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
10086 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
10090 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
10091 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
10095 * _scsih_get_shost_and_ioc - get shost and ioc
10109 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
10110 return -ENXIO; in _scsih_get_shost_and_ioc()
10115 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
10116 return -ENXIO; in _scsih_get_shost_and_ioc()
10123 * scsih_remove - detach and remove add host
10143 ioc->remove_host = 1; in scsih_remove()
10150 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
10151 wq = ioc->firmware_event_thread; in scsih_remove()
10152 ioc->firmware_event_thread = NULL; in scsih_remove()
10153 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
10160 if (ioc->is_aero_ioc) in scsih_remove()
10162 &ioc->ioc_pg1_copy); in scsih_remove()
10167 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
10169 if (raid_device->starget) { in scsih_remove()
10171 raid_device->starget->hostdata; in scsih_remove()
10172 sas_target_priv_data->deleted = 1; in scsih_remove()
10173 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
10176 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
10179 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
10182 list_del_init(&pcie_device->list); in scsih_remove()
10188 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
10189 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
10192 mpt3sas_port->remote_identify.sas_address); in scsih_remove()
10193 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
10195 mpt3sas_port->remote_identify.device_type == in scsih_remove()
10198 mpt3sas_port->remote_identify.sas_address); in scsih_remove()
10202 if (ioc->sas_hba.num_phys) { in scsih_remove()
10203 kfree(ioc->sas_hba.phy); in scsih_remove()
10204 ioc->sas_hba.phy = NULL; in scsih_remove()
10205 ioc->sas_hba.num_phys = 0; in scsih_remove()
10210 list_del(&ioc->list); in scsih_remove()
10216 * scsih_shutdown - routine call during system shutdown
10231 ioc->remove_host = 1; in scsih_shutdown()
10238 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
10239 wq = ioc->firmware_event_thread; in scsih_shutdown()
10240 ioc->firmware_event_thread = NULL; in scsih_shutdown()
10241 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
10248 if (ioc->is_aero_ioc) in scsih_shutdown()
10250 &ioc->ioc_pg1_copy); in scsih_shutdown()
10259 * _scsih_probe_boot_devices - reports 1st device
10263 * device scsi-ml or sas transport for persistent boot device
10282 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
10286 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
10287 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
10288 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
10289 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
10290 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
10291 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
10292 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
10293 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
10294 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
10302 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
10303 raid_device->id, 0); in _scsih_probe_boot_devices()
10307 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
10309 tid = pcie_device->id; in _scsih_probe_boot_devices()
10310 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
10311 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
10312 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
10316 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
10318 handle = sas_device->handle; in _scsih_probe_boot_devices()
10319 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
10320 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
10321 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
10322 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
10324 if (ioc->hide_drives) in _scsih_probe_boot_devices()
10329 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
10330 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
10341 * _scsih_probe_raid - reporting raid volumes to scsi-ml
10353 &ioc->raid_device_list, list) { in _scsih_probe_raid()
10354 if (raid_device->starget) in _scsih_probe_raid()
10356 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
10357 raid_device->id, 0); in _scsih_probe_raid()
10368 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
10369 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
10370 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
10374 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
10384 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
10394 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
10395 list_del_init(&sas_device->list); in sas_device_make_active()
10400 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
10402 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
10406 * _scsih_probe_sas - reporting sas devices to sas transport
10416 if (ioc->hide_drives) in _scsih_probe_sas()
10420 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
10421 sas_device->sas_address_parent)) { in _scsih_probe_sas()
10425 } else if (!sas_device->starget) { in _scsih_probe_sas()
10429 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
10432 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
10434 sas_device->sas_address, in _scsih_probe_sas()
10435 sas_device->sas_address_parent); in _scsih_probe_sas()
10447 * get_next_pcie_device - Get the next pcie device
10460 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
10461 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
10462 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
10466 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
10472 * pcie_device_make_active - Add pcie device to pcie_device_list list
10484 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
10486 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
10487 list_del_init(&pcie_device->list); in pcie_device_make_active()
10491 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
10493 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
10497 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
10510 if (pcie_device->starget) { in _scsih_probe_pcie()
10514 if (pcie_device->access_status == in _scsih_probe_pcie()
10520 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
10521 pcie_device->id, 0); in _scsih_probe_pcie()
10526 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
10530 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
10533 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
10534 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
10548 * _scsih_probe_devices - probing for devices
10558 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
10563 if (ioc->ir_firmware) { in _scsih_probe_devices()
10565 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
10582 * scsih_scan_start - scsi lld callback for .scan_start
10594 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
10596 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
10602 ioc->start_scan = 1; in scsih_scan_start()
10610 * scsih_scan_finished - scsi lld callback for .scan_finished
10624 ioc->is_driver_loading = 0; in scsih_scan_finished()
10625 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10630 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
10632 ioc->is_driver_loading = 0; in scsih_scan_finished()
10636 if (ioc->start_scan) in scsih_scan_finished()
10639 if (ioc->start_scan_failed) { in scsih_scan_finished()
10641 ioc->start_scan_failed); in scsih_scan_finished()
10642 ioc->is_driver_loading = 0; in scsih_scan_finished()
10643 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10644 ioc->remove_host = 1; in scsih_scan_finished()
10649 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
10651 if (ioc->wait_for_discovery_to_complete) { in scsih_scan_finished()
10652 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10656 ioc->is_driver_loading = 0; in scsih_scan_finished()
10680 .this_id = -1,
10718 .this_id = -1,
10738 * _scsih_determine_hba_mpi_version - determine in which MPI version class
10750 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
10810 * _scsih_probe - attach and add scsi host
10827 return -ENODEV; in _scsih_probe()
10830 * for other generation HBA's return with -ENODEV in _scsih_probe()
10833 return -ENODEV; in _scsih_probe()
10836 * for other generation HBA's return with -ENODEV in _scsih_probe()
10840 return -ENODEV; in _scsih_probe()
10850 return -ENODEV; in _scsih_probe()
10853 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
10854 ioc->id = mpt2_ids++; in _scsih_probe()
10855 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
10856 switch (pdev->device) { in _scsih_probe()
10858 ioc->is_warpdrive = 1; in _scsih_probe()
10859 ioc->hide_ir_msg = 1; in _scsih_probe()
10863 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
10866 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
10876 return -ENODEV; in _scsih_probe()
10879 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
10880 ioc->id = mpt3_ids++; in _scsih_probe()
10881 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
10882 switch (pdev->device) { in _scsih_probe()
10891 ioc->is_gen35_ioc = 1; in _scsih_probe()
10895 dev_err(&pdev->dev, in _scsih_probe()
10897 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
10898 pdev->subsystem_device); in _scsih_probe()
10902 dev_err(&pdev->dev, in _scsih_probe()
10904 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
10905 pdev->subsystem_device); in _scsih_probe()
10909 dev_info(&pdev->dev, in _scsih_probe()
10914 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
10917 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
10919 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
10920 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
10921 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
10922 ioc->combined_reply_queue = 1; in _scsih_probe()
10923 if (ioc->is_gen35_ioc) in _scsih_probe()
10924 ioc->combined_reply_index_count = in _scsih_probe()
10927 ioc->combined_reply_index_count = in _scsih_probe()
10932 return -ENODEV; in _scsih_probe()
10935 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
10937 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
10939 ioc->shost = shost; in _scsih_probe()
10940 ioc->pdev = pdev; in _scsih_probe()
10941 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
10942 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
10943 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
10944 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
10945 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
10946 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
10947 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
10948 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
10949 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
10950 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
10951 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
10952 ioc->logging_level = logging_level; in _scsih_probe()
10953 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
10955 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
10959 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
10961 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
10964 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
10966 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
10967 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
10968 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
10969 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
10970 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
10971 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
10972 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
10973 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
10974 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
10976 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
10977 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
10978 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
10979 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
10980 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
10981 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
10982 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
10983 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
10984 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
10985 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
10986 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
10987 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
10988 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
10989 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
10991 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
10994 shost->max_cmd_len = 32; in _scsih_probe()
10995 shost->max_lun = max_lun; in _scsih_probe()
10996 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
10997 shost->unique_id = ioc->id; in _scsih_probe()
10999 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
11001 shost->max_sectors = 128; in _scsih_probe()
11003 shost->max_sectors); in _scsih_probe()
11007 shost->max_sectors = 64; in _scsih_probe()
11011 shost->max_sectors = 32767; in _scsih_probe()
11015 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
11017 shost->max_sectors); in _scsih_probe()
11032 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
11033 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
11034 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
11035 ioc->firmware_event_name, 0); in _scsih_probe()
11036 if (!ioc->firmware_event_thread) { in _scsih_probe()
11039 rv = -ENODEV; in _scsih_probe()
11043 ioc->is_driver_loading = 1; in _scsih_probe()
11047 rv = -ENODEV; in _scsih_probe()
11051 if (ioc->is_warpdrive) { in _scsih_probe()
11052 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
11053 ioc->hide_drives = 0; in _scsih_probe()
11054 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
11055 ioc->hide_drives = 1; in _scsih_probe()
11058 ioc->hide_drives = 1; in _scsih_probe()
11060 ioc->hide_drives = 0; in _scsih_probe()
11063 ioc->hide_drives = 0; in _scsih_probe()
11065 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
11078 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
11081 list_del(&ioc->list); in _scsih_probe()
11089 * scsih_suspend - power management suspend main entry point
11122 * scsih_resume - power management resume main entry point
11132 pci_power_t device_state = pdev->current_state; in scsih_resume()
11145 ioc->pdev = pdev; in scsih_resume()
11158 * scsih_pci_error_detected - Called when a PCI error is detected.
11182 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
11183 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
11189 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
11198 * scsih_pci_slot_reset - Called when PCI slot has been reset.
11217 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
11218 ioc->pdev = pdev; in scsih_pci_slot_reset()
11237 * scsih_pci_resume() - resume normal ops after PCI reset
11256 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
11260 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
11274 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
11284 * scsih__ncq_prio_supp - Check for NCQ command priority support
11471 * scsih_init - main entry point for this driver.
11522 * scsih_exit - exit point for this driver (when it is a module).
11553 * _mpt3sas_init - main entry point for this driver.
11568 return -ENODEV; in _mpt3sas_init()
11578 return -ENODEV; in _mpt3sas_init()
11590 return -ENODEV; in _mpt3sas_init()
11610 * _mpt3sas_exit - exit point for this driver (when it is a module).