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()
2444 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2452 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2455 * obtaining the device_info bits for the 1st device in _scsih_get_volume_capabilities()
2459 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2463 raid_device->device_info = in _scsih_get_volume_capabilities()
2473 * _scsih_enable_tlr - setting TLR flags
2475 * @sdev: scsi device struct
2486 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2489 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2500 * scsih_device_configure - device configure routine.
2501 * @sdev: scsi device struct
2505 * the device is ignored.
2510 struct Scsi_Host *shost = sdev->host; in scsih_device_configure()
2522 u16 handle, volume_handle = 0; in scsih_device_configure() local
2526 sas_device_priv_data = sdev->hostdata; in scsih_device_configure()
2527 sas_device_priv_data->configured_lun = 1; in scsih_device_configure()
2528 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_device_configure()
2529 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_device_configure()
2530 handle = sas_target_priv_data->handle; in scsih_device_configure()
2533 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_device_configure()
2535 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_device_configure()
2536 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in scsih_device_configure()
2537 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_device_configure()
2562 if (raid_device->device_info & in scsih_device_configure()
2568 if (raid_device->device_info & in scsih_device_configure()
2575 switch (raid_device->volume_type) { in scsih_device_configure()
2581 if (ioc->manu_pg10.OEMIdentifier && in scsih_device_configure()
2582 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_device_configure()
2584 !(raid_device->num_pds % 2)) in scsih_device_configure()
2604 if (!ioc->hide_ir_msg) in scsih_device_configure()
2606 "%s: handle(0x%04x), wwid(0x%016llx)," in scsih_device_configure()
2608 r_level, raid_device->handle, in scsih_device_configure()
2609 (unsigned long long)raid_device->wwid, in scsih_device_configure()
2610 raid_device->num_pds, ds); in scsih_device_configure()
2612 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_device_configure()
2613 lim->max_hw_sectors = MPT3SAS_RAID_MAX_SECTORS; in scsih_device_configure()
2622 if (!ioc->is_warpdrive) in scsih_device_configure()
2623 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_device_configure()
2627 /* non-raid handling */ in scsih_device_configure()
2628 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_device_configure()
2629 if (mpt3sas_config_get_volume_handle(ioc, handle, in scsih_device_configure()
2646 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_device_configure()
2647 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_device_configure()
2649 sas_device_priv_data->sas_target->sas_address); in scsih_device_configure()
2651 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_device_configure()
2658 qdepth = ioc->max_nvme_qd; in scsih_device_configure()
2661 "%s: handle(0x%04x), wwid(0x%016llx), port(%d)\n", in scsih_device_configure()
2662 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_device_configure()
2663 pcie_device->port_num); in scsih_device_configure()
2664 if (pcie_device->enclosure_handle != 0) in scsih_device_configure()
2668 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_device_configure()
2669 pcie_device->slot); in scsih_device_configure()
2670 if (pcie_device->connector_name[0] != '\0') in scsih_device_configure()
2674 pcie_device->enclosure_level, in scsih_device_configure()
2675 pcie_device->connector_name); in scsih_device_configure()
2677 if (pcie_device->nvme_mdts) in scsih_device_configure()
2678 lim->max_hw_sectors = pcie_device->nvme_mdts / 512; in scsih_device_configure()
2681 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_device_configure()
2683 lim->virt_boundary_mask = ioc->page_size - 1; in scsih_device_configure()
2687 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_device_configure()
2689 sas_device_priv_data->sas_target->sas_address, in scsih_device_configure()
2690 sas_device_priv_data->sas_target->port); in scsih_device_configure()
2692 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_device_configure()
2699 sas_device->volume_handle = volume_handle; in scsih_device_configure()
2700 sas_device->volume_wwid = volume_wwid; in scsih_device_configure()
2701 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_device_configure()
2702 qdepth = (sas_device->port_type > 1) ? in scsih_device_configure()
2703 ioc->max_wideport_qd : ioc->max_narrowport_qd; in scsih_device_configure()
2705 if (sas_device->device_info & in scsih_device_configure()
2708 "set ignore_delay_remove for handle(0x%04x)\n", in scsih_device_configure()
2709 sas_device_priv_data->sas_target->handle); in scsih_device_configure()
2710 sas_device_priv_data->ignore_delay_remove = 1; in scsih_device_configure()
2715 qdepth = ioc->max_sata_qd; in scsih_device_configure()
2716 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_device_configure()
2718 else if (sas_device->device_info & in scsih_device_configure()
2723 sdev_printk(KERN_INFO, sdev, "%s: handle(0x%04x), " \ in scsih_device_configure()
2725 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_device_configure()
2726 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_device_configure()
2731 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_device_configure()
2734 _scsih_display_sata_capabilities(ioc, handle, sdev); in scsih_device_configure()
2748 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2749 * @sdev: scsi device struct
2750 * @bdev: pointer to block device context
2751 * @capacity: device size (in 512 byte sectors)
2774 * Handle extended translation size for logical drives in scsih_bios_param()
2794 * _scsih_response_code - translation of device response code
2796 * @response_code: response code returned by the device
2836 * _scsih_tm_done - tm completion routine
2853 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2855 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2857 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2860 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2861 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2863 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2864 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2869 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2871 * @handle: device handle
2873 * During taskmangement request, we need to freeze the device queue.
2876 mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_set_tm_flag() argument
2882 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2885 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2888 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2889 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2891 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2897 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2899 * @handle: device handle
2901 * During taskmangement request, we need to freeze the device queue.
2904 mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in mpt3sas_scsih_clear_tm_flag() argument
2910 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2913 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2916 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2917 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2919 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2925 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2941 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2957 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2958 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2959 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2961 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2962 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2963 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2971 * scsih_tm_post_processing - post processing of target & LUN reset
2973 * @handle: device handle
2988 scsih_tm_post_processing(struct MPT3SAS_ADAPTER *ioc, u16 handle, in scsih_tm_post_processing() argument
2999 " smid(%d), task_type(0x%02x), handle(0x%04x)\n", in scsih_tm_post_processing()
3000 smid_task, type, handle); in scsih_tm_post_processing()
3015 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
3017 * @handle: device handle
3030 * The callback index is set inside `ioc->tm_cb_idx`.
3036 mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, in mpt3sas_scsih_issue_tm() argument
3048 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
3050 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
3055 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
3056 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
3081 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
3088 …ioc_info(ioc, "sending tm: handle(0x%04x), task_type(0x%02x), smid(%d), timeout(%d), tr_method(0x%… in mpt3sas_scsih_issue_tm()
3089 handle, type, smid_task, timeout, tr_method)); in mpt3sas_scsih_issue_tm()
3090 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
3092 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
3094 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
3095 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
3096 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
3097 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
3100 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
3101 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
3102 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
3103 mpt3sas_scsih_set_tm_flag(ioc, handle); in mpt3sas_scsih_issue_tm()
3104 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
3105 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
3106 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
3107 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
3109 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
3122 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
3124 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
3127 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
3128 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
3129 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
3130 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
3131 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
3132 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
3143 * doesn't match with device handle on which this task abort in mpt3sas_scsih_issue_tm()
3153 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3156 ioc_info(ioc, "Task abort tm failed: handle(0x%04x)," in mpt3sas_scsih_issue_tm()
3158 handle, timeout, tr_method, smid_task, msix_task); in mpt3sas_scsih_issue_tm()
3165 rc = scsih_tm_post_processing(ioc, handle, channel, id, lun, in mpt3sas_scsih_issue_tm()
3177 mpt3sas_scsih_clear_tm_flag(ioc, handle); in mpt3sas_scsih_issue_tm()
3178 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3182 int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, in mpt3sas_scsih_issue_locked_tm() argument
3188 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3189 ret = mpt3sas_scsih_issue_tm(ioc, handle, channel, id, lun, type, in mpt3sas_scsih_issue_locked_tm()
3191 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3197 * _scsih_tm_display_info - displays info about the device
3206 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3207 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3215 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3221 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3223 "%s handle(0x%04x), %s wwid(0x%016llx)\n", in _scsih_tm_display_info()
3224 device_str, priv_target->handle, in _scsih_tm_display_info()
3225 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3227 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3228 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3232 "handle(0x%04x), wwid(0x%016llx), port(%d)\n", in _scsih_tm_display_info()
3233 pcie_device->handle, in _scsih_tm_display_info()
3234 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3235 pcie_device->port_num); in _scsih_tm_display_info()
3236 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3240 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3241 pcie_device->slot); in _scsih_tm_display_info()
3242 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3245 pcie_device->enclosure_level, in _scsih_tm_display_info()
3246 pcie_device->connector_name); in _scsih_tm_display_info()
3249 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3252 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3255 if (priv_target->flags & in _scsih_tm_display_info()
3258 "volume handle(0x%04x), " in _scsih_tm_display_info()
3260 sas_device->volume_handle, in _scsih_tm_display_info()
3261 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3264 "handle(0x%04x), sas_address(0x%016llx), phy(%d)\n", in _scsih_tm_display_info()
3265 sas_device->handle, in _scsih_tm_display_info()
3266 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3267 sas_device->phy); in _scsih_tm_display_info()
3274 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3279 * scsih_abort - eh threads main abort routine
3287 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3290 u16 handle; in scsih_abort() local
3295 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3297 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3298 (scsi_cmd_to_rq(scmd)->timeout / HZ) * 1000); in scsih_abort()
3301 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3302 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3303 ioc->remove_host) { in scsih_abort()
3304 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3305 "device been deleted! scmd(0x%p)\n", scmd); in scsih_abort()
3306 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3313 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3314 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3316 scmd->result = DID_RESET << 16; in scsih_abort()
3322 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3324 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3325 scmd->result = DID_RESET << 16; in scsih_abort()
3332 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3333 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_abort()
3334 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3335 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3336 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3337 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3338 scmd->device->id, scmd->device->lun, in scsih_abort()
3340 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3342 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3345 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3353 * scsih_dev_reset - eh threads main device reset routine
3361 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3365 u16 handle; in scsih_dev_reset() local
3370 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3371 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3373 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3374 "attempting device reset! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3377 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3378 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3379 ioc->remove_host) { in scsih_dev_reset()
3380 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3381 "device been deleted! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3382 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3389 handle = 0; in scsih_dev_reset()
3390 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3395 handle = sas_device->volume_handle; in scsih_dev_reset()
3397 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3399 if (!handle) { in scsih_dev_reset()
3400 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3405 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_dev_reset()
3407 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3408 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3409 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3414 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3415 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3419 if (r == SUCCESS && scsi_device_busy(scmd->device)) in scsih_dev_reset()
3422 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3434 * scsih_target_reset - eh threads main target reset routine
3442 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3446 u16 handle; in scsih_target_reset() local
3450 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3451 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3457 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3458 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3459 ioc->remove_host) { in scsih_target_reset()
3462 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3469 handle = 0; in scsih_target_reset()
3470 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3475 handle = sas_device->volume_handle; in scsih_target_reset()
3477 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3479 if (!handle) { in scsih_target_reset()
3480 scmd->result = DID_RESET << 16; in scsih_target_reset()
3485 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); in scsih_target_reset()
3487 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3488 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3489 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3493 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3494 scmd->device->id, 0, in scsih_target_reset()
3498 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3513 * scsih_host_reset - eh threads main host reset routine
3521 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3527 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3543 * _scsih_fw_event_add - insert and queue up fw_event
3546 * Context: This function will acquire ioc->fw_event_lock.
3556 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3559 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3561 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3562 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3563 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3565 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3566 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3570 * _scsih_fw_event_del_from_list - delete fw_event from the list
3573 * Context: This function will acquire ioc->fw_event_lock.
3583 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3584 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3585 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3588 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3593 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3604 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3610 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3611 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3612 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3618 * _scsih_error_recovery_delete_devices - remove devices not responding
3629 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3630 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3636 * mpt3sas_port_enable_complete - port enable completed (fake event)
3647 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3648 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3658 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3659 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3660 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3662 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3665 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3671 * _scsih_fw_event_cleanup_queue - cleanup event queue
3684 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3685 !ioc->firmware_event_thread) in _scsih_fw_event_cleanup_queue()
3693 if (ioc->shost_recovery && ioc->current_event) in _scsih_fw_event_cleanup_queue()
3694 ioc->current_event->ignore = 1; in _scsih_fw_event_cleanup_queue()
3696 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3698 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3714 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3715 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3717 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3722 * Driver has to clear ioc->start_scan flag when in _scsih_fw_event_cleanup_queue()
3729 if (fw_event->event == MPT3SAS_PORT_ENABLE_COMPLETE) { in _scsih_fw_event_cleanup_queue()
3730 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _scsih_fw_event_cleanup_queue()
3731 ioc->start_scan = 0; in _scsih_fw_event_cleanup_queue()
3742 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3746 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3750 * _scsih_internal_device_block - block the sdev device
3751 * @sdev: per device object
3752 * @sas_device_priv_data : per device driver private data
3754 * make sure device is blocked without error, if not
3763 sdev_printk(KERN_INFO, sdev, "device_block, handle(0x%04x)\n", in _scsih_internal_device_block()
3764 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3765 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3768 if (r == -EINVAL) in _scsih_internal_device_block()
3770 "device_block failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_block()
3771 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3775 * _scsih_internal_device_unblock - unblock the sdev device
3776 * @sdev: per device object
3777 * @sas_device_priv_data : per device driver private data
3778 * make sure device is unblocked without error, if not retry
3789 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3790 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3792 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3793 /* The device has been set to SDEV_RUNNING by SD layer during in _scsih_internal_device_unblock()
3794 * device addition but the request queue is still stopped by in _scsih_internal_device_unblock()
3796 * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */ in _scsih_internal_device_unblock()
3799 "device_unblock failed with return(%d) for handle(0x%04x) " in _scsih_internal_device_unblock()
3801 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3802 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3806 "failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_unblock()
3807 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3809 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3813 " failed with return(%d) for handle(0x%04x)\n", in _scsih_internal_device_unblock()
3814 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3819 * _scsih_ublock_io_all_device - unblock every device
3822 * change the device state from block to running
3830 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3831 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3834 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3838 "device_running, handle(0x%04x)\n", in _scsih_ublock_io_all_device()
3839 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3846 * _scsih_ublock_io_device - prepare device to be deleted
3851 * unblock then put device in offline state
3860 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3861 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3862 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3864 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3867 if (sas_device_priv_data->sas_target->port != port) in _scsih_ublock_io_device()
3869 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3876 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3879 * During device pull we need to appropriately set the sdev state.
3887 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3888 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3891 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3893 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3895 "%s skip device_block for SES handle(0x%04x)\n", in _scsih_block_io_all_device()
3896 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3904 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3906 * @handle: device handle
3908 * During device pull we need to appropriately set the sdev state.
3911 _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_block_io_device() argument
3917 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_block_io_device()
3919 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3920 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3923 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3925 if (sas_device_priv_data->block) in _scsih_block_io_device()
3927 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3929 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3931 "%s skip device_block for SES handle(0x%04x)\n", in _scsih_block_io_device()
3932 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3964 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3965 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3967 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3969 mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3970 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
3972 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3973 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3976 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3981 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3983 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3985 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3989 ioc, mpt3sas_port->remote_identify.sas_address, in _scsih_block_io_to_children_attached_to_ex()
3990 mpt3sas_port->hba_port); in _scsih_block_io_to_children_attached_to_ex()
4003 * direct attached during device pull.
4010 u16 handle; in _scsih_block_io_to_children_attached_directly() local
4013 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
4014 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
4015 if (!handle) in _scsih_block_io_to_children_attached_directly()
4017 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
4020 _scsih_block_io_device(ioc, handle); in _scsih_block_io_to_children_attached_directly()
4030 * direct attached during device pull/reconnect.
4037 u16 handle; in _scsih_block_io_to_pcie_children_attached_directly() local
4040 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
4041 handle = in _scsih_block_io_to_pcie_children_attached_directly()
4042 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
4043 if (!handle) in _scsih_block_io_to_pcie_children_attached_directly()
4045 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
4048 _scsih_block_io_device(ioc, handle); in _scsih_block_io_to_pcie_children_attached_directly()
4052 * _scsih_tm_tr_send - send task management request
4054 * @handle: device handle
4057 * This code is to initiate the device removal handshake protocol
4067 _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_tm_tr_send() argument
4081 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
4083 ioc_info(ioc, "%s: host in pci error recovery: handle(0x%04x)\n", in _scsih_tm_tr_send()
4084 __func__, handle)); in _scsih_tm_tr_send()
4090 ioc_info(ioc, "%s: host is not operational: handle(0x%04x)\n", in _scsih_tm_tr_send()
4091 __func__, handle)); in _scsih_tm_tr_send()
4096 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
4099 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
4101 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4102 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_tm_tr_send()
4103 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
4104 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
4105 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
4106 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4107 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
4108 port = sas_device->port; in _scsih_tm_tr_send()
4110 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
4112 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4113 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in _scsih_tm_tr_send()
4114 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
4115 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
4116 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
4117 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
4118 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
4120 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
4121 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
4123 pcie_device->device_info)))) in _scsih_tm_tr_send()
4131 ioc_info(ioc, "setting delete flag: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_tm_tr_send()
4132 handle, (u64)sas_address)); in _scsih_tm_tr_send()
4134 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4137 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
4138 sas_device->slot)); in _scsih_tm_tr_send()
4139 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4142 sas_device->enclosure_level, in _scsih_tm_tr_send()
4143 sas_device->connector_name)); in _scsih_tm_tr_send()
4145 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
4148 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
4149 pcie_device->slot)); in _scsih_tm_tr_send()
4150 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
4153 pcie_device->enclosure_level, in _scsih_tm_tr_send()
4154 pcie_device->connector_name)); in _scsih_tm_tr_send()
4157 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
4160 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
4165 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
4166 delayed_tr->handle = handle; in _scsih_tm_tr_send()
4167 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
4169 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_tm_tr_send()
4170 handle)); in _scsih_tm_tr_send()
4175 ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_send()
4176 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
4179 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
4180 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
4181 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
4182 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
4183 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
4184 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4195 * _scsih_tm_tr_complete -
4203 * This code is part of the code to initiate the device removal
4214 u16 handle; in _scsih_tm_tr_complete() local
4223 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4242 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4243 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4245 ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n", in _scsih_tm_tr_complete()
4246 handle, in _scsih_tm_tr_complete()
4247 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4253 …ioc_info(ioc, "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x), c… in _scsih_tm_tr_complete()
4254 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4255 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4256 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4258 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4263 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4264 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4265 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4267 ioc_info(ioc, "DELAYED:sc:handle(0x%04x), (open)\n", in _scsih_tm_tr_complete()
4268 handle)); in _scsih_tm_tr_complete()
4273 ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_complete()
4274 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4277 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4278 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4279 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4280 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4285 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4296 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4299 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4300 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4306 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4308 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4321 * _scsih_sas_control_complete - completion routine
4329 * This code is part of the code to initiate the device removal
4344 …ioc_info(ioc, "sc_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_sas_control_complete()
4345 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4346 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4347 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4348 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4350 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4351 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4361 * _scsih_tm_tr_volume_send - send target reset request for volumes
4363 * @handle: device handle
4371 _scsih_tm_tr_volume_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_tm_tr_volume_send() argument
4377 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4384 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4389 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4390 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4391 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4393 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_tm_tr_volume_send()
4394 handle)); in _scsih_tm_tr_volume_send()
4399 ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_tm_tr_volume_send()
4400 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4403 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4404 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4405 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4406 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4410 * _scsih_tm_volume_tr_complete - target reset completion
4424 u16 handle; in _scsih_tm_volume_tr_complete() local
4429 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4442 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4443 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4445 ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n", in _scsih_tm_volume_tr_complete()
4446 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4452 …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()
4453 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4454 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4455 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4461 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4467 * Context - processed in interrupt context.
4474 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4481 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4482 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4483 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4487 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4490 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4491 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4492 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4493 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4494 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4495 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4499 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4503 * @handle: device handle
4505 * Context - processed in interrupt context.
4509 u16 smid, u16 handle) in _scsih_issue_delayed_sas_io_unit_ctrl() argument
4513 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4516 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4521 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4539 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4540 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4541 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4544 ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n", in _scsih_issue_delayed_sas_io_unit_ctrl()
4545 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4548 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4549 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4550 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4551 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4555 * mpt3sas_check_for_pending_internal_cmds - check for pending internal messages
4573 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4574 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4577 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4578 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4583 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4584 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4587 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4588 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4596 * _scsih_check_for_pending_tm - check for pending task management
4611 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4612 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4615 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4616 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4621 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4622 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4625 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4626 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4635 * _scsih_check_topo_delete_events - sanity check on topo events
4639 * This routine added to better handle cable breaker.
4655 u16 handle; in _scsih_check_topo_delete_events() local
4657 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4658 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4659 if (!handle) in _scsih_check_topo_delete_events()
4661 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4664 _scsih_tm_tr_send(ioc, handle); in _scsih_check_topo_delete_events()
4667 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4668 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4672 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4675 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4679 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4681 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4682 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4683 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4684 _scsih_block_io_device(ioc, handle); in _scsih_check_topo_delete_events()
4685 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4686 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4689 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4693 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4694 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4695 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4696 fw_event->ignore) in _scsih_check_topo_delete_events()
4699 fw_event->event_data; in _scsih_check_topo_delete_events()
4700 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4702 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4704 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4708 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4712 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4716 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4722 * or device add and delete events in a single shot. When there
4734 u16 handle, switch_handle; in _scsih_check_pcie_topo_remove_events() local
4736 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4737 handle = in _scsih_check_pcie_topo_remove_events()
4738 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4739 if (!handle) in _scsih_check_pcie_topo_remove_events()
4741 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4743 _scsih_tm_tr_send(ioc, handle); in _scsih_check_pcie_topo_remove_events()
4746 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4753 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4755 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4760 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4764 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4765 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4766 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4767 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4771 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4772 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4774 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4776 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4780 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4784 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4788 * _scsih_set_volume_delete_flag - setting volume delete flag
4790 * @handle: device handle
4795 _scsih_set_volume_delete_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_set_volume_delete_flag() argument
4801 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4802 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_set_volume_delete_flag()
4803 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4804 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4806 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4807 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4809 ioc_info(ioc, "setting delete flag: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_set_volume_delete_flag()
4810 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4812 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4816 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4817 * @handle: input handle
4818 * @a: handle for volume a
4819 * @b: handle for volume b
4822 * routine is to set the volume handle in either a or b. When the given
4823 * input handle is non-zero, or when a and b have not been set before.
4826 _scsih_set_volume_handle_for_tr(u16 handle, u16 *a, u16 *b) in _scsih_set_volume_handle_for_tr() argument
4828 if (!handle || handle == *a || handle == *b) in _scsih_set_volume_handle_for_tr()
4831 *a = handle; in _scsih_set_volume_handle_for_tr()
4833 *b = handle; in _scsih_set_volume_handle_for_tr()
4837 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4854 u16 handle, volume_handle, a, b; in _scsih_check_ir_config_unhide_events() local
4860 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4864 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4865 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4866 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4869 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4871 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4873 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4880 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4881 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4882 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4885 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4886 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4897 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4898 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4899 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4901 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4902 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4903 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4905 _scsih_tm_tr_send(ioc, handle); in _scsih_check_ir_config_unhide_events()
4909 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4910 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4911 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4913 ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n", in _scsih_check_ir_config_unhide_events()
4914 handle)); in _scsih_check_ir_config_unhide_events()
4916 _scsih_tm_tr_send(ioc, handle); in _scsih_check_ir_config_unhide_events()
4922 * _scsih_check_volume_delete_events - set delete flag for volumes
4927 * This will handle the case when the cable connected to entire volume is
4937 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4939 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4943 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4947 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4957 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4959 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4960 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4961 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4962 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4963 event_data->SensorNum); in _scsih_temp_threshold_events()
4965 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4966 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4983 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4985 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4989 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4991 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4996 * _scsih_flush_running_cmds - completing outstanding commands.
5010 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
5019 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
5020 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
5022 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
5029 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5055 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK) in _scsih_setup_eedp()
5058 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) in _scsih_setup_eedp()
5061 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT) { in _scsih_setup_eedp()
5064 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
5068 mpi_request_3v->EEDPBlockSize = cpu_to_le16(scsi_prot_interval(scmd)); in _scsih_setup_eedp()
5070 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
5072 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
5076 * _scsih_eedp_error_handling - return sense code for EEDP errors
5104 * scsih_qcmd - main scsi request entry point
5108 * The callback index is set inside `ioc->scsi_io_cb_idx`.
5111 * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
5127 u16 handle; in scsih_qcmd() local
5129 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
5132 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
5133 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
5134 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5140 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5145 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
5147 /* invalid device handle */ in scsih_qcmd()
5148 handle = sas_target_priv_data->handle; in scsih_qcmd()
5151 * Avoid error handling escallation when device is disconnected in scsih_qcmd()
5153 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) { in scsih_qcmd()
5154 if (scmd->device->host->shost_state == SHOST_RECOVERY && in scsih_qcmd()
5155 scmd->cmnd[0] == TEST_UNIT_READY) { in scsih_qcmd()
5162 if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) { in scsih_qcmd()
5163 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5169 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
5172 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
5173 /* device has been deleted */ in scsih_qcmd()
5174 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
5177 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
5178 sas_device_priv_data->block) { in scsih_qcmd()
5179 /* device busy with task management */ in scsih_qcmd()
5189 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5193 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5195 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5203 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5208 /* Make sure Device is not raid volume. in scsih_qcmd()
5211 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5212 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5213 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5216 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5223 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5226 if (scmd->cmd_len == 32) in scsih_qcmd()
5228 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5229 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5231 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5233 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5234 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5235 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5236 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5237 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5238 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5239 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5240 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5242 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5243 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5244 mpi_request->LUN); in scsih_qcmd()
5245 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5247 if (mpi_request->DataLength) { in scsih_qcmd()
5248 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5249 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5255 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5257 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5258 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5262 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5263 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5264 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5266 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5268 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5269 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5271 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5279 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5288 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5289 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5290 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5293 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5294 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5295 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5300 * _scsih_scsi_ioc_info - translated non-successful SCSI_IO request
5306 * scsi_status - SCSI Status code returned from target device
5307 * scsi_state - state info associated with SCSI_IO determined by ioc
5308 * ioc_status - ioc supplied status info
5316 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5318 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5319 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5322 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5323 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5326 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5327 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5332 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5351 desc_ioc_state = "scsi invalid dev handle"; in _scsih_scsi_ioc_info()
5354 desc_ioc_state = "scsi device not there"; in _scsih_scsi_ioc_info()
5455 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5457 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5458 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5462 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5463 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5465 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5466 pcie_device->slot); in _scsih_scsi_ioc_info()
5467 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5469 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5470 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5477 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5487 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5490 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5491 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5492 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5493 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5499 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5502 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5505 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5512 * _scsih_turn_on_pfa_led - illuminate PFA LED
5514 * @handle: device handle
5518 _scsih_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_turn_on_pfa_led() argument
5524 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_turn_on_pfa_led()
5533 mpi_request.DevHandle = cpu_to_le16(handle); in _scsih_turn_on_pfa_led()
5541 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5555 * _scsih_turn_off_pfa_led - turn off Fault LED
5557 * @sas_device: sas device whose PFA LED has to turned off
5571 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5573 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5592 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5594 * @handle: device handle
5598 _scsih_send_event_to_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_send_event_to_turn_on_pfa_led() argument
5605 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5606 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5607 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5613 * _scsih_smart_predicted_fault - process smart errors
5615 * @handle: device handle
5619 _scsih_smart_predicted_fault(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_smart_predicted_fault() argument
5629 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5630 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5631 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_smart_predicted_fault()
5635 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5636 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5638 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5639 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5644 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5646 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5647 _scsih_send_event_to_turn_on_pfa_led(ioc, handle); in _scsih_smart_predicted_fault()
5659 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5660 event_reply->Event = in _scsih_smart_predicted_fault()
5662 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5663 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5666 event_reply->EventData; in _scsih_smart_predicted_fault()
5667 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5668 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5669 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5670 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5679 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5684 * _scsih_io_done - scsi request callback
5721 scmd->result = DID_OK << 16; in _scsih_io_done()
5725 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5726 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5727 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5728 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5731 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5738 if (st->direct_io && in _scsih_io_done()
5741 st->direct_io = 0; in _scsih_io_done()
5742 st->scmd = scmd; in _scsih_io_done()
5743 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5744 mpi_request->DevHandle = in _scsih_io_done()
5745 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5746 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5747 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5751 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5754 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5755 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5756 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5757 if ((!ioc->is_warpdrive && in _scsih_io_done()
5758 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5759 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5760 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5762 sas_disable_tlr(scmd->device); in _scsih_io_done()
5763 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5767 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5768 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5770 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5774 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5788 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5789 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5790 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5794 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5797 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5798 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5799 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5800 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5806 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5810 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5814 if (sas_device_priv_data->block) { in _scsih_io_done()
5815 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5819 if (scmd->retries > 2) { in _scsih_io_done()
5820 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5821 scsi_device_set_state(scmd->device, in _scsih_io_done()
5824 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5825 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5829 scmd->result = DID_RESET << 16; in _scsih_io_done()
5831 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5834 scmd->result = DID_RESET << 16; in _scsih_io_done()
5837 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5841 scmd->result = DID_RESET << 16; in _scsih_io_done()
5845 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5846 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5848 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5852 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5857 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5859 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5861 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5864 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5866 scmd->result = DID_RESET << 16; in _scsih_io_done()
5867 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5868 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5869 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5880 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5885 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5887 scmd->result = DID_RESET << 16; in _scsih_io_done()
5906 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5911 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5923 * _scsih_update_vphys_after_reset - update the Port's
5948 &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
5949 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
5952 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
5953 vphy->flags |= MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
5960 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_update_vphys_after_reset()
5976 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_update_vphys_after_reset()
5980 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_update_vphys_after_reset()
5984 * Check whether Phy is connected to SEP device or not, in _scsih_update_vphys_after_reset()
5985 * if it is SEP device then read the Phy's SASPHYPage0 data to in _scsih_update_vphys_after_reset()
5988 * device is a HBA's vSES device. in _scsih_update_vphys_after_reset()
5991 sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_update_vphys_after_reset()
6006 * Get the vSES device's SAS Address. in _scsih_update_vphys_after_reset()
6009 sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_update_vphys_after_reset()
6024 port_next, &ioc->port_table_list, list) { in _scsih_update_vphys_after_reset()
6025 if (!port->vphys_mask) in _scsih_update_vphys_after_reset()
6028 &port->vphys_list, list) { in _scsih_update_vphys_after_reset()
6033 if (!(vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY)) in _scsih_update_vphys_after_reset()
6039 * to current Phy's vSES device SAS Address. in _scsih_update_vphys_after_reset()
6041 if (vphy->sas_address != attached_sas_addr) in _scsih_update_vphys_after_reset()
6047 if (!(vphy->phy_mask & (1 << i))) in _scsih_update_vphys_after_reset()
6048 vphy->phy_mask = (1 << i); in _scsih_update_vphys_after_reset()
6056 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_update_vphys_after_reset()
6063 mport->port_id = port_id; in _scsih_update_vphys_after_reset()
6066 __func__, mport, mport->port_id); in _scsih_update_vphys_after_reset()
6067 list_add_tail(&mport->list, in _scsih_update_vphys_after_reset()
6068 &ioc->port_table_list); in _scsih_update_vphys_after_reset()
6073 * device's Port ID got changed after reset and in _scsih_update_vphys_after_reset()
6078 if (!mport->vphys_mask) in _scsih_update_vphys_after_reset()
6080 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6081 mport->vphys_mask |= (1 << i); in _scsih_update_vphys_after_reset()
6082 port->vphys_mask &= ~(1 << i); in _scsih_update_vphys_after_reset()
6083 list_move(&vphy->list, in _scsih_update_vphys_after_reset()
6084 &mport->vphys_list); in _scsih_update_vphys_after_reset()
6088 sas_device->port = mport; in _scsih_update_vphys_after_reset()
6093 * direct attached device with mport's Port ID, in _scsih_update_vphys_after_reset()
6095 * device has this Port ID, so unmark the mport in _scsih_update_vphys_after_reset()
6098 if (mport->flags & HBA_PORT_FLAG_DIRTY_PORT) { in _scsih_update_vphys_after_reset()
6099 mport->sas_address = 0; in _scsih_update_vphys_after_reset()
6100 mport->phy_mask = 0; in _scsih_update_vphys_after_reset()
6101 mport->flags &= in _scsih_update_vphys_after_reset()
6107 vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY; in _scsih_update_vphys_after_reset()
6120 * _scsih_get_port_table_after_reset - Construct temporary port table
6138 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_get_port_table_after_reset()
6152 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _scsih_get_port_table_after_reset()
6154 if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4) < in _scsih_get_port_table_after_reset()
6158 le16_to_cpu(sas_iounit_pg0->PhyData[i].AttachedDevHandle); in _scsih_get_port_table_after_reset()
6167 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6179 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_get_port_table_after_reset()
6199 * _scsih_look_and_get_matched_port_entry - Get matched hba port entry
6219 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_look_and_get_matched_port_entry()
6220 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT)) in _scsih_look_and_get_matched_port_entry()
6223 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6224 && (port_table_entry->phy_mask == port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6230 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6231 && (port_table_entry->phy_mask & port_entry->phy_mask) in _scsih_look_and_get_matched_port_entry()
6232 && (port_table_entry->port_id == port_entry->port_id)) { in _scsih_look_and_get_matched_port_entry()
6238 if ((port_table_entry->sas_address == port_entry->sas_address) in _scsih_look_and_get_matched_port_entry()
6239 && (port_table_entry->phy_mask & port_entry->phy_mask)) { in _scsih_look_and_get_matched_port_entry()
6248 if (port_table_entry->sas_address == port_entry->sas_address) { in _scsih_look_and_get_matched_port_entry()
6267 * _scsih_del_phy_part_of_anther_port - remove phy if it
6281 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_del_phy_part_of_anther_port()
6290 ioc, sas_node, &sas_node->phy[offset]); in _scsih_del_phy_part_of_anther_port()
6300 * _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from
6315 struct _sas_node *sas_node = &ioc->sas_hba; in _scsih_add_or_del_phys_from_existing_port()
6317 phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; in _scsih_add_or_del_phys_from_existing_port()
6319 for (offset = 0; offset < ioc->sas_hba.num_phys; offset++) { in _scsih_add_or_del_phys_from_existing_port()
6327 if (sas_node->phy[offset].phy_belongs_to_port) in _scsih_add_or_del_phys_from_existing_port()
6329 ioc, sas_node, &sas_node->phy[offset]); in _scsih_add_or_del_phys_from_existing_port()
6331 ioc, sas_node, &sas_node->phy[offset], in _scsih_add_or_del_phys_from_existing_port()
6332 hba_port_entry->sas_address, in _scsih_add_or_del_phys_from_existing_port()
6339 * _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty.
6351 &ioc->port_table_list, list) { in _scsih_del_dirty_vphy()
6352 if (!port->vphys_mask) in _scsih_del_dirty_vphy()
6355 &port->vphys_list, list) { in _scsih_del_dirty_vphy()
6356 if (vphy->flags & MPT_VPHY_FLAG_DIRTY_PHY) { in _scsih_del_dirty_vphy()
6359 vphy, port->port_id, in _scsih_del_dirty_vphy()
6360 vphy->phy_mask)); in _scsih_del_dirty_vphy()
6361 port->vphys_mask &= ~vphy->phy_mask; in _scsih_del_dirty_vphy()
6362 list_del(&vphy->list); in _scsih_del_dirty_vphy()
6366 if (!port->vphys_mask && !port->sas_address) in _scsih_del_dirty_vphy()
6367 port->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_del_dirty_vphy()
6372 * _scsih_del_dirty_port_entries - delete dirty port entries from port list
6383 &ioc->port_table_list, list) { in _scsih_del_dirty_port_entries()
6384 if (!(port->flags & HBA_PORT_FLAG_DIRTY_PORT) || in _scsih_del_dirty_port_entries()
6385 port->flags & HBA_PORT_FLAG_NEW_PORT) in _scsih_del_dirty_port_entries()
6390 port, port->port_id, port->phy_mask)); in _scsih_del_dirty_port_entries()
6391 list_del(&port->list); in _scsih_del_dirty_port_entries()
6397 * _scsih_sas_port_refresh - Update HBA port table after host reset
6414 (unsigned long long)ioc->sas_hba.sas_address)); in _scsih_sas_port_refresh()
6423 if (num_phys > ioc->sas_hba.nr_phys_allocated) { in _scsih_sas_port_refresh()
6428 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_port_refresh()
6430 port_table = kcalloc(ioc->sas_hba.num_phys, in _scsih_sas_port_refresh()
6446 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) in _scsih_sas_port_refresh()
6447 port_table_entry->flags |= HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6451 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) { in _scsih_sas_port_refresh()
6454 port_table_entry->port_id, in _scsih_sas_port_refresh()
6455 port_table_entry->phy_mask, in _scsih_sas_port_refresh()
6456 port_table_entry->sas_address)); in _scsih_sas_port_refresh()
6493 if (port_entry->port_id != port_table[j].port_id) in _scsih_sas_port_refresh()
6494 port_entry->port_id = port_table[j].port_id; in _scsih_sas_port_refresh()
6495 port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT; in _scsih_sas_port_refresh()
6496 port_entry->phy_mask = port_table[j].phy_mask; in _scsih_sas_port_refresh()
6503 * _scsih_alloc_vphy - allocate virtual_phy object
6526 if (!port->vphys_mask) in _scsih_alloc_vphy()
6527 INIT_LIST_HEAD(&port->vphys_list); in _scsih_alloc_vphy()
6533 port->vphys_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6534 vphy->phy_mask |= (1 << phy_num); in _scsih_alloc_vphy()
6536 list_add_tail(&vphy->list, &port->vphys_list); in _scsih_alloc_vphy()
6540 vphy, port->port_id, phy_num); in _scsih_alloc_vphy()
6546 * _scsih_sas_host_refresh - refreshing sas host object contents
6550 * During port enable, fw will send topology events for every device. Its
6569 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
6571 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_refresh()
6585 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
6586 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
6588 ioc->sas_hba.handle = le16_to_cpu( in _scsih_sas_host_refresh()
6589 sas_iounit_pg0->PhyData[0].ControllerDevHandle); in _scsih_sas_host_refresh()
6590 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_refresh()
6596 port->port_id = port_id; in _scsih_sas_host_refresh()
6599 port, port->port_id); in _scsih_sas_host_refresh()
6600 if (ioc->shost_recovery) in _scsih_sas_host_refresh()
6601 port->flags = HBA_PORT_FLAG_NEW_PORT; in _scsih_sas_host_refresh()
6602 list_add_tail(&port->list, &ioc->port_table_list); in _scsih_sas_host_refresh()
6605 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_refresh()
6607 if (le32_to_cpu(sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & in _scsih_sas_host_refresh()
6621 * Allocate a virtual_phy object for vSES device, if in _scsih_sas_host_refresh()
6622 * this vSES device is hot added. in _scsih_sas_host_refresh()
6626 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_refresh()
6633 if (!ioc->sas_hba.phy[i].phy) { in _scsih_sas_host_refresh()
6647 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_refresh()
6649 &ioc->sas_hba.phy[i], phy_pg0, in _scsih_sas_host_refresh()
6650 ioc->sas_hba.parent_dev); in _scsih_sas_host_refresh()
6653 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
6654 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
6658 ioc->sas_hba.phy[i].port = in _scsih_sas_host_refresh()
6660 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
6662 ioc->sas_hba.phy[i].port); in _scsih_sas_host_refresh()
6668 for (i = ioc->sas_hba.num_phys; in _scsih_sas_host_refresh()
6669 i < ioc->sas_hba.nr_phys_allocated; i++) { in _scsih_sas_host_refresh()
6670 if (ioc->sas_hba.phy[i].phy && in _scsih_sas_host_refresh()
6671 ioc->sas_hba.phy[i].phy->negotiated_linkrate >= in _scsih_sas_host_refresh()
6674 ioc->sas_hba.sas_address, 0, i, in _scsih_sas_host_refresh()
6682 * _scsih_sas_host_add - create sas host object
6685 * Creating host side data object, stored in ioc->sas_hba
6710 ioc->sas_hba.nr_phys_allocated = max_t(u8, in _scsih_sas_host_add()
6712 ioc->sas_hba.phy = kcalloc(ioc->sas_hba.nr_phys_allocated, in _scsih_sas_host_add()
6714 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
6719 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
6722 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6744 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6765 ioc->io_missing_delay = in _scsih_sas_host_add()
6766 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
6768 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
6770 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
6773 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
6776 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
6777 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
6793 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
6796 port_id = sas_iounit_pg0->PhyData[i].Port; in _scsih_sas_host_add()
6802 port->port_id = port_id; in _scsih_sas_host_add()
6805 port, port->port_id); in _scsih_sas_host_add()
6806 list_add_tail(&port->list, in _scsih_sas_host_add()
6807 &ioc->port_table_list); in _scsih_sas_host_add()
6811 * Check whether current Phy belongs to HBA vSES device or not. in _scsih_sas_host_add()
6818 * Allocate a virtual_phy object for vSES device. in _scsih_sas_host_add()
6822 ioc->sas_hba.phy[i].hba_vphy = 1; in _scsih_sas_host_add()
6825 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
6826 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
6827 ioc->sas_hba.phy[i].port = in _scsih_sas_host_add()
6829 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
6830 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
6833 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
6838 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
6840 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
6841 ioc_info(ioc, "host_add: handle(0x%04x), sas_addr(0x%016llx), phys(%d)\n", in _scsih_sas_host_add()
6842 ioc->sas_hba.handle, in _scsih_sas_host_add()
6843 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
6844 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
6846 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
6849 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
6850 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
6860 * _scsih_expander_add - creating expander object
6862 * @handle: expander handle
6864 * Creating expander object, stored in ioc->sas_expander_list.
6869 _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_expander_add() argument
6886 if (!handle) in _scsih_expander_add()
6887 return -1; in _scsih_expander_add()
6889 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
6890 return -1; in _scsih_expander_add()
6893 MPI2_SAS_EXPAND_PGAD_FORM_HNDL, handle))) { in _scsih_expander_add()
6896 return -1; in _scsih_expander_add()
6904 return -1; in _scsih_expander_add()
6907 /* handle out of order topology events */ in _scsih_expander_add()
6913 return -1; in _scsih_expander_add()
6917 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
6918 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6922 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6930 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6934 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6944 return -1; in _scsih_expander_add()
6947 sas_expander->handle = handle; in _scsih_expander_add()
6948 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6949 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6950 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6951 sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_expander_add()
6952 if (!sas_expander->port) { in _scsih_expander_add()
6955 rc = -1; in _scsih_expander_add()
6959 ioc_info(ioc, "expander_add: handle(0x%04x), parent(0x%04x), sas_addr(0x%016llx), phys(%d)\n", in _scsih_expander_add()
6960 handle, parent_handle, in _scsih_expander_add()
6961 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6963 if (!sas_expander->num_phys) { in _scsih_expander_add()
6964 rc = -1; in _scsih_expander_add()
6967 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6969 if (!sas_expander->phy) { in _scsih_expander_add()
6972 rc = -1; in _scsih_expander_add()
6976 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6977 mpt3sas_port = mpt3sas_transport_port_add(ioc, handle, in _scsih_expander_add()
6978 sas_address_parent, sas_expander->port); in _scsih_expander_add()
6982 rc = -1; in _scsih_expander_add()
6985 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6986 sas_expander->rphy = mpt3sas_port->rphy; in _scsih_expander_add()
6988 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
6990 &expander_pg1, i, handle))) { in _scsih_expander_add()
6993 rc = -1; in _scsih_expander_add()
6996 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
6997 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
6998 sas_expander->phy[i].port = in _scsih_expander_add()
7002 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
7003 sas_expander->parent_dev))) { in _scsih_expander_add()
7006 rc = -1; in _scsih_expander_add()
7011 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
7014 sas_expander->enclosure_handle); in _scsih_expander_add()
7016 sas_expander->enclosure_logical_id = in _scsih_expander_add()
7017 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
7026 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
7027 sas_address_parent, sas_expander->port); in _scsih_expander_add()
7033 * mpt3sas_expander_remove - removing expander object
7045 if (ioc->shost_recovery) in mpt3sas_expander_remove()
7051 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7054 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
7060 * _scsih_done - internal SCSI_IO callback handler.
7067 * The callback index passed is `ioc->scsih_cb_idx`
7078 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
7080 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
7082 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
7084 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
7085 mpi_reply->MsgLength*4); in _scsih_done()
7086 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
7088 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
7089 complete(&ioc->scsih_cmds.done); in _scsih_done()
7100 * _scsih_check_access_status - check access flags
7103 * @handle: sas device handle
7104 * @access_status: errors returned during discovery of the device
7110 u16 handle, u8 access_status) in _scsih_check_access_status() argument
7133 desc = "device blocked"; in _scsih_check_access_status()
7157 ioc_err(ioc, "discovery errors(%s): sas_address(0x%016llx), handle(0x%04x)\n", in _scsih_check_access_status()
7158 desc, (u64)sas_address, handle); in _scsih_check_access_status()
7163 * _scsih_check_device - checking device responsiveness
7166 * @handle: attached device handle
7172 u64 parent_sas_address, u16 handle, u8 phy_number, u8 link_rate) in _scsih_check_device() argument
7187 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) in _scsih_check_device()
7194 /* wide port handling ~ we need only handle device once for the phy that in _scsih_check_device()
7195 * is matched in sas device page zero in _scsih_check_device()
7200 /* check if this is end device */ in _scsih_check_device()
7205 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
7216 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
7217 starget = sas_device->starget; in _scsih_check_device()
7218 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
7220 "handle changed from(0x%04x) to (0x%04x)!!!\n", in _scsih_check_device()
7221 sas_device->handle, handle); in _scsih_check_device()
7222 sas_target_priv_data->handle = handle; in _scsih_check_device()
7223 sas_device->handle = handle; in _scsih_check_device()
7226 sas_device->enclosure_level = in _scsih_check_device()
7228 memcpy(sas_device->connector_name, in _scsih_check_device()
7230 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
7232 sas_device->enclosure_level = 0; in _scsih_check_device()
7233 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
7236 sas_device->enclosure_handle = in _scsih_check_device()
7238 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
7240 sas_device->enclosure_handle); in _scsih_check_device()
7242 sas_device->enclosure_logical_id = in _scsih_check_device()
7243 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
7244 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
7246 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
7247 sas_device->chassis_slot = in _scsih_check_device()
7248 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
7253 /* check if device is present */ in _scsih_check_device()
7256 ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_check_device()
7257 handle); in _scsih_check_device()
7262 if (_scsih_check_access_status(ioc, sas_address, handle, in _scsih_check_device()
7266 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7274 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
7280 * _scsih_add_device - creating sas device object
7282 * @handle: sas device handle
7283 * @phy_num: phy number end device attached to
7286 * Creating end device object, stored in ioc->sas_device_list.
7288 * Return: 0 for success, non-zero for failure.
7291 _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num, in _scsih_add_device() argument
7304 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_add_device()
7307 return -1; in _scsih_add_device()
7315 return -1; in _scsih_add_device()
7318 /* check if this is end device */ in _scsih_add_device()
7321 return -1; in _scsih_add_device()
7322 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7325 /* check if device is present */ in _scsih_add_device()
7328 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_add_device()
7329 handle); in _scsih_add_device()
7330 return -1; in _scsih_add_device()
7334 if (_scsih_check_access_status(ioc, sas_address, handle, in _scsih_add_device()
7336 return -1; in _scsih_add_device()
7342 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
7344 return -1; in _scsih_add_device()
7352 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_add_device()
7364 kref_init(&sas_device->refcount); in _scsih_add_device()
7365 sas_device->handle = handle; in _scsih_add_device()
7368 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
7371 sas_device->enclosure_handle = in _scsih_add_device()
7373 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
7374 sas_device->slot = in _scsih_add_device()
7376 sas_device->device_info = device_info; in _scsih_add_device()
7377 sas_device->sas_address = sas_address; in _scsih_add_device()
7378 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
7379 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
7381 sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); in _scsih_add_device()
7382 if (!sas_device->port) { in _scsih_add_device()
7390 sas_device->enclosure_level = in _scsih_add_device()
7392 memcpy(sas_device->connector_name, in _scsih_add_device()
7394 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
7396 sas_device->enclosure_level = 0; in _scsih_add_device()
7397 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
7400 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
7402 sas_device->enclosure_logical_id = in _scsih_add_device()
7403 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
7404 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
7406 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
7407 sas_device->chassis_slot = in _scsih_add_device()
7408 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
7412 /* get device name */ in _scsih_add_device()
7413 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
7414 sas_device->port_type = sas_device_pg0.MaxPortConnections; in _scsih_add_device()
7416 "handle(0x%0x) sas_address(0x%016llx) port_type(0x%0x)\n", in _scsih_add_device()
7417 handle, sas_device->sas_address, sas_device->port_type); in _scsih_add_device()
7419 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
7430 * _scsih_remove_device - removing sas device object
7440 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
7441 (sas_device->pfa_led_on)) { in _scsih_remove_device()
7443 sas_device->pfa_led_on = 0; in _scsih_remove_device()
7447 ioc_info(ioc, "%s: enter: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7449 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7454 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
7455 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
7456 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
7457 _scsih_ublock_io_device(ioc, sas_device->sas_address, in _scsih_remove_device()
7458 sas_device->port); in _scsih_remove_device()
7459 sas_target_priv_data->handle = in _scsih_remove_device()
7463 if (!ioc->hide_drives) in _scsih_remove_device()
7465 sas_device->sas_address, in _scsih_remove_device()
7466 sas_device->sas_address_parent, in _scsih_remove_device()
7467 sas_device->port); in _scsih_remove_device()
7469 ioc_info(ioc, "removing handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7470 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
7475 ioc_info(ioc, "%s: exit: handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_remove_device()
7477 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
7483 * _scsih_sas_topology_change_event_debug - debug for topology event
7493 u16 handle; in _scsih_sas_topology_change_event_debug() local
7499 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
7520 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
7521 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
7522 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
7523 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
7524 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
7525 if (!handle) in _scsih_sas_topology_change_event_debug()
7527 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
7528 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
7550 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
7551 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
7554 handle, status_str, link_rate, prev_link_rate); in _scsih_sas_topology_change_event_debug()
7560 * _scsih_sas_topology_change_event - handle topology changes
7571 u16 parent_handle, handle; in _scsih_sas_topology_change_event() local
7581 fw_event->event_data; in _scsih_sas_topology_change_event()
7583 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
7586 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7589 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
7594 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7599 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
7600 port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); in _scsih_sas_topology_change_event()
7602 /* handle expander add */ in _scsih_sas_topology_change_event()
7603 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
7607 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7611 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
7612 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
7613 port = sas_expander->port; in _scsih_sas_topology_change_event()
7614 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
7615 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
7616 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
7618 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7621 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
7623 /* handle siblings events */ in _scsih_sas_topology_change_event()
7624 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
7625 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
7630 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
7632 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
7635 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7637 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
7641 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
7642 if (!handle) in _scsih_sas_topology_change_event()
7644 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
7645 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
7649 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7656 handle, phy_number, link_rate, port); in _scsih_sas_topology_change_event()
7661 _scsih_check_device(ioc, sas_address, handle, in _scsih_sas_topology_change_event()
7664 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
7671 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
7675 handle, phy_number, link_rate, port); in _scsih_sas_topology_change_event()
7677 _scsih_add_device(ioc, handle, phy_number, 0); in _scsih_sas_topology_change_event()
7682 _scsih_device_remove_by_handle(ioc, handle); in _scsih_sas_topology_change_event()
7687 /* handle expander removal */ in _scsih_sas_topology_change_event()
7688 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
7696 * _scsih_sas_device_status_change_event_debug - debug for device event
7707 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
7712 reason_str = "unsupported device discovered"; in _scsih_sas_device_status_change_event_debug()
7715 reason_str = "internal device reset"; in _scsih_sas_device_status_change_event_debug()
7733 reason_str = "internal device reset complete"; in _scsih_sas_device_status_change_event_debug()
7751 ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)", in _scsih_sas_device_status_change_event_debug()
7752 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
7753 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
7754 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
7755 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
7757 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
7762 * _scsih_sas_device_status_change_event - handle device status change
7776 /* In MPI Revision K (0xC), the internal device reset complete was in _scsih_sas_device_status_change_event()
7779 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
7782 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7784 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
7788 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7789 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
7792 mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); in _scsih_sas_device_status_change_event()
7794 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
7797 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
7801 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
7803 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
7805 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
7807 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
7809 "%s tm_busy flag for handle(0x%04x)\n", in _scsih_sas_device_status_change_event()
7810 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
7811 target_priv_data->handle); in _scsih_sas_device_status_change_event()
7817 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
7822 * _scsih_check_pcie_access_status - check access flags
7825 * @handle: sas device handle
7826 * @access_status: errors returned during discovery of the device
7832 u16 handle, u8 access_status) in _scsih_check_pcie_access_status() argument
7843 desc = "PCIe device capability failed"; in _scsih_check_pcie_access_status()
7846 desc = "PCIe device blocked"; in _scsih_check_pcie_access_status()
7848 "Device with Access Status (%s): wwid(0x%016llx), " in _scsih_check_pcie_access_status()
7849 "handle(0x%04x)\n ll only be added to the internal list", in _scsih_check_pcie_access_status()
7850 desc, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7854 desc = "PCIe device mem space access failed"; in _scsih_check_pcie_access_status()
7857 desc = "PCIe device unsupported"; in _scsih_check_pcie_access_status()
7860 desc = "PCIe device MSIx Required"; in _scsih_check_pcie_access_status()
7863 desc = "PCIe device init fail max"; in _scsih_check_pcie_access_status()
7866 desc = "PCIe device status unknown"; in _scsih_check_pcie_access_status()
7872 desc = "nvme device configuration unsupported"; in _scsih_check_pcie_access_status()
7896 ioc_err(ioc, "NVMe discovery error(0x%02x): wwid(0x%016llx), handle(0x%04x)\n", in _scsih_check_pcie_access_status()
7897 access_status, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7904 ioc_info(ioc, "NVMe discovery error(%s): wwid(0x%016llx), handle(0x%04x)\n", in _scsih_check_pcie_access_status()
7905 desc, (u64)wwid, handle); in _scsih_check_pcie_access_status()
7910 * _scsih_pcie_device_remove_from_sml - removing pcie device
7922 ioc_info(ioc, "%s: enter: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7924 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7925 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7929 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7930 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7931 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7935 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7936 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7938 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
7939 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
7940 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
7941 _scsih_ublock_io_device(ioc, pcie_device->wwid, NULL); in _scsih_pcie_device_remove_from_sml()
7942 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
7945 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7946 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
7947 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7949 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7950 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
7951 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7953 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7954 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
7956 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
7958 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7960 ioc_info(ioc, "%s: exit: handle(0x%04x), wwid(0x%016llx)\n", in _scsih_pcie_device_remove_from_sml()
7962 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7963 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7967 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7968 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7969 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7973 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7974 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7976 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7981 * _scsih_pcie_check_device - checking device responsiveness
7983 * @handle: attached device handle
7986 _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_pcie_check_device() argument
7999 &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) in _scsih_pcie_check_device()
8006 /* check if this is end device */ in _scsih_pcie_check_device()
8012 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8016 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8020 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
8021 starget = pcie_device->starget; in _scsih_pcie_check_device()
8022 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
8023 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
8025 "handle changed from(0x%04x) to (0x%04x)!!!\n", in _scsih_pcie_check_device()
8026 pcie_device->handle, handle); in _scsih_pcie_check_device()
8027 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
8028 pcie_device->handle = handle; in _scsih_pcie_check_device()
8032 pcie_device->enclosure_level = in _scsih_pcie_check_device()
8034 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
8037 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
8038 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
8042 /* check if device is present */ in _scsih_pcie_check_device()
8045 ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_pcie_check_device()
8046 handle); in _scsih_pcie_check_device()
8047 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8053 if (_scsih_check_pcie_access_status(ioc, wwid, handle, in _scsih_pcie_check_device()
8055 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8060 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
8069 * _scsih_pcie_add_device - creating pcie device object
8071 * @handle: pcie device handle
8073 * Creating end device object, stored in ioc->pcie_device_list.
8078 _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_pcie_add_device() argument
8089 &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_pcie_add_device()
8102 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8105 /* check if device is present */ in _scsih_pcie_add_device()
8108 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_pcie_add_device()
8109 handle); in _scsih_pcie_add_device()
8114 if (_scsih_check_pcie_access_status(ioc, wwid, handle, in _scsih_pcie_add_device()
8124 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
8129 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
8130 * specific NVMe device; therefore, this page is only in _scsih_pcie_add_device()
8137 handle)) { in _scsih_pcie_add_device()
8161 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
8162 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
8163 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
8164 pcie_device->handle = handle; in _scsih_pcie_add_device()
8165 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
8166 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
8167 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
8168 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
8169 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
8172 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
8174 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
8175 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
8179 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
8180 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
8183 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
8184 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
8188 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
8191 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
8193 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
8194 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
8196 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
8199 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
8201 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
8208 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
8209 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
8210 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
8212 pcie_device->reset_timeout = in _scsih_pcie_add_device()
8215 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8217 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
8219 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
8229 * _scsih_pcie_topology_change_event_debug - debug for topology
8240 u16 handle; in _scsih_pcie_topology_change_event_debug() local
8246 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
8267 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
8268 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
8269 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
8270 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
8271 handle = in _scsih_pcie_topology_change_event_debug()
8272 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
8273 if (!handle) in _scsih_pcie_topology_change_event_debug()
8275 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
8276 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
8297 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
8299 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
8303 handle, status_str, link_rate, prev_link_rate); in _scsih_pcie_topology_change_event_debug()
8308 * _scsih_pcie_topology_change_event - handle PCIe topology
8320 u16 handle; in _scsih_pcie_topology_change_event() local
8326 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
8329 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
8332 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
8333 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8336 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8341 /* handle siblings events */ in _scsih_pcie_topology_change_event()
8342 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
8343 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
8348 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
8350 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
8351 handle = in _scsih_pcie_topology_change_event()
8352 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
8353 if (!handle) in _scsih_pcie_topology_change_event()
8356 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
8358 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
8363 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8370 _scsih_pcie_check_device(ioc, handle); in _scsih_pcie_topology_change_event()
8373 * where a device has been added, however its returning in _scsih_pcie_topology_change_event()
8374 * BUSY for sometime. Then before the Device Missing in _scsih_pcie_topology_change_event()
8375 * Delay expires and the device becomes READY, the in _scsih_pcie_topology_change_event()
8376 * device is removed and added back. in _scsih_pcie_topology_change_event()
8378 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8379 pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); in _scsih_pcie_topology_change_event()
8380 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
8387 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
8391 ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n", in _scsih_pcie_topology_change_event()
8392 handle)); in _scsih_pcie_topology_change_event()
8393 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
8394 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8398 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
8403 rc = _scsih_pcie_add_device(ioc, handle); in _scsih_pcie_topology_change_event()
8410 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
8415 _scsih_pcie_device_remove_by_handle(ioc, handle); in _scsih_pcie_topology_change_event()
8422 * _scsih_pcie_device_status_change_event_debug - debug for device event
8433 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
8438 reason_str = "unsupported device discovered"; in _scsih_pcie_device_status_change_event_debug()
8441 reason_str = "internal device reset"; in _scsih_pcie_device_status_change_event_debug()
8456 reason_str = "device init failure"; in _scsih_pcie_device_status_change_event_debug()
8459 reason_str = "internal device reset complete"; in _scsih_pcie_device_status_change_event_debug()
8475 ioc_info(ioc, "PCIE device status change: (%s)\n" in _scsih_pcie_device_status_change_event_debug()
8477 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
8478 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
8479 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
8480 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
8482 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
8487 * _scsih_pcie_device_status_change_event - handle device status
8502 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
8503 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
8507 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8509 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
8513 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8514 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
8517 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
8520 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
8524 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
8526 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
8528 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
8533 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
8537 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
8549 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
8564 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
8565 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
8566 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
8570 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
8582 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
8584 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
8586 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
8589 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
8590 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
8597 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
8609 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
8619 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
8620 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
8625 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
8635 * _scsih_sas_broadcast_primitive_event - handle broadcast events
8647 u16 smid, handle; in _scsih_sas_broadcast_primitive_event() local
8655 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
8662 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8664 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
8668 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8669 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
8679 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
8683 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
8684 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8690 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
8691 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
8692 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
8695 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8699 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8703 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
8707 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
8708 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
8711 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8714 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8715 r = mpt3sas_scsih_issue_tm(ioc, handle, 0, 0, lun, in _scsih_sas_broadcast_primitive_event()
8716 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
8717 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8722 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8725 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
8731 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8736 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8738 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
8740 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8749 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8753 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8756 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
8757 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
8758 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
8759 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
8770 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
8772 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
8773 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8776 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
8781 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
8786 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
8790 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
8793 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
8794 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
8796 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
8800 * _scsih_sas_discovery_event - handle discovery events
8810 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
8812 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
8814 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
8816 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
8818 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
8822 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
8823 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
8824 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
8826 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
8834 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
8845 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
8847 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
8849 …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()
8850 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8851 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8852 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8855 …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()
8856 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
8857 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
8858 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
8866 * _scsih_pcie_enumeration_event - handle enumeration events
8876 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
8878 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
8882 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
8884 event_data->Flags); in _scsih_pcie_enumeration_event()
8885 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
8887 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
8892 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
8894 * @handle: device handle for physical disk
8900 _scsih_ir_fastpath(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phys_disk_num) in _scsih_ir_fastpath() argument
8910 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
8913 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8915 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
8917 rc = -EAGAIN; in _scsih_ir_fastpath()
8920 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
8922 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
8925 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8926 rc = -EAGAIN; in _scsih_ir_fastpath()
8931 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
8934 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
8935 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
8936 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
8939 … ioc_info(ioc, "IR RAID_ACTION: turning fast path on for handle(0x%04x), phys_disk_num (0x%02x)\n", in _scsih_ir_fastpath()
8940 handle, phys_disk_num)); in _scsih_ir_fastpath()
8942 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
8943 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
8944 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
8946 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
8948 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
8950 rc = -EFAULT; in _scsih_ir_fastpath()
8954 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
8956 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
8957 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
8959 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8967 rc = -EFAULT; in _scsih_ir_fastpath()
8974 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8975 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8983 * _scsih_reprobe_lun - reprobing lun
8984 * @sdev: scsi device struct
8985 * @no_uld_attach: sdev->no_uld_attach flag setting
8991 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
8993 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
8998 * _scsih_sas_volume_add - add new volume
9010 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add() local
9013 mpt3sas_config_get_volume_wwid(ioc, handle, &wwid); in _scsih_sas_volume_add()
9020 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9022 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9034 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
9035 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
9036 raid_device->handle = handle; in _scsih_sas_volume_add()
9037 raid_device->wwid = wwid; in _scsih_sas_volume_add()
9039 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
9040 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
9041 raid_device->id, 0); in _scsih_sas_volume_add()
9045 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9047 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
9052 * _scsih_sas_volume_delete - delete volume
9054 * @handle: volume device handle
9058 _scsih_sas_volume_delete(struct MPT3SAS_ADAPTER *ioc, u16 handle) in _scsih_sas_volume_delete() argument
9065 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9066 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_volume_delete()
9068 if (raid_device->starget) { in _scsih_sas_volume_delete()
9069 starget = raid_device->starget; in _scsih_sas_volume_delete()
9070 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
9071 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
9073 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in _scsih_sas_volume_delete()
9074 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
9075 list_del(&raid_device->list); in _scsih_sas_volume_delete()
9078 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
9080 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
9084 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
9097 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose() local
9099 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9100 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_expose()
9102 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
9103 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
9104 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
9105 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
9106 starget = sas_device->starget; in _scsih_sas_pd_expose()
9107 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
9108 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
9112 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
9124 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
9137 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide() local
9141 mpt3sas_config_get_volume_handle(ioc, handle, &volume_handle); in _scsih_sas_pd_hide()
9146 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9147 sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_hide()
9149 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
9150 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
9151 starget = sas_device->starget; in _scsih_sas_pd_hide()
9152 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
9153 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
9155 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
9156 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
9159 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
9164 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
9173 * _scsih_sas_pd_delete - delete pd component
9182 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete() local
9184 _scsih_device_remove_by_handle(ioc, handle); in _scsih_sas_pd_delete()
9188 * _scsih_sas_pd_add - remove pd component
9198 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add() local
9205 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
9207 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_pd_add()
9209 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9215 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _scsih_sas_pd_add()
9231 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_sas_pd_add()
9236 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
9237 _scsih_add_device(ioc, handle, 0, 1); in _scsih_sas_pd_add()
9241 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
9255 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
9258 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
9260 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
9261 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
9262 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
9294 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
9310 pr_info("\t(%s:%s), vol handle(0x%04x), " \ in _scsih_sas_ir_config_change_event_debug()
9311 "pd handle(0x%04x), pd num(0x%02x)\n", element_str, in _scsih_sas_ir_config_change_event_debug()
9312 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
9313 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
9314 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
9319 * _scsih_sas_ir_config_change_event - handle ir configuration change events
9333 fw_event->event_data; in _scsih_sas_ir_config_change_event()
9335 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
9336 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
9339 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
9342 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
9343 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
9344 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
9345 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9346 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
9348 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
9349 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
9354 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
9356 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
9366 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
9369 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9373 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9377 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9381 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
9389 * _scsih_sas_ir_volume_event - IR volume event
9401 u16 handle; in _scsih_sas_ir_volume_event() local
9405 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
9407 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
9410 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
9413 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
9414 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
9415 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
9417 ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n", in _scsih_sas_ir_volume_event()
9418 __func__, handle, in _scsih_sas_ir_volume_event()
9419 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
9424 _scsih_sas_volume_delete(ioc, handle); in _scsih_sas_ir_volume_event()
9431 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9432 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_ir_volume_event()
9433 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
9438 mpt3sas_config_get_volume_wwid(ioc, handle, &wwid); in _scsih_sas_ir_volume_event()
9452 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
9453 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
9454 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
9455 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
9457 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
9458 raid_device->id, 0); in _scsih_sas_ir_volume_event()
9470 * _scsih_sas_ir_physical_disk_event - PD event
9479 u16 handle, parent_handle; in _scsih_sas_ir_physical_disk_event() local
9486 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
9489 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
9492 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
9495 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
9496 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
9498 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
9500 ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n", in _scsih_sas_ir_physical_disk_event()
9501 __func__, handle, in _scsih_sas_ir_physical_disk_event()
9502 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
9512 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
9513 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
9515 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_sas_ir_physical_disk_event()
9523 handle))) { in _scsih_sas_ir_physical_disk_event()
9539 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_sas_ir_physical_disk_event()
9544 _scsih_add_device(ioc, handle, 0, 1); in _scsih_sas_ir_physical_disk_event()
9557 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
9568 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
9591 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
9592 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
9596 * _scsih_sas_ir_operation_status_event - handle RAID operation events
9607 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
9610 u16 handle; in _scsih_sas_ir_operation_status_event() local
9612 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
9613 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
9618 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
9620 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9621 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
9622 raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle); in _scsih_sas_ir_operation_status_event()
9624 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
9625 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
9626 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
9631 * _scsih_prep_device_scan - initialize parameters prior to device scan
9634 * Set the deleted flag prior to device scan. If the device is found during
9643 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
9644 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
9645 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
9646 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
9651 * _scsih_update_device_qdepth - Update QD during Reset.
9665 shost_for_each_device(sdev, ioc->shost) { in _scsih_update_device_qdepth()
9666 sas_device_priv_data = sdev->hostdata; in _scsih_update_device_qdepth()
9667 if (sas_device_priv_data && sas_device_priv_data->sas_target) { in _scsih_update_device_qdepth()
9668 sas_target_priv_data = sas_device_priv_data->sas_target; in _scsih_update_device_qdepth()
9669 sas_device = sas_device_priv_data->sas_target->sas_dev; in _scsih_update_device_qdepth()
9670 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) in _scsih_update_device_qdepth()
9671 qdepth = ioc->max_nvme_qd; in _scsih_update_device_qdepth()
9673 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) in _scsih_update_device_qdepth()
9674 qdepth = (sas_device->port_type > 1) ? in _scsih_update_device_qdepth()
9675 ioc->max_wideport_qd : ioc->max_narrowport_qd; in _scsih_update_device_qdepth()
9677 sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in _scsih_update_device_qdepth()
9678 qdepth = ioc->max_sata_qd; in _scsih_update_device_qdepth()
9687 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
9689 * @sas_device_pg0: SAS Device page 0
9704 ioc, sas_device_pg0->PhysicalPort, 0); in _scsih_mark_responding_sas_device()
9706 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
9709 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
9711 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_mark_responding_sas_device()
9712 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9714 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9715 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
9716 if (sas_device->sas_address != le64_to_cpu( in _scsih_mark_responding_sas_device()
9717 sas_device_pg0->SASAddress)) in _scsih_mark_responding_sas_device()
9719 if (sas_device->slot != le16_to_cpu(sas_device_pg0->Slot)) in _scsih_mark_responding_sas_device()
9721 if (sas_device->port != port) in _scsih_mark_responding_sas_device()
9723 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
9724 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
9725 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
9726 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
9727 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
9728 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
9733 "handle(0x%04x), sas_addr(0x%016llx)\n", in _scsih_mark_responding_sas_device()
9734 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
9736 sas_device->sas_address); in _scsih_mark_responding_sas_device()
9738 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
9742 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
9743 sas_device->slot); in _scsih_mark_responding_sas_device()
9745 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
9747 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
9748 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
9749 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
9750 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
9752 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
9753 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
9756 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
9757 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
9758 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
9760 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
9761 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
9762 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
9764 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
9765 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
9766 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
9770 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
9771 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
9774 sas_device->handle); in _scsih_mark_responding_sas_device()
9775 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
9776 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9778 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
9779 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
9783 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
9787 * _scsih_create_enclosure_list_after_reset - Free Existing list,
9813 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
9822 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
9823 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
9825 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
9830 * _scsih_search_responding_sas_devices -
9842 u16 handle; in _scsih_search_responding_sas_devices() local
9845 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
9847 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
9850 handle = 0xFFFF; in _scsih_search_responding_sas_devices()
9853 handle))) { in _scsih_search_responding_sas_devices()
9858 handle = le16_to_cpu(sas_device_pg0.DevHandle); in _scsih_search_responding_sas_devices()
9866 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
9870 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
9872 * @pcie_device_pg0: PCIe Device page 0
9886 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9887 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
9888 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
9889 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9890 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
9891 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
9892 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
9893 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
9894 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
9895 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
9896 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
9897 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
9898 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
9903 "handle(0x%04x), wwid(0x%016llx) ", in _scsih_mark_responding_pcie_device()
9904 pcie_device->handle, in _scsih_mark_responding_pcie_device()
9905 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
9906 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
9911 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
9912 pcie_device->slot); in _scsih_mark_responding_pcie_device()
9915 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
9917 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
9918 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
9919 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
9920 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
9921 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
9923 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
9924 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
9927 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
9928 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
9931 pcie_device->handle); in _scsih_mark_responding_pcie_device()
9932 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
9933 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9935 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
9936 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
9942 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
9946 * _scsih_search_responding_pcie_devices -
9958 u16 handle; in _scsih_search_responding_pcie_devices() local
9961 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
9963 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
9966 handle = 0xFFFF; in _scsih_search_responding_pcie_devices()
9969 handle))) { in _scsih_search_responding_pcie_devices()
9978 handle = le16_to_cpu(pcie_device_pg0.DevHandle); in _scsih_search_responding_pcie_devices()
9985 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
9989 * _scsih_mark_responding_raid_device - mark a raid_device as responding
9992 * @handle: device handle
9999 u16 handle) in _scsih_mark_responding_raid_device() argument
10006 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10007 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
10008 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
10009 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
10010 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
10011 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
10012 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
10015 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
10016 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10017 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
10018 "handle(0x%04x), wwid(0x%016llx)\n", handle, in _scsih_mark_responding_raid_device()
10019 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
10023 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
10027 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10028 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
10029 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
10034 raid_device->handle); in _scsih_mark_responding_raid_device()
10035 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
10037 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
10038 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10042 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
10046 * _scsih_search_responding_raid_devices -
10060 u16 handle; in _scsih_search_responding_raid_devices() local
10063 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
10068 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
10071 handle = 0xFFFF; in _scsih_search_responding_raid_devices()
10073 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { in _scsih_search_responding_raid_devices()
10078 handle = le16_to_cpu(volume_pg1.DevHandle); in _scsih_search_responding_raid_devices()
10081 &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in _scsih_search_responding_raid_devices()
10089 le64_to_cpu(volume_pg1.WWID), handle); in _scsih_search_responding_raid_devices()
10093 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
10095 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
10104 handle = le16_to_cpu(pd_pg0.DevHandle); in _scsih_search_responding_raid_devices()
10105 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
10113 * _scsih_mark_responding_expander - mark a expander as responding
10128 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander() local
10129 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10130 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
10132 ioc, expander_pg0->PhysicalPort, 0); in _scsih_mark_responding_expander()
10139 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10140 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
10141 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
10143 if (sas_expander->port != port) in _scsih_mark_responding_expander()
10145 sas_expander->responding = 1; in _scsih_mark_responding_expander()
10148 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
10149 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
10150 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
10151 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
10154 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
10156 pr_info("\texpander(0x%016llx): handle changed" \ in _scsih_mark_responding_expander()
10158 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
10159 sas_expander->handle, handle); in _scsih_mark_responding_expander()
10160 sas_expander->handle = handle; in _scsih_mark_responding_expander()
10161 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
10162 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
10166 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
10170 * _scsih_search_responding_expanders -
10183 u16 handle; in _scsih_search_responding_expanders() local
10188 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
10191 handle = 0xFFFF; in _scsih_search_responding_expanders()
10193 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { in _scsih_search_responding_expanders()
10200 handle = le16_to_cpu(expander_pg0.DevHandle); in _scsih_search_responding_expanders()
10204 "\texpander present: handle(0x%04x), sas_addr(0x%016llx), port:%d\n", in _scsih_search_responding_expanders()
10205 handle, (unsigned long long)sas_address, in _scsih_search_responding_expanders()
10206 (ioc->multipath_on_hba ? in _scsih_search_responding_expanders()
10216 * _scsih_remove_unresponding_devices - removing unresponding devices
10233 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
10235 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
10238 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10245 &ioc->sas_device_init_list, list) { in _scsih_remove_unresponding_devices()
10246 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10251 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
10252 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
10253 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
10255 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
10257 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
10264 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
10268 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
10270 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10276 &ioc->pcie_device_init_list, list) { in _scsih_remove_unresponding_devices()
10277 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10282 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
10283 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
10284 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
10286 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
10288 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
10292 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
10297 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
10300 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
10301 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
10303 raid_device->handle); in _scsih_remove_unresponding_devices()
10305 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
10311 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10314 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
10315 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
10316 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
10318 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
10320 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
10334 struct _sas_node *sas_expander, u16 handle) in _scsih_refresh_expander_links() argument
10340 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
10342 &expander_pg1, i, handle))) { in _scsih_refresh_expander_links()
10348 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
10351 sas_expander->port); in _scsih_refresh_expander_links()
10356 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
10372 u16 handle, parent_handle; in _scsih_scan_for_devices_after_reset() local
10388 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10390 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { in _scsih_scan_for_devices_after_reset()
10398 handle = le16_to_cpu(expander_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10399 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10404 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
10407 handle); in _scsih_scan_for_devices_after_reset()
10409 ioc_info(ioc, "\tBEFORE adding expander: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10410 handle, in _scsih_scan_for_devices_after_reset()
10412 _scsih_expander_add(ioc, handle); in _scsih_scan_for_devices_after_reset()
10413 ioc_info(ioc, "\tAFTER adding expander: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10414 handle, in _scsih_scan_for_devices_after_reset()
10421 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
10439 handle = le16_to_cpu(pd_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10440 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); in _scsih_scan_for_devices_after_reset()
10447 handle) != 0) in _scsih_scan_for_devices_after_reset()
10459 ioc_info(ioc, "\tBEFORE adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10460 handle, in _scsih_scan_for_devices_after_reset()
10464 handle, sas_device_pg0.PhyNum, in _scsih_scan_for_devices_after_reset()
10467 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
10469 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10473 while (_scsih_add_device(ioc, handle, retry_count++, in _scsih_scan_for_devices_after_reset()
10477 ioc_info(ioc, "\tAFTER adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10478 handle, in _scsih_scan_for_devices_after_reset()
10488 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10490 &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { in _scsih_scan_for_devices_after_reset()
10498 handle = le16_to_cpu(volume_pg1.DevHandle); in _scsih_scan_for_devices_after_reset()
10499 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10502 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
10506 &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, in _scsih_scan_for_devices_after_reset()
10522 ioc_info(ioc, "\tBEFORE adding volume: handle (0x%04x)\n", in _scsih_scan_for_devices_after_reset()
10525 ioc_info(ioc, "\tAFTER adding volume: handle (0x%04x)\n", in _scsih_scan_for_devices_after_reset()
10537 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10540 handle))) { in _scsih_scan_for_devices_after_reset()
10544 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10548 handle = le16_to_cpu(sas_device_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10562 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10563 handle, in _scsih_scan_for_devices_after_reset()
10565 mpt3sas_transport_update_links(ioc, sas_address, handle, in _scsih_scan_for_devices_after_reset()
10569 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
10573 while (_scsih_add_device(ioc, handle, retry_count++, in _scsih_scan_for_devices_after_reset()
10577 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10578 handle, in _scsih_scan_for_devices_after_reset()
10586 handle = 0xFFFF; in _scsih_scan_for_devices_after_reset()
10589 handle))) { in _scsih_scan_for_devices_after_reset()
10593 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
10597 handle = le16_to_cpu(pcie_device_pg0.DevHandle); in _scsih_scan_for_devices_after_reset()
10609 _scsih_pcie_add_device(ioc, handle); in _scsih_scan_for_devices_after_reset()
10611 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
10612 handle, (u64)le64_to_cpu(pcie_device_pg0.WWID)); in _scsih_scan_for_devices_after_reset()
10620 * mpt3sas_scsih_pre_reset_handler - reset callback handler (for scsih)
10631 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
10642 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10643 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10644 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10645 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10647 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10648 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10649 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10650 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10653 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10654 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10655 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
10661 * mpt3sas_scsih_reset_done_handler - reset callback handler (for scsih)
10670 if (!(disable_discovery > 0 && !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
10671 if (ioc->multipath_on_hba) { in mpt3sas_scsih_reset_done_handler()
10686 * _mpt3sas_fw_work - delayed task for processing firmware events
10694 ioc->current_event = fw_event; in _mpt3sas_fw_work()
10698 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
10700 ioc->current_event = NULL; in _mpt3sas_fw_work()
10704 switch (fw_event->event) { in _mpt3sas_fw_work()
10708 fw_event->event_data); in _mpt3sas_fw_work()
10711 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
10712 ioc->shost_recovery) { in _mpt3sas_fw_work()
10717 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
10724 if (ioc->is_gen35_ioc) in _mpt3sas_fw_work()
10731 *- Register the devices from sas_device_init_list to SML in _mpt3sas_fw_work()
10732 *- clear is_driver_loading flag, in _mpt3sas_fw_work()
10733 *- start the watchdog thread. in _mpt3sas_fw_work()
10737 if (ioc->is_driver_loading) in _mpt3sas_fw_work()
10742 ioc->start_scan = 0; in _mpt3sas_fw_work()
10743 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
10750 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
10756 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
10759 fw_event->event_data); in _mpt3sas_fw_work()
10794 ioc->current_event = NULL; in _mpt3sas_fw_work()
10799 ioc->current_event = NULL; in _mpt3sas_fw_work()
10816 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
10820 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
10826 * This function merely adds a new work task into ioc->firmware_event_thread.
10843 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
10854 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
10860 /* handle these */ in mpt3sas_scsih_event_callback()
10865 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10867 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
10871 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
10872 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
10875 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
10882 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10888 * sas device page0's not by processing the in mpt3sas_scsih_event_callback()
10891 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10897 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10898 if (ioc->shost_recovery) in mpt3sas_scsih_event_callback()
10904 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10909 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10916 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
10920 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10921 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); in mpt3sas_scsih_event_callback()
10923 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
10935 …no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode.… in mpt3sas_scsih_event_callback()
10947 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10961 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
10965 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
10966 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
10969 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10974 ActiveCableEventData->ActiveCablePowerRequirement)); in mpt3sas_scsih_event_callback()
10979 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
10991 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
10999 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
11000 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
11001 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
11002 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
11003 fw_event->event = event; in mpt3sas_scsih_event_callback()
11010 * _scsih_expander_node_remove - removing expander device from list.
11015 * ioc->sas_expander_list.
11027 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
11028 if (ioc->shost_recovery) in _scsih_expander_node_remove()
11030 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11033 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11034 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11035 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11037 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
11040 mpt3sas_port->remote_identify.sas_address, in _scsih_expander_node_remove()
11041 mpt3sas_port->hba_port); in _scsih_expander_node_remove()
11044 port_id = sas_expander->port->port_id; in _scsih_expander_node_remove()
11046 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
11047 sas_expander->sas_address_parent, sas_expander->port); in _scsih_expander_node_remove()
11050 "expander_remove: handle(0x%04x), sas_addr(0x%016llx), port:%d\n", in _scsih_expander_node_remove()
11051 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
11052 sas_expander->sas_address, in _scsih_expander_node_remove()
11055 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11056 list_del(&sas_expander->list); in _scsih_expander_node_remove()
11057 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
11059 kfree(sas_expander->phy); in _scsih_expander_node_remove()
11064 * _scsih_nvme_shutdown - NVMe shutdown notification
11079 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
11082 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11084 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
11089 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
11091 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
11095 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11100 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
11102 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
11103 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
11105 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
11106 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
11110 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
11111 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
11112 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
11114 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
11119 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
11120 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
11123 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
11124 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
11127 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
11128 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
11133 * _scsih_ir_shutdown - IR shutdown notification
11147 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
11151 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
11154 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11156 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
11160 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
11162 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
11165 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11170 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
11173 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
11174 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
11176 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11178 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
11179 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
11180 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
11182 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
11187 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
11188 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
11189 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
11191 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
11192 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
11196 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
11197 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
11201 * _scsih_get_shost_and_ioc - get shost and ioc
11203 * @pdev: PCI device struct
11215 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
11216 return -ENXIO; in _scsih_get_shost_and_ioc()
11221 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
11222 return -ENXIO; in _scsih_get_shost_and_ioc()
11229 * scsih_remove - detach and remove add host
11230 * @pdev: PCI device struct
11250 ioc->remove_host = 1; in scsih_remove()
11259 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
11260 wq = ioc->firmware_event_thread; in scsih_remove()
11261 ioc->firmware_event_thread = NULL; in scsih_remove()
11262 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
11269 if (ioc->is_aero_ioc) in scsih_remove()
11271 &ioc->ioc_pg1_copy); in scsih_remove()
11276 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
11278 if (raid_device->starget) { in scsih_remove()
11280 raid_device->starget->hostdata; in scsih_remove()
11281 sas_target_priv_data->deleted = 1; in scsih_remove()
11282 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
11284 ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n", in scsih_remove()
11285 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
11288 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
11291 list_del_init(&pcie_device->list); in scsih_remove()
11297 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
11298 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11301 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11302 mpt3sas_port->hba_port); in scsih_remove()
11303 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
11305 mpt3sas_port->remote_identify.device_type == in scsih_remove()
11308 mpt3sas_port->remote_identify.sas_address, in scsih_remove()
11309 mpt3sas_port->hba_port); in scsih_remove()
11313 &ioc->port_table_list, list) { in scsih_remove()
11314 list_del(&port->list); in scsih_remove()
11319 if (ioc->sas_hba.num_phys) { in scsih_remove()
11320 kfree(ioc->sas_hba.phy); in scsih_remove()
11321 ioc->sas_hba.phy = NULL; in scsih_remove()
11322 ioc->sas_hba.num_phys = 0; in scsih_remove()
11328 list_del(&ioc->list); in scsih_remove()
11334 * scsih_shutdown - routine call during system shutdown
11335 * @pdev: PCI device struct
11349 ioc->remove_host = 1; in scsih_shutdown()
11358 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
11359 wq = ioc->firmware_event_thread; in scsih_shutdown()
11360 ioc->firmware_event_thread = NULL; in scsih_shutdown()
11361 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
11368 if (ioc->is_aero_ioc) in scsih_shutdown()
11370 &ioc->ioc_pg1_copy); in scsih_shutdown()
11376 ioc->shost_recovery = 1; in scsih_shutdown()
11378 ioc->shost_recovery = 0; in scsih_shutdown()
11385 * _scsih_probe_boot_devices - reports 1st device
11389 * device scsi-ml or sas transport for persistent boot device
11396 void *device; in _scsih_probe_boot_devices() local
11400 u16 handle; in _scsih_probe_boot_devices() local
11409 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
11412 device = NULL; in _scsih_probe_boot_devices()
11413 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
11414 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
11415 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
11416 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
11417 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
11418 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
11419 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
11420 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
11421 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
11424 if (!device) in _scsih_probe_boot_devices()
11428 raid_device = device; in _scsih_probe_boot_devices()
11431 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11434 if (raid_device->starget) in _scsih_probe_boot_devices()
11436 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
11437 raid_device->id, 0); in _scsih_probe_boot_devices()
11441 pcie_device = device; in _scsih_probe_boot_devices()
11443 * If this boot NVMe device is already registered with SML then in _scsih_probe_boot_devices()
11444 * no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11447 if (pcie_device->starget) in _scsih_probe_boot_devices()
11449 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11450 tid = pcie_device->id; in _scsih_probe_boot_devices()
11451 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
11452 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
11453 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
11457 sas_device = device; in _scsih_probe_boot_devices()
11459 * If this boot sas/sata device is already registered with SML in _scsih_probe_boot_devices()
11460 * then no need to register it again as part of device scanning in _scsih_probe_boot_devices()
11463 if (sas_device->starget) in _scsih_probe_boot_devices()
11465 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11466 handle = sas_device->handle; in _scsih_probe_boot_devices()
11467 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
11468 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
11469 port = sas_device->port; in _scsih_probe_boot_devices()
11470 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
11471 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
11473 if (ioc->hide_drives) in _scsih_probe_boot_devices()
11479 if (!mpt3sas_transport_port_add(ioc, handle, in _scsih_probe_boot_devices()
11482 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
11483 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
11494 * _scsih_probe_raid - reporting raid volumes to scsi-ml
11506 &ioc->raid_device_list, list) { in _scsih_probe_raid()
11507 if (raid_device->starget) in _scsih_probe_raid()
11509 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
11510 raid_device->id, 0); in _scsih_probe_raid()
11521 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
11522 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
11523 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
11527 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
11537 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
11547 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
11548 list_del_init(&sas_device->list); in sas_device_make_active()
11553 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
11555 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
11559 * _scsih_probe_sas - reporting sas devices to sas transport
11569 if (ioc->hide_drives) in _scsih_probe_sas()
11573 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
11574 sas_device->sas_address_parent, sas_device->port)) { in _scsih_probe_sas()
11578 } else if (!sas_device->starget) { in _scsih_probe_sas()
11582 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
11585 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
11587 sas_device->sas_address, in _scsih_probe_sas()
11588 sas_device->sas_address_parent, in _scsih_probe_sas()
11589 sas_device->port); in _scsih_probe_sas()
11601 * get_next_pcie_device - Get the next pcie device
11604 * Get the next pcie device from pcie_device_init_list list.
11606 * Return: pcie device structure if pcie_device_init_list list is not empty
11614 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11615 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
11616 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
11620 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
11626 * pcie_device_make_active - Add pcie device to pcie_device_list list
11628 * @pcie_device: pcie device object
11630 * Add the pcie device which has registered with SCSI Transport Later to
11638 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11640 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
11641 list_del_init(&pcie_device->list); in pcie_device_make_active()
11645 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
11647 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
11651 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
11662 /* PCIe Device List */ in _scsih_probe_pcie()
11664 if (pcie_device->starget) { in _scsih_probe_pcie()
11668 if (pcie_device->access_status == in _scsih_probe_pcie()
11674 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
11675 pcie_device->id, 0); in _scsih_probe_pcie()
11680 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
11684 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
11687 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
11688 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
11702 * _scsih_probe_devices - probing for devices
11712 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
11717 if (ioc->ir_firmware) { in _scsih_probe_devices()
11719 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
11736 * scsih_scan_start - scsi lld callback for .scan_start
11748 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
11750 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
11756 ioc->start_scan = 1; in scsih_scan_start()
11764 * _scsih_complete_devices_scanning - add the devices to sml and
11773 if (ioc->wait_for_discovery_to_complete) { in _scsih_complete_devices_scanning()
11774 ioc->wait_for_discovery_to_complete = 0; in _scsih_complete_devices_scanning()
11779 ioc->is_driver_loading = 0; in _scsih_complete_devices_scanning()
11783 * scsih_scan_finished - scsi lld callback for .scan_finished
11799 ioc->is_driver_loading = 0; in scsih_scan_finished()
11800 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11805 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11807 ioc->is_driver_loading = 0; in scsih_scan_finished()
11811 if (ioc->start_scan) { in scsih_scan_finished()
11829 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) { in scsih_scan_finished()
11832 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11835 if (ioc->start_scan_failed) { in scsih_scan_finished()
11837 ioc->start_scan_failed); in scsih_scan_finished()
11838 ioc->is_driver_loading = 0; in scsih_scan_finished()
11839 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
11840 ioc->remove_host = 1; in scsih_scan_finished()
11845 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11850 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
11852 ioc->is_driver_loading = 0; in scsih_scan_finished()
11858 * scsih_map_queues - map reply queues with request queues
11864 (struct MPT3SAS_ADAPTER *)shost->hostdata; in scsih_map_queues()
11867 int nr_msix_vectors = ioc->iopoll_q_start_index; in scsih_map_queues()
11868 int iopoll_q_count = ioc->reply_queue_count - nr_msix_vectors; in scsih_map_queues()
11870 if (shost->nr_hw_queues == 1) in scsih_map_queues()
11873 for (i = 0, qoff = 0; i < shost->nr_maps; i++) { in scsih_map_queues()
11874 map = &shost->tag_set.map[i]; in scsih_map_queues()
11875 map->nr_queues = 0; in scsih_map_queues()
11878 map->nr_queues = in scsih_map_queues()
11879 nr_msix_vectors - ioc->high_iops_queues; in scsih_map_queues()
11880 offset = ioc->high_iops_queues; in scsih_map_queues()
11882 map->nr_queues = iopoll_q_count; in scsih_map_queues()
11884 if (!map->nr_queues) in scsih_map_queues()
11889 * affinity), so use the regular blk-mq cpu mapping in scsih_map_queues()
11891 map->queue_offset = qoff; in scsih_map_queues()
11893 blk_mq_pci_map_queues(map, ioc->pdev, offset); in scsih_map_queues()
11897 qoff += map->nr_queues; in scsih_map_queues()
11921 .this_id = -1,
11959 .this_id = -1,
11981 * _scsih_determine_hba_mpi_version - determine in which MPI version class
11982 * this device belongs to.
11983 * @pdev: PCI device struct
11993 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
12053 * _scsih_probe - attach and add scsi host
12054 * @pdev: PCI device struct
12055 * @id: pci device id
12068 /* Determine in which MPI version class this pci device belongs */ in _scsih_probe()
12071 return -ENODEV; in _scsih_probe()
12074 * for other generation HBA's return with -ENODEV in _scsih_probe()
12077 return -ENODEV; in _scsih_probe()
12080 * for other generation HBA's return with -ENODEV in _scsih_probe()
12084 return -ENODEV; in _scsih_probe()
12094 return -ENODEV; in _scsih_probe()
12097 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12098 ioc->id = mpt2_ids++; in _scsih_probe()
12099 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
12100 switch (pdev->device) { in _scsih_probe()
12102 ioc->is_warpdrive = 1; in _scsih_probe()
12103 ioc->hide_ir_msg = 1; in _scsih_probe()
12107 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
12110 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
12114 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12115 ioc->multipath_on_hba = 0; in _scsih_probe()
12117 ioc->multipath_on_hba = 1; in _scsih_probe()
12126 return -ENODEV; in _scsih_probe()
12129 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
12130 ioc->id = mpt3_ids++; in _scsih_probe()
12131 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
12132 switch (pdev->device) { in _scsih_probe()
12141 ioc->is_gen35_ioc = 1; in _scsih_probe()
12145 dev_err(&pdev->dev, in _scsih_probe()
12147 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12148 pdev->subsystem_device); in _scsih_probe()
12152 dev_err(&pdev->dev, in _scsih_probe()
12154 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
12155 pdev->subsystem_device); in _scsih_probe()
12159 dev_info(&pdev->dev, in _scsih_probe()
12164 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
12167 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
12169 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
12170 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
12171 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
12172 ioc->combined_reply_queue = 1; in _scsih_probe()
12173 if (ioc->is_gen35_ioc) in _scsih_probe()
12174 ioc->combined_reply_index_count = in _scsih_probe()
12177 ioc->combined_reply_index_count = in _scsih_probe()
12181 switch (ioc->is_gen35_ioc) { in _scsih_probe()
12183 if (multipath_on_hba == -1 || multipath_on_hba == 0) in _scsih_probe()
12184 ioc->multipath_on_hba = 0; in _scsih_probe()
12186 ioc->multipath_on_hba = 1; in _scsih_probe()
12189 if (multipath_on_hba == -1 || multipath_on_hba > 0) in _scsih_probe()
12190 ioc->multipath_on_hba = 1; in _scsih_probe()
12192 ioc->multipath_on_hba = 0; in _scsih_probe()
12200 return -ENODEV; in _scsih_probe()
12203 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
12205 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
12207 ioc->shost = shost; in _scsih_probe()
12208 ioc->pdev = pdev; in _scsih_probe()
12209 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
12210 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
12211 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
12212 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
12213 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
12214 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
12215 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
12216 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
12217 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
12218 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
12219 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
12220 ioc->logging_level = logging_level; in _scsih_probe()
12221 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
12223 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
12227 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
12229 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY; in _scsih_probe()
12231 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
12234 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
12235 mutex_init(&ioc->hostdiag_unlock_mutex); in _scsih_probe()
12237 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
12238 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
12239 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
12240 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
12241 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
12242 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
12243 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
12244 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
12245 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
12247 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
12248 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
12249 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
12250 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
12251 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
12252 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
12253 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
12254 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
12255 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
12256 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
12257 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
12258 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
12259 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
12260 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
12261 INIT_LIST_HEAD(&ioc->port_table_list); in _scsih_probe()
12263 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
12266 shost->max_cmd_len = 32; in _scsih_probe()
12267 shost->max_lun = max_lun; in _scsih_probe()
12268 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
12269 shost->unique_id = ioc->id; in _scsih_probe()
12271 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
12273 shost->max_sectors = 128; in _scsih_probe()
12275 shost->max_sectors); in _scsih_probe()
12279 shost->max_sectors = 64; in _scsih_probe()
12283 shost->max_sectors = 32767; in _scsih_probe()
12287 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
12289 shost->max_sectors); in _scsih_probe()
12304 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
12305 "fw_event_%s%d", 0, ioc->driver_name, ioc->id); in _scsih_probe()
12306 if (!ioc->firmware_event_thread) { in _scsih_probe()
12309 rv = -ENODEV; in _scsih_probe()
12313 shost->host_tagset = 0; in _scsih_probe()
12315 if (ioc->is_gen35_ioc && host_tagset_enable) in _scsih_probe()
12316 shost->host_tagset = 1; in _scsih_probe()
12318 ioc->is_driver_loading = 1; in _scsih_probe()
12322 rv = -ENODEV; in _scsih_probe()
12326 if (ioc->is_warpdrive) { in _scsih_probe()
12327 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
12328 ioc->hide_drives = 0; in _scsih_probe()
12329 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
12330 ioc->hide_drives = 1; in _scsih_probe()
12333 ioc->hide_drives = 1; in _scsih_probe()
12335 ioc->hide_drives = 0; in _scsih_probe()
12338 ioc->hide_drives = 0; in _scsih_probe()
12340 shost->nr_hw_queues = 1; in _scsih_probe()
12342 if (shost->host_tagset) { in _scsih_probe()
12343 shost->nr_hw_queues = in _scsih_probe()
12344 ioc->reply_queue_count - ioc->high_iops_queues; in _scsih_probe()
12347 ioc->reply_queue_count - ioc->iopoll_q_start_index; in _scsih_probe()
12349 shost->nr_maps = iopoll_q_count ? 3 : 1; in _scsih_probe()
12351 dev_info(&ioc->pdev->dev, in _scsih_probe()
12353 shost->can_queue, shost->nr_hw_queues); in _scsih_probe()
12356 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
12369 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
12372 list_del(&ioc->list); in _scsih_probe()
12379 * scsih_suspend - power management suspend main entry point
12380 * @dev: Device struct
12385 scsih_suspend(struct device *dev) in scsih_suspend()
12407 * scsih_resume - power management resume main entry point
12408 * @dev: Device struct
12413 scsih_resume(struct device *dev) in scsih_resume()
12418 pci_power_t device_state = pdev->current_state; in scsih_resume()
12428 ioc->pdev = pdev; in scsih_resume()
12440 * scsih_pci_error_detected - Called when a PCI error is detected.
12441 * @pdev: PCI device struct
12464 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12465 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
12470 /* Permanent error, prepare for device removal */ in scsih_pci_error_detected()
12471 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
12481 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12482 * @pdev: PCI device struct
12500 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
12501 ioc->pdev = pdev; in scsih_pci_slot_reset()
12520 * scsih_pci_resume() - resume normal ops after PCI reset
12521 * @pdev: pointer to PCI device
12539 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
12543 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
12544 * @pdev: pointer to PCI device
12557 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
12560 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still in scsih_pci_mmio_enabled()
12567 * The pci device ids are defined in mpi/mpi2_cnfg.h.
12734 * scsih_init - main entry point for this driver.
12785 * scsih_exit - exit point for this driver (when it is a module).
12816 * _mpt3sas_init - main entry point for this driver.
12831 return -ENODEV; in _mpt3sas_init()
12841 return -ENODEV; in _mpt3sas_init()
12853 return -ENODEV; in _mpt3sas_init()
12875 * _mpt3sas_exit - exit point for this driver (when it is a module).