^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Scsi Host Layer for MPT (Message Passing Technology) based controllers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This code is based on drivers/scsi/mpt3sas/mpt3sas_scsih.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2012-2014 LSI Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2013-2014 Avago Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * (mailto: MPT-FusionLinux.pdl@avagotech.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * modify it under the terms of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * as published by the Free Software Foundation; either version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * solely responsible for determining the appropriateness of using and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * distributing the Program and assumes all risks associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * exercise of rights under this Agreement, including but not limited to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * the risks and costs of program errors, damage to or loss of data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * programs or equipment, and unavailability or interruption of operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * DISCLAIMER OF LIABILITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <linux/aer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <linux/raid_class.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include "mpt3sas_base.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define RAID_CHANNEL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define PCIE_CHANNEL 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* forward proto's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static void _scsih_expander_node_remove(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct _sas_node *sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static void _firmware_event_work(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static void _scsih_remove_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct _sas_device *sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static int _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u8 retry_count, u8 is_pd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static int _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static void _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct _pcie_device *pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static u8 _scsih_check_for_pending_tm(struct MPT3SAS_ADAPTER *ioc, u16 smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* global parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) LIST_HEAD(mpt3sas_ioc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* global ioc lock for list operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) DEFINE_SPINLOCK(gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) MODULE_AUTHOR(MPT3SAS_AUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) MODULE_VERSION(MPT3SAS_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) MODULE_ALIAS("mpt2sas");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* local parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static u8 scsi_io_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static u8 tm_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static u8 ctl_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static u8 base_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static u8 port_enable_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static u8 transport_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static u8 scsih_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static u8 config_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int mpt2_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static int mpt3_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static u8 tm_tr_cb_idx = -1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static u8 tm_tr_volume_cb_idx = -1 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static u8 tm_sas_control_cb_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* command line options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static u32 logging_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) MODULE_PARM_DESC(logging_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) " bits for enabling additional logging info (default=0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static ushort max_sectors = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) module_param(max_sectors, ushort, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) MODULE_PARM_DESC(max_sectors, "max sectors, range 64 to 32767 default=32767");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static int missing_delay[2] = {-1, -1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) module_param_array(missing_delay, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define MPT3SAS_MAX_LUN (16895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static u64 max_lun = MPT3SAS_MAX_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) module_param(max_lun, ullong, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) MODULE_PARM_DESC(max_lun, " max lun, default=16895 ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static ushort hbas_to_enumerate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) module_param(hbas_to_enumerate, ushort, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) MODULE_PARM_DESC(hbas_to_enumerate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) " 0 - enumerates both SAS 2.0 & SAS 3.0 generation HBAs\n \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 1 - enumerates only SAS 2.0 generation HBAs\n \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 2 - enumerates only SAS 3.0 generation HBAs (default=0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* diag_buffer_enable is bitwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * bit 0 set = TRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * bit 1 set = SNAPSHOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * bit 2 set = EXTENDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * Either bit can be set, or both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int diag_buffer_enable = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) module_param(diag_buffer_enable, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) MODULE_PARM_DESC(diag_buffer_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) " post diag buffers (TRACE=1/SNAPSHOT=2/EXTENDED=4/default=0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static int disable_discovery = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) module_param(disable_discovery, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) MODULE_PARM_DESC(disable_discovery, " disable discovery ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /* permit overriding the host protection capabilities mask (EEDP/T10 PI) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static int prot_mask = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) module_param(prot_mask, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) MODULE_PARM_DESC(prot_mask, " host protection capabilities mask, def=7 ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static bool enable_sdev_max_qd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) module_param(enable_sdev_max_qd, bool, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) MODULE_PARM_DESC(enable_sdev_max_qd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) "Enable sdev max qd as can_queue, def=disabled(0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* raid transport support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static struct raid_template *mpt3sas_raid_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static struct raid_template *mpt2sas_raid_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * struct sense_info - common structure for obtaining sense keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @skey: sense key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @asc: additional sense code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @ascq: additional sense code qualifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct sense_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) u8 skey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) u8 asc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) u8 ascq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #define MPT3SAS_PROCESS_TRIGGER_DIAG (0xFFFB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define MPT3SAS_TURN_ON_PFA_LED (0xFFFC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #define MPT3SAS_PORT_ENABLE_COMPLETE (0xFFFD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define MPT3SAS_ABRT_TASK_SET (0xFFFE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define MPT3SAS_REMOVE_UNRESPONDING_DEVICES (0xFFFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * struct fw_event_work - firmware event struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * @list: link list framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * @work: work object (ioc->fault_reset_work_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * @device_handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * @VF_ID: virtual function id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * @VP_ID: virtual port id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * @ignore: flag meaning this event has been marked to ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @event: firmware event MPI2_EVENT_XXX defined in mpi2_ioc.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * @refcount: kref for this event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * @event_data: reply event data payload follows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * This object stored on ioc->fw_event_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct fw_event_work {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) u16 device_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) u8 VF_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) u8 VP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) u8 ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) u16 event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) char event_data[] __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static void fw_event_work_free(struct kref *r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) kfree(container_of(r, struct fw_event_work, refcount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static void fw_event_work_get(struct fw_event_work *fw_work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) kref_get(&fw_work->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static void fw_event_work_put(struct fw_event_work *fw_work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) kref_put(&fw_work->refcount, fw_event_work_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static struct fw_event_work *alloc_fw_event_work(int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) fw_event = kzalloc(sizeof(*fw_event) + len, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (!fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) kref_init(&fw_event->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * struct _scsi_io_transfer - scsi io transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * @handle: sas device handle (assigned by firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * @is_raid: flag set for hidden raid components
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * @dir: DMA_TO_DEVICE, DMA_FROM_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * @data_length: data transfer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * @data_dma: dma pointer to data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * @sense: sense data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * @lun: lun number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * @cdb_length: cdb length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * @cdb: cdb contents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * @timeout: timeout for this command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * @VF_ID: virtual function id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * @VP_ID: virtual port id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * @valid_reply: flag set for reply message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * @sense_length: sense length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * @ioc_status: ioc status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * @scsi_state: scsi state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @scsi_status: scsi staus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * @log_info: log information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * @transfer_length: data length transfer when there is a reply message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * Used for sending internal scsi commands to devices within this module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * Refer to _scsi_send_scsi_io().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct _scsi_io_transfer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) u8 is_raid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) enum dma_data_direction dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) u32 data_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) dma_addr_t data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) u8 sense[SCSI_SENSE_BUFFERSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) u32 lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) u8 cdb_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) u8 cdb[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) u8 timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) u8 VF_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) u8 VP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) u8 valid_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) /* the following bits are only valid when 'valid_reply = 1' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) u32 sense_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) u8 scsi_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) u8 scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u32 log_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u32 transfer_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * _scsih_set_debug_level - global setting of ioc->logging_level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * @val: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * @kp: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * Note: The logging levels are defined in mpt3sas_debug.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) _scsih_set_debug_level(const char *val, const struct kernel_param *kp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) int ret = param_set_int(val, kp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) pr_info("setting logging_level(0x%08x)\n", logging_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) list_for_each_entry(ioc, &mpt3sas_ioc_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ioc->logging_level = logging_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) module_param_call(logging_level, _scsih_set_debug_level, param_get_int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) &logging_level, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * _scsih_srch_boot_sas_address - search based on sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * @boot_device: boot device object from bios page 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * Return: 1 when there's a match, 0 means no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) _scsih_srch_boot_sas_address(u64 sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) Mpi2BootDeviceSasWwid_t *boot_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * _scsih_srch_boot_device_name - search based on device name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * @device_name: device name specified in INDENTIFY fram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * @boot_device: boot device object from bios page 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * Return: 1 when there's a match, 0 means no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) _scsih_srch_boot_device_name(u64 device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) Mpi2BootDeviceDeviceName_t *boot_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * _scsih_srch_boot_encl_slot - search based on enclosure_logical_id/slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * @enclosure_logical_id: enclosure logical id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * @slot_number: slot number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * @boot_device: boot device object from bios page 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * Return: 1 when there's a match, 0 means no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) _scsih_srch_boot_encl_slot(u64 enclosure_logical_id, u16 slot_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) Mpi2BootDeviceEnclosureSlot_t *boot_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return (enclosure_logical_id == le64_to_cpu(boot_device->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) EnclosureLogicalID) && slot_number == le16_to_cpu(boot_device->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) SlotNumber)) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * _scsih_is_boot_device - search for matching boot device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * @device_name: device name specified in INDENTIFY fram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * @enclosure_logical_id: enclosure logical id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * @slot: slot number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) * @form: specifies boot device form
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) * @boot_device: boot device object from bios page 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * Return: 1 when there's a match, 0 means no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) _scsih_is_boot_device(u64 sas_address, u64 device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) u64 enclosure_logical_id, u16 slot, u8 form,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) Mpi2BiosPage2BootDevice_t *boot_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) switch (form) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) case MPI2_BIOSPAGE2_FORM_SAS_WWID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (!sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) rc = _scsih_srch_boot_sas_address(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) sas_address, &boot_device->SasWwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) case MPI2_BIOSPAGE2_FORM_ENCLOSURE_SLOT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (!enclosure_logical_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) rc = _scsih_srch_boot_encl_slot(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) slot, &boot_device->EnclosureSlot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) case MPI2_BIOSPAGE2_FORM_DEVICE_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (!device_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) rc = _scsih_srch_boot_device_name(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) device_name, &boot_device->DeviceName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) case MPI2_BIOSPAGE2_FORM_NO_DEVICE_SPECIFIED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * _scsih_get_sas_address - set the sas_address for given device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * @ioc: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * Return: 0 success, non-zero when failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) _scsih_get_sas_address(struct MPT3SAS_ADAPTER *ioc, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) u64 *sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) *sas_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /* For HBA, vSES doesn't return HBA SAS address. Instead return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * vSES's sas address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if ((handle <= ioc->sas_hba.num_phys) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) (!(le32_to_cpu(sas_device_pg0.DeviceInfo) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) MPI2_SAS_DEVICE_INFO_SEP)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) *sas_address = ioc->sas_hba.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) *sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /* we hit this because the given parent handle doesn't exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) /* else error case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) ioc_err(ioc, "handle(0x%04x), ioc_status(0x%04x), failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) handle, ioc_status, __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * _scsih_determine_boot_device - determine boot device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * @device: sas_device or pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * @channel: SAS or PCIe channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * Determines whether this device should be first reported device to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * to scsi-ml or sas transport, this purpose is for persistent boot device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * There are primary, alternate, and current entries in bios page 2. The order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * priority is primary, alternate, then current. This routine saves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * the corresponding device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * The saved data to be used later in _scsih_probe_boot_devices().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) _scsih_determine_boot_device(struct MPT3SAS_ADAPTER *ioc, void *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) u32 channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) u64 device_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) u64 enclosure_logical_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) u16 slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /* only process this function when driver loads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (!ioc->is_driver_loading)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) /* no Bios, return immediately */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (!ioc->bios_pg3.BiosVersion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (channel == RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) raid_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) sas_address = raid_device->wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) device_name = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) enclosure_logical_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) slot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) } else if (channel == PCIE_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) pcie_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) sas_address = pcie_device->wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) device_name = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) enclosure_logical_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) slot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) sas_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) sas_address = sas_device->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) device_name = sas_device->device_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) enclosure_logical_id = sas_device->enclosure_logical_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) slot = sas_device->slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) if (!ioc->req_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) if (_scsih_is_boot_device(sas_address, device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) enclosure_logical_id, slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) (ioc->bios_pg2.ReqBootDeviceForm &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) MPI2_BIOSPAGE2_FORM_MASK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) &ioc->bios_pg2.RequestedBootDevice)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) dinitprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) ioc_info(ioc, "%s: req_boot_device(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) __func__, (u64)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) ioc->req_boot_device.device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) ioc->req_boot_device.channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (!ioc->req_alt_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) if (_scsih_is_boot_device(sas_address, device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) enclosure_logical_id, slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) (ioc->bios_pg2.ReqAltBootDeviceForm &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) MPI2_BIOSPAGE2_FORM_MASK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) &ioc->bios_pg2.RequestedAltBootDevice)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) dinitprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) ioc_info(ioc, "%s: req_alt_boot_device(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) __func__, (u64)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) ioc->req_alt_boot_device.device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) ioc->req_alt_boot_device.channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) if (!ioc->current_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (_scsih_is_boot_device(sas_address, device_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) enclosure_logical_id, slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) (ioc->bios_pg2.CurrentBootDeviceForm &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) MPI2_BIOSPAGE2_FORM_MASK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) &ioc->bios_pg2.CurrentBootDevice)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) dinitprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) ioc_info(ioc, "%s: current_boot_device(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) __func__, (u64)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) ioc->current_boot_device.device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) ioc->current_boot_device.channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) static struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) __mpt3sas_get_sdev_from_target(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) struct MPT3SAS_TARGET *tgt_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct _sas_device *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) assert_spin_locked(&ioc->sas_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) ret = tgt_priv->sas_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) sas_device_get(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) mpt3sas_get_sdev_from_target(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct MPT3SAS_TARGET *tgt_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) struct _sas_device *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) ret = __mpt3sas_get_sdev_from_target(ioc, tgt_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) __mpt3sas_get_pdev_from_target(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) struct MPT3SAS_TARGET *tgt_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct _pcie_device *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) assert_spin_locked(&ioc->pcie_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) ret = tgt_priv->pcie_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) pcie_device_get(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * mpt3sas_get_pdev_from_target - pcie device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) * @tgt_priv: starget private object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * Context: This function will acquire ioc->pcie_device_lock and will release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * before returning the pcie_device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * This searches for pcie_device from target, then return pcie_device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) mpt3sas_get_pdev_from_target(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) struct MPT3SAS_TARGET *tgt_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) struct _pcie_device *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) ret = __mpt3sas_get_pdev_from_target(ioc, tgt_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) __mpt3sas_get_sdev_by_addr(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) assert_spin_locked(&ioc->sas_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) list_for_each_entry(sas_device, &ioc->sas_device_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) if (sas_device->sas_address == sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) list_for_each_entry(sas_device, &ioc->sas_device_init_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) if (sas_device->sas_address == sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) found_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) * mpt3sas_get_sdev_by_addr - sas device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * Context: Calling function should acquire ioc->sas_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) * This searches for sas_device based on sas_address, then return sas_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) mpt3sas_get_sdev_by_addr(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) return sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) static struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) __mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) assert_spin_locked(&ioc->sas_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) list_for_each_entry(sas_device, &ioc->sas_device_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) if (sas_device->handle == handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) list_for_each_entry(sas_device, &ioc->sas_device_init_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) if (sas_device->handle == handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) found_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) return sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) * mpt3sas_get_sdev_by_handle - sas device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) * @handle: sas device handle (assigned by firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * Context: Calling function should acquire ioc->sas_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) * This searches for sas_device based on sas_address, then return sas_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) struct _sas_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) return sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) * _scsih_display_enclosure_chassis_info - display device location info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) * @sas_device: per sas device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) * @starget: scsi target struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) _scsih_display_enclosure_chassis_info(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) struct _sas_device *sas_device, struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) if (sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) "enclosure logical id (0x%016llx), slot(%d) \n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) if (sas_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) "enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) sas_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) sas_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if (sas_device->is_chassis_slot_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) sdev_printk(KERN_INFO, sdev, "chassis slot(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) sas_device->chassis_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) } else if (starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) "enclosure logical id(0x%016llx), slot(%d) \n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) if (sas_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) "enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) sas_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) sas_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) if (sas_device->is_chassis_slot_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) "chassis slot(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) sas_device->chassis_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) ioc_info(ioc, "enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) (u64)sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) if (sas_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) ioc_info(ioc, "enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) sas_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) sas_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) if (sas_device->is_chassis_slot_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) ioc_info(ioc, "chassis slot(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) sas_device->chassis_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) * _scsih_sas_device_remove - remove sas_device from list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) * @sas_device: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) * Context: This function will acquire ioc->sas_device_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) * If sas_device is on the list, remove it and decrement its reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) _scsih_sas_device_remove(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) ioc_info(ioc, "removing handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) sas_device->handle, (u64)sas_device->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) _scsih_display_enclosure_chassis_info(ioc, sas_device, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) * The lock serializes access to the list, but we still need to verify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * that nobody removed the entry while we were waiting on the lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) if (!list_empty(&sas_device->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) list_del_init(&sas_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) * _scsih_device_remove_by_handle - removing device object by handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) _scsih_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) list_del_init(&sas_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) _scsih_remove_device(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) * mpt3sas_device_remove_by_sas_address - removing device object by sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) * @sas_address: device sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) sas_device = __mpt3sas_get_sdev_by_addr(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) list_del_init(&sas_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) _scsih_remove_device(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * _scsih_sas_device_add - insert sas_device to the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) * @sas_device: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) * Context: This function will acquire ioc->sas_device_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * Adding new object to the ioc->sas_device_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) _scsih_sas_device_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) ioc_info(ioc, "%s: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) __func__, sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) (u64)sas_device->sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) dewtprintk(ioc, _scsih_display_enclosure_chassis_info(ioc, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) NULL, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) list_add_tail(&sas_device->list, &ioc->sas_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) if (ioc->hide_drives) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) clear_bit(sas_device->handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) if (!mpt3sas_transport_port_add(ioc, sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) sas_device->sas_address_parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) } else if (!sas_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) * When asyn scanning is enabled, its not possible to remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) * devices while scanning is turned on due to an oops in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) if (!ioc->is_driver_loading) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) mpt3sas_transport_port_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) sas_device->sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) clear_bit(sas_device->handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) * _scsih_sas_device_init_add - insert sas_device to the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) * @sas_device: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * Context: This function will acquire ioc->sas_device_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) * Adding new object at driver load time to the ioc->sas_device_init_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) _scsih_sas_device_init_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) ioc_info(ioc, "%s: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) __func__, sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) (u64)sas_device->sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) dewtprintk(ioc, _scsih_display_enclosure_chassis_info(ioc, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) NULL, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) list_add_tail(&sas_device->list, &ioc->sas_device_init_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) _scsih_determine_boot_device(ioc, sas_device, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) __mpt3sas_get_pdev_by_wwid(struct MPT3SAS_ADAPTER *ioc, u64 wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) assert_spin_locked(&ioc->pcie_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) if (pcie_device->wwid == wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) if (pcie_device->wwid == wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) found_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) * mpt3sas_get_pdev_by_wwid - pcie device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * @wwid: wwid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) * Context: This function will acquire ioc->pcie_device_lock and will release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) * before returning the pcie_device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) * This searches for pcie_device based on wwid, then return pcie_device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) mpt3sas_get_pdev_by_wwid(struct MPT3SAS_ADAPTER *ioc, u64 wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) pcie_device = __mpt3sas_get_pdev_by_wwid(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) __mpt3sas_get_pdev_by_idchannel(struct MPT3SAS_ADAPTER *ioc, int id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) assert_spin_locked(&ioc->pcie_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) if (pcie_device->id == id && pcie_device->channel == channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) if (pcie_device->id == id && pcie_device->channel == channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) found_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) static struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) __mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) assert_spin_locked(&ioc->pcie_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (pcie_device->handle == handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) list_for_each_entry(pcie_device, &ioc->pcie_device_init_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) if (pcie_device->handle == handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) goto found_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) found_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) * mpt3sas_get_pdev_by_handle - pcie device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) * @handle: Firmware device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) * Context: This function will acquire ioc->pcie_device_lock and will release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) * before returning the pcie_device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) * This searches for pcie_device based on handle, then return pcie_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) struct _pcie_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) * _scsih_set_nvme_max_shutdown_latency - Update max_shutdown_latency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) * Context: This function will acquire ioc->pcie_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) * Update ioc->max_shutdown_latency to that NVMe drives RTD3 Entry Latency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * which has reported maximum among all available NVMe drives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) * Minimum max_shutdown_latency will be six seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) _scsih_set_nvme_max_shutdown_latency(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) u16 shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) if (pcie_device->shutdown_latency) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) if (shutdown_latency < pcie_device->shutdown_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) shutdown_latency =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) pcie_device->shutdown_latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) ioc->max_shutdown_latency = shutdown_latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) * _scsih_pcie_device_remove - remove pcie_device from list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) * @pcie_device: the pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) * Context: This function will acquire ioc->pcie_device_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) * If pcie_device is on the list, remove it and decrement its reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) _scsih_pcie_device_remove(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) struct _pcie_device *pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) int was_on_pcie_device_list = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) u8 update_latency = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) if (!pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) pcie_device->handle, (u64)pcie_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) ioc_info(ioc, "removing enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) ioc_info(ioc, "removing enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) pcie_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) if (!list_empty(&pcie_device->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) list_del_init(&pcie_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) was_on_pcie_device_list = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) if (pcie_device->shutdown_latency == ioc->max_shutdown_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) update_latency = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) if (was_on_pcie_device_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) kfree(pcie_device->serial_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) * This device's RTD3 Entry Latency matches IOC's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) * max_shutdown_latency. Recalculate IOC's max_shutdown_latency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) * from the available drives as current drive is getting removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) if (update_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) _scsih_set_nvme_max_shutdown_latency(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) _scsih_pcie_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) int was_on_pcie_device_list = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) u8 update_latency = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) if (!list_empty(&pcie_device->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) list_del_init(&pcie_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) was_on_pcie_device_list = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) if (pcie_device->shutdown_latency == ioc->max_shutdown_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) update_latency = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) if (was_on_pcie_device_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) _scsih_pcie_device_remove_from_sml(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) * This device's RTD3 Entry Latency matches IOC's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) * max_shutdown_latency. Recalculate IOC's max_shutdown_latency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) * from the available drives as current drive is getting removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) if (update_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) _scsih_set_nvme_max_shutdown_latency(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) * _scsih_pcie_device_add - add pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) * @pcie_device: pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) * This is added to the pcie_device_list link list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) _scsih_pcie_device_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) struct _pcie_device *pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) ioc_info(ioc, "%s: handle (0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) pcie_device->handle, (u64)pcie_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) ioc_info(ioc, "%s: enclosure logical id(0x%016llx), slot( %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) pcie_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) ioc_info(ioc, "%s: enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) __func__, pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) pcie_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) list_add_tail(&pcie_device->list, &ioc->pcie_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) if (pcie_device->access_status ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) clear_bit(pcie_device->handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) _scsih_pcie_device_remove(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) } else if (!pcie_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) if (!ioc->is_driver_loading) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) /*TODO-- Need to find out whether this condition will occur or not*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) clear_bit(pcie_device->handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) clear_bit(pcie_device->handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) * _scsih_pcie_device_init_add - insert pcie_device to the init list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) * @pcie_device: the pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) * Context: This function will acquire ioc->pcie_device_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) * Adding new object at driver load time to the ioc->pcie_device_init_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) _scsih_pcie_device_init_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) struct _pcie_device *pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) ioc_info(ioc, "%s: handle (0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) pcie_device->handle, (u64)pcie_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) ioc_info(ioc, "%s: enclosure logical id(0x%016llx), slot( %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) pcie_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) ioc_info(ioc, "%s: enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) __func__, pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) pcie_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) if (pcie_device->access_status !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) _scsih_determine_boot_device(ioc, pcie_device, PCIE_CHANNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) * _scsih_raid_device_find_by_id - raid device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) * @id: sas device target id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) * @channel: sas device channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) * Context: Calling function should acquire ioc->raid_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) * This searches for raid_device based on target id, then return raid_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) static struct _raid_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) _scsih_raid_device_find_by_id(struct MPT3SAS_ADAPTER *ioc, int id, int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) struct _raid_device *raid_device, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) list_for_each_entry(raid_device, &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) if (raid_device->id == id && raid_device->channel == channel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) r = raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) * mpt3sas_raid_device_find_by_handle - raid device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) * @handle: sas device handle (assigned by firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) * Context: Calling function should acquire ioc->raid_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) * This searches for raid_device based on handle, then return raid_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) struct _raid_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) struct _raid_device *raid_device, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) list_for_each_entry(raid_device, &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) if (raid_device->handle != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) r = raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) * _scsih_raid_device_find_by_wwid - raid device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) * @wwid: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) * Context: Calling function should acquire ioc->raid_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) * This searches for raid_device based on wwid, then return raid_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) * object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) static struct _raid_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) _scsih_raid_device_find_by_wwid(struct MPT3SAS_ADAPTER *ioc, u64 wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) struct _raid_device *raid_device, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) list_for_each_entry(raid_device, &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) if (raid_device->wwid != wwid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) r = raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) * _scsih_raid_device_add - add raid_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) * @raid_device: raid_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) * This is added to the raid_device_list link list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) _scsih_raid_device_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) struct _raid_device *raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) ioc_info(ioc, "%s: handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) raid_device->handle, (u64)raid_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) list_add_tail(&raid_device->list, &ioc->raid_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) * _scsih_raid_device_remove - delete raid_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) * @raid_device: raid_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) _scsih_raid_device_remove(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) struct _raid_device *raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) list_del(&raid_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) kfree(raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) * mpt3sas_scsih_expander_find_by_handle - expander device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) * @handle: expander handle (assigned by firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) * Context: Calling function should acquire ioc->sas_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) * This searches for expander device based on handle, then returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) * sas_node object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) struct _sas_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) mpt3sas_scsih_expander_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) struct _sas_node *sas_expander, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) if (sas_expander->handle != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) r = sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) * mpt3sas_scsih_enclosure_find_by_handle - exclosure device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) * @handle: enclosure handle (assigned by firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) * Context: Calling function should acquire ioc->sas_device_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) * This searches for enclosure device based on handle, then returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) * enclosure object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) static struct _enclosure_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) mpt3sas_scsih_enclosure_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) struct _enclosure_node *enclosure_dev, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) list_for_each_entry(enclosure_dev, &ioc->enclosure_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) if (le16_to_cpu(enclosure_dev->pg0.EnclosureHandle) != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) r = enclosure_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) * mpt3sas_scsih_expander_find_by_sas_address - expander device search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) * Context: Calling function should acquire ioc->sas_node_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) * This searches for expander device based on sas_address, then returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) * sas_node object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) struct _sas_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) mpt3sas_scsih_expander_find_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) struct _sas_node *sas_expander, *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) if (sas_expander->sas_address != sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) r = sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) * _scsih_expander_node_add - insert expander device to the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * @sas_expander: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * Context: This function will acquire ioc->sas_node_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) * Adding new object to the ioc->sas_expander_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) _scsih_expander_node_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) struct _sas_node *sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) list_add_tail(&sas_expander->list, &ioc->sas_expander_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) * _scsih_is_end_device - determines if device is an end device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) * @device_info: bitfield providing information about the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) * Context: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) * Return: 1 if end device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) _scsih_is_end_device(u32 device_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) if (device_info & MPI2_SAS_DEVICE_INFO_END_DEVICE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) ((device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) (device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) (device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) * _scsih_is_nvme_pciescsi_device - determines if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) * device is an pcie nvme/scsi device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) * @device_info: bitfield providing information about the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) * Context: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) * Returns 1 if device is pcie device type nvme/scsi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) _scsih_is_nvme_pciescsi_device(u32 device_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) if (((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) == MPI26_PCIE_DEVINFO_NVME) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) ((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) == MPI26_PCIE_DEVINFO_SCSI))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) * _scsih_scsi_lookup_find_by_target - search for matching channel:id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) * @id: target id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) * @channel: channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) * Context: This function will acquire ioc->scsi_lookup_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) * This will search for a matching channel:id in the scsi_lookup array,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) * returning 1 if found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) _scsih_scsi_lookup_find_by_target(struct MPT3SAS_ADAPTER *ioc, int id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) int smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) for (smid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) smid <= ioc->shost->can_queue; smid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) if (!scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) if (scmd->device->id == id &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) scmd->device->channel == channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) * _scsih_scsi_lookup_find_by_lun - search for matching channel:id:lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) * @id: target id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) * @lun: lun number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) * @channel: channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) * Context: This function will acquire ioc->scsi_lookup_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) * This will search for a matching channel:id:lun in the scsi_lookup array,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) * returning 1 if found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) _scsih_scsi_lookup_find_by_lun(struct MPT3SAS_ADAPTER *ioc, int id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) unsigned int lun, int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) int smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) for (smid = 1; smid <= ioc->shost->can_queue; smid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) if (!scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) if (scmd->device->id == id &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) scmd->device->channel == channel &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) scmd->device->lun == lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) * mpt3sas_scsih_scsi_lookup_get - returns scmd entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) * Return: the smid stored scmd pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) * Then will dereference the stored scmd pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) struct scsi_cmnd *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc, u16 smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) struct scsi_cmnd *scmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) struct scsiio_tracker *st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) Mpi25SCSIIORequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) if (smid > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) u32 unique_tag = smid - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) * If SCSI IO request is outstanding at driver level then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) * DevHandle filed must be non-zero. If DevHandle is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) * then it means that this smid is free at driver level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) * so return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) if (!mpi_request->DevHandle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) return scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) scmd = scsi_host_find_tag(ioc->shost, unique_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) if (scmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) if (st->cb_idx == 0xFF || st->smid == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) scmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) return scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) * scsih_change_queue_depth - setting device queue depth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) * @qdepth: requested queue depth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) * Return: queue depth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) struct Scsi_Host *shost = sdev->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) int max_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) max_depth = shost->can_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) * limit max device queue for SATA to 32 if enable_sdev_max_qd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) * is disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) if (ioc->enable_sdev_max_qd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) goto not_sata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) goto not_sata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) sas_target_priv_data = sas_device_priv_data->sas_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) if (!sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) goto not_sata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) goto not_sata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) sas_device = __mpt3sas_get_sdev_from_target(ioc, sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) max_depth = MPT3SAS_SATA_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) not_sata:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) if (!sdev->tagged_supported)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) max_depth = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) if (qdepth > max_depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) qdepth = max_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) scsi_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) "qdepth(%d), tagged(%d), scsi_level(%d), cmd_que(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) sdev->queue_depth, sdev->tagged_supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) sdev->scsi_level, ((sdev->inquiry[7] & 2) >> 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) return sdev->queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) * mpt3sas_scsih_change_queue_depth - setting device queue depth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) * @qdepth: requested queue depth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) * Returns nothing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) struct Scsi_Host *shost = sdev->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) if (ioc->enable_sdev_max_qd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) qdepth = shost->can_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) scsih_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) * scsih_target_alloc - target add routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) * @starget: scsi target struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) * Return: 0 if ok. Any other return is assumed to be an error and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) * the device is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) scsih_target_alloc(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) struct Scsi_Host *shost = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) sas_target_priv_data = kzalloc(sizeof(*sas_target_priv_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) if (!sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) starget->hostdata = sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) sas_target_priv_data->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) /* RAID volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) if (starget->channel == RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) raid_device = _scsih_raid_device_find_by_id(ioc, starget->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) starget->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) if (raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) sas_target_priv_data->handle = raid_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) sas_target_priv_data->sas_address = raid_device->wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) if (ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) sas_target_priv_data->raid_device = raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) raid_device->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) /* PCIe devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) if (starget->channel == PCIE_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) pcie_device = __mpt3sas_get_pdev_by_idchannel(ioc, starget->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) starget->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) sas_target_priv_data->handle = pcie_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) sas_target_priv_data->sas_address = pcie_device->wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) sas_target_priv_data->pcie_dev = pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) pcie_device->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) pcie_device->id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) pcie_device->channel = starget->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) sas_target_priv_data->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) MPT_TARGET_FLAGS_PCIE_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) if (pcie_device->fast_path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) sas_target_priv_data->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) MPT_TARGET_FASTPATH_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) /* sas/sata devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) rphy = dev_to_rphy(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) rphy->identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) sas_target_priv_data->handle = sas_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) sas_target_priv_data->sas_address = sas_device->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) sas_target_priv_data->sas_dev = sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) sas_device->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) sas_device->id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) sas_device->channel = starget->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) if (test_bit(sas_device->handle, ioc->pd_handles))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) sas_target_priv_data->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) if (sas_device->fast_path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) sas_target_priv_data->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) MPT_TARGET_FASTPATH_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) * scsih_target_destroy - target destroy routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) * @starget: scsi target struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) scsih_target_destroy(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) struct Scsi_Host *shost = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) if (!sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) if (starget->channel == RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) raid_device = _scsih_raid_device_find_by_id(ioc, starget->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) starget->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) if (raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) raid_device->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) raid_device->sdev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) if (starget->channel == PCIE_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) pcie_device = __mpt3sas_get_pdev_from_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) if (pcie_device && (pcie_device->starget == starget) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) (pcie_device->id == starget->id) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) (pcie_device->channel == starget->channel))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) pcie_device->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) * Corresponding get() is in _scsih_target_alloc()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) sas_target_priv_data->pcie_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) sas_device = __mpt3sas_get_sdev_from_target(ioc, sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) if (sas_device && (sas_device->starget == starget) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) (sas_device->id == starget->id) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) (sas_device->channel == starget->channel))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) sas_device->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) * Corresponding get() is in _scsih_target_alloc()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) sas_target_priv_data->sas_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) kfree(sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) starget->hostdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) * scsih_slave_alloc - device add routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) * Return: 0 if ok. Any other return is assumed to be an error and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) * the device is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) scsih_slave_alloc(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) sas_device_priv_data = kzalloc(sizeof(*sas_device_priv_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) sas_device_priv_data->lun = sdev->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) sas_device_priv_data->flags = MPT_DEVICE_FLAGS_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) starget = scsi_target(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) sas_target_priv_data->num_luns++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) sas_device_priv_data->sas_target = sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) sdev->hostdata = sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) sdev->no_uld_attach = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) shost = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) if (starget->channel == RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) raid_device = _scsih_raid_device_find_by_id(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) starget->id, starget->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) raid_device->sdev = sdev; /* raid is single lun */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) if (starget->channel == PCIE_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) pcie_device = __mpt3sas_get_pdev_by_wwid(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) sas_target_priv_data->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) if (pcie_device && (pcie_device->starget == NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) "%s : pcie_device->starget set to starget @ %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) pcie_device->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) sas_target_priv_data->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) if (sas_device && (sas_device->starget == NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) "%s : sas_device->starget set to starget @ %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) sas_device->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) * scsih_slave_destroy - device destroy routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) scsih_slave_destroy(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) if (!sdev->hostdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) starget = scsi_target(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) sas_target_priv_data->num_luns--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) shost = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) pcie_device = __mpt3sas_get_pdev_from_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) if (pcie_device && !sas_target_priv_data->num_luns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) pcie_device->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) } else if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) sas_device = __mpt3sas_get_sdev_from_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) sas_target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) if (sas_device && !sas_target_priv_data->num_luns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) sas_device->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) kfree(sdev->hostdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) sdev->hostdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) * _scsih_display_sata_capabilities - sata capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) _scsih_display_sata_capabilities(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) u16 handle, struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) flags = le16_to_cpu(sas_device_pg0.Flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) "atapi(%s), ncq(%s), asyn_notify(%s), smart(%s), fua(%s), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) "sw_preserve(%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) (device_info & MPI2_SAS_DEVICE_INFO_ATAPI_DEVICE) ? "y" : "n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) (flags & MPI2_SAS_DEVICE0_FLAGS_SATA_NCQ_SUPPORTED) ? "y" : "n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) (flags & MPI2_SAS_DEVICE0_FLAGS_SATA_ASYNCHRONOUS_NOTIFY) ? "y" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) "n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) (flags & MPI2_SAS_DEVICE0_FLAGS_SATA_SMART_SUPPORTED) ? "y" : "n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) (flags & MPI2_SAS_DEVICE0_FLAGS_SATA_FUA_SUPPORTED) ? "y" : "n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) (flags & MPI2_SAS_DEVICE0_FLAGS_SATA_SW_PRESERVE) ? "y" : "n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) * raid transport support -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) * Enabled for SLES11 and newer, in older kernels the driver will panic when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) * unloading the driver followed by a load - I believe that the subroutine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) * raid_class_release() is not cleaning up properly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) * scsih_is_raid - return boolean indicating device is raid volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) * @dev: the device struct object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) scsih_is_raid(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) if (ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) return (sdev->channel == RAID_CHANNEL) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) scsih_is_nvme(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) return (sdev->channel == PCIE_CHANNEL) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) * scsih_get_resync - get raid volume resync percent complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) * @dev: the device struct object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) scsih_get_resync(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) static struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) Mpi2RaidVolPage0_t vol_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) u32 volume_status_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) u8 percent_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) percent_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) if (ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) sdev->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) if (raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) handle = raid_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) percent_complete = raid_device->percent_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply, &vol_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) sizeof(Mpi2RaidVolPage0_t))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) percent_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) volume_status_flags = le32_to_cpu(vol_pg0.VolumeStatusFlags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) if (!(volume_status_flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) MPI2_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) percent_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) switch (ioc->hba_mpi_version_belonged) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) case MPI2_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) raid_set_resync(mpt2sas_raid_template, dev, percent_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) case MPI25_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) case MPI26_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) raid_set_resync(mpt3sas_raid_template, dev, percent_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) * scsih_get_state - get raid volume level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) * @dev: the device struct object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) scsih_get_state(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) static struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) Mpi2RaidVolPage0_t vol_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) u32 volstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) enum raid_state state = RAID_STATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) u16 handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) raid_device = _scsih_raid_device_find_by_id(ioc, sdev->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) sdev->channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) handle = raid_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) if (!raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply, &vol_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) sizeof(Mpi2RaidVolPage0_t))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) volstate = le32_to_cpu(vol_pg0.VolumeStatusFlags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) if (volstate & MPI2_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) state = RAID_STATE_RESYNCING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) switch (vol_pg0.VolumeState) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) case MPI2_RAID_VOL_STATE_OPTIMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) case MPI2_RAID_VOL_STATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) state = RAID_STATE_ACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) case MPI2_RAID_VOL_STATE_DEGRADED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) state = RAID_STATE_DEGRADED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) case MPI2_RAID_VOL_STATE_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) case MPI2_RAID_VOL_STATE_MISSING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) state = RAID_STATE_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) switch (ioc->hba_mpi_version_belonged) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) case MPI2_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) raid_set_state(mpt2sas_raid_template, dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) case MPI25_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) case MPI26_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) raid_set_state(mpt3sas_raid_template, dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) * _scsih_set_level - set raid level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) * @ioc: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) * @volume_type: volume type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) _scsih_set_level(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) struct scsi_device *sdev, u8 volume_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) enum raid_level level = RAID_LEVEL_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) switch (volume_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) case MPI2_RAID_VOL_TYPE_RAID0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) level = RAID_LEVEL_0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) case MPI2_RAID_VOL_TYPE_RAID10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) level = RAID_LEVEL_10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) case MPI2_RAID_VOL_TYPE_RAID1E:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) level = RAID_LEVEL_1E;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) case MPI2_RAID_VOL_TYPE_RAID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) level = RAID_LEVEL_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) switch (ioc->hba_mpi_version_belonged) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) case MPI2_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) raid_set_level(mpt2sas_raid_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) &sdev->sdev_gendev, level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) case MPI25_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) case MPI26_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) raid_set_level(mpt3sas_raid_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) &sdev->sdev_gendev, level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) * _scsih_get_volume_capabilities - volume capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) * @raid_device: the raid_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) * Return: 0 for success, else 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) _scsih_get_volume_capabilities(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) struct _raid_device *raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) Mpi2RaidVolPage0_t *vol_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) Mpi2RaidPhysDiskPage0_t pd_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) u16 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) u8 num_pds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) if ((mpt3sas_config_get_number_pds(ioc, raid_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) &num_pds)) || !num_pds) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) raid_device->num_pds = num_pds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) sz = offsetof(Mpi2RaidVolPage0_t, PhysDisk) + (num_pds *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) sizeof(Mpi2RaidVol0PhysDisk_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) vol_pg0 = kzalloc(sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) if (!vol_pg0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) if ((mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply, vol_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, raid_device->handle, sz))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) kfree(vol_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) raid_device->volume_type = vol_pg0->VolumeType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) /* figure out what the underlying devices are by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) * obtaining the device_info bits for the 1st device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) if (!(mpt3sas_config_get_phys_disk_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) &pd_pg0, MPI2_PHYSDISK_PGAD_FORM_PHYSDISKNUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) vol_pg0->PhysDisk[0].PhysDiskNum))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) if (!(mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) le16_to_cpu(pd_pg0.DevHandle)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) raid_device->device_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) le32_to_cpu(sas_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) kfree(vol_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) * _scsih_enable_tlr - setting TLR flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) * Enabling Transaction Layer Retries for tape devices when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) * vpd page 0x90 is present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) _scsih_enable_tlr(struct MPT3SAS_ADAPTER *ioc, struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) /* only for TAPE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) if (sdev->type != TYPE_TAPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) sas_enable_tlr(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) sdev_printk(KERN_INFO, sdev, "TLR %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) sas_is_tlr_enabled(sdev) ? "Enabled" : "Disabled");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) * scsih_slave_configure - device configure routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) * Return: 0 if ok. Any other return is assumed to be an error and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) * the device is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) scsih_slave_configure(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) struct Scsi_Host *shost = sdev->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) int qdepth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) u8 ssp_target = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) char *ds = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) char *r_level = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) u16 handle, volume_handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) u64 volume_wwid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) qdepth = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) sas_device_priv_data->configured_lun = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) sas_device_priv_data->flags &= ~MPT_DEVICE_FLAGS_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) sas_target_priv_data = sas_device_priv_data->sas_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) handle = sas_target_priv_data->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) /* raid volume handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) if (!raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) if (_scsih_get_volume_capabilities(ioc, raid_device)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) * WARPDRIVE: Initialize the required data for Direct IO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) mpt3sas_init_warpdrive_properties(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) /* RAID Queue Depth Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) * IS volume = underlying qdepth of drive type, either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) * MPT3SAS_SAS_QUEUE_DEPTH or MPT3SAS_SATA_QUEUE_DEPTH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) * IM/IME/R10 = 128 (MPT3SAS_RAID_QUEUE_DEPTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) if (raid_device->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) MPI2_SAS_DEVICE_INFO_SSP_TARGET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) qdepth = MPT3SAS_SAS_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) ds = "SSP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) qdepth = MPT3SAS_SATA_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) if (raid_device->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) MPI2_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) ds = "SATA";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) ds = "STP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) switch (raid_device->volume_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) case MPI2_RAID_VOL_TYPE_RAID0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) r_level = "RAID0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) case MPI2_RAID_VOL_TYPE_RAID1E:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) if (ioc->manu_pg10.OEMIdentifier &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) (le32_to_cpu(ioc->manu_pg10.GenericFlags0) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) MFG10_GF0_R10_DISPLAY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) !(raid_device->num_pds % 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) r_level = "RAID10";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) r_level = "RAID1E";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) case MPI2_RAID_VOL_TYPE_RAID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) r_level = "RAID1";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) case MPI2_RAID_VOL_TYPE_RAID10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) r_level = "RAID10";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) case MPI2_RAID_VOL_TYPE_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) r_level = "RAIDX";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) if (!ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) "%s: handle(0x%04x), wwid(0x%016llx),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) " pd_count(%d), type(%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) r_level, raid_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) (unsigned long long)raid_device->wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) raid_device->num_pds, ds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) blk_queue_max_hw_sectors(sdev->request_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) MPT3SAS_RAID_MAX_SECTORS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) "Set queue's max_sector to: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) MPT3SAS_RAID_MAX_SECTORS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) mpt3sas_scsih_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) /* raid transport support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) _scsih_set_level(ioc, sdev, raid_device->volume_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) /* non-raid handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) if (mpt3sas_config_get_volume_handle(ioc, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) &volume_handle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) if (volume_handle && mpt3sas_config_get_volume_wwid(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) volume_handle, &volume_wwid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) /* PCIe handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) pcie_device = __mpt3sas_get_pdev_by_wwid(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) sas_device_priv_data->sas_target->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) if (!pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) qdepth = MPT3SAS_NVME_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) ds = "NVMe";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) "%s: handle(0x%04x), wwid(0x%016llx), port(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) ds, handle, (unsigned long long)pcie_device->wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) pcie_device->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) "%s: enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) ds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) (unsigned long long)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) "%s: enclosure level(0x%04x),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) "connector name( %s)\n", ds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) pcie_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) if (pcie_device->nvme_mdts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) blk_queue_max_hw_sectors(sdev->request_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) pcie_device->nvme_mdts/512);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) mpt3sas_scsih_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) /* Enable QUEUE_FLAG_NOMERGES flag, so that IOs won't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) ** merged and can eliminate holes created during merging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) ** operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) blk_queue_flag_set(QUEUE_FLAG_NOMERGES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) sdev->request_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) blk_queue_virt_boundary(sdev->request_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) ioc->page_size - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) sas_device_priv_data->sas_target->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) if (!sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) ioc_warn(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) __FILE__, __LINE__, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) sas_device->volume_handle = volume_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) sas_device->volume_wwid = volume_wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) qdepth = MPT3SAS_SAS_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) ssp_target = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) if (sas_device->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) MPI2_SAS_DEVICE_INFO_SEP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) "set ignore_delay_remove for handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) sas_device_priv_data->ignore_delay_remove = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) ds = "SES";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) ds = "SSP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) qdepth = MPT3SAS_SATA_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) if (sas_device->device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) ds = "STP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) else if (sas_device->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) MPI2_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) ds = "SATA";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) sdev_printk(KERN_INFO, sdev, "%s: handle(0x%04x), " \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) "sas_addr(0x%016llx), phy(%d), device_name(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) ds, handle, (unsigned long long)sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) sas_device->phy, (unsigned long long)sas_device->device_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) _scsih_display_enclosure_chassis_info(NULL, sas_device, sdev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) if (!ssp_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) _scsih_display_sata_capabilities(ioc, handle, sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) mpt3sas_scsih_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) if (ssp_target) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) sas_read_port_mode_page(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) _scsih_enable_tlr(ioc, sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) * scsih_bios_param - fetch head, sector, cylinder info for a disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) * @bdev: pointer to block device context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) * @capacity: device size (in 512 byte sectors)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) * @params: three element array to place output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) * params[0] number of heads (max 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) * params[1] number of sectors (max 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) * params[2] number of cylinders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) scsih_bios_param(struct scsi_device *sdev, struct block_device *bdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) sector_t capacity, int params[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) int heads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) int sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) sector_t cylinders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) ulong dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) heads = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) sectors = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) dummy = heads * sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) cylinders = capacity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) sector_div(cylinders, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) * Handle extended translation size for logical drives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) * > 1Gb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) if ((ulong)capacity >= 0x200000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) heads = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) sectors = 63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) dummy = heads * sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) cylinders = capacity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) sector_div(cylinders, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) /* return result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) params[0] = heads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) params[1] = sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) params[2] = cylinders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) * _scsih_response_code - translation of device response code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) * @response_code: response code returned by the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) _scsih_response_code(struct MPT3SAS_ADAPTER *ioc, u8 response_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) char *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) switch (response_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) case MPI2_SCSITASKMGMT_RSP_TM_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) desc = "task management request completed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) case MPI2_SCSITASKMGMT_RSP_INVALID_FRAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) desc = "invalid frame";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) case MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) desc = "task management request not supported";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) case MPI2_SCSITASKMGMT_RSP_TM_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) desc = "task management request failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) case MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) desc = "task management request succeeded";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) case MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) desc = "invalid lun";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) case 0xA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) desc = "overlapped tag attempted";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) case MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) desc = "task queued, however not sent to target";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) desc = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) ioc_warn(ioc, "response_code(0x%01x): %s\n", response_code, desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) * _scsih_tm_done - tm completion routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) * Context: none.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) * The callback handler when using scsih_issue_tm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) _scsih_tm_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) MPI2DefaultReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) if (ioc->tm_cmds.status == MPT3_CMD_NOT_USED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) if (ioc->tm_cmds.smid != smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) ioc->tm_cmds.status |= MPT3_CMD_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) if (mpi_reply) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) memcpy(ioc->tm_cmds.reply, mpi_reply, mpi_reply->MsgLength*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) ioc->tm_cmds.status |= MPT3_CMD_REPLY_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) ioc->tm_cmds.status &= ~MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) complete(&ioc->tm_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) * mpt3sas_scsih_set_tm_flag - set per target tm_busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) * During taskmangement request, we need to freeze the device queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) u8 skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) if (skip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) if (sas_device_priv_data->sas_target->handle == handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) sas_device_priv_data->sas_target->tm_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) ioc->ignore_loginfos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) * mpt3sas_scsih_clear_tm_flag - clear per target tm_busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) * During taskmangement request, we need to freeze the device queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) u8 skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) if (skip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) if (sas_device_priv_data->sas_target->handle == handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) sas_device_priv_data->sas_target->tm_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) ioc->ignore_loginfos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) * scsih_tm_cmd_map_status - map the target reset & LUN reset TM status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) * @ioc - per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) * @channel - the channel assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) * @id: the id assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) * @lun: lun number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in mpi2_init.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) * @smid_task: smid assigned to the task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) * Look whether TM has aborted the timed out SCSI command, if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) * TM has aborted the IO then return SUCCESS else return FAILED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) scsih_tm_cmd_map_status(struct MPT3SAS_ADAPTER *ioc, uint channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) uint id, uint lun, u8 type, u16 smid_task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) if (smid_task <= ioc->shost->can_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) case MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) if (!(_scsih_scsi_lookup_find_by_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) id, channel)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) case MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) case MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) if (!(_scsih_scsi_lookup_find_by_lun(ioc, id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) lun, channel)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) } else if (smid_task == ioc->scsih_cmds.smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) if ((ioc->scsih_cmds.status & MPT3_CMD_COMPLETE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) (ioc->scsih_cmds.status & MPT3_CMD_NOT_USED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) } else if (smid_task == ioc->ctl_cmds.smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) if ((ioc->ctl_cmds.status & MPT3_CMD_COMPLETE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) (ioc->ctl_cmds.status & MPT3_CMD_NOT_USED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) * scsih_tm_post_processing - post processing of target & LUN reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) * @ioc - per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) * @channel - the channel assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) * @id: the id assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) * @lun: lun number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in mpi2_init.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) * @smid_task: smid assigned to the task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) * Post processing of target & LUN reset. Due to interrupt latency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) * issue it possible that interrupt for aborted IO might not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) * received yet. So before returning failure status, poll the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) * reply descriptor pools for the reply of timed out SCSI command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) * Return FAILED status if reply for timed out is not received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) * otherwise return SUCCESS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) scsih_tm_post_processing(struct MPT3SAS_ADAPTER *ioc, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) uint channel, uint id, uint lun, u8 type, u16 smid_task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) rc = scsih_tm_cmd_map_status(ioc, channel, id, lun, type, smid_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) if (rc == SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) "Poll ReplyDescriptor queues for completion of"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) " smid(%d), task_type(0x%02x), handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) smid_task, type, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) * Due to interrupt latency issues, driver may receive interrupt for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) * TM first and then for aborted SCSI IO command. So, poll all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) * ReplyDescriptor pools before returning the FAILED status to SML.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) mpt3sas_base_mask_interrupts(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) mpt3sas_base_sync_reply_irqs(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) mpt3sas_base_unmask_interrupts(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) return scsih_tm_cmd_map_status(ioc, channel, id, lun, type, smid_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) * mpt3sas_scsih_issue_tm - main routine for sending tm requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) * @ioc: per adapter struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) * @channel: the channel assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) * @id: the id assigned by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) * @lun: lun number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in mpi2_init.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) * @smid_task: smid assigned to the task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) * @msix_task: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) * @timeout: timeout in seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) * @tr_method: Target Reset Method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) * Context: user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) * A generic API for sending task management requests to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) * The callback index is set inside `ioc->tm_cb_idx`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) * The caller is responsible to check for outstanding commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) * Return: SUCCESS or FAILED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) uint id, u64 lun, u8 type, u16 smid_task, u16 msix_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) u8 timeout, u8 tr_method)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) Mpi2SCSITaskManagementRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) Mpi2SCSITaskManagementReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) Mpi25SCSIIORequest_t *request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) u16 smid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) lockdep_assert_held(&ioc->tm_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) if (ioc->tm_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) ioc_info(ioc, "%s: tm_cmd busy!!!\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) if (ioc->shost_recovery || ioc->remove_host ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) ioc_info(ioc, "%s: host reset in progress!\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) if (ioc_state & MPI2_DOORBELL_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) dhsprintk(ioc, ioc_info(ioc, "unexpected doorbell active!\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) return (!rc) ? SUCCESS : FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) mpt3sas_print_fault_code(ioc, ioc_state &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) MPI2_DOORBELL_DATA_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) return (!rc) ? SUCCESS : FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) } else if ((ioc_state & MPI2_IOC_STATE_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) MPI2_IOC_STATE_COREDUMP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) mpt3sas_print_coredump_info(ioc, ioc_state &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) MPI2_DOORBELL_DATA_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) return (!rc) ? SUCCESS : FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) ioc_info(ioc, "sending tm: handle(0x%04x), task_type(0x%02x), smid(%d), timeout(%d), tr_method(0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) handle, type, smid_task, timeout, tr_method));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) ioc->tm_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) ioc->tm_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) memset(mpi_request, 0, sizeof(Mpi2SCSITaskManagementRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) memset(ioc->tm_cmds.reply, 0, sizeof(Mpi2SCSITaskManagementReply_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) mpi_request->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) mpi_request->TaskType = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) if (type == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) type == MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) mpi_request->MsgFlags = tr_method;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) mpi_request->TaskMID = cpu_to_le16(smid_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) mpt3sas_scsih_set_tm_flag(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) init_completion(&ioc->tm_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) ioc->put_smid_hi_priority(ioc, smid, msix_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) ioc->tm_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) sizeof(Mpi2SCSITaskManagementRequest_t)/4, issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) if (issue_reset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) rc = mpt3sas_base_hard_reset_handler(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) rc = (!rc) ? SUCCESS : FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) /* sync IRQs in case those were busy during flush. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) mpt3sas_base_sync_reply_irqs(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) mpt3sas_trigger_master(ioc, MASTER_TRIGGER_TASK_MANAGMENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) mpi_reply = ioc->tm_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) ioc_info(ioc, "complete tm: ioc_status(0x%04x), loginfo(0x%08x), term_count(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) le32_to_cpu(mpi_reply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) le32_to_cpu(mpi_reply->TerminationCount)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) if (ioc->logging_level & MPT_DEBUG_TM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) _scsih_response_code(ioc, mpi_reply->ResponseCode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) if (mpi_reply->IOCStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) _debug_dump_mf(mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) sizeof(Mpi2SCSITaskManagementRequest_t)/4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) case MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) * If DevHandle filed in smid_task's entry of request pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) * doesn't match with device handle on which this task abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) * TM is received then it means that TM has successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) * aborted the timed out command. Since smid_task's entry in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) * request pool will be memset to zero once the timed out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) * command is returned to the SML. If the command is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) * aborted then smid_task’s entry won’t be cleared and it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) * will have same DevHandle value on which this task abort TM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) * is received and driver will return the TM status as FAILED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) request = mpt3sas_base_get_msg_frame(ioc, smid_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) if (le16_to_cpu(request->DevHandle) != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) ioc_info(ioc, "Task abort tm failed: handle(0x%04x),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) "timeout(%d) tr_method(0x%x) smid(%d) msix_index(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) handle, timeout, tr_method, smid_task, msix_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) case MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) case MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) case MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) rc = scsih_tm_post_processing(ioc, handle, channel, id, lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) type, smid_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) case MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) mpt3sas_scsih_clear_tm_flag(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) ioc->tm_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) uint channel, uint id, u64 lun, u8 type, u16 smid_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) u16 msix_task, u8 timeout, u8 tr_method)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) mutex_lock(&ioc->tm_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) ret = mpt3sas_scsih_issue_tm(ioc, handle, channel, id, lun, type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) smid_task, msix_task, timeout, tr_method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) mutex_unlock(&ioc->tm_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) * _scsih_tm_display_info - displays info about the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) * @ioc: per adapter struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) * Called by task management callback handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) _scsih_tm_display_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) struct scsi_target *starget = scmd->device->sdev_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) struct MPT3SAS_TARGET *priv_target = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) char *device_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) if (!priv_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) if (ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) device_str = "WarpDrive";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) device_str = "volume";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) scsi_print_command(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) "%s handle(0x%04x), %s wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) device_str, priv_target->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) device_str, (unsigned long long)priv_target->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) pcie_device = __mpt3sas_get_pdev_from_target(ioc, priv_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) "handle(0x%04x), wwid(0x%016llx), port(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) pcie_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) (unsigned long long)pcie_device->wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) pcie_device->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) "enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) "enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) pcie_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) sas_device = __mpt3sas_get_sdev_from_target(ioc, priv_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) if (priv_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) MPT_TARGET_FLAGS_RAID_COMPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) "volume handle(0x%04x), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) "volume wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) sas_device->volume_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) (unsigned long long)sas_device->volume_wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) "handle(0x%04x), sas_address(0x%016llx), phy(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) (unsigned long long)sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) sas_device->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) _scsih_display_enclosure_chassis_info(NULL, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) NULL, starget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) * scsih_abort - eh threads main abort routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) * Return: SUCCESS if command aborted else FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) scsih_abort(struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) struct scsiio_tracker *st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) u8 timeout = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) sdev_printk(KERN_INFO, scmd->device, "attempting task abort!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) "scmd(0x%p), outstanding for %u ms & timeout %u ms\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) scmd, jiffies_to_msecs(jiffies - scmd->jiffies_at_alloc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) (scmd->request->timeout / HZ) * 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) _scsih_tm_display_info(ioc, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) sas_device_priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) sdev_printk(KERN_INFO, scmd->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) "device been deleted! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) r = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) /* check for completed command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) if (st == NULL || st->cb_idx == 0xFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) sdev_printk(KERN_INFO, scmd->device, "No reference found at "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) "driver, assuming scmd(0x%p) might have completed\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) r = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) /* for hidden raid components and volumes this is not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) MPT_TARGET_FLAGS_RAID_COMPONENT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) sas_device_priv_data->sas_target->flags & MPT_TARGET_FLAGS_VOLUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) mpt3sas_halt_firmware(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) handle = sas_device_priv_data->sas_target->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) if (pcie_device && (!ioc->tm_custom_handling) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) timeout = ioc->nvme_abort_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) scmd->device->id, scmd->device->lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) st->smid, st->msix_io, timeout, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) /* Command must be cleared after abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) if (r == SUCCESS && st->cb_idx != 0xFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) * scsih_dev_reset - eh threads main device reset routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) * Return: SUCCESS if command aborted else FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) scsih_dev_reset(struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) u8 tr_method = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) u8 tr_timeout = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) struct scsi_target *starget = scmd->device->sdev_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) struct MPT3SAS_TARGET *target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) sdev_printk(KERN_INFO, scmd->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) "attempting device reset! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) _scsih_tm_display_info(ioc, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) sas_device_priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) sdev_printk(KERN_INFO, scmd->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) "device been deleted! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) r = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) /* for hidden raid components obtain the volume_handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) MPT_TARGET_FLAGS_RAID_COMPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) sas_device = mpt3sas_get_sdev_from_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) handle = sas_device->volume_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) handle = sas_device_priv_data->sas_target->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) if (!handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) if (pcie_device && (!ioc->tm_custom_handling) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) tr_timeout = pcie_device->reset_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) scmd->device->id, scmd->device->lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) tr_timeout, tr_method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) /* Check for busy commands after reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) if (r == SUCCESS && atomic_read(&scmd->device->device_busy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) * scsih_target_reset - eh threads main target reset routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) * Return: SUCCESS if command aborted else FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) scsih_target_reset(struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) u8 tr_method = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) u8 tr_timeout = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) struct scsi_target *starget = scmd->device->sdev_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) struct MPT3SAS_TARGET *target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) "attempting target reset! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) _scsih_tm_display_info(ioc, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) sas_device_priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) "target been deleted! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) r = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) /* for hidden raid components obtain the volume_handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) MPT_TARGET_FLAGS_RAID_COMPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) sas_device = mpt3sas_get_sdev_from_target(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) target_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) handle = sas_device->volume_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) handle = sas_device_priv_data->sas_target->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) if (!handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) if (pcie_device && (!ioc->tm_custom_handling) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) tr_timeout = pcie_device->reset_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) scmd->device->id, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) tr_timeout, tr_method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) /* Check for busy commands after reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) if (r == SUCCESS && atomic_read(&starget->target_busy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) starget_printk(KERN_INFO, starget, "target reset: %s scmd(0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) * scsih_host_reset - eh threads main host reset routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) * Return: SUCCESS if command aborted else FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) scsih_host_reset(struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) int r, retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) ioc_info(ioc, "attempting host reset! scmd(0x%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) scsi_print_command(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) if (ioc->is_driver_loading || ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) ioc_info(ioc, "Blocking the host reset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) r = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) r = (retval < 0) ? FAILED : SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) ioc_info(ioc, "host reset: %s scmd(0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) r == SUCCESS ? "SUCCESS" : "FAILED", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) * _scsih_fw_event_add - insert and queue up fw_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) * @fw_event: object describing the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) * Context: This function will acquire ioc->fw_event_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) * This adds the firmware event object into link list, then queues it up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) * be processed from user context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) _scsih_fw_event_add(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) if (ioc->firmware_event_thread == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) fw_event_work_get(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) INIT_LIST_HEAD(&fw_event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) list_add_tail(&fw_event->list, &ioc->fw_event_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) INIT_WORK(&fw_event->work, _firmware_event_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) fw_event_work_get(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) queue_work(ioc->firmware_event_thread, &fw_event->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) * _scsih_fw_event_del_from_list - delete fw_event from the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) * @fw_event: object describing the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) * Context: This function will acquire ioc->fw_event_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) * If the fw_event is on the fw_event_list, remove it and do a put.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) _scsih_fw_event_del_from_list(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) if (!list_empty(&fw_event->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) list_del_init(&fw_event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) * mpt3sas_send_trigger_data_event - send event for processing trigger data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) * @event_data: trigger event data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) u16 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) if (ioc->is_driver_loading)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) sz = sizeof(*event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) fw_event = alloc_fw_event_work(sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) if (!fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) memcpy(fw_event->event_data, event_data, sizeof(*event_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) _scsih_fw_event_add(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) * _scsih_error_recovery_delete_devices - remove devices not responding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) _scsih_error_recovery_delete_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) if (ioc->is_driver_loading)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) fw_event = alloc_fw_event_work(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) if (!fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) fw_event->event = MPT3SAS_REMOVE_UNRESPONDING_DEVICES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) _scsih_fw_event_add(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) * mpt3sas_port_enable_complete - port enable completed (fake event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) fw_event = alloc_fw_event_work(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) if (!fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) fw_event->event = MPT3SAS_PORT_ENABLE_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) _scsih_fw_event_add(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) static struct fw_event_work *dequeue_next_fw_event(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) struct fw_event_work *fw_event = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) if (!list_empty(&ioc->fw_event_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) fw_event = list_first_entry(&ioc->fw_event_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) struct fw_event_work, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) list_del_init(&fw_event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) return fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) * _scsih_fw_event_cleanup_queue - cleanup event queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) * Walk the firmware event queue, either killing timers, or waiting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) * for outstanding events to complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) !ioc->firmware_event_thread || in_interrupt())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) ioc->fw_events_cleanup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) while ((fw_event = dequeue_next_fw_event(ioc)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) (fw_event = ioc->current_event)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) * Don't call cancel_work_sync() for current_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) * other than MPT3SAS_REMOVE_UNRESPONDING_DEVICES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) * otherwise we may observe deadlock if current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) * hard reset issued as part of processing the current_event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) * Orginal logic of cleaning the current_event is added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) * for handling the back to back host reset issued by the user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) * i.e. during back to back host reset, driver use to process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) * the two instances of MPT3SAS_REMOVE_UNRESPONDING_DEVICES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) * event back to back and this made the drives to unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) * the devices from SML.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) if (fw_event == ioc->current_event &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) ioc->current_event->event !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) MPT3SAS_REMOVE_UNRESPONDING_DEVICES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) ioc->current_event = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) * Wait on the fw_event to complete. If this returns 1, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) * the event was never executed, and we need a put for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) * reference the work had on the fw_event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) * If it did execute, we wait for it to finish, and the put will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) * happen from _firmware_event_work()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) if (cancel_work_sync(&fw_event->work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) ioc->fw_events_cleanup = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) * _scsih_internal_device_block - block the sdev device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) * @sdev: per device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) * @sas_device_priv_data : per device driver private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) * make sure device is blocked without error, if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) * print an error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) _scsih_internal_device_block(struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) struct MPT3SAS_DEVICE *sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) int r = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) sdev_printk(KERN_INFO, sdev, "device_block, handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) sas_device_priv_data->block = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) r = scsi_internal_device_block_nowait(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) if (r == -EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) "device_block failed with return(%d) for handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) r, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) * _scsih_internal_device_unblock - unblock the sdev device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) * @sdev: per device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) * @sas_device_priv_data : per device driver private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) * make sure device is unblocked without error, if not retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) * by blocking and then unblocking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) _scsih_internal_device_unblock(struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) struct MPT3SAS_DEVICE *sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) int r = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) sdev_printk(KERN_WARNING, sdev, "device_unblock and setting to running, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) "handle(0x%04x)\n", sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) sas_device_priv_data->block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) r = scsi_internal_device_unblock_nowait(sdev, SDEV_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) if (r == -EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) /* The device has been set to SDEV_RUNNING by SD layer during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) * device addition but the request queue is still stopped by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) * our earlier block call. We need to perform a block again
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) * to get the device to SDEV_BLOCK and then to SDEV_RUNNING */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) "device_unblock failed with return(%d) for handle(0x%04x) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) "performing a block followed by an unblock\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) r, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) sas_device_priv_data->block = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) r = scsi_internal_device_block_nowait(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) sdev_printk(KERN_WARNING, sdev, "retried device_block "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) "failed with return(%d) for handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) r, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) sas_device_priv_data->block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) r = scsi_internal_device_unblock_nowait(sdev, SDEV_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) sdev_printk(KERN_WARNING, sdev, "retried device_unblock"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) " failed with return(%d) for handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) r, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) * _scsih_ublock_io_all_device - unblock every device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) * change the device state from block to running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) _scsih_ublock_io_all_device(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) if (!sas_device_priv_data->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) dewtprintk(ioc, sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) "device_running, handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) sas_device_priv_data->sas_target->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) _scsih_internal_device_unblock(sdev, sas_device_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) * _scsih_ublock_io_device - prepare device to be deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) * unblock then put device in offline state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) _scsih_ublock_io_device(struct MPT3SAS_ADAPTER *ioc, u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) if (!sas_device_priv_data || !sas_device_priv_data->sas_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) if (sas_device_priv_data->sas_target->sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) != sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) if (sas_device_priv_data->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) _scsih_internal_device_unblock(sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) sas_device_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) * _scsih_block_io_all_device - set the device state to SDEV_BLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) * During device pull we need to appropriately set the sdev state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) _scsih_block_io_all_device(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) if (sas_device_priv_data->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) if (sas_device_priv_data->ignore_delay_remove) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) "%s skip device_block for SES handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) __func__, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) _scsih_internal_device_block(sdev, sas_device_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) * _scsih_block_io_device - set the device state to SDEV_BLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) * During device pull we need to appropriately set the sdev state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) if (sas_device_priv_data->sas_target->handle != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) if (sas_device_priv_data->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) if (sas_device && sas_device->pend_sas_rphy_add)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) if (sas_device_priv_data->ignore_delay_remove) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) "%s skip device_block for SES handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) __func__, sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) _scsih_internal_device_block(sdev, sas_device_priv_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) * _scsih_block_io_to_children_attached_to_ex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) * @sas_expander: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) * This routine set sdev state to SDEV_BLOCK for all devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) * attached to this expander. This function called when expander is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) * pulled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) _scsih_block_io_to_children_attached_to_ex(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) struct _sas_node *sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) struct _sas_port *mpt3sas_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) struct _sas_node *expander_sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) if (!sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) list_for_each_entry(mpt3sas_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) &sas_expander->sas_port_list, port_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) SAS_END_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) set_bit(sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) ioc->blocking_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) list_for_each_entry(mpt3sas_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) &sas_expander->sas_port_list, port_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) SAS_EDGE_EXPANDER_DEVICE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) SAS_FANOUT_EXPANDER_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) expander_sibling =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) mpt3sas_scsih_expander_find_by_sas_address(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) ioc, mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) _scsih_block_io_to_children_attached_to_ex(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) expander_sibling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) * _scsih_block_io_to_children_attached_directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) * @event_data: topology change event data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) * This routine set sdev state to SDEV_BLOCK for all devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) * direct attached during device pull.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) _scsih_block_io_to_children_attached_directly(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) Mpi2EventDataSasTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) reason_code = event_data->PHY[i].PhyStatus &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) MPI2_EVENT_SAS_TOPO_RC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) if (reason_code == MPI2_EVENT_SAS_TOPO_RC_DELAY_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) _scsih_block_io_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) * _scsih_block_io_to_pcie_children_attached_directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) * @event_data: topology change event data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) * This routine set sdev state to SDEV_BLOCK for all devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) * direct attached during device pull/reconnect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) _scsih_block_io_to_pcie_children_attached_directly(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) Mpi26EventDataPCIeTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) reason_code = event_data->PortEntry[i].PortStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) if (reason_code ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) MPI26_EVENT_PCIE_TOPO_PS_DELAY_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) _scsih_block_io_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) * _scsih_tm_tr_send - send task management request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) * This code is to initiate the device removal handshake protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) * with controller firmware. This function will issue target reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) * using high priority request queue. It will send a sas iounit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) * control request (MPI2_SAS_OP_REMOVE_DEVICE) from this completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) * This is designed to send muliple task management request at the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) * time to the fifo. If the fifo is full, we will append the request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) * and process it in a future completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) Mpi2SCSITaskManagementRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) u64 sas_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) struct _tr_list *delayed_tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) u8 tr_method = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) if (ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) ioc_info(ioc, "%s: host in pci error recovery: handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) __func__, handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) ioc_info(ioc, "%s: host is not operational: handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) __func__, handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) /* if PD, then return */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) if (test_bit(handle, ioc->pd_handles))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) clear_bit(handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) if (sas_device && sas_device->starget &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) sas_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) sas_target_priv_data = sas_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) sas_address = sas_device->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) if (!sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) if (pcie_device && pcie_device->starget &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) pcie_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) sas_target_priv_data = pcie_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) sas_address = pcie_device->wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) if (pcie_device && (!ioc->tm_custom_handling) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) (!(mpt3sas_scsih_is_pcie_scsi_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) pcie_device->device_info))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) tr_method =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) if (sas_target_priv_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) ioc_info(ioc, "setting delete flag: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) handle, (u64)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) ioc_info(ioc, "setting delete flag:enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) (u64)sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) sas_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) if (sas_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) ioc_info(ioc, "setting delete flag: enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) sas_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) sas_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) } else if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) ioc_info(ioc, "setting delete flag: logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) pcie_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) ioc_info(ioc, "setting delete flag:, enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) pcie_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) _scsih_ublock_io_device(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) delayed_tr = kzalloc(sizeof(*delayed_tr), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) if (!delayed_tr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) INIT_LIST_HEAD(&delayed_tr->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) delayed_tr->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) handle, smid, ioc->tm_tr_cb_idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) memset(mpi_request, 0, sizeof(Mpi2SCSITaskManagementRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) mpi_request->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) mpi_request->MsgFlags = tr_method;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) set_bit(handle, ioc->device_remove_in_progress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) ioc->put_smid_hi_priority(ioc, smid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) mpt3sas_trigger_master(ioc, MASTER_TRIGGER_DEVICE_REMOVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) * _scsih_tm_tr_complete -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) * This is the target reset completion routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) * This code is part of the code to initiate the device removal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) * handshake protocol with controller firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) * It will send a sas iounit control request (MPI2_SAS_OP_REMOVE_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) _scsih_tm_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) Mpi2SCSITaskManagementRequest_t *mpi_request_tm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) Mpi2SCSITaskManagementReply_t *mpi_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) Mpi2SasIoUnitControlRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) u16 smid_sas_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) struct _sc_list *delayed_sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) if (ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) ioc_info(ioc, "%s: host in pci error recovery\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) ioc_info(ioc, "%s: host is not operational\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) if (unlikely(!mpi_reply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) mpi_request_tm = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) handle = le16_to_cpu(mpi_request_tm->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) if (handle != le16_to_cpu(mpi_reply->DevHandle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) le16_to_cpu(mpi_reply->DevHandle), smid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) mpt3sas_trigger_master(ioc, MASTER_TRIGGER_TASK_MANAGMENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) ioc_info(ioc, "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x), completed(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) handle, smid, le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) le32_to_cpu(mpi_reply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) le32_to_cpu(mpi_reply->TerminationCount)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) smid_sas_ctrl = mpt3sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) if (!smid_sas_ctrl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) delayed_sc = kzalloc(sizeof(*delayed_sc), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) if (!delayed_sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) return _scsih_check_for_pending_tm(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) INIT_LIST_HEAD(&delayed_sc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) delayed_sc->handle = le16_to_cpu(mpi_request_tm->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) list_add_tail(&delayed_sc->list, &ioc->delayed_sc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) ioc_info(ioc, "DELAYED:sc:handle(0x%04x), (open)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) return _scsih_check_for_pending_tm(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) handle, smid_sas_ctrl, ioc->tm_sas_control_cb_idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid_sas_ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) memset(mpi_request, 0, sizeof(Mpi2SasIoUnitControlRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) mpi_request->DevHandle = mpi_request_tm->DevHandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) ioc->put_smid_default(ioc, smid_sas_ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) return _scsih_check_for_pending_tm(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) /** _scsih_allow_scmd_to_device - check whether scmd needs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) * issue to IOC or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) * Returns true if scmd can be issued to IOC otherwise returns false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) inline bool _scsih_allow_scmd_to_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) if (ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) if (ioc->hba_mpi_version_belonged == MPI2_VERSION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) if (ioc->remove_host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) if (ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) switch (scmd->cmnd[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) case SYNCHRONIZE_CACHE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) case START_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) * _scsih_sas_control_complete - completion routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) * This is the sas iounit control completion routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) * This code is part of the code to initiate the device removal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) * handshake protocol with controller firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) _scsih_sas_control_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) u8 msix_index, u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) Mpi2SasIoUnitControlReply_t *mpi_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) if (likely(mpi_reply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) ioc_info(ioc, "sc_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) le16_to_cpu(mpi_reply->DevHandle), smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) le32_to_cpu(mpi_reply->IOCLogInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) if (le16_to_cpu(mpi_reply->IOCStatus) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) clear_bit(le16_to_cpu(mpi_reply->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) ioc->device_remove_in_progress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) return mpt3sas_check_for_pending_internal_cmds(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) * _scsih_tm_tr_volume_send - send target reset request for volumes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) * This is designed to send muliple task management request at the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) * time to the fifo. If the fifo is full, we will append the request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) * and process it in a future completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) _scsih_tm_tr_volume_send(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) Mpi2SCSITaskManagementRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) struct _tr_list *delayed_tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) if (ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) ioc_info(ioc, "%s: host reset in progress!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) smid = mpt3sas_base_get_smid_hpr(ioc, ioc->tm_tr_volume_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) delayed_tr = kzalloc(sizeof(*delayed_tr), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) if (!delayed_tr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) INIT_LIST_HEAD(&delayed_tr->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) delayed_tr->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) list_add_tail(&delayed_tr->list, &ioc->delayed_tr_volume_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) ioc_info(ioc, "tr_send:handle(0x%04x), (open), smid(%d), cb(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) handle, smid, ioc->tm_tr_volume_cb_idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) memset(mpi_request, 0, sizeof(Mpi2SCSITaskManagementRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) mpi_request->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) ioc->put_smid_hi_priority(ioc, smid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) * _scsih_tm_volume_tr_complete - target reset completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) _scsih_tm_volume_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) u8 msix_index, u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) Mpi2SCSITaskManagementRequest_t *mpi_request_tm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) Mpi2SCSITaskManagementReply_t *mpi_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) if (ioc->shost_recovery || ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) ioc_info(ioc, "%s: host reset in progress!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) if (unlikely(!mpi_reply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) mpi_request_tm = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) handle = le16_to_cpu(mpi_request_tm->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) if (handle != le16_to_cpu(mpi_reply->DevHandle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) ioc_err(ioc, "spurious interrupt: handle(0x%04x:0x%04x), smid(%d)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) handle, le16_to_cpu(mpi_reply->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) smid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) ioc_info(ioc, "tr_complete:handle(0x%04x), (open) smid(%d), ioc_status(0x%04x), loginfo(0x%08x), completed(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) handle, smid, le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) le32_to_cpu(mpi_reply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) le32_to_cpu(mpi_reply->TerminationCount)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) return _scsih_check_for_pending_tm(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) * _scsih_issue_delayed_event_ack - issue delayed Event ACK messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) * @event: Event ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) * @event_context: used to track events uniquely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) * Context - processed in interrupt context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) _scsih_issue_delayed_event_ack(struct MPT3SAS_ADAPTER *ioc, u16 smid, U16 event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) U32 event_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) Mpi2EventAckRequest_t *ack_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) int i = smid - ioc->internal_smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) /* Without releasing the smid just update the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) * call back index and reuse the same smid for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) * processing this delayed request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) ioc->internal_lookup[i].cb_idx = ioc->base_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) ioc_info(ioc, "EVENT ACK: event(0x%04x), smid(%d), cb(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) le16_to_cpu(event), smid, ioc->base_cb_idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) ack_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) memset(ack_request, 0, sizeof(Mpi2EventAckRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) ack_request->Function = MPI2_FUNCTION_EVENT_ACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) ack_request->Event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) ack_request->EventContext = event_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) ack_request->VF_ID = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) ack_request->VP_ID = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) * _scsih_issue_delayed_sas_io_unit_ctrl - issue delayed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) * sas_io_unit_ctrl messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) * Context - processed in interrupt context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) _scsih_issue_delayed_sas_io_unit_ctrl(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) u16 smid, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) Mpi2SasIoUnitControlRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) int i = smid - ioc->internal_smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) if (ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) ioc_info(ioc, "%s: host has been removed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) } else if (ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) ioc_info(ioc, "%s: host in pci error recovery\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) ioc_info(ioc, "%s: host is not operational\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) /* Without releasing the smid just update the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) * call back index and reuse the same smid for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) * processing this delayed request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) ioc->internal_lookup[i].cb_idx = ioc->tm_sas_control_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) ioc_info(ioc, "sc_send:handle(0x%04x), (open), smid(%d), cb(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) handle, smid, ioc->tm_sas_control_cb_idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) memset(mpi_request, 0, sizeof(Mpi2SasIoUnitControlRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) mpi_request->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) * _scsih_check_for_pending_internal_cmds - check for pending internal messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) * Context: Executed in interrupt context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) * This will check delayed internal messages list, and process the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) * next request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc, u16 smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) struct _sc_list *delayed_sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) struct _event_ack_list *delayed_event_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) if (!list_empty(&ioc->delayed_event_ack_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) delayed_event_ack = list_entry(ioc->delayed_event_ack_list.next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) struct _event_ack_list, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) _scsih_issue_delayed_event_ack(ioc, smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) delayed_event_ack->Event, delayed_event_ack->EventContext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) list_del(&delayed_event_ack->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) kfree(delayed_event_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) if (!list_empty(&ioc->delayed_sc_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) delayed_sc = list_entry(ioc->delayed_sc_list.next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) struct _sc_list, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) _scsih_issue_delayed_sas_io_unit_ctrl(ioc, smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) delayed_sc->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) list_del(&delayed_sc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) kfree(delayed_sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) * _scsih_check_for_pending_tm - check for pending task management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) * This will check delayed target reset list, and feed the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) * next reqeust.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) _scsih_check_for_pending_tm(struct MPT3SAS_ADAPTER *ioc, u16 smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) struct _tr_list *delayed_tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) if (!list_empty(&ioc->delayed_tr_volume_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) delayed_tr = list_entry(ioc->delayed_tr_volume_list.next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) struct _tr_list, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) _scsih_tm_tr_volume_send(ioc, delayed_tr->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) list_del(&delayed_tr->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) kfree(delayed_tr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) if (!list_empty(&ioc->delayed_tr_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) delayed_tr = list_entry(ioc->delayed_tr_list.next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) struct _tr_list, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) _scsih_tm_tr_send(ioc, delayed_tr->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) list_del(&delayed_tr->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) kfree(delayed_tr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) * _scsih_check_topo_delete_events - sanity check on topo events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) * @event_data: the event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) * This routine added to better handle cable breaker.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) * This handles the case where driver receives multiple expander
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) * add and delete events in a single shot. When there is a delete event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) * the routine will void any pending add events waiting in the event queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) _scsih_check_topo_delete_events(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) Mpi2EventDataSasTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) Mpi2EventDataSasTopologyChangeList_t *local_event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) u16 expander_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) struct _sas_node *sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) int i, reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) for (i = 0 ; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) reason_code = event_data->PHY[i].PhyStatus &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) MPI2_EVENT_SAS_TOPO_RC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) if (reason_code == MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) _scsih_tm_tr_send(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) expander_handle = le16_to_cpu(event_data->ExpanderDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) if (expander_handle < ioc->sas_hba.num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) _scsih_block_io_to_children_attached_directly(ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) if (event_data->ExpStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) MPI2_EVENT_SAS_TOPO_ES_DELAY_NOT_RESPONDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) /* put expander attached devices into blocking state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) sas_expander = mpt3sas_scsih_expander_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) expander_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) _scsih_block_io_to_children_attached_to_ex(ioc, sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) handle = find_first_bit(ioc->blocking_handles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) ioc->facts.MaxDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) if (handle < ioc->facts.MaxDevHandle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) _scsih_block_io_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) } while (test_and_clear_bit(handle, ioc->blocking_handles));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) } else if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) _scsih_block_io_to_children_attached_directly(ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) if (event_data->ExpStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) /* mark ignore flag for pending events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) list_for_each_entry(fw_event, &ioc->fw_event_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) fw_event->ignore)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) local_event_data = (Mpi2EventDataSasTopologyChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) if (local_event_data->ExpStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) MPI2_EVENT_SAS_TOPO_ES_ADDED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) local_event_data->ExpStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) MPI2_EVENT_SAS_TOPO_ES_RESPONDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) if (le16_to_cpu(local_event_data->ExpanderDevHandle) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) expander_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) ioc_info(ioc, "setting ignoring flag\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) fw_event->ignore = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) * _scsih_check_pcie_topo_remove_events - sanity check on topo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) * events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) * @event_data: the event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) * This handles the case where driver receives multiple switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) * or device add and delete events in a single shot. When there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) * is a delete event the routine will void any pending add
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) * events waiting in the event queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) _scsih_check_pcie_topo_remove_events(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) Mpi26EventDataPCIeTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) Mpi26EventDataPCIeTopologyChangeList_t *local_event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) int i, reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) u16 handle, switch_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) reason_code = event_data->PortEntry[i].PortStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) if (reason_code == MPI26_EVENT_PCIE_TOPO_PS_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) _scsih_tm_tr_send(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) switch_handle = le16_to_cpu(event_data->SwitchDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) if (!switch_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) _scsih_block_io_to_pcie_children_attached_directly(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) /* TODO We are not supporting cascaded PCIe Switch removal yet*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) if ((event_data->SwitchStatus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) == MPI26_EVENT_PCIE_TOPO_SS_DELAY_NOT_RESPONDING) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) (event_data->SwitchStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) MPI26_EVENT_PCIE_TOPO_SS_RESPONDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) _scsih_block_io_to_pcie_children_attached_directly(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) if (event_data->SwitchStatus != MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) /* mark ignore flag for pending events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) list_for_each_entry(fw_event, &ioc->fw_event_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) if (fw_event->event != MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) fw_event->ignore)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) local_event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) (Mpi26EventDataPCIeTopologyChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) if (local_event_data->SwitchStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) MPI2_EVENT_SAS_TOPO_ES_ADDED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) local_event_data->SwitchStatus ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) MPI2_EVENT_SAS_TOPO_ES_RESPONDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) if (le16_to_cpu(local_event_data->SwitchDevHandle) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) switch_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) ioc_info(ioc, "setting ignoring flag for switch event\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) fw_event->ignore = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) * _scsih_set_volume_delete_flag - setting volume delete flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) * This returns nothing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) _scsih_set_volume_delete_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) if (raid_device && raid_device->starget &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) raid_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) sas_target_priv_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) raid_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) ioc_info(ioc, "setting delete flag: handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) handle, (u64)raid_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) * _scsih_set_volume_handle_for_tr - set handle for target reset to volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) * @handle: input handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) * @a: handle for volume a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) * @b: handle for volume b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) * IR firmware only supports two raid volumes. The purpose of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) * routine is to set the volume handle in either a or b. When the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) * input handle is non-zero, or when a and b have not been set before.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) _scsih_set_volume_handle_for_tr(u16 handle, u16 *a, u16 *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) if (!handle || handle == *a || handle == *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) if (!*a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) *a = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) else if (!*b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) *b = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) * _scsih_check_ir_config_unhide_events - check for UNHIDE events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) * @event_data: the event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) * This routine will send target reset to volume, followed by target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) * resets to the PDs. This is called when a PD has been removed, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) * volume has been deleted or removed. When the target reset is sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) * to volume, the PD target resets need to be queued to start upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) * completion of the volume target reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) _scsih_check_ir_config_unhide_events(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) Mpi2EventDataIrConfigChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) Mpi2EventIrConfigElement_t *element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) u16 handle, volume_handle, a, b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) struct _tr_list *delayed_tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) a = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) b = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) if (ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) /* Volume Resets for Deleted or Removed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) if (le32_to_cpu(event_data->Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) if (element->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) element->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) MPI2_EVENT_IR_CHANGE_RC_REMOVED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) volume_handle = le16_to_cpu(element->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) _scsih_set_volume_delete_flag(ioc, volume_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) _scsih_set_volume_handle_for_tr(volume_handle, &a, &b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) /* Volume Resets for UNHIDE events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) if (le32_to_cpu(event_data->Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_UNHIDE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) volume_handle = le16_to_cpu(element->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) _scsih_set_volume_handle_for_tr(volume_handle, &a, &b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) if (a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) _scsih_tm_tr_volume_send(ioc, a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) if (b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) _scsih_tm_tr_volume_send(ioc, b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) /* PD target resets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) if (element->ReasonCode != MPI2_EVENT_IR_CHANGE_RC_UNHIDE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) handle = le16_to_cpu(element->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) volume_handle = le16_to_cpu(element->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) clear_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) if (!volume_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) _scsih_tm_tr_send(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) else if (volume_handle == a || volume_handle == b) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) delayed_tr = kzalloc(sizeof(*delayed_tr), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) BUG_ON(!delayed_tr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) INIT_LIST_HEAD(&delayed_tr->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) delayed_tr->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) list_add_tail(&delayed_tr->list, &ioc->delayed_tr_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) ioc_info(ioc, "DELAYED:tr:handle(0x%04x), (open)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) _scsih_tm_tr_send(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) * _scsih_check_volume_delete_events - set delete flag for volumes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) * @event_data: the event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) * This will handle the case when the cable connected to entire volume is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) * pulled. We will take care of setting the deleted flag so normal IO will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) * not be sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) _scsih_check_volume_delete_events(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) Mpi2EventDataIrVolume_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) u32 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) state = le32_to_cpu(event_data->NewValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) if (state == MPI2_RAID_VOL_STATE_MISSING || state ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) MPI2_RAID_VOL_STATE_FAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) _scsih_set_volume_delete_flag(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) le16_to_cpu(event_data->VolDevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) * _scsih_temp_threshold_events - display temperature threshold exceeded events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) * @event_data: the temp threshold event data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) * Context: interrupt time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) Mpi2EventDataTemperature_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) u32 doorbell;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) if (ioc->temp_sensors_count >= event_data->SensorNum) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) ioc_err(ioc, "Temperature Threshold flags %s%s%s%s exceeded for Sensor: %d !!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) le16_to_cpu(event_data->Status) & 0x1 ? "0 " : " ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) le16_to_cpu(event_data->Status) & 0x2 ? "1 " : " ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) le16_to_cpu(event_data->Status) & 0x4 ? "2 " : " ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) le16_to_cpu(event_data->Status) & 0x8 ? "3 " : " ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) event_data->SensorNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) ioc_err(ioc, "Current Temp In Celsius: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) event_data->CurrentTemperature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) doorbell = mpt3sas_base_get_iocstate(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) if ((doorbell & MPI2_IOC_STATE_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) MPI2_IOC_STATE_FAULT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) mpt3sas_print_fault_code(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) doorbell & MPI2_DOORBELL_DATA_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) } else if ((doorbell & MPI2_IOC_STATE_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) MPI2_IOC_STATE_COREDUMP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) mpt3sas_print_coredump_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) doorbell & MPI2_DOORBELL_DATA_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) if (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) if (pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) return test_and_set_bit(0, &priv->ata_command_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) clear_bit(0, &priv->ata_command_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) * _scsih_flush_running_cmds - completing outstanding commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) * The flushing out of all pending scmd commands following host reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) * where all IO is dropped to the floor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) struct scsiio_tracker *st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) if (!scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) _scsih_set_satl_pending(scmd, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) mpt3sas_base_clear_st(ioc, st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) scsi_dma_unmap(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) if (ioc->pci_error_recovery || ioc->remove_host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) dtmprintk(ioc, ioc_info(ioc, "completing %d cmds\n", count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) * _scsih_setup_eedp - setup MPI request for EEDP transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) * @mpi_request: pointer to the SCSI_IO request message frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) * Supporting protection 1 and 3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) Mpi25SCSIIORequest_t *mpi_request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) u16 eedp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) unsigned char prot_op = scsi_get_prot_op(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) unsigned char prot_type = scsi_get_prot_type(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) Mpi25SCSIIORequest_t *mpi_request_3v =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) (Mpi25SCSIIORequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) if (prot_type == SCSI_PROT_DIF_TYPE0 || prot_op == SCSI_PROT_NORMAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) if (prot_op == SCSI_PROT_READ_STRIP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) eedp_flags = MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) else if (prot_op == SCSI_PROT_WRITE_INSERT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) eedp_flags = MPI2_SCSIIO_EEDPFLAGS_INSERT_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) switch (prot_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) case SCSI_PROT_DIF_TYPE1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) case SCSI_PROT_DIF_TYPE2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) * enable ref/guard checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) * auto increment ref tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) mpi_request->CDB.EEDP32.PrimaryReferenceTag =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) cpu_to_be32(t10_pi_ref_tag(scmd->request));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) case SCSI_PROT_DIF_TYPE3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) * enable guard checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) mpi_request_3v->EEDPBlockSize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) cpu_to_le16(scmd->device->sector_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) if (ioc->is_gen35_ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) eedp_flags |= MPI25_SCSIIO_EEDPFLAGS_APPTAG_DISABLE_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) mpi_request->EEDPFlags = cpu_to_le16(eedp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) * _scsih_eedp_error_handling - return sense code for EEDP errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) * @ioc_status: ioc status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) u8 ascq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) switch (ioc_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) ascq = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) ascq = 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) ascq = 0x03;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) ascq = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST, 0x10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) ascq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) scmd->result = DRIVER_SENSE << 24 | (DID_ABORT << 16) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) * scsih_qcmd - main scsi request entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) * @shost: SCSI host pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) * The callback index is set inside `ioc->scsi_io_cb_idx`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) * Return: 0 on success. If there's a failure, return either:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) struct request *rq = scmd->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) int class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) Mpi25SCSIIORequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) u32 mpi_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) if (ioc->logging_level & MPT_DEBUG_SCSI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) scsi_print_command(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) sas_device_priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) if (!(_scsih_allow_scmd_to_device(ioc, scmd))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) sas_target_priv_data = sas_device_priv_data->sas_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) /* invalid device handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) handle = sas_target_priv_data->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) /* host recovery or link resets sent via IOCTLs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) return SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) } else if (sas_target_priv_data->deleted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) /* device has been deleted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) } else if (sas_target_priv_data->tm_busy ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) sas_device_priv_data->block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) /* device busy with task management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) return SCSI_MLQUEUE_DEVICE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) * Bug work around for firmware SATL handling. The loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) * is based on atomic operations and ensures consistency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) * since we're lockless at this point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) if (test_bit(0, &sas_device_priv_data->ata_command_pending))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) return SCSI_MLQUEUE_DEVICE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) } while (_scsih_set_satl_pending(scmd, true));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) if (scmd->sc_data_direction == DMA_FROM_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) mpi_control = MPI2_SCSIIO_CONTROL_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) else if (scmd->sc_data_direction == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) mpi_control = MPI2_SCSIIO_CONTROL_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) mpi_control = MPI2_SCSIIO_CONTROL_NODATATRANSFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) /* set tags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) /* NCQ Prio supported, make sure control indicated high priority */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) if (sas_device_priv_data->ncq_prio_enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) if (class == IOPRIO_CLASS_RT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) mpi_control |= 1 << MPI2_SCSIIO_CONTROL_CMDPRI_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) /* Make sure Device is not raid volume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) * We do not expose raid functionality to upper layer for warpdrive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) && !scsih_is_nvme(&scmd->device->sdev_gendev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) _scsih_set_satl_pending(scmd, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) memset(mpi_request, 0, ioc->request_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) _scsih_setup_eedp(ioc, scmd, mpi_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) if (scmd->cmd_len == 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) mpi_control |= 4 << MPI2_SCSIIO_CONTROL_ADDCDBLEN_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) MPT_TARGET_FLAGS_RAID_COMPONENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) mpi_request->Function = MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) mpi_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) mpi_request->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) mpi_request->DataLength = cpu_to_le32(scsi_bufflen(scmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) mpi_request->Control = cpu_to_le32(mpi_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) mpi_request->MsgFlags = MPI2_SCSIIO_MSGFLAGS_SYSTEM_SENSE_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) mpi_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) mpi_request->SenseBufferLowAddress =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) mpt3sas_base_get_sense_buffer_dma(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) mpi_request->SGLOffset0 = offsetof(Mpi25SCSIIORequest_t, SGL) / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) mpi_request->LUN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) if (mpi_request->DataLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) pcie_device = sas_target_priv_data->pcie_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) _scsih_set_satl_pending(scmd, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) ioc->build_zero_len_sge(ioc, &mpi_request->SGL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) raid_device = sas_target_priv_data->raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) if (raid_device && raid_device->direct_io_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) mpt3sas_setup_direct_io(ioc, scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) raid_device, mpi_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) mpi_request->IoFlags = cpu_to_le16(scmd->cmd_len |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) MPI25_SCSIIO_IOFLAGS_FAST_PATH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) ioc->put_smid_fast_path(ioc, smid, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) ioc->put_smid_scsi_io(ioc, smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) le16_to_cpu(mpi_request->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) return SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) * _scsih_normalize_sense - normalize descriptor and fixed format sense data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) * @sense_buffer: sense data returned by target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) * @data: normalized skey/asc/ascq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) _scsih_normalize_sense(char *sense_buffer, struct sense_info *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) if ((sense_buffer[0] & 0x7F) >= 0x72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) /* descriptor format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) data->skey = sense_buffer[1] & 0x0F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) data->asc = sense_buffer[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) data->ascq = sense_buffer[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) /* fixed format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) data->skey = sense_buffer[2] & 0x0F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) data->asc = sense_buffer[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) data->ascq = sense_buffer[13];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) * _scsih_scsi_ioc_info - translated non-succesfull SCSI_IO request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) * @scmd: pointer to scsi command object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) * @mpi_reply: reply mf payload returned from firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) * @smid: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) * scsi_status - SCSI Status code returned from target device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) * scsi_state - state info associated with SCSI_IO determined by ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) * ioc_status - ioc supplied status info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) Mpi2SCSIIOReply_t *mpi_reply, u16 smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) u32 response_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) u8 *response_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) u16 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) u8 scsi_state = mpi_reply->SCSIState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) u8 scsi_status = mpi_reply->SCSIStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) char *desc_ioc_state = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) char *desc_scsi_status = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) char *desc_scsi_state = ioc->tmp_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) struct scsi_target *starget = scmd->device->sdev_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) struct MPT3SAS_TARGET *priv_target = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) char *device_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) if (!priv_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) if (ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) device_str = "WarpDrive";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) device_str = "volume";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) if (log_info == 0x31170000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) switch (ioc_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) case MPI2_IOCSTATUS_SUCCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) desc_ioc_state = "success";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) case MPI2_IOCSTATUS_INVALID_FUNCTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) desc_ioc_state = "invalid function";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) desc_ioc_state = "scsi recovered error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) case MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) desc_ioc_state = "scsi invalid dev handle";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) desc_ioc_state = "scsi device not there";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) case MPI2_IOCSTATUS_SCSI_DATA_OVERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) desc_ioc_state = "scsi data overrun";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) case MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) desc_ioc_state = "scsi data underrun";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) case MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) desc_ioc_state = "scsi io data error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) desc_ioc_state = "scsi protocol error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) desc_ioc_state = "scsi task terminated";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) desc_ioc_state = "scsi residual mismatch";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) desc_ioc_state = "scsi task mgmt failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) desc_ioc_state = "scsi ioc terminated";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) desc_ioc_state = "scsi ext terminated";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) desc_ioc_state = "eedp guard error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) desc_ioc_state = "eedp ref tag error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) desc_ioc_state = "eedp app tag error";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) case MPI2_IOCSTATUS_INSUFFICIENT_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) desc_ioc_state = "insufficient power";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) desc_ioc_state = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) switch (scsi_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) case MPI2_SCSI_STATUS_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) desc_scsi_status = "good";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) case MPI2_SCSI_STATUS_CHECK_CONDITION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) desc_scsi_status = "check condition";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) case MPI2_SCSI_STATUS_CONDITION_MET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) desc_scsi_status = "condition met";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) case MPI2_SCSI_STATUS_BUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) desc_scsi_status = "busy";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) case MPI2_SCSI_STATUS_INTERMEDIATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) desc_scsi_status = "intermediate";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) case MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) desc_scsi_status = "intermediate condmet";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) case MPI2_SCSI_STATUS_RESERVATION_CONFLICT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) desc_scsi_status = "reservation conflict";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) case MPI2_SCSI_STATUS_COMMAND_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) desc_scsi_status = "command terminated";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) case MPI2_SCSI_STATUS_TASK_SET_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) desc_scsi_status = "task set full";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) case MPI2_SCSI_STATUS_ACA_ACTIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) desc_scsi_status = "aca active";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) case MPI2_SCSI_STATUS_TASK_ABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) desc_scsi_status = "task aborted";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) desc_scsi_status = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) desc_scsi_state[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) if (!scsi_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) desc_scsi_state = " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) strcat(desc_scsi_state, "response info ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) strcat(desc_scsi_state, "state terminated ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) if (scsi_state & MPI2_SCSI_STATE_NO_SCSI_STATUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) strcat(desc_scsi_state, "no status ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_FAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) strcat(desc_scsi_state, "autosense failed ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) strcat(desc_scsi_state, "autosense valid ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) scsi_print_command(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) ioc_warn(ioc, "\t%s wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) device_str, (u64)priv_target->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) ioc_info(ioc, "\twwid(0x%016llx), port(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) (u64)pcie_device->wwid, pcie_device->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) ioc_info(ioc, "\tenclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) if (pcie_device->connector_name[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) ioc_info(ioc, "\tenclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) pcie_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) ioc_warn(ioc, "\tsas_address(0x%016llx), phy(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) (u64)sas_device->sas_address, sas_device->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) _scsih_display_enclosure_chassis_info(ioc, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) ioc_warn(ioc, "\thandle(0x%04x), ioc_status(%s)(0x%04x), smid(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) le16_to_cpu(mpi_reply->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) desc_ioc_state, ioc_status, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) ioc_warn(ioc, "\trequest_len(%d), underflow(%d), resid(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) scsi_bufflen(scmd), scmd->underflow, scsi_get_resid(scmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) ioc_warn(ioc, "\ttag(%d), transfer_count(%d), sc->result(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) le16_to_cpu(mpi_reply->TaskTag),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) le32_to_cpu(mpi_reply->TransferCount), scmd->result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) ioc_warn(ioc, "\tscsi_status(%s)(0x%02x), scsi_state(%s)(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) desc_scsi_status, scsi_status, desc_scsi_state, scsi_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) struct sense_info data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) _scsih_normalize_sense(scmd->sense_buffer, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) ioc_warn(ioc, "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) data.skey, data.asc, data.ascq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) le32_to_cpu(mpi_reply->SenseCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) response_info = le32_to_cpu(mpi_reply->ResponseInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) response_bytes = (u8 *)&response_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) _scsih_response_code(ioc, response_bytes[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) * _scsih_turn_on_pfa_led - illuminate PFA LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) * Context: process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) _scsih_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) Mpi2SepReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) Mpi2SepRequest_t mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) memset(&mpi_request, 0, sizeof(Mpi2SepRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) mpi_request.Function = MPI2_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) mpi_request.Action = MPI2_SEP_REQ_ACTION_WRITE_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) mpi_request.SlotStatus =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) cpu_to_le32(MPI2_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) mpi_request.DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) mpi_request.Flags = MPI2_SEP_REQ_FLAGS_DEVHANDLE_ADDRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) if ((mpt3sas_base_scsi_enclosure_processor(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) &mpi_request)) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) sas_device->pfa_led_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) ioc_info(ioc, "enclosure_processor: ioc_status (0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) le16_to_cpu(mpi_reply.IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) le32_to_cpu(mpi_reply.IOCLogInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) * _scsih_turn_off_pfa_led - turn off Fault LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) * @sas_device: sas device whose PFA LED has to turned off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) * Context: process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) _scsih_turn_off_pfa_led(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) Mpi2SepReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) Mpi2SepRequest_t mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) memset(&mpi_request, 0, sizeof(Mpi2SepRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) mpi_request.Function = MPI2_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) mpi_request.Action = MPI2_SEP_REQ_ACTION_WRITE_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) mpi_request.SlotStatus = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) mpi_request.Slot = cpu_to_le16(sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) mpi_request.DevHandle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) mpi_request.EnclosureHandle = cpu_to_le16(sas_device->enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) mpi_request.Flags = MPI2_SEP_REQ_FLAGS_ENCLOSURE_SLOT_ADDRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) if ((mpt3sas_base_scsi_enclosure_processor(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) &mpi_request)) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) ioc_info(ioc, "enclosure_processor: ioc_status (0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) le16_to_cpu(mpi_reply.IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) le32_to_cpu(mpi_reply.IOCLogInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) * _scsih_send_event_to_turn_on_pfa_led - fire delayed event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) * Context: interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) _scsih_send_event_to_turn_on_pfa_led(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) fw_event = alloc_fw_event_work(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) if (!fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) fw_event->event = MPT3SAS_TURN_ON_PFA_LED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) fw_event->device_handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) _scsih_fw_event_add(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) * _scsih_smart_predicted_fault - process smart errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) * Context: interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) _scsih_smart_predicted_fault(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) Mpi2EventNotificationReply_t *event_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) Mpi2EventDataSasDeviceStatusChange_t *event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) ssize_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) /* only handle non-raid devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) starget = sas_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) if ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_RAID_COMPONENT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) ((sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) _scsih_display_enclosure_chassis_info(NULL, sas_device, NULL, starget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) if (ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) _scsih_send_event_to_turn_on_pfa_led(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) /* insert into event log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) sz = offsetof(Mpi2EventNotificationReply_t, EventData) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) sizeof(Mpi2EventDataSasDeviceStatusChange_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) event_reply = kzalloc(sz, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) if (!event_reply) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) event_reply->Function = MPI2_FUNCTION_EVENT_NOTIFICATION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) event_reply->Event =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) cpu_to_le16(MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) event_reply->MsgLength = sz/4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) event_reply->EventDataLength =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) cpu_to_le16(sizeof(Mpi2EventDataSasDeviceStatusChange_t)/4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) event_data = (Mpi2EventDataSasDeviceStatusChange_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) event_reply->EventData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) event_data->ReasonCode = MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) event_data->ASC = 0x5D;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) event_data->DevHandle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) event_data->SASAddress = cpu_to_le64(sas_target_priv_data->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) mpt3sas_ctl_add_to_event_log(ioc, event_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) kfree(event_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) * _scsih_io_done - scsi request callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) * Callback handler when using _scsih_qcmd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) Mpi25SCSIIORequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) Mpi2SCSIIOReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) struct scsiio_tracker *st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) u32 xfer_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) u8 scsi_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) u8 scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) u32 log_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) u32 response_code = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) if (scmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529) _scsih_set_satl_pending(scmd, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) if (mpi_reply == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) scmd->result = DID_OK << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) sas_device_priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) sas_device_priv_data->sas_target->deleted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) ioc_status = le16_to_cpu(mpi_reply->IOCStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) * WARPDRIVE: If direct_io is set then it is directIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) * the failed direct I/O should be redirected to volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) if (st->direct_io &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) ((ioc_status & MPI2_IOCSTATUS_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) != MPI2_IOCSTATUS_SCSI_TASK_TERMINATED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) st->direct_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) st->scmd = scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) mpi_request->DevHandle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) cpu_to_le16(sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) ioc->put_smid_scsi_io(ioc, smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) /* turning off TLR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) scsi_state = mpi_reply->SCSIState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) response_code =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) if (!sas_device_priv_data->tlr_snoop_check) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) sas_device_priv_data->tlr_snoop_check++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) if ((!ioc->is_warpdrive &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) !scsih_is_raid(&scmd->device->sdev_gendev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) !scsih_is_nvme(&scmd->device->sdev_gendev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) && sas_is_tlr_enabled(scmd->device) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) response_code == MPI2_SCSITASKMGMT_RSP_INVALID_FRAME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) sas_disable_tlr(scmd->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) log_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) ioc_status &= MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) scsi_status = mpi_reply->SCSIStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) if (ioc_status == MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN && xfer_cnt == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) (scsi_status == MPI2_SCSI_STATUS_BUSY ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) scsi_status == MPI2_SCSI_STATUS_RESERVATION_CONFLICT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) scsi_status == MPI2_SCSI_STATUS_TASK_SET_FULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) ioc_status = MPI2_IOCSTATUS_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) struct sense_info data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) const void *sense_data = mpt3sas_base_get_sense_buffer(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) u32 sz = min_t(u32, SCSI_SENSE_BUFFERSIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) le32_to_cpu(mpi_reply->SenseCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) memcpy(scmd->sense_buffer, sense_data, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) _scsih_normalize_sense(scmd->sense_buffer, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) /* failure prediction threshold exceeded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) if (data.asc == 0x5D)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) _scsih_smart_predicted_fault(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) le16_to_cpu(mpi_reply->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) mpt3sas_trigger_scsi(ioc, data.skey, data.asc, data.ascq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) if ((ioc->logging_level & MPT_DEBUG_REPLY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) ((scmd->sense_buffer[2] == UNIT_ATTENTION) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) (scmd->sense_buffer[2] == MEDIUM_ERROR) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) (scmd->sense_buffer[2] == HARDWARE_ERROR)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) _scsih_scsi_ioc_info(ioc, scmd, mpi_reply, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) switch (ioc_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) case MPI2_IOCSTATUS_BUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) case MPI2_IOCSTATUS_INSUFFICIENT_RESOURCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) scmd->result = SAM_STAT_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) if (sas_device_priv_data->block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) scmd->result = DID_TRANSPORT_DISRUPTED << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) if (log_info == 0x31110630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) if (scmd->retries > 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) scmd->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) scsi_device_set_state(scmd->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) SDEV_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) scmd->device->expecting_cc_ua = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) } else if (log_info == VIRTUAL_IO_FAILED_RETRY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) } else if ((scmd->device->channel == RAID_CHANNEL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) (scsi_state == (MPI2_SCSI_STATE_TERMINATED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) MPI2_SCSI_STATE_NO_SCSI_STATUS))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) if ((xfer_cnt == 0) || (scmd->underflow > xfer_cnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) scmd->result = (DID_OK << 16) | scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) case MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) scmd->result = (DID_OK << 16) | scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) if ((scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) if (xfer_cnt < scmd->underflow) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) if (scsi_status == SAM_STAT_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) scmd->result = SAM_STAT_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) } else if (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) MPI2_SCSI_STATE_NO_SCSI_STATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) else if (!xfer_cnt && scmd->cmnd[0] == REPORT_LUNS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) mpi_reply->SCSIState = MPI2_SCSI_STATE_AUTOSENSE_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) mpi_reply->SCSIStatus = SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) scmd->result = (DRIVER_SENSE << 24) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) SAM_STAT_CHECK_CONDITION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) scmd->sense_buffer[0] = 0x70;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) scmd->sense_buffer[2] = ILLEGAL_REQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) scmd->sense_buffer[12] = 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) scmd->sense_buffer[13] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) case MPI2_IOCSTATUS_SCSI_DATA_OVERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) scsi_set_resid(scmd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) case MPI2_IOCSTATUS_SUCCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) scmd->result = (DID_OK << 16) | scsi_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) if (response_code ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) MPI2_SCSITASKMGMT_RSP_INVALID_FRAME ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) (scsi_state & (MPI2_SCSI_STATE_AUTOSENSE_FAILED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) MPI2_SCSI_STATE_NO_SCSI_STATUS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) else if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) scmd->result = DID_RESET << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) _scsih_eedp_error_handling(scmd, ioc_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) case MPI2_IOCSTATUS_INVALID_FUNCTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) case MPI2_IOCSTATUS_INVALID_SGL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) case MPI2_IOCSTATUS_INTERNAL_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) case MPI2_IOCSTATUS_INVALID_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) case MPI2_IOCSTATUS_INVALID_STATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) case MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) case MPI2_IOCSTATUS_INSUFFICIENT_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) scmd->result = DID_SOFT_ERROR << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) if (scmd->result && (ioc->logging_level & MPT_DEBUG_REPLY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) _scsih_scsi_ioc_info(ioc , scmd, mpi_reply, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) scsi_dma_unmap(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) scmd->scsi_done(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) * _scsih_sas_host_refresh - refreshing sas host object contents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) * Context: user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) * During port enable, fw will send topology events for every device. Its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) * possible that the handles may change from the previous setting, so this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) * code keeping handles updating if changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) u16 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) Mpi2SasIOUnitPage0_t *sas_iounit_pg0 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) u16 attached_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) u8 link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) ioc_info(ioc, "updating handles for sas_host(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) (u64)ioc->sas_hba.sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) * sizeof(Mpi2SasIOUnit0PhyData_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) if (!sas_iounit_pg0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) if ((mpt3sas_config_get_sas_iounit_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) sas_iounit_pg0, sz)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) for (i = 0; i < ioc->sas_hba.num_phys ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) if (i == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) PhyData[0].ControllerDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) attached_handle = le16_to_cpu(sas_iounit_pg0->PhyData[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) if (attached_handle && link_rate < MPI2_SAS_NEG_LINK_RATE_1_5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) link_rate = MPI2_SAS_NEG_LINK_RATE_1_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) attached_handle, i, link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) kfree(sas_iounit_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) * _scsih_sas_host_add - create sas host object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) * Creating host side data object, stored in ioc->sas_hba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) Mpi2SasIOUnitPage0_t *sas_iounit_pg0 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) Mpi2SasIOUnitPage1_t *sas_iounit_pg1 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) Mpi2SasPhyPage0_t phy_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) Mpi2SasEnclosurePage0_t enclosure_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) u16 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) u8 device_missing_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) u8 num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) mpt3sas_config_get_number_hba_phys(ioc, &num_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) if (!num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) ioc->sas_hba.phy = kcalloc(num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) sizeof(struct _sas_phy), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) if (!ioc->sas_hba.phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) ioc->sas_hba.num_phys = num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) /* sas_iounit page 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) sizeof(Mpi2SasIOUnit0PhyData_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) if (!sas_iounit_pg0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) if ((mpt3sas_config_get_sas_iounit_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) sas_iounit_pg0, sz))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) /* sas_iounit page 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) sizeof(Mpi2SasIOUnit1PhyData_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) if (!sas_iounit_pg1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) sas_iounit_pg1, sz))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) ioc->io_missing_delay =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) sas_iounit_pg1->IODeviceMissingDelay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) device_missing_delay =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) sas_iounit_pg1->ReportDeviceMissingDelay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) if (device_missing_delay & MPI2_SASIOUNIT1_REPORT_MISSING_UNIT_16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) ioc->device_missing_delay = (device_missing_delay &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK) * 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) ioc->device_missing_delay = device_missing_delay &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) ioc->sas_hba.parent_dev = &ioc->shost->shost_gendev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) for (i = 0; i < ioc->sas_hba.num_phys ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) if ((mpt3sas_config_get_phy_pg0(ioc, &mpi_reply, &phy_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) i))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) if (i == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) ioc->sas_hba.handle = le16_to_cpu(sas_iounit_pg0->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) PhyData[0].ControllerDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) ioc->sas_hba.phy[i].phy_id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) phy_pg0, ioc->sas_hba.parent_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, ioc->sas_hba.handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) ioc->sas_hba.enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) le16_to_cpu(sas_device_pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) ioc->sas_hba.sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) ioc_info(ioc, "host_add: handle(0x%04x), sas_addr(0x%016llx), phys(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) ioc->sas_hba.handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) (u64)ioc->sas_hba.sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) ioc->sas_hba.num_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) if (ioc->sas_hba.enclosure_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) if (!(mpt3sas_config_get_enclosure_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) &enclosure_pg0, MPI2_SAS_ENCLOS_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) ioc->sas_hba.enclosure_handle)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) ioc->sas_hba.enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) le64_to_cpu(enclosure_pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) kfree(sas_iounit_pg1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) kfree(sas_iounit_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) * _scsih_expander_add - creating expander object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) * @handle: expander handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) * Creating expander object, stored in ioc->sas_expander_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) * Return: 0 for success, else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) struct _sas_node *sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) struct _enclosure_node *enclosure_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) Mpi2ExpanderPage0_t expander_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) Mpi2ExpanderPage1_t expander_pg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) u16 parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) u64 sas_address, sas_address_parent = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) struct _sas_port *mpt3sas_port = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) if (ioc->shost_recovery || ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) if ((mpt3sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) MPI2_SAS_EXPAND_PGAD_FORM_HNDL, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) /* handle out of order topology events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) parent_handle = le16_to_cpu(expander_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) if (_scsih_get_sas_address(ioc, parent_handle, &sas_address_parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) if (sas_address_parent != ioc->sas_hba.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) if (!sas_expander) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) rc = _scsih_expander_add(ioc, parent_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001) if (rc != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) sas_address = le64_to_cpu(expander_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) if (sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) sas_expander = kzalloc(sizeof(struct _sas_node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) if (!sas_expander) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) sas_expander->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) sas_expander->num_phys = expander_pg0.NumPhys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) sas_expander->sas_address_parent = sas_address_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) sas_expander->sas_address = sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) ioc_info(ioc, "expander_add: handle(0x%04x), parent(0x%04x), sas_addr(0x%016llx), phys(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) handle, parent_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) (u64)sas_expander->sas_address, sas_expander->num_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) if (!sas_expander->num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) sas_expander->phy = kcalloc(sas_expander->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) sizeof(struct _sas_phy), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) if (!sas_expander->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) INIT_LIST_HEAD(&sas_expander->sas_port_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) mpt3sas_port = mpt3sas_transport_port_add(ioc, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) if (!mpt3sas_port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) sas_expander->parent_dev = &mpt3sas_port->rphy->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) for (i = 0 ; i < sas_expander->num_phys ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) if ((mpt3sas_config_get_expander_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) &expander_pg1, i, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064) sas_expander->phy[i].handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) sas_expander->phy[i].phy_id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) if ((mpt3sas_transport_add_expander_phy(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) &sas_expander->phy[i], expander_pg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) sas_expander->parent_dev))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077) if (sas_expander->enclosure_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) sas_expander->enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081) if (enclosure_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) sas_expander->enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086) _scsih_expander_node_add(ioc, sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) out_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) if (mpt3sas_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) mpt3sas_transport_port_remove(ioc, sas_expander->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093) sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) kfree(sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) * mpt3sas_expander_remove - removing expander object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) * @sas_address: expander sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) struct _sas_node *sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) if (sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) _scsih_expander_node_remove(ioc, sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) * _scsih_done - internal SCSI_IO callback handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) * Callback handler when sending internal generated SCSI_IO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128) * The callback index passed is `ioc->scsih_cb_idx`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) _scsih_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) MPI2DefaultReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) if (ioc->scsih_cmds.status == MPT3_CMD_NOT_USED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141) if (ioc->scsih_cmds.smid != smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) ioc->scsih_cmds.status |= MPT3_CMD_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) if (mpi_reply) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) memcpy(ioc->scsih_cmds.reply, mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) mpi_reply->MsgLength*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) ioc->scsih_cmds.status |= MPT3_CMD_REPLY_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) ioc->scsih_cmds.status &= ~MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) complete(&ioc->scsih_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) #define MPT3_MAX_LUNS (255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) * _scsih_check_access_status - check access flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) * @sas_address: sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) * @handle: sas device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) * @access_status: errors returned during discovery of the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) * Return: 0 for success, else failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) _scsih_check_access_status(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) u16 handle, u8 access_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) u8 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) char *desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) switch (access_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) case MPI2_SAS_DEVICE0_ASTATUS_NO_ERRORS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) case MPI2_SAS_DEVICE0_ASTATUS_SATA_NEEDS_INITIALIZATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) case MPI2_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) desc = "sata capability failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184) case MPI2_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) desc = "sata affiliation conflict";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) case MPI2_SAS_DEVICE0_ASTATUS_ROUTE_NOT_ADDRESSABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) desc = "route not addressable";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) case MPI2_SAS_DEVICE0_ASTATUS_SMP_ERROR_NOT_ADDRESSABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) desc = "smp error not addressable";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) case MPI2_SAS_DEVICE0_ASTATUS_DEVICE_BLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) desc = "device blocked";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196) case MPI2_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) case MPI2_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) case MPI2_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199) case MPI2_SAS_DEVICE0_ASTATUS_SIF_DIAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200) case MPI2_SAS_DEVICE0_ASTATUS_SIF_IDENTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201) case MPI2_SAS_DEVICE0_ASTATUS_SIF_CHECK_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) case MPI2_SAS_DEVICE0_ASTATUS_SIF_PIO_SN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) case MPI2_SAS_DEVICE0_ASTATUS_SIF_MDMA_SN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) case MPI2_SAS_DEVICE0_ASTATUS_SIF_UDMA_SN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) case MPI2_SAS_DEVICE0_ASTATUS_SIF_ZONING_VIOLATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206) case MPI2_SAS_DEVICE0_ASTATUS_SIF_NOT_ADDRESSABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) case MPI2_SAS_DEVICE0_ASTATUS_SIF_MAX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208) desc = "sata initialization failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) desc = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) ioc_err(ioc, "discovery errors(%s): sas_address(0x%016llx), handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219) desc, (u64)sas_address, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224) * _scsih_check_device - checking device responsiveness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) * @parent_sas_address: sas address of parent expander or sas host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) * @handle: attached device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) * @phy_number: phy number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229) * @link_rate: new link rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232) _scsih_check_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233) u64 parent_sas_address, u16 handle, u8 phy_number, u8 link_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) struct _enclosure_node *enclosure_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254) /* wide port handling ~ we need only handle device once for the phy that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) * is matched in sas device page zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) if (phy_number != sas_device_pg0.PhyNum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) /* check if this is end device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262) if (!(_scsih_is_end_device(device_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266) sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) if (unlikely(sas_device->handle != handle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274) starget = sas_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277) "handle changed from(0x%04x) to (0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) sas_device->handle, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) sas_target_priv_data->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) sas_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) if (le16_to_cpu(sas_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) sas_device->enclosure_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) sas_device_pg0.EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) memcpy(sas_device->connector_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) sas_device_pg0.ConnectorName, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) sas_device->connector_name[4] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) sas_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) sas_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293) sas_device->enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294) le16_to_cpu(sas_device_pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295) sas_device->is_chassis_slot_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296) enclosure_dev = mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) sas_device->enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298) if (enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299) sas_device->enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301) if (le16_to_cpu(enclosure_dev->pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) MPI2_SAS_ENCLS0_FLAGS_CHASSIS_SLOT_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) sas_device->is_chassis_slot_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) sas_device->chassis_slot =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) enclosure_dev->pg0.ChassisSlot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310) /* check if device is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) if (!(le16_to_cpu(sas_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) MPI2_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) ioc_err(ioc, "device is not present handle(0x%04x), flags!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) /* check if there were any issues with discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) if (_scsih_check_access_status(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) sas_device_pg0.AccessStatus))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324) _scsih_ublock_io_device(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) * _scsih_add_device - creating sas device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) * @handle: sas device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) * @phy_num: phy number end device attached to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341) * @is_pd: is this hidden raid component
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343) * Creating end device object, stored in ioc->sas_device_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) * Return: 0 for success, non-zero for failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) u8 is_pd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354) struct _enclosure_node *enclosure_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374) /* check if this is end device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375) device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) if (!(_scsih_is_end_device(device_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) set_bit(handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) /* check if device is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) if (!(le16_to_cpu(sas_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) MPI2_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) ioc_err(ioc, "device is not present handle(0x04%x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389) /* check if there were any issues with discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) if (_scsih_check_access_status(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) sas_device_pg0.AccessStatus))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) sas_device = mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) clear_bit(handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) if (sas_device_pg0.EnclosureHandle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405) le16_to_cpu(sas_device_pg0.EnclosureHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6406) if (enclosure_dev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6407) ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6408) sas_device_pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6411) sas_device = kzalloc(sizeof(struct _sas_device),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6412) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6413) if (!sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6414) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6415) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6416) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6419) kref_init(&sas_device->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6420) sas_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6421) if (_scsih_get_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6422) le16_to_cpu(sas_device_pg0.ParentDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6423) &sas_device->sas_address_parent) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6424) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6425) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6426) sas_device->enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6427) le16_to_cpu(sas_device_pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6428) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6429) sas_device->slot =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6430) le16_to_cpu(sas_device_pg0.Slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6431) sas_device->device_info = device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6432) sas_device->sas_address = sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6433) sas_device->phy = sas_device_pg0.PhyNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6434) sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6435) MPI25_SAS_DEVICE0_FLAGS_FAST_PATH_CAPABLE) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6437) if (le16_to_cpu(sas_device_pg0.Flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6438) & MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6439) sas_device->enclosure_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6440) sas_device_pg0.EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6441) memcpy(sas_device->connector_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6442) sas_device_pg0.ConnectorName, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6443) sas_device->connector_name[4] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6444) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6445) sas_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6446) sas_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6448) /* get enclosure_logical_id & chassis_slot*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6449) sas_device->is_chassis_slot_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6450) if (enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6451) sas_device->enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6452) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6453) if (le16_to_cpu(enclosure_dev->pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6454) MPI2_SAS_ENCLS0_FLAGS_CHASSIS_SLOT_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6455) sas_device->is_chassis_slot_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6456) sas_device->chassis_slot =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6457) enclosure_dev->pg0.ChassisSlot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6461) /* get device name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6462) sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6464) if (ioc->wait_for_discovery_to_complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6465) _scsih_sas_device_init_add(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6466) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6467) _scsih_sas_device_add(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6469) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6470) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6473) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6474) * _scsih_remove_device - removing sas device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6475) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6476) * @sas_device: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6477) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6478) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6479) _scsih_remove_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6480) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6482) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6484) if ((ioc->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6485) (sas_device->pfa_led_on)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6486) _scsih_turn_off_pfa_led(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6487) sas_device->pfa_led_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6490) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6491) ioc_info(ioc, "%s: enter: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6492) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6493) sas_device->handle, (u64)sas_device->sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6495) dewtprintk(ioc, _scsih_display_enclosure_chassis_info(ioc, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6496) NULL, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6498) if (sas_device->starget && sas_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6499) sas_target_priv_data = sas_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6500) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6501) _scsih_ublock_io_device(ioc, sas_device->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6502) sas_target_priv_data->handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6503) MPT3SAS_INVALID_DEVICE_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6506) if (!ioc->hide_drives)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6507) mpt3sas_transport_port_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6508) sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6509) sas_device->sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6511) ioc_info(ioc, "removing handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6512) sas_device->handle, (u64)sas_device->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6514) _scsih_display_enclosure_chassis_info(ioc, sas_device, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6516) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6517) ioc_info(ioc, "%s: exit: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6518) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6519) sas_device->handle, (u64)sas_device->sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6520) dewtprintk(ioc, _scsih_display_enclosure_chassis_info(ioc, sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6521) NULL, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6524) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6525) * _scsih_sas_topology_change_event_debug - debug for topology event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6526) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6527) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6528) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6530) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6531) _scsih_sas_topology_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6532) Mpi2EventDataSasTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6534) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6535) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6536) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6537) u8 phy_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6538) char *status_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6539) u8 link_rate, prev_link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6541) switch (event_data->ExpStatus) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6542) case MPI2_EVENT_SAS_TOPO_ES_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6543) status_str = "add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6544) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6545) case MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6546) status_str = "remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6547) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6548) case MPI2_EVENT_SAS_TOPO_ES_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6549) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6550) status_str = "responding";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6551) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6552) case MPI2_EVENT_SAS_TOPO_ES_DELAY_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6553) status_str = "remove delay";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6554) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6555) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6556) status_str = "unknown status";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6557) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6559) ioc_info(ioc, "sas topology change: (%s)\n", status_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6560) pr_info("\thandle(0x%04x), enclosure_handle(0x%04x) " \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6561) "start_phy(%02d), count(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6562) le16_to_cpu(event_data->ExpanderDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6563) le16_to_cpu(event_data->EnclosureHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6564) event_data->StartPhyNum, event_data->NumEntries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6565) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6566) handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6567) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6568) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6569) phy_number = event_data->StartPhyNum + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6570) reason_code = event_data->PHY[i].PhyStatus &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6571) MPI2_EVENT_SAS_TOPO_RC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6572) switch (reason_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6573) case MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6574) status_str = "target add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6575) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6576) case MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6577) status_str = "target remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6578) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6579) case MPI2_EVENT_SAS_TOPO_RC_DELAY_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6580) status_str = "delay target remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6581) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6582) case MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6583) status_str = "link rate change";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6584) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6585) case MPI2_EVENT_SAS_TOPO_RC_NO_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6586) status_str = "target responding";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6587) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6588) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6589) status_str = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6590) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6592) link_rate = event_data->PHY[i].LinkRate >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6593) prev_link_rate = event_data->PHY[i].LinkRate & 0xF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6594) pr_info("\tphy(%02d), attached_handle(0x%04x): %s:" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6595) " link rate: new(0x%02x), old(0x%02x)\n", phy_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6596) handle, status_str, link_rate, prev_link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6601) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6602) * _scsih_sas_topology_change_event - handle topology changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6603) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6604) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6605) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6606) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6608) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6609) _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6610) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6611) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6612) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6613) u16 parent_handle, handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6614) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6615) u8 phy_number, max_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6616) struct _sas_node *sas_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6617) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6618) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6619) u8 link_rate, prev_link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6620) Mpi2EventDataSasTopologyChangeList_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6621) (Mpi2EventDataSasTopologyChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6622) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6624) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6625) _scsih_sas_topology_change_event_debug(ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6627) if (ioc->shost_recovery || ioc->remove_host || ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6628) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6630) if (!ioc->sas_hba.num_phys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6631) _scsih_sas_host_add(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6632) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6633) _scsih_sas_host_refresh(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6635) if (fw_event->ignore) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6636) dewtprintk(ioc, ioc_info(ioc, "ignoring expander event\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6637) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6640) parent_handle = le16_to_cpu(event_data->ExpanderDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6642) /* handle expander add */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6643) if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6644) if (_scsih_expander_add(ioc, parent_handle) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6645) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6647) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6648) sas_expander = mpt3sas_scsih_expander_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6649) parent_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6650) if (sas_expander) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6651) sas_address = sas_expander->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6652) max_phys = sas_expander->num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6653) } else if (parent_handle < ioc->sas_hba.num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6654) sas_address = ioc->sas_hba.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6655) max_phys = ioc->sas_hba.num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6656) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6657) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6658) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6660) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6662) /* handle siblings events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6663) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6664) if (fw_event->ignore) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6665) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6666) ioc_info(ioc, "ignoring expander event\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6667) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6669) if (ioc->remove_host || ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6670) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6671) phy_number = event_data->StartPhyNum + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6672) if (phy_number >= max_phys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6673) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6674) reason_code = event_data->PHY[i].PhyStatus &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6675) MPI2_EVENT_SAS_TOPO_RC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6676) if ((event_data->PHY[i].PhyStatus &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6677) MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT) && (reason_code !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6678) MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6679) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6680) handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6681) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6682) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6683) link_rate = event_data->PHY[i].LinkRate >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6684) prev_link_rate = event_data->PHY[i].LinkRate & 0xF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6685) switch (reason_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6686) case MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6688) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6689) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6691) if (link_rate == prev_link_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6692) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6694) mpt3sas_transport_update_links(ioc, sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6695) handle, phy_number, link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6697) if (link_rate < MPI2_SAS_NEG_LINK_RATE_1_5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6698) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6700) _scsih_check_device(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6701) phy_number, link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6703) if (!test_bit(handle, ioc->pend_os_device_add))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6704) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6706) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6708) case MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6710) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6711) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6713) mpt3sas_transport_update_links(ioc, sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6714) handle, phy_number, link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6716) _scsih_add_device(ioc, handle, phy_number, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6718) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6719) case MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6721) _scsih_device_remove_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6722) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6726) /* handle expander removal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6727) if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_NOT_RESPONDING &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6728) sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6729) mpt3sas_expander_remove(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6731) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6734) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6735) * _scsih_sas_device_status_change_event_debug - debug for device event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6736) * @ioc: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6737) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6738) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6739) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6740) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6741) _scsih_sas_device_status_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6742) Mpi2EventDataSasDeviceStatusChange_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6744) char *reason_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6746) switch (event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6747) case MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6748) reason_str = "smart data";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6749) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6750) case MPI2_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6751) reason_str = "unsupported device discovered";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6752) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6753) case MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6754) reason_str = "internal device reset";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6755) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6756) case MPI2_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6757) reason_str = "internal task abort";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6758) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6759) case MPI2_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6760) reason_str = "internal task abort set";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6761) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6762) case MPI2_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6763) reason_str = "internal clear task set";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6764) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6765) case MPI2_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6766) reason_str = "internal query task";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6767) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6768) case MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6769) reason_str = "sata init failure";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6770) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6771) case MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6772) reason_str = "internal device reset complete";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6773) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6774) case MPI2_EVENT_SAS_DEV_STAT_RC_CMP_TASK_ABORT_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6775) reason_str = "internal task abort complete";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6776) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6777) case MPI2_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6778) reason_str = "internal async notification";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6779) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6780) case MPI2_EVENT_SAS_DEV_STAT_RC_EXPANDER_REDUCED_FUNCTIONALITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6781) reason_str = "expander reduced functionality";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6782) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6783) case MPI2_EVENT_SAS_DEV_STAT_RC_CMP_EXPANDER_REDUCED_FUNCTIONALITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6784) reason_str = "expander reduced functionality complete";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6785) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6786) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6787) reason_str = "unknown reason";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6788) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6790) ioc_info(ioc, "device status change: (%s)\thandle(0x%04x), sas address(0x%016llx), tag(%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6791) reason_str, le16_to_cpu(event_data->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6792) (u64)le64_to_cpu(event_data->SASAddress),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6793) le16_to_cpu(event_data->TaskTag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6794) if (event_data->ReasonCode == MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6795) pr_cont(", ASC(0x%x), ASCQ(0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6796) event_data->ASC, event_data->ASCQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6797) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6800) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6801) * _scsih_sas_device_status_change_event - handle device status change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6802) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6803) * @event_data: The fw event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6804) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6805) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6806) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6807) _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6808) Mpi2EventDataSasDeviceStatusChange_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6809) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6810) struct MPT3SAS_TARGET *target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6811) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6812) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6813) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6815) /* In MPI Revision K (0xC), the internal device reset complete was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6816) * implemented, so avoid setting tm_busy flag for older firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6817) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6818) if ((ioc->facts.HeaderVersion >> 8) < 0xC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6819) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6821) if (event_data->ReasonCode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6822) MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6823) event_data->ReasonCode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6824) MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6825) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6827) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6828) sas_address = le64_to_cpu(event_data->SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6829) sas_device = __mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6830) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6832) if (!sas_device || !sas_device->starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6833) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6835) target_priv_data = sas_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6836) if (!target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6837) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6839) if (event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6840) MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6841) target_priv_data->tm_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6842) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6843) target_priv_data->tm_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6845) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6846) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6847) "%s tm_busy flag for handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6848) (target_priv_data->tm_busy == 1) ? "Enable" : "Disable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6849) target_priv_data->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6851) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6852) if (sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6853) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6855) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6859) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6860) * _scsih_check_pcie_access_status - check access flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6861) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6862) * @wwid: wwid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6863) * @handle: sas device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6864) * @access_status: errors returned during discovery of the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6865) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6866) * Return: 0 for success, else failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6867) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6868) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6869) _scsih_check_pcie_access_status(struct MPT3SAS_ADAPTER *ioc, u64 wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6870) u16 handle, u8 access_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6871) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6872) u8 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6873) char *desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6875) switch (access_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6876) case MPI26_PCIEDEV0_ASTATUS_NO_ERRORS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6877) case MPI26_PCIEDEV0_ASTATUS_NEEDS_INITIALIZATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6878) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6879) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6880) case MPI26_PCIEDEV0_ASTATUS_CAPABILITY_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6881) desc = "PCIe device capability failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6882) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6883) case MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6884) desc = "PCIe device blocked";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6885) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6886) "Device with Access Status (%s): wwid(0x%016llx), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6887) "handle(0x%04x)\n ll only be added to the internal list",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6888) desc, (u64)wwid, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6889) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6890) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6891) case MPI26_PCIEDEV0_ASTATUS_MEMORY_SPACE_ACCESS_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6892) desc = "PCIe device mem space access failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6893) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6894) case MPI26_PCIEDEV0_ASTATUS_UNSUPPORTED_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6895) desc = "PCIe device unsupported";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6896) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6897) case MPI26_PCIEDEV0_ASTATUS_MSIX_REQUIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6898) desc = "PCIe device MSIx Required";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6899) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6900) case MPI26_PCIEDEV0_ASTATUS_INIT_FAIL_MAX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6901) desc = "PCIe device init fail max";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6902) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6903) case MPI26_PCIEDEV0_ASTATUS_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6904) desc = "PCIe device status unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6905) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6906) case MPI26_PCIEDEV0_ASTATUS_NVME_READY_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6907) desc = "nvme ready timeout";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6908) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6909) case MPI26_PCIEDEV0_ASTATUS_NVME_DEVCFG_UNSUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6910) desc = "nvme device configuration unsupported";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6911) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6912) case MPI26_PCIEDEV0_ASTATUS_NVME_IDENTIFY_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6913) desc = "nvme identify failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6914) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6915) case MPI26_PCIEDEV0_ASTATUS_NVME_QCONFIG_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6916) desc = "nvme qconfig failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6917) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6918) case MPI26_PCIEDEV0_ASTATUS_NVME_QCREATION_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6919) desc = "nvme qcreation failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6920) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6921) case MPI26_PCIEDEV0_ASTATUS_NVME_EVENTCFG_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6922) desc = "nvme eventcfg failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6923) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6924) case MPI26_PCIEDEV0_ASTATUS_NVME_GET_FEATURE_STAT_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6925) desc = "nvme get feature stat failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6926) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6927) case MPI26_PCIEDEV0_ASTATUS_NVME_IDLE_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6928) desc = "nvme idle timeout";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6929) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6930) case MPI26_PCIEDEV0_ASTATUS_NVME_FAILURE_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6931) desc = "nvme failure status";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6932) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6933) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6934) ioc_err(ioc, "NVMe discovery error(0x%02x): wwid(0x%016llx), handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6935) access_status, (u64)wwid, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6936) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6939) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6940) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6942) ioc_info(ioc, "NVMe discovery error(%s): wwid(0x%016llx), handle(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6943) desc, (u64)wwid, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6944) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6947) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6948) * _scsih_pcie_device_remove_from_sml - removing pcie device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6949) * from SML and free up associated memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6950) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6951) * @pcie_device: the pcie_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6952) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6953) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6954) _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6955) struct _pcie_device *pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6957) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6959) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6960) ioc_info(ioc, "%s: enter: handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6961) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6962) pcie_device->handle, (u64)pcie_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6963) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6964) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6965) ioc_info(ioc, "%s: enter: enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6966) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6967) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6968) pcie_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6969) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6970) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6971) ioc_info(ioc, "%s: enter: enclosure level(0x%04x), connector name(%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6972) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6973) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6974) pcie_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6976) if (pcie_device->starget && pcie_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6977) sas_target_priv_data = pcie_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6978) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6979) _scsih_ublock_io_device(ioc, pcie_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6980) sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6983) ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6984) pcie_device->handle, (u64)pcie_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6985) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6986) ioc_info(ioc, "removing : enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6987) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6988) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6989) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6990) ioc_info(ioc, "removing: enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6991) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6992) pcie_device->connector_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6994) if (pcie_device->starget && (pcie_device->access_status !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6995) MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6996) scsi_remove_target(&pcie_device->starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6997) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6998) ioc_info(ioc, "%s: exit: handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6999) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7000) pcie_device->handle, (u64)pcie_device->wwid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7001) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7002) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7003) ioc_info(ioc, "%s: exit: enclosure logical id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7004) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7005) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7006) pcie_device->slot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7007) if (pcie_device->connector_name[0] != '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7008) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7009) ioc_info(ioc, "%s: exit: enclosure level(0x%04x), connector name( %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7010) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7011) pcie_device->enclosure_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7012) pcie_device->connector_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7014) kfree(pcie_device->serial_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7018) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7019) * _scsih_pcie_check_device - checking device responsiveness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7020) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7021) * @handle: attached device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7022) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7023) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7024) _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7025) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7026) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7027) Mpi26PCIeDevicePage0_t pcie_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7028) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7029) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7030) u64 wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7031) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7032) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7033) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7034) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7036) if ((mpt3sas_config_get_pcie_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7037) &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7038) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7040) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7041) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7042) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7044) /* check if this is end device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7045) device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7046) if (!(_scsih_is_nvme_pciescsi_device(device_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7047) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7049) wwid = le64_to_cpu(pcie_device_pg0.WWID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7050) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7051) pcie_device = __mpt3sas_get_pdev_by_wwid(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7053) if (!pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7054) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7055) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7058) if (unlikely(pcie_device->handle != handle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7059) starget = pcie_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7060) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7061) pcie_device->access_status = pcie_device_pg0.AccessStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7062) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7063) "handle changed from(0x%04x) to (0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7064) pcie_device->handle, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7065) sas_target_priv_data->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7066) pcie_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7068) if (le32_to_cpu(pcie_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7069) MPI26_PCIEDEV0_FLAGS_ENCL_LEVEL_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7070) pcie_device->enclosure_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7071) pcie_device_pg0.EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7072) memcpy(&pcie_device->connector_name[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7073) &pcie_device_pg0.ConnectorName[0], 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7074) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7075) pcie_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7076) pcie_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7080) /* check if device is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7081) if (!(le32_to_cpu(pcie_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7082) MPI26_PCIEDEV0_FLAGS_DEVICE_PRESENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7083) ioc_info(ioc, "device is not present handle(0x%04x), flags!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7084) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7085) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7086) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7087) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7090) /* check if there were any issues with discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7091) if (_scsih_check_pcie_access_status(ioc, wwid, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7092) pcie_device_pg0.AccessStatus)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7093) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7094) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7095) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7098) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7099) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7101) _scsih_ublock_io_device(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7103) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7107) * _scsih_pcie_add_device - creating pcie device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7108) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7109) * @handle: pcie device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7111) * Creating end device object, stored in ioc->pcie_device_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7112) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7113) * Return: 1 means queue the event later, 0 means complete the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7115) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7116) _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7118) Mpi26PCIeDevicePage0_t pcie_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7119) Mpi26PCIeDevicePage2_t pcie_device_pg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7120) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7121) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7122) struct _enclosure_node *enclosure_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7123) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7124) u64 wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7126) if ((mpt3sas_config_get_pcie_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7127) &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7128) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7129) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7130) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7132) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7133) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7134) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7135) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7136) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7137) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7140) set_bit(handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7141) wwid = le64_to_cpu(pcie_device_pg0.WWID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7143) /* check if device is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7144) if (!(le32_to_cpu(pcie_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7145) MPI26_PCIEDEV0_FLAGS_DEVICE_PRESENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7146) ioc_err(ioc, "device is not present handle(0x04%x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7147) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7148) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7151) /* check if there were any issues with discovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7152) if (_scsih_check_pcie_access_status(ioc, wwid, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7153) pcie_device_pg0.AccessStatus))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7154) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7156) if (!(_scsih_is_nvme_pciescsi_device(le32_to_cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7157) (pcie_device_pg0.DeviceInfo))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7158) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7160) pcie_device = mpt3sas_get_pdev_by_wwid(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7161) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7162) clear_bit(handle, ioc->pend_os_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7163) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7164) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7167) /* PCIe Device Page 2 contains read-only information about a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7168) * specific NVMe device; therefore, this page is only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7169) * valid for NVMe devices and skip for pcie devices of type scsi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7171) if (!(mpt3sas_scsih_is_pcie_scsi_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7172) le32_to_cpu(pcie_device_pg0.DeviceInfo)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7173) if (mpt3sas_config_get_pcie_device_pg2(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7174) &pcie_device_pg2, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7175) handle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7176) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7177) "failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7178) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7179) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7182) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7183) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7184) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7185) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7186) "failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7187) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7188) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7192) pcie_device = kzalloc(sizeof(struct _pcie_device), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7193) if (!pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7194) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7195) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7196) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7199) kref_init(&pcie_device->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7200) pcie_device->id = ioc->pcie_target_id++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7201) pcie_device->channel = PCIE_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7202) pcie_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7203) pcie_device->access_status = pcie_device_pg0.AccessStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7204) pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7205) pcie_device->wwid = wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7206) pcie_device->port_num = pcie_device_pg0.PortNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7207) pcie_device->fast_path = (le32_to_cpu(pcie_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7208) MPI26_PCIEDEV0_FLAGS_FAST_PATH_CAPABLE) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7210) pcie_device->enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7211) le16_to_cpu(pcie_device_pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7212) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7213) pcie_device->slot = le16_to_cpu(pcie_device_pg0.Slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7215) if (le32_to_cpu(pcie_device_pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7216) MPI26_PCIEDEV0_FLAGS_ENCL_LEVEL_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7217) pcie_device->enclosure_level = pcie_device_pg0.EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7218) memcpy(&pcie_device->connector_name[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7219) &pcie_device_pg0.ConnectorName[0], 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7220) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7221) pcie_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7222) pcie_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7225) /* get enclosure_logical_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7226) if (pcie_device->enclosure_handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7227) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7228) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7229) pcie_device->enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7230) if (enclosure_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7231) pcie_device->enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7232) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7234) /* TODO -- Add device name once FW supports it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7235) if (!(mpt3sas_scsih_is_pcie_scsi_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7236) le32_to_cpu(pcie_device_pg0.DeviceInfo)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7237) pcie_device->nvme_mdts =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7238) le32_to_cpu(pcie_device_pg2.MaximumDataTransferSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7239) pcie_device->shutdown_latency =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7240) le16_to_cpu(pcie_device_pg2.ShutdownLatency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7241) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7242) * Set IOC's max_shutdown_latency to drive's RTD3 Entry Latency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7243) * if drive's RTD3 Entry Latency is greater then IOC's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7244) * max_shutdown_latency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7246) if (pcie_device->shutdown_latency > ioc->max_shutdown_latency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7247) ioc->max_shutdown_latency =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7248) pcie_device->shutdown_latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7249) if (pcie_device_pg2.ControllerResetTO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7250) pcie_device->reset_timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7251) pcie_device_pg2.ControllerResetTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7252) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7253) pcie_device->reset_timeout = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7254) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7255) pcie_device->reset_timeout = 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7257) if (ioc->wait_for_discovery_to_complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7258) _scsih_pcie_device_init_add(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7259) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7260) _scsih_pcie_device_add(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7262) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7263) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7266) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7267) * _scsih_pcie_topology_change_event_debug - debug for topology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7268) * event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7269) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7270) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7271) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7273) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7274) _scsih_pcie_topology_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7275) Mpi26EventDataPCIeTopologyChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7277) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7278) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7279) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7280) u8 port_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7281) char *status_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7282) u8 link_rate, prev_link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7284) switch (event_data->SwitchStatus) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7285) case MPI26_EVENT_PCIE_TOPO_SS_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7286) status_str = "add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7287) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7288) case MPI26_EVENT_PCIE_TOPO_SS_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7289) status_str = "remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7290) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7291) case MPI26_EVENT_PCIE_TOPO_SS_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7292) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7293) status_str = "responding";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7294) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7295) case MPI26_EVENT_PCIE_TOPO_SS_DELAY_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7296) status_str = "remove delay";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7297) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7298) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7299) status_str = "unknown status";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7300) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7302) ioc_info(ioc, "pcie topology change: (%s)\n", status_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7303) pr_info("\tswitch_handle(0x%04x), enclosure_handle(0x%04x)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7304) "start_port(%02d), count(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7305) le16_to_cpu(event_data->SwitchDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7306) le16_to_cpu(event_data->EnclosureHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7307) event_data->StartPortNum, event_data->NumEntries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7308) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7309) handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7310) le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7311) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7312) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7313) port_number = event_data->StartPortNum + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7314) reason_code = event_data->PortEntry[i].PortStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7315) switch (reason_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7316) case MPI26_EVENT_PCIE_TOPO_PS_DEV_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7317) status_str = "target add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7319) case MPI26_EVENT_PCIE_TOPO_PS_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7320) status_str = "target remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7322) case MPI26_EVENT_PCIE_TOPO_PS_DELAY_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7323) status_str = "delay target remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7324) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7325) case MPI26_EVENT_PCIE_TOPO_PS_PORT_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7326) status_str = "link rate change";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7327) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7328) case MPI26_EVENT_PCIE_TOPO_PS_NO_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7329) status_str = "target responding";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7330) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7331) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7332) status_str = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7333) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7335) link_rate = event_data->PortEntry[i].CurrentPortInfo &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7336) MPI26_EVENT_PCIE_TOPO_PI_RATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7337) prev_link_rate = event_data->PortEntry[i].PreviousPortInfo &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7338) MPI26_EVENT_PCIE_TOPO_PI_RATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7339) pr_info("\tport(%02d), attached_handle(0x%04x): %s:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7340) " link rate: new(0x%02x), old(0x%02x)\n", port_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7341) handle, status_str, link_rate, prev_link_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7345) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7346) * _scsih_pcie_topology_change_event - handle PCIe topology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7347) * changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7348) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7349) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7350) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7351) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7352) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7353) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7354) _scsih_pcie_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7355) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7357) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7358) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7359) u16 reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7360) u8 link_rate, prev_link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7361) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7362) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7363) Mpi26EventDataPCIeTopologyChangeList_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7364) (Mpi26EventDataPCIeTopologyChangeList_t *) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7365) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7367) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7368) _scsih_pcie_topology_change_event_debug(ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7370) if (ioc->shost_recovery || ioc->remove_host ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7371) ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7372) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7374) if (fw_event->ignore) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7375) dewtprintk(ioc, ioc_info(ioc, "ignoring switch event\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7376) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7379) /* handle siblings events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7380) for (i = 0; i < event_data->NumEntries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7381) if (fw_event->ignore) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7382) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7383) ioc_info(ioc, "ignoring switch event\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7384) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7386) if (ioc->remove_host || ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7387) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7388) reason_code = event_data->PortEntry[i].PortStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7389) handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7390) le16_to_cpu(event_data->PortEntry[i].AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7391) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7392) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7394) link_rate = event_data->PortEntry[i].CurrentPortInfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7395) & MPI26_EVENT_PCIE_TOPO_PI_RATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7396) prev_link_rate = event_data->PortEntry[i].PreviousPortInfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7397) & MPI26_EVENT_PCIE_TOPO_PI_RATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7399) switch (reason_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7400) case MPI26_EVENT_PCIE_TOPO_PS_PORT_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7401) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7402) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7403) if (link_rate == prev_link_rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7405) if (link_rate < MPI26_EVENT_PCIE_TOPO_PI_RATE_2_5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7406) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7408) _scsih_pcie_check_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7410) /* This code after this point handles the test case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7411) * where a device has been added, however its returning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7412) * BUSY for sometime. Then before the Device Missing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7413) * Delay expires and the device becomes READY, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7414) * device is removed and added back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7416) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7417) pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7418) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7420) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7421) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7422) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7425) if (!test_bit(handle, ioc->pend_os_device_add))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7426) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7428) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7429) ioc_info(ioc, "handle(0x%04x) device not found: convert event to a device add\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7430) handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7431) event_data->PortEntry[i].PortStatus &= 0xF0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7432) event_data->PortEntry[i].PortStatus |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7433) MPI26_EVENT_PCIE_TOPO_PS_DEV_ADDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7434) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7435) case MPI26_EVENT_PCIE_TOPO_PS_DEV_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7436) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7437) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7438) if (link_rate < MPI26_EVENT_PCIE_TOPO_PI_RATE_2_5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7439) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7441) rc = _scsih_pcie_add_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7442) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7443) /* mark entry vacant */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7444) /* TODO This needs to be reviewed and fixed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7445) * we dont have an entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7446) * to make an event void like vacant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7447) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7448) event_data->PortEntry[i].PortStatus |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7449) MPI26_EVENT_PCIE_TOPO_PS_NO_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7451) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7452) case MPI26_EVENT_PCIE_TOPO_PS_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7453) _scsih_pcie_device_remove_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7454) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7459) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7460) * _scsih_pcie_device_status_change_event_debug - debug for device event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7461) * @ioc: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7462) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7463) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7465) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7466) _scsih_pcie_device_status_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7467) Mpi26EventDataPCIeDeviceStatusChange_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7469) char *reason_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7471) switch (event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7472) case MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7473) reason_str = "smart data";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7475) case MPI26_EVENT_PCIDEV_STAT_RC_UNSUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7476) reason_str = "unsupported device discovered";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7477) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7478) case MPI26_EVENT_PCIDEV_STAT_RC_INTERNAL_DEVICE_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7479) reason_str = "internal device reset";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7480) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7481) case MPI26_EVENT_PCIDEV_STAT_RC_TASK_ABORT_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7482) reason_str = "internal task abort";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7483) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7484) case MPI26_EVENT_PCIDEV_STAT_RC_ABORT_TASK_SET_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7485) reason_str = "internal task abort set";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7486) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7487) case MPI26_EVENT_PCIDEV_STAT_RC_CLEAR_TASK_SET_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7488) reason_str = "internal clear task set";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7489) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7490) case MPI26_EVENT_PCIDEV_STAT_RC_QUERY_TASK_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7491) reason_str = "internal query task";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7492) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7493) case MPI26_EVENT_PCIDEV_STAT_RC_DEV_INIT_FAILURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7494) reason_str = "device init failure";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7495) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7496) case MPI26_EVENT_PCIDEV_STAT_RC_CMP_INTERNAL_DEV_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7497) reason_str = "internal device reset complete";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7498) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7499) case MPI26_EVENT_PCIDEV_STAT_RC_CMP_TASK_ABORT_INTERNAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7500) reason_str = "internal task abort complete";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7501) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7502) case MPI26_EVENT_PCIDEV_STAT_RC_ASYNC_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7503) reason_str = "internal async notification";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7504) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7505) case MPI26_EVENT_PCIDEV_STAT_RC_PCIE_HOT_RESET_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7506) reason_str = "pcie hot reset failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7507) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7508) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7509) reason_str = "unknown reason";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7510) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7513) ioc_info(ioc, "PCIE device status change: (%s)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7514) "\thandle(0x%04x), WWID(0x%016llx), tag(%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7515) reason_str, le16_to_cpu(event_data->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7516) (u64)le64_to_cpu(event_data->WWID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7517) le16_to_cpu(event_data->TaskTag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7518) if (event_data->ReasonCode == MPI26_EVENT_PCIDEV_STAT_RC_SMART_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7519) pr_cont(", ASC(0x%x), ASCQ(0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7520) event_data->ASC, event_data->ASCQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7521) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7524) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7525) * _scsih_pcie_device_status_change_event - handle device status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7526) * change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7527) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7528) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7529) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7530) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7531) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7532) _scsih_pcie_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7533) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7535) struct MPT3SAS_TARGET *target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7536) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7537) u64 wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7538) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7539) Mpi26EventDataPCIeDeviceStatusChange_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7540) (Mpi26EventDataPCIeDeviceStatusChange_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7541) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7542) _scsih_pcie_device_status_change_event_debug(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7543) event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7545) if (event_data->ReasonCode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7546) MPI26_EVENT_PCIDEV_STAT_RC_INTERNAL_DEVICE_RESET &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7547) event_data->ReasonCode !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7548) MPI26_EVENT_PCIDEV_STAT_RC_CMP_INTERNAL_DEV_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7549) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7551) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7552) wwid = le64_to_cpu(event_data->WWID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7553) pcie_device = __mpt3sas_get_pdev_by_wwid(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7555) if (!pcie_device || !pcie_device->starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7556) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7558) target_priv_data = pcie_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7559) if (!target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7560) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7562) if (event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7563) MPI26_EVENT_PCIDEV_STAT_RC_INTERNAL_DEVICE_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7564) target_priv_data->tm_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7565) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7566) target_priv_data->tm_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7567) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7568) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7569) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7571) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7574) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7575) * _scsih_sas_enclosure_dev_status_change_event_debug - debug for enclosure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7576) * event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7577) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7578) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7579) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7580) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7581) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7582) _scsih_sas_enclosure_dev_status_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7583) Mpi2EventDataSasEnclDevStatusChange_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7584) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7585) char *reason_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7587) switch (event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7588) case MPI2_EVENT_SAS_ENCL_RC_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7589) reason_str = "enclosure add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7590) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7591) case MPI2_EVENT_SAS_ENCL_RC_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7592) reason_str = "enclosure remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7593) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7594) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7595) reason_str = "unknown reason";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7596) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7597) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7599) ioc_info(ioc, "enclosure status change: (%s)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7600) "\thandle(0x%04x), enclosure logical id(0x%016llx) number slots(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7601) reason_str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7602) le16_to_cpu(event_data->EnclosureHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7603) (u64)le64_to_cpu(event_data->EnclosureLogicalID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7604) le16_to_cpu(event_data->StartSlot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7607) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7608) * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7609) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7610) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7611) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7612) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7613) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7614) _scsih_sas_enclosure_dev_status_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7615) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7617) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7618) struct _enclosure_node *enclosure_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7619) Mpi2EventDataSasEnclDevStatusChange_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7620) (Mpi2EventDataSasEnclDevStatusChange_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7621) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7622) u16 enclosure_handle = le16_to_cpu(event_data->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7624) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7625) _scsih_sas_enclosure_dev_status_change_event_debug(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7626) (Mpi2EventDataSasEnclDevStatusChange_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7627) fw_event->event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7628) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7629) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7631) if (enclosure_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7632) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7633) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7634) enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7635) switch (event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7636) case MPI2_EVENT_SAS_ENCL_RC_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7637) if (!enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7638) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7639) kzalloc(sizeof(struct _enclosure_node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7640) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7641) if (!enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7642) ioc_info(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7643) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7644) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7646) rc = mpt3sas_config_get_enclosure_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7647) &enclosure_dev->pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7648) MPI2_SAS_ENCLOS_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7649) enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7651) if (rc || (le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7652) MPI2_IOCSTATUS_MASK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7653) kfree(enclosure_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7654) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7657) list_add_tail(&enclosure_dev->list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7658) &ioc->enclosure_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7660) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7661) case MPI2_EVENT_SAS_ENCL_RC_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7662) if (enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7663) list_del(&enclosure_dev->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7664) kfree(enclosure_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7666) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7667) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7668) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7672) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7673) * _scsih_sas_broadcast_primitive_event - handle broadcast events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7674) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7675) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7676) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7677) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7678) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7679) _scsih_sas_broadcast_primitive_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7680) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7681) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7682) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7683) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7684) struct scsiio_tracker *st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7685) u16 smid, handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7686) u32 lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7687) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7688) u32 termination_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7689) u32 query_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7690) Mpi2SCSITaskManagementReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7691) Mpi2EventDataSasBroadcastPrimitive_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7692) (Mpi2EventDataSasBroadcastPrimitive_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7693) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7694) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7695) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7696) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7697) u8 max_retries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7698) u8 task_abort_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7700) mutex_lock(&ioc->tm_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7701) ioc_info(ioc, "%s: enter: phy number(%d), width(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7702) __func__, event_data->PhyNum, event_data->PortWidth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7704) _scsih_block_io_all_device(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7706) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7707) mpi_reply = ioc->tm_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7708) broadcast_aen_retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7710) /* sanity checks for retrying this loop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7711) if (max_retries++ == 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7712) dewtprintk(ioc, ioc_info(ioc, "%s: giving up\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7713) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7714) } else if (max_retries > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7715) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7716) ioc_info(ioc, "%s: %d retry\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7717) __func__, max_retries - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7719) termination_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7720) query_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7721) for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7722) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7723) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7724) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7725) if (!scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7726) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7727) st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7728) sdev = scmd->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7729) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7730) if (!sas_device_priv_data || !sas_device_priv_data->sas_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7731) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7732) /* skip hidden raid components */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7733) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7734) MPT_TARGET_FLAGS_RAID_COMPONENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7735) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7736) /* skip volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7737) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7738) MPT_TARGET_FLAGS_VOLUME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7739) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7740) /* skip PCIe devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7741) if (sas_device_priv_data->sas_target->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7742) MPT_TARGET_FLAGS_PCIE_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7743) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7745) handle = sas_device_priv_data->sas_target->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7746) lun = sas_device_priv_data->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7747) query_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7749) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7750) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7752) spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7753) r = mpt3sas_scsih_issue_tm(ioc, handle, 0, 0, lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7754) MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, st->smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7755) st->msix_io, 30, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7756) if (r == FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7757) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7758) "mpt3sas_scsih_issue_tm: FAILED when sending "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7759) "QUERY_TASK: scmd(%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7760) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7761) goto broadcast_aen_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7763) ioc_status = le16_to_cpu(mpi_reply->IOCStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7764) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7765) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7766) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7767) "query task: FAILED with IOCSTATUS(0x%04x), scmd(%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7768) ioc_status, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7769) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7770) goto broadcast_aen_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7773) /* see if IO is still owned by IOC and target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7774) if (mpi_reply->ResponseCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7775) MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7776) mpi_reply->ResponseCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7777) MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7778) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7779) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7781) task_abort_retries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7782) tm_retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7783) if (task_abort_retries++ == 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7784) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7785) ioc_info(ioc, "%s: ABORT_TASK: giving up\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7786) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7787) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7788) goto broadcast_aen_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7791) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7792) goto out_no_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7794) r = mpt3sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7795) sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7796) st->smid, st->msix_io, 30, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7797) if (r == FAILED || st->cb_idx != 0xFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7798) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7799) "mpt3sas_scsih_issue_tm: ABORT_TASK: FAILED : "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7800) "scmd(%p)\n", scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7801) goto tm_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7804) if (task_abort_retries > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7805) sdev_printk(KERN_WARNING, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7806) "mpt3sas_scsih_issue_tm: ABORT_TASK: RETRIES (%d):"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7807) " scmd(%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7808) task_abort_retries - 1, scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7810) termination_count += le32_to_cpu(mpi_reply->TerminationCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7811) spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7814) if (ioc->broadcast_aen_pending) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7815) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7816) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7817) "%s: loop back due to pending AEN\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7818) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7819) ioc->broadcast_aen_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7820) goto broadcast_aen_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7823) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7824) spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7825) out_no_lock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7827) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7828) ioc_info(ioc, "%s - exit, query_count = %d termination_count = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7829) __func__, query_count, termination_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7831) ioc->broadcast_aen_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7832) if (!ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7833) _scsih_ublock_io_all_device(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7834) mutex_unlock(&ioc->tm_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7837) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7838) * _scsih_sas_discovery_event - handle discovery events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7839) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7840) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7841) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7842) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7843) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7844) _scsih_sas_discovery_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7845) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7846) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7847) Mpi2EventDataSasDiscovery_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7848) (Mpi2EventDataSasDiscovery_t *) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7850) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7851) ioc_info(ioc, "discovery event: (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7852) event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7853) "start" : "stop");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7854) if (event_data->DiscoveryStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7855) pr_cont("discovery_status(0x%08x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7856) le32_to_cpu(event_data->DiscoveryStatus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7857) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7860) if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7861) !ioc->sas_hba.num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7862) if (disable_discovery > 0 && ioc->shost_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7863) /* Wait for the reset to complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7864) while (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7865) ssleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7867) _scsih_sas_host_add(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7871) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7872) * _scsih_sas_device_discovery_error_event - display SAS device discovery error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7873) * events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7874) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7875) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7876) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7877) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7878) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7879) _scsih_sas_device_discovery_error_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7880) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7881) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7882) Mpi25EventDataSasDeviceDiscoveryError_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7883) (Mpi25EventDataSasDeviceDiscoveryError_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7885) switch (event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7886) case MPI25_EVENT_SAS_DISC_ERR_SMP_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7887) ioc_warn(ioc, "SMP command sent to the expander (handle:0x%04x, sas_address:0x%016llx, physical_port:0x%02x) has failed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7888) le16_to_cpu(event_data->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7889) (u64)le64_to_cpu(event_data->SASAddress),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7890) event_data->PhysicalPort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7891) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7892) case MPI25_EVENT_SAS_DISC_ERR_SMP_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7893) ioc_warn(ioc, "SMP command sent to the expander (handle:0x%04x, sas_address:0x%016llx, physical_port:0x%02x) has timed out\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7894) le16_to_cpu(event_data->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7895) (u64)le64_to_cpu(event_data->SASAddress),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7896) event_data->PhysicalPort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7897) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7898) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7899) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7901) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7903) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7904) * _scsih_pcie_enumeration_event - handle enumeration events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7905) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7906) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7907) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7908) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7909) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7910) _scsih_pcie_enumeration_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7911) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7913) Mpi26EventDataPCIeEnumeration_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7914) (Mpi26EventDataPCIeEnumeration_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7916) if (!(ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7917) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7919) ioc_info(ioc, "pcie enumeration event: (%s) Flag 0x%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7920) (event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7921) "started" : "completed",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7922) event_data->Flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7923) if (event_data->EnumerationStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7924) pr_cont("enumeration_status(0x%08x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7925) le32_to_cpu(event_data->EnumerationStatus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7926) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7929) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7930) * _scsih_ir_fastpath - turn on fastpath for IR physdisk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7931) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7932) * @handle: device handle for physical disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7933) * @phys_disk_num: physical disk number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7934) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7935) * Return: 0 for success, else failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7936) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7937) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7938) _scsih_ir_fastpath(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phys_disk_num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7939) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7940) Mpi2RaidActionRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7941) Mpi2RaidActionReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7942) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7943) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7944) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7945) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7946) u32 log_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7948) if (ioc->hba_mpi_version_belonged == MPI2_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7949) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7951) mutex_lock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7953) if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7954) ioc_err(ioc, "%s: scsih_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7955) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7956) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7958) ioc->scsih_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7960) smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7961) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7962) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7963) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7964) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7965) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7966) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7968) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7969) ioc->scsih_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7970) memset(mpi_request, 0, sizeof(Mpi2RaidActionRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7972) mpi_request->Function = MPI2_FUNCTION_RAID_ACTION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7973) mpi_request->Action = MPI2_RAID_ACTION_PHYSDISK_HIDDEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7974) mpi_request->PhysDiskNum = phys_disk_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7976) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7977) ioc_info(ioc, "IR RAID_ACTION: turning fast path on for handle(0x%04x), phys_disk_num (0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7978) handle, phys_disk_num));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7980) init_completion(&ioc->scsih_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7981) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7982) wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7984) if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7985) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7986) ioc->scsih_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7987) sizeof(Mpi2RaidActionRequest_t)/4, issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7988) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7989) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7992) if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7994) mpi_reply = ioc->scsih_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7995) ioc_status = le16_to_cpu(mpi_reply->IOCStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7996) if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7997) log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7998) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7999) log_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8000) ioc_status &= MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8001) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8002) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8003) ioc_info(ioc, "IR RAID_ACTION: failed: ioc_status(0x%04x), loginfo(0x%08x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8004) ioc_status, log_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8005) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8006) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8007) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8008) ioc_info(ioc, "IR RAID_ACTION: completed successfully\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8011) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8012) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8013) mutex_unlock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8015) if (issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8016) mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8017) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8018) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8020) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8021) * _scsih_reprobe_lun - reprobing lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8022) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8023) * @no_uld_attach: sdev->no_uld_attach flag setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8024) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8025) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8026) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8027) _scsih_reprobe_lun(struct scsi_device *sdev, void *no_uld_attach)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8029) sdev->no_uld_attach = no_uld_attach ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8030) sdev_printk(KERN_INFO, sdev, "%s raid component\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8031) sdev->no_uld_attach ? "hiding" : "exposing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8032) WARN_ON(scsi_device_reprobe(sdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8035) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8036) * _scsih_sas_volume_add - add new volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8037) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8038) * @element: IR config element data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8039) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8040) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8041) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8042) _scsih_sas_volume_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8043) Mpi2EventIrConfigElement_t *element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8044) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8045) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8046) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8047) u64 wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8048) u16 handle = le16_to_cpu(element->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8049) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8051) mpt3sas_config_get_volume_wwid(ioc, handle, &wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8052) if (!wwid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8053) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8054) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8055) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8058) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8059) raid_device = _scsih_raid_device_find_by_wwid(ioc, wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8060) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8062) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8063) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8065) raid_device = kzalloc(sizeof(struct _raid_device), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8066) if (!raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8067) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8068) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8069) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8072) raid_device->id = ioc->sas_id++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8073) raid_device->channel = RAID_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8074) raid_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8075) raid_device->wwid = wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8076) _scsih_raid_device_add(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8077) if (!ioc->wait_for_discovery_to_complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8078) rc = scsi_add_device(ioc->shost, RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8079) raid_device->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8080) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8081) _scsih_raid_device_remove(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8082) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8083) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8084) _scsih_determine_boot_device(ioc, raid_device, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8085) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8087) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8089) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8090) * _scsih_sas_volume_delete - delete volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8091) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8092) * @handle: volume device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8093) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8094) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8095) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8096) _scsih_sas_volume_delete(struct MPT3SAS_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8097) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8098) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8099) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8100) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8101) struct scsi_target *starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8103) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8104) raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8105) if (raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8106) if (raid_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8107) starget = raid_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8108) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8109) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8111) ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8112) raid_device->handle, (u64)raid_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8113) list_del(&raid_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8114) kfree(raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8116) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8117) if (starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8118) scsi_remove_target(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8121) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8122) * _scsih_sas_pd_expose - expose pd component to /dev/sdX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8123) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8124) * @element: IR config element data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8125) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8127) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8128) _scsih_sas_pd_expose(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8129) Mpi2EventIrConfigElement_t *element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8131) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8132) struct scsi_target *starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8133) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8134) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8135) u16 handle = le16_to_cpu(element->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8137) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8138) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8139) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8140) sas_device->volume_handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8141) sas_device->volume_wwid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8142) clear_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8143) if (sas_device->starget && sas_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8144) starget = sas_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8145) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8146) sas_target_priv_data->flags &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8147) ~MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8150) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8151) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8152) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8154) /* exposing raid component */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8155) if (starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8156) starget_for_each_device(starget, NULL, _scsih_reprobe_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8158) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8161) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8162) * _scsih_sas_pd_hide - hide pd component from /dev/sdX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8163) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8164) * @element: IR config element data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8165) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8166) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8167) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8168) _scsih_sas_pd_hide(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8169) Mpi2EventIrConfigElement_t *element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8171) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8172) struct scsi_target *starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8173) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8174) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8175) u16 handle = le16_to_cpu(element->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8176) u16 volume_handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8177) u64 volume_wwid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8179) mpt3sas_config_get_volume_handle(ioc, handle, &volume_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8180) if (volume_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8181) mpt3sas_config_get_volume_wwid(ioc, volume_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8182) &volume_wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8184) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8185) sas_device = __mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8186) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8187) set_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8188) if (sas_device->starget && sas_device->starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8189) starget = sas_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8190) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8191) sas_target_priv_data->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8192) MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8193) sas_device->volume_handle = volume_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8194) sas_device->volume_wwid = volume_wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8197) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8198) if (!sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8199) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8201) /* hiding raid component */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8202) _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8204) if (starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8205) starget_for_each_device(starget, (void *)1, _scsih_reprobe_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8207) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8210) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8211) * _scsih_sas_pd_delete - delete pd component
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8212) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8213) * @element: IR config element data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8214) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8216) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8217) _scsih_sas_pd_delete(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8218) Mpi2EventIrConfigElement_t *element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8220) u16 handle = le16_to_cpu(element->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8222) _scsih_device_remove_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8225) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8226) * _scsih_sas_pd_add - remove pd component
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8227) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8228) * @element: IR config element data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8229) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8230) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8231) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8232) _scsih_sas_pd_add(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8233) Mpi2EventIrConfigElement_t *element)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8235) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8236) u16 handle = le16_to_cpu(element->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8237) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8238) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8239) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8240) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8241) u16 parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8243) set_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8245) sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8246) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8247) _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8248) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8249) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8252) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8253) MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8254) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8255) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8256) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8259) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8260) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8261) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8262) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8263) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8264) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8267) parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8268) if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8269) mpt3sas_transport_update_links(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8270) sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8272) _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8273) _scsih_add_device(ioc, handle, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8276) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8277) * _scsih_sas_ir_config_change_event_debug - debug for IR Config Change events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8278) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8279) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8280) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8281) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8282) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8283) _scsih_sas_ir_config_change_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8284) Mpi2EventDataIrConfigChangeList_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8286) Mpi2EventIrConfigElement_t *element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8287) u8 element_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8288) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8289) char *reason_str = NULL, *element_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8291) element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8293) ioc_info(ioc, "raid config change: (%s), elements(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8294) le32_to_cpu(event_data->Flags) & MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8295) "foreign" : "native",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8296) event_data->NumElements);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8297) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8298) switch (element->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8299) case MPI2_EVENT_IR_CHANGE_RC_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8300) reason_str = "add";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8301) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8302) case MPI2_EVENT_IR_CHANGE_RC_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8303) reason_str = "remove";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8304) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8305) case MPI2_EVENT_IR_CHANGE_RC_NO_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8306) reason_str = "no change";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8307) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8308) case MPI2_EVENT_IR_CHANGE_RC_HIDE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8309) reason_str = "hide";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8310) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8311) case MPI2_EVENT_IR_CHANGE_RC_UNHIDE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8312) reason_str = "unhide";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8313) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8314) case MPI2_EVENT_IR_CHANGE_RC_VOLUME_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8315) reason_str = "volume_created";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8316) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8317) case MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8318) reason_str = "volume_deleted";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8319) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8320) case MPI2_EVENT_IR_CHANGE_RC_PD_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8321) reason_str = "pd_created";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8322) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8323) case MPI2_EVENT_IR_CHANGE_RC_PD_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8324) reason_str = "pd_deleted";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8325) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8326) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8327) reason_str = "unknown reason";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8328) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8330) element_type = le16_to_cpu(element->ElementFlags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8331) MPI2_EVENT_IR_CHANGE_EFLAGS_ELEMENT_TYPE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8332) switch (element_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8333) case MPI2_EVENT_IR_CHANGE_EFLAGS_VOLUME_ELEMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8334) element_str = "volume";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8335) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8336) case MPI2_EVENT_IR_CHANGE_EFLAGS_VOLPHYSDISK_ELEMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8337) element_str = "phys disk";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8338) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8339) case MPI2_EVENT_IR_CHANGE_EFLAGS_HOTSPARE_ELEMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8340) element_str = "hot spare";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8342) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8343) element_str = "unknown element";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8344) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8346) pr_info("\t(%s:%s), vol handle(0x%04x), " \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8347) "pd handle(0x%04x), pd num(0x%02x)\n", element_str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8348) reason_str, le16_to_cpu(element->VolDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8349) le16_to_cpu(element->PhysDiskDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8350) element->PhysDiskNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8354) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8355) * _scsih_sas_ir_config_change_event - handle ir configuration change events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8356) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8357) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8358) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8359) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8360) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8361) _scsih_sas_ir_config_change_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8362) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8363) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8364) Mpi2EventIrConfigElement_t *element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8365) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8366) u8 foreign_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8367) Mpi2EventDataIrConfigChangeList_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8368) (Mpi2EventDataIrConfigChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8369) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8371) if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8372) (!ioc->hide_ir_msg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8373) _scsih_sas_ir_config_change_event_debug(ioc, event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8375) foreign_config = (le32_to_cpu(event_data->Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8376) MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8378) element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8379) if (ioc->shost_recovery &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8380) ioc->hba_mpi_version_belonged != MPI2_VERSION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8381) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8382) if (element->ReasonCode == MPI2_EVENT_IR_CHANGE_RC_HIDE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8383) _scsih_ir_fastpath(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8384) le16_to_cpu(element->PhysDiskDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8385) element->PhysDiskNum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8387) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8390) for (i = 0; i < event_data->NumElements; i++, element++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8392) switch (element->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8393) case MPI2_EVENT_IR_CHANGE_RC_VOLUME_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8394) case MPI2_EVENT_IR_CHANGE_RC_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8395) if (!foreign_config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8396) _scsih_sas_volume_add(ioc, element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8397) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8398) case MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8399) case MPI2_EVENT_IR_CHANGE_RC_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8400) if (!foreign_config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8401) _scsih_sas_volume_delete(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8402) le16_to_cpu(element->VolDevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8403) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8404) case MPI2_EVENT_IR_CHANGE_RC_PD_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8405) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8406) _scsih_sas_pd_hide(ioc, element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8407) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8408) case MPI2_EVENT_IR_CHANGE_RC_PD_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8409) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8410) _scsih_sas_pd_expose(ioc, element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8411) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8412) case MPI2_EVENT_IR_CHANGE_RC_HIDE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8413) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8414) _scsih_sas_pd_add(ioc, element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8415) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8416) case MPI2_EVENT_IR_CHANGE_RC_UNHIDE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8417) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8418) _scsih_sas_pd_delete(ioc, element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8419) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8424) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8425) * _scsih_sas_ir_volume_event - IR volume event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8426) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8427) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8428) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8429) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8430) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8431) _scsih_sas_ir_volume_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8432) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8434) u64 wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8435) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8436) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8437) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8438) u32 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8439) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8440) Mpi2EventDataIrVolume_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8441) (Mpi2EventDataIrVolume_t *) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8443) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8444) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8446) if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8447) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8449) handle = le16_to_cpu(event_data->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8450) state = le32_to_cpu(event_data->NewValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8451) if (!ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8452) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8453) ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8454) __func__, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8455) le32_to_cpu(event_data->PreviousValue),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8456) state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8457) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8458) case MPI2_RAID_VOL_STATE_MISSING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8459) case MPI2_RAID_VOL_STATE_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8460) _scsih_sas_volume_delete(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8461) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8463) case MPI2_RAID_VOL_STATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8464) case MPI2_RAID_VOL_STATE_DEGRADED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8465) case MPI2_RAID_VOL_STATE_OPTIMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8467) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8468) raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8469) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8471) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8472) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8474) mpt3sas_config_get_volume_wwid(ioc, handle, &wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8475) if (!wwid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8476) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8477) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8478) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8481) raid_device = kzalloc(sizeof(struct _raid_device), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8482) if (!raid_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8483) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8484) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8485) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8488) raid_device->id = ioc->sas_id++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8489) raid_device->channel = RAID_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8490) raid_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8491) raid_device->wwid = wwid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8492) _scsih_raid_device_add(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8493) rc = scsi_add_device(ioc->shost, RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8494) raid_device->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8495) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8496) _scsih_raid_device_remove(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8497) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8499) case MPI2_RAID_VOL_STATE_INITIALIZING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8500) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8501) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8505) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8506) * _scsih_sas_ir_physical_disk_event - PD event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8507) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8508) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8509) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8510) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8511) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8512) _scsih_sas_ir_physical_disk_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8513) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8515) u16 handle, parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8516) u32 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8517) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8518) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8519) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8520) u32 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8521) Mpi2EventDataIrPhysicalDisk_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8522) (Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8523) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8525) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8526) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8528) if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8529) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8531) handle = le16_to_cpu(event_data->PhysDiskDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8532) state = le32_to_cpu(event_data->NewValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8534) if (!ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8535) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8536) ioc_info(ioc, "%s: handle(0x%04x), old(0x%08x), new(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8537) __func__, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8538) le32_to_cpu(event_data->PreviousValue),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8539) state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8541) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8542) case MPI2_RAID_PD_STATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8543) case MPI2_RAID_PD_STATE_DEGRADED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8544) case MPI2_RAID_PD_STATE_REBUILDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8545) case MPI2_RAID_PD_STATE_OPTIMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8546) case MPI2_RAID_PD_STATE_HOT_SPARE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8548) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8549) set_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8551) sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8552) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8553) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8554) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8557) if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8558) &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8559) handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8560) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8561) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8562) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8565) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8566) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8567) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8568) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8569) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8570) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8573) parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8574) if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8575) mpt3sas_transport_update_links(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8576) sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8578) _scsih_add_device(ioc, handle, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8580) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8582) case MPI2_RAID_PD_STATE_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8583) case MPI2_RAID_PD_STATE_NOT_CONFIGURED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8584) case MPI2_RAID_PD_STATE_NOT_COMPATIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8585) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8586) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8590) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8591) * _scsih_sas_ir_operation_status_event_debug - debug for IR op event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8592) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8593) * @event_data: event data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8594) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8596) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8597) _scsih_sas_ir_operation_status_event_debug(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8598) Mpi2EventDataIrOperationStatus_t *event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8600) char *reason_str = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8602) switch (event_data->RAIDOperation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8603) case MPI2_EVENT_IR_RAIDOP_RESYNC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8604) reason_str = "resync";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8605) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8606) case MPI2_EVENT_IR_RAIDOP_ONLINE_CAP_EXPANSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8607) reason_str = "online capacity expansion";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8608) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8609) case MPI2_EVENT_IR_RAIDOP_CONSISTENCY_CHECK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8610) reason_str = "consistency check";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8611) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8612) case MPI2_EVENT_IR_RAIDOP_BACKGROUND_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8613) reason_str = "background init";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8614) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8615) case MPI2_EVENT_IR_RAIDOP_MAKE_DATA_CONSISTENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8616) reason_str = "make data consistent";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8617) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8620) if (!reason_str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8621) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8623) ioc_info(ioc, "raid operational status: (%s)\thandle(0x%04x), percent complete(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8624) reason_str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8625) le16_to_cpu(event_data->VolDevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8626) event_data->PercentComplete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8629) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8630) * _scsih_sas_ir_operation_status_event - handle RAID operation events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8631) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8632) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8633) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8634) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8635) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8636) _scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8637) struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8639) Mpi2EventDataIrOperationStatus_t *event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8640) (Mpi2EventDataIrOperationStatus_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8641) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8642) static struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8643) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8644) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8646) if ((ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8647) (!ioc->hide_ir_msg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8648) _scsih_sas_ir_operation_status_event_debug(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8649) event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8651) /* code added for raid transport support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8652) if (event_data->RAIDOperation == MPI2_EVENT_IR_RAIDOP_RESYNC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8654) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8655) handle = le16_to_cpu(event_data->VolDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8656) raid_device = mpt3sas_raid_device_find_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8657) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8658) raid_device->percent_complete =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8659) event_data->PercentComplete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8660) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8664) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8665) * _scsih_prep_device_scan - initialize parameters prior to device scan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8666) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8667) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8668) * Set the deleted flag prior to device scan. If the device is found during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8669) * the scan, then we clear the deleted flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8670) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8671) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8672) _scsih_prep_device_scan(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8673) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8674) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8675) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8677) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8678) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8679) if (sas_device_priv_data && sas_device_priv_data->sas_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8680) sas_device_priv_data->sas_target->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8684) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8685) * _scsih_mark_responding_sas_device - mark a sas_devices as responding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8686) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8687) * @sas_device_pg0: SAS Device page 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8688) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8689) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8690) * Used in _scsih_remove_unresponsive_sas_devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8691) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8692) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8693) _scsih_mark_responding_sas_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8694) Mpi2SasDevicePage0_t *sas_device_pg0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8696) struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8697) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8698) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8699) struct _enclosure_node *enclosure_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8700) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8702) if (sas_device_pg0->EnclosureHandle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8703) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8704) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8705) le16_to_cpu(sas_device_pg0->EnclosureHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8706) if (enclosure_dev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8707) ioc_info(ioc, "Enclosure handle(0x%04x) doesn't match with enclosure device!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8708) sas_device_pg0->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8710) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8711) list_for_each_entry(sas_device, &ioc->sas_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8712) if ((sas_device->sas_address == le64_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8713) sas_device_pg0->SASAddress)) && (sas_device->slot ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8714) le16_to_cpu(sas_device_pg0->Slot))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8715) sas_device->responding = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8716) starget = sas_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8717) if (starget && starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8718) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8719) sas_target_priv_data->tm_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8720) sas_target_priv_data->deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8721) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8722) sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8723) if (starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8724) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8725) "handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8726) le16_to_cpu(sas_device_pg0->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8727) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8728) sas_device->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8730) if (sas_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8731) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8732) "enclosure logical id(0x%016llx),"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8733) " slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8734) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8735) sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8736) sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8738) if (le16_to_cpu(sas_device_pg0->Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8739) MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8740) sas_device->enclosure_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8741) sas_device_pg0->EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8742) memcpy(&sas_device->connector_name[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8743) &sas_device_pg0->ConnectorName[0], 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8744) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8745) sas_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8746) sas_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8749) sas_device->enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8750) le16_to_cpu(sas_device_pg0->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8751) sas_device->is_chassis_slot_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8752) if (enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8753) sas_device->enclosure_logical_id = le64_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8754) enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8755) if (le16_to_cpu(enclosure_dev->pg0.Flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8756) MPI2_SAS_ENCLS0_FLAGS_CHASSIS_SLOT_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8757) sas_device->is_chassis_slot_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8758) sas_device->chassis_slot =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8759) enclosure_dev->pg0.ChassisSlot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8763) if (sas_device->handle == le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8764) sas_device_pg0->DevHandle))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8765) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8766) pr_info("\thandle changed from(0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8767) sas_device->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8768) sas_device->handle = le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8769) sas_device_pg0->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8770) if (sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8771) sas_target_priv_data->handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8772) le16_to_cpu(sas_device_pg0->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8773) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8776) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8777) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8780) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8781) * _scsih_create_enclosure_list_after_reset - Free Existing list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8782) * And create enclosure list by scanning all Enclosure Page(0)s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8783) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8784) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8785) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8786) _scsih_create_enclosure_list_after_reset(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8787) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8788) struct _enclosure_node *enclosure_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8789) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8790) u16 enclosure_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8791) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8793) /* Free existing enclosure list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8794) mpt3sas_free_enclosure_list(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8796) /* Re constructing enclosure list after reset*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8797) enclosure_handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8798) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8799) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8800) kzalloc(sizeof(struct _enclosure_node), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8801) if (!enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8802) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8803) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8804) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8806) rc = mpt3sas_config_get_enclosure_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8807) &enclosure_dev->pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8808) MPI2_SAS_ENCLOS_PGAD_FORM_GET_NEXT_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8809) enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8811) if (rc || (le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8812) MPI2_IOCSTATUS_MASK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8813) kfree(enclosure_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8814) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8816) list_add_tail(&enclosure_dev->list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8817) &ioc->enclosure_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8818) enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8819) le16_to_cpu(enclosure_dev->pg0.EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8820) } while (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8823) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8824) * _scsih_search_responding_sas_devices -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8825) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8826) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8827) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8828) * If not remove.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8829) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8830) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8831) _scsih_search_responding_sas_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8833) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8834) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8835) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8836) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8837) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8839) ioc_info(ioc, "search for end-devices: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8841) if (list_empty(&ioc->sas_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8842) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8844) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8845) while (!(mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8846) &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8847) handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8848) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8849) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8850) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8851) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8852) handle = le16_to_cpu(sas_device_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8853) device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8854) if (!(_scsih_is_end_device(device_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8855) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8856) _scsih_mark_responding_sas_device(ioc, &sas_device_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8859) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8860) ioc_info(ioc, "search for end-devices: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8863) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8864) * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8865) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8866) * @pcie_device_pg0: PCIe Device page 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8867) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8868) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8869) * Used in _scsih_remove_unresponding_devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8870) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8871) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8872) _scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8873) Mpi26PCIeDevicePage0_t *pcie_device_pg0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8875) struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8876) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8877) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8878) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8880) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8881) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8882) if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8883) && (pcie_device->slot == le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8884) pcie_device_pg0->Slot))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8885) pcie_device->access_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8886) pcie_device_pg0->AccessStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8887) pcie_device->responding = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8888) starget = pcie_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8889) if (starget && starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8890) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8891) sas_target_priv_data->tm_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8892) sas_target_priv_data->deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8893) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8894) sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8895) if (starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8896) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8897) "handle(0x%04x), wwid(0x%016llx) ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8898) pcie_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8899) (unsigned long long)pcie_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8900) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8901) starget_printk(KERN_INFO, starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8902) "enclosure logical id(0x%016llx), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8903) "slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8904) (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8905) pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8906) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8907) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8909) if (((le32_to_cpu(pcie_device_pg0->Flags)) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8910) MPI26_PCIEDEV0_FLAGS_ENCL_LEVEL_VALID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8911) (ioc->hba_mpi_version_belonged != MPI2_VERSION)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8912) pcie_device->enclosure_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8913) pcie_device_pg0->EnclosureLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8914) memcpy(&pcie_device->connector_name[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8915) &pcie_device_pg0->ConnectorName[0], 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8916) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8917) pcie_device->enclosure_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8918) pcie_device->connector_name[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8921) if (pcie_device->handle == le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8922) pcie_device_pg0->DevHandle))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8923) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8924) pr_info("\thandle changed from(0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8925) pcie_device->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8926) pcie_device->handle = le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8927) pcie_device_pg0->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8928) if (sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8929) sas_target_priv_data->handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8930) le16_to_cpu(pcie_device_pg0->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8931) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8935) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8936) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8939) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8940) * _scsih_search_responding_pcie_devices -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8941) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8942) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8943) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8944) * If not remove.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8945) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8946) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8947) _scsih_search_responding_pcie_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8948) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8949) Mpi26PCIeDevicePage0_t pcie_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8950) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8951) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8952) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8953) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8955) ioc_info(ioc, "search for end-devices: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8957) if (list_empty(&ioc->pcie_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8958) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8960) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8961) while (!(mpt3sas_config_get_pcie_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8962) &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8963) handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8964) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8965) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8966) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8967) ioc_info(ioc, "\tbreak from %s: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8968) __func__, ioc_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8969) le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8970) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8972) handle = le16_to_cpu(pcie_device_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8973) device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8974) if (!(_scsih_is_nvme_pciescsi_device(device_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8975) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8976) _scsih_mark_responding_pcie_device(ioc, &pcie_device_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8978) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8979) ioc_info(ioc, "search for PCIe end-devices: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8982) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8983) * _scsih_mark_responding_raid_device - mark a raid_device as responding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8984) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8985) * @wwid: world wide identifier for raid volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8986) * @handle: device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8987) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8988) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8989) * Used in _scsih_remove_unresponsive_raid_devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8990) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8991) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8992) _scsih_mark_responding_raid_device(struct MPT3SAS_ADAPTER *ioc, u64 wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8993) u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8994) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8995) struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8996) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8997) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8998) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9000) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9001) list_for_each_entry(raid_device, &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9002) if (raid_device->wwid == wwid && raid_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9003) starget = raid_device->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9004) if (starget && starget->hostdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9005) sas_target_priv_data = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9006) sas_target_priv_data->deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9007) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9008) sas_target_priv_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9009) raid_device->responding = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9010) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9011) starget_printk(KERN_INFO, raid_device->starget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9012) "handle(0x%04x), wwid(0x%016llx)\n", handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9013) (unsigned long long)raid_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9015) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9016) * WARPDRIVE: The handles of the PDs might have changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9017) * across the host reset so re-initialize the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9018) * required data for Direct IO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9020) mpt3sas_init_warpdrive_properties(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9021) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9022) if (raid_device->handle == handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9023) spin_unlock_irqrestore(&ioc->raid_device_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9024) flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9025) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9027) pr_info("\thandle changed from(0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9028) raid_device->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9029) raid_device->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9030) if (sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9031) sas_target_priv_data->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9032) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9033) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9036) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9037) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9039) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9040) * _scsih_search_responding_raid_devices -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9041) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9042) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9043) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9044) * If not remove.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9045) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9046) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9047) _scsih_search_responding_raid_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9049) Mpi2RaidVolPage1_t volume_pg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9050) Mpi2RaidVolPage0_t volume_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9051) Mpi2RaidPhysDiskPage0_t pd_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9052) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9053) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9054) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9055) u8 phys_disk_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9057) if (!ioc->ir_firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9058) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9060) ioc_info(ioc, "search for raid volumes: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9062) if (list_empty(&ioc->raid_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9063) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9065) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9066) while (!(mpt3sas_config_get_raid_volume_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9067) &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9068) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9069) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9070) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9071) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9072) handle = le16_to_cpu(volume_pg1.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9074) if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9075) &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9076) sizeof(Mpi2RaidVolPage0_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9077) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9079) if (volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9080) volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_ONLINE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9081) volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_DEGRADED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9082) _scsih_mark_responding_raid_device(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9083) le64_to_cpu(volume_pg1.WWID), handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9086) /* refresh the pd_handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9087) if (!ioc->is_warpdrive) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9088) phys_disk_num = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9089) memset(ioc->pd_handles, 0, ioc->pd_handles_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9090) while (!(mpt3sas_config_get_phys_disk_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9091) &pd_pg0, MPI2_PHYSDISK_PGAD_FORM_GET_NEXT_PHYSDISKNUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9092) phys_disk_num))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9093) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9094) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9095) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9096) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9097) phys_disk_num = pd_pg0.PhysDiskNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9098) handle = le16_to_cpu(pd_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9099) set_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9102) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9103) ioc_info(ioc, "search for responding raid volumes: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9107) * _scsih_mark_responding_expander - mark a expander as responding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9108) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9109) * @expander_pg0:SAS Expander Config Page0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9111) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9112) * Used in _scsih_remove_unresponsive_expanders.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9114) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9115) _scsih_mark_responding_expander(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9116) Mpi2ExpanderPage0_t *expander_pg0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9118) struct _sas_node *sas_expander = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9119) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9120) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9121) struct _enclosure_node *enclosure_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9122) u16 handle = le16_to_cpu(expander_pg0->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9123) u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9124) u64 sas_address = le64_to_cpu(expander_pg0->SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9126) if (enclosure_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9127) enclosure_dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9128) mpt3sas_scsih_enclosure_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9129) enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9131) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9132) list_for_each_entry(sas_expander, &ioc->sas_expander_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9133) if (sas_expander->sas_address != sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9134) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9135) sas_expander->responding = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9137) if (enclosure_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9138) sas_expander->enclosure_logical_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9139) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9140) sas_expander->enclosure_handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9141) le16_to_cpu(expander_pg0->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9144) if (sas_expander->handle == handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9145) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9146) pr_info("\texpander(0x%016llx): handle changed" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9147) " from(0x%04x) to (0x%04x)!!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9148) (unsigned long long)sas_expander->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9149) sas_expander->handle, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9150) sas_expander->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9151) for (i = 0 ; i < sas_expander->num_phys ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9152) sas_expander->phy[i].handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9153) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9155) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9156) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9159) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9160) * _scsih_search_responding_expanders -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9161) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9162) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9163) * After host reset, find out whether devices are still responding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9164) * If not remove.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9166) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9167) _scsih_search_responding_expanders(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9169) Mpi2ExpanderPage0_t expander_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9170) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9171) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9172) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9173) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9175) ioc_info(ioc, "search for expanders: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9177) if (list_empty(&ioc->sas_expander_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9178) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9180) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9181) while (!(mpt3sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9182) MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9184) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9185) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9186) if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9187) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9189) handle = le16_to_cpu(expander_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9190) sas_address = le64_to_cpu(expander_pg0.SASAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9191) pr_info("\texpander present: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9192) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9193) (unsigned long long)sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9194) _scsih_mark_responding_expander(ioc, &expander_pg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9197) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9198) ioc_info(ioc, "search for expanders: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9201) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9202) * _scsih_remove_unresponding_devices - removing unresponding devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9203) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9205) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9206) _scsih_remove_unresponding_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9208) struct _sas_device *sas_device, *sas_device_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9209) struct _sas_node *sas_expander, *sas_expander_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9210) struct _raid_device *raid_device, *raid_device_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9211) struct _pcie_device *pcie_device, *pcie_device_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9212) struct list_head tmp_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9213) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9214) LIST_HEAD(head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9216) ioc_info(ioc, "removing unresponding devices: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9218) /* removing unresponding end devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9219) ioc_info(ioc, "removing unresponding devices: end-devices\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9221) * Iterate, pulling off devices marked as non-responding. We become the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9222) * owner for the reference the list had on any object we prune.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9223) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9224) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9225) list_for_each_entry_safe(sas_device, sas_device_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9226) &ioc->sas_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9227) if (!sas_device->responding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9228) list_move_tail(&sas_device->list, &head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9229) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9230) sas_device->responding = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9232) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9234) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9235) * Now, uninitialize and remove the unresponding devices we pruned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9236) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9237) list_for_each_entry_safe(sas_device, sas_device_next, &head, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9238) _scsih_remove_device(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9239) list_del_init(&sas_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9240) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9243) ioc_info(ioc, "Removing unresponding devices: pcie end-devices\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9244) INIT_LIST_HEAD(&head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9245) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9246) list_for_each_entry_safe(pcie_device, pcie_device_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9247) &ioc->pcie_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9248) if (!pcie_device->responding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9249) list_move_tail(&pcie_device->list, &head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9250) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9251) pcie_device->responding = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9253) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9255) list_for_each_entry_safe(pcie_device, pcie_device_next, &head, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9256) _scsih_pcie_device_remove_from_sml(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9257) list_del_init(&pcie_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9258) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9261) /* removing unresponding volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9262) if (ioc->ir_firmware) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9263) ioc_info(ioc, "removing unresponding devices: volumes\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9264) list_for_each_entry_safe(raid_device, raid_device_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9265) &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9266) if (!raid_device->responding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9267) _scsih_sas_volume_delete(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9268) raid_device->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9269) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9270) raid_device->responding = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9274) /* removing unresponding expanders */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9275) ioc_info(ioc, "removing unresponding devices: expanders\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9276) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9277) INIT_LIST_HEAD(&tmp_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9278) list_for_each_entry_safe(sas_expander, sas_expander_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9279) &ioc->sas_expander_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9280) if (!sas_expander->responding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9281) list_move_tail(&sas_expander->list, &tmp_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9282) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9283) sas_expander->responding = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9285) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9286) list_for_each_entry_safe(sas_expander, sas_expander_next, &tmp_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9287) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9288) _scsih_expander_node_remove(ioc, sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9291) ioc_info(ioc, "removing unresponding devices: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9293) /* unblock devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9294) _scsih_ublock_io_all_device(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9297) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9298) _scsih_refresh_expander_links(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9299) struct _sas_node *sas_expander, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9301) Mpi2ExpanderPage1_t expander_pg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9302) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9303) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9305) for (i = 0 ; i < sas_expander->num_phys ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9306) if ((mpt3sas_config_get_expander_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9307) &expander_pg1, i, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9308) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9309) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9310) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9313) mpt3sas_transport_update_links(ioc, sas_expander->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9314) le16_to_cpu(expander_pg1.AttachedDevHandle), i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9315) expander_pg1.NegotiatedLinkRate >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9319) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9320) * _scsih_scan_for_devices_after_reset - scan for devices after host reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9321) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9322) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9323) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9324) _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9326) Mpi2ExpanderPage0_t expander_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9327) Mpi2SasDevicePage0_t sas_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9328) Mpi26PCIeDevicePage0_t pcie_device_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9329) Mpi2RaidVolPage1_t volume_pg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9330) Mpi2RaidVolPage0_t volume_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9331) Mpi2RaidPhysDiskPage0_t pd_pg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9332) Mpi2EventIrConfigElement_t element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9333) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9334) u8 phys_disk_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9335) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9336) u16 handle, parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9337) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9338) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9339) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9340) struct _sas_node *expander_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9341) static struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9342) u8 retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9343) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9345) ioc_info(ioc, "scan devices: start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9347) _scsih_sas_host_refresh(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9349) ioc_info(ioc, "\tscan devices: expanders start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9351) /* expanders */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9352) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9353) while (!(mpt3sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9354) MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9355) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9356) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9357) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9358) ioc_info(ioc, "\tbreak from expander scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9359) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9360) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9362) handle = le16_to_cpu(expander_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9363) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9364) expander_device = mpt3sas_scsih_expander_find_by_sas_address(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9365) ioc, le64_to_cpu(expander_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9366) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9367) if (expander_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9368) _scsih_refresh_expander_links(ioc, expander_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9369) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9370) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9371) ioc_info(ioc, "\tBEFORE adding expander: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9372) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9373) (u64)le64_to_cpu(expander_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9374) _scsih_expander_add(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9375) ioc_info(ioc, "\tAFTER adding expander: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9376) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9377) (u64)le64_to_cpu(expander_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9381) ioc_info(ioc, "\tscan devices: expanders complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9383) if (!ioc->ir_firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9384) goto skip_to_sas;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9386) ioc_info(ioc, "\tscan devices: phys disk start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9388) /* phys disk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9389) phys_disk_num = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9390) while (!(mpt3sas_config_get_phys_disk_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9391) &pd_pg0, MPI2_PHYSDISK_PGAD_FORM_GET_NEXT_PHYSDISKNUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9392) phys_disk_num))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9393) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9394) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9395) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9396) ioc_info(ioc, "\tbreak from phys disk scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9397) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9400) phys_disk_num = pd_pg0.PhysDiskNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9401) handle = le16_to_cpu(pd_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9402) sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9403) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9404) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9405) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9407) if (mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9408) &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9409) handle) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9410) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9411) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9412) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9413) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9414) ioc_info(ioc, "\tbreak from phys disk scan ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9415) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9416) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9418) parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9419) if (!_scsih_get_sas_address(ioc, parent_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9420) &sas_address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9421) ioc_info(ioc, "\tBEFORE adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9422) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9423) (u64)le64_to_cpu(sas_device_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9424) mpt3sas_transport_update_links(ioc, sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9425) handle, sas_device_pg0.PhyNum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9426) MPI2_SAS_NEG_LINK_RATE_1_5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9427) set_bit(handle, ioc->pd_handles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9428) retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9429) /* This will retry adding the end device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9430) * _scsih_add_device() will decide on retries and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9431) * return "1" when it should be retried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9432) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9433) while (_scsih_add_device(ioc, handle, retry_count++,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9434) 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9435) ssleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9437) ioc_info(ioc, "\tAFTER adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9438) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9439) (u64)le64_to_cpu(sas_device_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9443) ioc_info(ioc, "\tscan devices: phys disk complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9445) ioc_info(ioc, "\tscan devices: volumes start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9447) /* volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9448) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9449) while (!(mpt3sas_config_get_raid_volume_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9450) &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9451) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9452) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9453) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9454) ioc_info(ioc, "\tbreak from volume scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9455) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9456) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9458) handle = le16_to_cpu(volume_pg1.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9459) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9460) raid_device = _scsih_raid_device_find_by_wwid(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9461) le64_to_cpu(volume_pg1.WWID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9462) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9463) if (raid_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9464) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9465) if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9466) &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9467) sizeof(Mpi2RaidVolPage0_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9468) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9469) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9470) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9471) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9472) ioc_info(ioc, "\tbreak from volume scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9473) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9476) if (volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9477) volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_ONLINE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9478) volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9479) memset(&element, 0, sizeof(Mpi2EventIrConfigElement_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9480) element.ReasonCode = MPI2_EVENT_IR_CHANGE_RC_ADDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9481) element.VolDevHandle = volume_pg1.DevHandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9482) ioc_info(ioc, "\tBEFORE adding volume: handle (0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9483) volume_pg1.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9484) _scsih_sas_volume_add(ioc, &element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9485) ioc_info(ioc, "\tAFTER adding volume: handle (0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9486) volume_pg1.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9490) ioc_info(ioc, "\tscan devices: volumes complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9492) skip_to_sas:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9494) ioc_info(ioc, "\tscan devices: end devices start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9496) /* sas devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9497) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9498) while (!(mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9499) &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9500) handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9501) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9502) MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9503) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9504) ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9505) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9506) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9508) handle = le16_to_cpu(sas_device_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9509) if (!(_scsih_is_end_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9510) le32_to_cpu(sas_device_pg0.DeviceInfo))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9511) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9512) sas_device = mpt3sas_get_sdev_by_addr(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9513) le64_to_cpu(sas_device_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9514) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9515) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9516) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9518) parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9519) if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9520) ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9521) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9522) (u64)le64_to_cpu(sas_device_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9523) mpt3sas_transport_update_links(ioc, sas_address, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9524) sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9525) retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9526) /* This will retry adding the end device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9527) * _scsih_add_device() will decide on retries and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9528) * return "1" when it should be retried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9530) while (_scsih_add_device(ioc, handle, retry_count++,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9531) 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9532) ssleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9534) ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9535) handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9536) (u64)le64_to_cpu(sas_device_pg0.SASAddress));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9539) ioc_info(ioc, "\tscan devices: end devices complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9540) ioc_info(ioc, "\tscan devices: pcie end devices start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9542) /* pcie devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9543) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9544) while (!(mpt3sas_config_get_pcie_device_pg0(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9545) &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9546) handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9547) ioc_status = le16_to_cpu(mpi_reply.IOCStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9548) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9549) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9550) ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9551) ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9552) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9554) handle = le16_to_cpu(pcie_device_pg0.DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9555) if (!(_scsih_is_nvme_pciescsi_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9556) le32_to_cpu(pcie_device_pg0.DeviceInfo))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9557) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9558) pcie_device = mpt3sas_get_pdev_by_wwid(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9559) le64_to_cpu(pcie_device_pg0.WWID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9560) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9561) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9562) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9564) retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9565) parent_handle = le16_to_cpu(pcie_device_pg0.ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9566) _scsih_pcie_add_device(ioc, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9568) ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9569) handle, (u64)le64_to_cpu(pcie_device_pg0.WWID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9571) ioc_info(ioc, "\tpcie devices: pcie end devices complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9572) ioc_info(ioc, "scan devices: complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9575) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9576) * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9577) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9578) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9579) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9580) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9581) void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9583) dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_PRE_RESET\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9586) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9587) * mpt3sas_scsih_clear_outstanding_scsi_tm_commands - clears outstanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9588) * scsi & tm cmds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9589) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9590) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9591) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9592) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9593) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9594) mpt3sas_scsih_clear_outstanding_scsi_tm_commands(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9596) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9597) ioc_info(ioc, "%s: clear outstanding scsi & tm cmds\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9598) if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9599) ioc->scsih_cmds.status |= MPT3_CMD_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9600) mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9601) complete(&ioc->scsih_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9603) if (ioc->tm_cmds.status & MPT3_CMD_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9604) ioc->tm_cmds.status |= MPT3_CMD_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9605) mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9606) complete(&ioc->tm_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9609) memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9610) memset(ioc->device_remove_in_progress, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9611) ioc->device_remove_in_progress_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9612) _scsih_fw_event_cleanup_queue(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9613) _scsih_flush_running_cmds(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9616) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9617) * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9618) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9619) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9620) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9622) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9623) mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9625) dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9626) if ((!ioc->is_driver_loading) && !(disable_discovery > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9627) !ioc->sas_hba.num_phys)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9628) _scsih_prep_device_scan(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9629) _scsih_create_enclosure_list_after_reset(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9630) _scsih_search_responding_sas_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9631) _scsih_search_responding_pcie_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9632) _scsih_search_responding_raid_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9633) _scsih_search_responding_expanders(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9634) _scsih_error_recovery_delete_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9638) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9639) * _mpt3sas_fw_work - delayed task for processing firmware events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9640) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9641) * @fw_event: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9642) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9643) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9644) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9645) _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9647) ioc->current_event = fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9648) _scsih_fw_event_del_from_list(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9650) /* the queue is being flushed so ignore this event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9651) if (ioc->remove_host || ioc->pci_error_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9652) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9653) ioc->current_event = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9654) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9657) switch (fw_event->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9658) case MPT3SAS_PROCESS_TRIGGER_DIAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9659) mpt3sas_process_trigger_data(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9660) (struct SL_WH_TRIGGERS_EVENT_DATA_T *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9661) fw_event->event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9662) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9663) case MPT3SAS_REMOVE_UNRESPONDING_DEVICES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9664) while (scsi_host_in_recovery(ioc->shost) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9665) ioc->shost_recovery) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9666) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9667) * If we're unloading or cancelling the work, bail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9668) * Otherwise, this can become an infinite loop.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9669) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9670) if (ioc->remove_host || ioc->fw_events_cleanup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9671) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9672) ssleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9674) _scsih_remove_unresponding_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9675) _scsih_scan_for_devices_after_reset(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9676) _scsih_set_nvme_max_shutdown_latency(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9677) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9678) case MPT3SAS_PORT_ENABLE_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9679) ioc->start_scan = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9680) if (missing_delay[0] != -1 && missing_delay[1] != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9681) mpt3sas_base_update_missing_delay(ioc, missing_delay[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9682) missing_delay[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9683) dewtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9684) ioc_info(ioc, "port enable: complete from worker thread\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9685) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9686) case MPT3SAS_TURN_ON_PFA_LED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9687) _scsih_turn_on_pfa_led(ioc, fw_event->device_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9688) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9689) case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9690) _scsih_sas_topology_change_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9691) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9692) case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9693) if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9694) _scsih_sas_device_status_change_event_debug(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9695) (Mpi2EventDataSasDeviceStatusChange_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9696) fw_event->event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9697) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9698) case MPI2_EVENT_SAS_DISCOVERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9699) _scsih_sas_discovery_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9700) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9701) case MPI2_EVENT_SAS_DEVICE_DISCOVERY_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9702) _scsih_sas_device_discovery_error_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9703) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9704) case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9705) _scsih_sas_broadcast_primitive_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9706) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9707) case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9708) _scsih_sas_enclosure_dev_status_change_event(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9709) fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9710) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9711) case MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9712) _scsih_sas_ir_config_change_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9713) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9714) case MPI2_EVENT_IR_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9715) _scsih_sas_ir_volume_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9716) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9717) case MPI2_EVENT_IR_PHYSICAL_DISK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9718) _scsih_sas_ir_physical_disk_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9719) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9720) case MPI2_EVENT_IR_OPERATION_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9721) _scsih_sas_ir_operation_status_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9722) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9723) case MPI2_EVENT_PCIE_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9724) _scsih_pcie_device_status_change_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9725) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9726) case MPI2_EVENT_PCIE_ENUMERATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9727) _scsih_pcie_enumeration_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9728) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9729) case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9730) _scsih_pcie_topology_change_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9731) ioc->current_event = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9732) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9733) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9735) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9736) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9737) ioc->current_event = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9740) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9741) * _firmware_event_work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9742) * @work: The fw_event_work object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9743) * Context: user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9744) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9745) * wrappers for the work thread handling firmware events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9746) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9748) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9749) _firmware_event_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9751) struct fw_event_work *fw_event = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9752) struct fw_event_work, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9754) _mpt3sas_fw_work(fw_event->ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9757) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9758) * mpt3sas_scsih_event_callback - firmware event handler (called at ISR time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9759) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9760) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9761) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9762) * Context: interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9763) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9764) * This function merely adds a new work task into ioc->firmware_event_thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9765) * The tasks are worked from _firmware_event_work in user context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9766) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9767) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9768) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9769) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9770) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9771) mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9772) u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9773) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9774) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9775) Mpi2EventNotificationReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9776) u16 event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9777) u16 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9778) Mpi26EventDataActiveCableExcept_t *ActiveCableEventData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9780) /* events turned off due to host reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9781) if (ioc->pci_error_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9782) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9784) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9786) if (unlikely(!mpi_reply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9787) ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9788) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9789) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9792) event = le16_to_cpu(mpi_reply->Event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9794) if (event != MPI2_EVENT_LOG_ENTRY_ADDED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9795) mpt3sas_trigger_event(ioc, event, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9797) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9798) /* handle these */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9799) case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9801) Mpi2EventDataSasBroadcastPrimitive_t *baen_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9802) (Mpi2EventDataSasBroadcastPrimitive_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9803) mpi_reply->EventData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9805) if (baen_data->Primitive !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9806) MPI2_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9807) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9809) if (ioc->broadcast_aen_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9810) ioc->broadcast_aen_pending++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9811) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9812) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9813) ioc->broadcast_aen_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9814) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9817) case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9818) _scsih_check_topo_delete_events(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9819) (Mpi2EventDataSasTopologyChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9820) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9821) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9822) case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9823) _scsih_check_pcie_topo_remove_events(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9824) (Mpi26EventDataPCIeTopologyChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9825) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9826) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9827) case MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9828) _scsih_check_ir_config_unhide_events(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9829) (Mpi2EventDataIrConfigChangeList_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9830) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9831) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9832) case MPI2_EVENT_IR_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9833) _scsih_check_volume_delete_events(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9834) (Mpi2EventDataIrVolume_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9835) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9836) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9837) case MPI2_EVENT_LOG_ENTRY_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9839) Mpi2EventDataLogEntryAdded_t *log_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9840) u32 *log_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9842) if (!ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9843) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9845) log_entry = (Mpi2EventDataLogEntryAdded_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9846) mpi_reply->EventData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9847) log_code = (u32 *)log_entry->LogData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9849) if (le16_to_cpu(log_entry->LogEntryQualifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9850) != MPT2_WARPDRIVE_LOGENTRY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9851) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9853) switch (le32_to_cpu(*log_code)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9854) case MPT2_WARPDRIVE_LC_SSDT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9855) ioc_warn(ioc, "WarpDrive Warning: IO Throttling has occurred in the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9856) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9857) case MPT2_WARPDRIVE_LC_SSDLW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9858) ioc_warn(ioc, "WarpDrive Warning: Program/Erase Cycles for the WarpDrive subsystem in degraded range. Check WarpDrive documentation for additional details.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9859) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9860) case MPT2_WARPDRIVE_LC_SSDLF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9861) ioc_err(ioc, "WarpDrive Fatal Error: There are no Program/Erase Cycles for the WarpDrive subsystem. The storage device will be in read-only mode. Check WarpDrive documentation for additional details.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9862) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9863) case MPT2_WARPDRIVE_LC_BRMF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9864) ioc_err(ioc, "WarpDrive Fatal Error: The Backup Rail Monitor has failed on the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9865) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9868) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9870) case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9871) _scsih_sas_device_status_change_event(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9872) (Mpi2EventDataSasDeviceStatusChange_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9873) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9874) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9875) case MPI2_EVENT_IR_OPERATION_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9876) case MPI2_EVENT_SAS_DISCOVERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9877) case MPI2_EVENT_SAS_DEVICE_DISCOVERY_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9878) case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9879) case MPI2_EVENT_IR_PHYSICAL_DISK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9880) case MPI2_EVENT_PCIE_ENUMERATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9881) case MPI2_EVENT_PCIE_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9882) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9884) case MPI2_EVENT_TEMP_THRESHOLD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9885) _scsih_temp_threshold_events(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9886) (Mpi2EventDataTemperature_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9887) mpi_reply->EventData);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9888) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9889) case MPI2_EVENT_ACTIVE_CABLE_EXCEPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9890) ActiveCableEventData =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9891) (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9892) switch (ActiveCableEventData->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9893) case MPI26_EVENT_ACTIVE_CABLE_INSUFFICIENT_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9894) ioc_notice(ioc, "Currently an active cable with ReceptacleID %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9895) ActiveCableEventData->ReceptacleID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9896) pr_notice("cannot be powered and devices connected\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9897) pr_notice("to this active cable will not be seen\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9898) pr_notice("This active cable requires %d mW of power\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9899) ActiveCableEventData->ActiveCablePowerRequirement);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9900) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9902) case MPI26_EVENT_ACTIVE_CABLE_DEGRADED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9903) ioc_notice(ioc, "Currently a cable with ReceptacleID %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9904) ActiveCableEventData->ReceptacleID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9905) pr_notice(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9906) "is not running at optimal speed(12 Gb/s rate)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9907) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9910) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9912) default: /* ignore the rest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9913) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9916) sz = le16_to_cpu(mpi_reply->EventDataLength) * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9917) fw_event = alloc_fw_event_work(sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9918) if (!fw_event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9919) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9920) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9921) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9922) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9924) memcpy(fw_event->event_data, mpi_reply->EventData, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9925) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9926) fw_event->VF_ID = mpi_reply->VF_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9927) fw_event->VP_ID = mpi_reply->VP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9928) fw_event->event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9929) _scsih_fw_event_add(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9930) fw_event_work_put(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9931) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9934) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9935) * _scsih_expander_node_remove - removing expander device from list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9936) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9937) * @sas_expander: the sas_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9938) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9939) * Removing object and freeing associated memory from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9940) * ioc->sas_expander_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9941) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9942) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9943) _scsih_expander_node_remove(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9944) struct _sas_node *sas_expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9945) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9946) struct _sas_port *mpt3sas_port, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9947) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9949) /* remove sibling ports attached to this expander */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9950) list_for_each_entry_safe(mpt3sas_port, next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9951) &sas_expander->sas_port_list, port_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9952) if (ioc->shost_recovery)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9953) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9954) if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9955) SAS_END_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9956) mpt3sas_device_remove_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9957) mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9958) else if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9959) SAS_EDGE_EXPANDER_DEVICE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9960) mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9961) SAS_FANOUT_EXPANDER_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9962) mpt3sas_expander_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9963) mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9966) mpt3sas_transport_port_remove(ioc, sas_expander->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9967) sas_expander->sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9969) ioc_info(ioc, "expander_remove: handle(0x%04x), sas_addr(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9970) sas_expander->handle, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9971) sas_expander->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9973) spin_lock_irqsave(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9974) list_del(&sas_expander->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9975) spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9977) kfree(sas_expander->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9978) kfree(sas_expander);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9981) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9982) * _scsih_nvme_shutdown - NVMe shutdown notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9983) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9984) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9985) * Sending IoUnitControl request with shutdown operation code to alert IOC that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9986) * the host system is shutting down so that IOC can issue NVMe shutdown to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9987) * NVMe drives attached to it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9988) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9989) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9990) _scsih_nvme_shutdown(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9991) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9992) Mpi26IoUnitControlRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9993) Mpi26IoUnitControlReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9994) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9996) /* are there any NVMe devices ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9997) if (list_empty(&ioc->pcie_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9998) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10000) mutex_lock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10002) if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10003) ioc_err(ioc, "%s: scsih_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10004) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10007) ioc->scsih_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10009) smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10010) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10011) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10012) "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10013) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10014) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10017) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10018) ioc->scsih_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10019) memset(mpi_request, 0, sizeof(Mpi26IoUnitControlRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10020) mpi_request->Function = MPI2_FUNCTION_IO_UNIT_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10021) mpi_request->Operation = MPI26_CTRL_OP_SHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10023) init_completion(&ioc->scsih_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10024) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10025) /* Wait for max_shutdown_latency seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10026) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10027) "Io Unit Control shutdown (sending), Shutdown latency %d sec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10028) ioc->max_shutdown_latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10029) wait_for_completion_timeout(&ioc->scsih_cmds.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10030) ioc->max_shutdown_latency*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10032) if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10033) ioc_err(ioc, "%s: timeout\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10034) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10037) if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10038) mpi_reply = ioc->scsih_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10039) ioc_info(ioc, "Io Unit Control shutdown (complete):"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10040) "ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10041) le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10042) le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10044) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10045) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10046) mutex_unlock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10050) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10051) * _scsih_ir_shutdown - IR shutdown notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10052) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10053) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10054) * Sending RAID Action to alert the Integrated RAID subsystem of the IOC that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10055) * the host system is shutting down.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10056) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10057) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10058) _scsih_ir_shutdown(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10059) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10060) Mpi2RaidActionRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10061) Mpi2RaidActionReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10062) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10064) /* is IR firmware build loaded ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10065) if (!ioc->ir_firmware)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10066) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10068) /* are there any volumes ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10069) if (list_empty(&ioc->raid_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10070) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10072) mutex_lock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10074) if (ioc->scsih_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10075) ioc_err(ioc, "%s: scsih_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10076) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10078) ioc->scsih_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10080) smid = mpt3sas_base_get_smid(ioc, ioc->scsih_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10081) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10082) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10083) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10084) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10087) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10088) ioc->scsih_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10089) memset(mpi_request, 0, sizeof(Mpi2RaidActionRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10091) mpi_request->Function = MPI2_FUNCTION_RAID_ACTION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10092) mpi_request->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10094) if (!ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10095) ioc_info(ioc, "IR shutdown (sending)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10096) init_completion(&ioc->scsih_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10097) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10098) wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10100) if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10101) ioc_err(ioc, "%s: timeout\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10102) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10105) if (ioc->scsih_cmds.status & MPT3_CMD_REPLY_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10106) mpi_reply = ioc->scsih_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10107) if (!ioc->hide_ir_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10108) ioc_info(ioc, "IR shutdown (complete): ioc_status(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10109) le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10110) le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10113) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10114) ioc->scsih_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10115) mutex_unlock(&ioc->scsih_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10118) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10119) * _scsih_get_shost_and_ioc - get shost and ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10120) * and verify whether they are NULL or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10121) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10122) * @shost: address of scsi host pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10123) * @ioc: address of HBA adapter pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10125) * Return zero if *shost and *ioc are not NULL otherwise return error number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10127) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10128) _scsih_get_shost_and_ioc(struct pci_dev *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10129) struct Scsi_Host **shost, struct MPT3SAS_ADAPTER **ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10131) *shost = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10132) if (*shost == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10133) dev_err(&pdev->dev, "pdev's driver data is null\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10134) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10137) *ioc = shost_priv(*shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10138) if (*ioc == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10139) dev_err(&pdev->dev, "shost's private data is null\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10140) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10143) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10146) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10147) * scsih_remove - detach and remove add host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10148) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10149) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10150) * Routine called when unloading the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10151) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10152) static void scsih_remove(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10154) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10155) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10156) struct _sas_port *mpt3sas_port, *next_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10157) struct _raid_device *raid_device, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10158) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10159) struct _pcie_device *pcie_device, *pcienext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10160) struct workqueue_struct *wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10161) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10162) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10164) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10165) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10167) ioc->remove_host = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10169) if (!pci_device_is_present(pdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10170) _scsih_flush_running_cmds(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10172) _scsih_fw_event_cleanup_queue(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10174) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10175) wq = ioc->firmware_event_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10176) ioc->firmware_event_thread = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10177) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10178) if (wq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10179) destroy_workqueue(wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10180) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10181) * Copy back the unmodified ioc page1. so that on next driver load,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10182) * current modified changes on ioc page1 won't take effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10184) if (ioc->is_aero_ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10185) mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10186) &ioc->ioc_pg1_copy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10187) /* release all the volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10188) _scsih_ir_shutdown(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10189) mpt3sas_destroy_debugfs(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10190) sas_remove_host(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10191) list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10192) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10193) if (raid_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10194) sas_target_priv_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10195) raid_device->starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10196) sas_target_priv_data->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10197) scsi_remove_target(&raid_device->starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10199) ioc_info(ioc, "removing handle(0x%04x), wwid(0x%016llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10200) raid_device->handle, (u64)raid_device->wwid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10201) _scsih_raid_device_remove(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10203) list_for_each_entry_safe(pcie_device, pcienext, &ioc->pcie_device_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10204) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10205) _scsih_pcie_device_remove_from_sml(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10206) list_del_init(&pcie_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10207) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10210) /* free ports attached to the sas_host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10211) list_for_each_entry_safe(mpt3sas_port, next_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10212) &ioc->sas_hba.sas_port_list, port_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10213) if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10214) SAS_END_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10215) mpt3sas_device_remove_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10216) mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10217) else if (mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10218) SAS_EDGE_EXPANDER_DEVICE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10219) mpt3sas_port->remote_identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10220) SAS_FANOUT_EXPANDER_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10221) mpt3sas_expander_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10222) mpt3sas_port->remote_identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10225) /* free phys attached to the sas_host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10226) if (ioc->sas_hba.num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10227) kfree(ioc->sas_hba.phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10228) ioc->sas_hba.phy = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10229) ioc->sas_hba.num_phys = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10232) mpt3sas_base_detach(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10233) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10234) list_del(&ioc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10235) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10236) scsi_host_put(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10239) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10240) * scsih_shutdown - routine call during system shutdown
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10241) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10242) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10243) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10244) scsih_shutdown(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10246) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10247) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10248) struct workqueue_struct *wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10249) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10250) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10252) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10253) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10255) ioc->remove_host = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10257) if (!pci_device_is_present(pdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10258) _scsih_flush_running_cmds(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10260) _scsih_fw_event_cleanup_queue(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10262) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10263) wq = ioc->firmware_event_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10264) ioc->firmware_event_thread = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10265) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10266) if (wq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10267) destroy_workqueue(wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10269) * Copy back the unmodified ioc page1 so that on next driver load,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10270) * current modified changes on ioc page1 won't take effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10272) if (ioc->is_aero_ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10273) mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10274) &ioc->ioc_pg1_copy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10276) _scsih_ir_shutdown(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10277) _scsih_nvme_shutdown(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10278) mpt3sas_base_detach(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10282) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10283) * _scsih_probe_boot_devices - reports 1st device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10284) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10285) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10286) * If specified in bios page 2, this routine reports the 1st
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10287) * device scsi-ml or sas transport for persistent boot device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10288) * purposes. Please refer to function _scsih_determine_boot_device()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10290) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10291) _scsih_probe_boot_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10293) u32 channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10294) void *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10295) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10296) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10297) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10298) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10299) u64 sas_address_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10300) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10301) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10302) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10303) int tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10305) /* no Bios, return immediately */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10306) if (!ioc->bios_pg3.BiosVersion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10307) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10309) device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10310) if (ioc->req_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10311) device = ioc->req_boot_device.device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10312) channel = ioc->req_boot_device.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10313) } else if (ioc->req_alt_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10314) device = ioc->req_alt_boot_device.device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10315) channel = ioc->req_alt_boot_device.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10316) } else if (ioc->current_boot_device.device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10317) device = ioc->current_boot_device.device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10318) channel = ioc->current_boot_device.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10321) if (!device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10322) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10324) if (channel == RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10325) raid_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10326) rc = scsi_add_device(ioc->shost, RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10327) raid_device->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10328) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10329) _scsih_raid_device_remove(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10330) } else if (channel == PCIE_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10331) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10332) pcie_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10333) tid = pcie_device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10334) list_move_tail(&pcie_device->list, &ioc->pcie_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10335) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10336) rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, tid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10337) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10338) _scsih_pcie_device_remove(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10339) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10340) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10341) sas_device = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10342) handle = sas_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10343) sas_address_parent = sas_device->sas_address_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10344) sas_address = sas_device->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10345) list_move_tail(&sas_device->list, &ioc->sas_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10346) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10348) if (ioc->hide_drives)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10349) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10350) if (!mpt3sas_transport_port_add(ioc, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10351) sas_address_parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10352) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10353) } else if (!sas_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10354) if (!ioc->is_driver_loading) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10355) mpt3sas_transport_port_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10356) sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10357) sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10358) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10364) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10365) * _scsih_probe_raid - reporting raid volumes to scsi-ml
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10366) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10367) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10368) * Called during initial loading of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10369) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10370) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10371) _scsih_probe_raid(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10373) struct _raid_device *raid_device, *raid_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10374) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10376) list_for_each_entry_safe(raid_device, raid_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10377) &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10378) if (raid_device->starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10379) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10380) rc = scsi_add_device(ioc->shost, RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10381) raid_device->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10382) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10383) _scsih_raid_device_remove(ioc, raid_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10387) static struct _sas_device *get_next_sas_device(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10389) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10390) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10392) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10393) if (!list_empty(&ioc->sas_device_init_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10394) sas_device = list_first_entry(&ioc->sas_device_init_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10395) struct _sas_device, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10396) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10398) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10400) return sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10403) static void sas_device_make_active(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10404) struct _sas_device *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10406) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10408) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10410) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10411) * Since we dropped the lock during the call to port_add(), we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10412) * be careful here that somebody else didn't move or delete this item
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10413) * while we were busy with other things.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10414) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10415) * If it was on the list, we need a put() for the reference the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10416) * had. Either way, we need a get() for the destination list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10417) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10418) if (!list_empty(&sas_device->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10419) list_del_init(&sas_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10420) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10423) sas_device_get(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10424) list_add_tail(&sas_device->list, &ioc->sas_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10426) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10429) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10430) * _scsih_probe_sas - reporting sas devices to sas transport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10431) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10432) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10433) * Called during initial loading of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10434) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10435) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10436) _scsih_probe_sas(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10437) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10438) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10440) if (ioc->hide_drives)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10441) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10443) while ((sas_device = get_next_sas_device(ioc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10444) if (!mpt3sas_transport_port_add(ioc, sas_device->handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10445) sas_device->sas_address_parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10446) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10447) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10448) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10449) } else if (!sas_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10450) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10451) * When asyn scanning is enabled, its not possible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10452) * remove devices while scanning is turned on due to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10453) * oops in scsi_sysfs_add_sdev()->add_device()->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10454) * sysfs_addrm_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10455) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10456) if (!ioc->is_driver_loading) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10457) mpt3sas_transport_port_remove(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10458) sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10459) sas_device->sas_address_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10460) _scsih_sas_device_remove(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10461) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10462) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10465) sas_device_make_active(ioc, sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10466) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10470) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10471) * get_next_pcie_device - Get the next pcie device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10472) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10474) * Get the next pcie device from pcie_device_init_list list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10476) * Return: pcie device structure if pcie_device_init_list list is not empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10477) * otherwise returns NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10478) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10479) static struct _pcie_device *get_next_pcie_device(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10481) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10482) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10484) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10485) if (!list_empty(&ioc->pcie_device_init_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10486) pcie_device = list_first_entry(&ioc->pcie_device_init_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10487) struct _pcie_device, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10488) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10490) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10492) return pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10495) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10496) * pcie_device_make_active - Add pcie device to pcie_device_list list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10497) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10498) * @pcie_device: pcie device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10500) * Add the pcie device which has registered with SCSI Transport Later to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10501) * pcie_device_list list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10503) static void pcie_device_make_active(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10504) struct _pcie_device *pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10506) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10508) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10510) if (!list_empty(&pcie_device->list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10511) list_del_init(&pcie_device->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10512) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10514) pcie_device_get(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10515) list_add_tail(&pcie_device->list, &ioc->pcie_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10517) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10520) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10521) * _scsih_probe_pcie - reporting PCIe devices to scsi-ml
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10522) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10523) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10524) * Called during initial loading of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10525) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10526) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10527) _scsih_probe_pcie(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10529) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10530) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10532) /* PCIe Device List */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10533) while ((pcie_device = get_next_pcie_device(ioc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10534) if (pcie_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10535) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10536) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10538) if (pcie_device->access_status ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10539) MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10540) pcie_device_make_active(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10541) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10542) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10544) rc = scsi_add_device(ioc->shost, PCIE_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10545) pcie_device->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10546) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10547) _scsih_pcie_device_remove(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10548) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10549) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10550) } else if (!pcie_device->starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10552) * When async scanning is enabled, its not possible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10553) * remove devices while scanning is turned on due to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10554) * oops in scsi_sysfs_add_sdev()->add_device()->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10555) * sysfs_addrm_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10556) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10557) if (!ioc->is_driver_loading) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10558) /* TODO-- Need to find out whether this condition will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10559) * occur or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10560) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10561) _scsih_pcie_device_remove(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10562) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10563) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10566) pcie_device_make_active(ioc, pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10567) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10571) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10572) * _scsih_probe_devices - probing for devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10573) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10574) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10575) * Called during initial loading of the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10576) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10577) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10578) _scsih_probe_devices(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10579) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10580) u16 volume_mapping_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10582) if (!(ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10583) return; /* return when IOC doesn't support initiator mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10585) _scsih_probe_boot_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10587) if (ioc->ir_firmware) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10588) volume_mapping_flags =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10589) le16_to_cpu(ioc->ioc_pg8.IRVolumeMappingFlags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10590) MPI2_IOCPAGE8_IRFLAGS_MASK_VOLUME_MAPPING_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10591) if (volume_mapping_flags ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10592) MPI2_IOCPAGE8_IRFLAGS_LOW_VOLUME_MAPPING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10593) _scsih_probe_raid(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10594) _scsih_probe_sas(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10595) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10596) _scsih_probe_sas(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10597) _scsih_probe_raid(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10599) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10600) _scsih_probe_sas(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10601) _scsih_probe_pcie(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10605) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10606) * scsih_scan_start - scsi lld callback for .scan_start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10607) * @shost: SCSI host pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10608) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10609) * The shost has the ability to discover targets on its own instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10610) * of scanning the entire bus. In our implemention, we will kick off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10611) * firmware discovery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10612) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10613) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10614) scsih_scan_start(struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10615) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10616) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10617) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10618) if (diag_buffer_enable != -1 && diag_buffer_enable != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10619) mpt3sas_enable_diag_buffer(ioc, diag_buffer_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10620) else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10621) mpt3sas_enable_diag_buffer(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10623) if (disable_discovery > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10624) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10626) ioc->start_scan = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10627) rc = mpt3sas_port_enable(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10629) if (rc != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10630) ioc_info(ioc, "port enable: FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10633) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10634) * scsih_scan_finished - scsi lld callback for .scan_finished
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10635) * @shost: SCSI host pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10636) * @time: elapsed time of the scan in jiffies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10637) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10638) * This function will be called periodicallyn until it returns 1 with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10639) * scsi_host and the elapsed time of the scan in jiffies. In our implemention,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10640) * we wait for firmware discovery to complete, then return 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10641) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10642) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10643) scsih_scan_finished(struct Scsi_Host *shost, unsigned long time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10645) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10647) if (disable_discovery > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10648) ioc->is_driver_loading = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10649) ioc->wait_for_discovery_to_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10650) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10653) if (time >= (300 * HZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10654) ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10655) ioc_info(ioc, "port enable: FAILED with timeout (timeout=300s)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10656) ioc->is_driver_loading = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10657) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10660) if (ioc->start_scan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10661) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10663) if (ioc->start_scan_failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10664) ioc_info(ioc, "port enable: FAILED with (ioc_status=0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10665) ioc->start_scan_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10666) ioc->is_driver_loading = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10667) ioc->wait_for_discovery_to_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10668) ioc->remove_host = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10669) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10672) ioc_info(ioc, "port enable: SUCCESS\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10673) ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10675) if (ioc->wait_for_discovery_to_complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10676) ioc->wait_for_discovery_to_complete = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10677) _scsih_probe_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10678) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10679) mpt3sas_base_start_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10680) ioc->is_driver_loading = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10681) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10684) /* shost template for SAS 2.0 HBA devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10685) static struct scsi_host_template mpt2sas_driver_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10686) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10687) .name = "Fusion MPT SAS Host",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10688) .proc_name = MPT2SAS_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10689) .queuecommand = scsih_qcmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10690) .target_alloc = scsih_target_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10691) .slave_alloc = scsih_slave_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10692) .slave_configure = scsih_slave_configure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10693) .target_destroy = scsih_target_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10694) .slave_destroy = scsih_slave_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10695) .scan_finished = scsih_scan_finished,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10696) .scan_start = scsih_scan_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10697) .change_queue_depth = scsih_change_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10698) .eh_abort_handler = scsih_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10699) .eh_device_reset_handler = scsih_dev_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10700) .eh_target_reset_handler = scsih_target_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10701) .eh_host_reset_handler = scsih_host_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10702) .bios_param = scsih_bios_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10703) .can_queue = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10704) .this_id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10705) .sg_tablesize = MPT2SAS_SG_DEPTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10706) .max_sectors = 32767,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10707) .cmd_per_lun = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10708) .shost_attrs = mpt3sas_host_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10709) .sdev_attrs = mpt3sas_dev_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10710) .track_queue_depth = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10711) .cmd_size = sizeof(struct scsiio_tracker),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10712) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10714) /* raid transport support for SAS 2.0 HBA devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10715) static struct raid_function_template mpt2sas_raid_functions = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10716) .cookie = &mpt2sas_driver_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10717) .is_raid = scsih_is_raid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10718) .get_resync = scsih_get_resync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10719) .get_state = scsih_get_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10720) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10722) /* shost template for SAS 3.0 HBA devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10723) static struct scsi_host_template mpt3sas_driver_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10724) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10725) .name = "Fusion MPT SAS Host",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10726) .proc_name = MPT3SAS_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10727) .queuecommand = scsih_qcmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10728) .target_alloc = scsih_target_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10729) .slave_alloc = scsih_slave_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10730) .slave_configure = scsih_slave_configure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10731) .target_destroy = scsih_target_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10732) .slave_destroy = scsih_slave_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10733) .scan_finished = scsih_scan_finished,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10734) .scan_start = scsih_scan_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10735) .change_queue_depth = scsih_change_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10736) .eh_abort_handler = scsih_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10737) .eh_device_reset_handler = scsih_dev_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10738) .eh_target_reset_handler = scsih_target_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10739) .eh_host_reset_handler = scsih_host_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10740) .bios_param = scsih_bios_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10741) .can_queue = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10742) .this_id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10743) .sg_tablesize = MPT3SAS_SG_DEPTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10744) .max_sectors = 32767,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10745) .max_segment_size = 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10746) .cmd_per_lun = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10747) .shost_attrs = mpt3sas_host_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10748) .sdev_attrs = mpt3sas_dev_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10749) .track_queue_depth = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10750) .cmd_size = sizeof(struct scsiio_tracker),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10751) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10753) /* raid transport support for SAS 3.0 HBA devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10754) static struct raid_function_template mpt3sas_raid_functions = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10755) .cookie = &mpt3sas_driver_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10756) .is_raid = scsih_is_raid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10757) .get_resync = scsih_get_resync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10758) .get_state = scsih_get_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10759) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10761) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10762) * _scsih_determine_hba_mpi_version - determine in which MPI version class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10763) * this device belongs to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10764) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10765) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10766) * return MPI2_VERSION for SAS 2.0 HBA devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10767) * MPI25_VERSION for SAS 3.0 HBA devices, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10768) * MPI26 VERSION for Cutlass & Invader SAS 3.0 HBA devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10769) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10770) static u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10771) _scsih_determine_hba_mpi_version(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10774) switch (pdev->device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10775) case MPI2_MFGPAGE_DEVID_SSS6200:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10776) case MPI2_MFGPAGE_DEVID_SAS2004:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10777) case MPI2_MFGPAGE_DEVID_SAS2008:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10778) case MPI2_MFGPAGE_DEVID_SAS2108_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10779) case MPI2_MFGPAGE_DEVID_SAS2108_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10780) case MPI2_MFGPAGE_DEVID_SAS2108_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10781) case MPI2_MFGPAGE_DEVID_SAS2116_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10782) case MPI2_MFGPAGE_DEVID_SAS2116_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10783) case MPI2_MFGPAGE_DEVID_SAS2208_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10784) case MPI2_MFGPAGE_DEVID_SAS2208_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10785) case MPI2_MFGPAGE_DEVID_SAS2208_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10786) case MPI2_MFGPAGE_DEVID_SAS2208_4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10787) case MPI2_MFGPAGE_DEVID_SAS2208_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10788) case MPI2_MFGPAGE_DEVID_SAS2208_6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10789) case MPI2_MFGPAGE_DEVID_SAS2308_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10790) case MPI2_MFGPAGE_DEVID_SAS2308_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10791) case MPI2_MFGPAGE_DEVID_SAS2308_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10792) case MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10793) case MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10794) return MPI2_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10795) case MPI25_MFGPAGE_DEVID_SAS3004:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10796) case MPI25_MFGPAGE_DEVID_SAS3008:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10797) case MPI25_MFGPAGE_DEVID_SAS3108_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10798) case MPI25_MFGPAGE_DEVID_SAS3108_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10799) case MPI25_MFGPAGE_DEVID_SAS3108_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10800) case MPI25_MFGPAGE_DEVID_SAS3108_6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10801) return MPI25_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10802) case MPI26_MFGPAGE_DEVID_SAS3216:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10803) case MPI26_MFGPAGE_DEVID_SAS3224:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10804) case MPI26_MFGPAGE_DEVID_SAS3316_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10805) case MPI26_MFGPAGE_DEVID_SAS3316_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10806) case MPI26_MFGPAGE_DEVID_SAS3316_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10807) case MPI26_MFGPAGE_DEVID_SAS3316_4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10808) case MPI26_MFGPAGE_DEVID_SAS3324_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10809) case MPI26_MFGPAGE_DEVID_SAS3324_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10810) case MPI26_MFGPAGE_DEVID_SAS3324_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10811) case MPI26_MFGPAGE_DEVID_SAS3324_4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10812) case MPI26_MFGPAGE_DEVID_SAS3508:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10813) case MPI26_MFGPAGE_DEVID_SAS3508_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10814) case MPI26_MFGPAGE_DEVID_SAS3408:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10815) case MPI26_MFGPAGE_DEVID_SAS3516:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10816) case MPI26_MFGPAGE_DEVID_SAS3516_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10817) case MPI26_MFGPAGE_DEVID_SAS3416:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10818) case MPI26_MFGPAGE_DEVID_SAS3616:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10819) case MPI26_ATLAS_PCIe_SWITCH_DEVID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10820) case MPI26_MFGPAGE_DEVID_CFG_SEC_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10821) case MPI26_MFGPAGE_DEVID_HARD_SEC_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10822) case MPI26_MFGPAGE_DEVID_CFG_SEC_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10823) case MPI26_MFGPAGE_DEVID_HARD_SEC_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10824) case MPI26_MFGPAGE_DEVID_INVALID0_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10825) case MPI26_MFGPAGE_DEVID_INVALID1_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10826) case MPI26_MFGPAGE_DEVID_INVALID0_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10827) case MPI26_MFGPAGE_DEVID_INVALID1_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10828) return MPI26_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10830) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10833) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10834) * _scsih_probe - attach and add scsi host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10835) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10836) * @id: pci device id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10837) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10838) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10839) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10840) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10841) _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10842) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10843) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10844) struct Scsi_Host *shost = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10845) int rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10846) u16 hba_mpi_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10848) /* Determine in which MPI version class this pci device belongs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10849) hba_mpi_version = _scsih_determine_hba_mpi_version(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10850) if (hba_mpi_version == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10851) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10853) /* Enumerate only SAS 2.0 HBA's if hbas_to_enumerate is one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10854) * for other generation HBA's return with -ENODEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10855) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10856) if ((hbas_to_enumerate == 1) && (hba_mpi_version != MPI2_VERSION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10857) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10859) /* Enumerate only SAS 3.0 HBA's if hbas_to_enumerate is two,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10860) * for other generation HBA's return with -ENODEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10861) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10862) if ((hbas_to_enumerate == 2) && (!(hba_mpi_version == MPI25_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10863) || hba_mpi_version == MPI26_VERSION)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10864) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10866) switch (hba_mpi_version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10867) case MPI2_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10868) pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10869) PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10870) /* Use mpt2sas driver host template for SAS 2.0 HBA's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10871) shost = scsi_host_alloc(&mpt2sas_driver_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10872) sizeof(struct MPT3SAS_ADAPTER));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10873) if (!shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10874) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10875) ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10876) memset(ioc, 0, sizeof(struct MPT3SAS_ADAPTER));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10877) ioc->hba_mpi_version_belonged = hba_mpi_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10878) ioc->id = mpt2_ids++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10879) sprintf(ioc->driver_name, "%s", MPT2SAS_DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10880) switch (pdev->device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10881) case MPI2_MFGPAGE_DEVID_SSS6200:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10882) ioc->is_warpdrive = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10883) ioc->hide_ir_msg = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10884) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10885) case MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10886) case MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10887) ioc->is_mcpu_endpoint = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10888) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10889) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10890) ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10891) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10893) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10894) case MPI25_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10895) case MPI26_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10896) /* Use mpt3sas driver host template for SAS 3.0 HBA's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10897) shost = scsi_host_alloc(&mpt3sas_driver_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10898) sizeof(struct MPT3SAS_ADAPTER));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10899) if (!shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10900) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10901) ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10902) memset(ioc, 0, sizeof(struct MPT3SAS_ADAPTER));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10903) ioc->hba_mpi_version_belonged = hba_mpi_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10904) ioc->id = mpt3_ids++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10905) sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10906) switch (pdev->device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10907) case MPI26_MFGPAGE_DEVID_SAS3508:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10908) case MPI26_MFGPAGE_DEVID_SAS3508_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10909) case MPI26_MFGPAGE_DEVID_SAS3408:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10910) case MPI26_MFGPAGE_DEVID_SAS3516:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10911) case MPI26_MFGPAGE_DEVID_SAS3516_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10912) case MPI26_MFGPAGE_DEVID_SAS3416:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10913) case MPI26_MFGPAGE_DEVID_SAS3616:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10914) case MPI26_ATLAS_PCIe_SWITCH_DEVID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10915) ioc->is_gen35_ioc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10916) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10917) case MPI26_MFGPAGE_DEVID_INVALID0_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10918) case MPI26_MFGPAGE_DEVID_INVALID0_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10919) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10920) "HBA with DeviceId 0x%04x, sub VendorId 0x%04x, sub DeviceId 0x%04x is Invalid",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10921) pdev->device, pdev->subsystem_vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10922) pdev->subsystem_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10923) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10924) case MPI26_MFGPAGE_DEVID_INVALID1_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10925) case MPI26_MFGPAGE_DEVID_INVALID1_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10926) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10927) "HBA with DeviceId 0x%04x, sub VendorId 0x%04x, sub DeviceId 0x%04x is Tampered",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10928) pdev->device, pdev->subsystem_vendor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10929) pdev->subsystem_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10930) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10931) case MPI26_MFGPAGE_DEVID_CFG_SEC_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10932) case MPI26_MFGPAGE_DEVID_CFG_SEC_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10933) dev_info(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10934) "HBA is in Configurable Secure mode\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10935) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10936) case MPI26_MFGPAGE_DEVID_HARD_SEC_3816:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10937) case MPI26_MFGPAGE_DEVID_HARD_SEC_3916:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10938) ioc->is_aero_ioc = ioc->is_gen35_ioc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10939) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10940) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10941) ioc->is_gen35_ioc = ioc->is_aero_ioc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10943) if ((ioc->hba_mpi_version_belonged == MPI25_VERSION &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10944) pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10945) (ioc->hba_mpi_version_belonged == MPI26_VERSION)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10946) ioc->combined_reply_queue = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10947) if (ioc->is_gen35_ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10948) ioc->combined_reply_index_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10949) MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10950) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10951) ioc->combined_reply_index_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10952) MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10954) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10955) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10956) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10959) INIT_LIST_HEAD(&ioc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10960) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10961) list_add_tail(&ioc->list, &mpt3sas_ioc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10962) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10963) ioc->shost = shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10964) ioc->pdev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10965) ioc->scsi_io_cb_idx = scsi_io_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10966) ioc->tm_cb_idx = tm_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10967) ioc->ctl_cb_idx = ctl_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10968) ioc->base_cb_idx = base_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10969) ioc->port_enable_cb_idx = port_enable_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10970) ioc->transport_cb_idx = transport_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10971) ioc->scsih_cb_idx = scsih_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10972) ioc->config_cb_idx = config_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10973) ioc->tm_tr_cb_idx = tm_tr_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10974) ioc->tm_tr_volume_cb_idx = tm_tr_volume_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10975) ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10976) ioc->logging_level = logging_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10977) ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10978) /* Host waits for minimum of six seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10979) ioc->max_shutdown_latency = IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10980) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10981) * Enable MEMORY MOVE support flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10982) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10983) ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10985) ioc->enable_sdev_max_qd = enable_sdev_max_qd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10987) /* misc semaphores and spin locks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10988) mutex_init(&ioc->reset_in_progress_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10989) /* initializing pci_access_mutex lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10990) mutex_init(&ioc->pci_access_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10991) spin_lock_init(&ioc->ioc_reset_in_progress_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10992) spin_lock_init(&ioc->scsi_lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10993) spin_lock_init(&ioc->sas_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10994) spin_lock_init(&ioc->sas_node_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10995) spin_lock_init(&ioc->fw_event_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10996) spin_lock_init(&ioc->raid_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10997) spin_lock_init(&ioc->pcie_device_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10998) spin_lock_init(&ioc->diag_trigger_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11000) INIT_LIST_HEAD(&ioc->sas_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11001) INIT_LIST_HEAD(&ioc->sas_device_init_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11002) INIT_LIST_HEAD(&ioc->sas_expander_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11003) INIT_LIST_HEAD(&ioc->enclosure_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11004) INIT_LIST_HEAD(&ioc->pcie_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11005) INIT_LIST_HEAD(&ioc->pcie_device_init_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11006) INIT_LIST_HEAD(&ioc->fw_event_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11007) INIT_LIST_HEAD(&ioc->raid_device_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11008) INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11009) INIT_LIST_HEAD(&ioc->delayed_tr_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11010) INIT_LIST_HEAD(&ioc->delayed_sc_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11011) INIT_LIST_HEAD(&ioc->delayed_event_ack_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11012) INIT_LIST_HEAD(&ioc->delayed_tr_volume_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11013) INIT_LIST_HEAD(&ioc->reply_queue_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11015) sprintf(ioc->name, "%s_cm%d", ioc->driver_name, ioc->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11017) /* init shost parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11018) shost->max_cmd_len = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11019) shost->max_lun = max_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11020) shost->transportt = mpt3sas_transport_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11021) shost->unique_id = ioc->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11023) if (ioc->is_mcpu_endpoint) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11024) /* mCPU MPI support 64K max IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11025) shost->max_sectors = 128;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11026) ioc_info(ioc, "The max_sectors value is set to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11027) shost->max_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11028) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11029) if (max_sectors != 0xFFFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11030) if (max_sectors < 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11031) shost->max_sectors = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11032) ioc_warn(ioc, "Invalid value %d passed for max_sectors, range is 64 to 32767. Assigning value of 64.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11033) max_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11034) } else if (max_sectors > 32767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11035) shost->max_sectors = 32767;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11036) ioc_warn(ioc, "Invalid value %d passed for max_sectors, range is 64 to 32767.Assigning default value of 32767.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11037) max_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11038) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11039) shost->max_sectors = max_sectors & 0xFFFE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11040) ioc_info(ioc, "The max_sectors value is set to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11041) shost->max_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11045) /* register EEDP capabilities with SCSI layer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11046) if (prot_mask >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11047) scsi_host_set_prot(shost, (prot_mask & 0x07));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11048) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11049) scsi_host_set_prot(shost, SHOST_DIF_TYPE1_PROTECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11050) | SHOST_DIF_TYPE2_PROTECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11051) | SHOST_DIF_TYPE3_PROTECTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11053) scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11055) /* event thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11056) snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11057) "fw_event_%s%d", ioc->driver_name, ioc->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11058) ioc->firmware_event_thread = alloc_ordered_workqueue(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11059) ioc->firmware_event_name, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11060) if (!ioc->firmware_event_thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11061) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11062) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11063) rv = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11064) goto out_thread_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11065) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11067) ioc->is_driver_loading = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11068) if ((mpt3sas_base_attach(ioc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11069) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11070) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11071) rv = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11072) goto out_attach_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11075) if (ioc->is_warpdrive) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11076) if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_EXPOSE_ALL_DISKS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11077) ioc->hide_drives = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11078) else if (ioc->mfg_pg10_hide_flag == MFG_PAGE10_HIDE_ALL_DISKS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11079) ioc->hide_drives = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11080) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11081) if (mpt3sas_get_num_volumes(ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11082) ioc->hide_drives = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11083) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11084) ioc->hide_drives = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11086) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11087) ioc->hide_drives = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11089) rv = scsi_add_host(shost, &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11090) if (rv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11091) ioc_err(ioc, "failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11092) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11093) goto out_add_shost_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11096) scsi_scan_host(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11097) mpt3sas_setup_debugfs(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11098) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11099) out_add_shost_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11100) mpt3sas_base_detach(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11101) out_attach_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11102) destroy_workqueue(ioc->firmware_event_thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11103) out_thread_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11104) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11105) list_del(&ioc->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11106) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11107) scsi_host_put(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11108) return rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11111) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11113) * scsih_suspend - power management suspend main entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11114) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11115) * @state: PM state change to (usually PCI_D3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11116) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11117) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11119) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11120) scsih_suspend(struct pci_dev *pdev, pm_message_t state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11122) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11123) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11124) pci_power_t device_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11125) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11127) rc = _scsih_get_shost_and_ioc(pdev, &shost, &ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11128) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11129) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11131) mpt3sas_base_stop_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11132) flush_scheduled_work();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11133) scsi_block_requests(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11134) _scsih_nvme_shutdown(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11135) device_state = pci_choose_state(pdev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11136) ioc_info(ioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11137) pdev, pci_name(pdev), device_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11139) pci_save_state(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11140) mpt3sas_base_free_resources(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11141) pci_set_power_state(pdev, device_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11142) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11145) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11146) * scsih_resume - power management resume main entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11147) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11148) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11149) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11151) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11152) scsih_resume(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11154) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11155) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11156) pci_power_t device_state = pdev->current_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11157) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11159) r = _scsih_get_shost_and_ioc(pdev, &shost, &ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11160) if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11161) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11163) ioc_info(ioc, "pdev=0x%p, slot=%s, previous operating state [D%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11164) pdev, pci_name(pdev), device_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11166) pci_set_power_state(pdev, PCI_D0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11167) pci_enable_wake(pdev, PCI_D0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11168) pci_restore_state(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11169) ioc->pdev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11170) r = mpt3sas_base_map_resources(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11171) if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11172) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11173) ioc_info(ioc, "Issuing Hard Reset as part of OS Resume\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11174) mpt3sas_base_hard_reset_handler(ioc, SOFT_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11175) scsi_unblock_requests(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11176) mpt3sas_base_start_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11177) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11179) #endif /* CONFIG_PM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11181) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11182) * scsih_pci_error_detected - Called when a PCI error is detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11183) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11184) * @state: PCI channel state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11185) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11186) * Description: Called when a PCI error is detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11187) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11188) * Return: PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11190) static pci_ers_result_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11191) scsih_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11193) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11194) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11196) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11197) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11199) ioc_info(ioc, "PCI error: detected callback, state(%d)!!\n", state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11201) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11202) case pci_channel_io_normal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11203) return PCI_ERS_RESULT_CAN_RECOVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11204) case pci_channel_io_frozen:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11205) /* Fatal error, prepare for slot reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11206) ioc->pci_error_recovery = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11207) scsi_block_requests(ioc->shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11208) mpt3sas_base_stop_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11209) mpt3sas_base_free_resources(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11210) return PCI_ERS_RESULT_NEED_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11211) case pci_channel_io_perm_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11212) /* Permanent error, prepare for device removal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11213) ioc->pci_error_recovery = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11214) mpt3sas_base_stop_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11215) _scsih_flush_running_cmds(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11216) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11218) return PCI_ERS_RESULT_NEED_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11221) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11222) * scsih_pci_slot_reset - Called when PCI slot has been reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11223) * @pdev: PCI device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11224) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11225) * Description: This routine is called by the pci error recovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11226) * code after the PCI slot has been reset, just before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11227) * should resume normal operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11229) static pci_ers_result_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11230) scsih_pci_slot_reset(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11232) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11233) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11234) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11236) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11237) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11239) ioc_info(ioc, "PCI error: slot reset callback!!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11241) ioc->pci_error_recovery = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11242) ioc->pdev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11243) pci_restore_state(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11244) rc = mpt3sas_base_map_resources(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11245) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11246) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11248) ioc_info(ioc, "Issuing Hard Reset as part of PCI Slot Reset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11249) rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11251) ioc_warn(ioc, "hard reset: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11252) (rc == 0) ? "success" : "failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11254) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11255) return PCI_ERS_RESULT_RECOVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11256) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11257) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11260) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11261) * scsih_pci_resume() - resume normal ops after PCI reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11262) * @pdev: pointer to PCI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11263) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11264) * Called when the error recovery driver tells us that its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11265) * OK to resume normal operation. Use completion to allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11266) * halted scsi ops to resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11268) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11269) scsih_pci_resume(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11271) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11272) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11274) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11275) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11277) ioc_info(ioc, "PCI error: resume callback!!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11279) mpt3sas_base_start_watchdog(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11280) scsi_unblock_requests(ioc->shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11283) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11284) * scsih_pci_mmio_enabled - Enable MMIO and dump debug registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11285) * @pdev: pointer to PCI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11286) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11287) static pci_ers_result_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11288) scsih_pci_mmio_enabled(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11290) struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11291) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11293) if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11294) return PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11296) ioc_info(ioc, "PCI error: mmio enabled callback!!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11298) /* TODO - dump whatever for debugging purposes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11300) /* This called only if scsih_pci_error_detected returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11301) * PCI_ERS_RESULT_CAN_RECOVER. Read/write to the device still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11302) * works, no need to reset slot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11303) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11304) return PCI_ERS_RESULT_RECOVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11307) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11308) * scsih__ncq_prio_supp - Check for NCQ command priority support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11309) * @sdev: scsi device struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11310) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11311) * This is called when a user indicates they would like to enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11312) * ncq command priorities. This works only on SATA devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11314) bool scsih_ncq_prio_supp(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11316) unsigned char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11317) bool ncq_prio_supp = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11319) if (!scsi_device_supports_vpd(sdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11320) return ncq_prio_supp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11322) buf = kmalloc(SCSI_VPD_PG_LEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11323) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11324) return ncq_prio_supp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11326) if (!scsi_get_vpd_page(sdev, 0x89, buf, SCSI_VPD_PG_LEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11327) ncq_prio_supp = (buf[213] >> 4) & 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11329) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11330) return ncq_prio_supp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11332) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11333) * The pci device ids are defined in mpi/mpi2_cnfg.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11334) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11335) static const struct pci_device_id mpt3sas_pci_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11336) /* Spitfire ~ 2004 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11337) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11338) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11339) /* Falcon ~ 2008 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11340) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2008,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11341) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11342) /* Liberator ~ 2108 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11343) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11344) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11345) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11346) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11347) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11348) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11349) /* Meteor ~ 2116 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11350) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11351) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11352) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11353) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11354) /* Thunderbolt ~ 2208 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11355) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11356) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11357) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11358) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11359) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11360) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11361) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11362) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11363) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11364) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11365) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11366) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11367) /* Mustang ~ 2308 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11368) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11369) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11370) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11371) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11372) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11373) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11374) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11375) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11376) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SWITCH_MPI_EP_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11377) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11378) /* SSS6200 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11379) { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SSS6200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11380) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11381) /* Fury ~ 3004 and 3008 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11382) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11383) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11384) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3008,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11385) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11386) /* Invader ~ 3108 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11387) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11388) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11389) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11390) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11391) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11392) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11393) { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11394) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11395) /* Cutlass ~ 3216 and 3224 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11396) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3216,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11397) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11398) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3224,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11399) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11400) /* Intruder ~ 3316 and 3324 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11401) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3316_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11402) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11403) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3316_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11404) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11405) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3316_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11406) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11407) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3316_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11408) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11409) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3324_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11410) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11411) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3324_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11412) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11413) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3324_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11414) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11415) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3324_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11416) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11417) /* Ventura, Crusader, Harpoon & Tomcat ~ 3516, 3416, 3508 & 3408*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11418) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3508,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11419) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11420) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3508_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11421) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11422) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3408,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11423) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11424) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3516,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11425) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11426) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3516_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11427) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11428) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3416,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11429) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11430) /* Mercator ~ 3616*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11431) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3616,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11432) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11434) /* Aero SI 0x00E1 Configurable Secure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11435) * 0x00E2 Hard Secure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11436) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11437) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_CFG_SEC_3916,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11438) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11439) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_HARD_SEC_3916,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11440) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11442) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11443) * Aero SI –> 0x00E0 Invalid, 0x00E3 Tampered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11444) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11445) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_INVALID0_3916,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11446) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11447) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_INVALID1_3916,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11448) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11450) /* Atlas PCIe Switch Management Port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11451) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_ATLAS_PCIe_SWITCH_DEVID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11452) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11454) /* Sea SI 0x00E5 Configurable Secure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11455) * 0x00E6 Hard Secure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11456) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11457) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_CFG_SEC_3816,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11458) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11459) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_HARD_SEC_3816,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11460) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11462) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11463) * Sea SI –> 0x00E4 Invalid, 0x00E7 Tampered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11465) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_INVALID0_3816,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11466) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11467) { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_INVALID1_3816,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11468) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11470) {0} /* Terminating entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11472) MODULE_DEVICE_TABLE(pci, mpt3sas_pci_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11474) static struct pci_error_handlers _mpt3sas_err_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11475) .error_detected = scsih_pci_error_detected,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11476) .mmio_enabled = scsih_pci_mmio_enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11477) .slot_reset = scsih_pci_slot_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11478) .resume = scsih_pci_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11479) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11481) static struct pci_driver mpt3sas_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11482) .name = MPT3SAS_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11483) .id_table = mpt3sas_pci_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11484) .probe = _scsih_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11485) .remove = scsih_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11486) .shutdown = scsih_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11487) .err_handler = &_mpt3sas_err_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11488) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11489) .suspend = scsih_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11490) .resume = scsih_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11491) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11492) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11494) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11495) * scsih_init - main entry point for this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11496) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11497) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11498) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11499) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11500) scsih_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11502) mpt2_ids = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11503) mpt3_ids = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11505) mpt3sas_base_initialize_callback_handler();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11507) /* queuecommand callback hander */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11508) scsi_io_cb_idx = mpt3sas_base_register_callback_handler(_scsih_io_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11510) /* task management callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11511) tm_cb_idx = mpt3sas_base_register_callback_handler(_scsih_tm_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11513) /* base internal commands callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11514) base_cb_idx = mpt3sas_base_register_callback_handler(mpt3sas_base_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11515) port_enable_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11516) mpt3sas_port_enable_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11518) /* transport internal commands callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11519) transport_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11520) mpt3sas_transport_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11522) /* scsih internal commands callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11523) scsih_cb_idx = mpt3sas_base_register_callback_handler(_scsih_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11525) /* configuration page API internal commands callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11526) config_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11527) mpt3sas_config_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11529) /* ctl module callback handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11530) ctl_cb_idx = mpt3sas_base_register_callback_handler(mpt3sas_ctl_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11532) tm_tr_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11533) _scsih_tm_tr_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11535) tm_tr_volume_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11536) _scsih_tm_volume_tr_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11538) tm_sas_control_cb_idx = mpt3sas_base_register_callback_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11539) _scsih_sas_control_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11541) mpt3sas_init_debugfs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11542) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11545) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11546) * scsih_exit - exit point for this driver (when it is a module).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11547) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11548) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11549) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11550) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11551) scsih_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11554) mpt3sas_base_release_callback_handler(scsi_io_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11555) mpt3sas_base_release_callback_handler(tm_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11556) mpt3sas_base_release_callback_handler(base_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11557) mpt3sas_base_release_callback_handler(port_enable_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11558) mpt3sas_base_release_callback_handler(transport_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11559) mpt3sas_base_release_callback_handler(scsih_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11560) mpt3sas_base_release_callback_handler(config_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11561) mpt3sas_base_release_callback_handler(ctl_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11563) mpt3sas_base_release_callback_handler(tm_tr_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11564) mpt3sas_base_release_callback_handler(tm_tr_volume_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11565) mpt3sas_base_release_callback_handler(tm_sas_control_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11567) /* raid transport support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11568) if (hbas_to_enumerate != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11569) raid_class_release(mpt3sas_raid_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11570) if (hbas_to_enumerate != 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11571) raid_class_release(mpt2sas_raid_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11572) sas_release_transport(mpt3sas_transport_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11573) mpt3sas_exit_debugfs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11576) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11577) * _mpt3sas_init - main entry point for this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11578) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11579) * Return: 0 success, anything else error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11580) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11581) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11582) _mpt3sas_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11583) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11584) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11586) pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11587) MPT3SAS_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11589) mpt3sas_transport_template =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11590) sas_attach_transport(&mpt3sas_transport_functions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11591) if (!mpt3sas_transport_template)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11592) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11594) /* No need attach mpt3sas raid functions template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11595) * if hbas_to_enumarate value is one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11596) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11597) if (hbas_to_enumerate != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11598) mpt3sas_raid_template =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11599) raid_class_attach(&mpt3sas_raid_functions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11600) if (!mpt3sas_raid_template) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11601) sas_release_transport(mpt3sas_transport_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11602) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11606) /* No need to attach mpt2sas raid functions template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11607) * if hbas_to_enumarate value is two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11609) if (hbas_to_enumerate != 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11610) mpt2sas_raid_template =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11611) raid_class_attach(&mpt2sas_raid_functions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11612) if (!mpt2sas_raid_template) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11613) sas_release_transport(mpt3sas_transport_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11614) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11618) error = scsih_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11619) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11620) scsih_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11621) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11624) mpt3sas_ctl_init(hbas_to_enumerate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11626) error = pci_register_driver(&mpt3sas_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11627) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11628) scsih_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11630) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11633) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11634) * _mpt3sas_exit - exit point for this driver (when it is a module).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11635) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11636) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11637) static void __exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11638) _mpt3sas_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11640) pr_info("mpt3sas version %s unloading\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11641) MPT3SAS_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11643) mpt3sas_ctl_exit(hbas_to_enumerate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11645) pci_unregister_driver(&mpt3sas_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11647) scsih_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11650) module_init(_mpt3sas_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11651) module_exit(_mpt3sas_exit);