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,
93 static u8 scsi_io_cb_idx = -1;
94 static u8 tm_cb_idx = -1;
95 static u8 ctl_cb_idx = -1;
96 static u8 base_cb_idx = -1;
97 static u8 port_enable_cb_idx = -1;
98 static u8 transport_cb_idx = -1;
99 static u8 scsih_cb_idx = -1;
100 static u8 config_cb_idx = -1;
104 static u8 tm_tr_cb_idx = -1 ;
105 static u8 tm_tr_volume_cb_idx = -1 ;
106 static u8 tm_sas_control_cb_idx = -1;
119 static int missing_delay[2] = {-1, -1};
121 MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
123 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
132 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
133 1 - enumerates only SAS 2.0 generation HBAs\n \
134 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
143 static int diag_buffer_enable = -1;
147 static int disable_discovery = -1;
153 static int prot_mask = -1;
162 static int multipath_on_hba = -1;
165 "Multipath support to add same target device\n\t\t"
168 "\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
169 "\t SAS 3.5 HBA - This will be enabled)");
182 * struct sense_info - common structure for obtaining sense keys
199 * struct fw_event_work - firmware event struct
201 * @work: work object (ioc->fault_reset_work_q)
202 * @ioc: per adapter object
203 * @device_handle: device handle
211 * This object stored on ioc->fw_event_list.
234 kref_get(&fw_work->refcount); in fw_event_work_get()
239 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
250 kref_init(&fw_event->refcount); in alloc_fw_event_work()
255 * struct _scsi_io_transfer - scsi io transfer
256 * @handle: sas device handle (assigned by firmware)
303 * _scsih_set_debug_level - global setting of ioc->logging_level.
321 ioc->logging_level = logging_level; in _scsih_set_debug_level()
329 * _scsih_srch_boot_sas_address - search based on sas_address
331 * @boot_device: boot device object from bios page 2
339 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
343 * _scsih_srch_boot_device_name - search based on device name
344 * @device_name: device name specified in INDENTIFY fram
345 * @boot_device: boot device object from bios page 2
353 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
357 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
360 * @boot_device: boot device object from bios page 2
368 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
369 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
374 * mpt3sas_get_port_by_id - get hba port entry corresponding to provided
376 * @ioc: per adapter object
395 if (!ioc->multipath_on_hba) in mpt3sas_get_port_by_id()
399 &ioc->port_table_list, list) { in mpt3sas_get_port_by_id()
400 if (port->port_id != port_id) in mpt3sas_get_port_by_id()
404 if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) in mpt3sas_get_port_by_id()
414 if (!ioc->multipath_on_hba) { in mpt3sas_get_port_by_id()
419 port->port_id = port_id; in mpt3sas_get_port_by_id()
422 port, port->port_id); in mpt3sas_get_port_by_id()
423 list_add_tail(&port->list, in mpt3sas_get_port_by_id()
424 &ioc->port_table_list); in mpt3sas_get_port_by_id()
431 * mpt3sas_get_vphy_by_phy - get virtual_phy object corresponding to phy number
432 * @ioc: per adapter object
444 if (!port->vphys_mask) in mpt3sas_get_vphy_by_phy()
447 list_for_each_entry_safe(vphy, vphy_next, &port->vphys_list, list) { in mpt3sas_get_vphy_by_phy()
448 if (vphy->phy_mask & (1 << phy)) in mpt3sas_get_vphy_by_phy()
455 * _scsih_is_boot_device - search for matching boot device.
457 * @device_name: device name specified in INDENTIFY fram
460 * @form: specifies boot device form
461 * @boot_device: boot device object from bios page 2
477 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
484 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
490 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
500 * _scsih_get_sas_address - set the sas_address for given device handle
502 * @handle: device handle
505 * Return: 0 success, non-zero when failure
521 return -ENXIO; in _scsih_get_sas_address()
529 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
532 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
540 return -ENXIO; in _scsih_get_sas_address()
545 return -EIO; in _scsih_get_sas_address()
549 * _scsih_determine_boot_device - determine boot device.
550 * @ioc: per adapter object
551 * @device: sas_device or pcie_device object
554 * Determines whether this device should be first reported device to
555 * to scsi-ml or sas transport, this purpose is for persistent boot device.
558 * the corresponding device object.
562 _scsih_determine_boot_device(struct MPT3SAS_ADAPTER *ioc, void *device, in _scsih_determine_boot_device() argument
574 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
578 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
582 raid_device = device; in _scsih_determine_boot_device()
583 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
588 pcie_device = device; in _scsih_determine_boot_device()
589 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
594 sas_device = device; in _scsih_determine_boot_device()
595 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
596 device_name = sas_device->device_name; in _scsih_determine_boot_device()
597 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
598 slot = sas_device->slot; in _scsih_determine_boot_device()
601 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
604 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
606 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
610 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
611 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
615 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
618 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
620 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
624 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
625 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
629 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
632 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
634 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
638 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
639 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
650 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
652 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
666 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
668 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
679 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
681 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
689 * mpt3sas_get_pdev_from_target - pcie device search
690 * @ioc: per adapter object
693 * Context: This function will acquire ioc->pcie_device_lock and will release
705 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
707 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
714 * __mpt3sas_get_sdev_by_rphy - sas device search
715 * @ioc: per adapter object
718 * Context: This function will acquire ioc->sas_device_lock and will release
730 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_rphy()
732 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_rphy()
733 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
740 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_rphy()
741 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
751 * __mpt3sas_get_sdev_by_addr - get _sas_device object corresponding to provided
753 * @ioc: per adapter object
754 * @sas_address: device sas address
769 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
771 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_addr()
772 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
774 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
780 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_addr()
781 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
783 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
793 * mpt3sas_get_sdev_by_addr - sas device search
794 * @ioc: per adapter object
797 * Context: Calling function should acquire ioc->sas_device_lock
809 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
812 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
822 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
824 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
825 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
828 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
829 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
840 * mpt3sas_get_sdev_by_handle - sas device search
841 * @ioc: per adapter object
842 * @handle: sas device handle (assigned by firmware)
843 * Context: Calling function should acquire ioc->sas_device_lock
854 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
856 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
862 * _scsih_display_enclosure_chassis_info - display device location info
863 * @ioc: per adapter object
864 * @sas_device: per sas device object
865 * @sdev: scsi device struct
874 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
878 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
879 sas_device->slot); in _scsih_display_enclosure_chassis_info()
880 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
883 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
884 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
885 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
887 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
889 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
893 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
894 sas_device->slot); in _scsih_display_enclosure_chassis_info()
895 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
898 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
899 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
900 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
903 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
905 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
907 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
908 sas_device->slot); in _scsih_display_enclosure_chassis_info()
909 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
911 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
912 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
913 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
915 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
920 * _scsih_sas_device_remove - remove sas_device from list.
921 * @ioc: per adapter object
923 * Context: This function will acquire ioc->sas_device_lock.
936 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
944 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
945 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
946 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
949 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
953 * _scsih_device_remove_by_handle - removing device object by handle
954 * @ioc: per adapter object
955 * @handle: device handle
963 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
966 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
969 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
972 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
980 * mpt3sas_device_remove_by_sas_address - removing device object by
982 * @ioc: per adapter object
983 * @sas_address: device sas_address
995 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
998 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1001 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
1004 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1012 * _scsih_sas_device_add - insert sas_device to the list.
1013 * @ioc: per adapter object
1015 * Context: This function will acquire ioc->sas_device_lock.
1017 * Adding new object to the ioc->sas_device_list.
1027 __func__, sas_device->handle, in _scsih_sas_device_add()
1028 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
1033 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1035 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
1036 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1038 if (ioc->hide_drives) { in _scsih_sas_device_add()
1039 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1043 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
1044 sas_device->sas_address_parent, sas_device->port)) { in _scsih_sas_device_add()
1046 } else if (!sas_device->starget) { in _scsih_sas_device_add()
1050 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
1052 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
1054 sas_device->sas_address, in _scsih_sas_device_add()
1055 sas_device->sas_address_parent, in _scsih_sas_device_add()
1056 sas_device->port); in _scsih_sas_device_add()
1060 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1064 * _scsih_sas_device_init_add - insert sas_device to the list.
1065 * @ioc: per adapter object
1067 * Context: This function will acquire ioc->sas_device_lock.
1069 * Adding new object at driver load time to the ioc->sas_device_init_list.
1079 __func__, sas_device->handle, in _scsih_sas_device_init_add()
1080 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
1085 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1087 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
1089 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1098 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
1100 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
1101 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1104 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
1105 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1117 * mpt3sas_get_pdev_by_wwid - pcie device search
1118 * @ioc: per adapter object
1121 * Context: This function will acquire ioc->pcie_device_lock and will release
1132 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1134 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1146 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
1148 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
1149 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1152 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
1153 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1168 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1170 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1171 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1174 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1175 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1187 * mpt3sas_get_pdev_by_handle - pcie device search
1188 * @ioc: per adapter object
1189 * @handle: Firmware device handle
1191 * Context: This function will acquire ioc->pcie_device_lock and will release
1203 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1205 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1211 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1212 * @ioc: per adapter object
1213 * Context: This function will acquire ioc->pcie_device_lock
1215 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1226 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1227 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1228 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1229 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1231 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1234 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1235 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1239 * _scsih_pcie_device_remove - remove pcie_device from list.
1240 * @ioc: per adapter object
1242 * Context: This function will acquire ioc->pcie_device_lock.
1257 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1258 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1260 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1261 pcie_device->slot); in _scsih_pcie_device_remove()
1262 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1264 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1265 pcie_device->connector_name); in _scsih_pcie_device_remove()
1267 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1268 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1269 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1272 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1274 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1276 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1281 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove()
1291 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1292 * @ioc: per adapter object
1293 * @handle: device handle
1303 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1306 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1309 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1310 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1314 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1317 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1324 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove_by_handle()
1333 * _scsih_pcie_device_add - add pcie_device object
1334 * @ioc: per adapter object
1348 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1349 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1353 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1354 pcie_device->slot)); in _scsih_pcie_device_add()
1355 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1358 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1359 pcie_device->connector_name)); in _scsih_pcie_device_add()
1361 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1363 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1364 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1366 if (pcie_device->access_status == in _scsih_pcie_device_add()
1368 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1371 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1373 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1374 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1375 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1376 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1379 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1383 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1384 * @ioc: per adapter object
1386 * Context: This function will acquire ioc->pcie_device_lock.
1388 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1399 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1400 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1404 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1405 pcie_device->slot)); in _scsih_pcie_device_init_add()
1406 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1409 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1410 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1412 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1414 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1415 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1418 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1421 * _scsih_raid_device_find_by_id - raid device search
1422 * @ioc: per adapter object
1423 * @id: sas device target id
1424 * @channel: sas device channel
1425 * Context: Calling function should acquire ioc->raid_device_lock
1436 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1437 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1448 * mpt3sas_raid_device_find_by_handle - raid device search
1449 * @ioc: per adapter object
1450 * @handle: sas device handle (assigned by firmware)
1451 * Context: Calling function should acquire ioc->raid_device_lock
1462 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1463 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1474 * _scsih_raid_device_find_by_wwid - raid device search
1475 * @ioc: per adapter object
1477 * Context: Calling function should acquire ioc->raid_device_lock
1488 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1489 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1500 * _scsih_raid_device_add - add raid_device object
1501 * @ioc: per adapter object
1515 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1517 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1518 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1519 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1523 * _scsih_raid_device_remove - delete raid_device object
1524 * @ioc: per adapter object
1534 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1535 list_del(&raid_device->list); in _scsih_raid_device_remove()
1537 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1541 * mpt3sas_scsih_expander_find_by_handle - expander device search
1542 * @ioc: per adapter object
1544 * Context: Calling function should acquire ioc->sas_device_lock
1546 * This searches for expander device based on handle, then returns the
1555 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1556 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1566 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1567 * @ioc: per adapter object
1569 * Context: Calling function should acquire ioc->sas_device_lock
1571 * This searches for enclosure device based on handle, then returns the
1580 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1581 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1590 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1591 * @ioc: per adapter object
1594 * Context: Calling function should acquire ioc->sas_node_lock.
1596 * This searches for expander device based on sas_address & port number,
1608 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1609 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1611 if (sas_expander->port != port) in mpt3sas_scsih_expander_find_by_sas_address()
1621 * _scsih_expander_node_add - insert expander device to the list.
1622 * @ioc: per adapter object
1624 * Context: This function will acquire ioc->sas_node_lock.
1626 * Adding new object to the ioc->sas_expander_list.
1634 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1635 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1636 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1640 * _scsih_is_end_device - determines if device is an end device
1641 * @device_info: bitfield providing information about the device.
1644 * Return: 1 if end device.
1659 * _scsih_is_nvme_pciescsi_device - determines if
1660 * device is an pcie nvme/scsi device
1661 * @device_info: bitfield providing information about the device.
1664 * Returns 1 if device is pcie device type nvme/scsi.
1679 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1680 * @ioc: per adapter object
1683 * Context: This function will acquire ioc->scsi_lookup_lock.
1696 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1700 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1701 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1708 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1709 * @ioc: per adapter object
1713 * Context: This function will acquire ioc->scsi_lookup_lock.
1725 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1730 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1731 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1732 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1739 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1740 * @ioc: per adapter object
1752 u16 tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1755 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1757 ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag; in mpt3sas_scsih_scsi_lookup_get()
1763 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1767 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1770 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1773 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1781 * scsih_change_queue_depth - setting device queue depth
1782 * @sdev: scsi device struct
1790 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1798 max_depth = shost->can_queue; in scsih_change_queue_depth()
1801 * limit max device queue for SATA to 32 if enable_sdev_max_qd in scsih_change_queue_depth()
1804 if (ioc->enable_sdev_max_qd || ioc->is_gen35_ioc) in scsih_change_queue_depth()
1807 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1810 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1813 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1816 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1819 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1824 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1828 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1835 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1836 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1837 return sdev->queue_depth; in scsih_change_queue_depth()
1841 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1842 * @sdev: scsi device struct
1850 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1853 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1854 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1860 * scsih_target_alloc - target add routine
1864 * the device is ignored.
1869 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1881 return -ENOMEM; in scsih_target_alloc()
1883 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1884 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1885 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1888 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1889 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1890 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1891 starget->channel); in scsih_target_alloc()
1893 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1894 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1895 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1896 if (ioc->is_warpdrive) in scsih_target_alloc()
1897 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1898 raid_device->starget = starget; in scsih_target_alloc()
1900 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1905 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1906 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1907 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1908 starget->channel); in scsih_target_alloc()
1910 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1911 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1912 sas_target_priv_data->port = NULL; in scsih_target_alloc()
1913 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1914 pcie_device->starget = starget; in scsih_target_alloc()
1915 pcie_device->id = starget->id; in scsih_target_alloc()
1916 pcie_device->channel = starget->channel; in scsih_target_alloc()
1917 sas_target_priv_data->flags |= in scsih_target_alloc()
1919 if (pcie_device->fast_path) in scsih_target_alloc()
1920 sas_target_priv_data->flags |= in scsih_target_alloc()
1923 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1928 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1929 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1933 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1934 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1935 sas_target_priv_data->port = sas_device->port; in scsih_target_alloc()
1936 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1937 sas_device->starget = starget; in scsih_target_alloc()
1938 sas_device->id = starget->id; in scsih_target_alloc()
1939 sas_device->channel = starget->channel; in scsih_target_alloc()
1940 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1941 sas_target_priv_data->flags |= in scsih_target_alloc()
1943 if (sas_device->fast_path) in scsih_target_alloc()
1944 sas_target_priv_data->flags |= in scsih_target_alloc()
1947 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1953 * scsih_target_destroy - target destroy routine
1959 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1967 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1971 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1972 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1973 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1974 starget->channel); in scsih_target_destroy()
1976 raid_device->starget = NULL; in scsih_target_destroy()
1977 raid_device->sdev = NULL; in scsih_target_destroy()
1979 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1983 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1984 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1987 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1988 (pcie_device->id == starget->id) && in scsih_target_destroy()
1989 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1990 pcie_device->starget = NULL; in scsih_target_destroy()
1996 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
2000 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
2004 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2006 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
2007 (sas_device->id == starget->id) && in scsih_target_destroy()
2008 (sas_device->channel == starget->channel)) in scsih_target_destroy()
2009 sas_device->starget = NULL; in scsih_target_destroy()
2015 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
2020 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2024 starget->hostdata = NULL; in scsih_target_destroy()
2028 * scsih_sdev_init - device add routine
2029 * @sdev: scsi device struct
2032 * the device is ignored.
2050 return -ENOMEM; in scsih_sdev_init()
2052 sas_device_priv_data->lun = sdev->lun; in scsih_sdev_init()
2053 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_sdev_init()
2056 sas_target_priv_data = starget->hostdata; in scsih_sdev_init()
2057 sas_target_priv_data->num_luns++; in scsih_sdev_init()
2058 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_sdev_init()
2059 sdev->hostdata = sas_device_priv_data; in scsih_sdev_init()
2060 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_sdev_init()
2061 sdev->no_uld_attach = 1; in scsih_sdev_init()
2063 shost = dev_to_shost(&starget->dev); in scsih_sdev_init()
2065 if (starget->channel == RAID_CHANNEL) { in scsih_sdev_init()
2066 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_sdev_init()
2068 starget->id, starget->channel); in scsih_sdev_init()
2070 raid_device->sdev = sdev; /* raid is single lun */ in scsih_sdev_init()
2071 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_sdev_init()
2073 if (starget->channel == PCIE_CHANNEL) { in scsih_sdev_init()
2074 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_init()
2076 sas_target_priv_data->sas_address); in scsih_sdev_init()
2077 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_sdev_init()
2079 "%s : pcie_device->starget set to starget @ %d\n", in scsih_sdev_init()
2081 pcie_device->starget = starget; in scsih_sdev_init()
2086 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_init()
2088 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_sdev_init()
2089 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_init()
2091 sas_target_priv_data->sas_address, in scsih_sdev_init()
2092 sas_target_priv_data->port); in scsih_sdev_init()
2093 if (sas_device && (sas_device->starget == NULL)) { in scsih_sdev_init()
2095 "%s : sas_device->starget set to starget @ %d\n", in scsih_sdev_init()
2097 sas_device->starget = starget; in scsih_sdev_init()
2103 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_init()
2110 * scsih_sdev_destroy - device destroy routine
2111 * @sdev: scsi device struct
2124 if (!sdev->hostdata) in scsih_sdev_destroy()
2128 sas_target_priv_data = starget->hostdata; in scsih_sdev_destroy()
2129 sas_target_priv_data->num_luns--; in scsih_sdev_destroy()
2131 shost = dev_to_shost(&starget->dev); in scsih_sdev_destroy()
2134 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_sdev_destroy()
2135 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_destroy()
2138 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_sdev_destroy()
2139 pcie_device->starget = NULL; in scsih_sdev_destroy()
2144 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_destroy()
2146 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_sdev_destroy()
2147 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_destroy()
2150 if (sas_device && !sas_target_priv_data->num_luns) in scsih_sdev_destroy()
2151 sas_device->starget = NULL; in scsih_sdev_destroy()
2155 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_destroy()
2158 kfree(sdev->hostdata); in scsih_sdev_destroy()
2159 sdev->hostdata = NULL; in scsih_sdev_destroy()
2163 * _scsih_display_sata_capabilities - sata capabilities
2164 * @ioc: per adapter object
2165 * @handle: device handle
2166 * @sdev: scsi device struct
2209 * raid transport support -
2211 * unloading the driver followed by a load - I believe that the subroutine
2216 * scsih_is_raid - return boolean indicating device is raid volume
2217 * @dev: the device struct object
2220 scsih_is_raid(struct device *dev) in scsih_is_raid()
2223 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2225 if (ioc->is_warpdrive) in scsih_is_raid()
2227 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2231 scsih_is_nvme(struct device *dev) in scsih_is_nvme()
2235 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2239 * scsih_get_resync - get raid volume resync percent complete
2240 * @dev: the device struct object
2243 scsih_get_resync(struct device *dev) in scsih_get_resync()
2246 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2257 if (ioc->is_warpdrive) in scsih_get_resync()
2260 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2261 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2262 sdev->channel); in scsih_get_resync()
2264 handle = raid_device->handle; in scsih_get_resync()
2265 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2267 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2288 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2300 * scsih_get_state - get raid volume level
2301 * @dev: the device struct object
2304 scsih_get_state(struct device *dev) in scsih_get_state()
2307 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2316 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2317 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2318 sdev->channel); in scsih_get_state()
2320 handle = raid_device->handle; in scsih_get_state()
2321 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2354 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2366 * _scsih_set_level - set raid level
2368 * @sdev: scsi device struct
2392 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2395 &sdev->sdev_gendev, level); in _scsih_set_level()
2400 &sdev->sdev_gendev, level); in _scsih_set_level()
2407 * _scsih_get_volume_capabilities - volume capabilities
2408 * @ioc: per adapter object
2424 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2432 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2443 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2451 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2454 * obtaining the device_info bits for the 1st device in _scsih_get_volume_capabilities()
2458 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2462 raid_device->device_info = in _scsih_get_volume_capabilities()
2472 * _scsih_enable_tlr - setting TLR flags
2473 * @ioc: per adapter object
2474 * @sdev: scsi device struct
2485 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2488 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2499 * scsih_sdev_configure - device configure routine.
2500 * @sdev: scsi device struct
2504 * the device is ignored.
2509 struct Scsi_Host *shost = sdev->host; in scsih_sdev_configure()
2525 sas_device_priv_data = sdev->hostdata; in scsih_sdev_configure()
2526 sas_device_priv_data->configured_lun = 1; in scsih_sdev_configure()
2527 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_sdev_configure()
2528 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_sdev_configure()
2529 handle = sas_target_priv_data->handle; in scsih_sdev_configure()
2532 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_sdev_configure()
2534 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_sdev_configure()
2536 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_sdev_configure()
2561 if (raid_device->device_info & in scsih_sdev_configure()
2567 if (raid_device->device_info & in scsih_sdev_configure()
2574 switch (raid_device->volume_type) { in scsih_sdev_configure()
2580 if (ioc->manu_pg10.OEMIdentifier && in scsih_sdev_configure()
2581 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_sdev_configure()
2583 !(raid_device->num_pds % 2)) in scsih_sdev_configure()
2603 if (!ioc->hide_ir_msg) in scsih_sdev_configure()
2607 r_level, raid_device->handle, in scsih_sdev_configure()
2608 (unsigned long long)raid_device->wwid, in scsih_sdev_configure()
2609 raid_device->num_pds, ds); in scsih_sdev_configure()
2611 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_sdev_configure()
2612 lim->max_hw_sectors = MPT3SAS_RAID_MAX_SECTORS; in scsih_sdev_configure()
2621 if (!ioc->is_warpdrive) in scsih_sdev_configure()
2622 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_sdev_configure()
2626 /* non-raid handling */ in scsih_sdev_configure()
2627 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_sdev_configure()
2645 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_sdev_configure()
2646 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2648 sas_device_priv_data->sas_target->sas_address); in scsih_sdev_configure()
2650 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2657 qdepth = ioc->max_nvme_qd; in scsih_sdev_configure()
2661 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_sdev_configure()
2662 pcie_device->port_num); in scsih_sdev_configure()
2663 if (pcie_device->enclosure_handle != 0) in scsih_sdev_configure()
2667 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_sdev_configure()
2668 pcie_device->slot); in scsih_sdev_configure()
2669 if (pcie_device->connector_name[0] != '\0') in scsih_sdev_configure()
2673 pcie_device->enclosure_level, in scsih_sdev_configure()
2674 pcie_device->connector_name); in scsih_sdev_configure()
2676 if (pcie_device->nvme_mdts) in scsih_sdev_configure()
2677 lim->max_hw_sectors = pcie_device->nvme_mdts / 512; in scsih_sdev_configure()
2680 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_sdev_configure()
2682 lim->virt_boundary_mask = ioc->page_size - 1; in scsih_sdev_configure()
2686 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2688 sas_device_priv_data->sas_target->sas_address, in scsih_sdev_configure()
2689 sas_device_priv_data->sas_target->port); in scsih_sdev_configure()
2691 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2698 sas_device->volume_handle = volume_handle; in scsih_sdev_configure()
2699 sas_device->volume_wwid = volume_wwid; in scsih_sdev_configure()
2700 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_sdev_configure()
2701 qdepth = (sas_device->port_type > 1) ? in scsih_sdev_configure()
2702 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_sdev_configure()
2704 if (sas_device->device_info & in scsih_sdev_configure()
2708 sas_device_priv_data->sas_target->handle); in scsih_sdev_configure()
2709 sas_device_priv_data->ignore_delay_remove = 1; in scsih_sdev_configure()
2714 qdepth = ioc->max_sata_qd; in scsih_sdev_configure()
2715 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_sdev_configure()
2717 else if (sas_device->device_info & in scsih_sdev_configure()
2724 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_sdev_configure()
2725 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_sdev_configure()
2730 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_sdev_configure()
2747 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2748 * @sdev: scsi device struct
2749 * @bdev: pointer to block device context
2750 * @capacity: device size (in 512 byte sectors)
2793 * _scsih_response_code - translation of device response code
2794 * @ioc: per adapter object
2795 * @response_code: response code returned by the device
2835 * _scsih_tm_done - tm completion routine
2836 * @ioc: per adapter object
2852 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2854 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2856 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2859 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2860 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2862 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2863 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2868 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2869 * @ioc: per adapter object
2870 * @handle: device handle
2872 * During taskmangement request, we need to freeze the device queue.
2881 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2884 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2887 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2888 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2890 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2896 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2897 * @ioc: per adapter object
2898 * @handle: device handle
2900 * During taskmangement request, we need to freeze the device queue.
2909 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2912 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2915 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2916 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2918 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2924 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2925 * @ioc: per adapter object
2940 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2956 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2957 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2958 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2960 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2961 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2962 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2970 * scsih_tm_post_processing - post processing of target & LUN reset
2971 * @ioc: per adapter object
2972 * @handle: device handle
3014 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3015 * @ioc: per adapter struct
3016 * @handle: device handle
3029 * The callback index is set inside `ioc->tm_cb_idx`.
3047 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3049 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3054 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3055 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3080 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3089 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3091 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3093 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3094 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3095 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3096 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3099 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3100 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3101 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3103 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3104 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3105 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3106 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3108 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3121 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3123 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3126 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3127 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3128 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3129 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3130 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3131 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3142 * doesn't match with device handle on which this task abort in mpt3sas_scsih_issue_tm()
3152 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3177 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3187 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3190 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3196 * _scsih_tm_display_info - displays info about the device
3197 * @ioc: per adapter struct
3205 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3206 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3214 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3220 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3223 device_str, priv_target->handle, in _scsih_tm_display_info()
3224 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3226 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3227 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3232 pcie_device->handle, in _scsih_tm_display_info()
3233 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3234 pcie_device->port_num); in _scsih_tm_display_info()
3235 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3239 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3240 pcie_device->slot); in _scsih_tm_display_info()
3241 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3244 pcie_device->enclosure_level, in _scsih_tm_display_info()
3245 pcie_device->connector_name); in _scsih_tm_display_info()
3248 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3251 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3254 if (priv_target->flags & in _scsih_tm_display_info()
3259 sas_device->volume_handle, in _scsih_tm_display_info()
3260 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3264 sas_device->handle, in _scsih_tm_display_info()
3265 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3266 sas_device->phy); in _scsih_tm_display_info()
3273 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3278 * scsih_abort - eh threads main abort routine
3286 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3294 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3296 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3297 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3300 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3301 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3302 ioc->remove_host) { in scsih_abort()
3303 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3304 "device been deleted! scmd(0x%p)\n", scmd); in scsih_abort()
3305 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3312 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3313 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3315 scmd->result = DID_RESET << 16; in scsih_abort()
3321 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3323 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3324 scmd->result = DID_RESET << 16; in scsih_abort()
3331 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3333 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3334 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3335 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3336 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3337 scmd->device->id, scmd->device->lun, in scsih_abort()
3339 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3341 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3344 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3352 * scsih_dev_reset - eh threads main device reset routine
3360 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3369 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3370 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3372 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3373 "attempting device reset! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3376 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3377 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3378 ioc->remove_host) { in scsih_dev_reset()
3379 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3380 "device been deleted! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3381 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3389 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3394 handle = sas_device->volume_handle; in scsih_dev_reset()
3396 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3399 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3406 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3407 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3408 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3413 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3414 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3418 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3421 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3433 * scsih_target_reset - eh threads main target reset routine
3441 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3449 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3450 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3456 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3457 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3458 ioc->remove_host) { in scsih_target_reset()
3461 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3469 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3474 handle = sas_device->volume_handle; in scsih_target_reset()
3476 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3479 scmd->result = DID_RESET << 16; in scsih_target_reset()
3486 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3487 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3488 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3492 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3493 scmd->device->id, 0, in scsih_target_reset()
3497 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3512 * scsih_host_reset - eh threads main host reset routine
3520 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3526 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3542 * _scsih_fw_event_add - insert and queue up fw_event
3543 * @ioc: per adapter object
3545 * Context: This function will acquire ioc->fw_event_lock.
3555 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3558 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3560 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3561 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3562 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3564 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3565 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3569 * _scsih_fw_event_del_from_list - delete fw_event from the list
3570 * @ioc: per adapter object
3572 * Context: This function will acquire ioc->fw_event_lock.
3582 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3583 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3584 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3587 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3592 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3593 * @ioc: per adapter object
3603 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3609 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3610 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3611 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3617 * _scsih_error_recovery_delete_devices - remove devices not responding
3618 * @ioc: per adapter object
3628 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3629 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3635 * mpt3sas_port_enable_complete - port enable completed (fake event)
3636 * @ioc: per adapter object
3646 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3647 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3657 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3658 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3659 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3661 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3664 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3670 * _scsih_fw_event_cleanup_queue - cleanup event queue
3671 * @ioc: per adapter object
3683 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3684 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3692 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3693 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3695 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3697 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3713 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3714 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3716 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3721 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3728 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3729 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3730 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3741 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3745 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3749 * _scsih_internal_device_block - block the sdev device
3750 * @sdev: per device object
3751 * @sas_device_priv_data : per device driver private data
3753 * make sure device is blocked without error, if not
3763 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3764 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3767 if (r == -EINVAL) in _scsih_internal_device_block()
3770 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3774 * _scsih_internal_device_unblock - unblock the sdev device
3775 * @sdev: per device object
3776 * @sas_device_priv_data : per device driver private data
3777 * make sure device is unblocked without error, if not retry
3788 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3789 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3791 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3792 /* The device has been set to SDEV_RUNNING by SD layer during in _scsih_internal_device_unblock()
3793 * device addition but the request queue is still stopped by in _scsih_internal_device_unblock()
3795 * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */ in _scsih_internal_device_unblock()
3800 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3801 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3806 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3808 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3813 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3818 * _scsih_ublock_io_all_device - unblock every device
3819 * @ioc: per adapter object
3821 * change the device state from block to running
3829 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3830 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3833 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3838 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3845 * _scsih_ublock_io_device - prepare device to be deleted
3846 * @ioc: per adapter object
3850 * unblock then put device in offline state
3859 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3860 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3861 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3863 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3866 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3868 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3875 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3876 * @ioc: per adapter object
3878 * During device pull we need to appropriately set the sdev state.
3886 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3887 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3890 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3892 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3895 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3903 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3904 * @ioc: per adapter object
3905 * @handle: device handle
3907 * During device pull we need to appropriately set the sdev state.
3918 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3919 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3922 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3924 if (sas_device_priv_data->block) in _scsih_block_io_device()
3926 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3928 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3931 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3943 * @ioc: per adapter object
3963 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3964 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3966 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3968 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3969 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3971 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3972 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3975 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3980 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3982 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3984 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3988 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3989 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3998 * @ioc: per adapter object
4002 * direct attached during device pull.
4012 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4013 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4016 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4025 * @ioc: per adapter object
4029 * direct attached during device pull/reconnect.
4039 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4041 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4044 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4051 * _scsih_tm_tr_send - send task management request
4052 * @ioc: per adapter object
4053 * @handle: device handle
4056 * This code is to initiate the device removal handshake protocol
4080 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4095 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4098 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4100 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4102 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4103 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4104 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4105 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4106 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4107 port = sas_device->port; in _scsih_tm_tr_send()
4109 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4111 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4113 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4114 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4115 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4116 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4117 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4119 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4120 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4122 pcie_device->device_info)))) in _scsih_tm_tr_send()
4133 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4136 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4137 sas_device->slot)); in _scsih_tm_tr_send()
4138 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4141 sas_device->enclosure_level, in _scsih_tm_tr_send()
4142 sas_device->connector_name)); in _scsih_tm_tr_send()
4144 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4147 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4148 pcie_device->slot)); in _scsih_tm_tr_send()
4149 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4152 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4153 pcie_device->connector_name)); in _scsih_tm_tr_send()
4156 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4159 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4164 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4165 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4166 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4175 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4178 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4179 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4180 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4181 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4182 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4183 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4194 * _scsih_tm_tr_complete -
4195 * @ioc: per adapter object
4202 * This code is part of the code to initiate the device removal
4222 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4241 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4242 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4246 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4253 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4254 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4255 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4257 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4262 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4263 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4264 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4273 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4276 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4277 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4278 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4279 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4284 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4286 * @ioc: per adapter object
4295 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4298 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4299 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4305 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4307 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4320 * _scsih_sas_control_complete - completion routine
4321 * @ioc: per adapter object
4328 * This code is part of the code to initiate the device removal
4344 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4345 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4346 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4347 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4349 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4350 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4360 * _scsih_tm_tr_volume_send - send target reset request for volumes
4361 * @ioc: per adapter object
4362 * @handle: device handle
4376 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4383 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4388 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4389 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4390 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4399 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4402 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4403 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4404 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4405 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4409 * _scsih_tm_volume_tr_complete - target reset completion
4410 * @ioc: per adapter object
4428 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4441 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4442 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4445 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4452 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4453 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4454 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4460 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4461 * @ioc: per adapter object
4466 * Context - processed in interrupt context.
4473 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4480 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4481 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4482 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4486 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4489 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4490 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4491 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4492 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4493 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4494 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4498 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4500 * @ioc: per adapter object
4502 * @handle: device handle
4504 * Context - processed in interrupt context.
4512 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4515 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4520 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4538 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4539 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4540 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4544 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4547 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4548 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4549 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4550 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4554 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4555 * @ioc: per adapter object
4572 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4573 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4576 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4577 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4582 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4583 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4586 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4587 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4595 * _scsih_check_for_pending_tm - check for pending task management
4596 * @ioc: per adapter object
4610 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4611 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4614 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4615 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4620 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4621 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4624 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4625 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4634 * _scsih_check_topo_delete_events - sanity check on topo events
4635 * @ioc: per adapter object
4656 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4657 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4660 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4666 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4667 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4671 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4674 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4678 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4680 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4681 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4682 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4684 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4685 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4688 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4692 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4693 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4694 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4695 fw_event->ignore) in _scsih_check_topo_delete_events()
4698 fw_event->event_data; in _scsih_check_topo_delete_events()
4699 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4701 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4703 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4707 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4711 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4715 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4717 * @ioc: per adapter object
4721 * or device add and delete events in a single shot. When there
4735 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4737 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4740 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4745 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4752 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4754 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4759 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4763 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4764 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4765 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4766 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4770 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4771 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4773 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4775 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4779 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4783 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4787 * _scsih_set_volume_delete_flag - setting volume delete flag
4788 * @ioc: per adapter object
4789 * @handle: device handle
4800 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4802 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4803 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4805 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4806 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4809 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4811 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4815 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4822 * input handle is non-zero, or when a and b have not been set before.
4836 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4837 * @ioc: per adapter object
4859 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4863 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4864 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4865 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4868 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4870 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4872 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4879 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4880 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4881 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4884 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4885 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4896 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4897 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4898 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4900 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4901 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4902 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4908 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4909 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4910 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4921 * _scsih_check_volume_delete_events - set delete flag for volumes
4922 * @ioc: per adapter object
4936 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4938 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4942 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4946 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4947 * @ioc: per adapter object
4956 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4958 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4959 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4960 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4961 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4962 event_data->SensorNum); in _scsih_temp_threshold_events()
4964 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4965 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4982 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4984 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4988 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4990 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4995 * _scsih_flush_running_cmds - completing outstanding commands.
4996 * @ioc: per adapter object
5009 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5018 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5019 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5021 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5028 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5029 * @ioc: per adapter object
5054 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5057 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5060 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5063 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5067 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5069 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5071 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5075 * _scsih_eedp_error_handling - return sense code for EEDP errors
5103 * scsih_qcmd - main scsi request entry point
5107 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5110 * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
5128 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5131 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5132 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5133 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5139 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5144 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5146 /* invalid device handle */ in scsih_qcmd()
5147 handle = sas_target_priv_data->handle; in scsih_qcmd()
5150 * Avoid error handling escallation when device is disconnected in scsih_qcmd()
5152 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5153 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5154 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5162 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5168 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5171 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5172 /* device has been deleted */ in scsih_qcmd()
5173 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5176 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5177 sas_device_priv_data->block) { in scsih_qcmd()
5178 /* device busy with task management */ in scsih_qcmd()
5188 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5192 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5194 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5202 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5207 /* Make sure Device is not raid volume. in scsih_qcmd()
5210 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5211 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5212 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5215 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5222 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5225 if (scmd->cmd_len == 32) in scsih_qcmd()
5227 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5228 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5230 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5232 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5233 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5234 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5235 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5236 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5237 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5238 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5239 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5241 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5242 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5243 mpi_request->LUN); in scsih_qcmd()
5244 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5246 if (mpi_request->DataLength) { in scsih_qcmd()
5247 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5248 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5254 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5256 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5257 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5261 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5262 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5263 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5265 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5267 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5268 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5270 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5278 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5287 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5288 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5289 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5292 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5293 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5294 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5299 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5300 * @ioc: per adapter object
5305 * scsi_status - SCSI Status code returned from target device
5306 * scsi_state - state info associated with SCSI_IO determined by ioc
5307 * ioc_status - ioc supplied status info
5315 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5317 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5318 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5321 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5322 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5325 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5326 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5331 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5353 desc_ioc_state = "scsi device not there"; in _scsih_scsi_ioc_info()
5454 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5456 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5457 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5461 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5462 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5464 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5465 pcie_device->slot); in _scsih_scsi_ioc_info()
5466 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5468 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5469 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5476 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5486 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5489 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5490 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5491 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5492 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5498 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5501 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5504 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5511 * _scsih_turn_on_pfa_led - illuminate PFA LED
5512 * @ioc: per adapter object
5513 * @handle: device handle
5540 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5554 * _scsih_turn_off_pfa_led - turn off Fault LED
5555 * @ioc: per adapter object
5556 * @sas_device: sas device whose PFA LED has to turned off
5570 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5572 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5591 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5592 * @ioc: per adapter object
5593 * @handle: device handle
5604 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5605 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5606 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5612 * _scsih_smart_predicted_fault - process smart errors
5613 * @ioc: per adapter object
5614 * @handle: device handle
5628 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5629 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5634 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5635 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5637 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5638 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5643 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5645 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5658 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5659 event_reply->Event = in _scsih_smart_predicted_fault()
5661 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5662 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5665 event_reply->EventData; in _scsih_smart_predicted_fault()
5666 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5667 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5668 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5669 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5678 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5683 * _scsih_io_done - scsi request callback
5684 * @ioc: per adapter object
5720 scmd->result = DID_OK << 16; in _scsih_io_done()
5724 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5725 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5726 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5727 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5730 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5737 if (st->direct_io && in _scsih_io_done()
5740 st->direct_io = 0; in _scsih_io_done()
5741 st->scmd = scmd; in _scsih_io_done()
5742 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5743 mpi_request->DevHandle = in _scsih_io_done()
5744 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5745 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5746 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5750 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5753 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5754 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5755 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5756 if ((!ioc->is_warpdrive && in _scsih_io_done()
5757 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5758 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5759 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5761 sas_disable_tlr(scmd->device); in _scsih_io_done()
5762 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5766 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5767 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5769 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5773 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5787 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5788 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5789 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5793 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5796 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5797 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5798 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5799 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5805 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5809 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5813 if (sas_device_priv_data->block) { in _scsih_io_done()
5814 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5818 if (scmd->retries > 2) { in _scsih_io_done()
5819 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5820 scsi_device_set_state(scmd->device, in _scsih_io_done()
5823 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5824 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5828 scmd->result = DID_RESET << 16; in _scsih_io_done()
5830 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5833 scmd->result = DID_RESET << 16; in _scsih_io_done()
5836 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5840 scmd->result = DID_RESET << 16; in _scsih_io_done()
5844 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5845 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5847 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5851 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5856 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5858 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5860 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5863 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5865 scmd->result = DID_RESET << 16; in _scsih_io_done()
5866 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5867 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5868 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5879 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5884 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5886 scmd->result = DID_RESET << 16; in _scsih_io_done()
5905 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5910 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5922 * _scsih_update_vphys_after_reset - update the Port's
5924 * @ioc: per adapter object
5947 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5948 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5951 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5952 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5959 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_update_vphys_after_reset()
5975 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5979 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
5983 * Check whether Phy is connected to SEP device or not, in _scsih_update_vphys_after_reset()
5984 * if it is SEP device then read the Phy's SASPHYPage0 data to in _scsih_update_vphys_after_reset()
5987 * device is a HBA's vSES device. in _scsih_update_vphys_after_reset()
5990 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6005 * Get the vSES device's SAS Address. in _scsih_update_vphys_after_reset()
6008 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6023 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6024 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6027 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6032 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6038 * to current Phy's vSES device SAS Address. in _scsih_update_vphys_after_reset()
6040 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6046 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6047 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6055 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6062 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6065 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6066 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6067 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6072 * device's Port ID got changed after reset and in _scsih_update_vphys_after_reset()
6077 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6079 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6080 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6081 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6082 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6083 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6087 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6092 * direct attached device with mport's Port ID, in _scsih_update_vphys_after_reset()
6094 * device has this Port ID, so unmark the mport in _scsih_update_vphys_after_reset()
6097 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6098 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6099 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6100 mport->flags &= in _scsih_update_vphys_after_reset()
6106 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6119 * _scsih_get_port_table_after_reset - Construct temporary port table
6120 * @ioc: per adapter object
6137 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_get_port_table_after_reset()
6151 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6153 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6157 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6166 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6178 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6198 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6200 * @ioc: per adapter object
6218 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6219 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6222 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6223 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6229 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6230 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6231 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6237 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6238 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6247 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6266 * _scsih_del_phy_part_of_anther_port - remove phy if it
6268 *@ioc: per adapter object
6280 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6289 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6299 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6301 *@ioc: per adapter object
6314 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6316 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6318 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6326 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6328 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6330 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6331 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6338 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6339 * @ioc: per adapter object
6350 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6351 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6354 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6355 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6358 vphy, port->port_id, in _scsih_del_dirty_vphy()
6359 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6360 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6361 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6365 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6366 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6371 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6373 *@ioc: per adapter object
6382 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6383 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6384 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6389 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6390 list_del(&port->list); in _scsih_del_dirty_port_entries()
6396 * _scsih_sas_port_refresh - Update HBA port table after host reset
6397 * @ioc: per adapter object
6413 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6422 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6427 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6429 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6445 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6446 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6450 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6453 port_table_entry->port_id, in _scsih_sas_port_refresh()
6454 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6455 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6492 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6493 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6494 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6495 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6502 * _scsih_alloc_vphy - allocate virtual_phy object
6503 * @ioc: per adapter object
6525 if (!port->vphys_mask) in _scsih_alloc_vphy()
6526 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6532 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6533 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6535 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6539 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6545 * _scsih_sas_host_refresh - refreshing sas host object contents
6546 * @ioc: per adapter object
6549 * During port enable, fw will send topology events for every device. Its
6568 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6570 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_refresh()
6584 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6585 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6587 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6588 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6589 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6595 port->port_id = port_id; in _scsih_sas_host_refresh()
6598 port, port->port_id); in _scsih_sas_host_refresh()
6599 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6600 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6601 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6604 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_refresh()
6606 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6620 * Allocate a virtual_phy object for vSES device, if in _scsih_sas_host_refresh()
6621 * this vSES device is hot added. in _scsih_sas_host_refresh()
6625 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6632 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6646 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6648 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6649 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6652 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6653 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6657 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6659 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6661 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6667 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6668 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6669 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6670 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6673 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6681 * _scsih_sas_host_add - create sas host object
6682 * @ioc: per adapter object
6684 * Creating host side data object, stored in ioc->sas_hba
6709 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6711 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6713 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6718 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6721 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6743 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6764 ioc->io_missing_delay = in _scsih_sas_host_add()
6765 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6767 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6769 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6772 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6775 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6776 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6792 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6795 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6801 port->port_id = port_id; in _scsih_sas_host_add()
6804 port, port->port_id); in _scsih_sas_host_add()
6805 list_add_tail(&port->list, in _scsih_sas_host_add()
6806 &ioc->port_table_list); in _scsih_sas_host_add()
6810 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_add()
6817 * Allocate a virtual_phy object for vSES device. in _scsih_sas_host_add()
6821 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6824 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6825 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6826 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6828 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6829 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6832 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6837 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6839 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6841 ioc->sas_hba.handle, in _scsih_sas_host_add()
6842 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6843 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6845 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6848 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6849 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6859 * _scsih_expander_add - creating expander object
6860 * @ioc: per adapter object
6863 * Creating expander object, stored in ioc->sas_expander_list.
6886 return -1; in _scsih_expander_add()
6888 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6889 return -1; in _scsih_expander_add()
6895 return -1; in _scsih_expander_add()
6903 return -1; in _scsih_expander_add()
6912 return -1; in _scsih_expander_add()
6916 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6917 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6921 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6929 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6933 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6943 return -1; in _scsih_expander_add()
6946 sas_expander->handle = handle; in _scsih_expander_add()
6947 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6948 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6949 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6950 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6951 if (!sas_expander->port) { in _scsih_expander_add()
6954 rc = -1; in _scsih_expander_add()
6960 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6962 if (!sas_expander->num_phys) { in _scsih_expander_add()
6963 rc = -1; in _scsih_expander_add()
6966 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6968 if (!sas_expander->phy) { in _scsih_expander_add()
6971 rc = -1; in _scsih_expander_add()
6975 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6977 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6981 rc = -1; in _scsih_expander_add()
6984 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6985 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
6987 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
6992 rc = -1; in _scsih_expander_add()
6995 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
6996 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
6997 sas_expander->phy[i].port = in _scsih_expander_add()
7001 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7002 sas_expander->parent_dev))) { in _scsih_expander_add()
7005 rc = -1; in _scsih_expander_add()
7010 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7013 sas_expander->enclosure_handle); in _scsih_expander_add()
7015 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7016 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7025 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7026 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7032 * mpt3sas_expander_remove - removing expander object
7033 * @ioc: per adapter object
7044 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7050 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7053 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7059 * _scsih_done - internal SCSI_IO callback handler.
7060 * @ioc: per adapter object
7066 * The callback index passed is `ioc->scsih_cb_idx`
7077 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7079 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7081 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7083 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7084 mpi_reply->MsgLength*4); in _scsih_done()
7085 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7087 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7088 complete(&ioc->scsih_cmds.done); in _scsih_done()
7099 * _scsih_check_access_status - check access flags
7100 * @ioc: per adapter object
7102 * @handle: sas device handle
7103 * @access_status: errors returned during discovery of the device
7132 desc = "device blocked"; in _scsih_check_access_status()
7162 * _scsih_check_device - checking device responsiveness
7163 * @ioc: per adapter object
7165 * @handle: attached device handle
7193 /* wide port handling ~ we need only handle device once for the phy that in _scsih_check_device()
7194 * is matched in sas device page zero in _scsih_check_device()
7199 /* check if this is end device */ in _scsih_check_device()
7204 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7215 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7216 starget = sas_device->starget; in _scsih_check_device()
7217 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7220 sas_device->handle, handle); in _scsih_check_device()
7221 sas_target_priv_data->handle = handle; in _scsih_check_device()
7222 sas_device->handle = handle; in _scsih_check_device()
7225 sas_device->enclosure_level = in _scsih_check_device()
7227 memcpy(sas_device->connector_name, in _scsih_check_device()
7229 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7231 sas_device->enclosure_level = 0; in _scsih_check_device()
7232 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7235 sas_device->enclosure_handle = in _scsih_check_device()
7237 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7239 sas_device->enclosure_handle); in _scsih_check_device()
7241 sas_device->enclosure_logical_id = in _scsih_check_device()
7242 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7243 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7245 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7246 sas_device->chassis_slot = in _scsih_check_device()
7247 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7252 /* check if device is present */ in _scsih_check_device()
7255 ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_check_device()
7265 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7273 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7279 * _scsih_add_device - creating sas device object
7280 * @ioc: per adapter object
7281 * @handle: sas device handle
7282 * @phy_num: phy number end device attached to
7285 * Creating end device object, stored in ioc->sas_device_list.
7287 * Return: 0 for success, non-zero for failure.
7306 return -1; in _scsih_add_device()
7314 return -1; in _scsih_add_device()
7317 /* check if this is end device */ in _scsih_add_device()
7320 return -1; in _scsih_add_device()
7321 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7324 /* check if device is present */ in _scsih_add_device()
7327 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_add_device()
7329 return -1; in _scsih_add_device()
7335 return -1; in _scsih_add_device()
7341 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7343 return -1; in _scsih_add_device()
7351 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_add_device()
7363 kref_init(&sas_device->refcount); in _scsih_add_device()
7364 sas_device->handle = handle; in _scsih_add_device()
7367 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7370 sas_device->enclosure_handle = in _scsih_add_device()
7372 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7373 sas_device->slot = in _scsih_add_device()
7375 sas_device->device_info = device_info; in _scsih_add_device()
7376 sas_device->sas_address = sas_address; in _scsih_add_device()
7377 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7378 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7380 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7381 if (!sas_device->port) { in _scsih_add_device()
7389 sas_device->enclosure_level = in _scsih_add_device()
7391 memcpy(sas_device->connector_name, in _scsih_add_device()
7393 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7395 sas_device->enclosure_level = 0; in _scsih_add_device()
7396 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7399 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7401 sas_device->enclosure_logical_id = in _scsih_add_device()
7402 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7403 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7405 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7406 sas_device->chassis_slot = in _scsih_add_device()
7407 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7411 /* get device name */ in _scsih_add_device()
7412 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7413 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7416 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7418 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7429 * _scsih_remove_device - removing sas device object
7430 * @ioc: per adapter object
7439 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7440 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7442 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7448 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7453 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7454 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7455 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7456 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7457 sas_device->port); in _scsih_remove_device()
7458 sas_target_priv_data->handle = in _scsih_remove_device()
7462 if (!ioc->hide_drives) in _scsih_remove_device()
7464 sas_device->sas_address, in _scsih_remove_device()
7465 sas_device->sas_address_parent, in _scsih_remove_device()
7466 sas_device->port); in _scsih_remove_device()
7469 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7476 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7482 * _scsih_sas_topology_change_event_debug - debug for topology event
7483 * @ioc: per adapter object
7498 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7519 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7520 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7521 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7522 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7523 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7526 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7527 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7549 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7550 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7559 * _scsih_sas_topology_change_event - handle topology changes
7560 * @ioc: per adapter object
7580 fw_event->event_data; in _scsih_sas_topology_change_event()
7582 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7585 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7588 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7593 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7598 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7599 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7602 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7606 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7610 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7611 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7612 port = sas_expander->port; in _scsih_sas_topology_change_event()
7613 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7614 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7615 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7617 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7620 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7623 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7624 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7629 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7631 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7634 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7636 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7640 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7643 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7644 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7648 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7663 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7670 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7687 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7695 * _scsih_sas_device_status_change_event_debug - debug for device event
7706 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7711 reason_str = "unsupported device discovered"; in _scsih_sas_device_status_change_event_debug()
7714 reason_str = "internal device reset"; in _scsih_sas_device_status_change_event_debug()
7732 reason_str = "internal device reset complete"; in _scsih_sas_device_status_change_event_debug()
7750 ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)", in _scsih_sas_device_status_change_event_debug()
7751 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7752 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7753 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7754 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7756 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7761 * _scsih_sas_device_status_change_event - handle device status change
7762 * @ioc: per adapter object
7775 /* In MPI Revision K (0xC), the internal device reset complete was in _scsih_sas_device_status_change_event()
7778 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7781 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7783 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7787 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7788 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7791 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7793 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7796 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7800 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7802 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7804 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7806 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7809 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7810 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7816 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7821 * _scsih_check_pcie_access_status - check access flags
7822 * @ioc: per adapter object
7824 * @handle: sas device handle
7825 * @access_status: errors returned during discovery of the device
7842 desc = "PCIe device capability failed"; in _scsih_check_pcie_access_status()
7845 desc = "PCIe device blocked"; in _scsih_check_pcie_access_status()
7847 "Device with Access Status (%s): wwid(0x%016llx), " in _scsih_check_pcie_access_status()
7853 desc = "PCIe device mem space access failed"; in _scsih_check_pcie_access_status()
7856 desc = "PCIe device unsupported"; in _scsih_check_pcie_access_status()
7859 desc = "PCIe device MSIx Required"; in _scsih_check_pcie_access_status()
7862 desc = "PCIe device init fail max"; in _scsih_check_pcie_access_status()
7865 desc = "PCIe device status unknown"; in _scsih_check_pcie_access_status()
7871 desc = "nvme device configuration unsupported"; in _scsih_check_pcie_access_status()
7909 * _scsih_pcie_device_remove_from_sml - removing pcie device
7911 * @ioc: per adapter object
7923 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7924 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7928 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7929 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7930 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7934 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7935 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7937 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7938 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7939 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7940 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7941 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7945 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7946 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7948 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7949 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7950 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7952 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7953 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7955 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7957 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7961 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7962 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7966 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7967 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7968 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7972 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7973 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7975 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7980 * _scsih_pcie_check_device - checking device responsiveness
7981 * @ioc: per adapter object
7982 * @handle: attached device handle
8005 /* check if this is end device */ in _scsih_pcie_check_device()
8011 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8015 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8019 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8020 starget = pcie_device->starget; in _scsih_pcie_check_device()
8021 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8022 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8025 pcie_device->handle, handle); in _scsih_pcie_check_device()
8026 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8027 pcie_device->handle = handle; in _scsih_pcie_check_device()
8031 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8033 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8036 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8037 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8041 /* check if device is present */ in _scsih_pcie_check_device()
8044 ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_pcie_check_device()
8046 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8054 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8059 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8068 * _scsih_pcie_add_device - creating pcie device object
8069 * @ioc: per adapter object
8070 * @handle: pcie device handle
8072 * Creating end device object, stored in ioc->pcie_device_list.
8101 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8104 /* check if device is present */ in _scsih_pcie_add_device()
8107 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_pcie_add_device()
8123 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8128 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8129 * specific NVMe device; therefore, this page is only in _scsih_pcie_add_device()
8160 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8161 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8162 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8163 pcie_device->handle = handle; in _scsih_pcie_add_device()
8164 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8165 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8166 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8167 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8168 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8171 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8173 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8174 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8178 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8179 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8182 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8183 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8187 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8190 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8192 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8193 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8195 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8198 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8200 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8207 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8208 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8209 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8211 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8214 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8216 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8218 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8228 * _scsih_pcie_topology_change_event_debug - debug for topology
8230 * @ioc: per adapter object
8245 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8266 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8267 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8268 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8269 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8271 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8274 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8275 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8296 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8298 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8307 * _scsih_pcie_topology_change_event - handle PCIe topology
8309 * @ioc: per adapter object
8325 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8328 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8331 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8332 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8335 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8341 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8342 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8347 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8349 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8351 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8355 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8357 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8362 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8372 * where a device has been added, however its returning in _scsih_pcie_topology_change_event()
8373 * BUSY for sometime. Then before the Device Missing in _scsih_pcie_topology_change_event()
8374 * Delay expires and the device becomes READY, the in _scsih_pcie_topology_change_event()
8375 * device is removed and added back. in _scsih_pcie_topology_change_event()
8377 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8379 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8386 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8390 ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n", in _scsih_pcie_topology_change_event()
8392 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8393 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8397 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8409 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8421 * _scsih_pcie_device_status_change_event_debug - debug for device event
8432 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8437 reason_str = "unsupported device discovered"; in _scsih_pcie_device_status_change_event_debug()
8440 reason_str = "internal device reset"; in _scsih_pcie_device_status_change_event_debug()
8455 reason_str = "device init failure"; in _scsih_pcie_device_status_change_event_debug()
8458 reason_str = "internal device reset complete"; in _scsih_pcie_device_status_change_event_debug()
8474 ioc_info(ioc, "PCIE device status change: (%s)\n" in _scsih_pcie_device_status_change_event_debug()
8476 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8477 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8478 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8479 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8481 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8486 * _scsih_pcie_device_status_change_event - handle device status
8488 * @ioc: per adapter object
8501 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8502 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8506 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8508 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8512 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8513 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8516 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8519 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8523 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8525 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8527 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8532 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8536 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8538 * @ioc: per adapter object
8548 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8563 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8564 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8565 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8569 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8570 * @ioc: per adapter object
8581 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8583 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8585 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8588 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8589 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8596 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8608 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8618 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8619 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8624 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8634 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8635 * @ioc: per adapter object
8654 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8661 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8663 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8667 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8668 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8678 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8682 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8683 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8689 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8690 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8691 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8694 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8698 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8702 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8706 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8707 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8710 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8713 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8715 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8716 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8721 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8724 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8730 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8735 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8737 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8739 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8748 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8752 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8755 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8756 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8757 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8758 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8769 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8771 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8772 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8775 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8780 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8785 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8789 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8792 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8793 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8795 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8799 * _scsih_sas_discovery_event - handle discovery events
8800 * @ioc: per adapter object
8809 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8811 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8813 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8815 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8817 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8821 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8822 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8823 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8825 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8833 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8835 * @ioc: per adapter object
8844 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8846 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8849 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8850 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8851 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8855 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8856 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8857 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8865 * _scsih_pcie_enumeration_event - handle enumeration events
8866 * @ioc: per adapter object
8875 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8877 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8881 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8883 event_data->Flags); in _scsih_pcie_enumeration_event()
8884 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8886 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8891 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8892 * @ioc: per adapter object
8893 * @handle: device handle for physical disk
8909 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8912 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8914 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8916 rc = -EAGAIN; in _scsih_ir_fastpath()
8919 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8921 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8924 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8925 rc = -EAGAIN; in _scsih_ir_fastpath()
8930 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8933 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8934 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8935 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8941 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8942 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8943 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8945 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8947 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8949 rc = -EFAULT; in _scsih_ir_fastpath()
8953 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8955 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8956 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8958 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8966 rc = -EFAULT; in _scsih_ir_fastpath()
8973 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8974 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8982 * _scsih_reprobe_lun - reprobing lun
8983 * @sdev: scsi device struct
8984 * @no_uld_attach: sdev->no_uld_attach flag setting
8990 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
8992 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
8997 * _scsih_sas_volume_add - add new volume
8998 * @ioc: per adapter object
9009 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
9019 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9021 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9033 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9034 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9035 raid_device->handle = handle; in _scsih_sas_volume_add()
9036 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9038 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9039 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9040 raid_device->id, 0); in _scsih_sas_volume_add()
9044 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9046 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9051 * _scsih_sas_volume_delete - delete volume
9052 * @ioc: per adapter object
9053 * @handle: volume device handle
9064 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9067 if (raid_device->starget) { in _scsih_sas_volume_delete()
9068 starget = raid_device->starget; in _scsih_sas_volume_delete()
9069 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9070 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9073 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9074 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9077 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9079 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9083 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9084 * @ioc: per adapter object
9096 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
9098 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9101 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9102 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9103 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9104 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9105 starget = sas_device->starget; in _scsih_sas_pd_expose()
9106 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9107 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9111 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9123 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9124 * @ioc: per adapter object
9136 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
9145 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9148 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9149 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9150 starget = sas_device->starget; in _scsih_sas_pd_hide()
9151 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9152 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9154 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9155 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9158 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9163 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9172 * _scsih_sas_pd_delete - delete pd component
9173 * @ioc: per adapter object
9181 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
9187 * _scsih_sas_pd_add - remove pd component
9188 * @ioc: per adapter object
9197 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
9204 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9208 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9235 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9240 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9241 * @ioc: per adapter object
9254 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9257 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9259 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9260 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9261 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9293 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9311 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9312 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9313 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9318 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9319 * @ioc: per adapter object
9332 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9334 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9335 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9338 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9341 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9342 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9343 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9344 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9345 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9347 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9348 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9353 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9355 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9365 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9368 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9372 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9376 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9380 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9388 * _scsih_sas_ir_volume_event - IR volume event
9389 * @ioc: per adapter object
9404 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9406 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9409 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9412 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9413 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9414 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9418 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9430 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9432 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9451 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9452 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9453 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9454 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9456 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9457 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9469 * _scsih_sas_ir_physical_disk_event - PD event
9470 * @ioc: per adapter object
9485 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9488 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9491 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9494 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9495 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9497 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9501 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9511 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9512 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9556 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9557 * @ioc: per adapter object
9567 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9590 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9591 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9595 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9596 * @ioc: per adapter object
9606 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9611 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9612 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9617 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9619 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9620 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9623 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9624 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9625 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9630 * _scsih_prep_device_scan - initialize parameters prior to device scan
9631 * @ioc: per adapter object
9633 * Set the deleted flag prior to device scan. If the device is found during
9642 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9643 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9644 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9645 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9650 * _scsih_update_device_qdepth - Update QD during Reset.
9651 * @ioc: per adapter object
9664 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9665 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9666 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9667 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9668 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9669 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9670 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9672 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9673 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9674 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9676 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9677 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9686 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9687 * @ioc: per adapter object
9688 * @sas_device_pg0: SAS Device page 0
9703 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9705 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9708 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9710 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_mark_responding_sas_device()
9711 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9713 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9714 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9715 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9716 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9718 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9720 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9722 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9723 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9724 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9725 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9726 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9727 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9733 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9735 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9737 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9741 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9742 sas_device->slot); in _scsih_mark_responding_sas_device()
9744 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9746 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9747 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9748 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9749 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9751 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9752 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9755 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9756 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9757 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9759 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9760 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9761 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9763 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9764 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9765 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9769 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9770 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9773 sas_device->handle); in _scsih_mark_responding_sas_device()
9774 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9775 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9777 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9778 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9782 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9786 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9788 * @ioc: per adapter object
9812 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9821 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9822 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9824 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9829 * _scsih_search_responding_sas_devices -
9830 * @ioc: per adapter object
9844 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9846 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9865 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9869 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9870 * @ioc: per adapter object
9871 * @pcie_device_pg0: PCIe Device page 0
9885 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9886 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9887 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9888 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9889 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9890 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9891 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9892 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9893 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9894 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9895 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9896 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9897 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9903 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9904 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9905 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9910 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9911 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9914 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9916 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9917 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9918 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9919 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9920 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9922 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9923 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9926 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9927 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9930 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9931 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9932 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9934 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9935 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9941 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9945 * _scsih_search_responding_pcie_devices -
9946 * @ioc: per adapter object
9960 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9962 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
9984 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
9988 * _scsih_mark_responding_raid_device - mark a raid_device as responding
9989 * @ioc: per adapter object
9991 * @handle: device handle
10005 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10006 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10007 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10008 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10009 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10010 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10011 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10014 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10015 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10016 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10018 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10022 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10026 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10027 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10028 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10033 raid_device->handle); in _scsih_mark_responding_raid_device()
10034 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10036 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10037 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10041 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10045 * _scsih_search_responding_raid_devices -
10046 * @ioc: per adapter object
10062 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10067 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10092 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10094 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10104 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10112 * _scsih_mark_responding_expander - mark a expander as responding
10113 * @ioc: per adapter object
10127 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
10128 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10129 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10131 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10138 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10139 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10140 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10142 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10144 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10147 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10148 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10149 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10150 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10153 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10157 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10158 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10159 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10160 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10161 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10165 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10169 * _scsih_search_responding_expanders -
10170 * @ioc: per adapter object
10187 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10205 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10215 * _scsih_remove_unresponding_devices - removing unresponding devices
10216 * @ioc: per adapter object
10232 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10234 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10237 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10244 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10245 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10250 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10251 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10252 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10254 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10256 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10263 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10267 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10269 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10275 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10276 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10281 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10282 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10283 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10285 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10287 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10291 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10296 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10299 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10300 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10302 raid_device->handle); in _scsih_remove_unresponding_devices()
10304 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10310 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10313 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10314 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10315 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10317 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10319 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10339 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10347 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10350 sas_expander->port); in _scsih_refresh_expander_links()
10355 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10356 * @ioc: per adapter object
10398 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10403 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10420 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10466 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10468 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10498 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10501 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10543 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10561 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10568 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10576 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10592 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10610 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10619 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10620 * @ioc: per adapter object
10630 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10632 * @ioc: per adapter object
10641 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10642 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10643 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10644 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10646 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10647 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10648 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10649 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10652 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10653 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10654 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10660 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10661 * @ioc: per adapter object
10669 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10670 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10685 * _mpt3sas_fw_work - delayed task for processing firmware events
10686 * @ioc: per adapter object
10693 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10697 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10699 ioc->current_event = NULL; in _mpt3sas_fw_work()
10703 switch (fw_event->event) { in _mpt3sas_fw_work()
10707 fw_event->event_data); in _mpt3sas_fw_work()
10710 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10711 ioc->shost_recovery) { in _mpt3sas_fw_work()
10716 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10723 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10730 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10731 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10732 *- start the watchdog thread. in _mpt3sas_fw_work()
10736 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10741 ioc->start_scan = 0; in _mpt3sas_fw_work()
10742 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10749 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10755 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10758 fw_event->event_data); in _mpt3sas_fw_work()
10793 ioc->current_event = NULL; in _mpt3sas_fw_work()
10798 ioc->current_event = NULL; in _mpt3sas_fw_work()
10815 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10819 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10820 * @ioc: per adapter object
10825 * This function merely adds a new work task into ioc->firmware_event_thread.
10842 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10853 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10864 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10866 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10870 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10871 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10874 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10881 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10887 * sas device page0's not by processing the in mpt3sas_scsih_event_callback()
10890 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10896 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10897 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10903 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10908 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10915 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10919 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10920 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10922 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10934 …no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode.… in mpt3sas_scsih_event_callback()
10946 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10960 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10964 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10965 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10968 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10973 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
10978 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10990 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
10998 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
10999 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11000 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11001 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11002 fw_event->event = event; in mpt3sas_scsih_event_callback()
11009 * _scsih_expander_node_remove - removing expander device from list.
11010 * @ioc: per adapter object
11014 * ioc->sas_expander_list.
11026 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11027 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11029 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11032 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11033 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11034 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11036 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11039 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11040 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11043 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11045 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11046 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11050 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11051 sas_expander->sas_address, in _scsih_expander_node_remove()
11054 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11055 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11056 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11058 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11063 * _scsih_nvme_shutdown - NVMe shutdown notification
11064 * @ioc: per adapter object
11078 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11081 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11083 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11088 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11090 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11094 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11099 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11101 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11102 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11104 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11105 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11109 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11110 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11111 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11113 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11118 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11119 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11122 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11123 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11126 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11127 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11132 * _scsih_ir_shutdown - IR shutdown notification
11133 * @ioc: per adapter object
11146 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11150 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11153 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11155 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11159 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11161 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11164 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11169 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11172 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11173 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11175 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11177 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11178 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11179 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11181 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11186 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11187 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11188 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11190 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11191 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11195 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11196 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11200 * _scsih_get_shost_and_ioc - get shost and ioc
11202 * @pdev: PCI device struct
11214 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11215 return -ENXIO; in _scsih_get_shost_and_ioc()
11220 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11221 return -ENXIO; in _scsih_get_shost_and_ioc()
11228 * scsih_remove - detach and remove add host
11229 * @pdev: PCI device struct
11249 ioc->remove_host = 1; in scsih_remove()
11258 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11259 wq = ioc->firmware_event_thread; in scsih_remove()
11260 ioc->firmware_event_thread = NULL; in scsih_remove()
11261 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11268 if (ioc->is_aero_ioc) in scsih_remove()
11270 &ioc->ioc_pg1_copy); in scsih_remove()
11275 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11277 if (raid_device->starget) { in scsih_remove()
11279 raid_device->starget->hostdata; in scsih_remove()
11280 sas_target_priv_data->deleted = 1; in scsih_remove()
11281 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11284 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11287 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11290 list_del_init(&pcie_device->list); in scsih_remove()
11296 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11297 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11300 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11301 mpt3sas_port->hba_port); in scsih_remove()
11302 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11304 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11307 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11308 mpt3sas_port->hba_port); in scsih_remove()
11312 &ioc->port_table_list, list) { in scsih_remove()
11313 list_del(&port->list); in scsih_remove()
11318 if (ioc->sas_hba.num_phys) { in scsih_remove()
11319 kfree(ioc->sas_hba.phy); in scsih_remove()
11320 ioc->sas_hba.phy = NULL; in scsih_remove()
11321 ioc->sas_hba.num_phys = 0; in scsih_remove()
11327 list_del(&ioc->list); in scsih_remove()
11333 * scsih_shutdown - routine call during system shutdown
11334 * @pdev: PCI device struct
11348 ioc->remove_host = 1; in scsih_shutdown()
11357 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11358 wq = ioc->firmware_event_thread; in scsih_shutdown()
11359 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11360 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11367 if (ioc->is_aero_ioc) in scsih_shutdown()
11369 &ioc->ioc_pg1_copy); in scsih_shutdown()
11375 ioc->shost_recovery = 1; in scsih_shutdown()
11377 ioc->shost_recovery = 0; in scsih_shutdown()
11384 * _scsih_probe_boot_devices - reports 1st device
11385 * @ioc: per adapter object
11388 * device scsi-ml or sas transport for persistent boot device
11395 void *device; in _scsih_probe_boot_devices() local
11408 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11411 device = NULL; in _scsih_probe_boot_devices()
11412 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11413 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11414 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11415 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11416 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11417 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11418 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11419 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11420 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11423 if (!device) in _scsih_probe_boot_devices()
11427 raid_device = device; in _scsih_probe_boot_devices()
11430 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11433 if (raid_device->starget) in _scsih_probe_boot_devices()
11435 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11436 raid_device->id, 0); in _scsih_probe_boot_devices()
11440 pcie_device = device; in _scsih_probe_boot_devices()
11442 * If this boot NVMe device is already registered with SML then in _scsih_probe_boot_devices()
11443 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11446 if (pcie_device->starget) in _scsih_probe_boot_devices()
11448 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11449 tid = pcie_device->id; in _scsih_probe_boot_devices()
11450 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11451 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11452 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11456 sas_device = device; in _scsih_probe_boot_devices()
11458 * If this boot sas/sata device is already registered with SML in _scsih_probe_boot_devices()
11459 * then no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11462 if (sas_device->starget) in _scsih_probe_boot_devices()
11464 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11465 handle = sas_device->handle; in _scsih_probe_boot_devices()
11466 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11467 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11468 port = sas_device->port; in _scsih_probe_boot_devices()
11469 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11470 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11472 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11481 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11482 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11493 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11494 * @ioc: per adapter object
11505 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11506 if (raid_device->starget) in _scsih_probe_raid()
11508 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11509 raid_device->id, 0); in _scsih_probe_raid()
11520 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11521 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11522 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11526 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11536 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11546 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11547 list_del_init(&sas_device->list); in sas_device_make_active()
11552 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11554 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11558 * _scsih_probe_sas - reporting sas devices to sas transport
11559 * @ioc: per adapter object
11568 if (ioc->hide_drives) in _scsih_probe_sas()
11572 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11573 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11577 } else if (!sas_device->starget) { in _scsih_probe_sas()
11581 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11584 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11586 sas_device->sas_address, in _scsih_probe_sas()
11587 sas_device->sas_address_parent, in _scsih_probe_sas()
11588 sas_device->port); in _scsih_probe_sas()
11600 * get_next_pcie_device - Get the next pcie device
11601 * @ioc: per adapter object
11603 * Get the next pcie device from pcie_device_init_list list.
11605 * Return: pcie device structure if pcie_device_init_list list is not empty
11613 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11614 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11615 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11619 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11625 * pcie_device_make_active - Add pcie device to pcie_device_list list
11626 * @ioc: per adapter object
11627 * @pcie_device: pcie device object
11629 * Add the pcie device which has registered with SCSI Transport Later to
11637 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11639 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11640 list_del_init(&pcie_device->list); in pcie_device_make_active()
11644 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11646 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11650 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11651 * @ioc: per adapter object
11661 /* PCIe Device List */ in _scsih_probe_pcie()
11663 if (pcie_device->starget) { in _scsih_probe_pcie()
11667 if (pcie_device->access_status == in _scsih_probe_pcie()
11673 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11674 pcie_device->id, 0); in _scsih_probe_pcie()
11679 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11683 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11686 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11687 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11701 * _scsih_probe_devices - probing for devices
11702 * @ioc: per adapter object
11711 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11716 if (ioc->ir_firmware) { in _scsih_probe_devices()
11718 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11735 * scsih_scan_start - scsi lld callback for .scan_start
11747 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11749 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11755 ioc->start_scan = 1; in scsih_scan_start()
11763 * _scsih_complete_devices_scanning - add the devices to sml and
11765 * @ioc: per adapter object
11772 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11773 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11778 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11782 * scsih_scan_finished - scsi lld callback for .scan_finished
11798 ioc->is_driver_loading = 0; in scsih_scan_finished()
11799 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11804 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11806 ioc->is_driver_loading = 0; in scsih_scan_finished()
11810 if (ioc->start_scan) { in scsih_scan_finished()
11828 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11831 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11834 if (ioc->start_scan_failed) { in scsih_scan_finished()
11836 ioc->start_scan_failed); in scsih_scan_finished()
11837 ioc->is_driver_loading = 0; in scsih_scan_finished()
11838 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11839 ioc->remove_host = 1; in scsih_scan_finished()
11844 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11849 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11851 ioc->is_driver_loading = 0; in scsih_scan_finished()
11857 * scsih_map_queues - map reply queues with request queues
11863 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11866 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11867 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11869 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11872 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11873 map = &shost->tag_set.map[i]; in scsih_map_queues()
11874 map->nr_queues = 0; in scsih_map_queues()
11877 map->nr_queues = in scsih_map_queues()
11878 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11879 offset = ioc->high_iops_queues; in scsih_map_queues()
11881 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11883 if (!map->nr_queues) in scsih_map_queues()
11888 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11890 map->queue_offset = qoff; in scsih_map_queues()
11892 blk_mq_map_hw_queues(map, &ioc->pdev->dev, offset); in scsih_map_queues()
11896 qoff += map->nr_queues; in scsih_map_queues()
11920 .this_id = -1,
11958 .this_id = -1,
11980 * _scsih_determine_hba_mpi_version - determine in which MPI version class
11981 * this device belongs to.
11982 * @pdev: PCI device struct
11992 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12052 * _scsih_probe - attach and add scsi host
12053 * @pdev: PCI device struct
12054 * @id: pci device id
12067 /* Determine in which MPI version class this pci device belongs */ in _scsih_probe()
12070 return -ENODEV; in _scsih_probe()
12073 * for other generation HBA's return with -ENODEV in _scsih_probe()
12076 return -ENODEV; in _scsih_probe()
12079 * for other generation HBA's return with -ENODEV in _scsih_probe()
12083 return -ENODEV; in _scsih_probe()
12093 return -ENODEV; in _scsih_probe()
12096 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12097 ioc->id = mpt2_ids++; in _scsih_probe()
12098 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12099 switch (pdev->device) { in _scsih_probe()
12101 ioc->is_warpdrive = 1; in _scsih_probe()
12102 ioc->hide_ir_msg = 1; in _scsih_probe()
12106 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12109 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12113 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12114 ioc->multipath_on_hba = 0; in _scsih_probe()
12116 ioc->multipath_on_hba = 1; in _scsih_probe()
12125 return -ENODEV; in _scsih_probe()
12128 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12129 ioc->id = mpt3_ids++; in _scsih_probe()
12130 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12131 switch (pdev->device) { in _scsih_probe()
12140 ioc->is_gen35_ioc = 1; in _scsih_probe()
12144 dev_err(&pdev->dev, in _scsih_probe()
12146 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12147 pdev->subsystem_device); in _scsih_probe()
12151 dev_err(&pdev->dev, in _scsih_probe()
12153 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12154 pdev->subsystem_device); in _scsih_probe()
12158 dev_info(&pdev->dev, in _scsih_probe()
12163 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12166 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12168 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12169 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12170 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12171 ioc->combined_reply_queue = 1; in _scsih_probe()
12172 if (ioc->is_gen35_ioc) in _scsih_probe()
12173 ioc->combined_reply_index_count = in _scsih_probe()
12176 ioc->combined_reply_index_count = in _scsih_probe()
12180 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12182 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12183 ioc->multipath_on_hba = 0; in _scsih_probe()
12185 ioc->multipath_on_hba = 1; in _scsih_probe()
12188 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12189 ioc->multipath_on_hba = 1; in _scsih_probe()
12191 ioc->multipath_on_hba = 0; in _scsih_probe()
12199 return -ENODEV; in _scsih_probe()
12202 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12204 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12206 ioc->shost = shost; in _scsih_probe()
12207 ioc->pdev = pdev; in _scsih_probe()
12208 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12209 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12210 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12211 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12212 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12213 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12214 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12215 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12216 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12217 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12218 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12219 ioc->logging_level = logging_level; in _scsih_probe()
12220 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12222 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12226 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12228 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12230 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12233 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12234 mutex_init(&ioc->hostdiag_unlock_mutex); in _scsih_probe()
12236 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12237 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12238 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12239 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12240 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12241 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12242 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12243 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12244 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12246 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12247 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12248 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12249 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12250 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12251 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12252 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12253 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12254 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12255 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12256 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12257 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12258 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12259 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12260 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12262 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12265 shost->max_cmd_len = 32; in _scsih_probe()
12266 shost->max_lun = max_lun; in _scsih_probe()
12267 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12268 shost->unique_id = ioc->id; in _scsih_probe()
12270 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12272 shost->max_sectors = 128; in _scsih_probe()
12274 shost->max_sectors); in _scsih_probe()
12278 shost->max_sectors = 64; in _scsih_probe()
12282 shost->max_sectors = 32767; in _scsih_probe()
12286 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12288 shost->max_sectors); in _scsih_probe()
12303 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12304 "fw_event_%s%d", 0, ioc->driver_name, ioc->id); in _scsih_probe()
12305 if (!ioc->firmware_event_thread) { in _scsih_probe()
12308 rv = -ENODEV; in _scsih_probe()
12312 shost->host_tagset = 0; in _scsih_probe()
12314 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12315 shost->host_tagset = 1; in _scsih_probe()
12317 ioc->is_driver_loading = 1; in _scsih_probe()
12321 rv = -ENODEV; in _scsih_probe()
12325 if (ioc->is_warpdrive) { in _scsih_probe()
12326 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12327 ioc->hide_drives = 0; in _scsih_probe()
12328 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12329 ioc->hide_drives = 1; in _scsih_probe()
12332 ioc->hide_drives = 1; in _scsih_probe()
12334 ioc->hide_drives = 0; in _scsih_probe()
12337 ioc->hide_drives = 0; in _scsih_probe()
12339 shost->nr_hw_queues = 1; in _scsih_probe()
12341 if (shost->host_tagset) { in _scsih_probe()
12342 shost->nr_hw_queues = in _scsih_probe()
12343 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12346 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12348 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12350 dev_info(&ioc->pdev->dev, in _scsih_probe()
12352 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12355 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12368 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12371 list_del(&ioc->list); in _scsih_probe()
12378 * scsih_suspend - power management suspend main entry point
12379 * @dev: Device struct
12384 scsih_suspend(struct device *dev) in scsih_suspend()
12406 * scsih_resume - power management resume main entry point
12407 * @dev: Device struct
12412 scsih_resume(struct device *dev) in scsih_resume()
12417 pci_power_t device_state = pdev->current_state; in scsih_resume()
12427 ioc->pdev = pdev; in scsih_resume()
12439 * scsih_pci_error_detected - Called when a PCI error is detected.
12440 * @pdev: PCI device struct
12463 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12464 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12469 /* Permanent error, prepare for device removal */ in scsih_pci_error_detected()
12470 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12480 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12481 * @pdev: PCI device struct
12499 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12500 ioc->pdev = pdev; in scsih_pci_slot_reset()
12519 * scsih_pci_resume() - resume normal ops after PCI reset
12520 * @pdev: pointer to PCI device
12538 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12542 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12543 * @pdev: pointer to PCI device
12556 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12559 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still in scsih_pci_mmio_enabled()
12566 * The pci device ids are defined in mpi/mpi2_cnfg.h.
12733 * scsih_init - main entry point for this driver.
12784 * scsih_exit - exit point for this driver (when it is a module).
12815 * _mpt3sas_init - main entry point for this driver.
12830 return -ENODEV; in _mpt3sas_init()
12840 return -ENODEV; in _mpt3sas_init()
12852 return -ENODEV; in _mpt3sas_init()
12874 * _mpt3sas_exit - exit point for this driver (when it is a module).