• Home
  • Raw
  • Download

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

5  * Copyright (C) 2012-2014  LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
93 static u8 scsi_io_cb_idx = -1;
94 static u8 tm_cb_idx = -1;
95 static u8 ctl_cb_idx = -1;
96 static u8 base_cb_idx = -1;
97 static u8 port_enable_cb_idx = -1;
98 static u8 transport_cb_idx = -1;
99 static u8 scsih_cb_idx = -1;
100 static u8 config_cb_idx = -1;
104 static u8 tm_tr_cb_idx = -1 ;
105 static u8 tm_tr_volume_cb_idx = -1 ;
106 static u8 tm_sas_control_cb_idx = -1;
119 static int missing_delay[2] = {-1, -1};
121 MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
123 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
132 " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
133 1 - enumerates only SAS 2.0 generation HBAs\n \
134 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
143 static int diag_buffer_enable = -1;
147 static int disable_discovery = -1;
153 static int prot_mask = -1;
168 * struct sense_info - common structure for obtaining sense keys
185 * struct fw_event_work - firmware event struct
187 * @work: work object (ioc->fault_reset_work_q)
188 * @ioc: per adapter object
189 * @device_handle: device handle
197 * This object stored on ioc->fw_event_list.
220 kref_get(&fw_work->refcount); in fw_event_work_get()
225 kref_put(&fw_work->refcount, fw_event_work_free); in fw_event_work_put()
236 kref_init(&fw_event->refcount); in alloc_fw_event_work()
241 * struct _scsi_io_transfer - scsi io transfer
242 * @handle: sas device handle (assigned by firmware)
289 * _scsih_set_debug_level - global setting of ioc->logging_level.
307 ioc->logging_level = logging_level; in _scsih_set_debug_level()
315 * _scsih_srch_boot_sas_address - search based on sas_address
317 * @boot_device: boot device object from bios page 2
325 return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; in _scsih_srch_boot_sas_address()
329 * _scsih_srch_boot_device_name - search based on device name
330 * @device_name: device name specified in INDENTIFY fram
331 * @boot_device: boot device object from bios page 2
339 return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; in _scsih_srch_boot_device_name()
343 * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
346 * @boot_device: boot device object from bios page 2
354 return (enclosure_logical_id == le64_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
355 EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device-> in _scsih_srch_boot_encl_slot()
360 * _scsih_is_boot_device - search for matching boot device.
362 * @device_name: device name specified in INDENTIFY fram
365 * @form: specifies boot device form
366 * @boot_device: boot device object from bios page 2
382 sas_address, &boot_device->SasWwid); in _scsih_is_boot_device()
389 slot, &boot_device->EnclosureSlot); in _scsih_is_boot_device()
395 device_name, &boot_device->DeviceName); in _scsih_is_boot_device()
405 * _scsih_get_sas_address - set the sas_address for given device handle
407 * @handle: device handle
410 * Return: 0 success, non-zero when failure
426 return -ENXIO; in _scsih_get_sas_address()
434 if ((handle <= ioc->sas_hba.num_phys) && in _scsih_get_sas_address()
437 *sas_address = ioc->sas_hba.sas_address; in _scsih_get_sas_address()
445 return -ENXIO; in _scsih_get_sas_address()
450 return -EIO; in _scsih_get_sas_address()
454 * _scsih_determine_boot_device - determine boot device.
455 * @ioc: per adapter object
456 * @device: sas_device or pcie_device object
459 * Determines whether this device should be first reported device to
460 * to scsi-ml or sas transport, this purpose is for persistent boot device.
463 * the corresponding device object.
467 _scsih_determine_boot_device(struct MPT3SAS_ADAPTER *ioc, void *device, in _scsih_determine_boot_device() argument
479 if (!ioc->is_driver_loading) in _scsih_determine_boot_device()
483 if (!ioc->bios_pg3.BiosVersion) in _scsih_determine_boot_device()
487 raid_device = device; in _scsih_determine_boot_device()
488 sas_address = raid_device->wwid; in _scsih_determine_boot_device()
493 pcie_device = device; in _scsih_determine_boot_device()
494 sas_address = pcie_device->wwid; in _scsih_determine_boot_device()
499 sas_device = device; in _scsih_determine_boot_device()
500 sas_address = sas_device->sas_address; in _scsih_determine_boot_device()
501 device_name = sas_device->device_name; in _scsih_determine_boot_device()
502 enclosure_logical_id = sas_device->enclosure_logical_id; in _scsih_determine_boot_device()
503 slot = sas_device->slot; in _scsih_determine_boot_device()
506 if (!ioc->req_boot_device.device) { in _scsih_determine_boot_device()
509 (ioc->bios_pg2.ReqBootDeviceForm & in _scsih_determine_boot_device()
511 &ioc->bios_pg2.RequestedBootDevice)) { in _scsih_determine_boot_device()
515 ioc->req_boot_device.device = device; in _scsih_determine_boot_device()
516 ioc->req_boot_device.channel = channel; in _scsih_determine_boot_device()
520 if (!ioc->req_alt_boot_device.device) { in _scsih_determine_boot_device()
523 (ioc->bios_pg2.ReqAltBootDeviceForm & in _scsih_determine_boot_device()
525 &ioc->bios_pg2.RequestedAltBootDevice)) { in _scsih_determine_boot_device()
529 ioc->req_alt_boot_device.device = device; in _scsih_determine_boot_device()
530 ioc->req_alt_boot_device.channel = channel; in _scsih_determine_boot_device()
534 if (!ioc->current_boot_device.device) { in _scsih_determine_boot_device()
537 (ioc->bios_pg2.CurrentBootDeviceForm & in _scsih_determine_boot_device()
539 &ioc->bios_pg2.CurrentBootDevice)) { in _scsih_determine_boot_device()
543 ioc->current_boot_device.device = device; in _scsih_determine_boot_device()
544 ioc->current_boot_device.channel = channel; in _scsih_determine_boot_device()
555 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_from_target()
557 ret = tgt_priv->sas_dev; in __mpt3sas_get_sdev_from_target()
571 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
573 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_from_target()
584 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_from_target()
586 ret = tgt_priv->pcie_dev; in __mpt3sas_get_pdev_from_target()
594 * mpt3sas_get_pdev_from_target - pcie device search
595 * @ioc: per adapter object
598 * Context: This function will acquire ioc->pcie_device_lock and will release
610 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
612 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_from_target()
623 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_addr()
625 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_addr()
626 if (sas_device->sas_address == sas_address) in __mpt3sas_get_sdev_by_addr()
629 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_addr()
630 if (sas_device->sas_address == sas_address) in __mpt3sas_get_sdev_by_addr()
641 * mpt3sas_get_sdev_by_addr - sas device search
642 * @ioc: per adapter object
644 * Context: Calling function should acquire ioc->sas_device_lock
656 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
659 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_addr()
669 assert_spin_locked(&ioc->sas_device_lock); in __mpt3sas_get_sdev_by_handle()
671 list_for_each_entry(sas_device, &ioc->sas_device_list, list) in __mpt3sas_get_sdev_by_handle()
672 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
675 list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) in __mpt3sas_get_sdev_by_handle()
676 if (sas_device->handle == handle) in __mpt3sas_get_sdev_by_handle()
687 * mpt3sas_get_sdev_by_handle - sas device search
688 * @ioc: per adapter object
689 * @handle: sas device handle (assigned by firmware)
690 * Context: Calling function should acquire ioc->sas_device_lock
701 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
703 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_get_sdev_by_handle()
709 * _scsih_display_enclosure_chassis_info - display device location info
710 * @ioc: per adapter object
711 * @sas_device: per sas device object
712 * @sdev: scsi device struct
721 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
725 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
726 sas_device->slot); in _scsih_display_enclosure_chassis_info()
727 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
730 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
731 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
732 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
734 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
736 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
740 sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
741 sas_device->slot); in _scsih_display_enclosure_chassis_info()
742 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
745 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
746 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
747 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
750 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
752 if (sas_device->enclosure_handle != 0) in _scsih_display_enclosure_chassis_info()
754 (u64)sas_device->enclosure_logical_id, in _scsih_display_enclosure_chassis_info()
755 sas_device->slot); in _scsih_display_enclosure_chassis_info()
756 if (sas_device->connector_name[0] != '\0') in _scsih_display_enclosure_chassis_info()
758 sas_device->enclosure_level, in _scsih_display_enclosure_chassis_info()
759 sas_device->connector_name); in _scsih_display_enclosure_chassis_info()
760 if (sas_device->is_chassis_slot_valid) in _scsih_display_enclosure_chassis_info()
762 sas_device->chassis_slot); in _scsih_display_enclosure_chassis_info()
767 * _scsih_sas_device_remove - remove sas_device from list.
768 * @ioc: per adapter object
770 * Context: This function will acquire ioc->sas_device_lock.
783 sas_device->handle, (u64)sas_device->sas_address); in _scsih_sas_device_remove()
791 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
792 if (!list_empty(&sas_device->list)) { in _scsih_sas_device_remove()
793 list_del_init(&sas_device->list); in _scsih_sas_device_remove()
796 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_remove()
800 * _scsih_device_remove_by_handle - removing device object by handle
801 * @ioc: per adapter object
802 * @handle: device handle
810 if (ioc->shost_recovery) in _scsih_device_remove_by_handle()
813 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
816 list_del_init(&sas_device->list); in _scsih_device_remove_by_handle()
819 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_device_remove_by_handle()
827 * mpt3sas_device_remove_by_sas_address - removing device object by sas address
828 * @ioc: per adapter object
829 * @sas_address: device sas_address
838 if (ioc->shost_recovery) in mpt3sas_device_remove_by_sas_address()
841 spin_lock_irqsave(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
844 list_del_init(&sas_device->list); in mpt3sas_device_remove_by_sas_address()
847 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in mpt3sas_device_remove_by_sas_address()
855 * _scsih_sas_device_add - insert sas_device to the list.
856 * @ioc: per adapter object
858 * Context: This function will acquire ioc->sas_device_lock.
860 * Adding new object to the ioc->sas_device_list.
870 __func__, sas_device->handle, in _scsih_sas_device_add()
871 (u64)sas_device->sas_address)); in _scsih_sas_device_add()
876 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
878 list_add_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_sas_device_add()
879 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_add()
881 if (ioc->hide_drives) { in _scsih_sas_device_add()
882 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
886 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_sas_device_add()
887 sas_device->sas_address_parent)) { in _scsih_sas_device_add()
889 } else if (!sas_device->starget) { in _scsih_sas_device_add()
893 * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() in _scsih_sas_device_add()
895 if (!ioc->is_driver_loading) { in _scsih_sas_device_add()
897 sas_device->sas_address, in _scsih_sas_device_add()
898 sas_device->sas_address_parent); in _scsih_sas_device_add()
902 clear_bit(sas_device->handle, ioc->pend_os_device_add); in _scsih_sas_device_add()
906 * _scsih_sas_device_init_add - insert sas_device to the list.
907 * @ioc: per adapter object
909 * Context: This function will acquire ioc->sas_device_lock.
911 * Adding new object at driver load time to the ioc->sas_device_init_list.
921 __func__, sas_device->handle, in _scsih_sas_device_init_add()
922 (u64)sas_device->sas_address)); in _scsih_sas_device_init_add()
927 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
929 list_add_tail(&sas_device->list, &ioc->sas_device_init_list); in _scsih_sas_device_init_add()
931 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_init_add()
940 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_wwid()
942 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_wwid()
943 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
946 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_wwid()
947 if (pcie_device->wwid == wwid) in __mpt3sas_get_pdev_by_wwid()
959 * mpt3sas_get_pdev_by_wwid - pcie device search
960 * @ioc: per adapter object
963 * Context: This function will acquire ioc->pcie_device_lock and will release
974 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
976 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_wwid()
988 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_idchannel()
990 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_idchannel()
991 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
994 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_idchannel()
995 if (pcie_device->id == id && pcie_device->channel == channel) in __mpt3sas_get_pdev_by_idchannel()
1010 assert_spin_locked(&ioc->pcie_device_lock); in __mpt3sas_get_pdev_by_handle()
1012 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) in __mpt3sas_get_pdev_by_handle()
1013 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1016 list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list) in __mpt3sas_get_pdev_by_handle()
1017 if (pcie_device->handle == handle) in __mpt3sas_get_pdev_by_handle()
1029 * mpt3sas_get_pdev_by_handle - pcie device search
1030 * @ioc: per adapter object
1031 * @handle: Firmware device handle
1033 * Context: This function will acquire ioc->pcie_device_lock and will release
1045 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1047 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in mpt3sas_get_pdev_by_handle()
1053 * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
1054 * @ioc: per adapter object
1055 * Context: This function will acquire ioc->pcie_device_lock
1057 * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
1068 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1069 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_set_nvme_max_shutdown_latency()
1070 if (pcie_device->shutdown_latency) { in _scsih_set_nvme_max_shutdown_latency()
1071 if (shutdown_latency < pcie_device->shutdown_latency) in _scsih_set_nvme_max_shutdown_latency()
1073 pcie_device->shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1076 ioc->max_shutdown_latency = shutdown_latency; in _scsih_set_nvme_max_shutdown_latency()
1077 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_set_nvme_max_shutdown_latency()
1081 * _scsih_pcie_device_remove - remove pcie_device from list.
1082 * @ioc: per adapter object
1084 * Context: This function will acquire ioc->pcie_device_lock.
1099 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove()
1100 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove()
1102 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove()
1103 pcie_device->slot); in _scsih_pcie_device_remove()
1104 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove()
1106 pcie_device->enclosure_level, in _scsih_pcie_device_remove()
1107 pcie_device->connector_name); in _scsih_pcie_device_remove()
1109 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1110 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove()
1111 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove()
1114 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove()
1116 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove()
1118 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove()
1123 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove()
1133 * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
1134 * @ioc: per adapter object
1135 * @handle: device handle
1145 if (ioc->shost_recovery) in _scsih_pcie_device_remove_by_handle()
1148 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1151 if (!list_empty(&pcie_device->list)) { in _scsih_pcie_device_remove_by_handle()
1152 list_del_init(&pcie_device->list); in _scsih_pcie_device_remove_by_handle()
1156 if (pcie_device->shutdown_latency == ioc->max_shutdown_latency) in _scsih_pcie_device_remove_by_handle()
1159 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_remove_by_handle()
1166 * This device's RTD3 Entry Latency matches IOC's in _scsih_pcie_device_remove_by_handle()
1175 * _scsih_pcie_device_add - add pcie_device object
1176 * @ioc: per adapter object
1190 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_add()
1191 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_add()
1195 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_add()
1196 pcie_device->slot)); in _scsih_pcie_device_add()
1197 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_add()
1200 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_add()
1201 pcie_device->connector_name)); in _scsih_pcie_device_add()
1203 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1205 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_pcie_device_add()
1206 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_add()
1208 if (pcie_device->access_status == in _scsih_pcie_device_add()
1210 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1213 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { in _scsih_pcie_device_add()
1215 } else if (!pcie_device->starget) { in _scsih_pcie_device_add()
1216 if (!ioc->is_driver_loading) { in _scsih_pcie_device_add()
1217 /*TODO-- Need to find out whether this condition will occur or not*/ in _scsih_pcie_device_add()
1218 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1221 clear_bit(pcie_device->handle, ioc->pend_os_device_add); in _scsih_pcie_device_add()
1225 * _scsih_pcie_device_init_add - insert pcie_device to the init list.
1226 * @ioc: per adapter object
1228 * Context: This function will acquire ioc->pcie_device_lock.
1230 * Adding new object at driver load time to the ioc->pcie_device_init_list.
1241 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_init_add()
1242 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_init_add()
1246 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_init_add()
1247 pcie_device->slot)); in _scsih_pcie_device_init_add()
1248 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_init_add()
1251 __func__, pcie_device->enclosure_level, in _scsih_pcie_device_init_add()
1252 pcie_device->connector_name)); in _scsih_pcie_device_init_add()
1254 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1256 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); in _scsih_pcie_device_init_add()
1257 if (pcie_device->access_status != in _scsih_pcie_device_init_add()
1260 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_init_add()
1263 * _scsih_raid_device_find_by_id - raid device search
1264 * @ioc: per adapter object
1265 * @id: sas device target id
1266 * @channel: sas device channel
1267 * Context: Calling function should acquire ioc->raid_device_lock
1278 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_id()
1279 if (raid_device->id == id && raid_device->channel == channel) { in _scsih_raid_device_find_by_id()
1290 * mpt3sas_raid_device_find_by_handle - raid device search
1291 * @ioc: per adapter object
1292 * @handle: sas device handle (assigned by firmware)
1293 * Context: Calling function should acquire ioc->raid_device_lock
1304 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in mpt3sas_raid_device_find_by_handle()
1305 if (raid_device->handle != handle) in mpt3sas_raid_device_find_by_handle()
1316 * _scsih_raid_device_find_by_wwid - raid device search
1317 * @ioc: per adapter object
1319 * Context: Calling function should acquire ioc->raid_device_lock
1330 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_raid_device_find_by_wwid()
1331 if (raid_device->wwid != wwid) in _scsih_raid_device_find_by_wwid()
1342 * _scsih_raid_device_add - add raid_device object
1343 * @ioc: per adapter object
1357 raid_device->handle, (u64)raid_device->wwid)); in _scsih_raid_device_add()
1359 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1360 list_add_tail(&raid_device->list, &ioc->raid_device_list); in _scsih_raid_device_add()
1361 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_add()
1365 * _scsih_raid_device_remove - delete raid_device object
1366 * @ioc: per adapter object
1376 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1377 list_del(&raid_device->list); in _scsih_raid_device_remove()
1379 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_raid_device_remove()
1383 * mpt3sas_scsih_expander_find_by_handle - expander device search
1384 * @ioc: per adapter object
1386 * Context: Calling function should acquire ioc->sas_device_lock
1388 * This searches for expander device based on handle, then returns the
1397 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_handle()
1398 if (sas_expander->handle != handle) in mpt3sas_scsih_expander_find_by_handle()
1408 * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
1409 * @ioc: per adapter object
1411 * Context: Calling function should acquire ioc->sas_device_lock
1413 * This searches for enclosure device based on handle, then returns the
1422 list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) { in mpt3sas_scsih_enclosure_find_by_handle()
1423 if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle) in mpt3sas_scsih_enclosure_find_by_handle()
1432 * mpt3sas_scsih_expander_find_by_sas_address - expander device search
1433 * @ioc: per adapter object
1435 * Context: Calling function should acquire ioc->sas_node_lock.
1437 * This searches for expander device based on sas_address, then returns the
1447 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in mpt3sas_scsih_expander_find_by_sas_address()
1448 if (sas_expander->sas_address != sas_address) in mpt3sas_scsih_expander_find_by_sas_address()
1458 * _scsih_expander_node_add - insert expander device to the list.
1459 * @ioc: per adapter object
1461 * Context: This function will acquire ioc->sas_node_lock.
1463 * Adding new object to the ioc->sas_expander_list.
1471 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1472 list_add_tail(&sas_expander->list, &ioc->sas_expander_list); in _scsih_expander_node_add()
1473 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_add()
1477 * _scsih_is_end_device - determines if device is an end device
1478 * @device_info: bitfield providing information about the device.
1481 * Return: 1 if end device.
1496 * _scsih_is_nvme_pciescsi_device - determines if
1497 * device is an pcie nvme/scsi device
1498 * @device_info: bitfield providing information about the device.
1501 * Returns 1 if device is pcie device type nvme/scsi.
1516 * _scsih_scsi_lookup_find_by_target - search for matching channel:id
1517 * @ioc: per adapter object
1520 * Context: This function will acquire ioc->scsi_lookup_lock.
1533 smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_target()
1537 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_target()
1538 scmd->device->channel == channel) in _scsih_scsi_lookup_find_by_target()
1545 * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
1546 * @ioc: per adapter object
1550 * Context: This function will acquire ioc->scsi_lookup_lock.
1562 for (smid = 1; smid <= ioc->shost->can_queue; smid++) { in _scsih_scsi_lookup_find_by_lun()
1567 if (scmd->device->id == id && in _scsih_scsi_lookup_find_by_lun()
1568 scmd->device->channel == channel && in _scsih_scsi_lookup_find_by_lun()
1569 scmd->device->lun == lun) in _scsih_scsi_lookup_find_by_lun()
1576 * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
1577 * @ioc: per adapter object
1591 smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { in mpt3sas_scsih_scsi_lookup_get()
1592 u32 unique_tag = smid - 1; in mpt3sas_scsih_scsi_lookup_get()
1598 * DevHandle filed must be non-zero. If DevHandle is zero in mpt3sas_scsih_scsi_lookup_get()
1602 if (!mpi_request->DevHandle) in mpt3sas_scsih_scsi_lookup_get()
1605 scmd = scsi_host_find_tag(ioc->shost, unique_tag); in mpt3sas_scsih_scsi_lookup_get()
1608 if (st->cb_idx == 0xFF || st->smid == 0) in mpt3sas_scsih_scsi_lookup_get()
1616 * scsih_change_queue_depth - setting device queue depth
1617 * @sdev: scsi device struct
1625 struct Scsi_Host *shost = sdev->host; in scsih_change_queue_depth()
1633 max_depth = shost->can_queue; in scsih_change_queue_depth()
1636 * limit max device queue for SATA to 32 if enable_sdev_max_qd in scsih_change_queue_depth()
1639 if (ioc->enable_sdev_max_qd) in scsih_change_queue_depth()
1642 sas_device_priv_data = sdev->hostdata; in scsih_change_queue_depth()
1645 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_change_queue_depth()
1648 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) in scsih_change_queue_depth()
1651 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1654 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) in scsih_change_queue_depth()
1659 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_change_queue_depth()
1663 if (!sdev->tagged_supported) in scsih_change_queue_depth()
1670 sdev->queue_depth, sdev->tagged_supported, in scsih_change_queue_depth()
1671 sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1)); in scsih_change_queue_depth()
1672 return sdev->queue_depth; in scsih_change_queue_depth()
1676 * mpt3sas_scsih_change_queue_depth - setting device queue depth
1677 * @sdev: scsi device struct
1685 struct Scsi_Host *shost = sdev->host; in mpt3sas_scsih_change_queue_depth()
1688 if (ioc->enable_sdev_max_qd) in mpt3sas_scsih_change_queue_depth()
1689 qdepth = shost->can_queue; in mpt3sas_scsih_change_queue_depth()
1695 * scsih_target_alloc - target add routine
1699 * the device is ignored.
1704 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_alloc()
1716 return -ENOMEM; in scsih_target_alloc()
1718 starget->hostdata = sas_target_priv_data; in scsih_target_alloc()
1719 sas_target_priv_data->starget = starget; in scsih_target_alloc()
1720 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in scsih_target_alloc()
1723 if (starget->channel == RAID_CHANNEL) { in scsih_target_alloc()
1724 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1725 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_alloc()
1726 starget->channel); in scsih_target_alloc()
1728 sas_target_priv_data->handle = raid_device->handle; in scsih_target_alloc()
1729 sas_target_priv_data->sas_address = raid_device->wwid; in scsih_target_alloc()
1730 sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME; in scsih_target_alloc()
1731 if (ioc->is_warpdrive) in scsih_target_alloc()
1732 sas_target_priv_data->raid_device = raid_device; in scsih_target_alloc()
1733 raid_device->starget = starget; in scsih_target_alloc()
1735 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_alloc()
1740 if (starget->channel == PCIE_CHANNEL) { in scsih_target_alloc()
1741 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1742 pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id, in scsih_target_alloc()
1743 starget->channel); in scsih_target_alloc()
1745 sas_target_priv_data->handle = pcie_device->handle; in scsih_target_alloc()
1746 sas_target_priv_data->sas_address = pcie_device->wwid; in scsih_target_alloc()
1747 sas_target_priv_data->pcie_dev = pcie_device; in scsih_target_alloc()
1748 pcie_device->starget = starget; in scsih_target_alloc()
1749 pcie_device->id = starget->id; in scsih_target_alloc()
1750 pcie_device->channel = starget->channel; in scsih_target_alloc()
1751 sas_target_priv_data->flags |= in scsih_target_alloc()
1753 if (pcie_device->fast_path) in scsih_target_alloc()
1754 sas_target_priv_data->flags |= in scsih_target_alloc()
1757 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_alloc()
1762 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1763 rphy = dev_to_rphy(starget->dev.parent); in scsih_target_alloc()
1765 rphy->identify.sas_address); in scsih_target_alloc()
1768 sas_target_priv_data->handle = sas_device->handle; in scsih_target_alloc()
1769 sas_target_priv_data->sas_address = sas_device->sas_address; in scsih_target_alloc()
1770 sas_target_priv_data->sas_dev = sas_device; in scsih_target_alloc()
1771 sas_device->starget = starget; in scsih_target_alloc()
1772 sas_device->id = starget->id; in scsih_target_alloc()
1773 sas_device->channel = starget->channel; in scsih_target_alloc()
1774 if (test_bit(sas_device->handle, ioc->pd_handles)) in scsih_target_alloc()
1775 sas_target_priv_data->flags |= in scsih_target_alloc()
1777 if (sas_device->fast_path) in scsih_target_alloc()
1778 sas_target_priv_data->flags |= in scsih_target_alloc()
1781 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_alloc()
1787 * scsih_target_destroy - target destroy routine
1793 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsih_target_destroy()
1801 sas_target_priv_data = starget->hostdata; in scsih_target_destroy()
1805 if (starget->channel == RAID_CHANNEL) { in scsih_target_destroy()
1806 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1807 raid_device = _scsih_raid_device_find_by_id(ioc, starget->id, in scsih_target_destroy()
1808 starget->channel); in scsih_target_destroy()
1810 raid_device->starget = NULL; in scsih_target_destroy()
1811 raid_device->sdev = NULL; in scsih_target_destroy()
1813 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_target_destroy()
1817 if (starget->channel == PCIE_CHANNEL) { in scsih_target_destroy()
1818 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1821 if (pcie_device && (pcie_device->starget == starget) && in scsih_target_destroy()
1822 (pcie_device->id == starget->id) && in scsih_target_destroy()
1823 (pcie_device->channel == starget->channel)) in scsih_target_destroy()
1824 pcie_device->starget = NULL; in scsih_target_destroy()
1830 sas_target_priv_data->pcie_dev = NULL; in scsih_target_destroy()
1834 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_target_destroy()
1838 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_target_destroy()
1840 if (sas_device && (sas_device->starget == starget) && in scsih_target_destroy()
1841 (sas_device->id == starget->id) && in scsih_target_destroy()
1842 (sas_device->channel == starget->channel)) in scsih_target_destroy()
1843 sas_device->starget = NULL; in scsih_target_destroy()
1849 sas_target_priv_data->sas_dev = NULL; in scsih_target_destroy()
1854 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_target_destroy()
1858 starget->hostdata = NULL; in scsih_target_destroy()
1862 * scsih_slave_alloc - device add routine
1863 * @sdev: scsi device struct
1866 * the device is ignored.
1884 return -ENOMEM; in scsih_slave_alloc()
1886 sas_device_priv_data->lun = sdev->lun; in scsih_slave_alloc()
1887 sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT; in scsih_slave_alloc()
1890 sas_target_priv_data = starget->hostdata; in scsih_slave_alloc()
1891 sas_target_priv_data->num_luns++; in scsih_slave_alloc()
1892 sas_device_priv_data->sas_target = sas_target_priv_data; in scsih_slave_alloc()
1893 sdev->hostdata = sas_device_priv_data; in scsih_slave_alloc()
1894 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT)) in scsih_slave_alloc()
1895 sdev->no_uld_attach = 1; in scsih_slave_alloc()
1897 shost = dev_to_shost(&starget->dev); in scsih_slave_alloc()
1899 if (starget->channel == RAID_CHANNEL) { in scsih_slave_alloc()
1900 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
1902 starget->id, starget->channel); in scsih_slave_alloc()
1904 raid_device->sdev = sdev; /* raid is single lun */ in scsih_slave_alloc()
1905 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_alloc()
1907 if (starget->channel == PCIE_CHANNEL) { in scsih_slave_alloc()
1908 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
1910 sas_target_priv_data->sas_address); in scsih_slave_alloc()
1911 if (pcie_device && (pcie_device->starget == NULL)) { in scsih_slave_alloc()
1913 "%s : pcie_device->starget set to starget @ %d\n", in scsih_slave_alloc()
1915 pcie_device->starget = starget; in scsih_slave_alloc()
1920 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_alloc()
1922 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_alloc()
1923 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
1925 sas_target_priv_data->sas_address); in scsih_slave_alloc()
1926 if (sas_device && (sas_device->starget == NULL)) { in scsih_slave_alloc()
1928 "%s : sas_device->starget set to starget @ %d\n", in scsih_slave_alloc()
1930 sas_device->starget = starget; in scsih_slave_alloc()
1936 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_alloc()
1943 * scsih_slave_destroy - device destroy routine
1944 * @sdev: scsi device struct
1957 if (!sdev->hostdata) in scsih_slave_destroy()
1961 sas_target_priv_data = starget->hostdata; in scsih_slave_destroy()
1962 sas_target_priv_data->num_luns--; in scsih_slave_destroy()
1964 shost = dev_to_shost(&starget->dev); in scsih_slave_destroy()
1967 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_destroy()
1968 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
1971 if (pcie_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
1972 pcie_device->starget = NULL; in scsih_slave_destroy()
1977 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_destroy()
1979 } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { in scsih_slave_destroy()
1980 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
1983 if (sas_device && !sas_target_priv_data->num_luns) in scsih_slave_destroy()
1984 sas_device->starget = NULL; in scsih_slave_destroy()
1988 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_destroy()
1991 kfree(sdev->hostdata); in scsih_slave_destroy()
1992 sdev->hostdata = NULL; in scsih_slave_destroy()
1996 * _scsih_display_sata_capabilities - sata capabilities
1997 * @ioc: per adapter object
1998 * @handle: device handle
1999 * @sdev: scsi device struct
2042 * raid transport support -
2044 * unloading the driver followed by a load - I believe that the subroutine
2049 * scsih_is_raid - return boolean indicating device is raid volume
2050 * @dev: the device struct object
2053 scsih_is_raid(struct device *dev) in scsih_is_raid()
2056 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_is_raid()
2058 if (ioc->is_warpdrive) in scsih_is_raid()
2060 return (sdev->channel == RAID_CHANNEL) ? 1 : 0; in scsih_is_raid()
2064 scsih_is_nvme(struct device *dev) in scsih_is_nvme()
2068 return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; in scsih_is_nvme()
2072 * scsih_get_resync - get raid volume resync percent complete
2073 * @dev: the device struct object
2076 scsih_get_resync(struct device *dev) in scsih_get_resync()
2079 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_resync()
2090 if (ioc->is_warpdrive) in scsih_get_resync()
2093 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_resync()
2094 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_resync()
2095 sdev->channel); in scsih_get_resync()
2097 handle = raid_device->handle; in scsih_get_resync()
2098 percent_complete = raid_device->percent_complete; in scsih_get_resync()
2100 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_resync()
2121 switch (ioc->hba_mpi_version_belonged) { in scsih_get_resync()
2133 * scsih_get_state - get raid volume level
2134 * @dev: the device struct object
2137 scsih_get_state(struct device *dev) in scsih_get_state()
2140 struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); in scsih_get_state()
2149 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_get_state()
2150 raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id, in scsih_get_state()
2151 sdev->channel); in scsih_get_state()
2153 handle = raid_device->handle; in scsih_get_state()
2154 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_get_state()
2187 switch (ioc->hba_mpi_version_belonged) { in scsih_get_state()
2199 * _scsih_set_level - set raid level
2201 * @sdev: scsi device struct
2225 switch (ioc->hba_mpi_version_belonged) { in _scsih_set_level()
2228 &sdev->sdev_gendev, level); in _scsih_set_level()
2233 &sdev->sdev_gendev, level); in _scsih_set_level()
2240 * _scsih_get_volume_capabilities - volume capabilities
2241 * @ioc: per adapter object
2257 if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle, in _scsih_get_volume_capabilities()
2265 raid_device->num_pds = num_pds; in _scsih_get_volume_capabilities()
2277 MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) { in _scsih_get_volume_capabilities()
2285 raid_device->volume_type = vol_pg0->VolumeType; in _scsih_get_volume_capabilities()
2288 * obtaining the device_info bits for the 1st device in _scsih_get_volume_capabilities()
2292 vol_pg0->PhysDisk[0].PhysDiskNum))) { in _scsih_get_volume_capabilities()
2296 raid_device->device_info = in _scsih_get_volume_capabilities()
2306 * _scsih_enable_tlr - setting TLR flags
2307 * @ioc: per adapter object
2308 * @sdev: scsi device struct
2319 if (sdev->type != TYPE_TAPE) in _scsih_enable_tlr()
2322 if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR)) in _scsih_enable_tlr()
2333 * scsih_slave_configure - device configure routine.
2334 * @sdev: scsi device struct
2337 * the device is ignored.
2342 struct Scsi_Host *shost = sdev->host; in scsih_slave_configure()
2358 sas_device_priv_data = sdev->hostdata; in scsih_slave_configure()
2359 sas_device_priv_data->configured_lun = 1; in scsih_slave_configure()
2360 sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT; in scsih_slave_configure()
2361 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_slave_configure()
2362 handle = sas_target_priv_data->handle; in scsih_slave_configure()
2365 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_slave_configure()
2367 spin_lock_irqsave(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2369 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in scsih_slave_configure()
2394 if (raid_device->device_info & in scsih_slave_configure()
2400 if (raid_device->device_info & in scsih_slave_configure()
2407 switch (raid_device->volume_type) { in scsih_slave_configure()
2413 if (ioc->manu_pg10.OEMIdentifier && in scsih_slave_configure()
2414 (le32_to_cpu(ioc->manu_pg10.GenericFlags0) & in scsih_slave_configure()
2416 !(raid_device->num_pds % 2)) in scsih_slave_configure()
2436 if (!ioc->hide_ir_msg) in scsih_slave_configure()
2440 r_level, raid_device->handle, in scsih_slave_configure()
2441 (unsigned long long)raid_device->wwid, in scsih_slave_configure()
2442 raid_device->num_pds, ds); in scsih_slave_configure()
2444 if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) { in scsih_slave_configure()
2445 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2455 if (!ioc->is_warpdrive) in scsih_slave_configure()
2456 _scsih_set_level(ioc, sdev, raid_device->volume_type); in scsih_slave_configure()
2460 /* non-raid handling */ in scsih_slave_configure()
2461 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) { in scsih_slave_configure()
2479 if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in scsih_slave_configure()
2480 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2482 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2484 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2495 ds, handle, (unsigned long long)pcie_device->wwid, in scsih_slave_configure()
2496 pcie_device->port_num); in scsih_slave_configure()
2497 if (pcie_device->enclosure_handle != 0) in scsih_slave_configure()
2501 (unsigned long long)pcie_device->enclosure_logical_id, in scsih_slave_configure()
2502 pcie_device->slot); in scsih_slave_configure()
2503 if (pcie_device->connector_name[0] != '\0') in scsih_slave_configure()
2507 pcie_device->enclosure_level, in scsih_slave_configure()
2508 pcie_device->connector_name); in scsih_slave_configure()
2510 if (pcie_device->nvme_mdts) in scsih_slave_configure()
2511 blk_queue_max_hw_sectors(sdev->request_queue, in scsih_slave_configure()
2512 pcie_device->nvme_mdts/512); in scsih_slave_configure()
2515 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in scsih_slave_configure()
2522 sdev->request_queue); in scsih_slave_configure()
2523 blk_queue_virt_boundary(sdev->request_queue, in scsih_slave_configure()
2524 ioc->page_size - 1); in scsih_slave_configure()
2528 spin_lock_irqsave(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2530 sas_device_priv_data->sas_target->sas_address); in scsih_slave_configure()
2532 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2539 sas_device->volume_handle = volume_handle; in scsih_slave_configure()
2540 sas_device->volume_wwid = volume_wwid; in scsih_slave_configure()
2541 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) { in scsih_slave_configure()
2544 if (sas_device->device_info & in scsih_slave_configure()
2548 sas_device_priv_data->sas_target->handle); in scsih_slave_configure()
2549 sas_device_priv_data->ignore_delay_remove = 1; in scsih_slave_configure()
2555 if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) in scsih_slave_configure()
2557 else if (sas_device->device_info & in scsih_slave_configure()
2564 ds, handle, (unsigned long long)sas_device->sas_address, in scsih_slave_configure()
2565 sas_device->phy, (unsigned long long)sas_device->device_name); in scsih_slave_configure()
2570 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in scsih_slave_configure()
2587 * scsih_bios_param - fetch head, sector, cylinder info for a disk
2588 * @sdev: scsi device struct
2589 * @bdev: pointer to block device context
2590 * @capacity: device size (in 512 byte sectors)
2633 * _scsih_response_code - translation of device response code
2634 * @ioc: per adapter object
2635 * @response_code: response code returned by the device
2675 * _scsih_tm_done - tm completion routine
2676 * @ioc: per adapter object
2692 if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED) in _scsih_tm_done()
2694 if (ioc->tm_cmds.smid != smid) in _scsih_tm_done()
2696 ioc->tm_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_tm_done()
2699 memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in _scsih_tm_done()
2700 ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_tm_done()
2702 ioc->tm_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_tm_done()
2703 complete(&ioc->tm_cmds.done); in _scsih_tm_done()
2708 * mpt3sas_scsih_set_tm_flag - set per target tm_busy
2709 * @ioc: per adapter object
2710 * @handle: device handle
2712 * During taskmangement request, we need to freeze the device queue.
2721 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_set_tm_flag()
2724 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_set_tm_flag()
2727 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_set_tm_flag()
2728 sas_device_priv_data->sas_target->tm_busy = 1; in mpt3sas_scsih_set_tm_flag()
2730 ioc->ignore_loginfos = 1; in mpt3sas_scsih_set_tm_flag()
2736 * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
2737 * @ioc: per adapter object
2738 * @handle: device handle
2740 * During taskmangement request, we need to freeze the device queue.
2749 shost_for_each_device(sdev, ioc->shost) { in mpt3sas_scsih_clear_tm_flag()
2752 sas_device_priv_data = sdev->hostdata; in mpt3sas_scsih_clear_tm_flag()
2755 if (sas_device_priv_data->sas_target->handle == handle) { in mpt3sas_scsih_clear_tm_flag()
2756 sas_device_priv_data->sas_target->tm_busy = 0; in mpt3sas_scsih_clear_tm_flag()
2758 ioc->ignore_loginfos = 0; in mpt3sas_scsih_clear_tm_flag()
2764 * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
2765 * @ioc - per adapter object
2766 * @channel - the channel assigned by the OS
2780 if (smid_task <= ioc->shost->can_queue) { in scsih_tm_cmd_map_status()
2796 } else if (smid_task == ioc->scsih_cmds.smid) { in scsih_tm_cmd_map_status()
2797 if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2798 (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2800 } else if (smid_task == ioc->ctl_cmds.smid) { in scsih_tm_cmd_map_status()
2801 if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) || in scsih_tm_cmd_map_status()
2802 (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED)) in scsih_tm_cmd_map_status()
2810 * scsih_tm_post_processing - post processing of target & LUN reset
2811 * @ioc - per adapter object
2812 * @handle: device handle
2813 * @channel - the channel assigned by the OS
2854 * mpt3sas_scsih_issue_tm - main routine for sending tm requests
2855 * @ioc: per adapter struct
2856 * @handle: device handle
2869 * The callback index is set inside `ioc->tm_cb_idx`.
2887 lockdep_assert_held(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_tm()
2889 if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_scsih_issue_tm()
2894 if (ioc->shost_recovery || ioc->remove_host || in mpt3sas_scsih_issue_tm()
2895 ioc->pci_error_recovery) { in mpt3sas_scsih_issue_tm()
2920 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); in mpt3sas_scsih_issue_tm()
2929 ioc->tm_cmds.status = MPT3_CMD_PENDING; in mpt3sas_scsih_issue_tm()
2931 ioc->tm_cmds.smid = smid; in mpt3sas_scsih_issue_tm()
2933 memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t)); in mpt3sas_scsih_issue_tm()
2934 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in mpt3sas_scsih_issue_tm()
2935 mpi_request->DevHandle = cpu_to_le16(handle); in mpt3sas_scsih_issue_tm()
2936 mpi_request->TaskType = type; in mpt3sas_scsih_issue_tm()
2939 mpi_request->MsgFlags = tr_method; in mpt3sas_scsih_issue_tm()
2940 mpi_request->TaskMID = cpu_to_le16(smid_task); in mpt3sas_scsih_issue_tm()
2941 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); in mpt3sas_scsih_issue_tm()
2943 init_completion(&ioc->tm_cmds.done); in mpt3sas_scsih_issue_tm()
2944 ioc->put_smid_hi_priority(ioc, smid, msix_task); in mpt3sas_scsih_issue_tm()
2945 wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); in mpt3sas_scsih_issue_tm()
2946 if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_scsih_issue_tm()
2948 ioc->tm_cmds.status, mpi_request, in mpt3sas_scsih_issue_tm()
2961 if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) { in mpt3sas_scsih_issue_tm()
2963 mpi_reply = ioc->tm_cmds.reply; in mpt3sas_scsih_issue_tm()
2966 le16_to_cpu(mpi_reply->IOCStatus), in mpt3sas_scsih_issue_tm()
2967 le32_to_cpu(mpi_reply->IOCLogInfo), in mpt3sas_scsih_issue_tm()
2968 le32_to_cpu(mpi_reply->TerminationCount))); in mpt3sas_scsih_issue_tm()
2969 if (ioc->logging_level & MPT_DEBUG_TM) { in mpt3sas_scsih_issue_tm()
2970 _scsih_response_code(ioc, mpi_reply->ResponseCode); in mpt3sas_scsih_issue_tm()
2971 if (mpi_reply->IOCStatus) in mpt3sas_scsih_issue_tm()
2982 * doesn't match with device handle on which this task abort in mpt3sas_scsih_issue_tm()
2992 if (le16_to_cpu(request->DevHandle) != handle) in mpt3sas_scsih_issue_tm()
3017 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_scsih_issue_tm()
3027 mutex_lock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3030 mutex_unlock(&ioc->tm_cmds.mutex); in mpt3sas_scsih_issue_locked_tm()
3036 * _scsih_tm_display_info - displays info about the device
3037 * @ioc: per adapter struct
3045 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_tm_display_info()
3046 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_tm_display_info()
3054 if (ioc->hide_ir_msg) in _scsih_tm_display_info()
3060 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_tm_display_info()
3063 device_str, priv_target->handle, in _scsih_tm_display_info()
3064 device_str, (unsigned long long)priv_target->sas_address); in _scsih_tm_display_info()
3066 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_tm_display_info()
3067 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3072 pcie_device->handle, in _scsih_tm_display_info()
3073 (unsigned long long)pcie_device->wwid, in _scsih_tm_display_info()
3074 pcie_device->port_num); in _scsih_tm_display_info()
3075 if (pcie_device->enclosure_handle != 0) in _scsih_tm_display_info()
3079 pcie_device->enclosure_logical_id, in _scsih_tm_display_info()
3080 pcie_device->slot); in _scsih_tm_display_info()
3081 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_display_info()
3084 pcie_device->enclosure_level, in _scsih_tm_display_info()
3085 pcie_device->connector_name); in _scsih_tm_display_info()
3088 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_display_info()
3091 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3094 if (priv_target->flags & in _scsih_tm_display_info()
3099 sas_device->volume_handle, in _scsih_tm_display_info()
3100 (unsigned long long)sas_device->volume_wwid); in _scsih_tm_display_info()
3104 sas_device->handle, in _scsih_tm_display_info()
3105 (unsigned long long)sas_device->sas_address, in _scsih_tm_display_info()
3106 sas_device->phy); in _scsih_tm_display_info()
3113 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_display_info()
3118 * scsih_abort - eh threads main abort routine
3126 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_abort()
3134 sdev_printk(KERN_INFO, scmd->device, "attempting task abort!" in scsih_abort()
3136 scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc), in scsih_abort()
3137 (scmd->request->timeout / HZ) * 1000); in scsih_abort()
3140 sas_device_priv_data = scmd->device->hostdata; in scsih_abort()
3141 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_abort()
3142 ioc->remove_host) { in scsih_abort()
3143 sdev_printk(KERN_INFO, scmd->device, in scsih_abort()
3144 "device been deleted! scmd(0x%p)\n", scmd); in scsih_abort()
3145 scmd->result = DID_NO_CONNECT << 16; in scsih_abort()
3146 scmd->scsi_done(scmd); in scsih_abort()
3152 if (st == NULL || st->cb_idx == 0xFF) { in scsih_abort()
3153 sdev_printk(KERN_INFO, scmd->device, "No reference found at " in scsih_abort()
3155 scmd->result = DID_RESET << 16; in scsih_abort()
3161 if (sas_device_priv_data->sas_target->flags & in scsih_abort()
3163 sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) { in scsih_abort()
3164 scmd->result = DID_RESET << 16; in scsih_abort()
3171 handle = sas_device_priv_data->sas_target->handle; in scsih_abort()
3173 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_abort()
3174 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) in scsih_abort()
3175 timeout = ioc->nvme_abort_timeout; in scsih_abort()
3176 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_abort()
3177 scmd->device->id, scmd->device->lun, in scsih_abort()
3179 st->smid, st->msix_io, timeout, 0); in scsih_abort()
3181 if (r == SUCCESS && st->cb_idx != 0xFF) in scsih_abort()
3184 sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n", in scsih_abort()
3192 * scsih_dev_reset - eh threads main device reset routine
3200 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_dev_reset()
3209 struct scsi_target *starget = scmd->device->sdev_target; in scsih_dev_reset()
3210 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_dev_reset()
3212 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3213 "attempting device reset! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3216 sas_device_priv_data = scmd->device->hostdata; in scsih_dev_reset()
3217 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_dev_reset()
3218 ioc->remove_host) { in scsih_dev_reset()
3219 sdev_printk(KERN_INFO, scmd->device, in scsih_dev_reset()
3220 "device been deleted! scmd(0x%p)\n", scmd); in scsih_dev_reset()
3221 scmd->result = DID_NO_CONNECT << 16; in scsih_dev_reset()
3222 scmd->scsi_done(scmd); in scsih_dev_reset()
3229 if (sas_device_priv_data->sas_target->flags & in scsih_dev_reset()
3234 handle = sas_device->volume_handle; in scsih_dev_reset()
3236 handle = sas_device_priv_data->sas_target->handle; in scsih_dev_reset()
3239 scmd->result = DID_RESET << 16; in scsih_dev_reset()
3246 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_dev_reset()
3247 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_dev_reset()
3248 tr_timeout = pcie_device->reset_timeout; in scsih_dev_reset()
3253 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_dev_reset()
3254 scmd->device->id, scmd->device->lun, in scsih_dev_reset()
3258 if (r == SUCCESS && atomic_read(&scmd->device->device_busy)) in scsih_dev_reset()
3261 sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", in scsih_dev_reset()
3273 * scsih_target_reset - eh threads main target reset routine
3281 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_target_reset()
3289 struct scsi_target *starget = scmd->device->sdev_target; in scsih_target_reset()
3290 struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; in scsih_target_reset()
3296 sas_device_priv_data = scmd->device->hostdata; in scsih_target_reset()
3297 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in scsih_target_reset()
3298 ioc->remove_host) { in scsih_target_reset()
3301 scmd->result = DID_NO_CONNECT << 16; in scsih_target_reset()
3302 scmd->scsi_done(scmd); in scsih_target_reset()
3309 if (sas_device_priv_data->sas_target->flags & in scsih_target_reset()
3314 handle = sas_device->volume_handle; in scsih_target_reset()
3316 handle = sas_device_priv_data->sas_target->handle; in scsih_target_reset()
3319 scmd->result = DID_RESET << 16; in scsih_target_reset()
3326 if (pcie_device && (!ioc->tm_custom_handling) && in scsih_target_reset()
3327 (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { in scsih_target_reset()
3328 tr_timeout = pcie_device->reset_timeout; in scsih_target_reset()
3332 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, in scsih_target_reset()
3333 scmd->device->id, 0, in scsih_target_reset()
3337 if (r == SUCCESS && atomic_read(&starget->target_busy)) in scsih_target_reset()
3352 * scsih_host_reset - eh threads main host reset routine
3360 struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); in scsih_host_reset()
3366 if (ioc->is_driver_loading || ioc->remove_host) { in scsih_host_reset()
3382 * _scsih_fw_event_add - insert and queue up fw_event
3383 * @ioc: per adapter object
3385 * Context: This function will acquire ioc->fw_event_lock.
3395 if (ioc->firmware_event_thread == NULL) in _scsih_fw_event_add()
3398 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3400 INIT_LIST_HEAD(&fw_event->list); in _scsih_fw_event_add()
3401 list_add_tail(&fw_event->list, &ioc->fw_event_list); in _scsih_fw_event_add()
3402 INIT_WORK(&fw_event->work, _firmware_event_work); in _scsih_fw_event_add()
3404 queue_work(ioc->firmware_event_thread, &fw_event->work); in _scsih_fw_event_add()
3405 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_add()
3409 * _scsih_fw_event_del_from_list - delete fw_event from the list
3410 * @ioc: per adapter object
3412 * Context: This function will acquire ioc->fw_event_lock.
3422 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3423 if (!list_empty(&fw_event->list)) { in _scsih_fw_event_del_from_list()
3424 list_del_init(&fw_event->list); in _scsih_fw_event_del_from_list()
3427 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_fw_event_del_from_list()
3432 * mpt3sas_send_trigger_data_event - send event for processing trigger data
3433 * @ioc: per adapter object
3443 if (ioc->is_driver_loading) in mpt3sas_send_trigger_data_event()
3449 fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG; in mpt3sas_send_trigger_data_event()
3450 fw_event->ioc = ioc; in mpt3sas_send_trigger_data_event()
3451 memcpy(fw_event->event_data, event_data, sizeof(*event_data)); in mpt3sas_send_trigger_data_event()
3457 * _scsih_error_recovery_delete_devices - remove devices not responding
3458 * @ioc: per adapter object
3465 if (ioc->is_driver_loading) in _scsih_error_recovery_delete_devices()
3470 fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES; in _scsih_error_recovery_delete_devices()
3471 fw_event->ioc = ioc; in _scsih_error_recovery_delete_devices()
3477 * mpt3sas_port_enable_complete - port enable completed (fake event)
3478 * @ioc: per adapter object
3488 fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE; in mpt3sas_port_enable_complete()
3489 fw_event->ioc = ioc; in mpt3sas_port_enable_complete()
3499 spin_lock_irqsave(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3500 if (!list_empty(&ioc->fw_event_list)) { in dequeue_next_fw_event()
3501 fw_event = list_first_entry(&ioc->fw_event_list, in dequeue_next_fw_event()
3503 list_del_init(&fw_event->list); in dequeue_next_fw_event()
3505 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in dequeue_next_fw_event()
3511 * _scsih_fw_event_cleanup_queue - cleanup event queue
3512 * @ioc: per adapter object
3522 if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) || in _scsih_fw_event_cleanup_queue()
3523 !ioc->firmware_event_thread || in_interrupt()) in _scsih_fw_event_cleanup_queue()
3526 ioc->fw_events_cleanup = 1; in _scsih_fw_event_cleanup_queue()
3528 (fw_event = ioc->current_event)) { in _scsih_fw_event_cleanup_queue()
3544 if (fw_event == ioc->current_event && in _scsih_fw_event_cleanup_queue()
3545 ioc->current_event->event != in _scsih_fw_event_cleanup_queue()
3547 ioc->current_event = NULL; in _scsih_fw_event_cleanup_queue()
3559 if (cancel_work_sync(&fw_event->work)) in _scsih_fw_event_cleanup_queue()
3564 ioc->fw_events_cleanup = 0; in _scsih_fw_event_cleanup_queue()
3568 * _scsih_internal_device_block - block the sdev device
3569 * @sdev: per device object
3570 * @sas_device_priv_data : per device driver private data
3572 * make sure device is blocked without error, if not
3582 sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3583 sas_device_priv_data->block = 1; in _scsih_internal_device_block()
3586 if (r == -EINVAL) in _scsih_internal_device_block()
3589 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_block()
3593 * _scsih_internal_device_unblock - unblock the sdev device
3594 * @sdev: per device object
3595 * @sas_device_priv_data : per device driver private data
3596 * make sure device is unblocked without error, if not retry
3607 "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3608 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3610 if (r == -EINVAL) { in _scsih_internal_device_unblock()
3611 /* The device has been set to SDEV_RUNNING by SD layer during in _scsih_internal_device_unblock()
3612 * device addition but the request queue is still stopped by in _scsih_internal_device_unblock()
3614 * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */ in _scsih_internal_device_unblock()
3619 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3620 sas_device_priv_data->block = 1; in _scsih_internal_device_unblock()
3625 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3627 sas_device_priv_data->block = 0; in _scsih_internal_device_unblock()
3632 r, sas_device_priv_data->sas_target->handle); in _scsih_internal_device_unblock()
3637 * _scsih_ublock_io_all_device - unblock every device
3638 * @ioc: per adapter object
3640 * change the device state from block to running
3648 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_all_device()
3649 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_all_device()
3652 if (!sas_device_priv_data->block) in _scsih_ublock_io_all_device()
3657 sas_device_priv_data->sas_target->handle)); in _scsih_ublock_io_all_device()
3664 * _scsih_ublock_io_device - prepare device to be deleted
3665 * @ioc: per adapter object
3668 * unblock then put device in offline state
3676 shost_for_each_device(sdev, ioc->shost) { in _scsih_ublock_io_device()
3677 sas_device_priv_data = sdev->hostdata; in _scsih_ublock_io_device()
3678 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_ublock_io_device()
3680 if (sas_device_priv_data->sas_target->sas_address in _scsih_ublock_io_device()
3683 if (sas_device_priv_data->block) in _scsih_ublock_io_device()
3690 * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
3691 * @ioc: per adapter object
3693 * During device pull we need to appropriately set the sdev state.
3701 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_all_device()
3702 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_all_device()
3705 if (sas_device_priv_data->block) in _scsih_block_io_all_device()
3707 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_all_device()
3710 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_all_device()
3718 * _scsih_block_io_device - set the device state to SDEV_BLOCK
3719 * @ioc: per adapter object
3720 * @handle: device handle
3722 * During device pull we need to appropriately set the sdev state.
3733 shost_for_each_device(sdev, ioc->shost) { in _scsih_block_io_device()
3734 sas_device_priv_data = sdev->hostdata; in _scsih_block_io_device()
3737 if (sas_device_priv_data->sas_target->handle != handle) in _scsih_block_io_device()
3739 if (sas_device_priv_data->block) in _scsih_block_io_device()
3741 if (sas_device && sas_device->pend_sas_rphy_add) in _scsih_block_io_device()
3743 if (sas_device_priv_data->ignore_delay_remove) { in _scsih_block_io_device()
3746 __func__, sas_device_priv_data->sas_target->handle); in _scsih_block_io_device()
3758 * @ioc: per adapter object
3778 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3779 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3781 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3783 mpt3sas_port->remote_identify.sas_address); in _scsih_block_io_to_children_attached_to_ex()
3785 set_bit(sas_device->handle, in _scsih_block_io_to_children_attached_to_ex()
3786 ioc->blocking_handles); in _scsih_block_io_to_children_attached_to_ex()
3789 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_block_io_to_children_attached_to_ex()
3794 &sas_expander->sas_port_list, port_list) { in _scsih_block_io_to_children_attached_to_ex()
3796 if (mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3798 mpt3sas_port->remote_identify.device_type == in _scsih_block_io_to_children_attached_to_ex()
3802 ioc, mpt3sas_port->remote_identify.sas_address); in _scsih_block_io_to_children_attached_to_ex()
3811 * @ioc: per adapter object
3815 * direct attached during device pull.
3825 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_children_attached_directly()
3826 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_block_io_to_children_attached_directly()
3829 reason_code = event_data->PHY[i].PhyStatus & in _scsih_block_io_to_children_attached_directly()
3838 * @ioc: per adapter object
3842 * direct attached during device pull/reconnect.
3852 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_block_io_to_pcie_children_attached_directly()
3854 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_block_io_to_pcie_children_attached_directly()
3857 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_block_io_to_pcie_children_attached_directly()
3864 * _scsih_tm_tr_send - send task management request
3865 * @ioc: per adapter object
3866 * @handle: device handle
3869 * This code is to initiate the device removal handshake protocol
3892 if (ioc->pci_error_recovery) { in _scsih_tm_tr_send()
3907 if (test_bit(handle, ioc->pd_handles)) in _scsih_tm_tr_send()
3910 clear_bit(handle, ioc->pend_os_device_add); in _scsih_tm_tr_send()
3912 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
3914 if (sas_device && sas_device->starget && in _scsih_tm_tr_send()
3915 sas_device->starget->hostdata) { in _scsih_tm_tr_send()
3916 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_tm_tr_send()
3917 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
3918 sas_address = sas_device->sas_address; in _scsih_tm_tr_send()
3920 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_tm_tr_send()
3922 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
3924 if (pcie_device && pcie_device->starget && in _scsih_tm_tr_send()
3925 pcie_device->starget->hostdata) { in _scsih_tm_tr_send()
3926 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_tm_tr_send()
3927 sas_target_priv_data->deleted = 1; in _scsih_tm_tr_send()
3928 sas_address = pcie_device->wwid; in _scsih_tm_tr_send()
3930 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_tm_tr_send()
3931 if (pcie_device && (!ioc->tm_custom_handling) && in _scsih_tm_tr_send()
3933 pcie_device->device_info)))) in _scsih_tm_tr_send()
3944 if (sas_device->enclosure_handle != 0) in _scsih_tm_tr_send()
3947 (u64)sas_device->enclosure_logical_id, in _scsih_tm_tr_send()
3948 sas_device->slot)); in _scsih_tm_tr_send()
3949 if (sas_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
3952 sas_device->enclosure_level, in _scsih_tm_tr_send()
3953 sas_device->connector_name)); in _scsih_tm_tr_send()
3955 if (pcie_device->enclosure_handle != 0) in _scsih_tm_tr_send()
3958 (u64)pcie_device->enclosure_logical_id, in _scsih_tm_tr_send()
3959 pcie_device->slot)); in _scsih_tm_tr_send()
3960 if (pcie_device->connector_name[0] != '\0') in _scsih_tm_tr_send()
3963 pcie_device->enclosure_level, in _scsih_tm_tr_send()
3964 pcie_device->connector_name)); in _scsih_tm_tr_send()
3967 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_tm_tr_send()
3970 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx); in _scsih_tm_tr_send()
3975 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_send()
3976 delayed_tr->handle = handle; in _scsih_tm_tr_send()
3977 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_tm_tr_send()
3986 handle, smid, ioc->tm_tr_cb_idx)); in _scsih_tm_tr_send()
3989 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_send()
3990 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_send()
3991 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_send()
3992 mpi_request->MsgFlags = tr_method; in _scsih_tm_tr_send()
3993 set_bit(handle, ioc->device_remove_in_progress); in _scsih_tm_tr_send()
3994 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_send()
4005 * _scsih_tm_tr_complete -
4006 * @ioc: per adapter object
4013 * This code is part of the code to initiate the device removal
4033 if (ioc->pci_error_recovery) { in _scsih_tm_tr_complete()
4052 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4053 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_tr_complete()
4057 le16_to_cpu(mpi_reply->DevHandle), smid)); in _scsih_tm_tr_complete()
4064 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_tr_complete()
4065 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_tr_complete()
4066 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_tr_complete()
4068 smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx); in _scsih_tm_tr_complete()
4073 INIT_LIST_HEAD(&delayed_sc->list); in _scsih_tm_tr_complete()
4074 delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_tr_complete()
4075 list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list); in _scsih_tm_tr_complete()
4084 handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx)); in _scsih_tm_tr_complete()
4087 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_tm_tr_complete()
4088 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_tm_tr_complete()
4089 mpi_request->DevHandle = mpi_request_tm->DevHandle; in _scsih_tm_tr_complete()
4090 ioc->put_smid_default(ioc, smid_sas_ctrl); in _scsih_tm_tr_complete()
4095 /** _scsih_allow_scmd_to_device - check whether scmd needs to
4097 * @ioc: per adapter object
4106 if (ioc->pci_error_recovery) in _scsih_allow_scmd_to_device()
4109 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { in _scsih_allow_scmd_to_device()
4110 if (ioc->remove_host) in _scsih_allow_scmd_to_device()
4116 if (ioc->remove_host) { in _scsih_allow_scmd_to_device()
4118 switch (scmd->cmnd[0]) { in _scsih_allow_scmd_to_device()
4131 * _scsih_sas_control_complete - completion routine
4132 * @ioc: per adapter object
4139 * This code is part of the code to initiate the device removal
4155 le16_to_cpu(mpi_reply->DevHandle), smid, in _scsih_sas_control_complete()
4156 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_sas_control_complete()
4157 le32_to_cpu(mpi_reply->IOCLogInfo))); in _scsih_sas_control_complete()
4158 if (le16_to_cpu(mpi_reply->IOCStatus) == in _scsih_sas_control_complete()
4160 clear_bit(le16_to_cpu(mpi_reply->DevHandle), in _scsih_sas_control_complete()
4161 ioc->device_remove_in_progress); in _scsih_sas_control_complete()
4171 * _scsih_tm_tr_volume_send - send target reset request for volumes
4172 * @ioc: per adapter object
4173 * @handle: device handle
4187 if (ioc->pci_error_recovery) { in _scsih_tm_tr_volume_send()
4194 smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx); in _scsih_tm_tr_volume_send()
4199 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_tm_tr_volume_send()
4200 delayed_tr->handle = handle; in _scsih_tm_tr_volume_send()
4201 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list); in _scsih_tm_tr_volume_send()
4210 handle, smid, ioc->tm_tr_volume_cb_idx)); in _scsih_tm_tr_volume_send()
4213 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; in _scsih_tm_tr_volume_send()
4214 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_tm_tr_volume_send()
4215 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in _scsih_tm_tr_volume_send()
4216 ioc->put_smid_hi_priority(ioc, smid, 0); in _scsih_tm_tr_volume_send()
4220 * _scsih_tm_volume_tr_complete - target reset completion
4221 * @ioc: per adapter object
4239 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _scsih_tm_volume_tr_complete()
4252 handle = le16_to_cpu(mpi_request_tm->DevHandle); in _scsih_tm_volume_tr_complete()
4253 if (handle != le16_to_cpu(mpi_reply->DevHandle)) { in _scsih_tm_volume_tr_complete()
4256 handle, le16_to_cpu(mpi_reply->DevHandle), in _scsih_tm_volume_tr_complete()
4263 handle, smid, le16_to_cpu(mpi_reply->IOCStatus), in _scsih_tm_volume_tr_complete()
4264 le32_to_cpu(mpi_reply->IOCLogInfo), in _scsih_tm_volume_tr_complete()
4265 le32_to_cpu(mpi_reply->TerminationCount))); in _scsih_tm_volume_tr_complete()
4271 * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
4272 * @ioc: per adapter object
4277 * Context - processed in interrupt context.
4284 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_event_ack()
4291 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4292 ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx; in _scsih_issue_delayed_event_ack()
4293 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_event_ack()
4297 le16_to_cpu(event), smid, ioc->base_cb_idx)); in _scsih_issue_delayed_event_ack()
4300 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; in _scsih_issue_delayed_event_ack()
4301 ack_request->Event = event; in _scsih_issue_delayed_event_ack()
4302 ack_request->EventContext = event_context; in _scsih_issue_delayed_event_ack()
4303 ack_request->VF_ID = 0; /* TODO */ in _scsih_issue_delayed_event_ack()
4304 ack_request->VP_ID = 0; in _scsih_issue_delayed_event_ack()
4305 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_event_ack()
4309 * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
4311 * @ioc: per adapter object
4313 * @handle: device handle
4315 * Context - processed in interrupt context.
4323 int i = smid - ioc->internal_smid; in _scsih_issue_delayed_sas_io_unit_ctrl()
4326 if (ioc->remove_host) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4331 } else if (ioc->pci_error_recovery) { in _scsih_issue_delayed_sas_io_unit_ctrl()
4349 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4350 ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx; in _scsih_issue_delayed_sas_io_unit_ctrl()
4351 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_issue_delayed_sas_io_unit_ctrl()
4355 handle, smid, ioc->tm_sas_control_cb_idx)); in _scsih_issue_delayed_sas_io_unit_ctrl()
4358 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; in _scsih_issue_delayed_sas_io_unit_ctrl()
4359 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE; in _scsih_issue_delayed_sas_io_unit_ctrl()
4360 mpi_request->DevHandle = cpu_to_le16(handle); in _scsih_issue_delayed_sas_io_unit_ctrl()
4361 ioc->put_smid_default(ioc, smid); in _scsih_issue_delayed_sas_io_unit_ctrl()
4365 * _scsih_check_for_pending_internal_cmds - check for pending internal messages
4366 * @ioc: per adapter object
4383 if (!list_empty(&ioc->delayed_event_ack_list)) { in mpt3sas_check_for_pending_internal_cmds()
4384 delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next, in mpt3sas_check_for_pending_internal_cmds()
4387 delayed_event_ack->Event, delayed_event_ack->EventContext); in mpt3sas_check_for_pending_internal_cmds()
4388 list_del(&delayed_event_ack->list); in mpt3sas_check_for_pending_internal_cmds()
4393 if (!list_empty(&ioc->delayed_sc_list)) { in mpt3sas_check_for_pending_internal_cmds()
4394 delayed_sc = list_entry(ioc->delayed_sc_list.next, in mpt3sas_check_for_pending_internal_cmds()
4397 delayed_sc->handle); in mpt3sas_check_for_pending_internal_cmds()
4398 list_del(&delayed_sc->list); in mpt3sas_check_for_pending_internal_cmds()
4406 * _scsih_check_for_pending_tm - check for pending task management
4407 * @ioc: per adapter object
4421 if (!list_empty(&ioc->delayed_tr_volume_list)) { in _scsih_check_for_pending_tm()
4422 delayed_tr = list_entry(ioc->delayed_tr_volume_list.next, in _scsih_check_for_pending_tm()
4425 _scsih_tm_tr_volume_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4426 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4431 if (!list_empty(&ioc->delayed_tr_list)) { in _scsih_check_for_pending_tm()
4432 delayed_tr = list_entry(ioc->delayed_tr_list.next, in _scsih_check_for_pending_tm()
4435 _scsih_tm_tr_send(ioc, delayed_tr->handle); in _scsih_check_for_pending_tm()
4436 list_del(&delayed_tr->list); in _scsih_check_for_pending_tm()
4445 * _scsih_check_topo_delete_events - sanity check on topo events
4446 * @ioc: per adapter object
4467 for (i = 0 ; i < event_data->NumEntries; i++) { in _scsih_check_topo_delete_events()
4468 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_check_topo_delete_events()
4471 reason_code = event_data->PHY[i].PhyStatus & in _scsih_check_topo_delete_events()
4477 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_check_topo_delete_events()
4478 if (expander_handle < ioc->sas_hba.num_phys) { in _scsih_check_topo_delete_events()
4482 if (event_data->ExpStatus == in _scsih_check_topo_delete_events()
4485 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4489 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_check_topo_delete_events()
4491 handle = find_first_bit(ioc->blocking_handles, in _scsih_check_topo_delete_events()
4492 ioc->facts.MaxDevHandle); in _scsih_check_topo_delete_events()
4493 if (handle < ioc->facts.MaxDevHandle) in _scsih_check_topo_delete_events()
4495 } while (test_and_clear_bit(handle, ioc->blocking_handles)); in _scsih_check_topo_delete_events()
4496 } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING) in _scsih_check_topo_delete_events()
4499 if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_topo_delete_events()
4503 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4504 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_topo_delete_events()
4505 if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in _scsih_check_topo_delete_events()
4506 fw_event->ignore) in _scsih_check_topo_delete_events()
4509 fw_event->event_data; in _scsih_check_topo_delete_events()
4510 if (local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4512 local_event_data->ExpStatus == in _scsih_check_topo_delete_events()
4514 if (le16_to_cpu(local_event_data->ExpanderDevHandle) == in _scsih_check_topo_delete_events()
4518 fw_event->ignore = 1; in _scsih_check_topo_delete_events()
4522 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_topo_delete_events()
4526 * _scsih_check_pcie_topo_remove_events - sanity check on topo
4528 * @ioc: per adapter object
4532 * or device add and delete events in a single shot. When there
4546 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_check_pcie_topo_remove_events()
4548 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_check_pcie_topo_remove_events()
4551 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_check_pcie_topo_remove_events()
4556 switch_handle = le16_to_cpu(event_data->SwitchDevHandle); in _scsih_check_pcie_topo_remove_events()
4563 if ((event_data->SwitchStatus in _scsih_check_pcie_topo_remove_events()
4565 (event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4570 if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING) in _scsih_check_pcie_topo_remove_events()
4574 spin_lock_irqsave(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4575 list_for_each_entry(fw_event, &ioc->fw_event_list, list) { in _scsih_check_pcie_topo_remove_events()
4576 if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in _scsih_check_pcie_topo_remove_events()
4577 fw_event->ignore) in _scsih_check_pcie_topo_remove_events()
4581 fw_event->event_data; in _scsih_check_pcie_topo_remove_events()
4582 if (local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4584 local_event_data->SwitchStatus == in _scsih_check_pcie_topo_remove_events()
4586 if (le16_to_cpu(local_event_data->SwitchDevHandle) == in _scsih_check_pcie_topo_remove_events()
4590 fw_event->ignore = 1; in _scsih_check_pcie_topo_remove_events()
4594 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in _scsih_check_pcie_topo_remove_events()
4598 * _scsih_set_volume_delete_flag - setting volume delete flag
4599 * @ioc: per adapter object
4600 * @handle: device handle
4611 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4613 if (raid_device && raid_device->starget && in _scsih_set_volume_delete_flag()
4614 raid_device->starget->hostdata) { in _scsih_set_volume_delete_flag()
4616 raid_device->starget->hostdata; in _scsih_set_volume_delete_flag()
4617 sas_target_priv_data->deleted = 1; in _scsih_set_volume_delete_flag()
4620 handle, (u64)raid_device->wwid)); in _scsih_set_volume_delete_flag()
4622 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_set_volume_delete_flag()
4626 * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
4633 * input handle is non-zero, or when a and b have not been set before.
4647 * _scsih_check_ir_config_unhide_events - check for UNHIDE events
4648 * @ioc: per adapter object
4670 if (ioc->is_warpdrive) in _scsih_check_ir_config_unhide_events()
4674 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4675 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4676 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4679 if (element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4681 element->ReasonCode == in _scsih_check_ir_config_unhide_events()
4683 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4690 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4691 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4692 if (le32_to_cpu(event_data->Flags) & in _scsih_check_ir_config_unhide_events()
4695 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) { in _scsih_check_ir_config_unhide_events()
4696 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4707 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_check_ir_config_unhide_events()
4708 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_check_ir_config_unhide_events()
4709 if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE) in _scsih_check_ir_config_unhide_events()
4711 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_check_ir_config_unhide_events()
4712 volume_handle = le16_to_cpu(element->VolDevHandle); in _scsih_check_ir_config_unhide_events()
4713 clear_bit(handle, ioc->pd_handles); in _scsih_check_ir_config_unhide_events()
4719 INIT_LIST_HEAD(&delayed_tr->list); in _scsih_check_ir_config_unhide_events()
4720 delayed_tr->handle = handle; in _scsih_check_ir_config_unhide_events()
4721 list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list); in _scsih_check_ir_config_unhide_events()
4732 * _scsih_check_volume_delete_events - set delete flag for volumes
4733 * @ioc: per adapter object
4747 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_check_volume_delete_events()
4749 state = le32_to_cpu(event_data->NewValue); in _scsih_check_volume_delete_events()
4753 le16_to_cpu(event_data->VolDevHandle)); in _scsih_check_volume_delete_events()
4757 * _scsih_temp_threshold_events - display temperature threshold exceeded events
4758 * @ioc: per adapter object
4767 if (ioc->temp_sensors_count >= event_data->SensorNum) { in _scsih_temp_threshold_events()
4769 le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ", in _scsih_temp_threshold_events()
4770 le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ", in _scsih_temp_threshold_events()
4771 le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ", in _scsih_temp_threshold_events()
4772 le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ", in _scsih_temp_threshold_events()
4773 event_data->SensorNum); in _scsih_temp_threshold_events()
4775 event_data->CurrentTemperature); in _scsih_temp_threshold_events()
4776 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_temp_threshold_events()
4793 struct MPT3SAS_DEVICE *priv = scmd->device->hostdata; in _scsih_set_satl_pending()
4795 if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16) in _scsih_set_satl_pending()
4799 return test_and_set_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4801 clear_bit(0, &priv->ata_command_pending); in _scsih_set_satl_pending()
4806 * _scsih_flush_running_cmds - completing outstanding commands.
4807 * @ioc: per adapter object
4820 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_flush_running_cmds()
4829 if (ioc->pci_error_recovery || ioc->remove_host) in _scsih_flush_running_cmds()
4830 scmd->result = DID_NO_CONNECT << 16; in _scsih_flush_running_cmds()
4832 scmd->result = DID_RESET << 16; in _scsih_flush_running_cmds()
4833 scmd->scsi_done(scmd); in _scsih_flush_running_cmds()
4839 * _scsih_setup_eedp - setup MPI request for EEDP transfer
4840 * @ioc: per adapter object
4877 mpi_request->CDB.EEDP32.PrimaryReferenceTag = in _scsih_setup_eedp()
4878 cpu_to_be32(t10_pi_ref_tag(scmd->request)); in _scsih_setup_eedp()
4891 mpi_request_3v->EEDPBlockSize = in _scsih_setup_eedp()
4892 cpu_to_le16(scmd->device->sector_size); in _scsih_setup_eedp()
4894 if (ioc->is_gen35_ioc) in _scsih_setup_eedp()
4896 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags); in _scsih_setup_eedp()
4900 * _scsih_eedp_error_handling - return sense code for EEDP errors
4923 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10, in _scsih_eedp_error_handling()
4925 scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) | in _scsih_eedp_error_handling()
4930 * scsih_qcmd - main scsi request entry point
4934 * The callback index is set inside `ioc->scsi_io_cb_idx`.
4937 * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
4947 struct request *rq = scmd->request; in scsih_qcmd()
4955 if (ioc->logging_level & MPT_DEBUG_SCSI) in scsih_qcmd()
4958 sas_device_priv_data = scmd->device->hostdata; in scsih_qcmd()
4959 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { in scsih_qcmd()
4960 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4961 scmd->scsi_done(scmd); in scsih_qcmd()
4966 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4967 scmd->scsi_done(scmd); in scsih_qcmd()
4971 sas_target_priv_data = sas_device_priv_data->sas_target; in scsih_qcmd()
4973 /* invalid device handle */ in scsih_qcmd()
4974 handle = sas_target_priv_data->handle; in scsih_qcmd()
4976 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4977 scmd->scsi_done(scmd); in scsih_qcmd()
4982 if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) { in scsih_qcmd()
4985 } else if (sas_target_priv_data->deleted) { in scsih_qcmd()
4986 /* device has been deleted */ in scsih_qcmd()
4987 scmd->result = DID_NO_CONNECT << 16; in scsih_qcmd()
4988 scmd->scsi_done(scmd); in scsih_qcmd()
4990 } else if (sas_target_priv_data->tm_busy || in scsih_qcmd()
4991 sas_device_priv_data->block) { in scsih_qcmd()
4992 /* device busy with task management */ in scsih_qcmd()
5002 if (test_bit(0, &sas_device_priv_data->ata_command_pending)) in scsih_qcmd()
5006 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in scsih_qcmd()
5008 else if (scmd->sc_data_direction == DMA_TO_DEVICE) in scsih_qcmd()
5016 if (sas_device_priv_data->ncq_prio_enable) { in scsih_qcmd()
5021 /* Make sure Device is not raid volume. in scsih_qcmd()
5024 if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) in scsih_qcmd()
5025 && !scsih_is_nvme(&scmd->device->sdev_gendev)) in scsih_qcmd()
5026 && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) in scsih_qcmd()
5029 smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); in scsih_qcmd()
5036 memset(mpi_request, 0, ioc->request_sz); in scsih_qcmd()
5039 if (scmd->cmd_len == 32) in scsih_qcmd()
5041 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5042 if (sas_device_priv_data->sas_target->flags & in scsih_qcmd()
5044 mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in scsih_qcmd()
5046 mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; in scsih_qcmd()
5047 mpi_request->DevHandle = cpu_to_le16(handle); in scsih_qcmd()
5048 mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); in scsih_qcmd()
5049 mpi_request->Control = cpu_to_le32(mpi_control); in scsih_qcmd()
5050 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len); in scsih_qcmd()
5051 mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR; in scsih_qcmd()
5052 mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; in scsih_qcmd()
5053 mpi_request->SenseBufferLowAddress = in scsih_qcmd()
5055 mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4; in scsih_qcmd()
5056 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) in scsih_qcmd()
5057 mpi_request->LUN); in scsih_qcmd()
5058 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in scsih_qcmd()
5060 if (mpi_request->DataLength) { in scsih_qcmd()
5061 pcie_device = sas_target_priv_data->pcie_dev; in scsih_qcmd()
5062 if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) { in scsih_qcmd()
5068 ioc->build_zero_len_sge(ioc, &mpi_request->SGL); in scsih_qcmd()
5070 raid_device = sas_target_priv_data->raid_device; in scsih_qcmd()
5071 if (raid_device && raid_device->direct_io_enabled) in scsih_qcmd()
5075 if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { in scsih_qcmd()
5076 if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { in scsih_qcmd()
5077 mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len | in scsih_qcmd()
5079 ioc->put_smid_fast_path(ioc, smid, handle); in scsih_qcmd()
5081 ioc->put_smid_scsi_io(ioc, smid, in scsih_qcmd()
5082 le16_to_cpu(mpi_request->DevHandle)); in scsih_qcmd()
5084 ioc->put_smid_default(ioc, smid); in scsih_qcmd()
5092 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
5101 data->skey = sense_buffer[1] & 0x0F; in _scsih_normalize_sense()
5102 data->asc = sense_buffer[2]; in _scsih_normalize_sense()
5103 data->ascq = sense_buffer[3]; in _scsih_normalize_sense()
5106 data->skey = sense_buffer[2] & 0x0F; in _scsih_normalize_sense()
5107 data->asc = sense_buffer[12]; in _scsih_normalize_sense()
5108 data->ascq = sense_buffer[13]; in _scsih_normalize_sense()
5113 * _scsih_scsi_ioc_info - translated non-succesfull SCSI_IO request
5114 * @ioc: per adapter object
5119 * scsi_status - SCSI Status code returned from target device
5120 * scsi_state - state info associated with SCSI_IO determined by ioc
5121 * ioc_status - ioc supplied status info
5129 u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & in _scsih_scsi_ioc_info()
5131 u8 scsi_state = mpi_reply->SCSIState; in _scsih_scsi_ioc_info()
5132 u8 scsi_status = mpi_reply->SCSIStatus; in _scsih_scsi_ioc_info()
5135 char *desc_scsi_state = ioc->tmp_string; in _scsih_scsi_ioc_info()
5136 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_scsi_ioc_info()
5139 struct scsi_target *starget = scmd->device->sdev_target; in _scsih_scsi_ioc_info()
5140 struct MPT3SAS_TARGET *priv_target = starget->hostdata; in _scsih_scsi_ioc_info()
5145 if (ioc->hide_ir_msg) in _scsih_scsi_ioc_info()
5167 desc_ioc_state = "scsi device not there"; in _scsih_scsi_ioc_info()
5268 if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { in _scsih_scsi_ioc_info()
5270 device_str, (u64)priv_target->sas_address); in _scsih_scsi_ioc_info()
5271 } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { in _scsih_scsi_ioc_info()
5275 (u64)pcie_device->wwid, pcie_device->port_num); in _scsih_scsi_ioc_info()
5276 if (pcie_device->enclosure_handle != 0) in _scsih_scsi_ioc_info()
5278 (u64)pcie_device->enclosure_logical_id, in _scsih_scsi_ioc_info()
5279 pcie_device->slot); in _scsih_scsi_ioc_info()
5280 if (pcie_device->connector_name[0]) in _scsih_scsi_ioc_info()
5282 pcie_device->enclosure_level, in _scsih_scsi_ioc_info()
5283 pcie_device->connector_name); in _scsih_scsi_ioc_info()
5290 (u64)sas_device->sas_address, sas_device->phy); in _scsih_scsi_ioc_info()
5300 le16_to_cpu(mpi_reply->DevHandle), in _scsih_scsi_ioc_info()
5303 scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd)); in _scsih_scsi_ioc_info()
5304 ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n", in _scsih_scsi_ioc_info()
5305 le16_to_cpu(mpi_reply->TaskTag), in _scsih_scsi_ioc_info()
5306 le32_to_cpu(mpi_reply->TransferCount), scmd->result); in _scsih_scsi_ioc_info()
5312 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_scsi_ioc_info()
5315 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_scsi_ioc_info()
5318 response_info = le32_to_cpu(mpi_reply->ResponseInfo); in _scsih_scsi_ioc_info()
5325 * _scsih_turn_on_pfa_led - illuminate PFA LED
5326 * @ioc: per adapter object
5327 * @handle: device handle
5354 sas_device->pfa_led_on = 1; in _scsih_turn_on_pfa_led()
5368 * _scsih_turn_off_pfa_led - turn off Fault LED
5369 * @ioc: per adapter object
5370 * @sas_device: sas device whose PFA LED has to turned off
5384 mpi_request.Slot = cpu_to_le16(sas_device->slot); in _scsih_turn_off_pfa_led()
5386 mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle); in _scsih_turn_off_pfa_led()
5405 * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
5406 * @ioc: per adapter object
5407 * @handle: device handle
5418 fw_event->event = MPT3SAS_TURN_ON_PFA_LED; in _scsih_send_event_to_turn_on_pfa_led()
5419 fw_event->device_handle = handle; in _scsih_send_event_to_turn_on_pfa_led()
5420 fw_event->ioc = ioc; in _scsih_send_event_to_turn_on_pfa_led()
5426 * _scsih_smart_predicted_fault - process smart errors
5427 * @ioc: per adapter object
5428 * @handle: device handle
5442 /* only handle non-raid devices */ in _scsih_smart_predicted_fault()
5443 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5448 starget = sas_device->starget; in _scsih_smart_predicted_fault()
5449 sas_target_priv_data = starget->hostdata; in _scsih_smart_predicted_fault()
5451 if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) || in _scsih_smart_predicted_fault()
5452 ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))) in _scsih_smart_predicted_fault()
5457 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5459 if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) in _scsih_smart_predicted_fault()
5472 event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; in _scsih_smart_predicted_fault()
5473 event_reply->Event = in _scsih_smart_predicted_fault()
5475 event_reply->MsgLength = sz/4; in _scsih_smart_predicted_fault()
5476 event_reply->EventDataLength = in _scsih_smart_predicted_fault()
5479 event_reply->EventData; in _scsih_smart_predicted_fault()
5480 event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA; in _scsih_smart_predicted_fault()
5481 event_data->ASC = 0x5D; in _scsih_smart_predicted_fault()
5482 event_data->DevHandle = cpu_to_le16(handle); in _scsih_smart_predicted_fault()
5483 event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address); in _scsih_smart_predicted_fault()
5492 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_smart_predicted_fault()
5497 * _scsih_io_done - scsi request callback
5498 * @ioc: per adapter object
5534 scmd->result = DID_OK << 16; in _scsih_io_done()
5538 sas_device_priv_data = scmd->device->hostdata; in _scsih_io_done()
5539 if (!sas_device_priv_data || !sas_device_priv_data->sas_target || in _scsih_io_done()
5540 sas_device_priv_data->sas_target->deleted) { in _scsih_io_done()
5541 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5544 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_io_done()
5551 if (st->direct_io && in _scsih_io_done()
5554 st->direct_io = 0; in _scsih_io_done()
5555 st->scmd = scmd; in _scsih_io_done()
5556 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); in _scsih_io_done()
5557 mpi_request->DevHandle = in _scsih_io_done()
5558 cpu_to_le16(sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5559 ioc->put_smid_scsi_io(ioc, smid, in _scsih_io_done()
5560 sas_device_priv_data->sas_target->handle); in _scsih_io_done()
5564 scsi_state = mpi_reply->SCSIState; in _scsih_io_done()
5567 le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; in _scsih_io_done()
5568 if (!sas_device_priv_data->tlr_snoop_check) { in _scsih_io_done()
5569 sas_device_priv_data->tlr_snoop_check++; in _scsih_io_done()
5570 if ((!ioc->is_warpdrive && in _scsih_io_done()
5571 !scsih_is_raid(&scmd->device->sdev_gendev) && in _scsih_io_done()
5572 !scsih_is_nvme(&scmd->device->sdev_gendev)) in _scsih_io_done()
5573 && sas_is_tlr_enabled(scmd->device) && in _scsih_io_done()
5575 sas_disable_tlr(scmd->device); in _scsih_io_done()
5576 sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); in _scsih_io_done()
5580 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); in _scsih_io_done()
5581 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); in _scsih_io_done()
5583 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_io_done()
5587 scsi_status = mpi_reply->SCSIStatus; in _scsih_io_done()
5601 le32_to_cpu(mpi_reply->SenseCount)); in _scsih_io_done()
5602 memcpy(scmd->sense_buffer, sense_data, sz); in _scsih_io_done()
5603 _scsih_normalize_sense(scmd->sense_buffer, &data); in _scsih_io_done()
5607 le16_to_cpu(mpi_reply->DevHandle)); in _scsih_io_done()
5610 if ((ioc->logging_level & MPT_DEBUG_REPLY) && in _scsih_io_done()
5611 ((scmd->sense_buffer[2] == UNIT_ATTENTION) || in _scsih_io_done()
5612 (scmd->sense_buffer[2] == MEDIUM_ERROR) || in _scsih_io_done()
5613 (scmd->sense_buffer[2] == HARDWARE_ERROR))) in _scsih_io_done()
5619 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5623 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5627 if (sas_device_priv_data->block) { in _scsih_io_done()
5628 scmd->result = DID_TRANSPORT_DISRUPTED << 16; in _scsih_io_done()
5632 if (scmd->retries > 2) { in _scsih_io_done()
5633 scmd->result = DID_NO_CONNECT << 16; in _scsih_io_done()
5634 scsi_device_set_state(scmd->device, in _scsih_io_done()
5637 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5638 scmd->device->expecting_cc_ua = 1; in _scsih_io_done()
5642 scmd->result = DID_RESET << 16; in _scsih_io_done()
5644 } else if ((scmd->device->channel == RAID_CHANNEL) && in _scsih_io_done()
5647 scmd->result = DID_RESET << 16; in _scsih_io_done()
5650 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5654 scmd->result = DID_RESET << 16; in _scsih_io_done()
5658 if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt)) in _scsih_io_done()
5659 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5661 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5665 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5670 if (xfer_cnt < scmd->underflow) { in _scsih_io_done()
5672 scmd->result = SAM_STAT_BUSY; in _scsih_io_done()
5674 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5677 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5679 scmd->result = DID_RESET << 16; in _scsih_io_done()
5680 else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) { in _scsih_io_done()
5681 mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID; in _scsih_io_done()
5682 mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION; in _scsih_io_done()
5683 scmd->result = (DRIVER_SENSE << 24) | in _scsih_io_done()
5685 scmd->sense_buffer[0] = 0x70; in _scsih_io_done()
5686 scmd->sense_buffer[2] = ILLEGAL_REQUEST; in _scsih_io_done()
5687 scmd->sense_buffer[12] = 0x20; in _scsih_io_done()
5688 scmd->sense_buffer[13] = 0; in _scsih_io_done()
5697 scmd->result = (DID_OK << 16) | scsi_status; in _scsih_io_done()
5702 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5704 scmd->result = DID_RESET << 16; in _scsih_io_done()
5723 scmd->result = DID_SOFT_ERROR << 16; in _scsih_io_done()
5728 if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY)) in _scsih_io_done()
5735 scmd->scsi_done(scmd); in _scsih_io_done()
5740 * _scsih_sas_host_refresh - refreshing sas host object contents
5741 * @ioc: per adapter object
5744 * During port enable, fw will send topology events for every device. Its
5761 (u64)ioc->sas_hba.sas_address)); in _scsih_sas_host_refresh()
5763 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys in _scsih_sas_host_refresh()
5778 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_refresh()
5779 link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4; in _scsih_sas_host_refresh()
5781 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_refresh()
5783 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_refresh()
5784 attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i]. in _scsih_sas_host_refresh()
5788 mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, in _scsih_sas_host_refresh()
5796 * _scsih_sas_host_add - create sas host object
5797 * @ioc: per adapter object
5799 * Creating host side data object, stored in ioc->sas_hba
5822 ioc->sas_hba.phy = kcalloc(num_phys, in _scsih_sas_host_add()
5824 if (!ioc->sas_hba.phy) { in _scsih_sas_host_add()
5829 ioc->sas_hba.num_phys = num_phys; in _scsih_sas_host_add()
5832 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
5855 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _scsih_sas_host_add()
5877 ioc->io_missing_delay = in _scsih_sas_host_add()
5878 sas_iounit_pg1->IODeviceMissingDelay; in _scsih_sas_host_add()
5880 sas_iounit_pg1->ReportDeviceMissingDelay; in _scsih_sas_host_add()
5882 ioc->device_missing_delay = (device_missing_delay & in _scsih_sas_host_add()
5885 ioc->device_missing_delay = device_missing_delay & in _scsih_sas_host_add()
5888 ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev; in _scsih_sas_host_add()
5889 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _scsih_sas_host_add()
5905 ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0-> in _scsih_sas_host_add()
5907 ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; in _scsih_sas_host_add()
5908 ioc->sas_hba.phy[i].phy_id = i; in _scsih_sas_host_add()
5909 mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], in _scsih_sas_host_add()
5910 phy_pg0, ioc->sas_hba.parent_dev); in _scsih_sas_host_add()
5913 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) { in _scsih_sas_host_add()
5918 ioc->sas_hba.enclosure_handle = in _scsih_sas_host_add()
5920 ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _scsih_sas_host_add()
5922 ioc->sas_hba.handle, in _scsih_sas_host_add()
5923 (u64)ioc->sas_hba.sas_address, in _scsih_sas_host_add()
5924 ioc->sas_hba.num_phys); in _scsih_sas_host_add()
5926 if (ioc->sas_hba.enclosure_handle) { in _scsih_sas_host_add()
5929 ioc->sas_hba.enclosure_handle))) in _scsih_sas_host_add()
5930 ioc->sas_hba.enclosure_logical_id = in _scsih_sas_host_add()
5940 * _scsih_expander_add - creating expander object
5941 * @ioc: per adapter object
5944 * Creating expander object, stored in ioc->sas_expander_list.
5966 return -1; in _scsih_expander_add()
5968 if (ioc->shost_recovery || ioc->pci_error_recovery) in _scsih_expander_add()
5969 return -1; in _scsih_expander_add()
5975 return -1; in _scsih_expander_add()
5983 return -1; in _scsih_expander_add()
5992 return -1; in _scsih_expander_add()
5994 if (sas_address_parent != ioc->sas_hba.sas_address) { in _scsih_expander_add()
5995 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
5998 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6006 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6010 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_add()
6020 return -1; in _scsih_expander_add()
6023 sas_expander->handle = handle; in _scsih_expander_add()
6024 sas_expander->num_phys = expander_pg0.NumPhys; in _scsih_expander_add()
6025 sas_expander->sas_address_parent = sas_address_parent; in _scsih_expander_add()
6026 sas_expander->sas_address = sas_address; in _scsih_expander_add()
6030 (u64)sas_expander->sas_address, sas_expander->num_phys); in _scsih_expander_add()
6032 if (!sas_expander->num_phys) { in _scsih_expander_add()
6033 rc = -1; in _scsih_expander_add()
6036 sas_expander->phy = kcalloc(sas_expander->num_phys, in _scsih_expander_add()
6038 if (!sas_expander->phy) { in _scsih_expander_add()
6041 rc = -1; in _scsih_expander_add()
6045 INIT_LIST_HEAD(&sas_expander->sas_port_list); in _scsih_expander_add()
6051 rc = -1; in _scsih_expander_add()
6054 sas_expander->parent_dev = &mpt3sas_port->rphy->dev; in _scsih_expander_add()
6056 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_expander_add()
6061 rc = -1; in _scsih_expander_add()
6064 sas_expander->phy[i].handle = handle; in _scsih_expander_add()
6065 sas_expander->phy[i].phy_id = i; in _scsih_expander_add()
6068 &sas_expander->phy[i], expander_pg1, in _scsih_expander_add()
6069 sas_expander->parent_dev))) { in _scsih_expander_add()
6072 rc = -1; in _scsih_expander_add()
6077 if (sas_expander->enclosure_handle) { in _scsih_expander_add()
6080 sas_expander->enclosure_handle); in _scsih_expander_add()
6082 sas_expander->enclosure_logical_id = in _scsih_expander_add()
6083 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_expander_add()
6092 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_add()
6099 * mpt3sas_expander_remove - removing expander object
6100 * @ioc: per adapter object
6109 if (ioc->shost_recovery) in mpt3sas_expander_remove()
6112 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
6115 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_expander_remove()
6121 * _scsih_done - internal SCSI_IO callback handler.
6122 * @ioc: per adapter object
6128 * The callback index passed is `ioc->scsih_cb_idx`
6139 if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED) in _scsih_done()
6141 if (ioc->scsih_cmds.smid != smid) in _scsih_done()
6143 ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE; in _scsih_done()
6145 memcpy(ioc->scsih_cmds.reply, mpi_reply, in _scsih_done()
6146 mpi_reply->MsgLength*4); in _scsih_done()
6147 ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID; in _scsih_done()
6149 ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING; in _scsih_done()
6150 complete(&ioc->scsih_cmds.done); in _scsih_done()
6161 * _scsih_check_access_status - check access flags
6162 * @ioc: per adapter object
6164 * @handle: sas device handle
6165 * @access_status: errors returned during discovery of the device
6194 desc = "device blocked"; in _scsih_check_access_status()
6224 * _scsih_check_device - checking device responsiveness
6225 * @ioc: per adapter object
6227 * @handle: attached device handle
6254 /* wide port handling ~ we need only handle device once for the phy that in _scsih_check_device()
6255 * is matched in sas device page zero in _scsih_check_device()
6260 /* check if this is end device */ in _scsih_check_device()
6265 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_check_device()
6273 if (unlikely(sas_device->handle != handle)) { in _scsih_check_device()
6274 starget = sas_device->starget; in _scsih_check_device()
6275 sas_target_priv_data = starget->hostdata; in _scsih_check_device()
6278 sas_device->handle, handle); in _scsih_check_device()
6279 sas_target_priv_data->handle = handle; in _scsih_check_device()
6280 sas_device->handle = handle; in _scsih_check_device()
6283 sas_device->enclosure_level = in _scsih_check_device()
6285 memcpy(sas_device->connector_name, in _scsih_check_device()
6287 sas_device->connector_name[4] = '\0'; in _scsih_check_device()
6289 sas_device->enclosure_level = 0; in _scsih_check_device()
6290 sas_device->connector_name[0] = '\0'; in _scsih_check_device()
6293 sas_device->enclosure_handle = in _scsih_check_device()
6295 sas_device->is_chassis_slot_valid = 0; in _scsih_check_device()
6297 sas_device->enclosure_handle); in _scsih_check_device()
6299 sas_device->enclosure_logical_id = in _scsih_check_device()
6300 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_check_device()
6301 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_check_device()
6303 sas_device->is_chassis_slot_valid = 1; in _scsih_check_device()
6304 sas_device->chassis_slot = in _scsih_check_device()
6305 enclosure_dev->pg0.ChassisSlot; in _scsih_check_device()
6310 /* check if device is present */ in _scsih_check_device()
6313 ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_check_device()
6323 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
6331 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_check_device()
6337 * _scsih_add_device - creating sas device object
6338 * @ioc: per adapter object
6339 * @handle: sas device handle
6340 * @phy_num: phy number end device attached to
6343 * Creating end device object, stored in ioc->sas_device_list.
6345 * Return: 0 for success, non-zero for failure.
6363 return -1; in _scsih_add_device()
6371 return -1; in _scsih_add_device()
6374 /* check if this is end device */ in _scsih_add_device()
6377 return -1; in _scsih_add_device()
6378 set_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
6381 /* check if device is present */ in _scsih_add_device()
6384 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_add_device()
6386 return -1; in _scsih_add_device()
6392 return -1; in _scsih_add_device()
6397 clear_bit(handle, ioc->pend_os_device_add); in _scsih_add_device()
6399 return -1; in _scsih_add_device()
6407 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_add_device()
6419 kref_init(&sas_device->refcount); in _scsih_add_device()
6420 sas_device->handle = handle; in _scsih_add_device()
6423 &sas_device->sas_address_parent) != 0) in _scsih_add_device()
6426 sas_device->enclosure_handle = in _scsih_add_device()
6428 if (sas_device->enclosure_handle != 0) in _scsih_add_device()
6429 sas_device->slot = in _scsih_add_device()
6431 sas_device->device_info = device_info; in _scsih_add_device()
6432 sas_device->sas_address = sas_address; in _scsih_add_device()
6433 sas_device->phy = sas_device_pg0.PhyNum; in _scsih_add_device()
6434 sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & in _scsih_add_device()
6439 sas_device->enclosure_level = in _scsih_add_device()
6441 memcpy(sas_device->connector_name, in _scsih_add_device()
6443 sas_device->connector_name[4] = '\0'; in _scsih_add_device()
6445 sas_device->enclosure_level = 0; in _scsih_add_device()
6446 sas_device->connector_name[0] = '\0'; in _scsih_add_device()
6449 sas_device->is_chassis_slot_valid = 0; in _scsih_add_device()
6451 sas_device->enclosure_logical_id = in _scsih_add_device()
6452 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_add_device()
6453 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_add_device()
6455 sas_device->is_chassis_slot_valid = 1; in _scsih_add_device()
6456 sas_device->chassis_slot = in _scsih_add_device()
6457 enclosure_dev->pg0.ChassisSlot; in _scsih_add_device()
6461 /* get device name */ in _scsih_add_device()
6462 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); in _scsih_add_device()
6464 if (ioc->wait_for_discovery_to_complete) in _scsih_add_device()
6474 * _scsih_remove_device - removing sas device object
6475 * @ioc: per adapter object
6484 if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) && in _scsih_remove_device()
6485 (sas_device->pfa_led_on)) { in _scsih_remove_device()
6487 sas_device->pfa_led_on = 0; in _scsih_remove_device()
6493 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
6498 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_remove_device()
6499 sas_target_priv_data = sas_device->starget->hostdata; in _scsih_remove_device()
6500 sas_target_priv_data->deleted = 1; in _scsih_remove_device()
6501 _scsih_ublock_io_device(ioc, sas_device->sas_address); in _scsih_remove_device()
6502 sas_target_priv_data->handle = in _scsih_remove_device()
6506 if (!ioc->hide_drives) in _scsih_remove_device()
6508 sas_device->sas_address, in _scsih_remove_device()
6509 sas_device->sas_address_parent); in _scsih_remove_device()
6512 sas_device->handle, (u64)sas_device->sas_address); in _scsih_remove_device()
6519 sas_device->handle, (u64)sas_device->sas_address)); in _scsih_remove_device()
6525 * _scsih_sas_topology_change_event_debug - debug for topology event
6526 * @ioc: per adapter object
6541 switch (event_data->ExpStatus) { in _scsih_sas_topology_change_event_debug()
6562 le16_to_cpu(event_data->ExpanderDevHandle), in _scsih_sas_topology_change_event_debug()
6563 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_topology_change_event_debug()
6564 event_data->StartPhyNum, event_data->NumEntries); in _scsih_sas_topology_change_event_debug()
6565 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event_debug()
6566 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event_debug()
6569 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event_debug()
6570 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event_debug()
6592 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event_debug()
6593 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event_debug()
6602 * _scsih_sas_topology_change_event - handle topology changes
6603 * @ioc: per adapter object
6622 fw_event->event_data; in _scsih_sas_topology_change_event()
6624 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_topology_change_event()
6627 if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
6630 if (!ioc->sas_hba.num_phys) in _scsih_sas_topology_change_event()
6635 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
6640 parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); in _scsih_sas_topology_change_event()
6643 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) in _scsih_sas_topology_change_event()
6647 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6651 sas_address = sas_expander->sas_address; in _scsih_sas_topology_change_event()
6652 max_phys = sas_expander->num_phys; in _scsih_sas_topology_change_event()
6653 } else if (parent_handle < ioc->sas_hba.num_phys) { in _scsih_sas_topology_change_event()
6654 sas_address = ioc->sas_hba.sas_address; in _scsih_sas_topology_change_event()
6655 max_phys = ioc->sas_hba.num_phys; in _scsih_sas_topology_change_event()
6657 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6660 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_sas_topology_change_event()
6663 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_sas_topology_change_event()
6664 if (fw_event->ignore) { in _scsih_sas_topology_change_event()
6669 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_sas_topology_change_event()
6671 phy_number = event_data->StartPhyNum + i; in _scsih_sas_topology_change_event()
6674 reason_code = event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
6676 if ((event_data->PHY[i].PhyStatus & in _scsih_sas_topology_change_event()
6680 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); in _scsih_sas_topology_change_event()
6683 link_rate = event_data->PHY[i].LinkRate >> 4; in _scsih_sas_topology_change_event()
6684 prev_link_rate = event_data->PHY[i].LinkRate & 0xF; in _scsih_sas_topology_change_event()
6688 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
6703 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_sas_topology_change_event()
6710 if (ioc->shost_recovery) in _scsih_sas_topology_change_event()
6727 if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING && in _scsih_sas_topology_change_event()
6735 * _scsih_sas_device_status_change_event_debug - debug for device event
6746 switch (event_data->ReasonCode) { in _scsih_sas_device_status_change_event_debug()
6751 reason_str = "unsupported device discovered"; in _scsih_sas_device_status_change_event_debug()
6754 reason_str = "internal device reset"; in _scsih_sas_device_status_change_event_debug()
6772 reason_str = "internal device reset complete"; in _scsih_sas_device_status_change_event_debug()
6790 ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)", in _scsih_sas_device_status_change_event_debug()
6791 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_status_change_event_debug()
6792 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_status_change_event_debug()
6793 le16_to_cpu(event_data->TaskTag)); in _scsih_sas_device_status_change_event_debug()
6794 if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA) in _scsih_sas_device_status_change_event_debug()
6796 event_data->ASC, event_data->ASCQ); in _scsih_sas_device_status_change_event_debug()
6801 * _scsih_sas_device_status_change_event - handle device status change
6802 * @ioc: per adapter object
6815 /* In MPI Revision K (0xC), the internal device reset complete was in _scsih_sas_device_status_change_event()
6818 if ((ioc->facts.HeaderVersion >> 8) < 0xC) in _scsih_sas_device_status_change_event()
6821 if (event_data->ReasonCode != in _scsih_sas_device_status_change_event()
6823 event_data->ReasonCode != in _scsih_sas_device_status_change_event()
6827 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
6828 sas_address = le64_to_cpu(event_data->SASAddress); in _scsih_sas_device_status_change_event()
6832 if (!sas_device || !sas_device->starget) in _scsih_sas_device_status_change_event()
6835 target_priv_data = sas_device->starget->hostdata; in _scsih_sas_device_status_change_event()
6839 if (event_data->ReasonCode == in _scsih_sas_device_status_change_event()
6841 target_priv_data->tm_busy = 1; in _scsih_sas_device_status_change_event()
6843 target_priv_data->tm_busy = 0; in _scsih_sas_device_status_change_event()
6845 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_device_status_change_event()
6848 (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", in _scsih_sas_device_status_change_event()
6849 target_priv_data->handle); in _scsih_sas_device_status_change_event()
6855 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_device_status_change_event()
6860 * _scsih_check_pcie_access_status - check access flags
6861 * @ioc: per adapter object
6863 * @handle: sas device handle
6864 * @access_status: errors returned during discovery of the device
6881 desc = "PCIe device capability failed"; in _scsih_check_pcie_access_status()
6884 desc = "PCIe device blocked"; in _scsih_check_pcie_access_status()
6886 "Device with Access Status (%s): wwid(0x%016llx), " in _scsih_check_pcie_access_status()
6892 desc = "PCIe device mem space access failed"; in _scsih_check_pcie_access_status()
6895 desc = "PCIe device unsupported"; in _scsih_check_pcie_access_status()
6898 desc = "PCIe device MSIx Required"; in _scsih_check_pcie_access_status()
6901 desc = "PCIe device init fail max"; in _scsih_check_pcie_access_status()
6904 desc = "PCIe device status unknown"; in _scsih_check_pcie_access_status()
6910 desc = "nvme device configuration unsupported"; in _scsih_check_pcie_access_status()
6948 * _scsih_pcie_device_remove_from_sml - removing pcie device
6950 * @ioc: per adapter object
6962 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
6963 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
6967 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
6968 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
6969 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
6973 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
6974 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
6976 if (pcie_device->starget && pcie_device->starget->hostdata) { in _scsih_pcie_device_remove_from_sml()
6977 sas_target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_remove_from_sml()
6978 sas_target_priv_data->deleted = 1; in _scsih_pcie_device_remove_from_sml()
6979 _scsih_ublock_io_device(ioc, pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
6980 sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; in _scsih_pcie_device_remove_from_sml()
6984 pcie_device->handle, (u64)pcie_device->wwid); in _scsih_pcie_device_remove_from_sml()
6985 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
6987 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
6988 pcie_device->slot); in _scsih_pcie_device_remove_from_sml()
6989 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
6991 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
6992 pcie_device->connector_name); in _scsih_pcie_device_remove_from_sml()
6994 if (pcie_device->starget && (pcie_device->access_status != in _scsih_pcie_device_remove_from_sml()
6996 scsi_remove_target(&pcie_device->starget->dev); in _scsih_pcie_device_remove_from_sml()
7000 pcie_device->handle, (u64)pcie_device->wwid)); in _scsih_pcie_device_remove_from_sml()
7001 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_device_remove_from_sml()
7005 (u64)pcie_device->enclosure_logical_id, in _scsih_pcie_device_remove_from_sml()
7006 pcie_device->slot)); in _scsih_pcie_device_remove_from_sml()
7007 if (pcie_device->connector_name[0] != '\0') in _scsih_pcie_device_remove_from_sml()
7011 pcie_device->enclosure_level, in _scsih_pcie_device_remove_from_sml()
7012 pcie_device->connector_name)); in _scsih_pcie_device_remove_from_sml()
7014 kfree(pcie_device->serial_number); in _scsih_pcie_device_remove_from_sml()
7019 * _scsih_pcie_check_device - checking device responsiveness
7020 * @ioc: per adapter object
7021 * @handle: attached device handle
7044 /* check if this is end device */ in _scsih_pcie_check_device()
7050 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7054 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7058 if (unlikely(pcie_device->handle != handle)) { in _scsih_pcie_check_device()
7059 starget = pcie_device->starget; in _scsih_pcie_check_device()
7060 sas_target_priv_data = starget->hostdata; in _scsih_pcie_check_device()
7061 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_check_device()
7064 pcie_device->handle, handle); in _scsih_pcie_check_device()
7065 sas_target_priv_data->handle = handle; in _scsih_pcie_check_device()
7066 pcie_device->handle = handle; in _scsih_pcie_check_device()
7070 pcie_device->enclosure_level = in _scsih_pcie_check_device()
7072 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_check_device()
7075 pcie_device->enclosure_level = 0; in _scsih_pcie_check_device()
7076 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_check_device()
7080 /* check if device is present */ in _scsih_pcie_check_device()
7083 ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n", in _scsih_pcie_check_device()
7085 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7093 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7098 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_check_device()
7107 * _scsih_pcie_add_device - creating pcie device object
7108 * @ioc: per adapter object
7109 * @handle: pcie device handle
7111 * Creating end device object, stored in ioc->pcie_device_list.
7140 set_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
7143 /* check if device is present */ in _scsih_pcie_add_device()
7146 ioc_err(ioc, "device is not present handle(0x04%x)!!!\n", in _scsih_pcie_add_device()
7162 clear_bit(handle, ioc->pend_os_device_add); in _scsih_pcie_add_device()
7167 /* PCIe Device Page 2 contains read-only information about a in _scsih_pcie_add_device()
7168 * specific NVMe device; therefore, this page is only in _scsih_pcie_add_device()
7199 kref_init(&pcie_device->refcount); in _scsih_pcie_add_device()
7200 pcie_device->id = ioc->pcie_target_id++; in _scsih_pcie_add_device()
7201 pcie_device->channel = PCIE_CHANNEL; in _scsih_pcie_add_device()
7202 pcie_device->handle = handle; in _scsih_pcie_add_device()
7203 pcie_device->access_status = pcie_device_pg0.AccessStatus; in _scsih_pcie_add_device()
7204 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); in _scsih_pcie_add_device()
7205 pcie_device->wwid = wwid; in _scsih_pcie_add_device()
7206 pcie_device->port_num = pcie_device_pg0.PortNum; in _scsih_pcie_add_device()
7207 pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) & in _scsih_pcie_add_device()
7210 pcie_device->enclosure_handle = in _scsih_pcie_add_device()
7212 if (pcie_device->enclosure_handle != 0) in _scsih_pcie_add_device()
7213 pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot); in _scsih_pcie_add_device()
7217 pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel; in _scsih_pcie_add_device()
7218 memcpy(&pcie_device->connector_name[0], in _scsih_pcie_add_device()
7221 pcie_device->enclosure_level = 0; in _scsih_pcie_add_device()
7222 pcie_device->connector_name[0] = '\0'; in _scsih_pcie_add_device()
7226 if (pcie_device->enclosure_handle) { in _scsih_pcie_add_device()
7229 pcie_device->enclosure_handle); in _scsih_pcie_add_device()
7231 pcie_device->enclosure_logical_id = in _scsih_pcie_add_device()
7232 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_pcie_add_device()
7234 /* TODO -- Add device name once FW supports it */ in _scsih_pcie_add_device()
7237 pcie_device->nvme_mdts = in _scsih_pcie_add_device()
7239 pcie_device->shutdown_latency = in _scsih_pcie_add_device()
7246 if (pcie_device->shutdown_latency > ioc->max_shutdown_latency) in _scsih_pcie_add_device()
7247 ioc->max_shutdown_latency = in _scsih_pcie_add_device()
7248 pcie_device->shutdown_latency; in _scsih_pcie_add_device()
7250 pcie_device->reset_timeout = in _scsih_pcie_add_device()
7253 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
7255 pcie_device->reset_timeout = 30; in _scsih_pcie_add_device()
7257 if (ioc->wait_for_discovery_to_complete) in _scsih_pcie_add_device()
7267 * _scsih_pcie_topology_change_event_debug - debug for topology
7269 * @ioc: per adapter object
7284 switch (event_data->SwitchStatus) { in _scsih_pcie_topology_change_event_debug()
7305 le16_to_cpu(event_data->SwitchDevHandle), in _scsih_pcie_topology_change_event_debug()
7306 le16_to_cpu(event_data->EnclosureHandle), in _scsih_pcie_topology_change_event_debug()
7307 event_data->StartPortNum, event_data->NumEntries); in _scsih_pcie_topology_change_event_debug()
7308 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event_debug()
7310 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event_debug()
7313 port_number = event_data->StartPortNum + i; in _scsih_pcie_topology_change_event_debug()
7314 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event_debug()
7335 link_rate = event_data->PortEntry[i].CurrentPortInfo & in _scsih_pcie_topology_change_event_debug()
7337 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo & in _scsih_pcie_topology_change_event_debug()
7346 * _scsih_pcie_topology_change_event - handle PCIe topology
7348 * @ioc: per adapter object
7364 (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data; in _scsih_pcie_topology_change_event()
7367 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_topology_change_event()
7370 if (ioc->shost_recovery || ioc->remove_host || in _scsih_pcie_topology_change_event()
7371 ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
7374 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
7380 for (i = 0; i < event_data->NumEntries; i++) { in _scsih_pcie_topology_change_event()
7381 if (fw_event->ignore) { in _scsih_pcie_topology_change_event()
7386 if (ioc->remove_host || ioc->pci_error_recovery) in _scsih_pcie_topology_change_event()
7388 reason_code = event_data->PortEntry[i].PortStatus; in _scsih_pcie_topology_change_event()
7390 le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle); in _scsih_pcie_topology_change_event()
7394 link_rate = event_data->PortEntry[i].CurrentPortInfo in _scsih_pcie_topology_change_event()
7396 prev_link_rate = event_data->PortEntry[i].PreviousPortInfo in _scsih_pcie_topology_change_event()
7401 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
7411 * where a device has been added, however its returning in _scsih_pcie_topology_change_event()
7412 * BUSY for sometime. Then before the Device Missing in _scsih_pcie_topology_change_event()
7413 * Delay expires and the device becomes READY, the in _scsih_pcie_topology_change_event()
7414 * device is removed and added back. in _scsih_pcie_topology_change_event()
7416 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
7418 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_topology_change_event()
7425 if (!test_bit(handle, ioc->pend_os_device_add)) in _scsih_pcie_topology_change_event()
7429 ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n", in _scsih_pcie_topology_change_event()
7431 event_data->PortEntry[i].PortStatus &= 0xF0; in _scsih_pcie_topology_change_event()
7432 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
7436 if (ioc->shost_recovery) in _scsih_pcie_topology_change_event()
7448 event_data->PortEntry[i].PortStatus |= in _scsih_pcie_topology_change_event()
7460 * _scsih_pcie_device_status_change_event_debug - debug for device event
7471 switch (event_data->ReasonCode) { in _scsih_pcie_device_status_change_event_debug()
7476 reason_str = "unsupported device discovered"; in _scsih_pcie_device_status_change_event_debug()
7479 reason_str = "internal device reset"; in _scsih_pcie_device_status_change_event_debug()
7494 reason_str = "device init failure"; in _scsih_pcie_device_status_change_event_debug()
7497 reason_str = "internal device reset complete"; in _scsih_pcie_device_status_change_event_debug()
7513 ioc_info(ioc, "PCIE device status change: (%s)\n" in _scsih_pcie_device_status_change_event_debug()
7515 reason_str, le16_to_cpu(event_data->DevHandle), in _scsih_pcie_device_status_change_event_debug()
7516 (u64)le64_to_cpu(event_data->WWID), in _scsih_pcie_device_status_change_event_debug()
7517 le16_to_cpu(event_data->TaskTag)); in _scsih_pcie_device_status_change_event_debug()
7518 if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA) in _scsih_pcie_device_status_change_event_debug()
7520 event_data->ASC, event_data->ASCQ); in _scsih_pcie_device_status_change_event_debug()
7525 * _scsih_pcie_device_status_change_event - handle device status
7527 * @ioc: per adapter object
7540 (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data; in _scsih_pcie_device_status_change_event()
7541 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_pcie_device_status_change_event()
7545 if (event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
7547 event_data->ReasonCode != in _scsih_pcie_device_status_change_event()
7551 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
7552 wwid = le64_to_cpu(event_data->WWID); in _scsih_pcie_device_status_change_event()
7555 if (!pcie_device || !pcie_device->starget) in _scsih_pcie_device_status_change_event()
7558 target_priv_data = pcie_device->starget->hostdata; in _scsih_pcie_device_status_change_event()
7562 if (event_data->ReasonCode == in _scsih_pcie_device_status_change_event()
7564 target_priv_data->tm_busy = 1; in _scsih_pcie_device_status_change_event()
7566 target_priv_data->tm_busy = 0; in _scsih_pcie_device_status_change_event()
7571 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_pcie_device_status_change_event()
7575 * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
7577 * @ioc: per adapter object
7587 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event_debug()
7602 le16_to_cpu(event_data->EnclosureHandle), in _scsih_sas_enclosure_dev_status_change_event_debug()
7603 (u64)le64_to_cpu(event_data->EnclosureLogicalID), in _scsih_sas_enclosure_dev_status_change_event_debug()
7604 le16_to_cpu(event_data->StartSlot)); in _scsih_sas_enclosure_dev_status_change_event_debug()
7608 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
7609 * @ioc: per adapter object
7620 (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data; in _scsih_sas_enclosure_dev_status_change_event()
7622 u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle); in _scsih_sas_enclosure_dev_status_change_event()
7624 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _scsih_sas_enclosure_dev_status_change_event()
7627 fw_event->event_data); in _scsih_sas_enclosure_dev_status_change_event()
7628 if (ioc->shost_recovery) in _scsih_sas_enclosure_dev_status_change_event()
7635 switch (event_data->ReasonCode) { in _scsih_sas_enclosure_dev_status_change_event()
7647 &enclosure_dev->pg0, in _scsih_sas_enclosure_dev_status_change_event()
7657 list_add_tail(&enclosure_dev->list, in _scsih_sas_enclosure_dev_status_change_event()
7658 &ioc->enclosure_list); in _scsih_sas_enclosure_dev_status_change_event()
7663 list_del(&enclosure_dev->list); in _scsih_sas_enclosure_dev_status_change_event()
7673 * _scsih_sas_broadcast_primitive_event - handle broadcast events
7674 * @ioc: per adapter object
7693 fw_event->event_data; in _scsih_sas_broadcast_primitive_event()
7700 mutex_lock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
7702 __func__, event_data->PhyNum, event_data->PortWidth); in _scsih_sas_broadcast_primitive_event()
7706 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7707 mpi_reply = ioc->tm_cmds.reply; in _scsih_sas_broadcast_primitive_event()
7717 __func__, max_retries - 1)); in _scsih_sas_broadcast_primitive_event()
7721 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { in _scsih_sas_broadcast_primitive_event()
7722 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7728 sdev = scmd->device; in _scsih_sas_broadcast_primitive_event()
7729 sas_device_priv_data = sdev->hostdata; in _scsih_sas_broadcast_primitive_event()
7730 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) in _scsih_sas_broadcast_primitive_event()
7733 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7737 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7741 if (sas_device_priv_data->sas_target->flags & in _scsih_sas_broadcast_primitive_event()
7745 handle = sas_device_priv_data->sas_target->handle; in _scsih_sas_broadcast_primitive_event()
7746 lun = sas_device_priv_data->lun; in _scsih_sas_broadcast_primitive_event()
7749 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7752 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7754 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid, in _scsih_sas_broadcast_primitive_event()
7755 st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
7760 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7763 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) in _scsih_sas_broadcast_primitive_event()
7769 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7774 if (mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
7776 mpi_reply->ResponseCode == in _scsih_sas_broadcast_primitive_event()
7778 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7787 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7791 if (ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7794 r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id, in _scsih_sas_broadcast_primitive_event()
7795 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, in _scsih_sas_broadcast_primitive_event()
7796 st->smid, st->msix_io, 30, 0); in _scsih_sas_broadcast_primitive_event()
7797 if (r == FAILED || st->cb_idx != 0xFF) { in _scsih_sas_broadcast_primitive_event()
7808 task_abort_retries - 1, scmd); in _scsih_sas_broadcast_primitive_event()
7810 termination_count += le32_to_cpu(mpi_reply->TerminationCount); in _scsih_sas_broadcast_primitive_event()
7811 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7814 if (ioc->broadcast_aen_pending) { in _scsih_sas_broadcast_primitive_event()
7819 ioc->broadcast_aen_pending = 0; in _scsih_sas_broadcast_primitive_event()
7824 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _scsih_sas_broadcast_primitive_event()
7828 ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n", in _scsih_sas_broadcast_primitive_event()
7831 ioc->broadcast_aen_busy = 0; in _scsih_sas_broadcast_primitive_event()
7832 if (!ioc->shost_recovery) in _scsih_sas_broadcast_primitive_event()
7834 mutex_unlock(&ioc->tm_cmds.mutex); in _scsih_sas_broadcast_primitive_event()
7838 * _scsih_sas_discovery_event - handle discovery events
7839 * @ioc: per adapter object
7848 (Mpi2EventDataSasDiscovery_t *) fw_event->event_data; in _scsih_sas_discovery_event()
7850 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { in _scsih_sas_discovery_event()
7852 event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ? in _scsih_sas_discovery_event()
7854 if (event_data->DiscoveryStatus) in _scsih_sas_discovery_event()
7856 le32_to_cpu(event_data->DiscoveryStatus)); in _scsih_sas_discovery_event()
7860 if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED && in _scsih_sas_discovery_event()
7861 !ioc->sas_hba.num_phys) { in _scsih_sas_discovery_event()
7862 if (disable_discovery > 0 && ioc->shost_recovery) { in _scsih_sas_discovery_event()
7864 while (ioc->shost_recovery) in _scsih_sas_discovery_event()
7872 * _scsih_sas_device_discovery_error_event - display SAS device discovery error
7874 * @ioc: per adapter object
7883 (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data; in _scsih_sas_device_discovery_error_event()
7885 switch (event_data->ReasonCode) { in _scsih_sas_device_discovery_error_event()
7888 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
7889 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
7890 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
7894 le16_to_cpu(event_data->DevHandle), in _scsih_sas_device_discovery_error_event()
7895 (u64)le64_to_cpu(event_data->SASAddress), in _scsih_sas_device_discovery_error_event()
7896 event_data->PhysicalPort); in _scsih_sas_device_discovery_error_event()
7904 * _scsih_pcie_enumeration_event - handle enumeration events
7905 * @ioc: per adapter object
7914 (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data; in _scsih_pcie_enumeration_event()
7916 if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)) in _scsih_pcie_enumeration_event()
7920 (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? in _scsih_pcie_enumeration_event()
7922 event_data->Flags); in _scsih_pcie_enumeration_event()
7923 if (event_data->EnumerationStatus) in _scsih_pcie_enumeration_event()
7925 le32_to_cpu(event_data->EnumerationStatus)); in _scsih_pcie_enumeration_event()
7930 * _scsih_ir_fastpath - turn on fastpath for IR physdisk
7931 * @ioc: per adapter object
7932 * @handle: device handle for physical disk
7948 if (ioc->hba_mpi_version_belonged == MPI2_VERSION) in _scsih_ir_fastpath()
7951 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
7953 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_fastpath()
7955 rc = -EAGAIN; in _scsih_ir_fastpath()
7958 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_fastpath()
7960 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_fastpath()
7963 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
7964 rc = -EAGAIN; in _scsih_ir_fastpath()
7969 ioc->scsih_cmds.smid = smid; in _scsih_ir_fastpath()
7972 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_fastpath()
7973 mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN; in _scsih_ir_fastpath()
7974 mpi_request->PhysDiskNum = phys_disk_num; in _scsih_ir_fastpath()
7980 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_fastpath()
7981 ioc->put_smid_default(ioc, smid); in _scsih_ir_fastpath()
7982 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_fastpath()
7984 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_fastpath()
7986 ioc->scsih_cmds.status, mpi_request, in _scsih_ir_fastpath()
7988 rc = -EFAULT; in _scsih_ir_fastpath()
7992 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_fastpath()
7994 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_fastpath()
7995 ioc_status = le16_to_cpu(mpi_reply->IOCStatus); in _scsih_ir_fastpath()
7997 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); in _scsih_ir_fastpath()
8005 rc = -EFAULT; in _scsih_ir_fastpath()
8012 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_fastpath()
8013 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_fastpath()
8021 * _scsih_reprobe_lun - reprobing lun
8022 * @sdev: scsi device struct
8023 * @no_uld_attach: sdev->no_uld_attach flag setting
8029 sdev->no_uld_attach = no_uld_attach ? 1 : 0; in _scsih_reprobe_lun()
8031 sdev->no_uld_attach ? "hiding" : "exposing"); in _scsih_reprobe_lun()
8036 * _scsih_sas_volume_add - add new volume
8037 * @ioc: per adapter object
8048 u16 handle = le16_to_cpu(element->VolDevHandle); in _scsih_sas_volume_add()
8058 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8060 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8072 raid_device->id = ioc->sas_id++; in _scsih_sas_volume_add()
8073 raid_device->channel = RAID_CHANNEL; in _scsih_sas_volume_add()
8074 raid_device->handle = handle; in _scsih_sas_volume_add()
8075 raid_device->wwid = wwid; in _scsih_sas_volume_add()
8077 if (!ioc->wait_for_discovery_to_complete) { in _scsih_sas_volume_add()
8078 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_volume_add()
8079 raid_device->id, 0); in _scsih_sas_volume_add()
8083 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8085 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_add()
8090 * _scsih_sas_volume_delete - delete volume
8091 * @ioc: per adapter object
8092 * @handle: volume device handle
8103 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
8106 if (raid_device->starget) { in _scsih_sas_volume_delete()
8107 starget = raid_device->starget; in _scsih_sas_volume_delete()
8108 sas_target_priv_data = starget->hostdata; in _scsih_sas_volume_delete()
8109 sas_target_priv_data->deleted = 1; in _scsih_sas_volume_delete()
8112 raid_device->handle, (u64)raid_device->wwid); in _scsih_sas_volume_delete()
8113 list_del(&raid_device->list); in _scsih_sas_volume_delete()
8116 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_volume_delete()
8118 scsi_remove_target(&starget->dev); in _scsih_sas_volume_delete()
8122 * _scsih_sas_pd_expose - expose pd component to /dev/sdX
8123 * @ioc: per adapter object
8135 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_expose()
8137 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
8140 sas_device->volume_handle = 0; in _scsih_sas_pd_expose()
8141 sas_device->volume_wwid = 0; in _scsih_sas_pd_expose()
8142 clear_bit(handle, ioc->pd_handles); in _scsih_sas_pd_expose()
8143 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_expose()
8144 starget = sas_device->starget; in _scsih_sas_pd_expose()
8145 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_expose()
8146 sas_target_priv_data->flags &= in _scsih_sas_pd_expose()
8150 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_expose()
8162 * _scsih_sas_pd_hide - hide pd component from /dev/sdX
8163 * @ioc: per adapter object
8175 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_hide()
8184 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
8187 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_hide()
8188 if (sas_device->starget && sas_device->starget->hostdata) { in _scsih_sas_pd_hide()
8189 starget = sas_device->starget; in _scsih_sas_pd_hide()
8190 sas_target_priv_data = starget->hostdata; in _scsih_sas_pd_hide()
8191 sas_target_priv_data->flags |= in _scsih_sas_pd_hide()
8193 sas_device->volume_handle = volume_handle; in _scsih_sas_pd_hide()
8194 sas_device->volume_wwid = volume_wwid; in _scsih_sas_pd_hide()
8197 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_sas_pd_hide()
8202 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_hide()
8211 * _scsih_sas_pd_delete - delete pd component
8212 * @ioc: per adapter object
8220 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_delete()
8226 * _scsih_sas_pd_add - remove pd component
8227 * @ioc: per adapter object
8236 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); in _scsih_sas_pd_add()
8243 set_bit(handle, ioc->pd_handles); in _scsih_sas_pd_add()
8247 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
8272 _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); in _scsih_sas_pd_add()
8277 * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
8278 * @ioc: per adapter object
8291 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event_debug()
8294 le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ? in _scsih_sas_ir_config_change_event_debug()
8296 event_data->NumElements); in _scsih_sas_ir_config_change_event_debug()
8297 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event_debug()
8298 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event_debug()
8330 element_type = le16_to_cpu(element->ElementFlags) & in _scsih_sas_ir_config_change_event_debug()
8348 reason_str, le16_to_cpu(element->VolDevHandle), in _scsih_sas_ir_config_change_event_debug()
8349 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event_debug()
8350 element->PhysDiskNum); in _scsih_sas_ir_config_change_event_debug()
8355 * _scsih_sas_ir_config_change_event - handle ir configuration change events
8356 * @ioc: per adapter object
8369 fw_event->event_data; in _scsih_sas_ir_config_change_event()
8371 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_config_change_event()
8372 (!ioc->hide_ir_msg)) in _scsih_sas_ir_config_change_event()
8375 foreign_config = (le32_to_cpu(event_data->Flags) & in _scsih_sas_ir_config_change_event()
8378 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in _scsih_sas_ir_config_change_event()
8379 if (ioc->shost_recovery && in _scsih_sas_ir_config_change_event()
8380 ioc->hba_mpi_version_belonged != MPI2_VERSION) { in _scsih_sas_ir_config_change_event()
8381 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
8382 if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE) in _scsih_sas_ir_config_change_event()
8384 le16_to_cpu(element->PhysDiskDevHandle), in _scsih_sas_ir_config_change_event()
8385 element->PhysDiskNum); in _scsih_sas_ir_config_change_event()
8390 for (i = 0; i < event_data->NumElements; i++, element++) { in _scsih_sas_ir_config_change_event()
8392 switch (element->ReasonCode) { in _scsih_sas_ir_config_change_event()
8402 le16_to_cpu(element->VolDevHandle)); in _scsih_sas_ir_config_change_event()
8405 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8409 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8413 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8417 if (!ioc->is_warpdrive) in _scsih_sas_ir_config_change_event()
8425 * _scsih_sas_ir_volume_event - IR volume event
8426 * @ioc: per adapter object
8441 (Mpi2EventDataIrVolume_t *) fw_event->event_data; in _scsih_sas_ir_volume_event()
8443 if (ioc->shost_recovery) in _scsih_sas_ir_volume_event()
8446 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) in _scsih_sas_ir_volume_event()
8449 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_volume_event()
8450 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_volume_event()
8451 if (!ioc->hide_ir_msg) in _scsih_sas_ir_volume_event()
8455 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_volume_event()
8467 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
8469 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_volume_event()
8488 raid_device->id = ioc->sas_id++; in _scsih_sas_ir_volume_event()
8489 raid_device->channel = RAID_CHANNEL; in _scsih_sas_ir_volume_event()
8490 raid_device->handle = handle; in _scsih_sas_ir_volume_event()
8491 raid_device->wwid = wwid; in _scsih_sas_ir_volume_event()
8493 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_sas_ir_volume_event()
8494 raid_device->id, 0); in _scsih_sas_ir_volume_event()
8506 * _scsih_sas_ir_physical_disk_event - PD event
8507 * @ioc: per adapter object
8522 (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data; in _scsih_sas_ir_physical_disk_event()
8525 if (ioc->shost_recovery) in _scsih_sas_ir_physical_disk_event()
8528 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) in _scsih_sas_ir_physical_disk_event()
8531 handle = le16_to_cpu(event_data->PhysDiskDevHandle); in _scsih_sas_ir_physical_disk_event()
8532 state = le32_to_cpu(event_data->NewValue); in _scsih_sas_ir_physical_disk_event()
8534 if (!ioc->hide_ir_msg) in _scsih_sas_ir_physical_disk_event()
8538 le32_to_cpu(event_data->PreviousValue), in _scsih_sas_ir_physical_disk_event()
8548 if (!ioc->is_warpdrive) in _scsih_sas_ir_physical_disk_event()
8549 set_bit(handle, ioc->pd_handles); in _scsih_sas_ir_physical_disk_event()
8591 * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
8592 * @ioc: per adapter object
8602 switch (event_data->RAIDOperation) { in _scsih_sas_ir_operation_status_event_debug()
8625 le16_to_cpu(event_data->VolDevHandle), in _scsih_sas_ir_operation_status_event_debug()
8626 event_data->PercentComplete); in _scsih_sas_ir_operation_status_event_debug()
8630 * _scsih_sas_ir_operation_status_event - handle RAID operation events
8631 * @ioc: per adapter object
8641 fw_event->event_data; in _scsih_sas_ir_operation_status_event()
8646 if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) && in _scsih_sas_ir_operation_status_event()
8647 (!ioc->hide_ir_msg)) in _scsih_sas_ir_operation_status_event()
8652 if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) { in _scsih_sas_ir_operation_status_event()
8654 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
8655 handle = le16_to_cpu(event_data->VolDevHandle); in _scsih_sas_ir_operation_status_event()
8658 raid_device->percent_complete = in _scsih_sas_ir_operation_status_event()
8659 event_data->PercentComplete; in _scsih_sas_ir_operation_status_event()
8660 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_sas_ir_operation_status_event()
8665 * _scsih_prep_device_scan - initialize parameters prior to device scan
8666 * @ioc: per adapter object
8668 * Set the deleted flag prior to device scan. If the device is found during
8677 shost_for_each_device(sdev, ioc->shost) { in _scsih_prep_device_scan()
8678 sas_device_priv_data = sdev->hostdata; in _scsih_prep_device_scan()
8679 if (sas_device_priv_data && sas_device_priv_data->sas_target) in _scsih_prep_device_scan()
8680 sas_device_priv_data->sas_target->deleted = 1; in _scsih_prep_device_scan()
8685 * _scsih_mark_responding_sas_device - mark a sas_devices as responding
8686 * @ioc: per adapter object
8687 * @sas_device_pg0: SAS Device page 0
8702 if (sas_device_pg0->EnclosureHandle) { in _scsih_mark_responding_sas_device()
8705 le16_to_cpu(sas_device_pg0->EnclosureHandle)); in _scsih_mark_responding_sas_device()
8707 ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n", in _scsih_mark_responding_sas_device()
8708 sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
8710 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
8711 list_for_each_entry(sas_device, &ioc->sas_device_list, list) { in _scsih_mark_responding_sas_device()
8712 if ((sas_device->sas_address == le64_to_cpu( in _scsih_mark_responding_sas_device()
8713 sas_device_pg0->SASAddress)) && (sas_device->slot == in _scsih_mark_responding_sas_device()
8714 le16_to_cpu(sas_device_pg0->Slot))) { in _scsih_mark_responding_sas_device()
8715 sas_device->responding = 1; in _scsih_mark_responding_sas_device()
8716 starget = sas_device->starget; in _scsih_mark_responding_sas_device()
8717 if (starget && starget->hostdata) { in _scsih_mark_responding_sas_device()
8718 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_sas_device()
8719 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_sas_device()
8720 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_sas_device()
8726 le16_to_cpu(sas_device_pg0->DevHandle), in _scsih_mark_responding_sas_device()
8728 sas_device->sas_address); in _scsih_mark_responding_sas_device()
8730 if (sas_device->enclosure_handle != 0) in _scsih_mark_responding_sas_device()
8735 sas_device->enclosure_logical_id, in _scsih_mark_responding_sas_device()
8736 sas_device->slot); in _scsih_mark_responding_sas_device()
8738 if (le16_to_cpu(sas_device_pg0->Flags) & in _scsih_mark_responding_sas_device()
8740 sas_device->enclosure_level = in _scsih_mark_responding_sas_device()
8741 sas_device_pg0->EnclosureLevel; in _scsih_mark_responding_sas_device()
8742 memcpy(&sas_device->connector_name[0], in _scsih_mark_responding_sas_device()
8743 &sas_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_sas_device()
8745 sas_device->enclosure_level = 0; in _scsih_mark_responding_sas_device()
8746 sas_device->connector_name[0] = '\0'; in _scsih_mark_responding_sas_device()
8749 sas_device->enclosure_handle = in _scsih_mark_responding_sas_device()
8750 le16_to_cpu(sas_device_pg0->EnclosureHandle); in _scsih_mark_responding_sas_device()
8751 sas_device->is_chassis_slot_valid = 0; in _scsih_mark_responding_sas_device()
8753 sas_device->enclosure_logical_id = le64_to_cpu( in _scsih_mark_responding_sas_device()
8754 enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_sas_device()
8755 if (le16_to_cpu(enclosure_dev->pg0.Flags) & in _scsih_mark_responding_sas_device()
8757 sas_device->is_chassis_slot_valid = 1; in _scsih_mark_responding_sas_device()
8758 sas_device->chassis_slot = in _scsih_mark_responding_sas_device()
8759 enclosure_dev->pg0.ChassisSlot; in _scsih_mark_responding_sas_device()
8763 if (sas_device->handle == le16_to_cpu( in _scsih_mark_responding_sas_device()
8764 sas_device_pg0->DevHandle)) in _scsih_mark_responding_sas_device()
8767 sas_device->handle); in _scsih_mark_responding_sas_device()
8768 sas_device->handle = le16_to_cpu( in _scsih_mark_responding_sas_device()
8769 sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
8771 sas_target_priv_data->handle = in _scsih_mark_responding_sas_device()
8772 le16_to_cpu(sas_device_pg0->DevHandle); in _scsih_mark_responding_sas_device()
8777 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_mark_responding_sas_device()
8781 * _scsih_create_enclosure_list_after_reset - Free Existing list,
8783 * @ioc: per adapter object
8807 &enclosure_dev->pg0, in _scsih_create_enclosure_list_after_reset()
8816 list_add_tail(&enclosure_dev->list, in _scsih_create_enclosure_list_after_reset()
8817 &ioc->enclosure_list); in _scsih_create_enclosure_list_after_reset()
8819 le16_to_cpu(enclosure_dev->pg0.EnclosureHandle); in _scsih_create_enclosure_list_after_reset()
8824 * _scsih_search_responding_sas_devices -
8825 * @ioc: per adapter object
8839 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_sas_devices()
8841 if (list_empty(&ioc->sas_device_list)) in _scsih_search_responding_sas_devices()
8860 ioc_info(ioc, "search for end-devices: complete\n"); in _scsih_search_responding_sas_devices()
8864 * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
8865 * @ioc: per adapter object
8866 * @pcie_device_pg0: PCIe Device page 0
8880 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
8881 list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { in _scsih_mark_responding_pcie_device()
8882 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) in _scsih_mark_responding_pcie_device()
8883 && (pcie_device->slot == le16_to_cpu( in _scsih_mark_responding_pcie_device()
8884 pcie_device_pg0->Slot))) { in _scsih_mark_responding_pcie_device()
8885 pcie_device->access_status = in _scsih_mark_responding_pcie_device()
8886 pcie_device_pg0->AccessStatus; in _scsih_mark_responding_pcie_device()
8887 pcie_device->responding = 1; in _scsih_mark_responding_pcie_device()
8888 starget = pcie_device->starget; in _scsih_mark_responding_pcie_device()
8889 if (starget && starget->hostdata) { in _scsih_mark_responding_pcie_device()
8890 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_pcie_device()
8891 sas_target_priv_data->tm_busy = 0; in _scsih_mark_responding_pcie_device()
8892 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_pcie_device()
8898 pcie_device->handle, in _scsih_mark_responding_pcie_device()
8899 (unsigned long long)pcie_device->wwid); in _scsih_mark_responding_pcie_device()
8900 if (pcie_device->enclosure_handle != 0) in _scsih_mark_responding_pcie_device()
8905 pcie_device->enclosure_logical_id, in _scsih_mark_responding_pcie_device()
8906 pcie_device->slot); in _scsih_mark_responding_pcie_device()
8909 if (((le32_to_cpu(pcie_device_pg0->Flags)) & in _scsih_mark_responding_pcie_device()
8911 (ioc->hba_mpi_version_belonged != MPI2_VERSION)) { in _scsih_mark_responding_pcie_device()
8912 pcie_device->enclosure_level = in _scsih_mark_responding_pcie_device()
8913 pcie_device_pg0->EnclosureLevel; in _scsih_mark_responding_pcie_device()
8914 memcpy(&pcie_device->connector_name[0], in _scsih_mark_responding_pcie_device()
8915 &pcie_device_pg0->ConnectorName[0], 4); in _scsih_mark_responding_pcie_device()
8917 pcie_device->enclosure_level = 0; in _scsih_mark_responding_pcie_device()
8918 pcie_device->connector_name[0] = '\0'; in _scsih_mark_responding_pcie_device()
8921 if (pcie_device->handle == le16_to_cpu( in _scsih_mark_responding_pcie_device()
8922 pcie_device_pg0->DevHandle)) in _scsih_mark_responding_pcie_device()
8925 pcie_device->handle); in _scsih_mark_responding_pcie_device()
8926 pcie_device->handle = le16_to_cpu( in _scsih_mark_responding_pcie_device()
8927 pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
8929 sas_target_priv_data->handle = in _scsih_mark_responding_pcie_device()
8930 le16_to_cpu(pcie_device_pg0->DevHandle); in _scsih_mark_responding_pcie_device()
8936 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_mark_responding_pcie_device()
8940 * _scsih_search_responding_pcie_devices -
8941 * @ioc: per adapter object
8955 ioc_info(ioc, "search for end-devices: start\n"); in _scsih_search_responding_pcie_devices()
8957 if (list_empty(&ioc->pcie_device_list)) in _scsih_search_responding_pcie_devices()
8979 ioc_info(ioc, "search for PCIe end-devices: complete\n"); in _scsih_search_responding_pcie_devices()
8983 * _scsih_mark_responding_raid_device - mark a raid_device as responding
8984 * @ioc: per adapter object
8986 * @handle: device handle
9000 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9001 list_for_each_entry(raid_device, &ioc->raid_device_list, list) { in _scsih_mark_responding_raid_device()
9002 if (raid_device->wwid == wwid && raid_device->starget) { in _scsih_mark_responding_raid_device()
9003 starget = raid_device->starget; in _scsih_mark_responding_raid_device()
9004 if (starget && starget->hostdata) { in _scsih_mark_responding_raid_device()
9005 sas_target_priv_data = starget->hostdata; in _scsih_mark_responding_raid_device()
9006 sas_target_priv_data->deleted = 0; in _scsih_mark_responding_raid_device()
9009 raid_device->responding = 1; in _scsih_mark_responding_raid_device()
9010 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9011 starget_printk(KERN_INFO, raid_device->starget, in _scsih_mark_responding_raid_device()
9013 (unsigned long long)raid_device->wwid); in _scsih_mark_responding_raid_device()
9017 * across the host reset so re-initialize the in _scsih_mark_responding_raid_device()
9021 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9022 if (raid_device->handle == handle) { in _scsih_mark_responding_raid_device()
9023 spin_unlock_irqrestore(&ioc->raid_device_lock, in _scsih_mark_responding_raid_device()
9028 raid_device->handle); in _scsih_mark_responding_raid_device()
9029 raid_device->handle = handle; in _scsih_mark_responding_raid_device()
9031 sas_target_priv_data->handle = handle; in _scsih_mark_responding_raid_device()
9032 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9036 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_mark_responding_raid_device()
9040 * _scsih_search_responding_raid_devices -
9041 * @ioc: per adapter object
9057 if (!ioc->ir_firmware) in _scsih_search_responding_raid_devices()
9062 if (list_empty(&ioc->raid_device_list)) in _scsih_search_responding_raid_devices()
9087 if (!ioc->is_warpdrive) { in _scsih_search_responding_raid_devices()
9089 memset(ioc->pd_handles, 0, ioc->pd_handles_sz); in _scsih_search_responding_raid_devices()
9099 set_bit(handle, ioc->pd_handles); in _scsih_search_responding_raid_devices()
9107 * _scsih_mark_responding_expander - mark a expander as responding
9108 * @ioc: per adapter object
9122 u16 handle = le16_to_cpu(expander_pg0->DevHandle); in _scsih_mark_responding_expander()
9123 u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
9124 u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); in _scsih_mark_responding_expander()
9131 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
9132 list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) { in _scsih_mark_responding_expander()
9133 if (sas_expander->sas_address != sas_address) in _scsih_mark_responding_expander()
9135 sas_expander->responding = 1; in _scsih_mark_responding_expander()
9138 sas_expander->enclosure_logical_id = in _scsih_mark_responding_expander()
9139 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); in _scsih_mark_responding_expander()
9140 sas_expander->enclosure_handle = in _scsih_mark_responding_expander()
9141 le16_to_cpu(expander_pg0->EnclosureHandle); in _scsih_mark_responding_expander()
9144 if (sas_expander->handle == handle) in _scsih_mark_responding_expander()
9148 (unsigned long long)sas_expander->sas_address, in _scsih_mark_responding_expander()
9149 sas_expander->handle, handle); in _scsih_mark_responding_expander()
9150 sas_expander->handle = handle; in _scsih_mark_responding_expander()
9151 for (i = 0 ; i < sas_expander->num_phys ; i++) in _scsih_mark_responding_expander()
9152 sas_expander->phy[i].handle = handle; in _scsih_mark_responding_expander()
9156 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_mark_responding_expander()
9160 * _scsih_search_responding_expanders -
9161 * @ioc: per adapter object
9177 if (list_empty(&ioc->sas_expander_list)) in _scsih_search_responding_expanders()
9202 * _scsih_remove_unresponding_devices - removing unresponding devices
9203 * @ioc: per adapter object
9219 ioc_info(ioc, "removing unresponding devices: end-devices\n"); in _scsih_remove_unresponding_devices()
9221 * Iterate, pulling off devices marked as non-responding. We become the in _scsih_remove_unresponding_devices()
9224 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
9226 &ioc->sas_device_list, list) { in _scsih_remove_unresponding_devices()
9227 if (!sas_device->responding) in _scsih_remove_unresponding_devices()
9228 list_move_tail(&sas_device->list, &head); in _scsih_remove_unresponding_devices()
9230 sas_device->responding = 0; in _scsih_remove_unresponding_devices()
9232 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_remove_unresponding_devices()
9239 list_del_init(&sas_device->list); in _scsih_remove_unresponding_devices()
9243 ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n"); in _scsih_remove_unresponding_devices()
9245 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
9247 &ioc->pcie_device_list, list) { in _scsih_remove_unresponding_devices()
9248 if (!pcie_device->responding) in _scsih_remove_unresponding_devices()
9249 list_move_tail(&pcie_device->list, &head); in _scsih_remove_unresponding_devices()
9251 pcie_device->responding = 0; in _scsih_remove_unresponding_devices()
9253 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_remove_unresponding_devices()
9257 list_del_init(&pcie_device->list); in _scsih_remove_unresponding_devices()
9262 if (ioc->ir_firmware) { in _scsih_remove_unresponding_devices()
9265 &ioc->raid_device_list, list) { in _scsih_remove_unresponding_devices()
9266 if (!raid_device->responding) in _scsih_remove_unresponding_devices()
9268 raid_device->handle); in _scsih_remove_unresponding_devices()
9270 raid_device->responding = 0; in _scsih_remove_unresponding_devices()
9276 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
9279 &ioc->sas_expander_list, list) { in _scsih_remove_unresponding_devices()
9280 if (!sas_expander->responding) in _scsih_remove_unresponding_devices()
9281 list_move_tail(&sas_expander->list, &tmp_list); in _scsih_remove_unresponding_devices()
9283 sas_expander->responding = 0; in _scsih_remove_unresponding_devices()
9285 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_remove_unresponding_devices()
9305 for (i = 0 ; i < sas_expander->num_phys ; i++) { in _scsih_refresh_expander_links()
9313 mpt3sas_transport_update_links(ioc, sas_expander->sas_address, in _scsih_refresh_expander_links()
9320 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
9321 * @ioc: per adapter object
9363 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
9366 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_scan_for_devices_after_reset()
9383 if (!ioc->ir_firmware) in _scsih_scan_for_devices_after_reset()
9427 set_bit(handle, ioc->pd_handles); in _scsih_scan_for_devices_after_reset()
9429 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
9459 spin_lock_irqsave(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
9462 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); in _scsih_scan_for_devices_after_reset()
9504 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
9520 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
9526 /* This will retry adding the end device. in _scsih_scan_for_devices_after_reset()
9534 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
9550 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n", in _scsih_scan_for_devices_after_reset()
9568 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", in _scsih_scan_for_devices_after_reset()
9576 * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
9577 * @ioc: per adapter object
9587 * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
9589 * @ioc: per adapter object
9598 if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9599 ioc->scsih_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9600 mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9601 complete(&ioc->scsih_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9603 if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9604 ioc->tm_cmds.status |= MPT3_CMD_RESET; in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9605 mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9606 complete(&ioc->tm_cmds.done); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9609 memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9610 memset(ioc->device_remove_in_progress, 0, in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9611 ioc->device_remove_in_progress_sz); in mpt3sas_scsih_clear_outstanding_scsi_tm_commands()
9617 * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
9618 * @ioc: per adapter object
9626 if ((!ioc->is_driver_loading) && !(disable_discovery > 0 && in mpt3sas_scsih_reset_done_handler()
9627 !ioc->sas_hba.num_phys)) { in mpt3sas_scsih_reset_done_handler()
9639 * _mpt3sas_fw_work - delayed task for processing firmware events
9640 * @ioc: per adapter object
9647 ioc->current_event = fw_event; in _mpt3sas_fw_work()
9651 if (ioc->remove_host || ioc->pci_error_recovery) { in _mpt3sas_fw_work()
9653 ioc->current_event = NULL; in _mpt3sas_fw_work()
9657 switch (fw_event->event) { in _mpt3sas_fw_work()
9661 fw_event->event_data); in _mpt3sas_fw_work()
9664 while (scsi_host_in_recovery(ioc->shost) || in _mpt3sas_fw_work()
9665 ioc->shost_recovery) { in _mpt3sas_fw_work()
9670 if (ioc->remove_host || ioc->fw_events_cleanup) in _mpt3sas_fw_work()
9679 ioc->start_scan = 0; in _mpt3sas_fw_work()
9680 if (missing_delay[0] != -1 && missing_delay[1] != -1) in _mpt3sas_fw_work()
9687 _scsih_turn_on_pfa_led(ioc, fw_event->device_handle); in _mpt3sas_fw_work()
9693 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) in _mpt3sas_fw_work()
9696 fw_event->event_data); in _mpt3sas_fw_work()
9731 ioc->current_event = NULL; in _mpt3sas_fw_work()
9737 ioc->current_event = NULL; in _mpt3sas_fw_work()
9754 _mpt3sas_fw_work(fw_event->ioc, fw_event); in _firmware_event_work()
9758 * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
9759 * @ioc: per adapter object
9764 * This function merely adds a new work task into ioc->firmware_event_thread.
9781 if (ioc->pci_error_recovery) in mpt3sas_scsih_event_callback()
9792 event = le16_to_cpu(mpi_reply->Event); in mpt3sas_scsih_event_callback()
9803 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9805 if (baen_data->Primitive != in mpt3sas_scsih_event_callback()
9809 if (ioc->broadcast_aen_busy) { in mpt3sas_scsih_event_callback()
9810 ioc->broadcast_aen_pending++; in mpt3sas_scsih_event_callback()
9813 ioc->broadcast_aen_busy = 1; in mpt3sas_scsih_event_callback()
9820 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9825 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9830 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9835 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9842 if (!ioc->is_warpdrive) in mpt3sas_scsih_event_callback()
9846 mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9847 log_code = (u32 *)log_entry->LogData; in mpt3sas_scsih_event_callback()
9849 if (le16_to_cpu(log_entry->LogEntryQualifier) in mpt3sas_scsih_event_callback()
9861 …no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode.… in mpt3sas_scsih_event_callback()
9873 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9887 mpi_reply->EventData); in mpt3sas_scsih_event_callback()
9891 (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData; in mpt3sas_scsih_event_callback()
9892 switch (ActiveCableEventData->ReasonCode) { in mpt3sas_scsih_event_callback()
9895 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
9899 ActiveCableEventData->ActiveCablePowerRequirement); in mpt3sas_scsih_event_callback()
9904 ActiveCableEventData->ReceptacleID); in mpt3sas_scsih_event_callback()
9916 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; in mpt3sas_scsih_event_callback()
9924 memcpy(fw_event->event_data, mpi_reply->EventData, sz); in mpt3sas_scsih_event_callback()
9925 fw_event->ioc = ioc; in mpt3sas_scsih_event_callback()
9926 fw_event->VF_ID = mpi_reply->VF_ID; in mpt3sas_scsih_event_callback()
9927 fw_event->VP_ID = mpi_reply->VP_ID; in mpt3sas_scsih_event_callback()
9928 fw_event->event = event; in mpt3sas_scsih_event_callback()
9935 * _scsih_expander_node_remove - removing expander device from list.
9936 * @ioc: per adapter object
9940 * ioc->sas_expander_list.
9951 &sas_expander->sas_port_list, port_list) { in _scsih_expander_node_remove()
9952 if (ioc->shost_recovery) in _scsih_expander_node_remove()
9954 if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9957 mpt3sas_port->remote_identify.sas_address); in _scsih_expander_node_remove()
9958 else if (mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9960 mpt3sas_port->remote_identify.device_type == in _scsih_expander_node_remove()
9963 mpt3sas_port->remote_identify.sas_address); in _scsih_expander_node_remove()
9966 mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, in _scsih_expander_node_remove()
9967 sas_expander->sas_address_parent); in _scsih_expander_node_remove()
9970 sas_expander->handle, (unsigned long long) in _scsih_expander_node_remove()
9971 sas_expander->sas_address); in _scsih_expander_node_remove()
9973 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
9974 list_del(&sas_expander->list); in _scsih_expander_node_remove()
9975 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _scsih_expander_node_remove()
9977 kfree(sas_expander->phy); in _scsih_expander_node_remove()
9982 * _scsih_nvme_shutdown - NVMe shutdown notification
9983 * @ioc: per adapter object
9997 if (list_empty(&ioc->pcie_device_list)) in _scsih_nvme_shutdown()
10000 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
10002 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_nvme_shutdown()
10007 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_nvme_shutdown()
10009 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_nvme_shutdown()
10013 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
10018 ioc->scsih_cmds.smid = smid; in _scsih_nvme_shutdown()
10020 mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL; in _scsih_nvme_shutdown()
10021 mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN; in _scsih_nvme_shutdown()
10023 init_completion(&ioc->scsih_cmds.done); in _scsih_nvme_shutdown()
10024 ioc->put_smid_default(ioc, smid); in _scsih_nvme_shutdown()
10028 ioc->max_shutdown_latency); in _scsih_nvme_shutdown()
10029 wait_for_completion_timeout(&ioc->scsih_cmds.done, in _scsih_nvme_shutdown()
10030 ioc->max_shutdown_latency*HZ); in _scsih_nvme_shutdown()
10032 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_nvme_shutdown()
10037 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_nvme_shutdown()
10038 mpi_reply = ioc->scsih_cmds.reply; in _scsih_nvme_shutdown()
10041 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_nvme_shutdown()
10042 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_nvme_shutdown()
10045 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_nvme_shutdown()
10046 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_nvme_shutdown()
10051 * _scsih_ir_shutdown - IR shutdown notification
10052 * @ioc: per adapter object
10065 if (!ioc->ir_firmware) in _scsih_ir_shutdown()
10069 if (list_empty(&ioc->raid_device_list)) in _scsih_ir_shutdown()
10072 mutex_lock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
10074 if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) { in _scsih_ir_shutdown()
10078 ioc->scsih_cmds.status = MPT3_CMD_PENDING; in _scsih_ir_shutdown()
10080 smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx); in _scsih_ir_shutdown()
10083 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
10088 ioc->scsih_cmds.smid = smid; in _scsih_ir_shutdown()
10091 mpi_request->Function = MPI2_FUNCTION_RAID_ACTION; in _scsih_ir_shutdown()
10092 mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in _scsih_ir_shutdown()
10094 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
10096 init_completion(&ioc->scsih_cmds.done); in _scsih_ir_shutdown()
10097 ioc->put_smid_default(ioc, smid); in _scsih_ir_shutdown()
10098 wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); in _scsih_ir_shutdown()
10100 if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { in _scsih_ir_shutdown()
10105 if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) { in _scsih_ir_shutdown()
10106 mpi_reply = ioc->scsih_cmds.reply; in _scsih_ir_shutdown()
10107 if (!ioc->hide_ir_msg) in _scsih_ir_shutdown()
10109 le16_to_cpu(mpi_reply->IOCStatus), in _scsih_ir_shutdown()
10110 le32_to_cpu(mpi_reply->IOCLogInfo)); in _scsih_ir_shutdown()
10114 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in _scsih_ir_shutdown()
10115 mutex_unlock(&ioc->scsih_cmds.mutex); in _scsih_ir_shutdown()
10119 * _scsih_get_shost_and_ioc - get shost and ioc
10121 * @pdev: PCI device struct
10133 dev_err(&pdev->dev, "pdev's driver data is null\n"); in _scsih_get_shost_and_ioc()
10134 return -ENXIO; in _scsih_get_shost_and_ioc()
10139 dev_err(&pdev->dev, "shost's private data is null\n"); in _scsih_get_shost_and_ioc()
10140 return -ENXIO; in _scsih_get_shost_and_ioc()
10147 * scsih_remove - detach and remove add host
10148 * @pdev: PCI device struct
10167 ioc->remove_host = 1; in scsih_remove()
10174 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_remove()
10175 wq = ioc->firmware_event_thread; in scsih_remove()
10176 ioc->firmware_event_thread = NULL; in scsih_remove()
10177 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_remove()
10184 if (ioc->is_aero_ioc) in scsih_remove()
10186 &ioc->ioc_pg1_copy); in scsih_remove()
10191 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, in scsih_remove()
10193 if (raid_device->starget) { in scsih_remove()
10195 raid_device->starget->hostdata; in scsih_remove()
10196 sas_target_priv_data->deleted = 1; in scsih_remove()
10197 scsi_remove_target(&raid_device->starget->dev); in scsih_remove()
10200 raid_device->handle, (u64)raid_device->wwid); in scsih_remove()
10203 list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list, in scsih_remove()
10206 list_del_init(&pcie_device->list); in scsih_remove()
10212 &ioc->sas_hba.sas_port_list, port_list) { in scsih_remove()
10213 if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
10216 mpt3sas_port->remote_identify.sas_address); in scsih_remove()
10217 else if (mpt3sas_port->remote_identify.device_type == in scsih_remove()
10219 mpt3sas_port->remote_identify.device_type == in scsih_remove()
10222 mpt3sas_port->remote_identify.sas_address); in scsih_remove()
10226 if (ioc->sas_hba.num_phys) { in scsih_remove()
10227 kfree(ioc->sas_hba.phy); in scsih_remove()
10228 ioc->sas_hba.phy = NULL; in scsih_remove()
10229 ioc->sas_hba.num_phys = 0; in scsih_remove()
10234 list_del(&ioc->list); in scsih_remove()
10240 * scsih_shutdown - routine call during system shutdown
10241 * @pdev: PCI device struct
10255 ioc->remove_host = 1; in scsih_shutdown()
10262 spin_lock_irqsave(&ioc->fw_event_lock, flags); in scsih_shutdown()
10263 wq = ioc->firmware_event_thread; in scsih_shutdown()
10264 ioc->firmware_event_thread = NULL; in scsih_shutdown()
10265 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in scsih_shutdown()
10272 if (ioc->is_aero_ioc) in scsih_shutdown()
10274 &ioc->ioc_pg1_copy); in scsih_shutdown()
10283 * _scsih_probe_boot_devices - reports 1st device
10284 * @ioc: per adapter object
10287 * device scsi-ml or sas transport for persistent boot device
10294 void *device; in _scsih_probe_boot_devices() local
10306 if (!ioc->bios_pg3.BiosVersion) in _scsih_probe_boot_devices()
10309 device = NULL; in _scsih_probe_boot_devices()
10310 if (ioc->req_boot_device.device) { in _scsih_probe_boot_devices()
10311 device = ioc->req_boot_device.device; in _scsih_probe_boot_devices()
10312 channel = ioc->req_boot_device.channel; in _scsih_probe_boot_devices()
10313 } else if (ioc->req_alt_boot_device.device) { in _scsih_probe_boot_devices()
10314 device = ioc->req_alt_boot_device.device; in _scsih_probe_boot_devices()
10315 channel = ioc->req_alt_boot_device.channel; in _scsih_probe_boot_devices()
10316 } else if (ioc->current_boot_device.device) { in _scsih_probe_boot_devices()
10317 device = ioc->current_boot_device.device; in _scsih_probe_boot_devices()
10318 channel = ioc->current_boot_device.channel; in _scsih_probe_boot_devices()
10321 if (!device) in _scsih_probe_boot_devices()
10325 raid_device = device; in _scsih_probe_boot_devices()
10326 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_boot_devices()
10327 raid_device->id, 0); in _scsih_probe_boot_devices()
10331 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
10332 pcie_device = device; in _scsih_probe_boot_devices()
10333 tid = pcie_device->id; in _scsih_probe_boot_devices()
10334 list_move_tail(&pcie_device->list, &ioc->pcie_device_list); in _scsih_probe_boot_devices()
10335 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in _scsih_probe_boot_devices()
10336 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0); in _scsih_probe_boot_devices()
10340 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
10341 sas_device = device; in _scsih_probe_boot_devices()
10342 handle = sas_device->handle; in _scsih_probe_boot_devices()
10343 sas_address_parent = sas_device->sas_address_parent; in _scsih_probe_boot_devices()
10344 sas_address = sas_device->sas_address; in _scsih_probe_boot_devices()
10345 list_move_tail(&sas_device->list, &ioc->sas_device_list); in _scsih_probe_boot_devices()
10346 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _scsih_probe_boot_devices()
10348 if (ioc->hide_drives) in _scsih_probe_boot_devices()
10353 } else if (!sas_device->starget) { in _scsih_probe_boot_devices()
10354 if (!ioc->is_driver_loading) { in _scsih_probe_boot_devices()
10365 * _scsih_probe_raid - reporting raid volumes to scsi-ml
10366 * @ioc: per adapter object
10377 &ioc->raid_device_list, list) { in _scsih_probe_raid()
10378 if (raid_device->starget) in _scsih_probe_raid()
10380 rc = scsi_add_device(ioc->shost, RAID_CHANNEL, in _scsih_probe_raid()
10381 raid_device->id, 0); in _scsih_probe_raid()
10392 spin_lock_irqsave(&ioc->sas_device_lock, flags); in get_next_sas_device()
10393 if (!list_empty(&ioc->sas_device_init_list)) { in get_next_sas_device()
10394 sas_device = list_first_entry(&ioc->sas_device_init_list, in get_next_sas_device()
10398 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in get_next_sas_device()
10408 spin_lock_irqsave(&ioc->sas_device_lock, flags); in sas_device_make_active()
10418 if (!list_empty(&sas_device->list)) { in sas_device_make_active()
10419 list_del_init(&sas_device->list); in sas_device_make_active()
10424 list_add_tail(&sas_device->list, &ioc->sas_device_list); in sas_device_make_active()
10426 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in sas_device_make_active()
10430 * _scsih_probe_sas - reporting sas devices to sas transport
10431 * @ioc: per adapter object
10440 if (ioc->hide_drives) in _scsih_probe_sas()
10444 if (!mpt3sas_transport_port_add(ioc, sas_device->handle, in _scsih_probe_sas()
10445 sas_device->sas_address_parent)) { in _scsih_probe_sas()
10449 } else if (!sas_device->starget) { in _scsih_probe_sas()
10453 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_sas()
10456 if (!ioc->is_driver_loading) { in _scsih_probe_sas()
10458 sas_device->sas_address, in _scsih_probe_sas()
10459 sas_device->sas_address_parent); in _scsih_probe_sas()
10471 * get_next_pcie_device - Get the next pcie device
10472 * @ioc: per adapter object
10474 * Get the next pcie device from pcie_device_init_list list.
10476 * Return: pcie device structure if pcie_device_init_list list is not empty
10484 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
10485 if (!list_empty(&ioc->pcie_device_init_list)) { in get_next_pcie_device()
10486 pcie_device = list_first_entry(&ioc->pcie_device_init_list, in get_next_pcie_device()
10490 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in get_next_pcie_device()
10496 * pcie_device_make_active - Add pcie device to pcie_device_list list
10497 * @ioc: per adapter object
10498 * @pcie_device: pcie device object
10500 * Add the pcie device which has registered with SCSI Transport Later to
10508 spin_lock_irqsave(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
10510 if (!list_empty(&pcie_device->list)) { in pcie_device_make_active()
10511 list_del_init(&pcie_device->list); in pcie_device_make_active()
10515 list_add_tail(&pcie_device->list, &ioc->pcie_device_list); in pcie_device_make_active()
10517 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); in pcie_device_make_active()
10521 * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
10522 * @ioc: per adapter object
10532 /* PCIe Device List */ in _scsih_probe_pcie()
10534 if (pcie_device->starget) { in _scsih_probe_pcie()
10538 if (pcie_device->access_status == in _scsih_probe_pcie()
10544 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, in _scsih_probe_pcie()
10545 pcie_device->id, 0); in _scsih_probe_pcie()
10550 } else if (!pcie_device->starget) { in _scsih_probe_pcie()
10554 * oops in scsi_sysfs_add_sdev()->add_device()-> in _scsih_probe_pcie()
10557 if (!ioc->is_driver_loading) { in _scsih_probe_pcie()
10558 /* TODO-- Need to find out whether this condition will in _scsih_probe_pcie()
10572 * _scsih_probe_devices - probing for devices
10573 * @ioc: per adapter object
10582 if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR)) in _scsih_probe_devices()
10587 if (ioc->ir_firmware) { in _scsih_probe_devices()
10589 le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) & in _scsih_probe_devices()
10606 * scsih_scan_start - scsi lld callback for .scan_start
10618 if (diag_buffer_enable != -1 && diag_buffer_enable != 0) in scsih_scan_start()
10620 else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) in scsih_scan_start()
10626 ioc->start_scan = 1; in scsih_scan_start()
10634 * scsih_scan_finished - scsi lld callback for .scan_finished
10648 ioc->is_driver_loading = 0; in scsih_scan_finished()
10649 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10654 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
10656 ioc->is_driver_loading = 0; in scsih_scan_finished()
10660 if (ioc->start_scan) in scsih_scan_finished()
10663 if (ioc->start_scan_failed) { in scsih_scan_finished()
10665 ioc->start_scan_failed); in scsih_scan_finished()
10666 ioc->is_driver_loading = 0; in scsih_scan_finished()
10667 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10668 ioc->remove_host = 1; in scsih_scan_finished()
10673 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in scsih_scan_finished()
10675 if (ioc->wait_for_discovery_to_complete) { in scsih_scan_finished()
10676 ioc->wait_for_discovery_to_complete = 0; in scsih_scan_finished()
10680 ioc->is_driver_loading = 0; in scsih_scan_finished()
10704 .this_id = -1,
10742 .this_id = -1,
10762 * _scsih_determine_hba_mpi_version - determine in which MPI version class
10763 * this device belongs to.
10764 * @pdev: PCI device struct
10774 switch (pdev->device) { in _scsih_determine_hba_mpi_version()
10834 * _scsih_probe - attach and add scsi host
10835 * @pdev: PCI device struct
10836 * @id: pci device id
10848 /* Determine in which MPI version class this pci device belongs */ in _scsih_probe()
10851 return -ENODEV; in _scsih_probe()
10854 * for other generation HBA's return with -ENODEV in _scsih_probe()
10857 return -ENODEV; in _scsih_probe()
10860 * for other generation HBA's return with -ENODEV in _scsih_probe()
10864 return -ENODEV; in _scsih_probe()
10874 return -ENODEV; in _scsih_probe()
10877 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
10878 ioc->id = mpt2_ids++; in _scsih_probe()
10879 sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME); in _scsih_probe()
10880 switch (pdev->device) { in _scsih_probe()
10882 ioc->is_warpdrive = 1; in _scsih_probe()
10883 ioc->hide_ir_msg = 1; in _scsih_probe()
10887 ioc->is_mcpu_endpoint = 1; in _scsih_probe()
10890 ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS; in _scsih_probe()
10900 return -ENODEV; in _scsih_probe()
10903 ioc->hba_mpi_version_belonged = hba_mpi_version; in _scsih_probe()
10904 ioc->id = mpt3_ids++; in _scsih_probe()
10905 sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME); in _scsih_probe()
10906 switch (pdev->device) { in _scsih_probe()
10915 ioc->is_gen35_ioc = 1; in _scsih_probe()
10919 dev_err(&pdev->dev, in _scsih_probe()
10921 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
10922 pdev->subsystem_device); in _scsih_probe()
10926 dev_err(&pdev->dev, in _scsih_probe()
10928 pdev->device, pdev->subsystem_vendor, in _scsih_probe()
10929 pdev->subsystem_device); in _scsih_probe()
10933 dev_info(&pdev->dev, in _scsih_probe()
10938 ioc->is_aero_ioc = ioc->is_gen35_ioc = 1; in _scsih_probe()
10941 ioc->is_gen35_ioc = ioc->is_aero_ioc = 0; in _scsih_probe()
10943 if ((ioc->hba_mpi_version_belonged == MPI25_VERSION && in _scsih_probe()
10944 pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) || in _scsih_probe()
10945 (ioc->hba_mpi_version_belonged == MPI26_VERSION)) { in _scsih_probe()
10946 ioc->combined_reply_queue = 1; in _scsih_probe()
10947 if (ioc->is_gen35_ioc) in _scsih_probe()
10948 ioc->combined_reply_index_count = in _scsih_probe()
10951 ioc->combined_reply_index_count = in _scsih_probe()
10956 return -ENODEV; in _scsih_probe()
10959 INIT_LIST_HEAD(&ioc->list); in _scsih_probe()
10961 list_add_tail(&ioc->list, &mpt3sas_ioc_list); in _scsih_probe()
10963 ioc->shost = shost; in _scsih_probe()
10964 ioc->pdev = pdev; in _scsih_probe()
10965 ioc->scsi_io_cb_idx = scsi_io_cb_idx; in _scsih_probe()
10966 ioc->tm_cb_idx = tm_cb_idx; in _scsih_probe()
10967 ioc->ctl_cb_idx = ctl_cb_idx; in _scsih_probe()
10968 ioc->base_cb_idx = base_cb_idx; in _scsih_probe()
10969 ioc->port_enable_cb_idx = port_enable_cb_idx; in _scsih_probe()
10970 ioc->transport_cb_idx = transport_cb_idx; in _scsih_probe()
10971 ioc->scsih_cb_idx = scsih_cb_idx; in _scsih_probe()
10972 ioc->config_cb_idx = config_cb_idx; in _scsih_probe()
10973 ioc->tm_tr_cb_idx = tm_tr_cb_idx; in _scsih_probe()
10974 ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx; in _scsih_probe()
10975 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; in _scsih_probe()
10976 ioc->logging_level = logging_level; in _scsih_probe()
10977 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; in _scsih_probe()
10979 ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT; in _scsih_probe()
10983 ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; in _scsih_probe()
10985 ioc->enable_sdev_max_qd = enable_sdev_max_qd; in _scsih_probe()
10988 mutex_init(&ioc->reset_in_progress_mutex); in _scsih_probe()
10990 mutex_init(&ioc->pci_access_mutex); in _scsih_probe()
10991 spin_lock_init(&ioc->ioc_reset_in_progress_lock); in _scsih_probe()
10992 spin_lock_init(&ioc->scsi_lookup_lock); in _scsih_probe()
10993 spin_lock_init(&ioc->sas_device_lock); in _scsih_probe()
10994 spin_lock_init(&ioc->sas_node_lock); in _scsih_probe()
10995 spin_lock_init(&ioc->fw_event_lock); in _scsih_probe()
10996 spin_lock_init(&ioc->raid_device_lock); in _scsih_probe()
10997 spin_lock_init(&ioc->pcie_device_lock); in _scsih_probe()
10998 spin_lock_init(&ioc->diag_trigger_lock); in _scsih_probe()
11000 INIT_LIST_HEAD(&ioc->sas_device_list); in _scsih_probe()
11001 INIT_LIST_HEAD(&ioc->sas_device_init_list); in _scsih_probe()
11002 INIT_LIST_HEAD(&ioc->sas_expander_list); in _scsih_probe()
11003 INIT_LIST_HEAD(&ioc->enclosure_list); in _scsih_probe()
11004 INIT_LIST_HEAD(&ioc->pcie_device_list); in _scsih_probe()
11005 INIT_LIST_HEAD(&ioc->pcie_device_init_list); in _scsih_probe()
11006 INIT_LIST_HEAD(&ioc->fw_event_list); in _scsih_probe()
11007 INIT_LIST_HEAD(&ioc->raid_device_list); in _scsih_probe()
11008 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); in _scsih_probe()
11009 INIT_LIST_HEAD(&ioc->delayed_tr_list); in _scsih_probe()
11010 INIT_LIST_HEAD(&ioc->delayed_sc_list); in _scsih_probe()
11011 INIT_LIST_HEAD(&ioc->delayed_event_ack_list); in _scsih_probe()
11012 INIT_LIST_HEAD(&ioc->delayed_tr_volume_list); in _scsih_probe()
11013 INIT_LIST_HEAD(&ioc->reply_queue_list); in _scsih_probe()
11015 sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id); in _scsih_probe()
11018 shost->max_cmd_len = 32; in _scsih_probe()
11019 shost->max_lun = max_lun; in _scsih_probe()
11020 shost->transportt = mpt3sas_transport_template; in _scsih_probe()
11021 shost->unique_id = ioc->id; in _scsih_probe()
11023 if (ioc->is_mcpu_endpoint) { in _scsih_probe()
11025 shost->max_sectors = 128; in _scsih_probe()
11027 shost->max_sectors); in _scsih_probe()
11031 shost->max_sectors = 64; in _scsih_probe()
11035 shost->max_sectors = 32767; in _scsih_probe()
11039 shost->max_sectors = max_sectors & 0xFFFE; in _scsih_probe()
11041 shost->max_sectors); in _scsih_probe()
11056 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), in _scsih_probe()
11057 "fw_event_%s%d", ioc->driver_name, ioc->id); in _scsih_probe()
11058 ioc->firmware_event_thread = alloc_ordered_workqueue( in _scsih_probe()
11059 ioc->firmware_event_name, 0); in _scsih_probe()
11060 if (!ioc->firmware_event_thread) { in _scsih_probe()
11063 rv = -ENODEV; in _scsih_probe()
11067 ioc->is_driver_loading = 1; in _scsih_probe()
11071 rv = -ENODEV; in _scsih_probe()
11075 if (ioc->is_warpdrive) { in _scsih_probe()
11076 if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS) in _scsih_probe()
11077 ioc->hide_drives = 0; in _scsih_probe()
11078 else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS) in _scsih_probe()
11079 ioc->hide_drives = 1; in _scsih_probe()
11082 ioc->hide_drives = 1; in _scsih_probe()
11084 ioc->hide_drives = 0; in _scsih_probe()
11087 ioc->hide_drives = 0; in _scsih_probe()
11089 rv = scsi_add_host(shost, &pdev->dev); in _scsih_probe()
11102 destroy_workqueue(ioc->firmware_event_thread); in _scsih_probe()
11105 list_del(&ioc->list); in _scsih_probe()
11113 * scsih_suspend - power management suspend main entry point
11114 * @pdev: PCI device struct
11146 * scsih_resume - power management resume main entry point
11147 * @pdev: PCI device struct
11156 pci_power_t device_state = pdev->current_state; in scsih_resume()
11169 ioc->pdev = pdev; in scsih_resume()
11182 * scsih_pci_error_detected - Called when a PCI error is detected.
11183 * @pdev: PCI device struct
11206 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
11207 scsi_block_requests(ioc->shost); in scsih_pci_error_detected()
11212 /* Permanent error, prepare for device removal */ in scsih_pci_error_detected()
11213 ioc->pci_error_recovery = 1; in scsih_pci_error_detected()
11222 * scsih_pci_slot_reset - Called when PCI slot has been reset.
11223 * @pdev: PCI device struct
11241 ioc->pci_error_recovery = 0; in scsih_pci_slot_reset()
11242 ioc->pdev = pdev; in scsih_pci_slot_reset()
11261 * scsih_pci_resume() - resume normal ops after PCI reset
11262 * @pdev: pointer to PCI device
11280 scsi_unblock_requests(ioc->shost); in scsih_pci_resume()
11284 * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
11285 * @pdev: pointer to PCI device
11298 /* TODO - dump whatever for debugging purposes */ in scsih_pci_mmio_enabled()
11301 * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still in scsih_pci_mmio_enabled()
11308 * scsih__ncq_prio_supp - Check for NCQ command priority support
11309 * @sdev: scsi device struct
11333 * The pci device ids are defined in mpi/mpi2_cnfg.h.
11495 * scsih_init - main entry point for this driver.
11546 * scsih_exit - exit point for this driver (when it is a module).
11577 * _mpt3sas_init - main entry point for this driver.
11592 return -ENODEV; in _mpt3sas_init()
11602 return -ENODEV; in _mpt3sas_init()
11614 return -ENODEV; in _mpt3sas_init()
11634 * _mpt3sas_exit - exit point for this driver (when it is a module).