Lines Matching +full:operating +full:- +full:range +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,
57 #include <linux/blk-mq-pci.h>
95 static u8 scsi_io_cb_idx = -1;
96 static u8 tm_cb_idx = -1;
97 static u8 ctl_cb_idx = -1;
98 static u8 base_cb_idx = -1;
99 static u8 port_enable_cb_idx = -1;
100 static u8 transport_cb_idx = -1;
101 static u8 scsih_cb_idx = -1;
102 static u8 config_cb_idx = -1;
106 static u8 tm_tr_cb_idx = -1 ;
107 static u8 tm_tr_volume_cb_idx = -1 ;
108 static u8 tm_sas_control_cb_idx = -1;
118 MODULE_PARM_DESC(max_sectors, "max sectors, range 64 to 32767 default=32767");
121 static int missing_delay[2] = {-1, -1};
125 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
134 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
135 1 - enumerates only SAS 2.0 generation HBAs\n \
136 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
145 static int diag_buffer_enable = -1;
149 static int disable_discovery = -1;
155 static int prot_mask = -1;
164 static int multipath_on_hba = -1;
170 "\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
171 "\t SAS 3.5 HBA - This will be enabled)");
184 * struct sense_info - common structure for obtaining sense keys
201 * struct fw_event_work - firmware event struct
203 * @work: work object (ioc->fault_reset_work_q)
213 * This object stored on ioc->fw_event_list.
236 kref_get(&fw_work->refcount); in fw_event_work_get()
241 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
252 kref_init(&fw_event->refcount); in alloc_fw_event_work()
257 * struct _scsi_io_transfer - scsi io transfer
305 * _scsih_set_debug_level - global setting of ioc->logging_level.
323 ioc->logging_level = logging_level; in _scsih_set_debug_level()
331 * _scsih_srch_boot_sas_address - search based on sas_address
341 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
345 * _scsih_srch_boot_device_name - search based on device name
355 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
359 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
370 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
371 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
376 * mpt3sas_get_port_by_id - get hba port entry corresponding to provided
397 if (!ioc->multipath_on_hba) in mpt3sas_get_port_by_id()
401 &ioc->port_table_list, list) { in mpt3sas_get_port_by_id()
402 if (port->port_id != port_id) in mpt3sas_get_port_by_id()
406 if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) in mpt3sas_get_port_by_id()
416 if (!ioc->multipath_on_hba) { in mpt3sas_get_port_by_id()
421 port->port_id = port_id; in mpt3sas_get_port_by_id()
424 port, port->port_id); in mpt3sas_get_port_by_id()
425 list_add_tail(&port->list, in mpt3sas_get_port_by_id()
426 &ioc->port_table_list); in mpt3sas_get_port_by_id()
433 * mpt3sas_get_vphy_by_phy - get virtual_phy object corresponding to phy number
446 if (!port->vphys_mask) in mpt3sas_get_vphy_by_phy()
449 list_for_each_entry_safe(vphy, vphy_next, &port->vphys_list, list) { in mpt3sas_get_vphy_by_phy()
450 if (vphy->phy_mask & (1 << phy)) in mpt3sas_get_vphy_by_phy()
457 * _scsih_is_boot_device - search for matching boot device.
479 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
486 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
492 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
502 * _scsih_get_sas_address - set the sas_address for given device handle
507 * Return: 0 success, non-zero when failure
523 return -ENXIO; in _scsih_get_sas_address()
531 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
534 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
542 return -ENXIO; in _scsih_get_sas_address()
547 return -EIO; in _scsih_get_sas_address()
551 * _scsih_determine_boot_device - determine boot device.
557 * to scsi-ml or sas transport, this purpose is for persistent boot device.
576 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
580 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
585 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
591 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
597 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
598 device_name = sas_device->device_name; in _scsih_determine_boot_device()
599 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
600 slot = sas_device->slot; in _scsih_determine_boot_device()
603 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
606 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
608 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
612 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
613 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
617 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
620 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
622 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
626 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
627 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
631 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
634 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
636 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
640 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
641 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
652 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
654 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
668 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
670 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
681 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
683 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
691 * mpt3sas_get_pdev_from_target - pcie device search
695 * Context: This function will acquire ioc->pcie_device_lock and will release
707 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
709 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
716 * __mpt3sas_get_sdev_by_rphy - sas device search
720 * Context: This function will acquire ioc->sas_device_lock and will release
732 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_rphy()
734 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_rphy()
735 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
742 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_rphy()
743 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
753 * __mpt3sas_get_sdev_by_addr - get _sas_device object corresponding to provided
771 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
773 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_addr()
774 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
776 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
782 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_addr()
783 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
785 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
795 * mpt3sas_get_sdev_by_addr - sas device search
799 * Context: Calling function should acquire ioc->sas_device_lock
811 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
814 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
824 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
826 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
827 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
830 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
831 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
842 * mpt3sas_get_sdev_by_handle - sas device search
845 * Context: Calling function should acquire ioc->sas_device_lock
856 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
858 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
864 * _scsih_display_enclosure_chassis_info - display device location info
876 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
880 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
881 sas_device->slot); in _scsih_display_enclosure_chassis_info()
882 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
885 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
886 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
887 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
889 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
891 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
895 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
896 sas_device->slot); in _scsih_display_enclosure_chassis_info()
897 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
900 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
901 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
902 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
905 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
907 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
909 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
910 sas_device->slot); in _scsih_display_enclosure_chassis_info()
911 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
913 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
914 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
915 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
917 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
922 * _scsih_sas_device_remove - remove sas_device from list.
925 * Context: This function will acquire ioc->sas_device_lock.
938 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
946 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
947 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
948 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
951 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
955 * _scsih_device_remove_by_handle - removing device object by handle
965 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
968 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
971 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
974 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
982 * mpt3sas_device_remove_by_sas_address - removing device object by
997 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
1000 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1003 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
1006 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1014 * _scsih_sas_device_add - insert sas_device to the list.
1017 * Context: This function will acquire ioc->sas_device_lock.
1019 * Adding new object to the ioc->sas_device_list.
1029 __func__, sas_device->handle, in _scsih_sas_device_add()
1030 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
1035 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1037 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
1038 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1040 if (ioc->hide_drives) { in _scsih_sas_device_add()
1041 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1045 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
1046 sas_device->sas_address_parent, sas_device->port)) { in _scsih_sas_device_add()
1048 } else if (!sas_device->starget) { in _scsih_sas_device_add()
1052 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
1054 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
1056 sas_device->sas_address, in _scsih_sas_device_add()
1057 sas_device->sas_address_parent, in _scsih_sas_device_add()
1058 sas_device->port); in _scsih_sas_device_add()
1062 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1066 * _scsih_sas_device_init_add - insert sas_device to the list.
1069 * Context: This function will acquire ioc->sas_device_lock.
1071 * Adding new object at driver load time to the ioc->sas_device_init_list.
1081 __func__, sas_device->handle, in _scsih_sas_device_init_add()
1082 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
1087 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1089 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
1091 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1100 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
1102 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
1103 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1106 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
1107 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1119 * mpt3sas_get_pdev_by_wwid - pcie device search
1123 * Context: This function will acquire ioc->pcie_device_lock and will release
1134 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1136 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1148 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
1150 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
1151 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1154 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
1155 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1170 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1172 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1173 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1176 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1177 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1189 * mpt3sas_get_pdev_by_handle - pcie device search
1193 * Context: This function will acquire ioc->pcie_device_lock and will release
1205 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1207 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1213 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1215 * Context: This function will acquire ioc->pcie_device_lock
1217 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1228 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1229 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1230 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1231 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1233 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1236 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1237 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1241 * _scsih_pcie_device_remove - remove pcie_device from list.
1244 * Context: This function will acquire ioc->pcie_device_lock.
1259 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1260 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1262 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1263 pcie_device->slot); in _scsih_pcie_device_remove()
1264 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1266 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1267 pcie_device->connector_name); in _scsih_pcie_device_remove()
1269 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1270 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1271 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1274 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1276 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1278 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1293 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1305 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1308 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1311 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1312 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1316 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1319 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1335 * _scsih_pcie_device_add - add pcie_device object
1350 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1351 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1355 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1356 pcie_device->slot)); in _scsih_pcie_device_add()
1357 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1360 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1361 pcie_device->connector_name)); in _scsih_pcie_device_add()
1363 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1365 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1366 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1368 if (pcie_device->access_status == in _scsih_pcie_device_add()
1370 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1373 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1375 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1376 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1377 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1378 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1381 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1385 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1388 * Context: This function will acquire ioc->pcie_device_lock.
1390 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1401 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1402 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1406 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1407 pcie_device->slot)); in _scsih_pcie_device_init_add()
1408 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1411 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1412 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1414 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1416 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1417 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1420 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1423 * _scsih_raid_device_find_by_id - raid device search
1427 * Context: Calling function should acquire ioc->raid_device_lock
1438 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1439 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1450 * mpt3sas_raid_device_find_by_handle - raid device search
1453 * Context: Calling function should acquire ioc->raid_device_lock
1464 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1465 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1476 * _scsih_raid_device_find_by_wwid - raid device search
1479 * Context: Calling function should acquire ioc->raid_device_lock
1490 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1491 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1502 * _scsih_raid_device_add - add raid_device object
1517 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1519 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1520 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1521 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1525 * _scsih_raid_device_remove - delete raid_device object
1536 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1537 list_del(&raid_device->list); in _scsih_raid_device_remove()
1539 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1543 * mpt3sas_scsih_expander_find_by_handle - expander device search
1546 * Context: Calling function should acquire ioc->sas_device_lock
1557 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1558 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1568 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1571 * Context: Calling function should acquire ioc->sas_device_lock
1582 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1583 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1592 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1596 * Context: Calling function should acquire ioc->sas_node_lock.
1610 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1611 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1613 if (sas_expander->port != port) in mpt3sas_scsih_expander_find_by_sas_address()
1623 * _scsih_expander_node_add - insert expander device to the list.
1626 * Context: This function will acquire ioc->sas_node_lock.
1628 * Adding new object to the ioc->sas_expander_list.
1636 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1637 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1638 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1642 * _scsih_is_end_device - determines if device is an end device
1661 * _scsih_is_nvme_pciescsi_device - determines if
1681 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1685 * Context: This function will acquire ioc->scsi_lookup_lock.
1698 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1702 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1703 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1710 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1715 * Context: This function will acquire ioc->scsi_lookup_lock.
1727 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1732 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1733 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1734 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1741 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1754 u16 tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1757 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1759 ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag; in mpt3sas_scsih_scsi_lookup_get()
1765 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1769 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1772 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1775 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1783 * scsih_change_queue_depth - setting device queue depth
1792 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1800 max_depth = shost->can_queue; in scsih_change_queue_depth()
1806 if (ioc->enable_sdev_max_qd || ioc->is_gen35_ioc) in scsih_change_queue_depth()
1809 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1812 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1815 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1818 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1821 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1826 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1830 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1837 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1838 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1839 return sdev->queue_depth; in scsih_change_queue_depth()
1843 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1852 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1855 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1856 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1862 * scsih_target_alloc - target add routine
1871 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1883 return -ENOMEM; in scsih_target_alloc()
1885 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1886 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1887 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1890 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1891 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1892 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1893 starget->channel); in scsih_target_alloc()
1895 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1896 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1897 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1898 if (ioc->is_warpdrive) in scsih_target_alloc()
1899 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1900 raid_device->starget = starget; in scsih_target_alloc()
1902 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1907 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1908 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1909 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1910 starget->channel); in scsih_target_alloc()
1912 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1913 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1914 sas_target_priv_data->port = NULL; in scsih_target_alloc()
1915 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1916 pcie_device->starget = starget; in scsih_target_alloc()
1917 pcie_device->id = starget->id; in scsih_target_alloc()
1918 pcie_device->channel = starget->channel; in scsih_target_alloc()
1919 sas_target_priv_data->flags |= in scsih_target_alloc()
1921 if (pcie_device->fast_path) in scsih_target_alloc()
1922 sas_target_priv_data->flags |= in scsih_target_alloc()
1925 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1930 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1931 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1935 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1936 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1937 sas_target_priv_data->port = sas_device->port; in scsih_target_alloc()
1938 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1939 sas_device->starget = starget; in scsih_target_alloc()
1940 sas_device->id = starget->id; in scsih_target_alloc()
1941 sas_device->channel = starget->channel; in scsih_target_alloc()
1942 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1943 sas_target_priv_data->flags |= in scsih_target_alloc()
1945 if (sas_device->fast_path) in scsih_target_alloc()
1946 sas_target_priv_data->flags |= in scsih_target_alloc()
1949 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1955 * scsih_target_destroy - target destroy routine
1961 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1969 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1973 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1974 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1975 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1976 starget->channel); in scsih_target_destroy()
1978 raid_device->starget = NULL; in scsih_target_destroy()
1979 raid_device->sdev = NULL; in scsih_target_destroy()
1981 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1985 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1986 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1989 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1990 (pcie_device->id == starget->id) && in scsih_target_destroy()
1991 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1992 pcie_device->starget = NULL; in scsih_target_destroy()
1998 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
2002 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
2006 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2008 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
2009 (sas_device->id == starget->id) && in scsih_target_destroy()
2010 (sas_device->channel == starget->channel)) in scsih_target_destroy()
2011 sas_device->starget = NULL; in scsih_target_destroy()
2017 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
2022 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2026 starget->hostdata = NULL; in scsih_target_destroy()
2030 * scsih_slave_alloc - device add routine
2052 return -ENOMEM; in scsih_slave_alloc()
2054 sas_device_priv_data->lun = sdev->lun; in scsih_slave_alloc()
2055 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_slave_alloc()
2058 sas_target_priv_data = starget->hostdata; in scsih_slave_alloc()
2059 sas_target_priv_data->num_luns++; in scsih_slave_alloc()
2060 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_slave_alloc()
2061 sdev->hostdata = sas_device_priv_data; in scsih_slave_alloc()
2062 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_slave_alloc()
2063 sdev->no_uld_attach = 1; in scsih_slave_alloc()
2065 shost = dev_to_shost(&starget->dev); in scsih_slave_alloc()
2067 if (starget->channel == RAID_CHANNEL) { in scsih_slave_alloc()
2068 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2070 starget->id, starget->channel); in scsih_slave_alloc()
2072 raid_device->sdev = sdev; /* raid is single lun */ in scsih_slave_alloc()
2073 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2075 if (starget->channel == PCIE_CHANNEL) { in scsih_slave_alloc()
2076 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2078 sas_target_priv_data->sas_address); in scsih_slave_alloc()
2079 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_slave_alloc()
2081 "%s : pcie_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2083 pcie_device->starget = starget; in scsih_slave_alloc()
2088 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2090 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_alloc()
2091 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2093 sas_target_priv_data->sas_address, in scsih_slave_alloc()
2094 sas_target_priv_data->port); in scsih_slave_alloc()
2095 if (sas_device && (sas_device->starget == NULL)) { in scsih_slave_alloc()
2097 "%s : sas_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2099 sas_device->starget = starget; in scsih_slave_alloc()
2105 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2112 * scsih_slave_destroy - device destroy routine
2126 if (!sdev->hostdata) in scsih_slave_destroy()
2130 sas_target_priv_data = starget->hostdata; in scsih_slave_destroy()
2131 sas_target_priv_data->num_luns--; in scsih_slave_destroy()
2133 shost = dev_to_shost(&starget->dev); in scsih_slave_destroy()
2136 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_destroy()
2137 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2140 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2141 pcie_device->starget = NULL; in scsih_slave_destroy()
2146 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2148 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_destroy()
2149 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2152 if (sas_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2153 sas_device->starget = NULL; in scsih_slave_destroy()
2157 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2160 kfree(sdev->hostdata); in scsih_slave_destroy()
2161 sdev->hostdata = NULL; in scsih_slave_destroy()
2165 * _scsih_display_sata_capabilities - sata capabilities
2211 * raid transport support -
2213 * unloading the driver followed by a load - I believe that the subroutine
2218 * scsih_is_raid - return boolean indicating device is raid volume
2225 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2227 if (ioc->is_warpdrive) in scsih_is_raid()
2229 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2237 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2241 * scsih_get_resync - get raid volume resync percent complete
2248 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2259 if (ioc->is_warpdrive) in scsih_get_resync()
2262 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2263 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2264 sdev->channel); in scsih_get_resync()
2266 handle = raid_device->handle; in scsih_get_resync()
2267 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2269 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2290 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2302 * scsih_get_state - get raid volume level
2309 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2318 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2319 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2320 sdev->channel); in scsih_get_state()
2322 handle = raid_device->handle; in scsih_get_state()
2323 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2356 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2368 * _scsih_set_level - set raid level
2394 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2397 &sdev->sdev_gendev, level); in _scsih_set_level()
2402 &sdev->sdev_gendev, level); in _scsih_set_level()
2409 * _scsih_get_volume_capabilities - volume capabilities
2426 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2434 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2446 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2454 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2461 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2465 raid_device->device_info = in _scsih_get_volume_capabilities()
2475 * _scsih_enable_tlr - setting TLR flags
2488 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2491 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2502 * scsih_slave_configure - device configure routine.
2511 struct Scsi_Host *shost = sdev->host; in scsih_slave_configure()
2527 sas_device_priv_data = sdev->hostdata; in scsih_slave_configure()
2528 sas_device_priv_data->configured_lun = 1; in scsih_slave_configure()
2529 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_slave_configure()
2530 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_slave_configure()
2531 handle = sas_target_priv_data->handle; in scsih_slave_configure()
2534 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_slave_configure()
2536 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2538 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2563 if (raid_device->device_info & in scsih_slave_configure()
2569 if (raid_device->device_info & in scsih_slave_configure()
2576 switch (raid_device->volume_type) { in scsih_slave_configure()
2582 if (ioc->manu_pg10.OEMIdentifier && in scsih_slave_configure()
2583 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_slave_configure()
2585 !(raid_device->num_pds % 2)) in scsih_slave_configure()
2605 if (!ioc->hide_ir_msg) in scsih_slave_configure()
2609 r_level, raid_device->handle, in scsih_slave_configure()
2610 (unsigned long long)raid_device->wwid, in scsih_slave_configure()
2611 raid_device->num_pds, ds); in scsih_slave_configure()
2613 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_slave_configure()
2614 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2624 if (!ioc->is_warpdrive) in scsih_slave_configure()
2625 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_slave_configure()
2629 /* non-raid handling */ in scsih_slave_configure()
2630 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_slave_configure()
2648 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_configure()
2649 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2651 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2653 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2660 qdepth = ioc->max_nvme_qd; in scsih_slave_configure()
2664 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_slave_configure()
2665 pcie_device->port_num); in scsih_slave_configure()
2666 if (pcie_device->enclosure_handle != 0) in scsih_slave_configure()
2670 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_slave_configure()
2671 pcie_device->slot); in scsih_slave_configure()
2672 if (pcie_device->connector_name[0] != '\0') in scsih_slave_configure()
2676 pcie_device->enclosure_level, in scsih_slave_configure()
2677 pcie_device->connector_name); in scsih_slave_configure()
2679 if (pcie_device->nvme_mdts) in scsih_slave_configure()
2680 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2681 pcie_device->nvme_mdts/512); in scsih_slave_configure()
2684 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2691 sdev->request_queue); in scsih_slave_configure()
2692 blk_queue_virt_boundary(sdev->request_queue, in scsih_slave_configure()
2693 ioc->page_size - 1); in scsih_slave_configure()
2697 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2699 sas_device_priv_data->sas_target->sas_address, in scsih_slave_configure()
2700 sas_device_priv_data->sas_target->port); in scsih_slave_configure()
2702 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2709 sas_device->volume_handle = volume_handle; in scsih_slave_configure()
2710 sas_device->volume_wwid = volume_wwid; in scsih_slave_configure()
2711 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_slave_configure()
2712 qdepth = (sas_device->port_type > 1) ? in scsih_slave_configure()
2713 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_slave_configure()
2715 if (sas_device->device_info & in scsih_slave_configure()
2719 sas_device_priv_data->sas_target->handle); in scsih_slave_configure()
2720 sas_device_priv_data->ignore_delay_remove = 1; in scsih_slave_configure()
2725 qdepth = ioc->max_sata_qd; in scsih_slave_configure()
2726 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_slave_configure()
2728 else if (sas_device->device_info & in scsih_slave_configure()
2735 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_slave_configure()
2736 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_slave_configure()
2741 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2758 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2804 * _scsih_response_code - translation of device response code
2846 * _scsih_tm_done - tm completion routine
2863 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2865 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2867 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2870 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2871 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2873 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2874 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2879 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2892 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2895 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2898 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2899 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2901 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2907 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2920 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2923 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2926 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2927 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2929 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2935 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2951 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2967 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2968 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2969 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2971 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2972 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2973 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2981 * scsih_tm_post_processing - post processing of target & LUN reset
3025 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3040 * The callback index is set inside `ioc->tm_cb_idx`.
3058 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3060 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3065 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3066 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3091 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3100 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3102 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3104 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3105 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3106 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3107 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3110 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3111 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3112 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3114 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3115 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3116 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3117 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3119 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3132 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3134 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3137 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3138 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3139 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3140 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3141 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3142 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3163 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3188 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3198 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3201 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3207 * _scsih_tm_display_info - displays info about the device
3216 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3217 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3225 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3231 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3234 device_str, priv_target->handle, in _scsih_tm_display_info()
3235 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3237 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3238 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3243 pcie_device->handle, in _scsih_tm_display_info()
3244 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3245 pcie_device->port_num); in _scsih_tm_display_info()
3246 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3250 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3251 pcie_device->slot); in _scsih_tm_display_info()
3252 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3255 pcie_device->enclosure_level, in _scsih_tm_display_info()
3256 pcie_device->connector_name); in _scsih_tm_display_info()
3259 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3262 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3265 if (priv_target->flags & in _scsih_tm_display_info()
3270 sas_device->volume_handle, in _scsih_tm_display_info()
3271 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3275 sas_device->handle, in _scsih_tm_display_info()
3276 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3277 sas_device->phy); in _scsih_tm_display_info()
3284 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3289 * scsih_abort - eh threads main abort routine
3297 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3305 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3307 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3308 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3311 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3312 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3313 ioc->remove_host) { in scsih_abort()
3314 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3316 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3317 scmd->scsi_done(scmd); in scsih_abort()
3323 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3324 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3326 scmd->result = DID_RESET << 16; in scsih_abort()
3332 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3334 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3335 scmd->result = DID_RESET << 16; in scsih_abort()
3342 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3344 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3345 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3346 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3347 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3348 scmd->device->id, scmd->device->lun, in scsih_abort()
3350 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3352 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3355 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3363 * scsih_dev_reset - eh threads main device reset routine
3371 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3380 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3381 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3383 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3387 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3388 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3389 ioc->remove_host) { in scsih_dev_reset()
3390 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3392 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3393 scmd->scsi_done(scmd); in scsih_dev_reset()
3400 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3405 handle = sas_device->volume_handle; in scsih_dev_reset()
3407 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3410 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3417 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3418 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3419 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3424 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3425 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3429 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3432 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3444 * scsih_target_reset - eh threads main target reset routine
3452 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3460 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3461 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3467 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3468 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3469 ioc->remove_host) { in scsih_target_reset()
3472 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3473 scmd->scsi_done(scmd); in scsih_target_reset()
3480 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3485 handle = sas_device->volume_handle; in scsih_target_reset()
3487 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3490 scmd->result = DID_RESET << 16; in scsih_target_reset()
3497 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3498 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3499 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3503 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3504 scmd->device->id, 0, in scsih_target_reset()
3508 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3523 * scsih_host_reset - eh threads main host reset routine
3531 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3537 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3553 * _scsih_fw_event_add - insert and queue up fw_event
3556 * Context: This function will acquire ioc->fw_event_lock.
3566 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3569 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3571 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3572 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3573 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3575 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3576 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3580 * _scsih_fw_event_del_from_list - delete fw_event from the list
3583 * Context: This function will acquire ioc->fw_event_lock.
3593 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3594 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3595 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3598 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3603 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3614 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3620 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3621 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3622 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3628 * _scsih_error_recovery_delete_devices - remove devices not responding
3639 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3640 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3646 * mpt3sas_port_enable_complete - port enable completed (fake event)
3657 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3658 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3668 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3669 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3670 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3672 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3674 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3680 * _scsih_fw_event_cleanup_queue - cleanup event queue
3693 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3694 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3702 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3703 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3705 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3707 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3723 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3724 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3726 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3731 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3738 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3739 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3740 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3751 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3756 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3760 * _scsih_internal_device_block - block the sdev device
3774 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3775 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3778 if (r == -EINVAL) in _scsih_internal_device_block()
3781 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3785 * _scsih_internal_device_unblock - unblock the sdev device
3799 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3800 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3802 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3811 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3812 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3817 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3819 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3824 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3829 * _scsih_ublock_io_all_device - unblock every device
3840 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3841 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3844 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3849 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3856 * _scsih_ublock_io_device - prepare device to be deleted
3870 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3871 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3874 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3877 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3879 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3886 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3897 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3898 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3901 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3903 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3906 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3914 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3929 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3930 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3933 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3935 if (sas_device_priv_data->block) in _scsih_block_io_device()
3937 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3939 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3942 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3974 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3975 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3977 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3979 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3980 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3982 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3983 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3986 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3991 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3993 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3995 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3999 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
4000 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
4023 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4024 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4027 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4050 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4052 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4055 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4062 * _scsih_tm_tr_send - send task management request
4091 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4106 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4109 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4111 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4113 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4114 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4115 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4116 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4117 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4118 port = sas_device->port; in _scsih_tm_tr_send()
4120 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4122 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4124 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4125 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4126 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4127 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4128 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4130 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4131 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4133 pcie_device->device_info)))) in _scsih_tm_tr_send()
4144 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4147 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4148 sas_device->slot)); in _scsih_tm_tr_send()
4149 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4152 sas_device->enclosure_level, in _scsih_tm_tr_send()
4153 sas_device->connector_name)); in _scsih_tm_tr_send()
4155 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4158 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4159 pcie_device->slot)); in _scsih_tm_tr_send()
4160 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4163 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4164 pcie_device->connector_name)); in _scsih_tm_tr_send()
4167 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4170 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4175 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4176 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4177 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4186 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4189 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4190 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4191 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4192 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4193 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4194 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4205 * _scsih_tm_tr_complete -
4233 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4252 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4253 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4257 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4264 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4265 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4266 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4268 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4273 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4274 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4275 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4284 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4287 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4288 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4289 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4290 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4295 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4306 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4309 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4310 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4316 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4318 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4331 * _scsih_sas_control_complete - completion routine
4355 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4356 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4357 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4358 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4360 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4361 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4371 * _scsih_tm_tr_volume_send - send target reset request for volumes
4387 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4394 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4399 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4400 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4401 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4410 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4413 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4414 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4415 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4416 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4420 * _scsih_tm_volume_tr_complete - target reset completion
4439 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4452 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4453 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4456 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4463 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4464 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4465 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4471 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4477 * Context - processed in interrupt context.
4484 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4491 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4492 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4493 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4497 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4500 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4501 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4502 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4503 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4504 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4505 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4509 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4515 * Context - processed in interrupt context.
4523 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4526 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4531 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4549 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4550 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4551 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4555 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4558 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4559 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4560 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4561 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4565 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4583 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4584 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4587 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4588 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4593 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4594 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4597 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4598 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4606 * _scsih_check_for_pending_tm - check for pending task management
4621 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4622 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4625 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4626 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4631 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4632 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4635 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4636 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4645 * _scsih_check_topo_delete_events - sanity check on topo events
4667 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4668 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4671 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4677 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4678 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4682 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4685 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4689 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4691 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4692 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4693 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4695 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4696 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4699 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4703 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4704 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4705 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4706 fw_event->ignore) in _scsih_check_topo_delete_events()
4709 fw_event->event_data; in _scsih_check_topo_delete_events()
4710 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4712 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4714 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4718 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4722 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4726 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4746 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4748 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4751 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4756 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4763 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4765 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4770 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4774 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4775 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4776 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4777 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4781 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4782 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4784 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4786 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4790 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4794 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4798 * _scsih_set_volume_delete_flag - setting volume delete flag
4811 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4813 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4814 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4816 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4817 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4820 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4822 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4826 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4833 * input handle is non-zero, or when a and b have not been set before.
4847 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4870 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4874 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4875 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4876 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4879 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4881 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4883 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4890 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4891 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4892 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4895 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4896 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4907 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4908 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4909 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4911 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4912 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4913 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4919 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4920 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4921 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4932 * _scsih_check_volume_delete_events - set delete flag for volumes
4947 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4949 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4953 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4957 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4967 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4969 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4970 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4971 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4972 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4973 event_data->SensorNum); in _scsih_temp_threshold_events()
4974 ioc_err(ioc, "Current Temp In Celsius: %d\n", in _scsih_temp_threshold_events()
4975 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4976 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4993 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4995 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4999 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5001 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5006 * _scsih_flush_running_cmds - completing outstanding commands.
5020 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5029 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5030 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5032 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5033 scmd->scsi_done(scmd); in _scsih_flush_running_cmds()
5039 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5065 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5068 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5071 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5074 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5078 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5080 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5082 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5086 * _scsih_eedp_error_handling - return sense code for EEDP errors
5114 * scsih_qcmd - main scsi request entry point
5118 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5139 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5142 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5143 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5144 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5145 scmd->scsi_done(scmd); in scsih_qcmd()
5150 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5151 scmd->scsi_done(scmd); in scsih_qcmd()
5155 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5158 handle = sas_target_priv_data->handle; in scsih_qcmd()
5160 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5161 scmd->scsi_done(scmd); in scsih_qcmd()
5166 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5169 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5171 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5172 scmd->scsi_done(scmd); in scsih_qcmd()
5174 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5175 sas_device_priv_data->block) { in scsih_qcmd()
5186 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5190 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5192 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5200 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5208 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5209 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5210 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5213 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5220 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5223 if (scmd->cmd_len == 32) in scsih_qcmd()
5225 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5226 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5228 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5230 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5231 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5232 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5233 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5234 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5235 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5236 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5237 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5239 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5240 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5241 mpi_request->LUN); in scsih_qcmd()
5242 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5244 if (mpi_request->DataLength) { in scsih_qcmd()
5245 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5246 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5252 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5254 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5255 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5259 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5260 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5261 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5263 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5265 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5266 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5268 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5276 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5285 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5286 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5287 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5290 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5291 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5292 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5297 * _scsih_scsi_ioc_info - translated non-succesfull SCSI_IO request
5303 * scsi_status - SCSI Status code returned from target device
5304 * scsi_state - state info associated with SCSI_IO determined by ioc
5305 * ioc_status - ioc supplied status info
5313 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5315 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5316 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5319 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5320 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5323 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5324 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5329 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5452 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5454 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5455 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5459 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5460 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5462 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5463 pcie_device->slot); in _scsih_scsi_ioc_info()
5464 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5466 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5467 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5474 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5484 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5487 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5488 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5489 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5490 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5496 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5499 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5502 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5509 * _scsih_turn_on_pfa_led - illuminate PFA LED
5538 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5552 * _scsih_turn_off_pfa_led - turn off Fault LED
5568 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5570 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5589 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5602 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5603 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5604 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5610 * _scsih_smart_predicted_fault - process smart errors
5626 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5627 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5632 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5633 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5635 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5636 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5641 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5643 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5656 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5657 event_reply->Event = in _scsih_smart_predicted_fault()
5659 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5660 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5663 event_reply->EventData; in _scsih_smart_predicted_fault()
5664 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5665 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5666 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5667 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5676 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5681 * _scsih_io_done - scsi request callback
5718 scmd->result = DID_OK << 16; in _scsih_io_done()
5722 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5723 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5724 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5725 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5728 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5735 if (st->direct_io && in _scsih_io_done()
5738 st->direct_io = 0; in _scsih_io_done()
5739 st->scmd = scmd; in _scsih_io_done()
5740 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5741 mpi_request->DevHandle = in _scsih_io_done()
5742 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5743 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5744 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5748 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5751 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5752 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5753 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5754 if ((!ioc->is_warpdrive && in _scsih_io_done()
5755 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5756 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5757 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5759 sas_disable_tlr(scmd->device); in _scsih_io_done()
5760 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5764 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5765 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5767 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5771 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5785 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5786 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5787 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5791 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5794 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5795 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5796 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5797 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5803 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5807 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5811 if (sas_device_priv_data->block) { in _scsih_io_done()
5812 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5816 if (scmd->retries > 2) { in _scsih_io_done()
5817 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5818 scsi_device_set_state(scmd->device, in _scsih_io_done()
5821 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5822 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5826 scmd->result = DID_RESET << 16; in _scsih_io_done()
5828 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5831 scmd->result = DID_RESET << 16; in _scsih_io_done()
5834 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5838 scmd->result = DID_RESET << 16; in _scsih_io_done()
5842 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5843 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5845 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5849 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5854 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5856 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5858 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5861 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5863 scmd->result = DID_RESET << 16; in _scsih_io_done()
5864 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5865 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5866 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5877 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5882 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5884 scmd->result = DID_RESET << 16; in _scsih_io_done()
5903 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5908 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5915 scmd->scsi_done(scmd); in _scsih_io_done()
5920 * _scsih_update_vphys_after_reset - update the Port's
5945 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5946 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5949 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5950 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5958 (ioc->sas_hba.num_phys * sizeof(Mpi2SasIOUnit0PhyData_t)); in _scsih_update_vphys_after_reset()
5974 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5978 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
5989 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6007 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6022 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6023 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6026 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6031 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6039 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6045 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6046 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6054 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6061 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6064 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6065 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6066 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6076 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6078 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6079 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6080 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6081 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6082 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6086 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6096 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6097 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6098 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6099 mport->flags &= in _scsih_update_vphys_after_reset()
6105 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6118 * _scsih_get_port_table_after_reset - Construct temporary port table
6136 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_get_port_table_after_reset()
6151 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6153 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6157 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6166 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6178 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6198 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6218 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6219 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6222 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6223 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6229 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6230 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6231 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6237 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6238 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6247 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6266 * _scsih_del_phy_part_of_anther_port - remove phy if it
6280 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6289 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6299 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6314 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6316 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6318 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6326 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6328 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6330 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6331 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6338 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6350 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6351 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6354 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6355 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6358 vphy, port->port_id, in _scsih_del_dirty_vphy()
6359 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6360 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6361 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6365 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6366 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6371 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6382 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6383 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6384 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6389 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6390 list_del(&port->list); in _scsih_del_dirty_port_entries()
6396 * _scsih_sas_port_refresh - Update HBA port table after host reset
6412 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6414 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6430 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6431 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6435 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6438 port_table_entry->port_id, in _scsih_sas_port_refresh()
6439 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6440 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6477 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6478 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6479 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6480 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6487 * _scsih_alloc_vphy - allocate virtual_phy object
6510 if (!port->vphys_mask) in _scsih_alloc_vphy()
6511 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6517 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6518 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6520 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6524 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6530 * _scsih_sas_host_refresh - refreshing sas host object contents
6553 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6555 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_sas_host_refresh()
6570 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6571 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6573 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6574 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6575 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6581 port->port_id = port_id; in _scsih_sas_host_refresh()
6584 port, port->port_id); in _scsih_sas_host_refresh()
6585 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6586 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6587 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6592 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6611 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6614 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6615 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6619 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6621 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6623 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6630 * _scsih_sas_host_add - create sas host object
6633 * Creating host side data object, stored in ioc->sas_hba
6657 ioc->sas_hba.phy = kcalloc(num_phys, in _scsih_sas_host_add()
6659 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6664 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6667 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6690 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6712 ioc->io_missing_delay = in _scsih_sas_host_add()
6713 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6715 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6717 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6720 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6723 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6724 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6740 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6743 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6749 port->port_id = port_id; in _scsih_sas_host_add()
6752 port, port->port_id); in _scsih_sas_host_add()
6753 list_add_tail(&port->list, in _scsih_sas_host_add()
6754 &ioc->port_table_list); in _scsih_sas_host_add()
6769 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6772 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6773 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6774 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6776 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6777 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6780 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6785 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6787 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6789 ioc->sas_hba.handle, in _scsih_sas_host_add()
6790 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6791 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6793 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6796 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6797 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6807 * _scsih_expander_add - creating expander object
6811 * Creating expander object, stored in ioc->sas_expander_list.
6834 return -1; in _scsih_expander_add()
6836 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6837 return -1; in _scsih_expander_add()
6843 return -1; in _scsih_expander_add()
6851 return -1; in _scsih_expander_add()
6860 return -1; in _scsih_expander_add()
6864 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6865 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6869 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6877 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6881 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6891 return -1; in _scsih_expander_add()
6894 sas_expander->handle = handle; in _scsih_expander_add()
6895 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6896 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6897 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6898 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6899 if (!sas_expander->port) { in _scsih_expander_add()
6902 rc = -1; in _scsih_expander_add()
6908 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6910 if (!sas_expander->num_phys) { in _scsih_expander_add()
6911 rc = -1; in _scsih_expander_add()
6914 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6916 if (!sas_expander->phy) { in _scsih_expander_add()
6919 rc = -1; in _scsih_expander_add()
6923 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6925 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6929 rc = -1; in _scsih_expander_add()
6932 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6933 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
6935 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
6940 rc = -1; in _scsih_expander_add()
6943 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
6944 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
6945 sas_expander->phy[i].port = in _scsih_expander_add()
6949 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
6950 sas_expander->parent_dev))) { in _scsih_expander_add()
6953 rc = -1; in _scsih_expander_add()
6958 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
6961 sas_expander->enclosure_handle); in _scsih_expander_add()
6963 sas_expander->enclosure_logical_id = in _scsih_expander_add()
6964 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
6973 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
6974 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6980 * mpt3sas_expander_remove - removing expander object
6992 if (ioc->shost_recovery) in mpt3sas_expander_remove()
6998 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7001 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7007 * _scsih_done - internal SCSI_IO callback handler.
7014 * The callback index passed is `ioc->scsih_cb_idx`
7025 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7027 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7029 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7031 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7032 mpi_reply->MsgLength*4); in _scsih_done()
7033 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7035 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7036 complete(&ioc->scsih_cmds.done); in _scsih_done()
7047 * _scsih_check_access_status - check access flags
7110 * _scsih_check_device - checking device responsiveness
7152 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7163 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7164 starget = sas_device->starget; in _scsih_check_device()
7165 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7168 sas_device->handle, handle); in _scsih_check_device()
7169 sas_target_priv_data->handle = handle; in _scsih_check_device()
7170 sas_device->handle = handle; in _scsih_check_device()
7173 sas_device->enclosure_level = in _scsih_check_device()
7175 memcpy(sas_device->connector_name, in _scsih_check_device()
7177 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7179 sas_device->enclosure_level = 0; in _scsih_check_device()
7180 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7183 sas_device->enclosure_handle = in _scsih_check_device()
7185 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7187 sas_device->enclosure_handle); in _scsih_check_device()
7189 sas_device->enclosure_logical_id = in _scsih_check_device()
7190 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7191 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7193 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7194 sas_device->chassis_slot = in _scsih_check_device()
7195 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7213 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7221 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7227 * _scsih_add_device - creating sas device object
7233 * Creating end device object, stored in ioc->sas_device_list.
7235 * Return: 0 for success, non-zero for failure.
7254 return -1; in _scsih_add_device()
7262 return -1; in _scsih_add_device()
7268 return -1; in _scsih_add_device()
7269 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7277 return -1; in _scsih_add_device()
7283 return -1; in _scsih_add_device()
7289 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7291 return -1; in _scsih_add_device()
7311 kref_init(&sas_device->refcount); in _scsih_add_device()
7312 sas_device->handle = handle; in _scsih_add_device()
7315 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7318 sas_device->enclosure_handle = in _scsih_add_device()
7320 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7321 sas_device->slot = in _scsih_add_device()
7323 sas_device->device_info = device_info; in _scsih_add_device()
7324 sas_device->sas_address = sas_address; in _scsih_add_device()
7325 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7326 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7328 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7329 if (!sas_device->port) { in _scsih_add_device()
7337 sas_device->enclosure_level = in _scsih_add_device()
7339 memcpy(sas_device->connector_name, in _scsih_add_device()
7341 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7343 sas_device->enclosure_level = 0; in _scsih_add_device()
7344 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7347 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7349 sas_device->enclosure_logical_id = in _scsih_add_device()
7350 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7351 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7353 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7354 sas_device->chassis_slot = in _scsih_add_device()
7355 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7360 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7361 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7364 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7366 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7377 * _scsih_remove_device - removing sas device object
7387 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7388 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7390 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7396 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7401 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7402 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7403 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7404 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7405 sas_device->port); in _scsih_remove_device()
7406 sas_target_priv_data->handle = in _scsih_remove_device()
7410 if (!ioc->hide_drives) in _scsih_remove_device()
7412 sas_device->sas_address, in _scsih_remove_device()
7413 sas_device->sas_address_parent, in _scsih_remove_device()
7414 sas_device->port); in _scsih_remove_device()
7417 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7424 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7430 * _scsih_sas_topology_change_event_debug - debug for topology event
7446 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7467 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7468 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7469 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7470 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7471 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7474 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7475 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7497 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7498 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7507 * _scsih_sas_topology_change_event - handle topology changes
7528 fw_event->event_data; in _scsih_sas_topology_change_event()
7530 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7533 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7536 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7541 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7546 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7547 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7550 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7554 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7558 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7559 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7560 port = sas_expander->port; in _scsih_sas_topology_change_event()
7561 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7562 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7563 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7565 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7568 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7571 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7572 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7577 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7579 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7582 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7584 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7588 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7591 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7592 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7596 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7611 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7618 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7635 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7643 * _scsih_sas_device_status_change_event_debug - debug for device event
7654 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7699 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7700 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7701 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7702 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7704 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7709 * _scsih_sas_device_status_change_event - handle device status change
7726 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7729 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7731 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7735 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7736 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7739 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7741 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7744 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7748 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7750 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7752 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7754 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7757 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7758 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7764 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7769 * _scsih_check_pcie_access_status - check access flags
7857 * _scsih_pcie_device_remove_from_sml - removing pcie device
7871 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7872 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7876 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7877 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7878 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7882 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7883 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7885 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7886 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7887 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7888 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7889 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7893 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7894 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7896 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7897 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7898 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7900 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7901 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7903 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7905 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7909 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7910 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7914 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7915 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7916 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7920 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7921 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7923 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7928 * _scsih_pcie_check_device - checking device responsiveness
7959 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7963 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7967 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
7968 starget = pcie_device->starget; in _scsih_pcie_check_device()
7969 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
7970 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
7973 pcie_device->handle, handle); in _scsih_pcie_check_device()
7974 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
7975 pcie_device->handle = handle; in _scsih_pcie_check_device()
7979 pcie_device->enclosure_level = in _scsih_pcie_check_device()
7981 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
7984 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
7985 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
7994 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8002 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8007 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8016 * _scsih_pcie_add_device - creating pcie device object
8020 * Creating end device object, stored in ioc->pcie_device_list.
8049 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8071 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8076 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8108 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8109 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8110 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8111 pcie_device->handle = handle; in _scsih_pcie_add_device()
8112 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8113 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8114 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8115 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8116 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8119 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8121 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8122 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8126 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8127 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8130 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8131 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8135 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8138 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8140 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8141 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8143 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8146 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8148 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8155 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8156 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8157 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8159 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8162 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8164 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8166 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8176 * _scsih_pcie_topology_change_event_debug - debug for topology
8193 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8214 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8215 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8216 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8217 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8219 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8222 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8223 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8244 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8246 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8255 * _scsih_pcie_topology_change_event - handle PCIe topology
8273 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8276 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8279 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8280 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8283 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8289 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8290 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8295 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8297 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8299 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8303 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8305 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8310 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8325 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8327 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8334 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8340 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8341 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8345 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8357 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8369 * _scsih_pcie_device_status_change_event_debug - debug for device event
8380 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8424 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8425 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8426 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8427 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8429 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8434 * _scsih_pcie_device_status_change_event - handle device status
8449 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8450 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8454 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8456 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8460 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8461 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8464 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8467 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8471 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8473 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8475 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8480 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8484 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8496 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8511 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8512 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8513 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8517 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8529 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8531 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8533 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8536 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8537 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8544 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8556 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8566 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8567 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8572 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8582 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8602 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8609 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8611 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8615 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8616 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8626 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8630 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8631 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8637 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8638 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8639 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8642 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8646 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8650 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8654 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8655 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8658 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8661 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8663 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8664 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8669 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8672 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8678 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8683 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8685 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8687 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8696 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8700 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8703 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8704 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8705 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8706 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8717 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8719 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8720 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8723 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8728 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8733 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8737 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8740 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8741 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8743 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8747 * _scsih_sas_discovery_event - handle discovery events
8757 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8759 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8761 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8763 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8765 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8769 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8770 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8771 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8773 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8781 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8792 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8794 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8797 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8798 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8799 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8803 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8804 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8805 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8813 * _scsih_pcie_enumeration_event - handle enumeration events
8823 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8825 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8829 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8831 event_data->Flags); in _scsih_pcie_enumeration_event()
8832 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8834 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8839 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8857 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8860 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8862 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8864 rc = -EAGAIN; in _scsih_ir_fastpath()
8867 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8869 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8872 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8873 rc = -EAGAIN; in _scsih_ir_fastpath()
8878 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8881 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8882 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8883 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8889 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8890 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8891 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8893 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8895 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8897 rc = -EFAULT; in _scsih_ir_fastpath()
8901 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8903 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8904 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8906 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8914 rc = -EFAULT; in _scsih_ir_fastpath()
8921 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8922 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8930 * _scsih_reprobe_lun - reprobing lun
8932 * @no_uld_attach: sdev->no_uld_attach flag setting
8938 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
8940 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
8945 * _scsih_sas_volume_add - add new volume
8957 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
8967 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8969 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8981 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
8982 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
8983 raid_device->handle = handle; in _scsih_sas_volume_add()
8984 raid_device->wwid = wwid; in _scsih_sas_volume_add()
8986 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
8987 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
8988 raid_device->id, 0); in _scsih_sas_volume_add()
8992 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8994 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8999 * _scsih_sas_volume_delete - delete volume
9012 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9015 if (raid_device->starget) { in _scsih_sas_volume_delete()
9016 starget = raid_device->starget; in _scsih_sas_volume_delete()
9017 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9018 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9021 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9022 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9025 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9027 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9031 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9044 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
9046 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9049 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9050 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9051 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9052 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9053 starget = sas_device->starget; in _scsih_sas_pd_expose()
9054 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9055 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9059 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9071 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9084 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
9093 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9096 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9097 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9098 starget = sas_device->starget; in _scsih_sas_pd_hide()
9099 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9100 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9102 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9103 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9106 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9111 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9120 * _scsih_sas_pd_delete - delete pd component
9129 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
9135 * _scsih_sas_pd_add - remove pd component
9145 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
9152 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9156 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9183 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9188 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9202 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9205 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9207 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9208 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9209 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9241 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9259 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9260 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9261 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9266 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9280 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9282 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9283 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9286 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9289 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9290 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9291 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9292 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9293 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9295 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9296 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9301 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9303 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9313 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9316 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9320 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9324 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9328 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9336 * _scsih_sas_ir_volume_event - IR volume event
9352 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9354 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9357 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9360 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9361 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9362 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9366 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9378 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9380 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9399 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9400 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9401 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9402 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9404 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9405 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9417 * _scsih_sas_ir_physical_disk_event - PD event
9433 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9436 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9439 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9442 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9443 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9445 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9449 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9459 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9460 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9504 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9515 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9538 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9539 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9543 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9554 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9559 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9560 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9565 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9567 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9568 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9571 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9572 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9573 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9578 * _scsih_prep_device_scan - initialize parameters prior to device scan
9590 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9591 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9592 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9593 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9598 * _scsih_update_device_qdepth - Update QD during Reset.
9612 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9613 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9614 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9615 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9616 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9617 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9618 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9620 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9621 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9622 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9624 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9625 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9634 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9651 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9653 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9656 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9659 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9661 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9662 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9663 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9664 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9666 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9668 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9670 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9671 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9672 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9673 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9674 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9675 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9681 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9683 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9685 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9689 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9690 sas_device->slot); in _scsih_mark_responding_sas_device()
9692 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9694 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9695 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9696 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9697 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9699 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9700 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9703 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9704 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9705 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9707 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9708 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9709 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9711 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9712 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9713 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9717 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9718 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9721 sas_device->handle); in _scsih_mark_responding_sas_device()
9722 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9723 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9725 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9726 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9730 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9734 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9760 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9769 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9770 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9772 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9777 * _scsih_search_responding_sas_devices -
9792 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9794 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9813 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9817 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9833 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9834 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9835 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9836 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9837 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9838 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9839 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9840 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9841 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9842 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9843 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9844 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9845 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9851 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9852 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9853 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9858 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9859 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9862 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9864 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9865 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9866 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9867 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9868 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9870 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9871 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9874 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9875 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9878 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9879 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9880 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9882 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9883 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9889 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9893 * _scsih_search_responding_pcie_devices -
9908 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9910 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
9932 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
9936 * _scsih_mark_responding_raid_device - mark a raid_device as responding
9953 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9954 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
9955 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
9956 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
9957 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
9958 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
9959 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
9962 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
9963 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9964 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
9966 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
9970 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
9974 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9975 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
9976 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
9981 raid_device->handle); in _scsih_mark_responding_raid_device()
9982 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
9984 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
9985 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9989 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9993 * _scsih_search_responding_raid_devices -
10010 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10015 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10040 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10042 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10052 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10060 * _scsih_mark_responding_expander - mark a expander as responding
10075 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
10076 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10077 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10079 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10086 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10087 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10088 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10090 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10092 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10095 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10096 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10097 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10098 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10101 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10105 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10106 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10107 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10108 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10109 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10113 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10117 * _scsih_search_responding_expanders -
10135 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10153 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10163 * _scsih_remove_unresponding_devices - removing unresponding devices
10180 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10182 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10185 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10192 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10193 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10198 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10199 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10200 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10202 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10204 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10211 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10215 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10217 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10223 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10224 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10229 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10230 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10231 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10233 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10235 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10239 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10244 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10247 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10248 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10250 raid_device->handle); in _scsih_remove_unresponding_devices()
10252 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10258 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10261 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10262 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10263 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10265 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10267 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10287 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10295 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10298 sas_expander->port); in _scsih_refresh_expander_links()
10303 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10356 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10361 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10378 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10424 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10455 handle = le16_to_cpu(volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10456 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10458 le64_to_cpu(volume_pg1->WWID)); in _scsih_scan_for_devices_after_reset()
10459 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10473 if (volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL || in _scsih_scan_for_devices_after_reset()
10474 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_ONLINE || in _scsih_scan_for_devices_after_reset()
10475 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) { in _scsih_scan_for_devices_after_reset()
10478 element.VolDevHandle = volume_pg1->DevHandle; in _scsih_scan_for_devices_after_reset()
10480 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10483 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10580 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10591 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10602 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10603 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10604 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10605 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10607 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10608 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10609 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10610 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10613 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10614 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10615 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10621 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10630 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10631 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10646 * _mpt3sas_fw_work - delayed task for processing firmware events
10654 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10658 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10660 ioc->current_event = NULL; in _mpt3sas_fw_work()
10664 switch (fw_event->event) { in _mpt3sas_fw_work()
10668 fw_event->event_data); in _mpt3sas_fw_work()
10671 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10672 ioc->shost_recovery) { in _mpt3sas_fw_work()
10677 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10684 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10691 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10692 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10693 *- start the watchdog thread. in _mpt3sas_fw_work()
10697 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10702 ioc->start_scan = 0; in _mpt3sas_fw_work()
10703 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10710 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10716 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10719 fw_event->event_data); in _mpt3sas_fw_work()
10754 ioc->current_event = NULL; in _mpt3sas_fw_work()
10759 ioc->current_event = NULL; in _mpt3sas_fw_work()
10776 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10780 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10786 * This function merely adds a new work task into ioc->firmware_event_thread.
10803 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10814 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10825 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10827 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10831 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10832 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10835 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10842 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10851 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10857 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10858 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10864 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10869 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10876 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10880 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10881 log_code = (u32 *)log_entry->LogData; in mpt3sas_scsih_event_callback()
10883 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10892 …ive Warning: Program/Erase Cycles for the WarpDrive subsystem in degraded range. Check WarpDrive d… in mpt3sas_scsih_event_callback()
10895 …Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode. Check Warp… in mpt3sas_scsih_event_callback()
10907 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10921 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10925 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10926 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10929 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10934 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
10939 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10951 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
10959 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
10960 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
10961 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
10962 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
10963 fw_event->event = event; in mpt3sas_scsih_event_callback()
10970 * _scsih_expander_node_remove - removing expander device from list.
10975 * ioc->sas_expander_list.
10986 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
10987 if (ioc->shost_recovery) in _scsih_expander_node_remove()
10989 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
10992 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
10993 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
10994 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
10996 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
10999 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11000 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11003 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11004 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11008 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11009 sas_expander->sas_address, in _scsih_expander_node_remove()
11010 sas_expander->port->port_id); in _scsih_expander_node_remove()
11012 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11013 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11014 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11016 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11021 * _scsih_nvme_shutdown - NVMe shutdown notification
11036 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11039 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11041 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11046 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11048 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11052 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11057 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11059 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11060 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11062 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11063 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11067 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11068 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11069 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11071 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11076 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11077 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11080 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11081 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11084 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11085 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11090 * _scsih_ir_shutdown - IR shutdown notification
11104 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11108 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11111 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11113 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11117 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11119 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11122 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11127 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11130 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11131 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11133 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11135 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11136 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11137 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11139 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11144 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11145 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11146 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11148 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11149 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11153 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11154 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11158 * _scsih_get_shost_and_ioc - get shost and ioc
11172 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11173 return -ENXIO; in _scsih_get_shost_and_ioc()
11178 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11179 return -ENXIO; in _scsih_get_shost_and_ioc()
11186 * scsih_remove - detach and remove add host
11207 ioc->remove_host = 1; in scsih_remove()
11216 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11217 wq = ioc->firmware_event_thread; in scsih_remove()
11218 ioc->firmware_event_thread = NULL; in scsih_remove()
11219 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11226 if (ioc->is_aero_ioc) in scsih_remove()
11228 &ioc->ioc_pg1_copy); in scsih_remove()
11233 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11235 if (raid_device->starget) { in scsih_remove()
11237 raid_device->starget->hostdata; in scsih_remove()
11238 sas_target_priv_data->deleted = 1; in scsih_remove()
11239 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11242 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11245 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11248 list_del_init(&pcie_device->list); in scsih_remove()
11254 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11255 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11258 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11259 mpt3sas_port->hba_port); in scsih_remove()
11260 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11262 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11265 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11266 mpt3sas_port->hba_port); in scsih_remove()
11270 &ioc->port_table_list, list) { in scsih_remove()
11271 list_del(&port->list); in scsih_remove()
11276 if (ioc->sas_hba.num_phys) { in scsih_remove()
11277 kfree(ioc->sas_hba.phy); in scsih_remove()
11278 ioc->sas_hba.phy = NULL; in scsih_remove()
11279 ioc->sas_hba.num_phys = 0; in scsih_remove()
11284 list_del(&ioc->list); in scsih_remove()
11290 * scsih_shutdown - routine call during system shutdown
11305 ioc->remove_host = 1; in scsih_shutdown()
11314 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11315 wq = ioc->firmware_event_thread; in scsih_shutdown()
11316 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11317 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11324 if (ioc->is_aero_ioc) in scsih_shutdown()
11326 &ioc->ioc_pg1_copy); in scsih_shutdown()
11331 ioc->shost_recovery = 1; in scsih_shutdown()
11333 ioc->shost_recovery = 0; in scsih_shutdown()
11340 * _scsih_probe_boot_devices - reports 1st device
11344 * device scsi-ml or sas transport for persistent boot device
11364 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11368 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11369 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11370 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11371 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11372 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11373 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11374 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11375 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11376 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11389 if (raid_device->starget) in _scsih_probe_boot_devices()
11391 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11392 raid_device->id, 0); in _scsih_probe_boot_devices()
11402 if (pcie_device->starget) in _scsih_probe_boot_devices()
11404 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11405 tid = pcie_device->id; in _scsih_probe_boot_devices()
11406 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11407 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11408 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11418 if (sas_device->starget) in _scsih_probe_boot_devices()
11420 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11421 handle = sas_device->handle; in _scsih_probe_boot_devices()
11422 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11423 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11424 port = sas_device->port; in _scsih_probe_boot_devices()
11425 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11426 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11428 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11437 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11438 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11449 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11461 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11462 if (raid_device->starget) in _scsih_probe_raid()
11464 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11465 raid_device->id, 0); in _scsih_probe_raid()
11476 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11477 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11478 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11482 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11492 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11502 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11503 list_del_init(&sas_device->list); in sas_device_make_active()
11508 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11510 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11514 * _scsih_probe_sas - reporting sas devices to sas transport
11524 if (ioc->hide_drives) in _scsih_probe_sas()
11528 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11529 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11533 } else if (!sas_device->starget) { in _scsih_probe_sas()
11537 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11540 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11542 sas_device->sas_address, in _scsih_probe_sas()
11543 sas_device->sas_address_parent, in _scsih_probe_sas()
11544 sas_device->port); in _scsih_probe_sas()
11556 * get_next_pcie_device - Get the next pcie device
11569 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11570 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11571 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11575 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11581 * pcie_device_make_active - Add pcie device to pcie_device_list list
11593 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11595 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11596 list_del_init(&pcie_device->list); in pcie_device_make_active()
11600 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11602 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11606 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11619 if (pcie_device->starget) { in _scsih_probe_pcie()
11623 if (pcie_device->access_status == in _scsih_probe_pcie()
11629 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11630 pcie_device->id, 0); in _scsih_probe_pcie()
11635 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11639 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11642 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11643 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11657 * _scsih_probe_devices - probing for devices
11667 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11672 if (ioc->ir_firmware) { in _scsih_probe_devices()
11674 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11691 * scsih_scan_start - scsi lld callback for .scan_start
11703 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11705 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11711 ioc->start_scan = 1; in scsih_scan_start()
11719 * _scsih_complete_devices_scanning - add the devices to sml and
11728 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11729 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11734 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11738 * scsih_scan_finished - scsi lld callback for .scan_finished
11754 ioc->is_driver_loading = 0; in scsih_scan_finished()
11755 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11760 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11762 ioc->is_driver_loading = 0; in scsih_scan_finished()
11766 if (ioc->start_scan) { in scsih_scan_finished()
11784 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11787 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11790 if (ioc->start_scan_failed) { in scsih_scan_finished()
11792 ioc->start_scan_failed); in scsih_scan_finished()
11793 ioc->is_driver_loading = 0; in scsih_scan_finished()
11794 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11795 ioc->remove_host = 1; in scsih_scan_finished()
11800 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11805 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11807 ioc->is_driver_loading = 0; in scsih_scan_finished()
11813 * scsih_map_queues - map reply queues with request queues
11819 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11822 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11823 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11825 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11828 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11829 map = &shost->tag_set.map[i]; in scsih_map_queues()
11830 map->nr_queues = 0; in scsih_map_queues()
11833 map->nr_queues = in scsih_map_queues()
11834 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11835 offset = ioc->high_iops_queues; in scsih_map_queues()
11837 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11839 if (!map->nr_queues) in scsih_map_queues()
11844 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11846 map->queue_offset = qoff; in scsih_map_queues()
11848 blk_mq_pci_map_queues(map, ioc->pdev, offset); in scsih_map_queues()
11852 qoff += map->nr_queues; in scsih_map_queues()
11877 .this_id = -1,
11915 .this_id = -1,
11937 * _scsih_determine_hba_mpi_version - determine in which MPI version class
11949 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12009 * _scsih_probe - attach and add scsi host
12027 return -ENODEV; in _scsih_probe()
12030 * for other generation HBA's return with -ENODEV in _scsih_probe()
12033 return -ENODEV; in _scsih_probe()
12036 * for other generation HBA's return with -ENODEV in _scsih_probe()
12040 return -ENODEV; in _scsih_probe()
12050 return -ENODEV; in _scsih_probe()
12053 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12054 ioc->id = mpt2_ids++; in _scsih_probe()
12055 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12056 switch (pdev->device) { in _scsih_probe()
12058 ioc->is_warpdrive = 1; in _scsih_probe()
12059 ioc->hide_ir_msg = 1; in _scsih_probe()
12063 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12066 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12070 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12071 ioc->multipath_on_hba = 0; in _scsih_probe()
12073 ioc->multipath_on_hba = 1; in _scsih_probe()
12082 return -ENODEV; in _scsih_probe()
12085 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12086 ioc->id = mpt3_ids++; in _scsih_probe()
12087 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12088 switch (pdev->device) { in _scsih_probe()
12097 ioc->is_gen35_ioc = 1; in _scsih_probe()
12101 dev_err(&pdev->dev, in _scsih_probe()
12103 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12104 pdev->subsystem_device); in _scsih_probe()
12108 dev_err(&pdev->dev, in _scsih_probe()
12110 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12111 pdev->subsystem_device); in _scsih_probe()
12115 dev_info(&pdev->dev, in _scsih_probe()
12120 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12123 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12125 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12126 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12127 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12128 ioc->combined_reply_queue = 1; in _scsih_probe()
12129 if (ioc->is_gen35_ioc) in _scsih_probe()
12130 ioc->combined_reply_index_count = in _scsih_probe()
12133 ioc->combined_reply_index_count = in _scsih_probe()
12137 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12139 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12140 ioc->multipath_on_hba = 0; in _scsih_probe()
12142 ioc->multipath_on_hba = 1; in _scsih_probe()
12145 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12146 ioc->multipath_on_hba = 1; in _scsih_probe()
12148 ioc->multipath_on_hba = 0; in _scsih_probe()
12156 return -ENODEV; in _scsih_probe()
12159 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12161 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12163 ioc->shost = shost; in _scsih_probe()
12164 ioc->pdev = pdev; in _scsih_probe()
12165 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12166 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12167 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12168 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12169 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12170 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12171 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12172 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12173 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12174 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12175 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12176 ioc->logging_level = logging_level; in _scsih_probe()
12177 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12179 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12183 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12185 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12187 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12190 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12192 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12193 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12194 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12195 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12196 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12197 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12198 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12199 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12200 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12202 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12203 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12204 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12205 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12206 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12207 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12208 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12209 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12210 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12211 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12212 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12213 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12214 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12215 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12216 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12218 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12221 shost->max_cmd_len = 32; in _scsih_probe()
12222 shost->max_lun = max_lun; in _scsih_probe()
12223 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12224 shost->unique_id = ioc->id; in _scsih_probe()
12226 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12228 shost->max_sectors = 128; in _scsih_probe()
12230 shost->max_sectors); in _scsih_probe()
12234 shost->max_sectors = 64; in _scsih_probe()
12235 …ioc_warn(ioc, "Invalid value %d passed for max_sectors, range is 64 to 32767. Assigning value of 6… in _scsih_probe()
12238 shost->max_sectors = 32767; in _scsih_probe()
12239 …ioc_warn(ioc, "Invalid value %d passed for max_sectors, range is 64 to 32767.Assigning default val… in _scsih_probe()
12242 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12244 shost->max_sectors); in _scsih_probe()
12259 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
12260 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
12261 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12262 ioc->firmware_event_name, 0); in _scsih_probe()
12263 if (!ioc->firmware_event_thread) { in _scsih_probe()
12266 rv = -ENODEV; in _scsih_probe()
12270 shost->host_tagset = 0; in _scsih_probe()
12272 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12273 shost->host_tagset = 1; in _scsih_probe()
12275 ioc->is_driver_loading = 1; in _scsih_probe()
12279 rv = -ENODEV; in _scsih_probe()
12283 if (ioc->is_warpdrive) { in _scsih_probe()
12284 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12285 ioc->hide_drives = 0; in _scsih_probe()
12286 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12287 ioc->hide_drives = 1; in _scsih_probe()
12290 ioc->hide_drives = 1; in _scsih_probe()
12292 ioc->hide_drives = 0; in _scsih_probe()
12295 ioc->hide_drives = 0; in _scsih_probe()
12297 shost->nr_hw_queues = 1; in _scsih_probe()
12299 if (shost->host_tagset) { in _scsih_probe()
12300 shost->nr_hw_queues = in _scsih_probe()
12301 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12304 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12306 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12308 dev_info(&ioc->pdev->dev, in _scsih_probe()
12310 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12313 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12326 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12329 list_del(&ioc->list); in _scsih_probe()
12336 * scsih_suspend - power management suspend main entry point
12357 ioc_info(ioc, "pdev=0x%p, slot=%s, entering operating state\n", in scsih_suspend()
12365 * scsih_resume - power management resume main entry point
12376 pci_power_t device_state = pdev->current_state; in scsih_resume()
12383 ioc_info(ioc, "pdev=0x%p, slot=%s, previous operating state [D%d]\n", in scsih_resume()
12386 ioc->pdev = pdev; in scsih_resume()
12398 * scsih_pci_error_detected - Called when a PCI error is detected.
12422 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12423 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12429 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12439 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12458 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12459 ioc->pdev = pdev; in scsih_pci_slot_reset()
12478 * scsih_pci_resume() - resume normal ops after PCI reset
12497 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12501 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12515 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12525 * scsih_ncq_prio_supp - Check for NCQ command priority support
12711 * scsih_init - main entry point for this driver.
12762 * scsih_exit - exit point for this driver (when it is a module).
12793 * _mpt3sas_init - main entry point for this driver.
12808 return -ENODEV; in _mpt3sas_init()
12818 return -ENODEV; in _mpt3sas_init()
12830 return -ENODEV; in _mpt3sas_init()
12850 * _mpt3sas_exit - exit point for this driver (when it is a module).