Lines Matching +full:device +full:- +full:handle

5  * Copyright (C) 2012-2014  LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
56 #include <linux/blk-mq-pci.h>
72 static int _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle,
74 static int _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle);
78 _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle);
94 static u8 scsi_io_cb_idx = -1;
95 static u8 tm_cb_idx = -1;
96 static u8 ctl_cb_idx = -1;
97 static u8 base_cb_idx = -1;
98 static u8 port_enable_cb_idx = -1;
99 static u8 transport_cb_idx = -1;
100 static u8 scsih_cb_idx = -1;
101 static u8 config_cb_idx = -1;
105 static u8 tm_tr_cb_idx = -1 ;
106 static u8 tm_tr_volume_cb_idx = -1 ;
107 static u8 tm_sas_control_cb_idx = -1;
120 static int missing_delay[2] = {-1, -1};
122 MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
124 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
133 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
134 1 - enumerates only SAS 2.0 generation HBAs\n \
135 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
144 static int diag_buffer_enable = -1;
148 static int disable_discovery = -1;
154 static int prot_mask = -1;
163 static int multipath_on_hba = -1;
166 "Multipath support to add same target device\n\t\t"
169 "\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
170 "\t SAS 3.5 HBA - This will be enabled)");
183 * struct sense_info - common structure for obtaining sense keys
200 * struct fw_event_work - firmware event struct
202 * @work: work object (ioc->fault_reset_work_q)
204 * @device_handle: device handle
212 * This object stored on ioc->fw_event_list.
235 kref_get(&fw_work->refcount); in fw_event_work_get()
240 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
251 kref_init(&fw_event->refcount); in alloc_fw_event_work()
256 * struct _scsi_io_transfer - scsi io transfer
257 * @handle: sas device handle (assigned by firmware)
281 u16 handle; member
304 * _scsih_set_debug_level - global setting of ioc->logging_level.
322 ioc->logging_level = logging_level; in _scsih_set_debug_level()
330 * _scsih_srch_boot_sas_address - search based on sas_address
332 * @boot_device: boot device object from bios page 2
340 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
344 * _scsih_srch_boot_device_name - search based on device name
345 * @device_name: device name specified in INDENTIFY fram
346 * @boot_device: boot device object from bios page 2
354 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
358 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
361 * @boot_device: boot device object from bios page 2
369 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
370 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
375 * mpt3sas_get_port_by_id - get hba port entry corresponding to provided
396 if (!ioc->multipath_on_hba) in mpt3sas_get_port_by_id()
400 &ioc->port_table_list, list) { in mpt3sas_get_port_by_id()
401 if (port->port_id != port_id) in mpt3sas_get_port_by_id()
405 if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) in mpt3sas_get_port_by_id()
415 if (!ioc->multipath_on_hba) { in mpt3sas_get_port_by_id()
420 port->port_id = port_id; in mpt3sas_get_port_by_id()
423 port, port->port_id); in mpt3sas_get_port_by_id()
424 list_add_tail(&port->list, in mpt3sas_get_port_by_id()
425 &ioc->port_table_list); in mpt3sas_get_port_by_id()
432 * mpt3sas_get_vphy_by_phy - get virtual_phy object corresponding to phy number
445 if (!port->vphys_mask) in mpt3sas_get_vphy_by_phy()
448 list_for_each_entry_safe(vphy, vphy_next, &port->vphys_list, list) { in mpt3sas_get_vphy_by_phy()
449 if (vphy->phy_mask & (1 << phy)) in mpt3sas_get_vphy_by_phy()
456 * _scsih_is_boot_device - search for matching boot device.
458 * @device_name: device name specified in INDENTIFY fram
461 * @form: specifies boot device form
462 * @boot_device: boot device object from bios page 2
478 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
485 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
491 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
501 * _scsih_get_sas_address - set the sas_address for given device handle
503 * @handle: device handle
506 * Return: 0 success, non-zero when failure
509 _scsih_get_sas_address(struct MPT3SAS_ADAPTER *ioc, u16 handle, in _scsih_get_sas_address() argument
519 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_get_sas_address()
522 return -ENXIO; in _scsih_get_sas_address()
530 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
533 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
539 /* we hit this because the given parent handle doesn't exist */ in _scsih_get_sas_address()
541 return -ENXIO; in _scsih_get_sas_address()
544 ioc_err(ioc, "handle(0x%04x), ioc_status(0x%04x), failure at %s:%d/%s()!\n", in _scsih_get_sas_address()
545 handle, ioc_status, __FILE__, __LINE__, __func__); in _scsih_get_sas_address()
546 return -EIO; in _scsih_get_sas_address()
550 * _scsih_determine_boot_device - determine boot device.
552 * @device: sas_device or pcie_device object
555 * Determines whether this device should be first reported device to
556 * to scsi-ml or sas transport, this purpose is for persistent boot device.
559 * the corresponding device object.
563 _scsih_determine_boot_device(struct MPT3SAS_ADAPTER *ioc, void *device, in _scsih_determine_boot_device() argument
575 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
579 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
583 raid_device = device; in _scsih_determine_boot_device()
584 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
589 pcie_device = device; in _scsih_determine_boot_device()
590 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
595 sas_device = device; in _scsih_determine_boot_device()
596 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
597 device_name = sas_device->device_name; in _scsih_determine_boot_device()
598 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
599 slot = sas_device->slot; in _scsih_determine_boot_device()
602 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
605 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
607 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
611 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
612 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
616 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
619 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
621 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
625 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
626 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
630 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
633 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
635 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
639 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
640 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
651 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
653 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
667 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
669 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
680 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
682 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
690 * mpt3sas_get_pdev_from_target - pcie device search
694 * Context: This function will acquire ioc->pcie_device_lock and will release
706 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
708 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
715 * __mpt3sas_get_sdev_by_rphy - sas device search
719 * Context: This function will acquire ioc->sas_device_lock and will release
731 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_rphy()
733 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_rphy()
734 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
741 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_rphy()
742 if (sas_device->rphy != rphy) in __mpt3sas_get_sdev_by_rphy()
752 * __mpt3sas_get_sdev_by_addr - get _sas_device object corresponding to provided
755 * @sas_address: device sas address
770 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
772 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in __mpt3sas_get_sdev_by_addr()
773 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
775 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
781 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) { in __mpt3sas_get_sdev_by_addr()
782 if (sas_device->sas_address != sas_address) in __mpt3sas_get_sdev_by_addr()
784 if (sas_device->port != port) in __mpt3sas_get_sdev_by_addr()
794 * mpt3sas_get_sdev_by_addr - sas device search
798 * Context: Calling function should acquire ioc->sas_device_lock
810 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
813 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
819 __mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in __mpt3sas_get_sdev_by_handle() argument
823 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
825 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
826 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
829 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
830 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
841 * mpt3sas_get_sdev_by_handle - sas device search
843 * @handle: sas device handle (assigned by firmware)
844 * Context: Calling function should acquire ioc->sas_device_lock
850 mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_get_sdev_by_handle() argument
855 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
856 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in mpt3sas_get_sdev_by_handle()
857 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
863 * _scsih_display_enclosure_chassis_info - display device location info
865 * @sas_device: per sas device object
866 * @sdev: scsi device struct
875 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
879 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
880 sas_device->slot); in _scsih_display_enclosure_chassis_info()
881 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
884 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
885 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
886 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
888 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
890 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
894 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
895 sas_device->slot); in _scsih_display_enclosure_chassis_info()
896 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
899 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
900 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
901 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
904 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
906 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
908 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
909 sas_device->slot); in _scsih_display_enclosure_chassis_info()
910 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
912 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
913 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
914 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
916 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
921 * _scsih_sas_device_remove - remove sas_device from list.
924 * Context: This function will acquire ioc->sas_device_lock.
936 ioc_info(ioc, "removing handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_sas_device_remove()
937 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
945 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
946 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
947 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
950 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
954 * _scsih_device_remove_by_handle - removing device object by handle
956 * @handle: device handle
959 _scsih_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_device_remove_by_handle() argument
964 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
967 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
968 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_device_remove_by_handle()
970 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
973 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
981 * mpt3sas_device_remove_by_sas_address - removing device object by
984 * @sas_address: device sas_address
996 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
999 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1002 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
1005 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
1013 * _scsih_sas_device_add - insert sas_device to the list.
1016 * Context: This function will acquire ioc->sas_device_lock.
1018 * Adding new object to the ioc->sas_device_list.
1027 ioc_info(ioc, "%s: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_sas_device_add()
1028 __func__, sas_device->handle, in _scsih_sas_device_add()
1029 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
1034 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1036 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
1037 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
1039 if (ioc->hide_drives) { in _scsih_sas_device_add()
1040 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1044 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
1045 sas_device->sas_address_parent, sas_device->port)) { in _scsih_sas_device_add()
1047 } else if (!sas_device->starget) { in _scsih_sas_device_add()
1051 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
1053 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
1055 sas_device->sas_address, in _scsih_sas_device_add()
1056 sas_device->sas_address_parent, in _scsih_sas_device_add()
1057 sas_device->port); in _scsih_sas_device_add()
1061 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
1065 * _scsih_sas_device_init_add - insert sas_device to the list.
1068 * Context: This function will acquire ioc->sas_device_lock.
1070 * Adding new object at driver load time to the ioc->sas_device_init_list.
1079 ioc_info(ioc, "%s: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_sas_device_init_add()
1080 __func__, sas_device->handle, in _scsih_sas_device_init_add()
1081 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
1086 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1088 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
1090 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
1099 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
1101 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
1102 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1105 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
1106 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
1118 * mpt3sas_get_pdev_by_wwid - pcie device search
1122 * Context: This function will acquire ioc->pcie_device_lock and will release
1133 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1135 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
1147 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
1149 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
1150 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1153 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
1154 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1165 __mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in __mpt3sas_get_pdev_by_handle() argument
1169 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1171 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1172 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1175 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1176 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1188 * mpt3sas_get_pdev_by_handle - pcie device search
1190 * @handle: Firmware device handle
1192 * Context: This function will acquire ioc->pcie_device_lock and will release
1195 * This searches for pcie_device based on handle, then return pcie_device
1199 mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_get_pdev_by_handle() argument
1204 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1205 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in mpt3sas_get_pdev_by_handle()
1206 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1212 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1214 * Context: This function will acquire ioc->pcie_device_lock
1216 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1227 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1228 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1229 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1230 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1232 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1235 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1236 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1240 * _scsih_pcie_device_remove - remove pcie_device from list.
1243 * Context: This function will acquire ioc->pcie_device_lock.
1257 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove()
1258 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1259 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1261 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1262 pcie_device->slot); in _scsih_pcie_device_remove()
1263 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1265 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1266 pcie_device->connector_name); in _scsih_pcie_device_remove()
1268 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1269 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1270 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1273 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1275 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1277 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1282 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove()
1292 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1294 * @handle: device handle
1297 _scsih_pcie_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_pcie_device_remove_by_handle() argument
1304 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1307 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1308 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in _scsih_pcie_device_remove_by_handle()
1310 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1311 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1315 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1318 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1325 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove_by_handle()
1334 * _scsih_pcie_device_add - add pcie_device object
1347 ioc_info(ioc, "%s: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_add()
1349 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1350 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1354 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1355 pcie_device->slot)); in _scsih_pcie_device_add()
1356 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1359 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1360 pcie_device->connector_name)); in _scsih_pcie_device_add()
1362 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1364 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1365 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1367 if (pcie_device->access_status == in _scsih_pcie_device_add()
1369 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1372 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1374 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1375 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1376 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1377 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1380 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1384 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1387 * Context: This function will acquire ioc->pcie_device_lock.
1389 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1398 ioc_info(ioc, "%s: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_init_add()
1400 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1401 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1405 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1406 pcie_device->slot)); in _scsih_pcie_device_init_add()
1407 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1410 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1411 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1413 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1415 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1416 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1419 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1422 * _scsih_raid_device_find_by_id - raid device search
1424 * @id: sas device target id
1425 * @channel: sas device channel
1426 * Context: Calling function should acquire ioc->raid_device_lock
1437 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1438 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1449 * mpt3sas_raid_device_find_by_handle - raid device search
1451 * @handle: sas device handle (assigned by firmware)
1452 * Context: Calling function should acquire ioc->raid_device_lock
1454 * This searches for raid_device based on handle, then return raid_device
1458 mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_raid_device_find_by_handle() argument
1463 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1464 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1475 * _scsih_raid_device_find_by_wwid - raid device search
1478 * Context: Calling function should acquire ioc->raid_device_lock
1489 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1490 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1501 * _scsih_raid_device_add - add raid_device object
1514 ioc_info(ioc, "%s: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_raid_device_add()
1516 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1518 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1519 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1520 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1524 * _scsih_raid_device_remove - delete raid_device object
1535 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1536 list_del(&raid_device->list); in _scsih_raid_device_remove()
1538 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1542 * mpt3sas_scsih_expander_find_by_handle - expander device search
1544 * @handle: expander handle (assigned by firmware)
1545 * Context: Calling function should acquire ioc->sas_device_lock
1547 * This searches for expander device based on handle, then returns the
1551 mpt3sas_scsih_expander_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_expander_find_by_handle() argument
1556 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1557 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1567 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1569 * @handle: enclosure handle (assigned by firmware)
1570 * Context: Calling function should acquire ioc->sas_device_lock
1572 * This searches for enclosure device based on handle, then returns the
1576 mpt3sas_scsih_enclosure_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_enclosure_find_by_handle() argument
1581 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1582 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1591 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1595 * Context: Calling function should acquire ioc->sas_node_lock.
1597 * This searches for expander device based on sas_address & port number,
1609 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1610 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1612 if (sas_expander->port != port) in mpt3sas_scsih_expander_find_by_sas_address()
1622 * _scsih_expander_node_add - insert expander device to the list.
1625 * Context: This function will acquire ioc->sas_node_lock.
1627 * Adding new object to the ioc->sas_expander_list.
1635 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1636 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1637 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1641 * _scsih_is_end_device - determines if device is an end device
1642 * @device_info: bitfield providing information about the device.
1645 * Return: 1 if end device.
1660 * _scsih_is_nvme_pciescsi_device - determines if
1661 * device is an pcie nvme/scsi device
1662 * @device_info: bitfield providing information about the device.
1665 * Returns 1 if device is pcie device type nvme/scsi.
1680 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1684 * Context: This function will acquire ioc->scsi_lookup_lock.
1697 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1701 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1702 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1709 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1714 * Context: This function will acquire ioc->scsi_lookup_lock.
1726 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1731 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1732 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1733 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1740 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1753 u16 tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1756 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1758 ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag; in mpt3sas_scsih_scsi_lookup_get()
1764 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1768 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1771 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1774 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1782 * scsih_change_queue_depth - setting device queue depth
1783 * @sdev: scsi device struct
1791 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1799 max_depth = shost->can_queue; in scsih_change_queue_depth()
1802 * limit max device queue for SATA to 32 if enable_sdev_max_qd in scsih_change_queue_depth()
1805 if (ioc->enable_sdev_max_qd || ioc->is_gen35_ioc) in scsih_change_queue_depth()
1808 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1811 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1814 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1817 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1820 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1825 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1829 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1836 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1837 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1838 return sdev->queue_depth; in scsih_change_queue_depth()
1842 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1843 * @sdev: scsi device struct
1851 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1854 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1855 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1861 * scsih_target_alloc - target add routine
1865 * the device is ignored.
1870 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1882 return -ENOMEM; in scsih_target_alloc()
1884 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1885 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1886 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1889 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1890 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1891 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1892 starget->channel); in scsih_target_alloc()
1894 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1895 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1896 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1897 if (ioc->is_warpdrive) in scsih_target_alloc()
1898 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1899 raid_device->starget = starget; in scsih_target_alloc()
1901 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1906 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1907 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1908 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1909 starget->channel); in scsih_target_alloc()
1911 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1912 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1913 sas_target_priv_data->port = NULL; in scsih_target_alloc()
1914 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1915 pcie_device->starget = starget; in scsih_target_alloc()
1916 pcie_device->id = starget->id; in scsih_target_alloc()
1917 pcie_device->channel = starget->channel; in scsih_target_alloc()
1918 sas_target_priv_data->flags |= in scsih_target_alloc()
1920 if (pcie_device->fast_path) in scsih_target_alloc()
1921 sas_target_priv_data->flags |= in scsih_target_alloc()
1924 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1929 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1930 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1934 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1935 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1936 sas_target_priv_data->port = sas_device->port; in scsih_target_alloc()
1937 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1938 sas_device->starget = starget; in scsih_target_alloc()
1939 sas_device->id = starget->id; in scsih_target_alloc()
1940 sas_device->channel = starget->channel; in scsih_target_alloc()
1941 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1942 sas_target_priv_data->flags |= in scsih_target_alloc()
1944 if (sas_device->fast_path) in scsih_target_alloc()
1945 sas_target_priv_data->flags |= in scsih_target_alloc()
1948 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1954 * scsih_target_destroy - target destroy routine
1960 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1968 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1972 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1973 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1974 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1975 starget->channel); in scsih_target_destroy()
1977 raid_device->starget = NULL; in scsih_target_destroy()
1978 raid_device->sdev = NULL; in scsih_target_destroy()
1980 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1984 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1985 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1988 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1989 (pcie_device->id == starget->id) && in scsih_target_destroy()
1990 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1991 pcie_device->starget = NULL; in scsih_target_destroy()
1997 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
2001 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
2005 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2007 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
2008 (sas_device->id == starget->id) && in scsih_target_destroy()
2009 (sas_device->channel == starget->channel)) in scsih_target_destroy()
2010 sas_device->starget = NULL; in scsih_target_destroy()
2016 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
2021 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
2025 starget->hostdata = NULL; in scsih_target_destroy()
2029 * scsih_slave_alloc - device add routine
2030 * @sdev: scsi device struct
2033 * the device is ignored.
2051 return -ENOMEM; in scsih_slave_alloc()
2053 sas_device_priv_data->lun = sdev->lun; in scsih_slave_alloc()
2054 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_slave_alloc()
2057 sas_target_priv_data = starget->hostdata; in scsih_slave_alloc()
2058 sas_target_priv_data->num_luns++; in scsih_slave_alloc()
2059 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_slave_alloc()
2060 sdev->hostdata = sas_device_priv_data; in scsih_slave_alloc()
2061 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_slave_alloc()
2062 sdev->no_uld_attach = 1; in scsih_slave_alloc()
2064 shost = dev_to_shost(&starget->dev); in scsih_slave_alloc()
2066 if (starget->channel == RAID_CHANNEL) { in scsih_slave_alloc()
2067 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2069 starget->id, starget->channel); in scsih_slave_alloc()
2071 raid_device->sdev = sdev; /* raid is single lun */ in scsih_slave_alloc()
2072 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
2074 if (starget->channel == PCIE_CHANNEL) { in scsih_slave_alloc()
2075 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2077 sas_target_priv_data->sas_address); in scsih_slave_alloc()
2078 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_slave_alloc()
2080 "%s : pcie_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2082 pcie_device->starget = starget; in scsih_slave_alloc()
2087 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
2089 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_alloc()
2090 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2092 sas_target_priv_data->sas_address, in scsih_slave_alloc()
2093 sas_target_priv_data->port); in scsih_slave_alloc()
2094 if (sas_device && (sas_device->starget == NULL)) { in scsih_slave_alloc()
2096 "%s : sas_device->starget set to starget @ %d\n", in scsih_slave_alloc()
2098 sas_device->starget = starget; in scsih_slave_alloc()
2104 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
2111 * scsih_slave_destroy - device destroy routine
2112 * @sdev: scsi device struct
2125 if (!sdev->hostdata) in scsih_slave_destroy()
2129 sas_target_priv_data = starget->hostdata; in scsih_slave_destroy()
2130 sas_target_priv_data->num_luns--; in scsih_slave_destroy()
2132 shost = dev_to_shost(&starget->dev); in scsih_slave_destroy()
2135 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_destroy()
2136 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2139 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2140 pcie_device->starget = NULL; in scsih_slave_destroy()
2145 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
2147 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_destroy()
2148 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2151 if (sas_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
2152 sas_device->starget = NULL; in scsih_slave_destroy()
2156 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
2159 kfree(sdev->hostdata); in scsih_slave_destroy()
2160 sdev->hostdata = NULL; in scsih_slave_destroy()
2164 * _scsih_display_sata_capabilities - sata capabilities
2166 * @handle: device handle
2167 * @sdev: scsi device struct
2171 u16 handle, struct scsi_device *sdev) in _scsih_display_sata_capabilities() argument
2180 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_display_sata_capabilities()
2210 * raid transport support -
2212 * unloading the driver followed by a load - I believe that the subroutine
2217 * scsih_is_raid - return boolean indicating device is raid volume
2218 * @dev: the device struct object
2221 scsih_is_raid(struct device *dev) in scsih_is_raid()
2224 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2226 if (ioc->is_warpdrive) in scsih_is_raid()
2228 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2232 scsih_is_nvme(struct device *dev) in scsih_is_nvme()
2236 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2240 * scsih_get_resync - get raid volume resync percent complete
2241 * @dev: the device struct object
2244 scsih_get_resync(struct device *dev) in scsih_get_resync()
2247 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2254 u16 handle; in scsih_get_resync() local
2257 handle = 0; in scsih_get_resync()
2258 if (ioc->is_warpdrive) in scsih_get_resync()
2261 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2262 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2263 sdev->channel); in scsih_get_resync()
2265 handle = raid_device->handle; in scsih_get_resync()
2266 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2268 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2270 if (!handle) in scsih_get_resync()
2274 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in scsih_get_resync()
2289 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2301 * scsih_get_state - get raid volume level
2302 * @dev: the device struct object
2305 scsih_get_state(struct device *dev) in scsih_get_state()
2308 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2315 u16 handle = 0; in scsih_get_state() local
2317 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2318 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2319 sdev->channel); in scsih_get_state()
2321 handle = raid_device->handle; in scsih_get_state()
2322 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2328 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in scsih_get_state()
2355 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2367 * _scsih_set_level - set raid level
2369 * @sdev: scsi device struct
2393 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2396 &sdev->sdev_gendev, level); in _scsih_set_level()
2401 &sdev->sdev_gendev, level); in _scsih_set_level()
2408 * _scsih_get_volume_capabilities - volume capabilities
2425 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2433 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2445 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2453 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2456 * obtaining the device_info bits for the 1st device in _scsih_get_volume_capabilities()
2460 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2464 raid_device->device_info = in _scsih_get_volume_capabilities()
2474 * _scsih_enable_tlr - setting TLR flags
2476 * @sdev: scsi device struct
2487 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2490 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2501 * scsih_slave_configure - device configure routine.
2502 * @sdev: scsi device struct
2505 * the device is ignored.
2510 struct Scsi_Host *shost = sdev->host; in scsih_slave_configure()
2522 u16 handle, volume_handle = 0; in scsih_slave_configure() local
2526 sas_device_priv_data = sdev->hostdata; in scsih_slave_configure()
2527 sas_device_priv_data->configured_lun = 1; in scsih_slave_configure()
2528 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_slave_configure()
2529 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_slave_configure()
2530 handle = sas_target_priv_data->handle; in scsih_slave_configure()
2533 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_slave_configure()
2535 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2536 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in scsih_slave_configure()
2537 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2562 if (raid_device->device_info & in scsih_slave_configure()
2568 if (raid_device->device_info & in scsih_slave_configure()
2575 switch (raid_device->volume_type) { in scsih_slave_configure()
2581 if (ioc->manu_pg10.OEMIdentifier && in scsih_slave_configure()
2582 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_slave_configure()
2584 !(raid_device->num_pds % 2)) in scsih_slave_configure()
2604 if (!ioc->hide_ir_msg) in scsih_slave_configure()
2606 "%s: handle(0x%04x), wwid(0x%016llx)," in scsih_slave_configure()
2608 r_level, raid_device->handle, in scsih_slave_configure()
2609 (unsigned long long)raid_device->wwid, in scsih_slave_configure()
2610 raid_device->num_pds, ds); in scsih_slave_configure()
2612 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_slave_configure()
2613 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2623 if (!ioc->is_warpdrive) in scsih_slave_configure()
2624 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_slave_configure()
2628 /* non-raid handling */ in scsih_slave_configure()
2629 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_slave_configure()
2630 if (mpt3sas_config_get_volume_handle(ioc, handle, in scsih_slave_configure()
2647 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_configure()
2648 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2650 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2652 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2659 qdepth = ioc->max_nvme_qd; in scsih_slave_configure()
2662 "%s: handle(0x%04x), wwid(0x%016llx), port(%d)\n", in scsih_slave_configure()
2663 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_slave_configure()
2664 pcie_device->port_num); in scsih_slave_configure()
2665 if (pcie_device->enclosure_handle != 0) in scsih_slave_configure()
2669 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_slave_configure()
2670 pcie_device->slot); in scsih_slave_configure()
2671 if (pcie_device->connector_name[0] != '\0') in scsih_slave_configure()
2675 pcie_device->enclosure_level, in scsih_slave_configure()
2676 pcie_device->connector_name); in scsih_slave_configure()
2678 if (pcie_device->nvme_mdts) in scsih_slave_configure()
2679 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2680 pcie_device->nvme_mdts/512); in scsih_slave_configure()
2683 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2690 sdev->request_queue); in scsih_slave_configure()
2691 blk_queue_virt_boundary(sdev->request_queue, in scsih_slave_configure()
2692 ioc->page_size - 1); in scsih_slave_configure()
2696 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2698 sas_device_priv_data->sas_target->sas_address, in scsih_slave_configure()
2699 sas_device_priv_data->sas_target->port); in scsih_slave_configure()
2701 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2708 sas_device->volume_handle = volume_handle; in scsih_slave_configure()
2709 sas_device->volume_wwid = volume_wwid; in scsih_slave_configure()
2710 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_slave_configure()
2711 qdepth = (sas_device->port_type > 1) ? in scsih_slave_configure()
2712 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_slave_configure()
2714 if (sas_device->device_info & in scsih_slave_configure()
2717 "set ignore_delay_remove for handle(0x%04x)\n", in scsih_slave_configure()
2718 sas_device_priv_data->sas_target->handle); in scsih_slave_configure()
2719 sas_device_priv_data->ignore_delay_remove = 1; in scsih_slave_configure()
2724 qdepth = ioc->max_sata_qd; in scsih_slave_configure()
2725 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_slave_configure()
2727 else if (sas_device->device_info & in scsih_slave_configure()
2732 sdev_printk(KERN_INFO, sdev, "%s: handle(0x%04x), " \ in scsih_slave_configure()
2734 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_slave_configure()
2735 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_slave_configure()
2740 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2743 _scsih_display_sata_capabilities(ioc, handle, sdev); in scsih_slave_configure()
2757 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2758 * @sdev: scsi device struct
2759 * @bdev: pointer to block device context
2760 * @capacity: device size (in 512 byte sectors)
2783 * Handle extended translation size for logical drives in scsih_bios_param()
2803 * _scsih_response_code - translation of device response code
2805 * @response_code: response code returned by the device
2845 * _scsih_tm_done - tm completion routine
2862 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2864 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2866 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2869 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2870 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2872 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2873 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2878 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2880 * @handle: device handle
2882 * During taskmangement request, we need to freeze the device queue.
2885 mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_set_tm_flag() argument
2891 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2894 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2897 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2898 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2900 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2906 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2908 * @handle: device handle
2910 * During taskmangement request, we need to freeze the device queue.
2913 mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_clear_tm_flag() argument
2919 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2922 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2925 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2926 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2928 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2934 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2950 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2966 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2967 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2968 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2970 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2971 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2972 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2980 * scsih_tm_post_processing - post processing of target & LUN reset
2982 * @handle: device handle
2997 scsih_tm_post_processing(struct MPT3SAS_ADAPTER *ioc, u16 handle, in scsih_tm_post_processing() argument
3008 " smid(%d), task_type(0x%02x), handle(0x%04x)\n", in scsih_tm_post_processing()
3009 smid_task, type, handle); in scsih_tm_post_processing()
3024 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3026 * @handle: device handle
3039 * The callback index is set inside `ioc->tm_cb_idx`.
3045 mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, in mpt3sas_scsih_issue_tm() argument
3057 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3059 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3064 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3065 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3090 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3097 …ioc_info(ioc, "sending tm: handle(0x%04x), task_type(0x%02x), smid(%d), timeout(%d), tr_method(0x%… in mpt3sas_scsih_issue_tm()
3098 handle, type, smid_task, timeout, tr_method)); in mpt3sas_scsih_issue_tm()
3099 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3101 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3103 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3104 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3105 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3106 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3109 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3110 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3111 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3112 mpt3sas_scsih_set_tm_flag(ioc, handle); in mpt3sas_scsih_issue_tm()
3113 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3114 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3115 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3116 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3118 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3131 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3133 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3136 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3137 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3138 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3139 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3140 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3141 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3152 * doesn't match with device handle on which this task abort in mpt3sas_scsih_issue_tm()
3162 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3165 ioc_info(ioc, "Task abort tm failed: handle(0x%04x)," in mpt3sas_scsih_issue_tm()
3167 handle, timeout, tr_method, smid_task, msix_task); in mpt3sas_scsih_issue_tm()
3174 rc = scsih_tm_post_processing(ioc, handle, channel, id, lun, in mpt3sas_scsih_issue_tm()
3186 mpt3sas_scsih_clear_tm_flag(ioc, handle); in mpt3sas_scsih_issue_tm()
3187 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3191 int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, in mpt3sas_scsih_issue_locked_tm() argument
3197 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3198 ret = mpt3sas_scsih_issue_tm(ioc, handle, channel, id, lun, type, in mpt3sas_scsih_issue_locked_tm()
3200 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3206 * _scsih_tm_display_info - displays info about the device
3215 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3216 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3224 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3230 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3232 "%s handle(0x%04x), %s wwid(0x%016llx)\n", in _scsih_tm_display_info()
3233 device_str, priv_target->handle, in _scsih_tm_display_info()
3234 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3236 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3237 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3241 "handle(0x%04x), wwid(0x%016llx), port(%d)\n", in _scsih_tm_display_info()
3242 pcie_device->handle, in _scsih_tm_display_info()
3243 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3244 pcie_device->port_num); in _scsih_tm_display_info()
3245 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3249 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3250 pcie_device->slot); in _scsih_tm_display_info()
3251 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3254 pcie_device->enclosure_level, in _scsih_tm_display_info()
3255 pcie_device->connector_name); in _scsih_tm_display_info()
3258 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3261 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3264 if (priv_target->flags & in _scsih_tm_display_info()
3267 "volume handle(0x%04x), " in _scsih_tm_display_info()
3269 sas_device->volume_handle, in _scsih_tm_display_info()
3270 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3273 "handle(0x%04x), sas_address(0x%016llx), phy(%d)\n", in _scsih_tm_display_info()
3274 sas_device->handle, in _scsih_tm_display_info()
3275 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3276 sas_device->phy); in _scsih_tm_display_info()
3283 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3288 * scsih_abort - eh threads main abort routine
3296 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3299 u16 handle; in scsih_abort() local
3304 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3306 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3307 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3310 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3311 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3312 ioc->remove_host) { in scsih_abort()
3313 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3314 "device been deleted! scmd(0x%p)\n", scmd); in scsih_abort()
3315 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3322 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3323 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3325 scmd->result = DID_RESET << 16; in scsih_abort()
3331 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3333 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3334 scmd->result = DID_RESET << 16; in scsih_abort()
3341 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3342 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_abort()
3343 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3344 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3345 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3346 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3347 scmd->device->id, scmd->device->lun, in scsih_abort()
3349 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3351 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3354 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3362 * scsih_dev_reset - eh threads main device reset routine
3370 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3374 u16 handle; in scsih_dev_reset() local
3379 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3380 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3382 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3383 "attempting device reset! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3386 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3387 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3388 ioc->remove_host) { in scsih_dev_reset()
3389 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3390 "device been deleted! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3391 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3398 handle = 0; in scsih_dev_reset()
3399 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3404 handle = sas_device->volume_handle; in scsih_dev_reset()
3406 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3408 if (!handle) { in scsih_dev_reset()
3409 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3414 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_dev_reset()
3416 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3417 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3418 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3423 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3424 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3428 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3431 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3443 * scsih_target_reset - eh threads main target reset routine
3451 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3455 u16 handle; in scsih_target_reset() local
3459 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3460 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3466 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3467 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3468 ioc->remove_host) { in scsih_target_reset()
3471 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3478 handle = 0; in scsih_target_reset()
3479 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3484 handle = sas_device->volume_handle; in scsih_target_reset()
3486 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3488 if (!handle) { in scsih_target_reset()
3489 scmd->result = DID_RESET << 16; in scsih_target_reset()
3494 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_target_reset()
3496 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3497 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3498 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3502 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3503 scmd->device->id, 0, in scsih_target_reset()
3507 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3522 * scsih_host_reset - eh threads main host reset routine
3530 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3536 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3552 * _scsih_fw_event_add - insert and queue up fw_event
3555 * Context: This function will acquire ioc->fw_event_lock.
3565 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3568 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3570 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3571 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3572 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3574 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3575 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3579 * _scsih_fw_event_del_from_list - delete fw_event from the list
3582 * Context: This function will acquire ioc->fw_event_lock.
3592 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3593 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3594 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3597 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3602 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3613 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3619 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3620 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3621 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3627 * _scsih_error_recovery_delete_devices - remove devices not responding
3638 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3639 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3645 * mpt3sas_port_enable_complete - port enable completed (fake event)
3656 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3657 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3667 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3668 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3669 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3671 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3674 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3680 * _scsih_fw_event_cleanup_queue - cleanup event queue
3693 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3694 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3702 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3703 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3705 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3707 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3723 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3724 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3726 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3731 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3738 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3739 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3740 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3751 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3755 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3759 * _scsih_internal_device_block - block the sdev device
3760 * @sdev: per device object
3761 * @sas_device_priv_data : per device driver private data
3763 * make sure device is blocked without error, if not
3772 sdev_printk(KERN_INFO, sdev, "device_block, handle(0x%04x)\n", in _scsih_internal_device_block()
3773 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3774 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3777 if (r == -EINVAL) in _scsih_internal_device_block()
3779 "device_block failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_block()
3780 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3784 * _scsih_internal_device_unblock - unblock the sdev device
3785 * @sdev: per device object
3786 * @sas_device_priv_data : per device driver private data
3787 * make sure device is unblocked without error, if not retry
3798 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3799 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3801 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3802 /* The device has been set to SDEV_RUNNING by SD layer during in _scsih_internal_device_unblock()
3803 * device addition but the request queue is still stopped by in _scsih_internal_device_unblock()
3805 * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */ in _scsih_internal_device_unblock()
3808 "device_unblock failed with return(%d) for handle(0x%04x) " in _scsih_internal_device_unblock()
3810 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3811 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3815 "failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_unblock()
3816 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3818 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3822 " failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_unblock()
3823 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3828 * _scsih_ublock_io_all_device - unblock every device
3831 * change the device state from block to running
3839 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3840 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3843 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3847 "device_running, handle(0x%04x)\n", in _scsih_ublock_io_all_device()
3848 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3855 * _scsih_ublock_io_device - prepare device to be deleted
3860 * unblock then put device in offline state
3869 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3870 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3871 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3873 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3876 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3878 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3885 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3888 * During device pull we need to appropriately set the sdev state.
3896 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3897 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3900 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3902 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3904 "%s skip device_block for SES handle(0x%04x)\n", in _scsih_block_io_all_device()
3905 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3913 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3915 * @handle: device handle
3917 * During device pull we need to appropriately set the sdev state.
3920 _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_block_io_device() argument
3926 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_block_io_device()
3928 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3929 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3932 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3934 if (sas_device_priv_data->block) in _scsih_block_io_device()
3936 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3938 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3940 "%s skip device_block for SES handle(0x%04x)\n", in _scsih_block_io_device()
3941 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3973 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3974 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3976 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3978 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3979 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3981 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3982 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3985 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3990 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3992 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3994 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3998 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3999 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
4012 * direct attached during device pull.
4019 u16 handle; in _scsih_block_io_to_children_attached_directly() local
4022 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4023 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4024 if (!handle) in _scsih_block_io_to_children_attached_directly()
4026 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4029 _scsih_block_io_device(ioc, handle); in _scsih_block_io_to_children_attached_directly()
4039 * direct attached during device pull/reconnect.
4046 u16 handle; in _scsih_block_io_to_pcie_children_attached_directly() local
4049 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4050 handle = in _scsih_block_io_to_pcie_children_attached_directly()
4051 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4052 if (!handle) in _scsih_block_io_to_pcie_children_attached_directly()
4054 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4057 _scsih_block_io_device(ioc, handle); in _scsih_block_io_to_pcie_children_attached_directly()
4061 * _scsih_tm_tr_send - send task management request
4063 * @handle: device handle
4066 * This code is to initiate the device removal handshake protocol
4076 _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_tm_tr_send() argument
4090 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4092 ioc_info(ioc, "%s: host in pci error recovery: handle(0x%04x)\n", in _scsih_tm_tr_send()
4093 __func__, handle)); in _scsih_tm_tr_send()
4099 ioc_info(ioc, "%s: host is not operational: handle(0x%04x)\n", in _scsih_tm_tr_send()
4100 __func__, handle)); in _scsih_tm_tr_send()
4105 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4108 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4110 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4111 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_tm_tr_send()
4112 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4113 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4114 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4115 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4116 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4117 port = sas_device->port; in _scsih_tm_tr_send()
4119 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4121 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4122 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in _scsih_tm_tr_send()
4123 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4124 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4125 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4126 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4127 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4129 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4130 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4132 pcie_device->device_info)))) in _scsih_tm_tr_send()
4140 ioc_info(ioc, "setting delete flag: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_tm_tr_send()
4141 handle, (u64)sas_address)); in _scsih_tm_tr_send()
4143 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4146 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4147 sas_device->slot)); in _scsih_tm_tr_send()
4148 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4151 sas_device->enclosure_level, in _scsih_tm_tr_send()
4152 sas_device->connector_name)); in _scsih_tm_tr_send()
4154 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4157 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4158 pcie_device->slot)); in _scsih_tm_tr_send()
4159 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4162 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4163 pcie_device->connector_name)); in _scsih_tm_tr_send()
4166 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4169 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4174 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4175 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4176 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4178 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_tm_tr_send()
4179 handle)); in _scsih_tm_tr_send()
4184 ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_send()
4185 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4188 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4189 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4190 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4191 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4192 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4193 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4204 * _scsih_tm_tr_complete -
4212 * This code is part of the code to initiate the device removal
4223 u16 handle; in _scsih_tm_tr_complete() local
4232 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4251 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4252 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4254 ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n", in _scsih_tm_tr_complete()
4255 handle, in _scsih_tm_tr_complete()
4256 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4262 …ioc_info(ioc, "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x), c… in _scsih_tm_tr_complete()
4263 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4264 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4265 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4267 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4272 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4273 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4274 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4276 ioc_info(ioc, "DELAYED:sc:handle(0x%04x), (open)\n", in _scsih_tm_tr_complete()
4277 handle)); in _scsih_tm_tr_complete()
4282 ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_complete()
4283 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4286 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4287 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4288 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4289 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4294 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4305 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4308 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4309 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4315 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4317 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4330 * _scsih_sas_control_complete - completion routine
4338 * This code is part of the code to initiate the device removal
4353 …ioc_info(ioc, "sc_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_sas_control_complete()
4354 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4355 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4356 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4357 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4359 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4360 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4370 * _scsih_tm_tr_volume_send - send target reset request for volumes
4372 * @handle: device handle
4380 _scsih_tm_tr_volume_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_tm_tr_volume_send() argument
4386 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4393 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4398 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4399 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4400 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4402 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_tm_tr_volume_send()
4403 handle)); in _scsih_tm_tr_volume_send()
4408 ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_volume_send()
4409 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4412 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4413 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4414 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4415 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4419 * _scsih_tm_volume_tr_complete - target reset completion
4433 u16 handle; in _scsih_tm_volume_tr_complete() local
4438 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4451 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4452 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4454 ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n", in _scsih_tm_volume_tr_complete()
4455 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4461 …ioc_info(ioc, "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x), c… in _scsih_tm_volume_tr_complete()
4462 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4463 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4464 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4470 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4476 * Context - processed in interrupt context.
4483 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4490 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4491 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4492 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4496 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4499 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4500 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4501 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4502 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4503 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4504 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4508 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4512 * @handle: device handle
4514 * Context - processed in interrupt context.
4518 u16 smid, u16 handle) in _scsih_issue_delayed_sas_io_unit_ctrl() argument
4522 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4525 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4530 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4548 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4549 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4550 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4553 ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_issue_delayed_sas_io_unit_ctrl()
4554 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4557 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4558 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4559 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4560 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4564 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4582 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4583 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4586 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4587 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4592 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4593 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4596 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4597 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4605 * _scsih_check_for_pending_tm - check for pending task management
4620 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4621 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4624 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4625 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4630 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4631 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4634 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4635 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4644 * _scsih_check_topo_delete_events - sanity check on topo events
4648 * This routine added to better handle cable breaker.
4664 u16 handle; in _scsih_check_topo_delete_events() local
4666 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4667 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4668 if (!handle) in _scsih_check_topo_delete_events()
4670 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4673 _scsih_tm_tr_send(ioc, handle); in _scsih_check_topo_delete_events()
4676 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4677 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4681 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4684 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4688 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4690 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4691 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4692 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4693 _scsih_block_io_device(ioc, handle); in _scsih_check_topo_delete_events()
4694 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4695 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4698 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4702 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4703 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4704 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4705 fw_event->ignore) in _scsih_check_topo_delete_events()
4708 fw_event->event_data; in _scsih_check_topo_delete_events()
4709 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4711 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4713 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4717 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4721 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4725 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4731 * or device add and delete events in a single shot. When there
4743 u16 handle, switch_handle; in _scsih_check_pcie_topo_remove_events() local
4745 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4746 handle = in _scsih_check_pcie_topo_remove_events()
4747 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4748 if (!handle) in _scsih_check_pcie_topo_remove_events()
4750 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4752 _scsih_tm_tr_send(ioc, handle); in _scsih_check_pcie_topo_remove_events()
4755 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4762 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4764 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4769 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4773 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4774 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4775 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4776 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4780 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4781 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4783 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4785 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4789 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4793 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4797 * _scsih_set_volume_delete_flag - setting volume delete flag
4799 * @handle: device handle
4804 _scsih_set_volume_delete_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_set_volume_delete_flag() argument
4810 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4811 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_set_volume_delete_flag()
4812 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4813 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4815 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4816 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4818 ioc_info(ioc, "setting delete flag: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_set_volume_delete_flag()
4819 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4821 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4825 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4826 * @handle: input handle
4827 * @a: handle for volume a
4828 * @b: handle for volume b
4831 * routine is to set the volume handle in either a or b. When the given
4832 * input handle is non-zero, or when a and b have not been set before.
4835 _scsih_set_volume_handle_for_tr(u16 handle, u16 *a, u16 *b) in _scsih_set_volume_handle_for_tr() argument
4837 if (!handle || handle == *a || handle == *b) in _scsih_set_volume_handle_for_tr()
4840 *a = handle; in _scsih_set_volume_handle_for_tr()
4842 *b = handle; in _scsih_set_volume_handle_for_tr()
4846 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4863 u16 handle, volume_handle, a, b; in _scsih_check_ir_config_unhide_events() local
4869 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4873 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4874 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4875 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4878 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4880 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4882 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4889 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4890 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4891 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4894 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4895 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4906 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4907 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4908 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4910 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4911 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4912 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4914 _scsih_tm_tr_send(ioc, handle); in _scsih_check_ir_config_unhide_events()
4918 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4919 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4920 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4922 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_check_ir_config_unhide_events()
4923 handle)); in _scsih_check_ir_config_unhide_events()
4925 _scsih_tm_tr_send(ioc, handle); in _scsih_check_ir_config_unhide_events()
4931 * _scsih_check_volume_delete_events - set delete flag for volumes
4936 * This will handle the case when the cable connected to entire volume is
4946 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4948 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4952 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4956 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4966 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4968 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4969 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4970 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4971 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4972 event_data->SensorNum); in _scsih_temp_threshold_events()
4974 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4975 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4992 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4994 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4998 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5000 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
5005 * _scsih_flush_running_cmds - completing outstanding commands.
5019 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5028 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5029 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5031 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5038 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5064 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5067 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5070 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5073 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5077 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5079 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5081 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5085 * _scsih_eedp_error_handling - return sense code for EEDP errors
5113 * scsih_qcmd - main scsi request entry point
5117 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5120 * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
5136 u16 handle; in scsih_qcmd() local
5138 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5141 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5142 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5143 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5149 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5154 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5156 /* invalid device handle */ in scsih_qcmd()
5157 handle = sas_target_priv_data->handle; in scsih_qcmd()
5160 * Avoid error handling escallation when device is disconnected in scsih_qcmd()
5162 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5163 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5164 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5171 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) { in scsih_qcmd()
5172 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5178 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5181 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5182 /* device has been deleted */ in scsih_qcmd()
5183 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5186 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5187 sas_device_priv_data->block) { in scsih_qcmd()
5188 /* device busy with task management */ in scsih_qcmd()
5198 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5202 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5204 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5212 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5217 /* Make sure Device is not raid volume. in scsih_qcmd()
5220 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5221 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5222 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5225 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5232 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5235 if (scmd->cmd_len == 32) in scsih_qcmd()
5237 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5238 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5240 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5242 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5243 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5244 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5245 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5246 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5247 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5248 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5249 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5251 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5252 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5253 mpi_request->LUN); in scsih_qcmd()
5254 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5256 if (mpi_request->DataLength) { in scsih_qcmd()
5257 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5258 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5264 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5266 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5267 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5271 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5272 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5273 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5275 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5277 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5278 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5280 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5288 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5297 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5298 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5299 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5302 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5303 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5304 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5309 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5315 * scsi_status - SCSI Status code returned from target device
5316 * scsi_state - state info associated with SCSI_IO determined by ioc
5317 * ioc_status - ioc supplied status info
5325 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5327 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5328 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5331 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5332 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5335 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5336 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5341 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5360 desc_ioc_state = "scsi invalid dev handle"; in _scsih_scsi_ioc_info()
5363 desc_ioc_state = "scsi device not there"; in _scsih_scsi_ioc_info()
5464 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5466 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5467 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5471 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5472 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5474 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5475 pcie_device->slot); in _scsih_scsi_ioc_info()
5476 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5478 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5479 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5486 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5496 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5499 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5500 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5501 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5502 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5508 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5511 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5514 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5521 * _scsih_turn_on_pfa_led - illuminate PFA LED
5523 * @handle: device handle
5527 _scsih_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_turn_on_pfa_led() argument
5533 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_turn_on_pfa_led()
5542 mpi_request.DevHandle = cpu_to_le16(handle); in _scsih_turn_on_pfa_led()
5550 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5564 * _scsih_turn_off_pfa_led - turn off Fault LED
5566 * @sas_device: sas device whose PFA LED has to turned off
5580 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5582 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5601 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5603 * @handle: device handle
5607 _scsih_send_event_to_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_send_event_to_turn_on_pfa_led() argument
5614 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5615 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5616 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5622 * _scsih_smart_predicted_fault - process smart errors
5624 * @handle: device handle
5628 _scsih_smart_predicted_fault(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_smart_predicted_fault() argument
5638 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5639 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5640 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_smart_predicted_fault()
5644 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5645 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5647 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5648 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5653 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5655 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5656 _scsih_send_event_to_turn_on_pfa_led(ioc, handle); in _scsih_smart_predicted_fault()
5668 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5669 event_reply->Event = in _scsih_smart_predicted_fault()
5671 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5672 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5675 event_reply->EventData; in _scsih_smart_predicted_fault()
5676 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5677 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5678 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5679 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5688 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5693 * _scsih_io_done - scsi request callback
5730 scmd->result = DID_OK << 16; in _scsih_io_done()
5734 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5735 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5736 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5737 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5740 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5747 if (st->direct_io && in _scsih_io_done()
5750 st->direct_io = 0; in _scsih_io_done()
5751 st->scmd = scmd; in _scsih_io_done()
5752 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5753 mpi_request->DevHandle = in _scsih_io_done()
5754 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5755 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5756 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5760 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5763 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5764 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5765 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5766 if ((!ioc->is_warpdrive && in _scsih_io_done()
5767 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5768 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5769 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5771 sas_disable_tlr(scmd->device); in _scsih_io_done()
5772 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5776 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5777 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5779 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5783 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5797 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5798 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5799 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5803 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5806 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5807 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5808 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5809 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5815 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5819 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5823 if (sas_device_priv_data->block) { in _scsih_io_done()
5824 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5828 if (scmd->retries > 2) { in _scsih_io_done()
5829 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5830 scsi_device_set_state(scmd->device, in _scsih_io_done()
5833 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5834 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5838 scmd->result = DID_RESET << 16; in _scsih_io_done()
5840 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5843 scmd->result = DID_RESET << 16; in _scsih_io_done()
5846 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5850 scmd->result = DID_RESET << 16; in _scsih_io_done()
5854 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5855 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5857 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5861 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5866 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5868 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5870 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5873 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5875 scmd->result = DID_RESET << 16; in _scsih_io_done()
5876 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5877 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5878 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5889 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5894 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5896 scmd->result = DID_RESET << 16; in _scsih_io_done()
5915 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5920 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5932 * _scsih_update_vphys_after_reset - update the Port's
5957 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5958 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5961 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5962 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5970 (ioc->sas_hba.num_phys * sizeof(Mpi2SasIOUnit0PhyData_t)); in _scsih_update_vphys_after_reset()
5986 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5990 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
5994 * Check whether Phy is connected to SEP device or not, in _scsih_update_vphys_after_reset()
5995 * if it is SEP device then read the Phy's SASPHYPage0 data to in _scsih_update_vphys_after_reset()
5998 * device is a HBA's vSES device. in _scsih_update_vphys_after_reset()
6001 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6016 * Get the vSES device's SAS Address. in _scsih_update_vphys_after_reset()
6019 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6034 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6035 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6038 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6043 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6049 * to current Phy's vSES device SAS Address. in _scsih_update_vphys_after_reset()
6051 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6057 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6058 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6066 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6073 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6076 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6077 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6078 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6083 * device's Port ID got changed after reset and in _scsih_update_vphys_after_reset()
6088 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6090 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6091 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6092 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6093 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6094 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6098 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6103 * direct attached device with mport's Port ID, in _scsih_update_vphys_after_reset()
6105 * device has this Port ID, so unmark the mport in _scsih_update_vphys_after_reset()
6108 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6109 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6110 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6111 mport->flags &= in _scsih_update_vphys_after_reset()
6117 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6130 * _scsih_get_port_table_after_reset - Construct temporary port table
6148 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_get_port_table_after_reset()
6163 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6165 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6169 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6178 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6190 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6210 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6230 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6231 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6234 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6235 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6241 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6242 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6243 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6249 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6250 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6259 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6278 * _scsih_del_phy_part_of_anther_port - remove phy if it
6292 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6301 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6311 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6326 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6328 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6330 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6338 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6340 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6342 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6343 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6350 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6362 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6363 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6366 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6367 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6370 vphy, port->port_id, in _scsih_del_dirty_vphy()
6371 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6372 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6373 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6377 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6378 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6383 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6394 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6395 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6396 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6401 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6402 list_del(&port->list); in _scsih_del_dirty_port_entries()
6408 * _scsih_sas_port_refresh - Update HBA port table after host reset
6425 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6434 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6439 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6441 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6457 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6458 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6462 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6465 port_table_entry->port_id, in _scsih_sas_port_refresh()
6466 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6467 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6504 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6505 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6506 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6507 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6514 * _scsih_alloc_vphy - allocate virtual_phy object
6537 if (!port->vphys_mask) in _scsih_alloc_vphy()
6538 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6544 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6545 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6547 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6551 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6557 * _scsih_sas_host_refresh - refreshing sas host object contents
6561 * During port enable, fw will send topology events for every device. Its
6580 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6582 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_sas_host_refresh()
6597 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6598 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6600 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6601 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6602 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6608 port->port_id = port_id; in _scsih_sas_host_refresh()
6611 port, port->port_id); in _scsih_sas_host_refresh()
6612 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6613 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6614 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6617 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_refresh()
6619 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6633 * Allocate a virtual_phy object for vSES device, if in _scsih_sas_host_refresh()
6634 * this vSES device is hot added. in _scsih_sas_host_refresh()
6638 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6645 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6659 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6661 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6662 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6665 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6666 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6670 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6672 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6674 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6680 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6681 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6682 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6683 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6686 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6694 * _scsih_sas_host_add - create sas host object
6697 * Creating host side data object, stored in ioc->sas_hba
6722 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6724 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6726 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6731 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6734 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6757 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
6779 ioc->io_missing_delay = in _scsih_sas_host_add()
6780 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6782 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6784 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6787 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6790 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6791 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6807 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6810 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6816 port->port_id = port_id; in _scsih_sas_host_add()
6819 port, port->port_id); in _scsih_sas_host_add()
6820 list_add_tail(&port->list, in _scsih_sas_host_add()
6821 &ioc->port_table_list); in _scsih_sas_host_add()
6825 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_add()
6832 * Allocate a virtual_phy object for vSES device. in _scsih_sas_host_add()
6836 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6839 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6840 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6841 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6843 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6844 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6847 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6852 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6854 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6855 ioc_info(ioc, "host_add: handle(0x%04x), sas_addr(0x%016llx), phys(%d)\n", in _scsih_sas_host_add()
6856 ioc->sas_hba.handle, in _scsih_sas_host_add()
6857 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6858 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6860 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6863 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6864 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6874 * _scsih_expander_add - creating expander object
6876 * @handle: expander handle
6878 * Creating expander object, stored in ioc->sas_expander_list.
6883 _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_expander_add() argument
6900 if (!handle) in _scsih_expander_add()
6901 return -1; in _scsih_expander_add()
6903 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6904 return -1; in _scsih_expander_add()
6907 MPI2_SAS_EXPAND_PGAD_FORM_HNDL, handle))) { in _scsih_expander_add()
6910 return -1; in _scsih_expander_add()
6918 return -1; in _scsih_expander_add()
6921 /* handle out of order topology events */ in _scsih_expander_add()
6927 return -1; in _scsih_expander_add()
6931 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6932 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6936 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6944 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6948 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6958 return -1; in _scsih_expander_add()
6961 sas_expander->handle = handle; in _scsih_expander_add()
6962 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6963 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6964 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6965 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6966 if (!sas_expander->port) { in _scsih_expander_add()
6969 rc = -1; in _scsih_expander_add()
6973 ioc_info(ioc, "expander_add: handle(0x%04x), parent(0x%04x), sas_addr(0x%016llx), phys(%d)\n", in _scsih_expander_add()
6974 handle, parent_handle, in _scsih_expander_add()
6975 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6977 if (!sas_expander->num_phys) { in _scsih_expander_add()
6978 rc = -1; in _scsih_expander_add()
6981 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6983 if (!sas_expander->phy) { in _scsih_expander_add()
6986 rc = -1; in _scsih_expander_add()
6990 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6991 mpt3sas_port = mpt3sas_transport_port_add(ioc, handle, in _scsih_expander_add()
6992 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6996 rc = -1; in _scsih_expander_add()
6999 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
7000 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
7002 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
7004 &expander_pg1, i, handle))) { in _scsih_expander_add()
7007 rc = -1; in _scsih_expander_add()
7010 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
7011 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
7012 sas_expander->phy[i].port = in _scsih_expander_add()
7016 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7017 sas_expander->parent_dev))) { in _scsih_expander_add()
7020 rc = -1; in _scsih_expander_add()
7025 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7028 sas_expander->enclosure_handle); in _scsih_expander_add()
7030 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7031 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7040 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7041 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7047 * mpt3sas_expander_remove - removing expander object
7059 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7065 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7068 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7074 * _scsih_done - internal SCSI_IO callback handler.
7081 * The callback index passed is `ioc->scsih_cb_idx`
7092 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7094 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7096 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7098 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7099 mpi_reply->MsgLength*4); in _scsih_done()
7100 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7102 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7103 complete(&ioc->scsih_cmds.done); in _scsih_done()
7114 * _scsih_check_access_status - check access flags
7117 * @handle: sas device handle
7118 * @access_status: errors returned during discovery of the device
7124 u16 handle, u8 access_status) in _scsih_check_access_status() argument
7147 desc = "device blocked"; in _scsih_check_access_status()
7171 ioc_err(ioc, "discovery errors(%s): sas_address(0x%016llx), handle(0x%04x)\n", in _scsih_check_access_status()
7172 desc, (u64)sas_address, handle); in _scsih_check_access_status()
7177 * _scsih_check_device - checking device responsiveness
7180 * @handle: attached device handle
7186 u64 parent_sas_address, u16 handle, u8 phy_number, u8 link_rate) in _scsih_check_device() argument
7201 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) in _scsih_check_device()
7208 /* wide port handling ~ we need only handle device once for the phy that in _scsih_check_device()
7209 * is matched in sas device page zero in _scsih_check_device()
7214 /* check if this is end device */ in _scsih_check_device()
7219 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7230 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7231 starget = sas_device->starget; in _scsih_check_device()
7232 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7234 "handle changed from(0x%04x) to (0x%04x)!!!\n", in _scsih_check_device()
7235 sas_device->handle, handle); in _scsih_check_device()
7236 sas_target_priv_data->handle = handle; in _scsih_check_device()
7237 sas_device->handle = handle; in _scsih_check_device()
7240 sas_device->enclosure_level = in _scsih_check_device()
7242 memcpy(sas_device->connector_name, in _scsih_check_device()
7244 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7246 sas_device->enclosure_level = 0; in _scsih_check_device()
7247 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7250 sas_device->enclosure_handle = in _scsih_check_device()
7252 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7254 sas_device->enclosure_handle); in _scsih_check_device()
7256 sas_device->enclosure_logical_id = in _scsih_check_device()
7257 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7258 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7260 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7261 sas_device->chassis_slot = in _scsih_check_device()
7262 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7267 /* check if device is present */ in _scsih_check_device()
7270 ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_check_device()
7271 handle); in _scsih_check_device()
7276 if (_scsih_check_access_status(ioc, sas_address, handle, in _scsih_check_device()
7280 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7288 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7294 * _scsih_add_device - creating sas device object
7296 * @handle: sas device handle
7297 * @phy_num: phy number end device attached to
7300 * Creating end device object, stored in ioc->sas_device_list.
7302 * Return: 0 for success, non-zero for failure.
7305 _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num, in _scsih_add_device() argument
7318 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_add_device()
7321 return -1; in _scsih_add_device()
7329 return -1; in _scsih_add_device()
7332 /* check if this is end device */ in _scsih_add_device()
7335 return -1; in _scsih_add_device()
7336 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7339 /* check if device is present */ in _scsih_add_device()
7342 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_add_device()
7343 handle); in _scsih_add_device()
7344 return -1; in _scsih_add_device()
7348 if (_scsih_check_access_status(ioc, sas_address, handle, in _scsih_add_device()
7350 return -1; in _scsih_add_device()
7356 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7358 return -1; in _scsih_add_device()
7366 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_add_device()
7378 kref_init(&sas_device->refcount); in _scsih_add_device()
7379 sas_device->handle = handle; in _scsih_add_device()
7382 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7385 sas_device->enclosure_handle = in _scsih_add_device()
7387 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7388 sas_device->slot = in _scsih_add_device()
7390 sas_device->device_info = device_info; in _scsih_add_device()
7391 sas_device->sas_address = sas_address; in _scsih_add_device()
7392 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7393 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7395 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7396 if (!sas_device->port) { in _scsih_add_device()
7404 sas_device->enclosure_level = in _scsih_add_device()
7406 memcpy(sas_device->connector_name, in _scsih_add_device()
7408 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7410 sas_device->enclosure_level = 0; in _scsih_add_device()
7411 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7414 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7416 sas_device->enclosure_logical_id = in _scsih_add_device()
7417 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7418 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7420 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7421 sas_device->chassis_slot = in _scsih_add_device()
7422 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7426 /* get device name */ in _scsih_add_device()
7427 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7428 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7430 "handle(0x%0x) sas_address(0x%016llx) port_type(0x%0x)\n", in _scsih_add_device()
7431 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7433 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7444 * _scsih_remove_device - removing sas device object
7454 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7455 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7457 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7461 ioc_info(ioc, "%s: enter: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7463 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7468 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7469 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7470 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7471 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7472 sas_device->port); in _scsih_remove_device()
7473 sas_target_priv_data->handle = in _scsih_remove_device()
7477 if (!ioc->hide_drives) in _scsih_remove_device()
7479 sas_device->sas_address, in _scsih_remove_device()
7480 sas_device->sas_address_parent, in _scsih_remove_device()
7481 sas_device->port); in _scsih_remove_device()
7483 ioc_info(ioc, "removing handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7484 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7489 ioc_info(ioc, "%s: exit: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7491 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7497 * _scsih_sas_topology_change_event_debug - debug for topology event
7507 u16 handle; in _scsih_sas_topology_change_event_debug() local
7513 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7534 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7535 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7536 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7537 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7538 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7539 if (!handle) in _scsih_sas_topology_change_event_debug()
7541 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7542 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7564 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7565 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7568 handle, status_str, link_rate, prev_link_rate); in _scsih_sas_topology_change_event_debug()
7574 * _scsih_sas_topology_change_event - handle topology changes
7585 u16 parent_handle, handle; in _scsih_sas_topology_change_event() local
7595 fw_event->event_data; in _scsih_sas_topology_change_event()
7597 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7600 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7603 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7608 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7613 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7614 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7616 /* handle expander add */ in _scsih_sas_topology_change_event()
7617 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7621 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7625 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7626 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7627 port = sas_expander->port; in _scsih_sas_topology_change_event()
7628 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7629 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7630 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7632 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7635 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7637 /* handle siblings events */ in _scsih_sas_topology_change_event()
7638 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7639 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7644 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7646 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7649 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7651 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7655 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7656 if (!handle) in _scsih_sas_topology_change_event()
7658 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7659 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7663 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7670 handle, phy_number, link_rate, port); in _scsih_sas_topology_change_event()
7675 _scsih_check_device(ioc, sas_address, handle, in _scsih_sas_topology_change_event()
7678 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7685 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7689 handle, phy_number, link_rate, port); in _scsih_sas_topology_change_event()
7691 _scsih_add_device(ioc, handle, phy_number, 0); in _scsih_sas_topology_change_event()
7696 _scsih_device_remove_by_handle(ioc, handle); in _scsih_sas_topology_change_event()
7701 /* handle expander removal */ in _scsih_sas_topology_change_event()
7702 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7710 * _scsih_sas_device_status_change_event_debug - debug for device event
7721 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7726 reason_str = "unsupported device discovered"; in _scsih_sas_device_status_change_event_debug()
7729 reason_str = "internal device reset"; in _scsih_sas_device_status_change_event_debug()
7747 reason_str = "internal device reset complete"; in _scsih_sas_device_status_change_event_debug()
7765 ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)", in _scsih_sas_device_status_change_event_debug()
7766 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7767 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7768 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7769 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7771 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7776 * _scsih_sas_device_status_change_event - handle device status change
7790 /* In MPI Revision K (0xC), the internal device reset complete was in _scsih_sas_device_status_change_event()
7793 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7796 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7798 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7802 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7803 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7806 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7808 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7811 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7815 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7817 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7819 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7821 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7823 "%s tm_busy flag for handle(0x%04x)\n", in _scsih_sas_device_status_change_event()
7824 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7825 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7831 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7836 * _scsih_check_pcie_access_status - check access flags
7839 * @handle: sas device handle
7840 * @access_status: errors returned during discovery of the device
7846 u16 handle, u8 access_status) in _scsih_check_pcie_access_status() argument
7857 desc = "PCIe device capability failed"; in _scsih_check_pcie_access_status()
7860 desc = "PCIe device blocked"; in _scsih_check_pcie_access_status()
7862 "Device with Access Status (%s): wwid(0x%016llx), " in _scsih_check_pcie_access_status()
7863 "handle(0x%04x)\n ll only be added to the internal list", in _scsih_check_pcie_access_status()
7864 desc, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7868 desc = "PCIe device mem space access failed"; in _scsih_check_pcie_access_status()
7871 desc = "PCIe device unsupported"; in _scsih_check_pcie_access_status()
7874 desc = "PCIe device MSIx Required"; in _scsih_check_pcie_access_status()
7877 desc = "PCIe device init fail max"; in _scsih_check_pcie_access_status()
7880 desc = "PCIe device status unknown"; in _scsih_check_pcie_access_status()
7886 desc = "nvme device configuration unsupported"; in _scsih_check_pcie_access_status()
7910 ioc_err(ioc, "NVMe discovery error(0x%02x): wwid(0x%016llx), handle(0x%04x)\n", in _scsih_check_pcie_access_status()
7911 access_status, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7918 ioc_info(ioc, "NVMe discovery error(%s): wwid(0x%016llx), handle(0x%04x)\n", in _scsih_check_pcie_access_status()
7919 desc, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7924 * _scsih_pcie_device_remove_from_sml - removing pcie device
7936 ioc_info(ioc, "%s: enter: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7938 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7939 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7943 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7944 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7945 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7949 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7950 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7952 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7953 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7954 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7955 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7956 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7959 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7960 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7961 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7963 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7964 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7965 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7967 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7968 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7970 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7972 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7974 ioc_info(ioc, "%s: exit: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7976 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7977 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7981 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7982 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7983 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7987 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7988 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7990 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7995 * _scsih_pcie_check_device - checking device responsiveness
7997 * @handle: attached device handle
8000 _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_pcie_check_device() argument
8013 &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) in _scsih_pcie_check_device()
8020 /* check if this is end device */ in _scsih_pcie_check_device()
8026 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8030 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8034 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8035 starget = pcie_device->starget; in _scsih_pcie_check_device()
8036 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8037 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8039 "handle changed from(0x%04x) to (0x%04x)!!!\n", in _scsih_pcie_check_device()
8040 pcie_device->handle, handle); in _scsih_pcie_check_device()
8041 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8042 pcie_device->handle = handle; in _scsih_pcie_check_device()
8046 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8048 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8051 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8052 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8056 /* check if device is present */ in _scsih_pcie_check_device()
8059 ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_pcie_check_device()
8060 handle); in _scsih_pcie_check_device()
8061 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8067 if (_scsih_check_pcie_access_status(ioc, wwid, handle, in _scsih_pcie_check_device()
8069 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8074 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8083 * _scsih_pcie_add_device - creating pcie device object
8085 * @handle: pcie device handle
8087 * Creating end device object, stored in ioc->pcie_device_list.
8092 _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_pcie_add_device() argument
8103 &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_pcie_add_device()
8116 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8119 /* check if device is present */ in _scsih_pcie_add_device()
8122 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_pcie_add_device()
8123 handle); in _scsih_pcie_add_device()
8128 if (_scsih_check_pcie_access_status(ioc, wwid, handle, in _scsih_pcie_add_device()
8138 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8143 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8144 * specific NVMe device; therefore, this page is only in _scsih_pcie_add_device()
8151 handle)) { in _scsih_pcie_add_device()
8175 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8176 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8177 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8178 pcie_device->handle = handle; in _scsih_pcie_add_device()
8179 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8180 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8181 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8182 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8183 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8186 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8188 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8189 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8193 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8194 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8197 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8198 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8202 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8205 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8207 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8208 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8210 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8213 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8215 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8222 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8223 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8224 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8226 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8229 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8231 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8233 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8243 * _scsih_pcie_topology_change_event_debug - debug for topology
8254 u16 handle; in _scsih_pcie_topology_change_event_debug() local
8260 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8281 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8282 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8283 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8284 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8285 handle = in _scsih_pcie_topology_change_event_debug()
8286 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8287 if (!handle) in _scsih_pcie_topology_change_event_debug()
8289 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8290 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8311 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8313 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8317 handle, status_str, link_rate, prev_link_rate); in _scsih_pcie_topology_change_event_debug()
8322 * _scsih_pcie_topology_change_event - handle PCIe topology
8334 u16 handle; in _scsih_pcie_topology_change_event() local
8340 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8343 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8346 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8347 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8350 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8355 /* handle siblings events */ in _scsih_pcie_topology_change_event()
8356 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8357 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8362 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8364 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8365 handle = in _scsih_pcie_topology_change_event()
8366 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8367 if (!handle) in _scsih_pcie_topology_change_event()
8370 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8372 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8377 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8384 _scsih_pcie_check_device(ioc, handle); in _scsih_pcie_topology_change_event()
8387 * where a device has been added, however its returning in _scsih_pcie_topology_change_event()
8388 * BUSY for sometime. Then before the Device Missing in _scsih_pcie_topology_change_event()
8389 * Delay expires and the device becomes READY, the in _scsih_pcie_topology_change_event()
8390 * device is removed and added back. in _scsih_pcie_topology_change_event()
8392 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8393 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in _scsih_pcie_topology_change_event()
8394 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8401 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8405 ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n", in _scsih_pcie_topology_change_event()
8406 handle)); in _scsih_pcie_topology_change_event()
8407 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8408 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8412 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8417 rc = _scsih_pcie_add_device(ioc, handle); in _scsih_pcie_topology_change_event()
8424 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8429 _scsih_pcie_device_remove_by_handle(ioc, handle); in _scsih_pcie_topology_change_event()
8436 * _scsih_pcie_device_status_change_event_debug - debug for device event
8447 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8452 reason_str = "unsupported device discovered"; in _scsih_pcie_device_status_change_event_debug()
8455 reason_str = "internal device reset"; in _scsih_pcie_device_status_change_event_debug()
8470 reason_str = "device init failure"; in _scsih_pcie_device_status_change_event_debug()
8473 reason_str = "internal device reset complete"; in _scsih_pcie_device_status_change_event_debug()
8489 ioc_info(ioc, "PCIE device status change: (%s)\n" in _scsih_pcie_device_status_change_event_debug()
8491 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8492 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8493 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8494 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8496 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8501 * _scsih_pcie_device_status_change_event - handle device status
8516 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8517 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8521 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8523 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8527 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8528 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8531 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8534 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8538 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8540 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8542 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8547 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8551 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8563 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8578 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8579 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8580 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8584 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8596 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8598 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8600 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8603 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8604 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8611 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8623 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8633 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8634 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8639 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8649 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8661 u16 smid, handle; in _scsih_sas_broadcast_primitive_event() local
8669 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8676 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8678 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8682 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8683 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8693 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8697 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8698 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8704 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8705 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8706 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8709 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8713 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8717 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8721 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8722 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8725 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8728 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8729 r = mpt3sas_scsih_issue_tm(ioc, handle, 0, 0, lun, in _scsih_sas_broadcast_primitive_event()
8730 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8731 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8736 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8739 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8745 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8750 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8752 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8754 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8763 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8767 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8770 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8771 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8772 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8773 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8784 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8786 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8787 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8790 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8795 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8800 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8804 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8807 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8808 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8810 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8814 * _scsih_sas_discovery_event - handle discovery events
8824 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8826 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8828 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8830 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8832 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8836 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8837 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8838 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8840 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8848 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8859 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8861 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8863 …ioc_warn(ioc, "SMP command sent to the expander (handle:0x%04x, sas_address:0x%016llx, physical_po… in _scsih_sas_device_discovery_error_event()
8864 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8865 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8866 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8869 …ioc_warn(ioc, "SMP command sent to the expander (handle:0x%04x, sas_address:0x%016llx, physical_po… in _scsih_sas_device_discovery_error_event()
8870 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8871 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8872 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8880 * _scsih_pcie_enumeration_event - handle enumeration events
8890 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8892 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8896 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8898 event_data->Flags); in _scsih_pcie_enumeration_event()
8899 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8901 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8906 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8908 * @handle: device handle for physical disk
8914 _scsih_ir_fastpath(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phys_disk_num) in _scsih_ir_fastpath() argument
8924 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8927 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8929 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8931 rc = -EAGAIN; in _scsih_ir_fastpath()
8934 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8936 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8939 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8940 rc = -EAGAIN; in _scsih_ir_fastpath()
8945 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8948 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8949 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8950 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8953 … ioc_info(ioc, "IR RAID_ACTION: turning fast path on for handle(0x%04x), phys_disk_num (0x%02x)\n", in _scsih_ir_fastpath()
8954 handle, phys_disk_num)); in _scsih_ir_fastpath()
8956 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8957 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8958 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8960 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8962 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8964 rc = -EFAULT; in _scsih_ir_fastpath()
8968 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8970 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8971 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8973 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8981 rc = -EFAULT; in _scsih_ir_fastpath()
8988 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8989 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8997 * _scsih_reprobe_lun - reprobing lun
8998 * @sdev: scsi device struct
8999 * @no_uld_attach: sdev->no_uld_attach flag setting
9005 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
9007 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
9012 * _scsih_sas_volume_add - add new volume
9024 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add() local
9027 mpt3sas_config_get_volume_wwid(ioc, handle, &wwid); in _scsih_sas_volume_add()
9034 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9036 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9048 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9049 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9050 raid_device->handle = handle; in _scsih_sas_volume_add()
9051 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9053 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9054 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9055 raid_device->id, 0); in _scsih_sas_volume_add()
9059 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9061 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9066 * _scsih_sas_volume_delete - delete volume
9068 * @handle: volume device handle
9072 _scsih_sas_volume_delete(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_sas_volume_delete() argument
9079 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9080 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_volume_delete()
9082 if (raid_device->starget) { in _scsih_sas_volume_delete()
9083 starget = raid_device->starget; in _scsih_sas_volume_delete()
9084 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9085 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9087 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in _scsih_sas_volume_delete()
9088 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9089 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9092 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9094 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9098 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9111 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose() local
9113 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9114 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_expose()
9116 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9117 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9118 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9119 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9120 starget = sas_device->starget; in _scsih_sas_pd_expose()
9121 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9122 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9126 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9138 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9151 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide() local
9155 mpt3sas_config_get_volume_handle(ioc, handle, &volume_handle); in _scsih_sas_pd_hide()
9160 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9161 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_hide()
9163 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9164 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9165 starget = sas_device->starget; in _scsih_sas_pd_hide()
9166 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9167 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9169 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9170 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9173 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9178 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9187 * _scsih_sas_pd_delete - delete pd component
9196 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete() local
9198 _scsih_device_remove_by_handle(ioc, handle); in _scsih_sas_pd_delete()
9202 * _scsih_sas_pd_add - remove pd component
9212 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add() local
9219 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9221 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_add()
9223 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9229 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_sas_pd_add()
9245 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_sas_pd_add()
9250 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9251 _scsih_add_device(ioc, handle, 0, 1); in _scsih_sas_pd_add()
9255 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9269 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9272 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9274 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9275 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9276 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9308 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9324 pr_info("\t(%s:%s), vol handle(0x%04x), " \ in _scsih_sas_ir_config_change_event_debug()
9325 "pd handle(0x%04x), pd num(0x%02x)\n", element_str, in _scsih_sas_ir_config_change_event_debug()
9326 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9327 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9328 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9333 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9347 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9349 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9350 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9353 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9356 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9357 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9358 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9359 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9360 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9362 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9363 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9368 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9370 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9380 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9383 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9387 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9391 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9395 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9403 * _scsih_sas_ir_volume_event - IR volume event
9415 u16 handle; in _scsih_sas_ir_volume_event() local
9419 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9421 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9424 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9427 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9428 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9429 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9431 ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n", in _scsih_sas_ir_volume_event()
9432 __func__, handle, in _scsih_sas_ir_volume_event()
9433 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9438 _scsih_sas_volume_delete(ioc, handle); in _scsih_sas_ir_volume_event()
9445 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9446 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_ir_volume_event()
9447 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9452 mpt3sas_config_get_volume_wwid(ioc, handle, &wwid); in _scsih_sas_ir_volume_event()
9466 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9467 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9468 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9469 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9471 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9472 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9484 * _scsih_sas_ir_physical_disk_event - PD event
9493 u16 handle, parent_handle; in _scsih_sas_ir_physical_disk_event() local
9500 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9503 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9506 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9509 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9510 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9512 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9514 ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n", in _scsih_sas_ir_physical_disk_event()
9515 __func__, handle, in _scsih_sas_ir_physical_disk_event()
9516 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9526 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9527 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9529 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_ir_physical_disk_event()
9537 handle))) { in _scsih_sas_ir_physical_disk_event()
9553 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_sas_ir_physical_disk_event()
9558 _scsih_add_device(ioc, handle, 0, 1); in _scsih_sas_ir_physical_disk_event()
9571 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9582 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9605 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9606 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9610 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9621 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9624 u16 handle; in _scsih_sas_ir_operation_status_event() local
9626 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9627 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9632 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9634 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9635 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9636 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_ir_operation_status_event()
9638 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9639 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9640 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9645 * _scsih_prep_device_scan - initialize parameters prior to device scan
9648 * Set the deleted flag prior to device scan. If the device is found during
9657 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9658 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9659 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9660 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9665 * _scsih_update_device_qdepth - Update QD during Reset.
9679 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9680 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9681 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9682 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9683 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9684 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9685 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9687 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9688 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9689 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9691 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9692 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9701 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9703 * @sas_device_pg0: SAS Device page 0
9718 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9720 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9723 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9725 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_mark_responding_sas_device()
9726 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9728 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9729 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9730 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9731 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9733 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9735 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9737 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9738 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9739 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9740 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9741 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9742 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9747 "handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_mark_responding_sas_device()
9748 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9750 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9752 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9756 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9757 sas_device->slot); in _scsih_mark_responding_sas_device()
9759 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9761 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9762 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9763 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9764 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9766 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9767 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9770 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9771 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9772 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9774 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9775 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9776 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9778 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9779 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9780 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9784 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9785 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9788 sas_device->handle); in _scsih_mark_responding_sas_device()
9789 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9790 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9792 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9793 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9797 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9801 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9827 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9836 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9837 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9839 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9844 * _scsih_search_responding_sas_devices -
9856 u16 handle; in _scsih_search_responding_sas_devices() local
9859 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9861 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9864 handle = 0xFFFF; in _scsih_search_responding_sas_devices()
9867 handle))) { in _scsih_search_responding_sas_devices()
9872 handle = le16_to_cpu(sas_device_pg0.DevHandle); in _scsih_search_responding_sas_devices()
9880 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9884 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9886 * @pcie_device_pg0: PCIe Device page 0
9900 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9901 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9902 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9903 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9904 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9905 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9906 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9907 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9908 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9909 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9910 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9911 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9912 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9917 "handle(0x%04x), wwid(0x%016llx) ", in _scsih_mark_responding_pcie_device()
9918 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9919 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9920 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9925 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9926 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9929 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9931 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9932 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9933 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9934 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9935 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9937 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9938 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9941 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9942 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9945 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9946 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9947 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9949 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9950 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9956 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9960 * _scsih_search_responding_pcie_devices -
9972 u16 handle; in _scsih_search_responding_pcie_devices() local
9975 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9977 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
9980 handle = 0xFFFF; in _scsih_search_responding_pcie_devices()
9983 handle))) { in _scsih_search_responding_pcie_devices()
9992 handle = le16_to_cpu(pcie_device_pg0.DevHandle); in _scsih_search_responding_pcie_devices()
9999 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
10003 * _scsih_mark_responding_raid_device - mark a raid_device as responding
10006 * @handle: device handle
10013 u16 handle) in _scsih_mark_responding_raid_device() argument
10020 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10021 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10022 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10023 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10024 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10025 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10026 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10029 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10030 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10031 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10032 "handle(0x%04x), wwid(0x%016llx)\n", handle, in _scsih_mark_responding_raid_device()
10033 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10037 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10041 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10042 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10043 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10048 raid_device->handle); in _scsih_mark_responding_raid_device()
10049 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10051 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10052 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10056 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10060 * _scsih_search_responding_raid_devices -
10074 u16 handle; in _scsih_search_responding_raid_devices() local
10077 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10082 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10085 handle = 0xFFFF; in _scsih_search_responding_raid_devices()
10087 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { in _scsih_search_responding_raid_devices()
10092 handle = le16_to_cpu(volume_pg1.DevHandle); in _scsih_search_responding_raid_devices()
10095 &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in _scsih_search_responding_raid_devices()
10103 le64_to_cpu(volume_pg1.WWID), handle); in _scsih_search_responding_raid_devices()
10107 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10109 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10118 handle = le16_to_cpu(pd_pg0.DevHandle); in _scsih_search_responding_raid_devices()
10119 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10127 * _scsih_mark_responding_expander - mark a expander as responding
10142 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander() local
10143 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10144 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10146 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10153 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10154 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10155 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10157 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10159 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10162 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10163 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10164 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10165 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10168 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10170 pr_info("\texpander(0x%016llx): handle changed" \ in _scsih_mark_responding_expander()
10172 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10173 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10174 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10175 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10176 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10180 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10184 * _scsih_search_responding_expanders -
10197 u16 handle; in _scsih_search_responding_expanders() local
10202 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10205 handle = 0xFFFF; in _scsih_search_responding_expanders()
10207 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { in _scsih_search_responding_expanders()
10214 handle = le16_to_cpu(expander_pg0.DevHandle); in _scsih_search_responding_expanders()
10218 "\texpander present: handle(0x%04x), sas_addr(0x%016llx), port:%d\n", in _scsih_search_responding_expanders()
10219 handle, (unsigned long long)sas_address, in _scsih_search_responding_expanders()
10220 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10230 * _scsih_remove_unresponding_devices - removing unresponding devices
10247 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10249 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10252 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10259 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10260 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10265 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10266 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10267 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10269 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10271 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10278 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10282 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10284 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10290 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10291 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10296 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10297 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10298 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10300 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10302 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10306 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10311 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10314 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10315 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10317 raid_device->handle); in _scsih_remove_unresponding_devices()
10319 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10325 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10328 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10329 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10330 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10332 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10334 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10348 struct _sas_node *sas_expander, u16 handle) in _scsih_refresh_expander_links() argument
10354 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10356 &expander_pg1, i, handle))) { in _scsih_refresh_expander_links()
10362 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10365 sas_expander->port); in _scsih_refresh_expander_links()
10370 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10386 u16 handle, parent_handle; in _scsih_scan_for_devices_after_reset() local
10412 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10414 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { in _scsih_scan_for_devices_after_reset()
10422 handle = le16_to_cpu(expander_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10423 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10428 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10431 handle); in _scsih_scan_for_devices_after_reset()
10433 ioc_info(ioc, "\tBEFORE adding expander: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10434 handle, in _scsih_scan_for_devices_after_reset()
10436 _scsih_expander_add(ioc, handle); in _scsih_scan_for_devices_after_reset()
10437 ioc_info(ioc, "\tAFTER adding expander: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10438 handle, in _scsih_scan_for_devices_after_reset()
10445 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10463 handle = le16_to_cpu(pd_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10464 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_scan_for_devices_after_reset()
10471 handle) != 0) in _scsih_scan_for_devices_after_reset()
10483 ioc_info(ioc, "\tBEFORE adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10484 handle, in _scsih_scan_for_devices_after_reset()
10488 handle, sas_device_pg0.PhyNum, in _scsih_scan_for_devices_after_reset()
10491 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10493 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10497 while (_scsih_add_device(ioc, handle, retry_count++, in _scsih_scan_for_devices_after_reset()
10501 ioc_info(ioc, "\tAFTER adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10502 handle, in _scsih_scan_for_devices_after_reset()
10512 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10514 volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { in _scsih_scan_for_devices_after_reset()
10522 handle = le16_to_cpu(volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10523 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10525 le64_to_cpu(volume_pg1->WWID)); in _scsih_scan_for_devices_after_reset()
10526 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10530 volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in _scsih_scan_for_devices_after_reset()
10540 if (volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL || in _scsih_scan_for_devices_after_reset()
10541 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_ONLINE || in _scsih_scan_for_devices_after_reset()
10542 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) { in _scsih_scan_for_devices_after_reset()
10545 element.VolDevHandle = volume_pg1->DevHandle; in _scsih_scan_for_devices_after_reset()
10546 ioc_info(ioc, "\tBEFORE adding volume: handle (0x%04x)\n", in _scsih_scan_for_devices_after_reset()
10547 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10549 ioc_info(ioc, "\tAFTER adding volume: handle (0x%04x)\n", in _scsih_scan_for_devices_after_reset()
10550 volume_pg1->DevHandle); in _scsih_scan_for_devices_after_reset()
10561 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10564 handle))) { in _scsih_scan_for_devices_after_reset()
10568 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10572 handle = le16_to_cpu(sas_device_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10586 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10587 handle, in _scsih_scan_for_devices_after_reset()
10589 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_scan_for_devices_after_reset()
10593 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10597 while (_scsih_add_device(ioc, handle, retry_count++, in _scsih_scan_for_devices_after_reset()
10601 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10602 handle, in _scsih_scan_for_devices_after_reset()
10610 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10613 handle))) { in _scsih_scan_for_devices_after_reset()
10617 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10621 handle = le16_to_cpu(pcie_device_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10633 _scsih_pcie_add_device(ioc, handle); in _scsih_scan_for_devices_after_reset()
10635 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10636 handle, (u64)le64_to_cpu(pcie_device_pg0.WWID)); in _scsih_scan_for_devices_after_reset()
10647 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10658 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10669 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10670 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10671 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10672 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10674 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10675 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10676 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10677 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10680 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10681 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10682 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10688 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10697 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10698 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10713 * _mpt3sas_fw_work - delayed task for processing firmware events
10721 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10725 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10727 ioc->current_event = NULL; in _mpt3sas_fw_work()
10731 switch (fw_event->event) { in _mpt3sas_fw_work()
10735 fw_event->event_data); in _mpt3sas_fw_work()
10738 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10739 ioc->shost_recovery) { in _mpt3sas_fw_work()
10744 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10751 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10758 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10759 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10760 *- start the watchdog thread. in _mpt3sas_fw_work()
10764 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10769 ioc->start_scan = 0; in _mpt3sas_fw_work()
10770 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10777 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10783 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10786 fw_event->event_data); in _mpt3sas_fw_work()
10821 ioc->current_event = NULL; in _mpt3sas_fw_work()
10826 ioc->current_event = NULL; in _mpt3sas_fw_work()
10843 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10847 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10853 * This function merely adds a new work task into ioc->firmware_event_thread.
10870 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10881 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10887 /* handle these */ in mpt3sas_scsih_event_callback()
10892 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10894 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10898 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10899 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10902 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10909 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10915 * sas device page0's not by processing the in mpt3sas_scsih_event_callback()
10918 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10924 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10925 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10931 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10936 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10943 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10947 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10948 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10950 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10962 …no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode.… in mpt3sas_scsih_event_callback()
10974 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10988 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10992 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10993 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10996 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
11001 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
11006 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
11018 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
11026 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
11027 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11028 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11029 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11030 fw_event->event = event; in mpt3sas_scsih_event_callback()
11037 * _scsih_expander_node_remove - removing expander device from list.
11042 * ioc->sas_expander_list.
11054 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11055 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11057 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11060 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11061 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11062 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11064 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11067 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11068 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11071 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11073 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11074 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11077 "expander_remove: handle(0x%04x), sas_addr(0x%016llx), port:%d\n", in _scsih_expander_node_remove()
11078 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11079 sas_expander->sas_address, in _scsih_expander_node_remove()
11082 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11083 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11084 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11086 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11091 * _scsih_nvme_shutdown - NVMe shutdown notification
11106 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11109 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11111 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11116 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11118 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11122 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11127 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11129 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11130 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11132 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11133 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11137 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11138 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11139 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11141 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11146 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11147 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11150 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11151 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11154 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11155 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11160 * _scsih_ir_shutdown - IR shutdown notification
11174 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11178 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11181 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11183 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11187 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11189 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11192 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11197 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11200 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11201 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11203 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11205 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11206 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11207 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11209 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11214 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11215 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11216 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11218 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11219 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11223 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11224 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11228 * _scsih_get_shost_and_ioc - get shost and ioc
11230 * @pdev: PCI device struct
11242 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11243 return -ENXIO; in _scsih_get_shost_and_ioc()
11248 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11249 return -ENXIO; in _scsih_get_shost_and_ioc()
11256 * scsih_remove - detach and remove add host
11257 * @pdev: PCI device struct
11277 ioc->remove_host = 1; in scsih_remove()
11286 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11287 wq = ioc->firmware_event_thread; in scsih_remove()
11288 ioc->firmware_event_thread = NULL; in scsih_remove()
11289 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11296 if (ioc->is_aero_ioc) in scsih_remove()
11298 &ioc->ioc_pg1_copy); in scsih_remove()
11303 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11305 if (raid_device->starget) { in scsih_remove()
11307 raid_device->starget->hostdata; in scsih_remove()
11308 sas_target_priv_data->deleted = 1; in scsih_remove()
11309 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11311 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in scsih_remove()
11312 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11315 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11318 list_del_init(&pcie_device->list); in scsih_remove()
11324 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11325 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11328 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11329 mpt3sas_port->hba_port); in scsih_remove()
11330 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11332 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11335 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11336 mpt3sas_port->hba_port); in scsih_remove()
11340 &ioc->port_table_list, list) { in scsih_remove()
11341 list_del(&port->list); in scsih_remove()
11346 if (ioc->sas_hba.num_phys) { in scsih_remove()
11347 kfree(ioc->sas_hba.phy); in scsih_remove()
11348 ioc->sas_hba.phy = NULL; in scsih_remove()
11349 ioc->sas_hba.num_phys = 0; in scsih_remove()
11354 list_del(&ioc->list); in scsih_remove()
11360 * scsih_shutdown - routine call during system shutdown
11361 * @pdev: PCI device struct
11375 ioc->remove_host = 1; in scsih_shutdown()
11384 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11385 wq = ioc->firmware_event_thread; in scsih_shutdown()
11386 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11387 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11394 if (ioc->is_aero_ioc) in scsih_shutdown()
11396 &ioc->ioc_pg1_copy); in scsih_shutdown()
11402 ioc->shost_recovery = 1; in scsih_shutdown()
11404 ioc->shost_recovery = 0; in scsih_shutdown()
11411 * _scsih_probe_boot_devices - reports 1st device
11415 * device scsi-ml or sas transport for persistent boot device
11422 void *device; in _scsih_probe_boot_devices() local
11426 u16 handle; in _scsih_probe_boot_devices() local
11435 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11438 device = NULL; in _scsih_probe_boot_devices()
11439 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11440 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11441 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11442 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11443 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11444 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11445 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11446 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11447 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11450 if (!device) in _scsih_probe_boot_devices()
11454 raid_device = device; in _scsih_probe_boot_devices()
11457 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11460 if (raid_device->starget) in _scsih_probe_boot_devices()
11462 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11463 raid_device->id, 0); in _scsih_probe_boot_devices()
11467 pcie_device = device; in _scsih_probe_boot_devices()
11469 * If this boot NVMe device is already registered with SML then in _scsih_probe_boot_devices()
11470 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11473 if (pcie_device->starget) in _scsih_probe_boot_devices()
11475 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11476 tid = pcie_device->id; in _scsih_probe_boot_devices()
11477 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11478 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11479 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11483 sas_device = device; in _scsih_probe_boot_devices()
11485 * If this boot sas/sata device is already registered with SML in _scsih_probe_boot_devices()
11486 * then no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11489 if (sas_device->starget) in _scsih_probe_boot_devices()
11491 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11492 handle = sas_device->handle; in _scsih_probe_boot_devices()
11493 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11494 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11495 port = sas_device->port; in _scsih_probe_boot_devices()
11496 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11497 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11499 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11505 if (!mpt3sas_transport_port_add(ioc, handle, in _scsih_probe_boot_devices()
11508 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11509 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11520 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11532 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11533 if (raid_device->starget) in _scsih_probe_raid()
11535 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11536 raid_device->id, 0); in _scsih_probe_raid()
11547 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11548 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11549 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11553 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11563 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11573 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11574 list_del_init(&sas_device->list); in sas_device_make_active()
11579 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11581 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11585 * _scsih_probe_sas - reporting sas devices to sas transport
11595 if (ioc->hide_drives) in _scsih_probe_sas()
11599 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11600 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11604 } else if (!sas_device->starget) { in _scsih_probe_sas()
11608 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11611 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11613 sas_device->sas_address, in _scsih_probe_sas()
11614 sas_device->sas_address_parent, in _scsih_probe_sas()
11615 sas_device->port); in _scsih_probe_sas()
11627 * get_next_pcie_device - Get the next pcie device
11630 * Get the next pcie device from pcie_device_init_list list.
11632 * Return: pcie device structure if pcie_device_init_list list is not empty
11640 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11641 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11642 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11646 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11652 * pcie_device_make_active - Add pcie device to pcie_device_list list
11654 * @pcie_device: pcie device object
11656 * Add the pcie device which has registered with SCSI Transport Later to
11664 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11666 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11667 list_del_init(&pcie_device->list); in pcie_device_make_active()
11671 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11673 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11677 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11688 /* PCIe Device List */ in _scsih_probe_pcie()
11690 if (pcie_device->starget) { in _scsih_probe_pcie()
11694 if (pcie_device->access_status == in _scsih_probe_pcie()
11700 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11701 pcie_device->id, 0); in _scsih_probe_pcie()
11706 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11710 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11713 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11714 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11728 * _scsih_probe_devices - probing for devices
11738 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11743 if (ioc->ir_firmware) { in _scsih_probe_devices()
11745 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11762 * scsih_scan_start - scsi lld callback for .scan_start
11774 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11776 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11782 ioc->start_scan = 1; in scsih_scan_start()
11790 * _scsih_complete_devices_scanning - add the devices to sml and
11799 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11800 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11805 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11809 * scsih_scan_finished - scsi lld callback for .scan_finished
11825 ioc->is_driver_loading = 0; in scsih_scan_finished()
11826 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11831 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11833 ioc->is_driver_loading = 0; in scsih_scan_finished()
11837 if (ioc->start_scan) { in scsih_scan_finished()
11855 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11858 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11861 if (ioc->start_scan_failed) { in scsih_scan_finished()
11863 ioc->start_scan_failed); in scsih_scan_finished()
11864 ioc->is_driver_loading = 0; in scsih_scan_finished()
11865 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11866 ioc->remove_host = 1; in scsih_scan_finished()
11871 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11876 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11878 ioc->is_driver_loading = 0; in scsih_scan_finished()
11884 * scsih_map_queues - map reply queues with request queues
11890 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11893 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11894 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11896 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11899 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11900 map = &shost->tag_set.map[i]; in scsih_map_queues()
11901 map->nr_queues = 0; in scsih_map_queues()
11904 map->nr_queues = in scsih_map_queues()
11905 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11906 offset = ioc->high_iops_queues; in scsih_map_queues()
11908 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11910 if (!map->nr_queues) in scsih_map_queues()
11915 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11917 map->queue_offset = qoff; in scsih_map_queues()
11919 blk_mq_pci_map_queues(map, ioc->pdev, offset); in scsih_map_queues()
11923 qoff += map->nr_queues; in scsih_map_queues()
11947 .this_id = -1,
11985 .this_id = -1,
12007 * _scsih_determine_hba_mpi_version - determine in which MPI version class
12008 * this device belongs to.
12009 * @pdev: PCI device struct
12019 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12079 * _scsih_probe - attach and add scsi host
12080 * @pdev: PCI device struct
12081 * @id: pci device id
12094 /* Determine in which MPI version class this pci device belongs */ in _scsih_probe()
12097 return -ENODEV; in _scsih_probe()
12100 * for other generation HBA's return with -ENODEV in _scsih_probe()
12103 return -ENODEV; in _scsih_probe()
12106 * for other generation HBA's return with -ENODEV in _scsih_probe()
12110 return -ENODEV; in _scsih_probe()
12120 return -ENODEV; in _scsih_probe()
12123 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12124 ioc->id = mpt2_ids++; in _scsih_probe()
12125 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12126 switch (pdev->device) { in _scsih_probe()
12128 ioc->is_warpdrive = 1; in _scsih_probe()
12129 ioc->hide_ir_msg = 1; in _scsih_probe()
12133 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12136 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12140 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12141 ioc->multipath_on_hba = 0; in _scsih_probe()
12143 ioc->multipath_on_hba = 1; in _scsih_probe()
12152 return -ENODEV; in _scsih_probe()
12155 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12156 ioc->id = mpt3_ids++; in _scsih_probe()
12157 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12158 switch (pdev->device) { in _scsih_probe()
12167 ioc->is_gen35_ioc = 1; in _scsih_probe()
12171 dev_err(&pdev->dev, in _scsih_probe()
12173 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12174 pdev->subsystem_device); in _scsih_probe()
12178 dev_err(&pdev->dev, in _scsih_probe()
12180 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12181 pdev->subsystem_device); in _scsih_probe()
12185 dev_info(&pdev->dev, in _scsih_probe()
12190 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12193 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12195 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12196 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12197 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12198 ioc->combined_reply_queue = 1; in _scsih_probe()
12199 if (ioc->is_gen35_ioc) in _scsih_probe()
12200 ioc->combined_reply_index_count = in _scsih_probe()
12203 ioc->combined_reply_index_count = in _scsih_probe()
12207 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12209 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12210 ioc->multipath_on_hba = 0; in _scsih_probe()
12212 ioc->multipath_on_hba = 1; in _scsih_probe()
12215 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12216 ioc->multipath_on_hba = 1; in _scsih_probe()
12218 ioc->multipath_on_hba = 0; in _scsih_probe()
12226 return -ENODEV; in _scsih_probe()
12229 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12231 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12233 ioc->shost = shost; in _scsih_probe()
12234 ioc->pdev = pdev; in _scsih_probe()
12235 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12236 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12237 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12238 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12239 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12240 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12241 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12242 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12243 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12244 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12245 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12246 ioc->logging_level = logging_level; in _scsih_probe()
12247 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12249 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12253 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12255 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12257 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12260 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12262 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12263 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12264 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12265 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12266 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12267 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12268 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12269 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12270 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12272 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12273 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12274 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12275 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12276 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12277 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12278 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12279 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12280 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12281 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12282 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12283 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12284 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12285 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12286 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12288 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12291 shost->max_cmd_len = 32; in _scsih_probe()
12292 shost->max_lun = max_lun; in _scsih_probe()
12293 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12294 shost->unique_id = ioc->id; in _scsih_probe()
12296 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12298 shost->max_sectors = 128; in _scsih_probe()
12300 shost->max_sectors); in _scsih_probe()
12304 shost->max_sectors = 64; in _scsih_probe()
12308 shost->max_sectors = 32767; in _scsih_probe()
12312 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12314 shost->max_sectors); in _scsih_probe()
12329 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
12330 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
12331 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12332 ioc->firmware_event_name, 0); in _scsih_probe()
12333 if (!ioc->firmware_event_thread) { in _scsih_probe()
12336 rv = -ENODEV; in _scsih_probe()
12340 shost->host_tagset = 0; in _scsih_probe()
12342 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12343 shost->host_tagset = 1; in _scsih_probe()
12345 ioc->is_driver_loading = 1; in _scsih_probe()
12349 rv = -ENODEV; in _scsih_probe()
12353 if (ioc->is_warpdrive) { in _scsih_probe()
12354 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12355 ioc->hide_drives = 0; in _scsih_probe()
12356 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12357 ioc->hide_drives = 1; in _scsih_probe()
12360 ioc->hide_drives = 1; in _scsih_probe()
12362 ioc->hide_drives = 0; in _scsih_probe()
12365 ioc->hide_drives = 0; in _scsih_probe()
12367 shost->nr_hw_queues = 1; in _scsih_probe()
12369 if (shost->host_tagset) { in _scsih_probe()
12370 shost->nr_hw_queues = in _scsih_probe()
12371 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12374 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12376 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12378 dev_info(&ioc->pdev->dev, in _scsih_probe()
12380 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12383 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12396 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12399 list_del(&ioc->list); in _scsih_probe()
12406 * scsih_suspend - power management suspend main entry point
12407 * @dev: Device struct
12412 scsih_suspend(struct device *dev) in scsih_suspend()
12434 * scsih_resume - power management resume main entry point
12435 * @dev: Device struct
12440 scsih_resume(struct device *dev) in scsih_resume()
12445 pci_power_t device_state = pdev->current_state; in scsih_resume()
12455 ioc->pdev = pdev; in scsih_resume()
12467 * scsih_pci_error_detected - Called when a PCI error is detected.
12468 * @pdev: PCI device struct
12491 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12492 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12497 /* Permanent error, prepare for device removal */ in scsih_pci_error_detected()
12498 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12508 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12509 * @pdev: PCI device struct
12527 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12528 ioc->pdev = pdev; in scsih_pci_slot_reset()
12547 * scsih_pci_resume() - resume normal ops after PCI reset
12548 * @pdev: pointer to PCI device
12566 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12570 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12571 * @pdev: pointer to PCI device
12584 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12587 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still in scsih_pci_mmio_enabled()
12594 * The pci device ids are defined in mpi/mpi2_cnfg.h.
12761 * scsih_init - main entry point for this driver.
12812 * scsih_exit - exit point for this driver (when it is a module).
12843 * _mpt3sas_init - main entry point for this driver.
12858 return -ENODEV; in _mpt3sas_init()
12868 return -ENODEV; in _mpt3sas_init()
12880 return -ENODEV; in _mpt3sas_init()
12902 * _mpt3sas_exit - exit point for this driver (when it is a module).