Lines Matching +full:per +full:- +full:device

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,
56 #include <linux/blk-mq-pci.h>
94 static u8 scsi_io_cb_idx = -1;
95 static u8 tm_cb_idx = -1;
96 static u8 ctl_cb_idx = -1;
97 static u8 base_cb_idx = -1;
98 static u8 port_enable_cb_idx = -1;
99 static u8 transport_cb_idx = -1;
100 static u8 scsih_cb_idx = -1;
101 static u8 config_cb_idx = -1;
105 static u8 tm_tr_cb_idx = -1 ;
106 static u8 tm_tr_volume_cb_idx = -1 ;
107 static u8 tm_sas_control_cb_idx = -1;
120 static int missing_delay[2] = {-1, -1};
122 MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
124 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
133 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
134 1 - enumerates only SAS 2.0 generation HBAs\n \
135 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
144 static int diag_buffer_enable = -1;
148 static int disable_discovery = -1;
154 static int prot_mask = -1;
163 static int multipath_on_hba = -1;
166 "Multipath support to add same target device\n\t\t"
169 "\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
170 "\t SAS 3.5 HBA - This will be enabled)");
183 * struct sense_info - common structure for obtaining sense keys
200 * struct fw_event_work - firmware event struct
202 * @work: work object (ioc->fault_reset_work_q)
203 * @ioc: per adapter object
204 * @device_handle: device handle
212 * This object stored on ioc->fw_event_list.
235 kref_get(&fw_work->refcount); in fw_event_work_get()
240 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
251 kref_init(&fw_event->refcount); in alloc_fw_event_work()
256 * struct _scsi_io_transfer - scsi io transfer
257 * @handle: sas device handle (assigned by firmware)
304 * _scsih_set_debug_level - global setting of ioc->logging_level.
322 ioc->logging_level = logging_level; in _scsih_set_debug_level()
330 * _scsih_srch_boot_sas_address - search based on sas_address
332 * @boot_device: boot device object from bios page 2
340 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
344 * _scsih_srch_boot_device_name - search based on device name
345 * @device_name: device name specified in INDENTIFY fram
346 * @boot_device: boot device object from bios page 2
354 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
358 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
361 * @boot_device: boot device object from bios page 2
369 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
370 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
375 * mpt3sas_get_port_by_id - get hba port entry corresponding to provided
377 * @ioc: per adapter object
396 if (!ioc->multipath_on_hba) in mpt3sas_get_port_by_id()
400 &ioc->port_table_list, list) { in mpt3sas_get_port_by_id()
401 if (port->port_id != port_id) in mpt3sas_get_port_by_id()
405 if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) in mpt3sas_get_port_by_id()
415 if (!ioc->multipath_on_hba) { in mpt3sas_get_port_by_id()
420 port->port_id = port_id; in mpt3sas_get_port_by_id()
423 port, port->port_id); in mpt3sas_get_port_by_id()
424 list_add_tail(&port->list, in mpt3sas_get_port_by_id()
425 &ioc->port_table_list); in mpt3sas_get_port_by_id()
432 * mpt3sas_get_vphy_by_phy - get virtual_phy object corresponding to phy number
433 * @ioc: per adapter object
445 if (!port->vphys_mask) in mpt3sas_get_vphy_by_phy()
448 list_for_each_entry_safe(vphy, vphy_next, &port->vphys_list, list) { in mpt3sas_get_vphy_by_phy()
449 if (vphy->phy_mask & (1 << phy)) in mpt3sas_get_vphy_by_phy()
456 * _scsih_is_boot_device - search for matching boot device.
458 * @device_name: device name specified in INDENTIFY fram
461 * @form: specifies boot device form
462 * @boot_device: boot device object from bios page 2
478 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
485 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
491 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
501 * _scsih_get_sas_address - set the sas_address for given device handle
503 * @handle: device handle
506 * Return: 0 success, non-zero when failure
522 return -ENXIO; in _scsih_get_sas_address()
530 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
533 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
541 return -ENXIO; in _scsih_get_sas_address()
546 return -EIO; in _scsih_get_sas_address()
550 * _scsih_determine_boot_device - determine boot device.
551 * @ioc: per adapter object
552 * @device: sas_device or pcie_device object
555 * Determines whether this device should be first reported device to
556 * to scsi-ml or sas transport, this purpose is for persistent boot device.
559 * the corresponding device object.
563 _scsih_determine_boot_device(struct MPT3SAS_ADAPTER *ioc, void *device, in _scsih_determine_boot_device() argument
575 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
579 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
583 raid_device = device; in _scsih_determine_boot_device()
584 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
589 pcie_device = device; in _scsih_determine_boot_device()
590 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
595 sas_device = device; in _scsih_determine_boot_device()
596 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
597 device_name = sas_device->device_name; in _scsih_determine_boot_device()
598 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
599 slot = sas_device->slot; in _scsih_determine_boot_device()
602 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
605 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
607 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
611 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
612 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
616 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
619 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
621 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
625 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
626 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
630 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
633 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
635 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
639 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
640 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
651 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
653 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
667 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
669 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
680 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
682 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
690 * mpt3sas_get_pdev_from_target - pcie device search
691 * @ioc: per adapter object
694 * Context: This function will acquire ioc->pcie_device_lock and will release
706 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
708 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
715 * __mpt3sas_get_sdev_by_rphy - sas device search
716 * @ioc: per adapter object
719 * Context: This function will acquire ioc->sas_device_lock and will release
731 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_rphy()
733 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_rphy()
734 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
741 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_rphy()
742 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
752 * __mpt3sas_get_sdev_by_addr - get _sas_device object corresponding to provided
754 * @ioc: per adapter object
755 * @sas_address: device sas address
770 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
772 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_addr()
773 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
775 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
781 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_addr()
782 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
784 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
794 * mpt3sas_get_sdev_by_addr - sas device search
795 * @ioc: per adapter object
798 * Context: Calling function should acquire ioc->sas_device_lock
810 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
813 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
823 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
825 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
826 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
829 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
830 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
841 * mpt3sas_get_sdev_by_handle - sas device search
842 * @ioc: per adapter object
843 * @handle: sas device handle (assigned by firmware)
844 * Context: Calling function should acquire ioc->sas_device_lock
855 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
857 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
863 * _scsih_display_enclosure_chassis_info - display device location info
864 * @ioc: per adapter object
865 * @sas_device: per sas device object
866 * @sdev: scsi device struct
875 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
879 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
880 sas_device->slot); in _scsih_display_enclosure_chassis_info()
881 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
884 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
885 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
886 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
888 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
890 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
894 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
895 sas_device->slot); in _scsih_display_enclosure_chassis_info()
896 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
899 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
900 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
901 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
904 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
906 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
908 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
909 sas_device->slot); in _scsih_display_enclosure_chassis_info()
910 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
912 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
913 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
914 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
916 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
921 * _scsih_sas_device_remove - remove sas_device from list.
922 * @ioc: per adapter object
924 * Context: This function will acquire ioc->sas_device_lock.
937 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
945 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
946 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
947 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
950 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
954 * _scsih_device_remove_by_handle - removing device object by handle
955 * @ioc: per adapter object
956 * @handle: device handle
964 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
967 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
970 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
973 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
981 * mpt3sas_device_remove_by_sas_address - removing device object by
983 * @ioc: per adapter object
984 * @sas_address: device sas_address
996 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
999 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1002 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
1005 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1013 * _scsih_sas_device_add - insert sas_device to the list.
1014 * @ioc: per adapter object
1016 * Context: This function will acquire ioc->sas_device_lock.
1018 * Adding new object to the ioc->sas_device_list.
1028 __func__, sas_device->handle, in _scsih_sas_device_add()
1029 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
1034 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1036 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
1037 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1039 if (ioc->hide_drives) { in _scsih_sas_device_add()
1040 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1044 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
1045 sas_device->sas_address_parent, sas_device->port)) { in _scsih_sas_device_add()
1047 } else if (!sas_device->starget) { in _scsih_sas_device_add()
1051 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
1053 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
1055 sas_device->sas_address, in _scsih_sas_device_add()
1056 sas_device->sas_address_parent, in _scsih_sas_device_add()
1057 sas_device->port); in _scsih_sas_device_add()
1061 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1065 * _scsih_sas_device_init_add - insert sas_device to the list.
1066 * @ioc: per adapter object
1068 * Context: This function will acquire ioc->sas_device_lock.
1070 * Adding new object at driver load time to the ioc->sas_device_init_list.
1080 __func__, sas_device->handle, in _scsih_sas_device_init_add()
1081 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
1086 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1088 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
1090 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1099 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
1101 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
1102 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1105 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
1106 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1118 * mpt3sas_get_pdev_by_wwid - pcie device search
1119 * @ioc: per adapter object
1122 * Context: This function will acquire ioc->pcie_device_lock and will release
1133 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1135 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1147 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
1149 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
1150 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1153 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
1154 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1169 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1171 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1172 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1175 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1176 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1188 * mpt3sas_get_pdev_by_handle - pcie device search
1189 * @ioc: per adapter object
1190 * @handle: Firmware device handle
1192 * Context: This function will acquire ioc->pcie_device_lock and will release
1204 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1206 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1212 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1213 * @ioc: per adapter object
1214 * Context: This function will acquire ioc->pcie_device_lock
1216 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1227 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1228 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1229 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1230 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1232 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1235 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1236 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1240 * _scsih_pcie_device_remove - remove pcie_device from list.
1241 * @ioc: per adapter object
1243 * Context: This function will acquire ioc->pcie_device_lock.
1258 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1259 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1261 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1262 pcie_device->slot); in _scsih_pcie_device_remove()
1263 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1265 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1266 pcie_device->connector_name); in _scsih_pcie_device_remove()
1268 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1269 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1270 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1273 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1275 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1277 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1282 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove()
1292 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1293 * @ioc: per adapter object
1294 * @handle: device handle
1304 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1307 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1310 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1311 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1315 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1318 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1325 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove_by_handle()
1334 * _scsih_pcie_device_add - add pcie_device object
1335 * @ioc: per adapter object
1349 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1350 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1354 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1355 pcie_device->slot)); in _scsih_pcie_device_add()
1356 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1359 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1360 pcie_device->connector_name)); in _scsih_pcie_device_add()
1362 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1364 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1365 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1367 if (pcie_device->access_status == in _scsih_pcie_device_add()
1369 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1372 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1374 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1375 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1376 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1377 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1380 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1384 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1385 * @ioc: per adapter object
1387 * Context: This function will acquire ioc->pcie_device_lock.
1389 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1400 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1401 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1405 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1406 pcie_device->slot)); in _scsih_pcie_device_init_add()
1407 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1410 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1411 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1413 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1415 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1416 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1419 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1422 * _scsih_raid_device_find_by_id - raid device search
1423 * @ioc: per adapter object
1424 * @id: sas device target id
1425 * @channel: sas device channel
1426 * Context: Calling function should acquire ioc->raid_device_lock
1437 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1438 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1449 * mpt3sas_raid_device_find_by_handle - raid device search
1450 * @ioc: per adapter object
1451 * @handle: sas device handle (assigned by firmware)
1452 * Context: Calling function should acquire ioc->raid_device_lock
1463 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1464 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1475 * _scsih_raid_device_find_by_wwid - raid device search
1476 * @ioc: per adapter object
1478 * Context: Calling function should acquire ioc->raid_device_lock
1489 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1490 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1501 * _scsih_raid_device_add - add raid_device object
1502 * @ioc: per adapter object
1516 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1518 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1519 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1520 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1524 * _scsih_raid_device_remove - delete raid_device object
1525 * @ioc: per adapter object
1535 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1536 list_del(&raid_device->list); in _scsih_raid_device_remove()
1538 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1542 * mpt3sas_scsih_expander_find_by_handle - expander device search
1543 * @ioc: per adapter object
1545 * Context: Calling function should acquire ioc->sas_device_lock
1547 * This searches for expander device based on handle, then returns the
1556 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1557 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1567 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1568 * @ioc: per adapter object
1570 * Context: Calling function should acquire ioc->sas_device_lock
1572 * This searches for enclosure device based on handle, then returns the
1581 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1582 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1591 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1592 * @ioc: per adapter object
1595 * Context: Calling function should acquire ioc->sas_node_lock.
1597 * This searches for expander device based on sas_address & port number,
1609 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1610 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1612 if (sas_expander->port != port) in mpt3sas_scsih_expander_find_by_sas_address()
1622 * _scsih_expander_node_add - insert expander device to the list.
1623 * @ioc: per adapter object
1625 * Context: This function will acquire ioc->sas_node_lock.
1627 * Adding new object to the ioc->sas_expander_list.
1635 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1636 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1637 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1641 * _scsih_is_end_device - determines if device is an end device
1642 * @device_info: bitfield providing information about the device.
1645 * Return: 1 if end device.
1660 * _scsih_is_nvme_pciescsi_device - determines if
1661 * device is an pcie nvme/scsi device
1662 * @device_info: bitfield providing information about the device.
1665 * Returns 1 if device is pcie device type nvme/scsi.
1680 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1681 * @ioc: per adapter object
1684 * Context: This function will acquire ioc->scsi_lookup_lock.
1697 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1701 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1702 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1709 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1710 * @ioc: per adapter object
1714 * Context: This function will acquire ioc->scsi_lookup_lock.
1726 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1731 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1732 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1733 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1740 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1741 * @ioc: per adapter object
1753 u16 tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1756 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1758 ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag; in mpt3sas_scsih_scsi_lookup_get()
1764 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1768 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1771 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1774 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1782 * scsih_change_queue_depth - setting device queue depth
1783 * @sdev: scsi device struct
1791 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1799 max_depth = shost->can_queue; in scsih_change_queue_depth()
1802 * limit max device queue for SATA to 32 if enable_sdev_max_qd in scsih_change_queue_depth()
1805 if (ioc->enable_sdev_max_qd || ioc->is_gen35_ioc) in scsih_change_queue_depth()
1808 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1811 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1814 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1817 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1820 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1825 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1829 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1836 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1837 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1838 return sdev->queue_depth; in scsih_change_queue_depth()
1842 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1843 * @sdev: scsi device struct
1851 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1854 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1855 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1861 * scsih_target_alloc - target add routine
1865 * the device is ignored.
1870 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1882 return -ENOMEM; in scsih_target_alloc()
1884 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1885 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1886 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1889 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1890 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1891 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1892 starget->channel); in scsih_target_alloc()
1894 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1895 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1896 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1897 if (ioc->is_warpdrive) in scsih_target_alloc()
1898 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1899 raid_device->starget = starget; in scsih_target_alloc()
1901 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1906 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1907 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1908 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1909 starget->channel); in scsih_target_alloc()
1911 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1912 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1913 sas_target_priv_data->port = NULL; in scsih_target_alloc()
1914 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1915 pcie_device->starget = starget; in scsih_target_alloc()
1916 pcie_device->id = starget->id; in scsih_target_alloc()
1917 pcie_device->channel = starget->channel; in scsih_target_alloc()
1918 sas_target_priv_data->flags |= in scsih_target_alloc()
1920 if (pcie_device->fast_path) in scsih_target_alloc()
1921 sas_target_priv_data->flags |= in scsih_target_alloc()
1924 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1929 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1930 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1934 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1935 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1936 sas_target_priv_data->port = sas_device->port; in scsih_target_alloc()
1937 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1938 sas_device->starget = starget; in scsih_target_alloc()
1939 sas_device->id = starget->id; in scsih_target_alloc()
1940 sas_device->channel = starget->channel; in scsih_target_alloc()
1941 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1942 sas_target_priv_data->flags |= in scsih_target_alloc()
1944 if (sas_device->fast_path) in scsih_target_alloc()
1945 sas_target_priv_data->flags |= in scsih_target_alloc()
1948 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1954 * scsih_target_destroy - target destroy routine
1960 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1968 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1972 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1973 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1974 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1975 starget->channel); in scsih_target_destroy()
1977 raid_device->starget = NULL; in scsih_target_destroy()
1978 raid_device->sdev = NULL; in scsih_target_destroy()
1980 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1984 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1985 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1988 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1989 (pcie_device->id == starget->id) && in scsih_target_destroy()
1990 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1991 pcie_device->starget = NULL; in scsih_target_destroy()
1997 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
2001 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
2005 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2007 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
2008 (sas_device->id == starget->id) && in scsih_target_destroy()
2009 (sas_device->channel == starget->channel)) in scsih_target_destroy()
2010 sas_device->starget = NULL; in scsih_target_destroy()
2016 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
2021 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2025 starget->hostdata = NULL; in scsih_target_destroy()
2029 * scsih_slave_alloc - device add routine
2030 * @sdev: scsi device struct
2033 * the device is ignored.
2051 return -ENOMEM; in scsih_slave_alloc()
2053 sas_device_priv_data->lun = sdev->lun; in scsih_slave_alloc()
2054 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_slave_alloc()
2057 sas_target_priv_data = starget->hostdata; in scsih_slave_alloc()
2058 sas_target_priv_data->num_luns++; in scsih_slave_alloc()
2059 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_slave_alloc()
2060 sdev->hostdata = sas_device_priv_data; in scsih_slave_alloc()
2061 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_slave_alloc()
2062 sdev->no_uld_attach = 1; in scsih_slave_alloc()
2064 shost = dev_to_shost(&starget->dev); in scsih_slave_alloc()
2066 if (starget->channel == RAID_CHANNEL) { in scsih_slave_alloc()
2067 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2069 starget->id, starget->channel); in scsih_slave_alloc()
2071 raid_device->sdev = sdev; /* raid is single lun */ in scsih_slave_alloc()
2072 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2074 if (starget->channel == PCIE_CHANNEL) { in scsih_slave_alloc()
2075 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2077 sas_target_priv_data->sas_address); in scsih_slave_alloc()
2078 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_slave_alloc()
2080 "%s : pcie_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2082 pcie_device->starget = starget; in scsih_slave_alloc()
2087 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2089 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_alloc()
2090 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2092 sas_target_priv_data->sas_address, in scsih_slave_alloc()
2093 sas_target_priv_data->port); in scsih_slave_alloc()
2094 if (sas_device && (sas_device->starget == NULL)) { in scsih_slave_alloc()
2096 "%s : sas_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2098 sas_device->starget = starget; in scsih_slave_alloc()
2104 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2111 * scsih_slave_destroy - device destroy routine
2112 * @sdev: scsi device struct
2125 if (!sdev->hostdata) in scsih_slave_destroy()
2129 sas_target_priv_data = starget->hostdata; in scsih_slave_destroy()
2130 sas_target_priv_data->num_luns--; in scsih_slave_destroy()
2132 shost = dev_to_shost(&starget->dev); in scsih_slave_destroy()
2135 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_destroy()
2136 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2139 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2140 pcie_device->starget = NULL; in scsih_slave_destroy()
2145 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2147 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_destroy()
2148 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2151 if (sas_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2152 sas_device->starget = NULL; in scsih_slave_destroy()
2156 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2159 kfree(sdev->hostdata); in scsih_slave_destroy()
2160 sdev->hostdata = NULL; in scsih_slave_destroy()
2164 * _scsih_display_sata_capabilities - sata capabilities
2165 * @ioc: per adapter object
2166 * @handle: device handle
2167 * @sdev: scsi device struct
2210 * raid transport support -
2212 * unloading the driver followed by a load - I believe that the subroutine
2217 * scsih_is_raid - return boolean indicating device is raid volume
2218 * @dev: the device struct object
2221 scsih_is_raid(struct device *dev) in scsih_is_raid()
2224 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2226 if (ioc->is_warpdrive) in scsih_is_raid()
2228 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2232 scsih_is_nvme(struct device *dev) in scsih_is_nvme()
2236 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2240 * scsih_get_resync - get raid volume resync percent complete
2241 * @dev: the device struct object
2244 scsih_get_resync(struct device *dev) in scsih_get_resync()
2247 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2258 if (ioc->is_warpdrive) in scsih_get_resync()
2261 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2262 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2263 sdev->channel); in scsih_get_resync()
2265 handle = raid_device->handle; in scsih_get_resync()
2266 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2268 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2289 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2301 * scsih_get_state - get raid volume level
2302 * @dev: the device struct object
2305 scsih_get_state(struct device *dev) in scsih_get_state()
2308 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2317 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2318 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2319 sdev->channel); in scsih_get_state()
2321 handle = raid_device->handle; in scsih_get_state()
2322 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2355 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2367 * _scsih_set_level - set raid level
2369 * @sdev: scsi device struct
2393 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2396 &sdev->sdev_gendev, level); in _scsih_set_level()
2401 &sdev->sdev_gendev, level); in _scsih_set_level()
2408 * _scsih_get_volume_capabilities - volume capabilities
2409 * @ioc: per adapter object
2425 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2433 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2444 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2452 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2455 * obtaining the device_info bits for the 1st device in _scsih_get_volume_capabilities()
2459 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2463 raid_device->device_info = in _scsih_get_volume_capabilities()
2473 * _scsih_enable_tlr - setting TLR flags
2474 * @ioc: per adapter object
2475 * @sdev: scsi device struct
2486 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2489 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2500 * scsih_slave_configure - device configure routine.
2501 * @sdev: scsi device struct
2504 * the device is ignored.
2509 struct Scsi_Host *shost = sdev->host; in scsih_slave_configure()
2525 sas_device_priv_data = sdev->hostdata; in scsih_slave_configure()
2526 sas_device_priv_data->configured_lun = 1; in scsih_slave_configure()
2527 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_slave_configure()
2528 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_slave_configure()
2529 handle = sas_target_priv_data->handle; in scsih_slave_configure()
2532 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_slave_configure()
2534 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2536 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2561 if (raid_device->device_info & in scsih_slave_configure()
2567 if (raid_device->device_info & in scsih_slave_configure()
2574 switch (raid_device->volume_type) { in scsih_slave_configure()
2580 if (ioc->manu_pg10.OEMIdentifier && in scsih_slave_configure()
2581 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_slave_configure()
2583 !(raid_device->num_pds % 2)) in scsih_slave_configure()
2603 if (!ioc->hide_ir_msg) in scsih_slave_configure()
2607 r_level, raid_device->handle, in scsih_slave_configure()
2608 (unsigned long long)raid_device->wwid, in scsih_slave_configure()
2609 raid_device->num_pds, ds); in scsih_slave_configure()
2611 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_slave_configure()
2612 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2622 if (!ioc->is_warpdrive) in scsih_slave_configure()
2623 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_slave_configure()
2627 /* non-raid handling */ in scsih_slave_configure()
2628 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_slave_configure()
2646 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_configure()
2647 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2649 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2651 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2658 qdepth = ioc->max_nvme_qd; in scsih_slave_configure()
2662 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_slave_configure()
2663 pcie_device->port_num); in scsih_slave_configure()
2664 if (pcie_device->enclosure_handle != 0) in scsih_slave_configure()
2668 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_slave_configure()
2669 pcie_device->slot); in scsih_slave_configure()
2670 if (pcie_device->connector_name[0] != '\0') in scsih_slave_configure()
2674 pcie_device->enclosure_level, in scsih_slave_configure()
2675 pcie_device->connector_name); in scsih_slave_configure()
2677 if (pcie_device->nvme_mdts) in scsih_slave_configure()
2678 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2679 pcie_device->nvme_mdts/512); in scsih_slave_configure()
2682 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2689 sdev->request_queue); in scsih_slave_configure()
2690 blk_queue_virt_boundary(sdev->request_queue, in scsih_slave_configure()
2691 ioc->page_size - 1); in scsih_slave_configure()
2695 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2697 sas_device_priv_data->sas_target->sas_address, in scsih_slave_configure()
2698 sas_device_priv_data->sas_target->port); in scsih_slave_configure()
2700 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2707 sas_device->volume_handle = volume_handle; in scsih_slave_configure()
2708 sas_device->volume_wwid = volume_wwid; in scsih_slave_configure()
2709 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_slave_configure()
2710 qdepth = (sas_device->port_type > 1) ? in scsih_slave_configure()
2711 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_slave_configure()
2713 if (sas_device->device_info & in scsih_slave_configure()
2717 sas_device_priv_data->sas_target->handle); in scsih_slave_configure()
2718 sas_device_priv_data->ignore_delay_remove = 1; in scsih_slave_configure()
2723 qdepth = ioc->max_sata_qd; in scsih_slave_configure()
2724 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_slave_configure()
2726 else if (sas_device->device_info & in scsih_slave_configure()
2733 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_slave_configure()
2734 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_slave_configure()
2739 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2756 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2757 * @sdev: scsi device struct
2758 * @bdev: pointer to block device context
2759 * @capacity: device size (in 512 byte sectors)
2802 * _scsih_response_code - translation of device response code
2803 * @ioc: per adapter object
2804 * @response_code: response code returned by the device
2844 * _scsih_tm_done - tm completion routine
2845 * @ioc: per adapter object
2861 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2863 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2865 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2868 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2869 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2871 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2872 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2877 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2878 * @ioc: per adapter object
2879 * @handle: device handle
2881 * During taskmangement request, we need to freeze the device queue.
2890 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2893 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2896 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2897 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2899 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2905 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2906 * @ioc: per adapter object
2907 * @handle: device handle
2909 * During taskmangement request, we need to freeze the device queue.
2918 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2921 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2924 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2925 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2927 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2933 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2934 * @ioc: per adapter object
2949 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2965 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2966 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2967 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2969 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2970 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2971 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2979 * scsih_tm_post_processing - post processing of target & LUN reset
2980 * @ioc: per adapter object
2981 * @handle: device handle
3023 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3024 * @ioc: per adapter struct
3025 * @handle: device handle
3038 * The callback index is set inside `ioc->tm_cb_idx`.
3056 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3058 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3063 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3064 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3089 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3098 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3100 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3102 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3103 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3104 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3105 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3108 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3109 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3110 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3112 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3113 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3114 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3115 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3117 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3130 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3132 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3135 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3136 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3137 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3138 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3139 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3140 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3151 * doesn't match with device handle on which this task abort in mpt3sas_scsih_issue_tm()
3161 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3186 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3196 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3199 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3205 * _scsih_tm_display_info - displays info about the device
3206 * @ioc: per adapter struct
3214 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3215 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3223 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3229 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3232 device_str, priv_target->handle, in _scsih_tm_display_info()
3233 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3235 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3236 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3241 pcie_device->handle, in _scsih_tm_display_info()
3242 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3243 pcie_device->port_num); in _scsih_tm_display_info()
3244 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3248 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3249 pcie_device->slot); in _scsih_tm_display_info()
3250 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3253 pcie_device->enclosure_level, in _scsih_tm_display_info()
3254 pcie_device->connector_name); in _scsih_tm_display_info()
3257 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3260 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3263 if (priv_target->flags & in _scsih_tm_display_info()
3268 sas_device->volume_handle, in _scsih_tm_display_info()
3269 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3273 sas_device->handle, in _scsih_tm_display_info()
3274 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3275 sas_device->phy); in _scsih_tm_display_info()
3282 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3287 * scsih_abort - eh threads main abort routine
3295 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3303 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3305 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3306 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3309 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3310 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3311 ioc->remove_host) { in scsih_abort()
3312 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3313 "device been deleted! scmd(0x%p)\n", scmd); in scsih_abort()
3314 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3321 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3322 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3324 scmd->result = DID_RESET << 16; in scsih_abort()
3330 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3332 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3333 scmd->result = DID_RESET << 16; in scsih_abort()
3340 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3342 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3343 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3344 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3345 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3346 scmd->device->id, scmd->device->lun, in scsih_abort()
3348 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3350 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3353 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3361 * scsih_dev_reset - eh threads main device reset routine
3369 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3378 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3379 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3381 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3382 "attempting device reset! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3385 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3386 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3387 ioc->remove_host) { in scsih_dev_reset()
3388 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3389 "device been deleted! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3390 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3398 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3403 handle = sas_device->volume_handle; in scsih_dev_reset()
3405 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3408 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3415 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3416 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3417 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3422 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3423 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3427 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3430 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3442 * scsih_target_reset - eh threads main target reset routine
3450 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3458 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3459 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3465 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3466 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3467 ioc->remove_host) { in scsih_target_reset()
3470 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3478 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3483 handle = sas_device->volume_handle; in scsih_target_reset()
3485 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3488 scmd->result = DID_RESET << 16; in scsih_target_reset()
3495 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3496 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3497 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3501 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3502 scmd->device->id, 0, in scsih_target_reset()
3506 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3521 * scsih_host_reset - eh threads main host reset routine
3529 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3535 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3551 * _scsih_fw_event_add - insert and queue up fw_event
3552 * @ioc: per adapter object
3554 * Context: This function will acquire ioc->fw_event_lock.
3564 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3567 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3569 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3570 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3571 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3573 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3574 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3578 * _scsih_fw_event_del_from_list - delete fw_event from the list
3579 * @ioc: per adapter object
3581 * Context: This function will acquire ioc->fw_event_lock.
3591 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3592 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3593 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3596 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3601 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3602 * @ioc: per adapter object
3612 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3618 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3619 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3620 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3626 * _scsih_error_recovery_delete_devices - remove devices not responding
3627 * @ioc: per adapter object
3637 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3638 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3644 * mpt3sas_port_enable_complete - port enable completed (fake event)
3645 * @ioc: per adapter object
3655 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3656 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3666 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3667 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3668 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3670 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3673 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3679 * _scsih_fw_event_cleanup_queue - cleanup event queue
3680 * @ioc: per adapter object
3692 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3693 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3701 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3702 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3704 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3706 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3722 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3723 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3725 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3730 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3737 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3738 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3739 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3750 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3754 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3758 * _scsih_internal_device_block - block the sdev device
3759 * @sdev: per device object
3760 * @sas_device_priv_data : per device driver private data
3762 * make sure device is blocked without error, if not
3772 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3773 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3776 if (r == -EINVAL) in _scsih_internal_device_block()
3779 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3783 * _scsih_internal_device_unblock - unblock the sdev device
3784 * @sdev: per device object
3785 * @sas_device_priv_data : per device driver private data
3786 * make sure device is unblocked without error, if not retry
3797 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3798 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3800 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3801 /* The device has been set to SDEV_RUNNING by SD layer during in _scsih_internal_device_unblock()
3802 * device addition but the request queue is still stopped by in _scsih_internal_device_unblock()
3804 * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */ in _scsih_internal_device_unblock()
3809 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3810 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3815 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3817 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3822 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3827 * _scsih_ublock_io_all_device - unblock every device
3828 * @ioc: per adapter object
3830 * change the device state from block to running
3838 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3839 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3842 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3847 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3854 * _scsih_ublock_io_device - prepare device to be deleted
3855 * @ioc: per adapter object
3859 * unblock then put device in offline state
3868 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3869 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3870 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3872 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3875 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3877 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3884 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3885 * @ioc: per adapter object
3887 * During device pull we need to appropriately set the sdev state.
3895 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3896 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3899 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3901 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3904 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3912 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3913 * @ioc: per adapter object
3914 * @handle: device handle
3916 * During device pull we need to appropriately set the sdev state.
3927 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3928 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3931 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3933 if (sas_device_priv_data->block) in _scsih_block_io_device()
3935 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3937 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3940 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3952 * @ioc: per adapter object
3972 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3973 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3975 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3977 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3978 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3980 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3981 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3984 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3989 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3991 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3993 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3997 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3998 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
4007 * @ioc: per adapter object
4011 * direct attached during device pull.
4021 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4022 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4025 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4034 * @ioc: per adapter object
4038 * direct attached during device pull/reconnect.
4048 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4050 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4053 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4060 * _scsih_tm_tr_send - send task management request
4061 * @ioc: per adapter object
4062 * @handle: device handle
4065 * This code is to initiate the device removal handshake protocol
4089 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4104 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4107 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4109 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4111 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4112 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4113 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4114 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4115 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4116 port = sas_device->port; in _scsih_tm_tr_send()
4118 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4120 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4122 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4123 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4124 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4125 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4126 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4128 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4129 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4131 pcie_device->device_info)))) in _scsih_tm_tr_send()
4142 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4145 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4146 sas_device->slot)); in _scsih_tm_tr_send()
4147 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4150 sas_device->enclosure_level, in _scsih_tm_tr_send()
4151 sas_device->connector_name)); in _scsih_tm_tr_send()
4153 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4156 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4157 pcie_device->slot)); in _scsih_tm_tr_send()
4158 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4161 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4162 pcie_device->connector_name)); in _scsih_tm_tr_send()
4165 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4168 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4173 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4174 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4175 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4184 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4187 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4188 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4189 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4190 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4191 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4192 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4203 * _scsih_tm_tr_complete -
4204 * @ioc: per adapter object
4211 * This code is part of the code to initiate the device removal
4231 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4250 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4251 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4255 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4262 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4263 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4264 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4266 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4271 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4272 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4273 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4282 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4285 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4286 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4287 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4288 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4293 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4295 * @ioc: per adapter object
4304 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4307 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4308 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4314 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4316 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4329 * _scsih_sas_control_complete - completion routine
4330 * @ioc: per adapter object
4337 * This code is part of the code to initiate the device removal
4353 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4354 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4355 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4356 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4358 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4359 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4369 * _scsih_tm_tr_volume_send - send target reset request for volumes
4370 * @ioc: per adapter object
4371 * @handle: device handle
4385 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4392 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4397 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4398 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4399 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4408 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4411 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4412 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4413 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4414 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4418 * _scsih_tm_volume_tr_complete - target reset completion
4419 * @ioc: per adapter object
4437 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4450 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4451 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4454 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4461 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4462 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4463 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4469 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4470 * @ioc: per adapter object
4475 * Context - processed in interrupt context.
4482 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4489 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4490 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4491 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4495 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4498 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4499 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4500 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4501 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4502 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4503 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4507 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4509 * @ioc: per adapter object
4511 * @handle: device handle
4513 * Context - processed in interrupt context.
4521 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4524 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4529 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4547 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4548 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4549 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4553 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4556 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4557 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4558 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4559 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4563 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4564 * @ioc: per adapter object
4581 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4582 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4585 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4586 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4591 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4592 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4595 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4596 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4604 * _scsih_check_for_pending_tm - check for pending task management
4605 * @ioc: per adapter object
4619 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4620 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4623 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4624 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4629 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4630 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4633 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4634 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4643 * _scsih_check_topo_delete_events - sanity check on topo events
4644 * @ioc: per adapter object
4665 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4666 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4669 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4675 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4676 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4680 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4683 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4687 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4689 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4690 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4691 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4693 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4694 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4697 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4701 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4702 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4703 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4704 fw_event->ignore) in _scsih_check_topo_delete_events()
4707 fw_event->event_data; in _scsih_check_topo_delete_events()
4708 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4710 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4712 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4716 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4720 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4724 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4726 * @ioc: per adapter object
4730 * or device add and delete events in a single shot. When there
4744 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4746 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4749 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4754 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4761 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4763 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4768 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4772 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4773 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4774 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4775 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4779 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4780 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4782 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4784 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4788 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4792 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4796 * _scsih_set_volume_delete_flag - setting volume delete flag
4797 * @ioc: per adapter object
4798 * @handle: device handle
4809 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4811 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4812 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4814 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4815 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4818 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4820 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4824 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4831 * input handle is non-zero, or when a and b have not been set before.
4845 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4846 * @ioc: per adapter object
4868 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4872 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4873 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4874 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4877 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4879 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4881 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4888 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4889 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4890 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4893 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4894 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4905 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4906 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4907 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4909 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4910 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4911 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4917 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4918 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4919 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4930 * _scsih_check_volume_delete_events - set delete flag for volumes
4931 * @ioc: per adapter object
4945 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4947 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4951 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4955 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4956 * @ioc: per adapter object
4965 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4967 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4968 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4969 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4970 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4971 event_data->SensorNum); in _scsih_temp_threshold_events()
4973 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4974 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4991 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4993 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4997 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4999 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5004 * _scsih_flush_running_cmds - completing outstanding commands.
5005 * @ioc: per adapter object
5018 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5027 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5028 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5030 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5037 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5038 * @ioc: per adapter object
5063 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5066 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5069 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5072 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5076 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5078 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5080 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5084 * _scsih_eedp_error_handling - return sense code for EEDP errors
5112 * scsih_qcmd - main scsi request entry point
5116 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5119 * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
5137 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5140 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5141 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5142 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5148 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5153 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5155 /* invalid device handle */ in scsih_qcmd()
5156 handle = sas_target_priv_data->handle; in scsih_qcmd()
5159 * Avoid error handling escallation when device is disconnected in scsih_qcmd()
5161 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5162 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5163 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5171 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5177 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5180 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5181 /* device has been deleted */ in scsih_qcmd()
5182 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5185 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5186 sas_device_priv_data->block) { in scsih_qcmd()
5187 /* device busy with task management */ in scsih_qcmd()
5197 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5201 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5203 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5211 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5216 /* Make sure Device is not raid volume. in scsih_qcmd()
5219 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5220 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5221 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5224 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5231 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5234 if (scmd->cmd_len == 32) in scsih_qcmd()
5236 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5237 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5239 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5241 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5242 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5243 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5244 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5245 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5246 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5247 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5248 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5250 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5251 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5252 mpi_request->LUN); in scsih_qcmd()
5253 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5255 if (mpi_request->DataLength) { in scsih_qcmd()
5256 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5257 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5263 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5265 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5266 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5270 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5271 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5272 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5274 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5276 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5277 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5279 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5287 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5296 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5297 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5298 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5301 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5302 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5303 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5308 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5309 * @ioc: per adapter object
5314 * scsi_status - SCSI Status code returned from target device
5315 * scsi_state - state info associated with SCSI_IO determined by ioc
5316 * ioc_status - ioc supplied status info
5324 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5326 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5327 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5330 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5331 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5334 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5335 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5340 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5362 desc_ioc_state = "scsi device not there"; in _scsih_scsi_ioc_info()
5463 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5465 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5466 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5470 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5471 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5473 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5474 pcie_device->slot); in _scsih_scsi_ioc_info()
5475 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5477 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5478 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5485 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5495 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5498 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5499 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5500 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5501 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5507 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5510 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5513 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5520 * _scsih_turn_on_pfa_led - illuminate PFA LED
5521 * @ioc: per adapter object
5522 * @handle: device handle
5549 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5563 * _scsih_turn_off_pfa_led - turn off Fault LED
5564 * @ioc: per adapter object
5565 * @sas_device: sas device whose PFA LED has to turned off
5579 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5581 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5600 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5601 * @ioc: per adapter object
5602 * @handle: device handle
5613 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5614 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5615 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5621 * _scsih_smart_predicted_fault - process smart errors
5622 * @ioc: per adapter object
5623 * @handle: device handle
5637 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5638 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5643 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5644 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5646 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5647 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5652 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5654 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5667 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5668 event_reply->Event = in _scsih_smart_predicted_fault()
5670 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5671 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5674 event_reply->EventData; in _scsih_smart_predicted_fault()
5675 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5676 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5677 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5678 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5687 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5692 * _scsih_io_done - scsi request callback
5693 * @ioc: per adapter object
5729 scmd->result = DID_OK << 16; in _scsih_io_done()
5733 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5734 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5735 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5736 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5739 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5746 if (st->direct_io && in _scsih_io_done()
5749 st->direct_io = 0; in _scsih_io_done()
5750 st->scmd = scmd; in _scsih_io_done()
5751 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5752 mpi_request->DevHandle = in _scsih_io_done()
5753 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5754 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5755 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5759 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5762 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5763 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5764 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5765 if ((!ioc->is_warpdrive && in _scsih_io_done()
5766 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5767 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5768 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5770 sas_disable_tlr(scmd->device); in _scsih_io_done()
5771 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5775 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5776 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5778 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5782 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5796 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5797 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5798 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5802 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5805 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5806 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5807 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5808 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5814 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5818 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5822 if (sas_device_priv_data->block) { in _scsih_io_done()
5823 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5827 if (scmd->retries > 2) { in _scsih_io_done()
5828 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5829 scsi_device_set_state(scmd->device, in _scsih_io_done()
5832 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5833 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5837 scmd->result = DID_RESET << 16; in _scsih_io_done()
5839 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5842 scmd->result = DID_RESET << 16; in _scsih_io_done()
5845 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5849 scmd->result = DID_RESET << 16; in _scsih_io_done()
5853 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5854 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5856 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5860 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5865 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5867 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5869 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5872 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5874 scmd->result = DID_RESET << 16; in _scsih_io_done()
5875 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5876 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5877 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5888 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5893 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5895 scmd->result = DID_RESET << 16; in _scsih_io_done()
5914 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5919 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5931 * _scsih_update_vphys_after_reset - update the Port's
5933 * @ioc: per adapter object
5956 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5957 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5960 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5961 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5968 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_update_vphys_after_reset()
5984 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5988 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
5992 * Check whether Phy is connected to SEP device or not, in _scsih_update_vphys_after_reset()
5993 * if it is SEP device then read the Phy's SASPHYPage0 data to in _scsih_update_vphys_after_reset()
5996 * device is a HBA's vSES device. in _scsih_update_vphys_after_reset()
5999 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6014 * Get the vSES device's SAS Address. in _scsih_update_vphys_after_reset()
6017 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6032 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6033 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6036 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6041 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6047 * to current Phy's vSES device SAS Address. in _scsih_update_vphys_after_reset()
6049 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6055 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6056 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6064 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6071 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6074 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6075 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6076 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6081 * device's Port ID got changed after reset and in _scsih_update_vphys_after_reset()
6086 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6088 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6089 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6090 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6091 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6092 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6096 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6101 * direct attached device with mport's Port ID, in _scsih_update_vphys_after_reset()
6103 * device has this Port ID, so unmark the mport in _scsih_update_vphys_after_reset()
6106 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6107 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6108 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6109 mport->flags &= in _scsih_update_vphys_after_reset()
6115 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6128 * _scsih_get_port_table_after_reset - Construct temporary port table
6129 * @ioc: per adapter object
6146 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_get_port_table_after_reset()
6160 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6162 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6166 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6175 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6187 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6207 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6209 * @ioc: per adapter object
6227 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6228 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6231 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6232 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6238 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6239 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6240 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6246 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6247 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6256 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6275 * _scsih_del_phy_part_of_anther_port - remove phy if it
6277 *@ioc: per adapter object
6289 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6298 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6308 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6310 *@ioc: per adapter object
6323 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6325 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6327 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6335 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6337 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6339 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6340 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6347 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6348 * @ioc: per adapter object
6359 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6360 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6363 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6364 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6367 vphy, port->port_id, in _scsih_del_dirty_vphy()
6368 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6369 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6370 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6374 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6375 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6380 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6382 *@ioc: per adapter object
6391 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6392 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6393 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6398 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6399 list_del(&port->list); in _scsih_del_dirty_port_entries()
6405 * _scsih_sas_port_refresh - Update HBA port table after host reset
6406 * @ioc: per adapter object
6422 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6431 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6436 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6438 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6454 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6455 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6459 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6462 port_table_entry->port_id, in _scsih_sas_port_refresh()
6463 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6464 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6501 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6502 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6503 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6504 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6511 * _scsih_alloc_vphy - allocate virtual_phy object
6512 * @ioc: per adapter object
6534 if (!port->vphys_mask) in _scsih_alloc_vphy()
6535 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6541 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6542 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6544 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6548 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6554 * _scsih_sas_host_refresh - refreshing sas host object contents
6555 * @ioc: per adapter object
6558 * During port enable, fw will send topology events for every device. Its
6577 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6579 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_refresh()
6593 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6594 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6596 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6597 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6598 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6604 port->port_id = port_id; in _scsih_sas_host_refresh()
6607 port, port->port_id); in _scsih_sas_host_refresh()
6608 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6609 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6610 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6613 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_refresh()
6615 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6629 * Allocate a virtual_phy object for vSES device, if in _scsih_sas_host_refresh()
6630 * this vSES device is hot added. in _scsih_sas_host_refresh()
6634 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6641 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6655 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6657 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6658 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6661 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6662 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6666 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6668 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6670 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6676 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6677 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6678 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6679 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6682 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6690 * _scsih_sas_host_add - create sas host object
6691 * @ioc: per adapter object
6693 * Creating host side data object, stored in ioc->sas_hba
6718 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6720 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6722 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6727 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6730 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6752 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6773 ioc->io_missing_delay = in _scsih_sas_host_add()
6774 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6776 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6778 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6781 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6784 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6785 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6801 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6804 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6810 port->port_id = port_id; in _scsih_sas_host_add()
6813 port, port->port_id); in _scsih_sas_host_add()
6814 list_add_tail(&port->list, in _scsih_sas_host_add()
6815 &ioc->port_table_list); in _scsih_sas_host_add()
6819 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_add()
6826 * Allocate a virtual_phy object for vSES device. in _scsih_sas_host_add()
6830 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6833 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6834 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6835 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6837 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6838 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6841 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6846 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6848 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6850 ioc->sas_hba.handle, in _scsih_sas_host_add()
6851 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6852 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6854 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6857 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6858 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6868 * _scsih_expander_add - creating expander object
6869 * @ioc: per adapter object
6872 * Creating expander object, stored in ioc->sas_expander_list.
6895 return -1; in _scsih_expander_add()
6897 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6898 return -1; in _scsih_expander_add()
6904 return -1; in _scsih_expander_add()
6912 return -1; in _scsih_expander_add()
6921 return -1; in _scsih_expander_add()
6925 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6926 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6930 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6938 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6942 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6952 return -1; in _scsih_expander_add()
6955 sas_expander->handle = handle; in _scsih_expander_add()
6956 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6957 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6958 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6959 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6960 if (!sas_expander->port) { in _scsih_expander_add()
6963 rc = -1; in _scsih_expander_add()
6969 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6971 if (!sas_expander->num_phys) { in _scsih_expander_add()
6972 rc = -1; in _scsih_expander_add()
6975 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6977 if (!sas_expander->phy) { in _scsih_expander_add()
6980 rc = -1; in _scsih_expander_add()
6984 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6986 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6990 rc = -1; in _scsih_expander_add()
6993 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6994 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
6996 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
7001 rc = -1; in _scsih_expander_add()
7004 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
7005 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
7006 sas_expander->phy[i].port = in _scsih_expander_add()
7010 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7011 sas_expander->parent_dev))) { in _scsih_expander_add()
7014 rc = -1; in _scsih_expander_add()
7019 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7022 sas_expander->enclosure_handle); in _scsih_expander_add()
7024 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7025 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7034 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7035 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7041 * mpt3sas_expander_remove - removing expander object
7042 * @ioc: per adapter object
7053 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7059 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7062 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7068 * _scsih_done - internal SCSI_IO callback handler.
7069 * @ioc: per adapter object
7075 * The callback index passed is `ioc->scsih_cb_idx`
7086 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7088 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7090 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7092 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7093 mpi_reply->MsgLength*4); in _scsih_done()
7094 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7096 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7097 complete(&ioc->scsih_cmds.done); in _scsih_done()
7108 * _scsih_check_access_status - check access flags
7109 * @ioc: per adapter object
7111 * @handle: sas device handle
7112 * @access_status: errors returned during discovery of the device
7141 desc = "device blocked"; in _scsih_check_access_status()
7171 * _scsih_check_device - checking device responsiveness
7172 * @ioc: per adapter object
7174 * @handle: attached device handle
7202 /* wide port handling ~ we need only handle device once for the phy that in _scsih_check_device()
7203 * is matched in sas device page zero in _scsih_check_device()
7208 /* check if this is end device */ in _scsih_check_device()
7213 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7224 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7225 starget = sas_device->starget; in _scsih_check_device()
7226 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7229 sas_device->handle, handle); in _scsih_check_device()
7230 sas_target_priv_data->handle = handle; in _scsih_check_device()
7231 sas_device->handle = handle; in _scsih_check_device()
7234 sas_device->enclosure_level = in _scsih_check_device()
7236 memcpy(sas_device->connector_name, in _scsih_check_device()
7238 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7240 sas_device->enclosure_level = 0; in _scsih_check_device()
7241 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7244 sas_device->enclosure_handle = in _scsih_check_device()
7246 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7248 sas_device->enclosure_handle); in _scsih_check_device()
7250 sas_device->enclosure_logical_id = in _scsih_check_device()
7251 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7252 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7254 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7255 sas_device->chassis_slot = in _scsih_check_device()
7256 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7261 /* check if device is present */ in _scsih_check_device()
7264 ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_check_device()
7274 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7282 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7288 * _scsih_add_device - creating sas device object
7289 * @ioc: per adapter object
7290 * @handle: sas device handle
7291 * @phy_num: phy number end device attached to
7294 * Creating end device object, stored in ioc->sas_device_list.
7296 * Return: 0 for success, non-zero for failure.
7315 return -1; in _scsih_add_device()
7323 return -1; in _scsih_add_device()
7326 /* check if this is end device */ in _scsih_add_device()
7329 return -1; in _scsih_add_device()
7330 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7333 /* check if device is present */ in _scsih_add_device()
7336 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_add_device()
7338 return -1; in _scsih_add_device()
7344 return -1; in _scsih_add_device()
7350 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7352 return -1; in _scsih_add_device()
7360 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_add_device()
7372 kref_init(&sas_device->refcount); in _scsih_add_device()
7373 sas_device->handle = handle; in _scsih_add_device()
7376 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7379 sas_device->enclosure_handle = in _scsih_add_device()
7381 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7382 sas_device->slot = in _scsih_add_device()
7384 sas_device->device_info = device_info; in _scsih_add_device()
7385 sas_device->sas_address = sas_address; in _scsih_add_device()
7386 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7387 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7389 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7390 if (!sas_device->port) { in _scsih_add_device()
7398 sas_device->enclosure_level = in _scsih_add_device()
7400 memcpy(sas_device->connector_name, in _scsih_add_device()
7402 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7404 sas_device->enclosure_level = 0; in _scsih_add_device()
7405 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7408 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7410 sas_device->enclosure_logical_id = in _scsih_add_device()
7411 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7412 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7414 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7415 sas_device->chassis_slot = in _scsih_add_device()
7416 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7420 /* get device name */ in _scsih_add_device()
7421 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7422 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7425 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7427 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7438 * _scsih_remove_device - removing sas device object
7439 * @ioc: per adapter object
7448 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7449 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7451 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7457 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7462 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7463 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7464 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7465 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7466 sas_device->port); in _scsih_remove_device()
7467 sas_target_priv_data->handle = in _scsih_remove_device()
7471 if (!ioc->hide_drives) in _scsih_remove_device()
7473 sas_device->sas_address, in _scsih_remove_device()
7474 sas_device->sas_address_parent, in _scsih_remove_device()
7475 sas_device->port); in _scsih_remove_device()
7478 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7485 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7491 * _scsih_sas_topology_change_event_debug - debug for topology event
7492 * @ioc: per adapter object
7507 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7528 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7529 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7530 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7531 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7532 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7535 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7536 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7558 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7559 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7568 * _scsih_sas_topology_change_event - handle topology changes
7569 * @ioc: per adapter object
7589 fw_event->event_data; in _scsih_sas_topology_change_event()
7591 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7594 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7597 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7602 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7607 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7608 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7611 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7615 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7619 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7620 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7621 port = sas_expander->port; in _scsih_sas_topology_change_event()
7622 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7623 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7624 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7626 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7629 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7632 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7633 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7638 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7640 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7643 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7645 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7649 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7652 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7653 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7657 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7672 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7679 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7696 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7704 * _scsih_sas_device_status_change_event_debug - debug for device event
7715 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7720 reason_str = "unsupported device discovered"; in _scsih_sas_device_status_change_event_debug()
7723 reason_str = "internal device reset"; in _scsih_sas_device_status_change_event_debug()
7741 reason_str = "internal device reset complete"; in _scsih_sas_device_status_change_event_debug()
7759 ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)", in _scsih_sas_device_status_change_event_debug()
7760 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7761 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7762 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7763 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7765 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7770 * _scsih_sas_device_status_change_event - handle device status change
7771 * @ioc: per adapter object
7784 /* In MPI Revision K (0xC), the internal device reset complete was in _scsih_sas_device_status_change_event()
7787 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7790 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7792 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7796 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7797 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7800 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7802 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7805 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7809 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7811 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7813 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7815 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7818 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7819 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7825 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7830 * _scsih_check_pcie_access_status - check access flags
7831 * @ioc: per adapter object
7833 * @handle: sas device handle
7834 * @access_status: errors returned during discovery of the device
7851 desc = "PCIe device capability failed"; in _scsih_check_pcie_access_status()
7854 desc = "PCIe device blocked"; in _scsih_check_pcie_access_status()
7856 "Device with Access Status (%s): wwid(0x%016llx), " in _scsih_check_pcie_access_status()
7862 desc = "PCIe device mem space access failed"; in _scsih_check_pcie_access_status()
7865 desc = "PCIe device unsupported"; in _scsih_check_pcie_access_status()
7868 desc = "PCIe device MSIx Required"; in _scsih_check_pcie_access_status()
7871 desc = "PCIe device init fail max"; in _scsih_check_pcie_access_status()
7874 desc = "PCIe device status unknown"; in _scsih_check_pcie_access_status()
7880 desc = "nvme device configuration unsupported"; in _scsih_check_pcie_access_status()
7918 * _scsih_pcie_device_remove_from_sml - removing pcie device
7920 * @ioc: per adapter object
7932 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7933 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7937 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7938 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7939 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7943 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7944 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7946 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7947 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7948 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7949 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7950 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7954 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7955 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7957 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7958 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7959 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7961 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7962 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7964 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7966 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7970 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7971 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7975 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7976 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7977 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7981 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7982 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7984 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7989 * _scsih_pcie_check_device - checking device responsiveness
7990 * @ioc: per adapter object
7991 * @handle: attached device handle
8014 /* check if this is end device */ in _scsih_pcie_check_device()
8020 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8024 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8028 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8029 starget = pcie_device->starget; in _scsih_pcie_check_device()
8030 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8031 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8034 pcie_device->handle, handle); in _scsih_pcie_check_device()
8035 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8036 pcie_device->handle = handle; in _scsih_pcie_check_device()
8040 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8042 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8045 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8046 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8050 /* check if device is present */ in _scsih_pcie_check_device()
8053 ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_pcie_check_device()
8055 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8063 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8068 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8077 * _scsih_pcie_add_device - creating pcie device object
8078 * @ioc: per adapter object
8079 * @handle: pcie device handle
8081 * Creating end device object, stored in ioc->pcie_device_list.
8110 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8113 /* check if device is present */ in _scsih_pcie_add_device()
8116 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_pcie_add_device()
8132 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8137 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8138 * specific NVMe device; therefore, this page is only in _scsih_pcie_add_device()
8169 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8170 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8171 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8172 pcie_device->handle = handle; in _scsih_pcie_add_device()
8173 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8174 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8175 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8176 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8177 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8180 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8182 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8183 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8187 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8188 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8191 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8192 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8196 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8199 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8201 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8202 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8204 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8207 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8209 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8216 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8217 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8218 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8220 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8223 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8225 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8227 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8237 * _scsih_pcie_topology_change_event_debug - debug for topology
8239 * @ioc: per adapter object
8254 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8275 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8276 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8277 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8278 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8280 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8283 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8284 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8305 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8307 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8316 * _scsih_pcie_topology_change_event - handle PCIe topology
8318 * @ioc: per adapter object
8334 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8337 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8340 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8341 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8344 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8350 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8351 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8356 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8358 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8360 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8364 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8366 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8371 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8381 * where a device has been added, however its returning in _scsih_pcie_topology_change_event()
8382 * BUSY for sometime. Then before the Device Missing in _scsih_pcie_topology_change_event()
8383 * Delay expires and the device becomes READY, the in _scsih_pcie_topology_change_event()
8384 * device is removed and added back. in _scsih_pcie_topology_change_event()
8386 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8388 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8395 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8399 ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n", in _scsih_pcie_topology_change_event()
8401 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8402 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8406 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8418 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8430 * _scsih_pcie_device_status_change_event_debug - debug for device event
8441 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8446 reason_str = "unsupported device discovered"; in _scsih_pcie_device_status_change_event_debug()
8449 reason_str = "internal device reset"; in _scsih_pcie_device_status_change_event_debug()
8464 reason_str = "device init failure"; in _scsih_pcie_device_status_change_event_debug()
8467 reason_str = "internal device reset complete"; in _scsih_pcie_device_status_change_event_debug()
8483 ioc_info(ioc, "PCIE device status change: (%s)\n" in _scsih_pcie_device_status_change_event_debug()
8485 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8486 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8487 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8488 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8490 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8495 * _scsih_pcie_device_status_change_event - handle device status
8497 * @ioc: per adapter object
8510 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8511 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8515 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8517 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8521 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8522 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8525 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8528 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8532 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8534 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8536 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8541 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8545 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8547 * @ioc: per adapter object
8557 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8572 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8573 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8574 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8578 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8579 * @ioc: per adapter object
8590 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8592 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8594 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8597 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8598 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8605 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8617 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8627 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8628 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8633 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8643 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8644 * @ioc: per adapter object
8663 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8670 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8672 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8676 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8677 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8687 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8691 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8692 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8698 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8699 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8700 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8703 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8707 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8711 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8715 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8716 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8719 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8722 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8724 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8725 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8730 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8733 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8739 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8744 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8746 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8748 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8757 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8761 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8764 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8765 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8766 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8767 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8778 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8780 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8781 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8784 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8789 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8794 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8798 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8801 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8802 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8804 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8808 * _scsih_sas_discovery_event - handle discovery events
8809 * @ioc: per adapter object
8818 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8820 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8822 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8824 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8826 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8830 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8831 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8832 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8834 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8842 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8844 * @ioc: per adapter object
8853 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8855 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8858 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8859 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8860 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8864 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8865 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8866 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8874 * _scsih_pcie_enumeration_event - handle enumeration events
8875 * @ioc: per adapter object
8884 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8886 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8890 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8892 event_data->Flags); in _scsih_pcie_enumeration_event()
8893 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8895 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8900 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8901 * @ioc: per adapter object
8902 * @handle: device handle for physical disk
8918 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8921 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8923 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8925 rc = -EAGAIN; in _scsih_ir_fastpath()
8928 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8930 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8933 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8934 rc = -EAGAIN; in _scsih_ir_fastpath()
8939 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8942 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8943 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8944 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8950 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8951 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8952 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8954 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8956 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8958 rc = -EFAULT; in _scsih_ir_fastpath()
8962 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8964 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8965 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8967 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8975 rc = -EFAULT; in _scsih_ir_fastpath()
8982 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8983 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8991 * _scsih_reprobe_lun - reprobing lun
8992 * @sdev: scsi device struct
8993 * @no_uld_attach: sdev->no_uld_attach flag setting
8999 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
9001 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
9006 * _scsih_sas_volume_add - add new volume
9007 * @ioc: per adapter object
9018 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
9028 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9030 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9042 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9043 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9044 raid_device->handle = handle; in _scsih_sas_volume_add()
9045 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9047 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9048 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9049 raid_device->id, 0); in _scsih_sas_volume_add()
9053 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9055 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9060 * _scsih_sas_volume_delete - delete volume
9061 * @ioc: per adapter object
9062 * @handle: volume device handle
9073 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9076 if (raid_device->starget) { in _scsih_sas_volume_delete()
9077 starget = raid_device->starget; in _scsih_sas_volume_delete()
9078 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9079 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9082 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9083 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9086 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9088 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9092 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9093 * @ioc: per adapter object
9105 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
9107 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9110 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9111 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9112 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9113 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9114 starget = sas_device->starget; in _scsih_sas_pd_expose()
9115 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9116 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9120 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9132 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9133 * @ioc: per adapter object
9145 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
9154 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9157 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9158 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9159 starget = sas_device->starget; in _scsih_sas_pd_hide()
9160 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9161 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9163 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9164 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9167 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9172 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9181 * _scsih_sas_pd_delete - delete pd component
9182 * @ioc: per adapter object
9190 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
9196 * _scsih_sas_pd_add - remove pd component
9197 * @ioc: per adapter object
9206 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
9213 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9217 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9244 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9249 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9250 * @ioc: per adapter object
9263 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9266 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9268 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9269 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9270 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9302 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9320 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9321 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9322 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9327 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9328 * @ioc: per adapter object
9341 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9343 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9344 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9347 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9350 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9351 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9352 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9353 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9354 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9356 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9357 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9362 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9364 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9374 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9377 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9381 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9385 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9389 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9397 * _scsih_sas_ir_volume_event - IR volume event
9398 * @ioc: per adapter object
9413 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9415 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9418 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9421 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9422 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9423 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9427 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9439 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9441 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9460 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9461 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9462 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9463 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9465 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9466 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9478 * _scsih_sas_ir_physical_disk_event - PD event
9479 * @ioc: per adapter object
9494 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9497 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9500 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9503 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9504 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9506 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9510 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9520 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9521 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9565 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9566 * @ioc: per adapter object
9576 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9599 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9600 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9604 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9605 * @ioc: per adapter object
9615 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9620 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9621 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9626 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9628 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9629 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9632 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9633 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9634 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9639 * _scsih_prep_device_scan - initialize parameters prior to device scan
9640 * @ioc: per adapter object
9642 * Set the deleted flag prior to device scan. If the device is found during
9651 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9652 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9653 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9654 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9659 * _scsih_update_device_qdepth - Update QD during Reset.
9660 * @ioc: per adapter object
9673 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9674 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9675 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9676 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9677 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9678 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9679 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9681 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9682 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9683 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9685 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9686 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9695 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9696 * @ioc: per adapter object
9697 * @sas_device_pg0: SAS Device page 0
9712 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9714 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9717 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9719 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_mark_responding_sas_device()
9720 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9722 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9723 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9724 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9725 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9727 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9729 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9731 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9732 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9733 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9734 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9735 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9736 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9742 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9744 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9746 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9750 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9751 sas_device->slot); in _scsih_mark_responding_sas_device()
9753 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9755 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9756 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9757 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9758 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9760 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9761 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9764 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9765 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9766 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9768 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9769 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9770 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9772 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9773 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9774 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9778 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9779 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9782 sas_device->handle); in _scsih_mark_responding_sas_device()
9783 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9784 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9786 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9787 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9791 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9795 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9797 * @ioc: per adapter object
9821 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9830 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9831 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9833 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9838 * _scsih_search_responding_sas_devices -
9839 * @ioc: per adapter object
9853 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9855 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9874 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9878 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9879 * @ioc: per adapter object
9880 * @pcie_device_pg0: PCIe Device page 0
9894 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9895 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9896 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9897 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9898 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9899 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9900 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9901 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9902 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9903 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9904 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9905 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9906 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9912 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9913 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9914 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9919 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9920 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9923 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9925 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9926 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9927 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9928 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9929 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9931 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9932 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9935 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9936 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9939 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9940 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9941 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9943 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9944 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9950 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9954 * _scsih_search_responding_pcie_devices -
9955 * @ioc: per adapter object
9969 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9971 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
9993 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
9997 * _scsih_mark_responding_raid_device - mark a raid_device as responding
9998 * @ioc: per adapter object
10000 * @handle: device handle
10014 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10015 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10016 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10017 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10018 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10019 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10020 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10023 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10024 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10025 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10027 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10031 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10035 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10036 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10037 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10042 raid_device->handle); in _scsih_mark_responding_raid_device()
10043 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10045 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10046 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10050 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10054 * _scsih_search_responding_raid_devices -
10055 * @ioc: per adapter object
10071 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10076 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10101 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10103 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10113 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10121 * _scsih_mark_responding_expander - mark a expander as responding
10122 * @ioc: per adapter object
10136 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
10137 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10138 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10140 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10147 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10148 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10149 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10151 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10153 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10156 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10157 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10158 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10159 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10162 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10166 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10167 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10168 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10169 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10170 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10174 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10178 * _scsih_search_responding_expanders -
10179 * @ioc: per adapter object
10196 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10214 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10224 * _scsih_remove_unresponding_devices - removing unresponding devices
10225 * @ioc: per adapter object
10241 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10243 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10246 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10253 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10254 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10259 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10260 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10261 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10263 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10265 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10272 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10276 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10278 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10284 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10285 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10290 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10291 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10292 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10294 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10296 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10300 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10305 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10308 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10309 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10311 raid_device->handle); in _scsih_remove_unresponding_devices()
10313 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10319 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10322 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10323 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10324 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10326 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10328 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10348 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10356 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10359 sas_expander->port); in _scsih_refresh_expander_links()
10364 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10365 * @ioc: per adapter object
10407 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10412 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10429 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10475 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10477 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10507 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10510 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10552 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10570 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10577 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10585 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10601 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10619 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10628 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10629 * @ioc: per adapter object
10639 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10641 * @ioc: per adapter object
10650 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10651 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10652 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10653 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10655 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10656 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10657 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10658 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10661 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10662 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10663 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10669 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10670 * @ioc: per adapter object
10678 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10679 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10694 * _mpt3sas_fw_work - delayed task for processing firmware events
10695 * @ioc: per adapter object
10702 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10706 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10708 ioc->current_event = NULL; in _mpt3sas_fw_work()
10712 switch (fw_event->event) { in _mpt3sas_fw_work()
10716 fw_event->event_data); in _mpt3sas_fw_work()
10719 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10720 ioc->shost_recovery) { in _mpt3sas_fw_work()
10725 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10732 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10739 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10740 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10741 *- start the watchdog thread. in _mpt3sas_fw_work()
10745 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10750 ioc->start_scan = 0; in _mpt3sas_fw_work()
10751 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10758 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10764 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10767 fw_event->event_data); in _mpt3sas_fw_work()
10802 ioc->current_event = NULL; in _mpt3sas_fw_work()
10807 ioc->current_event = NULL; in _mpt3sas_fw_work()
10824 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10828 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10829 * @ioc: per adapter object
10834 * This function merely adds a new work task into ioc->firmware_event_thread.
10851 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10862 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10873 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10875 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10879 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10880 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10883 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10890 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10896 * sas device page0's not by processing the in mpt3sas_scsih_event_callback()
10899 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10905 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10906 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10912 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10917 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10924 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10928 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10929 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10931 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10943 …no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode.… in mpt3sas_scsih_event_callback()
10955 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10969 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10973 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10974 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10977 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10982 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
10987 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10999 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
11007 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
11008 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11009 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11010 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11011 fw_event->event = event; in mpt3sas_scsih_event_callback()
11018 * _scsih_expander_node_remove - removing expander device from list.
11019 * @ioc: per adapter object
11023 * ioc->sas_expander_list.
11035 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11036 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11038 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11041 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11042 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11043 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11045 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11048 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11049 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11052 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11054 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11055 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11059 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11060 sas_expander->sas_address, in _scsih_expander_node_remove()
11063 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11064 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11065 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11067 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11072 * _scsih_nvme_shutdown - NVMe shutdown notification
11073 * @ioc: per adapter object
11087 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11090 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11092 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11097 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11099 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11103 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11108 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11110 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11111 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11113 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11114 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11118 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11119 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11120 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11122 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11127 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11128 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11131 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11132 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11135 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11136 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11141 * _scsih_ir_shutdown - IR shutdown notification
11142 * @ioc: per adapter object
11155 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11159 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11162 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11164 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11168 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11170 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11173 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11178 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11181 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11182 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11184 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11186 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11187 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11188 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11190 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11195 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11196 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11197 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11199 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11200 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11204 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11205 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11209 * _scsih_get_shost_and_ioc - get shost and ioc
11211 * @pdev: PCI device struct
11223 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11224 return -ENXIO; in _scsih_get_shost_and_ioc()
11229 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11230 return -ENXIO; in _scsih_get_shost_and_ioc()
11237 * scsih_remove - detach and remove add host
11238 * @pdev: PCI device struct
11258 ioc->remove_host = 1; in scsih_remove()
11267 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11268 wq = ioc->firmware_event_thread; in scsih_remove()
11269 ioc->firmware_event_thread = NULL; in scsih_remove()
11270 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11277 if (ioc->is_aero_ioc) in scsih_remove()
11279 &ioc->ioc_pg1_copy); in scsih_remove()
11284 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11286 if (raid_device->starget) { in scsih_remove()
11288 raid_device->starget->hostdata; in scsih_remove()
11289 sas_target_priv_data->deleted = 1; in scsih_remove()
11290 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11293 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11296 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11299 list_del_init(&pcie_device->list); in scsih_remove()
11305 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11306 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11309 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11310 mpt3sas_port->hba_port); in scsih_remove()
11311 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11313 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11316 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11317 mpt3sas_port->hba_port); in scsih_remove()
11321 &ioc->port_table_list, list) { in scsih_remove()
11322 list_del(&port->list); in scsih_remove()
11327 if (ioc->sas_hba.num_phys) { in scsih_remove()
11328 kfree(ioc->sas_hba.phy); in scsih_remove()
11329 ioc->sas_hba.phy = NULL; in scsih_remove()
11330 ioc->sas_hba.num_phys = 0; in scsih_remove()
11336 list_del(&ioc->list); in scsih_remove()
11342 * scsih_shutdown - routine call during system shutdown
11343 * @pdev: PCI device struct
11357 ioc->remove_host = 1; in scsih_shutdown()
11366 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11367 wq = ioc->firmware_event_thread; in scsih_shutdown()
11368 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11369 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11376 if (ioc->is_aero_ioc) in scsih_shutdown()
11378 &ioc->ioc_pg1_copy); in scsih_shutdown()
11384 ioc->shost_recovery = 1; in scsih_shutdown()
11386 ioc->shost_recovery = 0; in scsih_shutdown()
11393 * _scsih_probe_boot_devices - reports 1st device
11394 * @ioc: per adapter object
11397 * device scsi-ml or sas transport for persistent boot device
11404 void *device; in _scsih_probe_boot_devices() local
11417 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11420 device = NULL; in _scsih_probe_boot_devices()
11421 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11422 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11423 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11424 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11425 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11426 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11427 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11428 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11429 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11432 if (!device) in _scsih_probe_boot_devices()
11436 raid_device = device; in _scsih_probe_boot_devices()
11439 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11442 if (raid_device->starget) in _scsih_probe_boot_devices()
11444 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11445 raid_device->id, 0); in _scsih_probe_boot_devices()
11449 pcie_device = device; in _scsih_probe_boot_devices()
11451 * If this boot NVMe device is already registered with SML then in _scsih_probe_boot_devices()
11452 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11455 if (pcie_device->starget) in _scsih_probe_boot_devices()
11457 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11458 tid = pcie_device->id; in _scsih_probe_boot_devices()
11459 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11460 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11461 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11465 sas_device = device; in _scsih_probe_boot_devices()
11467 * If this boot sas/sata device is already registered with SML in _scsih_probe_boot_devices()
11468 * then no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11471 if (sas_device->starget) in _scsih_probe_boot_devices()
11473 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11474 handle = sas_device->handle; in _scsih_probe_boot_devices()
11475 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11476 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11477 port = sas_device->port; in _scsih_probe_boot_devices()
11478 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11479 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11481 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11490 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11491 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11502 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11503 * @ioc: per adapter object
11514 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11515 if (raid_device->starget) in _scsih_probe_raid()
11517 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11518 raid_device->id, 0); in _scsih_probe_raid()
11529 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11530 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11531 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11535 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11545 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11555 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11556 list_del_init(&sas_device->list); in sas_device_make_active()
11561 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11563 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11567 * _scsih_probe_sas - reporting sas devices to sas transport
11568 * @ioc: per adapter object
11577 if (ioc->hide_drives) in _scsih_probe_sas()
11581 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11582 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11586 } else if (!sas_device->starget) { in _scsih_probe_sas()
11590 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11593 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11595 sas_device->sas_address, in _scsih_probe_sas()
11596 sas_device->sas_address_parent, in _scsih_probe_sas()
11597 sas_device->port); in _scsih_probe_sas()
11609 * get_next_pcie_device - Get the next pcie device
11610 * @ioc: per adapter object
11612 * Get the next pcie device from pcie_device_init_list list.
11614 * Return: pcie device structure if pcie_device_init_list list is not empty
11622 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11623 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11624 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11628 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11634 * pcie_device_make_active - Add pcie device to pcie_device_list list
11635 * @ioc: per adapter object
11636 * @pcie_device: pcie device object
11638 * Add the pcie device which has registered with SCSI Transport Later to
11646 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11648 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11649 list_del_init(&pcie_device->list); in pcie_device_make_active()
11653 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11655 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11659 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11660 * @ioc: per adapter object
11670 /* PCIe Device List */ in _scsih_probe_pcie()
11672 if (pcie_device->starget) { in _scsih_probe_pcie()
11676 if (pcie_device->access_status == in _scsih_probe_pcie()
11682 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11683 pcie_device->id, 0); in _scsih_probe_pcie()
11688 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11692 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11695 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11696 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11710 * _scsih_probe_devices - probing for devices
11711 * @ioc: per adapter object
11720 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11725 if (ioc->ir_firmware) { in _scsih_probe_devices()
11727 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11744 * scsih_scan_start - scsi lld callback for .scan_start
11756 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11758 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11764 ioc->start_scan = 1; in scsih_scan_start()
11772 * _scsih_complete_devices_scanning - add the devices to sml and
11774 * @ioc: per adapter object
11781 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11782 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11787 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11791 * scsih_scan_finished - scsi lld callback for .scan_finished
11807 ioc->is_driver_loading = 0; in scsih_scan_finished()
11808 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11813 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11815 ioc->is_driver_loading = 0; in scsih_scan_finished()
11819 if (ioc->start_scan) { in scsih_scan_finished()
11837 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11840 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11843 if (ioc->start_scan_failed) { in scsih_scan_finished()
11845 ioc->start_scan_failed); in scsih_scan_finished()
11846 ioc->is_driver_loading = 0; in scsih_scan_finished()
11847 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11848 ioc->remove_host = 1; in scsih_scan_finished()
11853 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11858 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11860 ioc->is_driver_loading = 0; in scsih_scan_finished()
11866 * scsih_map_queues - map reply queues with request queues
11872 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11875 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11876 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11878 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11881 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11882 map = &shost->tag_set.map[i]; in scsih_map_queues()
11883 map->nr_queues = 0; in scsih_map_queues()
11886 map->nr_queues = in scsih_map_queues()
11887 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11888 offset = ioc->high_iops_queues; in scsih_map_queues()
11890 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11892 if (!map->nr_queues) in scsih_map_queues()
11897 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11899 map->queue_offset = qoff; in scsih_map_queues()
11901 blk_mq_pci_map_queues(map, ioc->pdev, offset); in scsih_map_queues()
11905 qoff += map->nr_queues; in scsih_map_queues()
11929 .this_id = -1,
11967 .this_id = -1,
11989 * _scsih_determine_hba_mpi_version - determine in which MPI version class
11990 * this device belongs to.
11991 * @pdev: PCI device struct
12001 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12061 * _scsih_probe - attach and add scsi host
12062 * @pdev: PCI device struct
12063 * @id: pci device id
12076 /* Determine in which MPI version class this pci device belongs */ in _scsih_probe()
12079 return -ENODEV; in _scsih_probe()
12082 * for other generation HBA's return with -ENODEV in _scsih_probe()
12085 return -ENODEV; in _scsih_probe()
12088 * for other generation HBA's return with -ENODEV in _scsih_probe()
12092 return -ENODEV; in _scsih_probe()
12102 return -ENODEV; in _scsih_probe()
12105 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12106 ioc->id = mpt2_ids++; in _scsih_probe()
12107 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12108 switch (pdev->device) { in _scsih_probe()
12110 ioc->is_warpdrive = 1; in _scsih_probe()
12111 ioc->hide_ir_msg = 1; in _scsih_probe()
12115 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12118 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12122 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12123 ioc->multipath_on_hba = 0; in _scsih_probe()
12125 ioc->multipath_on_hba = 1; in _scsih_probe()
12134 return -ENODEV; in _scsih_probe()
12137 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12138 ioc->id = mpt3_ids++; in _scsih_probe()
12139 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12140 switch (pdev->device) { in _scsih_probe()
12149 ioc->is_gen35_ioc = 1; in _scsih_probe()
12153 dev_err(&pdev->dev, in _scsih_probe()
12155 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12156 pdev->subsystem_device); in _scsih_probe()
12160 dev_err(&pdev->dev, in _scsih_probe()
12162 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12163 pdev->subsystem_device); in _scsih_probe()
12167 dev_info(&pdev->dev, in _scsih_probe()
12172 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12175 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12177 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12178 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12179 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12180 ioc->combined_reply_queue = 1; in _scsih_probe()
12181 if (ioc->is_gen35_ioc) in _scsih_probe()
12182 ioc->combined_reply_index_count = in _scsih_probe()
12185 ioc->combined_reply_index_count = in _scsih_probe()
12189 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12191 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12192 ioc->multipath_on_hba = 0; in _scsih_probe()
12194 ioc->multipath_on_hba = 1; in _scsih_probe()
12197 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12198 ioc->multipath_on_hba = 1; in _scsih_probe()
12200 ioc->multipath_on_hba = 0; in _scsih_probe()
12208 return -ENODEV; in _scsih_probe()
12211 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12213 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12215 ioc->shost = shost; in _scsih_probe()
12216 ioc->pdev = pdev; in _scsih_probe()
12217 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12218 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12219 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12220 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12221 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12222 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12223 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12224 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12225 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12226 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12227 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12228 ioc->logging_level = logging_level; in _scsih_probe()
12229 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12231 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12235 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12237 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12239 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12242 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12244 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12245 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12246 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12247 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12248 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12249 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12250 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12251 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12252 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12254 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12255 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12256 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12257 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12258 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12259 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12260 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12261 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12262 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12263 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12264 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12265 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12266 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12267 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12268 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12270 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12273 shost->max_cmd_len = 32; in _scsih_probe()
12274 shost->max_lun = max_lun; in _scsih_probe()
12275 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12276 shost->unique_id = ioc->id; in _scsih_probe()
12278 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12280 shost->max_sectors = 128; in _scsih_probe()
12282 shost->max_sectors); in _scsih_probe()
12286 shost->max_sectors = 64; in _scsih_probe()
12290 shost->max_sectors = 32767; in _scsih_probe()
12294 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12296 shost->max_sectors); in _scsih_probe()
12311 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
12312 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
12313 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12314 ioc->firmware_event_name, 0); in _scsih_probe()
12315 if (!ioc->firmware_event_thread) { in _scsih_probe()
12318 rv = -ENODEV; in _scsih_probe()
12322 shost->host_tagset = 0; in _scsih_probe()
12324 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12325 shost->host_tagset = 1; in _scsih_probe()
12327 ioc->is_driver_loading = 1; in _scsih_probe()
12331 rv = -ENODEV; in _scsih_probe()
12335 if (ioc->is_warpdrive) { in _scsih_probe()
12336 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12337 ioc->hide_drives = 0; in _scsih_probe()
12338 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12339 ioc->hide_drives = 1; in _scsih_probe()
12342 ioc->hide_drives = 1; in _scsih_probe()
12344 ioc->hide_drives = 0; in _scsih_probe()
12347 ioc->hide_drives = 0; in _scsih_probe()
12349 shost->nr_hw_queues = 1; in _scsih_probe()
12351 if (shost->host_tagset) { in _scsih_probe()
12352 shost->nr_hw_queues = in _scsih_probe()
12353 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12356 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12358 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12360 dev_info(&ioc->pdev->dev, in _scsih_probe()
12362 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12365 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12378 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12381 list_del(&ioc->list); in _scsih_probe()
12388 * scsih_suspend - power management suspend main entry point
12389 * @dev: Device struct
12394 scsih_suspend(struct device *dev) in scsih_suspend()
12416 * scsih_resume - power management resume main entry point
12417 * @dev: Device struct
12422 scsih_resume(struct device *dev) in scsih_resume()
12427 pci_power_t device_state = pdev->current_state; in scsih_resume()
12437 ioc->pdev = pdev; in scsih_resume()
12449 * scsih_pci_error_detected - Called when a PCI error is detected.
12450 * @pdev: PCI device struct
12473 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12474 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12479 /* Permanent error, prepare for device removal */ in scsih_pci_error_detected()
12480 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12490 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12491 * @pdev: PCI device struct
12509 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12510 ioc->pdev = pdev; in scsih_pci_slot_reset()
12529 * scsih_pci_resume() - resume normal ops after PCI reset
12530 * @pdev: pointer to PCI device
12548 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12552 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12553 * @pdev: pointer to PCI device
12566 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12569 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still in scsih_pci_mmio_enabled()
12576 * scsih_ncq_prio_supp - Check for NCQ command priority support
12577 * @sdev: scsi device struct
12588 vpd = rcu_dereference(sdev->vpd_pg89); in scsih_ncq_prio_supp()
12589 if (!vpd || vpd->len < 214) in scsih_ncq_prio_supp()
12592 ncq_prio_supp = (vpd->data[213] >> 4) & 1; in scsih_ncq_prio_supp()
12599 * The pci device ids are defined in mpi/mpi2_cnfg.h.
12766 * scsih_init - main entry point for this driver.
12817 * scsih_exit - exit point for this driver (when it is a module).
12848 * _mpt3sas_init - main entry point for this driver.
12863 return -ENODEV; in _mpt3sas_init()
12873 return -ENODEV; in _mpt3sas_init()
12885 return -ENODEV; in _mpt3sas_init()
12907 * _mpt3sas_exit - exit point for this driver (when it is a module).