Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width
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;
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
185 * @skey: sense key
186 * @asc: additional sense code
187 * @ascq: additional sense code qualifier
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
263 * @sense: sense data
271 * @sense_length: sense length
287 u8 sense[SCSI_SENSE_BUFFERSIZE]; member
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
1643 * @device_info: bitfield providing information about the device.
1661 * _scsih_is_nvme_pciescsi_device - determines if
1663 * @device_info: bitfield providing information about the device.
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()
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()
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()
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()
3675 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3681 * _scsih_fw_event_cleanup_queue - cleanup event queue
3694 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3695 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3703 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3704 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3706 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3708 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3724 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3725 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3727 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3732 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3739 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3740 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3741 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3752 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()
3872 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) 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()
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()
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()
5150 scmd->result = DID_NO_CONNECT << 16; 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()
5163 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5164 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5165 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5173 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5179 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5182 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5184 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5187 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5188 sas_device_priv_data->block) { in scsih_qcmd()
5199 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5203 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5205 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5213 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5221 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5222 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5223 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5226 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5233 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5236 if (scmd->cmd_len == 32) in scsih_qcmd()
5238 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5239 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5241 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5243 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5244 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5245 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5246 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5247 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5248 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5249 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5250 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5252 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5253 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5254 mpi_request->LUN); in scsih_qcmd()
5255 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5257 if (mpi_request->DataLength) { in scsih_qcmd()
5258 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5259 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5265 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5267 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5268 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5272 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5273 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5274 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5276 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5278 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5279 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5281 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5289 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5290 * @sense_buffer: sense data returned by target
5298 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5299 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5300 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5303 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5304 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5305 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5310 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5316 * scsi_status - SCSI Status code returned from target device
5317 * scsi_state - state info associated with SCSI_IO determined by ioc
5318 * ioc_status - ioc supplied status info
5326 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5328 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5329 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5332 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5333 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5336 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5337 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5342 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5465 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5467 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5468 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5472 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5473 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5475 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5476 pcie_device->slot); in _scsih_scsi_ioc_info()
5477 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5479 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5480 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5487 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5497 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5500 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5501 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5502 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5503 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5509 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5512 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5515 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5522 * _scsih_turn_on_pfa_led - illuminate PFA LED
5551 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5565 * _scsih_turn_off_pfa_led - turn off Fault LED
5581 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5583 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5602 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5615 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5616 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5617 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5623 * _scsih_smart_predicted_fault - process smart errors
5639 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5640 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5645 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5646 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5648 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5649 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5654 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5656 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5669 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5670 event_reply->Event = in _scsih_smart_predicted_fault()
5672 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5673 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5676 event_reply->EventData; in _scsih_smart_predicted_fault()
5677 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5678 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5679 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5680 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5689 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5694 * _scsih_io_done - scsi request callback
5731 scmd->result = DID_OK << 16; in _scsih_io_done()
5735 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5736 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5737 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5738 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5741 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5748 if (st->direct_io && in _scsih_io_done()
5751 st->direct_io = 0; in _scsih_io_done()
5752 st->scmd = scmd; in _scsih_io_done()
5753 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5754 mpi_request->DevHandle = in _scsih_io_done()
5755 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5756 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5757 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5761 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5764 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5765 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5766 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5767 if ((!ioc->is_warpdrive && in _scsih_io_done()
5768 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5769 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5770 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5772 sas_disable_tlr(scmd->device); in _scsih_io_done()
5773 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5777 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5778 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5780 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5784 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5798 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5799 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5800 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5804 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5807 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5808 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5809 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5810 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5816 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5820 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5824 if (sas_device_priv_data->block) { in _scsih_io_done()
5825 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5829 if (scmd->retries > 2) { in _scsih_io_done()
5830 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5831 scsi_device_set_state(scmd->device, in _scsih_io_done()
5834 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5835 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5839 scmd->result = DID_RESET << 16; in _scsih_io_done()
5841 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5844 scmd->result = DID_RESET << 16; in _scsih_io_done()
5847 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5851 scmd->result = DID_RESET << 16; in _scsih_io_done()
5855 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5856 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5858 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5862 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5867 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5869 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5871 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5874 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5876 scmd->result = DID_RESET << 16; in _scsih_io_done()
5877 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5878 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5879 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5890 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5895 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5897 scmd->result = DID_RESET << 16; in _scsih_io_done()
5916 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5921 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5933 * _scsih_update_vphys_after_reset - update the Port's
5958 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5959 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5962 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5963 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5971 (ioc->sas_hba.num_phys * sizeof(Mpi2SasIOUnit0PhyData_t)); in _scsih_update_vphys_after_reset()
5987 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5991 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
6002 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6020 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6035 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6036 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6039 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6044 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6052 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6058 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6059 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6067 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6074 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6077 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6078 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6079 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6089 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6091 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6092 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6093 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6094 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6095 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6099 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6109 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6110 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6111 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6112 mport->flags &= in _scsih_update_vphys_after_reset()
6118 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6131 * _scsih_get_port_table_after_reset - Construct temporary port table
6149 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_get_port_table_after_reset()
6164 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6166 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6170 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6179 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6191 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6211 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6231 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6232 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6235 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6236 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6242 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6243 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6244 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6250 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6251 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6260 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6279 * _scsih_del_phy_part_of_anther_port - remove phy if it
6293 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6302 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6312 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6327 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6329 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6331 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6339 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6341 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6343 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6344 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6351 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6363 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6364 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6367 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6368 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6371 vphy, port->port_id, in _scsih_del_dirty_vphy()
6372 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6373 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6374 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6378 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6379 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6384 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6395 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6396 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6397 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6402 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6403 list_del(&port->list); in _scsih_del_dirty_port_entries()
6409 * _scsih_sas_port_refresh - Update HBA port table after host reset
6426 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6435 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6440 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6442 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6458 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6459 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6463 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6466 port_table_entry->port_id, in _scsih_sas_port_refresh()
6467 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6468 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6505 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6506 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6507 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6508 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6515 * _scsih_alloc_vphy - allocate virtual_phy object
6538 if (!port->vphys_mask) in _scsih_alloc_vphy()
6539 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6545 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6546 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6548 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6552 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6558 * _scsih_sas_host_refresh - refreshing sas host object contents
6581 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6583 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_sas_host_refresh()
6598 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6599 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6601 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6602 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6603 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6609 port->port_id = port_id; in _scsih_sas_host_refresh()
6612 port, port->port_id); in _scsih_sas_host_refresh()
6613 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6614 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6615 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6620 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6639 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6646 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6660 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6662 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6663 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6666 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6667 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6671 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6673 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6675 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6681 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6682 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6683 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6684 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6687 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6695 * _scsih_sas_host_add - create sas host object
6698 * Creating host side data object, stored in ioc->sas_hba
6723 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6725 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6727 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6732 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6735 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6758 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6780 ioc->io_missing_delay = in _scsih_sas_host_add()
6781 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6783 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6785 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6788 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6791 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6792 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6808 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6811 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6817 port->port_id = port_id; in _scsih_sas_host_add()
6820 port, port->port_id); in _scsih_sas_host_add()
6821 list_add_tail(&port->list, in _scsih_sas_host_add()
6822 &ioc->port_table_list); in _scsih_sas_host_add()
6837 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6840 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6841 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6842 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6844 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6845 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6848 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6853 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6855 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6857 ioc->sas_hba.handle, in _scsih_sas_host_add()
6858 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6859 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6861 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6864 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6865 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6875 * _scsih_expander_add - creating expander object
6879 * Creating expander object, stored in ioc->sas_expander_list.
6902 return -1; in _scsih_expander_add()
6904 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6905 return -1; in _scsih_expander_add()
6911 return -1; in _scsih_expander_add()
6919 return -1; in _scsih_expander_add()
6928 return -1; in _scsih_expander_add()
6932 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6933 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6937 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6945 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6949 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6959 return -1; in _scsih_expander_add()
6962 sas_expander->handle = handle; in _scsih_expander_add()
6963 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6964 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6965 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6966 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6967 if (!sas_expander->port) { in _scsih_expander_add()
6970 rc = -1; in _scsih_expander_add()
6976 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6978 if (!sas_expander->num_phys) { in _scsih_expander_add()
6979 rc = -1; in _scsih_expander_add()
6982 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6984 if (!sas_expander->phy) { in _scsih_expander_add()
6987 rc = -1; in _scsih_expander_add()
6991 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6993 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6997 rc = -1; in _scsih_expander_add()
7000 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
7001 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
7003 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
7008 rc = -1; in _scsih_expander_add()
7011 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
7012 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
7013 sas_expander->phy[i].port = in _scsih_expander_add()
7017 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7018 sas_expander->parent_dev))) { in _scsih_expander_add()
7021 rc = -1; in _scsih_expander_add()
7026 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7029 sas_expander->enclosure_handle); in _scsih_expander_add()
7031 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7032 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7041 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7042 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7048 * mpt3sas_expander_remove - removing expander object
7060 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7066 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7069 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7075 * _scsih_done - internal SCSI_IO callback handler.
7082 * The callback index passed is `ioc->scsih_cb_idx`
7093 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7095 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7097 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7099 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7100 mpi_reply->MsgLength*4); in _scsih_done()
7101 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7103 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7104 complete(&ioc->scsih_cmds.done); in _scsih_done()
7115 * _scsih_check_access_status - check access flags
7178 * _scsih_check_device - checking device responsiveness
7220 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7231 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7232 starget = sas_device->starget; in _scsih_check_device()
7233 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7236 sas_device->handle, handle); in _scsih_check_device()
7237 sas_target_priv_data->handle = handle; in _scsih_check_device()
7238 sas_device->handle = handle; in _scsih_check_device()
7241 sas_device->enclosure_level = in _scsih_check_device()
7243 memcpy(sas_device->connector_name, in _scsih_check_device()
7245 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7247 sas_device->enclosure_level = 0; in _scsih_check_device()
7248 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7251 sas_device->enclosure_handle = in _scsih_check_device()
7253 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7255 sas_device->enclosure_handle); in _scsih_check_device()
7257 sas_device->enclosure_logical_id = in _scsih_check_device()
7258 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7259 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7261 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7262 sas_device->chassis_slot = in _scsih_check_device()
7263 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7281 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7289 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7295 * _scsih_add_device - creating sas device object
7301 * Creating end device object, stored in ioc->sas_device_list.
7303 * Return: 0 for success, non-zero for failure.
7322 return -1; in _scsih_add_device()
7330 return -1; in _scsih_add_device()
7336 return -1; in _scsih_add_device()
7337 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7345 return -1; in _scsih_add_device()
7351 return -1; in _scsih_add_device()
7357 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7359 return -1; in _scsih_add_device()
7379 kref_init(&sas_device->refcount); in _scsih_add_device()
7380 sas_device->handle = handle; in _scsih_add_device()
7383 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7386 sas_device->enclosure_handle = in _scsih_add_device()
7388 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7389 sas_device->slot = in _scsih_add_device()
7391 sas_device->device_info = device_info; in _scsih_add_device()
7392 sas_device->sas_address = sas_address; in _scsih_add_device()
7393 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7394 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7396 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7397 if (!sas_device->port) { in _scsih_add_device()
7405 sas_device->enclosure_level = in _scsih_add_device()
7407 memcpy(sas_device->connector_name, in _scsih_add_device()
7409 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7411 sas_device->enclosure_level = 0; in _scsih_add_device()
7412 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7415 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7417 sas_device->enclosure_logical_id = in _scsih_add_device()
7418 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7419 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7421 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7422 sas_device->chassis_slot = in _scsih_add_device()
7423 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7428 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7429 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7432 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7434 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7445 * _scsih_remove_device - removing sas device object
7455 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7456 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7458 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7464 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7469 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7470 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7471 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7472 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7473 sas_device->port); in _scsih_remove_device()
7474 sas_target_priv_data->handle = in _scsih_remove_device()
7478 if (!ioc->hide_drives) in _scsih_remove_device()
7480 sas_device->sas_address, in _scsih_remove_device()
7481 sas_device->sas_address_parent, in _scsih_remove_device()
7482 sas_device->port); in _scsih_remove_device()
7485 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7492 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7498 * _scsih_sas_topology_change_event_debug - debug for topology event
7514 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7535 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7536 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7537 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7538 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7539 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7542 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7543 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7565 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7566 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7575 * _scsih_sas_topology_change_event - handle topology changes
7596 fw_event->event_data; in _scsih_sas_topology_change_event()
7598 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7601 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7604 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7609 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7614 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7615 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7618 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7622 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7626 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7627 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7628 port = sas_expander->port; in _scsih_sas_topology_change_event()
7629 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7630 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7631 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7633 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7636 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7639 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7640 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7645 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7647 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7650 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7652 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7656 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7659 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7660 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7664 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7679 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7686 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7703 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7711 * _scsih_sas_device_status_change_event_debug - debug for device event
7722 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7767 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7768 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7769 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7770 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7772 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7777 * _scsih_sas_device_status_change_event - handle device status change
7794 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7797 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7799 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7803 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7804 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7807 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7809 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7812 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7816 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7818 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7820 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7822 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7825 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7826 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7832 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7837 * _scsih_check_pcie_access_status - check access flags
7925 * _scsih_pcie_device_remove_from_sml - removing pcie device
7939 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7940 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7944 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7945 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7946 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7950 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7951 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7953 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7954 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7955 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7956 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7957 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7961 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7962 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7964 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7965 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7966 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7968 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7969 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7971 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7973 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7977 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7978 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7982 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7983 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7984 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7988 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7989 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7991 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7996 * _scsih_pcie_check_device - checking device responsiveness
8027 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8031 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8035 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8036 starget = pcie_device->starget; in _scsih_pcie_check_device()
8037 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8038 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8041 pcie_device->handle, handle); in _scsih_pcie_check_device()
8042 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8043 pcie_device->handle = handle; in _scsih_pcie_check_device()
8047 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8049 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8052 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8053 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8062 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8070 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8075 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8084 * _scsih_pcie_add_device - creating pcie device object
8088 * Creating end device object, stored in ioc->pcie_device_list.
8117 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8139 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8144 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8176 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8177 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8178 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8179 pcie_device->handle = handle; in _scsih_pcie_add_device()
8180 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8181 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8182 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8183 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8184 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8187 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8189 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8190 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8194 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8195 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8198 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8199 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8203 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8206 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8208 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8209 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8211 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8214 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8216 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8223 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8224 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8225 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8227 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8230 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8232 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8234 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8244 * _scsih_pcie_topology_change_event_debug - debug for topology
8261 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8282 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8283 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8284 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8285 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8287 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8290 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8291 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8312 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8314 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8323 * _scsih_pcie_topology_change_event - handle PCIe topology
8341 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8344 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8347 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8348 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8351 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8357 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8358 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8363 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8365 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8367 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8371 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8373 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8378 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8393 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8395 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8402 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8408 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8409 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8413 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8425 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8437 * _scsih_pcie_device_status_change_event_debug - debug for device event
8448 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8492 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8493 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8494 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8495 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8497 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8502 * _scsih_pcie_device_status_change_event - handle device status
8517 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8518 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8522 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8524 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8528 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8529 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8532 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8535 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8539 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8541 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8543 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8548 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8552 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8564 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8579 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8580 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8581 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8585 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8597 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8599 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8601 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8604 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8605 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8612 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8624 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8634 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8635 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8640 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8650 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8670 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8677 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8678 ioc_info(ioc, "%s: enter: phy number(%d), width(%d)\n", in _scsih_sas_broadcast_primitive_event()
8679 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8683 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8684 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8694 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8698 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8699 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8705 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8706 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8707 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8710 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8714 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8718 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8722 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8723 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8726 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8729 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8731 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8732 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8737 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8740 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8746 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8751 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8753 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8755 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8764 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8768 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8771 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8772 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8773 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8774 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8785 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8787 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8788 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8791 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8796 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8801 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8805 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8808 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8809 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8811 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8815 * _scsih_sas_discovery_event - handle discovery events
8825 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8827 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8829 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8831 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8833 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8837 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8838 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8839 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8841 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8849 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8860 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8862 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8865 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8866 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8867 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8871 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8872 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8873 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8881 * _scsih_pcie_enumeration_event - handle enumeration events
8891 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8893 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8897 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8899 event_data->Flags); in _scsih_pcie_enumeration_event()
8900 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8902 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8907 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8925 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8928 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8930 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8932 rc = -EAGAIN; in _scsih_ir_fastpath()
8935 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8937 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8940 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8941 rc = -EAGAIN; in _scsih_ir_fastpath()
8946 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8949 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8950 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8951 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8957 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8958 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8959 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8961 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8963 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8965 rc = -EFAULT; in _scsih_ir_fastpath()
8969 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8971 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8972 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8974 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8982 rc = -EFAULT; in _scsih_ir_fastpath()
8989 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8990 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8998 * _scsih_reprobe_lun - reprobing lun
9000 * @no_uld_attach: sdev->no_uld_attach flag setting
9006 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
9008 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
9013 * _scsih_sas_volume_add - add new volume
9025 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
9035 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9037 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9049 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9050 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9051 raid_device->handle = handle; in _scsih_sas_volume_add()
9052 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9054 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9055 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9056 raid_device->id, 0); in _scsih_sas_volume_add()
9060 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9062 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9067 * _scsih_sas_volume_delete - delete volume
9080 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9083 if (raid_device->starget) { in _scsih_sas_volume_delete()
9084 starget = raid_device->starget; in _scsih_sas_volume_delete()
9085 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9086 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9089 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9090 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9093 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9095 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9099 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9112 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
9114 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9117 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9118 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9119 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9120 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9121 starget = sas_device->starget; in _scsih_sas_pd_expose()
9122 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9123 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9127 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9139 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9152 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
9161 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9164 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9165 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9166 starget = sas_device->starget; in _scsih_sas_pd_hide()
9167 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9168 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9170 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9171 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9174 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9179 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9188 * _scsih_sas_pd_delete - delete pd component
9197 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
9203 * _scsih_sas_pd_add - remove pd component
9213 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
9220 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9224 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9251 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9256 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9270 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9273 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9275 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9276 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9277 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9309 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9327 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9328 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9329 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9334 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9348 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9350 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9351 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9354 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9357 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9358 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9359 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9360 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9361 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9363 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9364 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9369 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9371 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9381 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9384 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9388 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9392 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9396 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9404 * _scsih_sas_ir_volume_event - IR volume event
9420 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9422 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9425 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9428 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9429 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9430 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9434 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9446 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9448 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9467 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9468 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9469 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9470 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9472 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9473 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9485 * _scsih_sas_ir_physical_disk_event - PD event
9501 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9504 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9507 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9510 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9511 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9513 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9517 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9527 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9528 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9572 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9583 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9606 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9607 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9611 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9622 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9627 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9628 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9633 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9635 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9636 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9639 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9640 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9641 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9646 * _scsih_prep_device_scan - initialize parameters prior to device scan
9658 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9659 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9660 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9661 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9666 * _scsih_update_device_qdepth - Update QD during Reset.
9680 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9681 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9682 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9683 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9684 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9685 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9686 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9688 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9689 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9690 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9692 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9693 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9702 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9719 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9721 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9724 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9727 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9729 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9730 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9731 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9732 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9734 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9736 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9738 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9739 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9740 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9741 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9742 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9743 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9749 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9751 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9753 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9757 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9758 sas_device->slot); in _scsih_mark_responding_sas_device()
9760 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9762 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9763 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9764 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9765 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9767 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9768 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9771 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9772 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9773 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9775 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9776 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9777 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9779 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9780 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9781 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9785 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9786 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9789 sas_device->handle); in _scsih_mark_responding_sas_device()
9790 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9791 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9793 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9794 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9798 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9802 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9828 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9837 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9838 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9840 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9845 * _scsih_search_responding_sas_devices -
9860 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9862 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9881 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9885 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9901 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9902 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9903 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9904 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9905 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9906 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9907 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9908 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9909 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9910 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9911 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9912 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9913 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9919 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9920 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9921 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9926 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9927 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9930 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9932 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9933 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9934 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9935 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9936 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9938 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9939 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9942 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9943 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9946 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9947 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9948 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9950 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9951 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9957 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9961 * _scsih_search_responding_pcie_devices -
9976 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9978 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
10000 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
10004 * _scsih_mark_responding_raid_device - mark a raid_device as responding
10021 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10022 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10023 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10024 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10025 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10026 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10027 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10030 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10031 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10032 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10034 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10038 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10042 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10043 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10044 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10049 raid_device->handle); in _scsih_mark_responding_raid_device()
10050 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10052 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10053 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10057 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10061 * _scsih_search_responding_raid_devices -
10078 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10083 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10108 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10110 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10120 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10128 * _scsih_mark_responding_expander - mark a expander as responding
10143 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
10144 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10145 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10147 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10154 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10155 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10156 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10158 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10160 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10163 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10164 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10165 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10166 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10169 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10173 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10174 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10175 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10176 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10177 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10181 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10185 * _scsih_search_responding_expanders -
10203 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10221 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10231 * _scsih_remove_unresponding_devices - removing unresponding devices
10248 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10250 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10253 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10260 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10261 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10266 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10267 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10268 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10270 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10272 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10279 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10283 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10285 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10291 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10292 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10297 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10298 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10299 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10301 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10303 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10307 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10312 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10315 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10316 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10318 raid_device->handle); in _scsih_remove_unresponding_devices()
10320 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10326 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10329 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10330 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10331 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10333 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10335 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10355 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10363 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10366 sas_expander->port); in _scsih_refresh_expander_links()
10371 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10424 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10429 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10446 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10492 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10523 handle = le16_to_cpu(volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10524 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10526 le64_to_cpu(volume_pg1->WWID)); in _scsih_scan_for_devices_after_reset()
10527 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10541 if (volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL || in _scsih_scan_for_devices_after_reset()
10542 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_ONLINE || in _scsih_scan_for_devices_after_reset()
10543 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) { in _scsih_scan_for_devices_after_reset()
10546 element.VolDevHandle = volume_pg1->DevHandle; in _scsih_scan_for_devices_after_reset()
10548 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10551 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10648 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10659 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10670 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10671 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10672 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10673 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10675 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10676 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10677 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10678 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10681 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10682 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10683 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10689 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10698 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10699 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10714 * _mpt3sas_fw_work - delayed task for processing firmware events
10722 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10726 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10728 ioc->current_event = NULL; in _mpt3sas_fw_work()
10732 switch (fw_event->event) { in _mpt3sas_fw_work()
10736 fw_event->event_data); in _mpt3sas_fw_work()
10739 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10740 ioc->shost_recovery) { in _mpt3sas_fw_work()
10745 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10752 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10759 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10760 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10761 *- start the watchdog thread. in _mpt3sas_fw_work()
10765 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10770 ioc->start_scan = 0; in _mpt3sas_fw_work()
10771 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10778 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10784 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10787 fw_event->event_data); in _mpt3sas_fw_work()
10822 ioc->current_event = NULL; in _mpt3sas_fw_work()
10827 ioc->current_event = NULL; in _mpt3sas_fw_work()
10844 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10848 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10854 * This function merely adds a new work task into ioc->firmware_event_thread.
10871 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10882 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10893 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10895 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10899 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10900 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10903 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10910 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10919 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10925 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10926 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10932 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10937 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10944 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10948 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10949 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10951 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10963 …Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode. Check Warp… in mpt3sas_scsih_event_callback()
10975 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10989 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10993 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10994 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10997 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
11002 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
11007 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
11019 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
11027 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
11028 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11029 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11030 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11031 fw_event->event = event; in mpt3sas_scsih_event_callback()
11038 * _scsih_expander_node_remove - removing expander device from list.
11043 * ioc->sas_expander_list.
11055 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11056 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11058 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11061 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11062 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11063 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11065 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11068 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11069 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11072 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11074 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11075 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11079 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11080 sas_expander->sas_address, in _scsih_expander_node_remove()
11083 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11084 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11085 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11087 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11092 * _scsih_nvme_shutdown - NVMe shutdown notification
11107 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11110 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11112 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11117 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11119 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11123 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11128 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11130 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11131 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11133 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11134 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11138 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11139 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11140 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11142 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11147 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11148 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11151 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11152 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11155 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11156 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11161 * _scsih_ir_shutdown - IR shutdown notification
11175 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11179 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11182 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11184 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11188 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11190 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11193 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11198 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11201 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11202 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11204 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11206 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11207 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11208 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11210 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11215 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11216 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11217 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11219 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11220 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11224 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11225 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11229 * _scsih_get_shost_and_ioc - get shost and ioc
11243 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11244 return -ENXIO; in _scsih_get_shost_and_ioc()
11249 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11250 return -ENXIO; in _scsih_get_shost_and_ioc()
11257 * scsih_remove - detach and remove add host
11278 ioc->remove_host = 1; in scsih_remove()
11287 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11288 wq = ioc->firmware_event_thread; in scsih_remove()
11289 ioc->firmware_event_thread = NULL; in scsih_remove()
11290 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11297 if (ioc->is_aero_ioc) in scsih_remove()
11299 &ioc->ioc_pg1_copy); in scsih_remove()
11304 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11306 if (raid_device->starget) { in scsih_remove()
11308 raid_device->starget->hostdata; in scsih_remove()
11309 sas_target_priv_data->deleted = 1; in scsih_remove()
11310 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11313 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11316 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11319 list_del_init(&pcie_device->list); in scsih_remove()
11325 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11326 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11329 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11330 mpt3sas_port->hba_port); in scsih_remove()
11331 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11333 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11336 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11337 mpt3sas_port->hba_port); in scsih_remove()
11341 &ioc->port_table_list, list) { in scsih_remove()
11342 list_del(&port->list); in scsih_remove()
11347 if (ioc->sas_hba.num_phys) { in scsih_remove()
11348 kfree(ioc->sas_hba.phy); in scsih_remove()
11349 ioc->sas_hba.phy = NULL; in scsih_remove()
11350 ioc->sas_hba.num_phys = 0; in scsih_remove()
11355 list_del(&ioc->list); in scsih_remove()
11361 * scsih_shutdown - routine call during system shutdown
11376 ioc->remove_host = 1; in scsih_shutdown()
11385 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11386 wq = ioc->firmware_event_thread; in scsih_shutdown()
11387 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11388 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11395 if (ioc->is_aero_ioc) in scsih_shutdown()
11397 &ioc->ioc_pg1_copy); in scsih_shutdown()
11403 ioc->shost_recovery = 1; in scsih_shutdown()
11405 ioc->shost_recovery = 0; in scsih_shutdown()
11412 * _scsih_probe_boot_devices - reports 1st device
11416 * device scsi-ml or sas transport for persistent boot device
11436 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11440 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11441 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11442 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11443 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11444 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11445 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11446 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11447 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11448 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11461 if (raid_device->starget) in _scsih_probe_boot_devices()
11463 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11464 raid_device->id, 0); in _scsih_probe_boot_devices()
11474 if (pcie_device->starget) in _scsih_probe_boot_devices()
11476 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11477 tid = pcie_device->id; in _scsih_probe_boot_devices()
11478 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11479 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11480 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11490 if (sas_device->starget) in _scsih_probe_boot_devices()
11492 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11493 handle = sas_device->handle; in _scsih_probe_boot_devices()
11494 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11495 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11496 port = sas_device->port; in _scsih_probe_boot_devices()
11497 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11498 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11500 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11509 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11510 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11521 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11533 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11534 if (raid_device->starget) in _scsih_probe_raid()
11536 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11537 raid_device->id, 0); in _scsih_probe_raid()
11548 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11549 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11550 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11554 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11564 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11574 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11575 list_del_init(&sas_device->list); in sas_device_make_active()
11580 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11582 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11586 * _scsih_probe_sas - reporting sas devices to sas transport
11596 if (ioc->hide_drives) in _scsih_probe_sas()
11600 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11601 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11605 } else if (!sas_device->starget) { in _scsih_probe_sas()
11609 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11612 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11614 sas_device->sas_address, in _scsih_probe_sas()
11615 sas_device->sas_address_parent, in _scsih_probe_sas()
11616 sas_device->port); in _scsih_probe_sas()
11628 * get_next_pcie_device - Get the next pcie device
11641 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11642 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11643 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11647 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11653 * pcie_device_make_active - Add pcie device to pcie_device_list list
11665 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11667 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11668 list_del_init(&pcie_device->list); in pcie_device_make_active()
11672 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11674 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11678 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11691 if (pcie_device->starget) { in _scsih_probe_pcie()
11695 if (pcie_device->access_status == in _scsih_probe_pcie()
11701 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11702 pcie_device->id, 0); in _scsih_probe_pcie()
11707 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11711 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11714 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11715 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11729 * _scsih_probe_devices - probing for devices
11739 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11744 if (ioc->ir_firmware) { in _scsih_probe_devices()
11746 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11763 * scsih_scan_start - scsi lld callback for .scan_start
11775 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11777 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11783 ioc->start_scan = 1; in scsih_scan_start()
11791 * _scsih_complete_devices_scanning - add the devices to sml and
11800 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11801 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11806 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11810 * scsih_scan_finished - scsi lld callback for .scan_finished
11826 ioc->is_driver_loading = 0; in scsih_scan_finished()
11827 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11832 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11834 ioc->is_driver_loading = 0; in scsih_scan_finished()
11838 if (ioc->start_scan) { in scsih_scan_finished()
11856 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11859 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11862 if (ioc->start_scan_failed) { in scsih_scan_finished()
11864 ioc->start_scan_failed); in scsih_scan_finished()
11865 ioc->is_driver_loading = 0; in scsih_scan_finished()
11866 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11867 ioc->remove_host = 1; in scsih_scan_finished()
11872 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11877 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11879 ioc->is_driver_loading = 0; in scsih_scan_finished()
11885 * scsih_map_queues - map reply queues with request queues
11891 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11894 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11895 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11897 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11900 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11901 map = &shost->tag_set.map[i]; in scsih_map_queues()
11902 map->nr_queues = 0; in scsih_map_queues()
11905 map->nr_queues = in scsih_map_queues()
11906 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11907 offset = ioc->high_iops_queues; in scsih_map_queues()
11909 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11911 if (!map->nr_queues) in scsih_map_queues()
11916 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11918 map->queue_offset = qoff; in scsih_map_queues()
11920 blk_mq_pci_map_queues(map, ioc->pdev, offset); in scsih_map_queues()
11924 qoff += map->nr_queues; in scsih_map_queues()
11948 .this_id = -1,
11986 .this_id = -1,
12008 * _scsih_determine_hba_mpi_version - determine in which MPI version class
12020 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12080 * _scsih_probe - attach and add scsi host
12098 return -ENODEV; in _scsih_probe()
12101 * for other generation HBA's return with -ENODEV in _scsih_probe()
12104 return -ENODEV; in _scsih_probe()
12107 * for other generation HBA's return with -ENODEV in _scsih_probe()
12111 return -ENODEV; in _scsih_probe()
12121 return -ENODEV; in _scsih_probe()
12124 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12125 ioc->id = mpt2_ids++; in _scsih_probe()
12126 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12127 switch (pdev->device) { in _scsih_probe()
12129 ioc->is_warpdrive = 1; in _scsih_probe()
12130 ioc->hide_ir_msg = 1; in _scsih_probe()
12134 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12137 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12141 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12142 ioc->multipath_on_hba = 0; in _scsih_probe()
12144 ioc->multipath_on_hba = 1; in _scsih_probe()
12153 return -ENODEV; in _scsih_probe()
12156 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12157 ioc->id = mpt3_ids++; in _scsih_probe()
12158 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12159 switch (pdev->device) { in _scsih_probe()
12168 ioc->is_gen35_ioc = 1; in _scsih_probe()
12172 dev_err(&pdev->dev, in _scsih_probe()
12174 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12175 pdev->subsystem_device); in _scsih_probe()
12179 dev_err(&pdev->dev, in _scsih_probe()
12181 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12182 pdev->subsystem_device); in _scsih_probe()
12186 dev_info(&pdev->dev, in _scsih_probe()
12191 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12194 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12196 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12197 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12198 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12199 ioc->combined_reply_queue = 1; in _scsih_probe()
12200 if (ioc->is_gen35_ioc) in _scsih_probe()
12201 ioc->combined_reply_index_count = in _scsih_probe()
12204 ioc->combined_reply_index_count = in _scsih_probe()
12208 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12210 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12211 ioc->multipath_on_hba = 0; in _scsih_probe()
12213 ioc->multipath_on_hba = 1; in _scsih_probe()
12216 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12217 ioc->multipath_on_hba = 1; in _scsih_probe()
12219 ioc->multipath_on_hba = 0; in _scsih_probe()
12227 return -ENODEV; in _scsih_probe()
12230 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12232 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12234 ioc->shost = shost; in _scsih_probe()
12235 ioc->pdev = pdev; in _scsih_probe()
12236 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12237 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12238 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12239 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12240 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12241 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12242 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12243 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12244 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12245 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12246 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12247 ioc->logging_level = logging_level; in _scsih_probe()
12248 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12250 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12254 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12256 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12258 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12261 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12263 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12264 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12265 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12266 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12267 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12268 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12269 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12270 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12271 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12273 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12274 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12275 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12276 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12277 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12278 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12279 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12280 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12281 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12282 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12283 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12284 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12285 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12286 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12287 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12289 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12292 shost->max_cmd_len = 32; in _scsih_probe()
12293 shost->max_lun = max_lun; in _scsih_probe()
12294 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12295 shost->unique_id = ioc->id; in _scsih_probe()
12297 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12299 shost->max_sectors = 128; in _scsih_probe()
12301 shost->max_sectors); in _scsih_probe()
12305 shost->max_sectors = 64; in _scsih_probe()
12309 shost->max_sectors = 32767; in _scsih_probe()
12313 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12315 shost->max_sectors); in _scsih_probe()
12330 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
12331 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
12332 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12333 ioc->firmware_event_name, 0); in _scsih_probe()
12334 if (!ioc->firmware_event_thread) { in _scsih_probe()
12337 rv = -ENODEV; in _scsih_probe()
12341 shost->host_tagset = 0; in _scsih_probe()
12343 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12344 shost->host_tagset = 1; in _scsih_probe()
12346 ioc->is_driver_loading = 1; in _scsih_probe()
12350 rv = -ENODEV; in _scsih_probe()
12354 if (ioc->is_warpdrive) { in _scsih_probe()
12355 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12356 ioc->hide_drives = 0; in _scsih_probe()
12357 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12358 ioc->hide_drives = 1; in _scsih_probe()
12361 ioc->hide_drives = 1; in _scsih_probe()
12363 ioc->hide_drives = 0; in _scsih_probe()
12366 ioc->hide_drives = 0; in _scsih_probe()
12368 shost->nr_hw_queues = 1; in _scsih_probe()
12370 if (shost->host_tagset) { in _scsih_probe()
12371 shost->nr_hw_queues = in _scsih_probe()
12372 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12375 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12377 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12379 dev_info(&ioc->pdev->dev, in _scsih_probe()
12381 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12384 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12397 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12400 list_del(&ioc->list); in _scsih_probe()
12407 * scsih_suspend - power management suspend main entry point
12435 * scsih_resume - power management resume main entry point
12446 pci_power_t device_state = pdev->current_state; in scsih_resume()
12456 ioc->pdev = pdev; in scsih_resume()
12468 * scsih_pci_error_detected - Called when a PCI error is detected.
12492 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12493 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12499 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12509 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12528 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12529 ioc->pdev = pdev; in scsih_pci_slot_reset()
12548 * scsih_pci_resume() - resume normal ops after PCI reset
12567 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12571 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12585 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12595 * scsih_ncq_prio_supp - Check for NCQ command priority support
12607 vpd = rcu_dereference(sdev->vpd_pg89); in scsih_ncq_prio_supp()
12608 if (!vpd || vpd->len < 214) in scsih_ncq_prio_supp()
12611 ncq_prio_supp = (vpd->data[213] >> 4) & 1; in scsih_ncq_prio_supp()
12785 * scsih_init - main entry point for this driver.
12836 * scsih_exit - exit point for this driver (when it is a module).
12867 * _mpt3sas_init - main entry point for this driver.
12882 return -ENODEV; in _mpt3sas_init()
12892 return -ENODEV; in _mpt3sas_init()
12904 return -ENODEV; in _mpt3sas_init()
12924 * _mpt3sas_exit - exit point for this driver (when it is a module).