^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/message/fusion/mptsas.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * For use with LSI PCI chip/adapter(s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * running LSI Fusion MPT (Message Passing Technology) firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 1999-2008 LSI Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * (mailto:DL-MPTFusionLinux@lsi.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) solely responsible for determining the appropriateness of using and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) distributing the Program and assumes all risks associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) exercise of rights under this Agreement, including but not limited to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) the risks and costs of program errors, damage to or loss of data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) programs or equipment, and unavailability or interruption of operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) DISCLAIMER OF LIABILITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/delay.h> /* for mdelay */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <scsi/scsi_cmnd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include <scsi/scsi_transport_sas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include <scsi/scsi_transport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include <scsi/scsi_dbg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #include "mptbase.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #include "mptscsih.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #include "mptsas.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define my_NAME "Fusion MPT SAS Host driver"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define my_VERSION MPT_LINUX_VERSION_COMMON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define MYNAM "mptsas"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * Reserved channel for integrated raid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define MPTSAS_RAID_CHANNEL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define SAS_CONFIG_PAGE_TIMEOUT 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_AUTHOR(MODULEAUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) MODULE_DESCRIPTION(my_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) MODULE_VERSION(my_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static int mpt_pt_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) module_param(mpt_pt_clear, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) MODULE_PARM_DESC(mpt_pt_clear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) " Clear persistency table: enable=1 "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) "(default=MPTSCSIH_PT_CLEAR=0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define MPTSAS_MAX_LUN (16895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static int max_lun = MPTSAS_MAX_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) module_param(max_lun, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) MODULE_PARM_DESC(max_lun, " max lun, default=16895 ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static int mpt_loadtime_max_sectors = 8192;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) module_param(mpt_loadtime_max_sectors, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) MODULE_PARM_DESC(mpt_loadtime_max_sectors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) " Maximum sector define for Host Bus Adaptor.Range 64 to 8192 default=8192");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static u8 mptsasDoneCtx = MPT_MAX_PROTOCOL_DRIVERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static u8 mptsasTaskCtx = MPT_MAX_PROTOCOL_DRIVERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static u8 mptsasInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static u8 mptsasMgmtCtx = MPT_MAX_PROTOCOL_DRIVERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static u8 mptsasDeviceResetCtx = MPT_MAX_PROTOCOL_DRIVERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static void mptsas_firmware_event_work(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static void mptsas_send_sas_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static void mptsas_send_raid_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static void mptsas_send_ir2_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static void mptsas_parse_device_info(struct sas_identify *identify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct mptsas_devinfo *device_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static inline void mptsas_set_rphy(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static struct mptsas_phyinfo *mptsas_find_phyinfo_by_sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) (MPT_ADAPTER *ioc, u64 sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static int mptsas_sas_device_pg0(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct mptsas_devinfo *device_info, u32 form, u32 form_specific);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static int mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct mptsas_enclosure *enclosure, u32 form, u32 form_specific);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static int mptsas_add_end_device(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct mptsas_phyinfo *phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void mptsas_del_end_device(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct mptsas_phyinfo *phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static void mptsas_send_link_status_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static struct mptsas_portinfo *mptsas_find_portinfo_by_sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) (MPT_ADAPTER *ioc, u64 sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void mptsas_expander_delete(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct mptsas_portinfo *port_info, u8 force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static void mptsas_send_expander_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void mptsas_not_responding_devices(MPT_ADAPTER *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void mptsas_scan_sas_topology(MPT_ADAPTER *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void mptsas_broadcast_primitive_work(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void mptsas_handle_queue_full_event(struct fw_event_work *fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static void mptsas_volume_delete(MPT_ADAPTER *ioc, u8 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void mptsas_schedule_target_reset(void *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static void mptsas_print_phy_data(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) "---- IO UNIT PAGE 0 ------------\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ioc->name, le16_to_cpu(phy_data->AttachedDeviceHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Controller Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) ioc->name, le16_to_cpu(phy_data->ControllerDevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ioc->name, phy_data->Port));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port Flags=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ioc->name, phy_data->PortFlags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Flags=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) ioc->name, phy_data->PhyFlags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ioc->name, phy_data->NegotiatedLinkRate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) "Controller PHY Device Info=0x%X\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) le32_to_cpu(phy_data->ControllerPhyDeviceInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DiscoveryStatus=0x%X\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ioc->name, le32_to_cpu(phy_data->DiscoveryStatus)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) "---- SAS PHY PAGE 0 ------------\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) "Attached Device Handle=0x%X\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) le16_to_cpu(pg0->AttachedDevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) "Attached PHY Identifier=0x%X\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) pg0->AttachedPhyIdentifier));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Attached Device Info=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ioc->name, le32_to_cpu(pg0->AttachedDeviceInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) ioc->name, pg0->ProgrammedLinkRate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Change Count=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ioc->name, pg0->ChangeCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Info=0x%X\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ioc->name, le32_to_cpu(pg0->PhyInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) "---- SAS PHY PAGE 1 ------------\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Invalid Dword Count=0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ioc->name, pg1->InvalidDwordCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) "Running Disparity Error Count=0x%x\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) pg1->RunningDisparityErrorCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) "Loss Dword Synch Count=0x%x\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) pg1->LossDwordSynchCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) "PHY Reset Problem Count=0x%x\n\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) pg1->PhyResetProblemCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) "---- SAS DEVICE PAGE 0 ---------\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ioc->name, le16_to_cpu(pg0->DevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ioc->name, le16_to_cpu(pg0->ParentDevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Enclosure Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ioc->name, le16_to_cpu(pg0->EnclosureHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Slot=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ioc->name, le16_to_cpu(pg0->Slot)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Target ID=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) ioc->name, pg0->TargetID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Bus=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ioc->name, pg0->Bus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Phy Num=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ioc->name, pg0->PhyNum));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Access Status=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ioc->name, le16_to_cpu(pg0->AccessStatus)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Device Info=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ioc->name, le32_to_cpu(pg0->DeviceInfo)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Flags=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ioc->name, le16_to_cpu(pg0->Flags)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ioc->name, pg0->PhysicalPort));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) "---- SAS EXPANDER PAGE 1 ------------\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) ioc->name, pg1->PhysicalPort));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Identifier=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ioc->name, pg1->PhyIdentifier));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ioc->name, pg1->NegotiatedLinkRate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) ioc->name, pg1->ProgrammedLinkRate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hardware Link Rate=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ioc->name, pg1->HwLinkRate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Owner Device Handle=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) ioc->name, le16_to_cpu(pg1->OwnerDevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) "Attached Device Handle=0x%X\n\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) le16_to_cpu(pg1->AttachedDevHandle)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) /* inhibit sas firmware event handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) mptsas_fw_event_off(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ioc->fw_events_off = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ioc->sas_discovery_quiesce_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* enable sas firmware event handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) mptsas_fw_event_on(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ioc->fw_events_off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /* queue a sas firmware event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) mptsas_add_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) unsigned long delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) list_add_tail(&fw_event->list, &ioc->fw_event_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) INIT_DELAYED_WORK(&fw_event->work, mptsas_firmware_event_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: add (fw_event=0x%p)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) "on cpuid %d\n", ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) fw_event, smp_processor_id()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) &fw_event->work, delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /* requeue a sas firmware event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) mptsas_requeue_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) unsigned long delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: reschedule task "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) "(fw_event=0x%p)on cpuid %d\n", ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) fw_event, smp_processor_id()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) fw_event->retries++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) &fw_event->work, msecs_to_jiffies(delay));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* free memory associated to a sas firmware event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) mptsas_free_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) spin_lock_irqsave(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: kfree (fw_event=0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) ioc->name, __func__, fw_event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) list_del(&fw_event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) kfree(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /* walk the firmware event queue, and either stop or wait for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * outstanding events to complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) mptsas_cleanup_fw_event_q(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct fw_event_work *fw_event, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct mptsas_target_reset_event *target_reset_list, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /* flush the target_reset_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (!list_empty(&hd->target_reset_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) list_for_each_entry_safe(target_reset_list, n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) &hd->target_reset_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) "%s: removing target reset for id=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) target_reset_list->sas_event_data.TargetID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) list_del(&target_reset_list->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) kfree(target_reset_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (list_empty(&ioc->fw_event_list) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) !ioc->fw_event_q || in_interrupt())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) list_for_each_entry_safe(fw_event, next, &ioc->fw_event_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (cancel_delayed_work(&fw_event->work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) return ((MPT_SCSI_HOST *)shost->hostdata)->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static inline MPT_ADAPTER *rphy_to_ioc(struct sas_rphy *rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return ((MPT_SCSI_HOST *)shost->hostdata)->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * mptsas_find_portinfo_by_handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * This function should be called with the sas_topology_mutex already held
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) static struct mptsas_portinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) struct mptsas_portinfo *port_info, *rc=NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) list_for_each_entry(port_info, &ioc->sas_topology, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) for (i = 0; i < port_info->num_phys; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) if (port_info->phy_info[i].identify.handle == handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) rc = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * mptsas_find_portinfo_by_sas_address -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * @handle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * This function should be called with the sas_topology_mutex already held
^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) static struct mptsas_portinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) mptsas_find_portinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) struct mptsas_portinfo *port_info, *rc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (sas_address >= ioc->hba_port_sas_addr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) sas_address < (ioc->hba_port_sas_addr +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) ioc->hba_port_num_phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) return ioc->hba_port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) list_for_each_entry(port_info, &ioc->sas_topology, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) for (i = 0; i < port_info->num_phys; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (port_info->phy_info[i].identify.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) rc = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) return rc;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * Returns true if there is a scsi end device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) mptsas_is_end_device(struct mptsas_devinfo * attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) if ((attached->sas_address) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) (attached->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) MPI_SAS_DEVICE_INFO_END_DEVICE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) ((attached->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) MPI_SAS_DEVICE_INFO_SSP_TARGET) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) (attached->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) MPI_SAS_DEVICE_INFO_STP_TARGET) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) (attached->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) MPI_SAS_DEVICE_INFO_SATA_DEVICE)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /* no mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) u8 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (!port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) port_info = port_details->port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) phy_info = port_info->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) "bitmask=0x%016llX\n", ioc->name, __func__, port_details,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) port_details->num_phys, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) port_details->phy_bitmask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) for (i = 0; i < port_info->num_phys; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if(phy_info->port_details != port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) mptsas_set_rphy(ioc, phy_info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) phy_info->port_details = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) kfree(port_details);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static inline struct sas_rphy *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) if (phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) return phy_info->port_details->rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (phy_info->port_details) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) phy_info->port_details->rphy = rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) ioc->name, rphy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (rphy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ioc->name, rphy, rphy->dev.release));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) static inline struct sas_port *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) mptsas_get_port(struct mptsas_phyinfo *phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) if (phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) return phy_info->port_details->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) mptsas_set_port(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_port *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) phy_info->port_details->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if (port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) &port->dev, MYIOC_s_FMT "add:", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "port=%p release=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) ioc->name, port, port->dev.release));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) static inline struct scsi_target *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) mptsas_get_starget(struct mptsas_phyinfo *phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) return phy_info->port_details->starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) mptsas_set_starget(struct mptsas_phyinfo *phy_info, struct scsi_target *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) phy_info->port_details->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * mptsas_add_device_component -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * @channel: fw mapped id's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * @id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * @sas_address:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * @device_info:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) mptsas_add_device_component(MPT_ADAPTER *ioc, u8 channel, u8 id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) u64 sas_address, u32 device_info, u16 slot, u64 enclosure_logical_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) struct mptsas_device_info *sas_info, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * Delete all matching devices out of the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (!sas_info->is_logical_volume &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) (sas_info->sas_address == sas_address ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) (sas_info->fw.channel == channel &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) sas_info->fw.id == id))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) list_del(&sas_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) kfree(sas_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) sas_info = kzalloc(sizeof(struct mptsas_device_info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if (!sas_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) * Set Firmware mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) sas_info->fw.id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) sas_info->fw.channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) sas_info->sas_address = sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) sas_info->device_info = device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) sas_info->slot = slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) sas_info->enclosure_logical_id = enclosure_logical_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) INIT_LIST_HEAD(&sas_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) list_add_tail(&sas_info->list, &ioc->sas_device_info_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * Set OS mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) shost_for_each_device(sdev, ioc->sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) starget = scsi_target(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) rphy = dev_to_rphy(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) if (rphy->identify.sas_address == sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) sas_info->os.id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) sas_info->os.channel = starget->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * mptsas_add_device_component_by_fw -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * @channel: fw mapped id's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * @id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) mptsas_add_device_component_by_fw(MPT_ADAPTER *ioc, u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct mptsas_devinfo sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct mptsas_enclosure enclosure_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) rc = mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) (channel << 8) + id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) memset(&enclosure_info, 0, sizeof(struct mptsas_enclosure));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) (MPI_SAS_ENCLOS_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) MPI_SAS_ENCLOS_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) sas_device.handle_enclosure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) mptsas_add_device_component(ioc, sas_device.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) sas_device.id, sas_device.sas_address, sas_device.device_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) sas_device.slot, enclosure_info.enclosure_logical_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * mptsas_add_device_component_starget_ir - Handle Integrated RAID, adding each individual device to list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) * @channel: fw mapped id's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) * @id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) mptsas_add_device_component_starget_ir(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) ConfigPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) pRaidVolumePage0_t buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) RaidPhysDiskPage0_t phys_disk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) struct mptsas_device_info *sas_info, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) memset(&cfg, 0 , sizeof(CONFIGPARMS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) memset(&hdr, 0 , sizeof(ConfigPageHeader_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) hdr.PageType = MPI_CONFIG_PAGETYPE_RAID_VOLUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) /* assumption that all volumes on channel = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) cfg.pageAddr = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) cfg.cfghdr.hdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) if (mpt_config(ioc, &cfg) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) if (!hdr.PageLength)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (mpt_config(ioc, &cfg) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) if (!buffer->NumPhysDisks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) * Adding entry for hidden components
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) for (i = 0; i < buffer->NumPhysDisks; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) if (mpt_raid_phys_disk_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) mptsas_add_device_component_by_fw(ioc, phys_disk.PhysDiskBus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) phys_disk.PhysDiskID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) list_for_each_entry(sas_info, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) if (!sas_info->is_logical_volume &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) (sas_info->fw.channel == phys_disk.PhysDiskBus &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) sas_info->fw.id == phys_disk.PhysDiskID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) sas_info->is_hidden_raid_component = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) sas_info->volume_id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * Delete all matching devices out of the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) if (sas_info->is_logical_volume && sas_info->fw.id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) starget->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) list_del(&sas_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) kfree(sas_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) sas_info = kzalloc(sizeof(struct mptsas_device_info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if (sas_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) sas_info->fw.id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) sas_info->os.id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) sas_info->os.channel = starget->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) sas_info->is_logical_volume = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) INIT_LIST_HEAD(&sas_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) list_add_tail(&sas_info->list, &ioc->sas_device_info_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) if (buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) * mptsas_add_device_component_starget -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) * @starget:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) mptsas_add_device_component_starget(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) VirtTarget *vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) struct mptsas_phyinfo *phy_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) struct mptsas_enclosure enclosure_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) rphy = dev_to_rphy(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) vtarget = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) rphy->identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) if (!phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) memset(&enclosure_info, 0, sizeof(struct mptsas_enclosure));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) (MPI_SAS_ENCLOS_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) MPI_SAS_ENCLOS_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) phy_info->attached.handle_enclosure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) mptsas_add_device_component(ioc, phy_info->attached.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) phy_info->attached.id, phy_info->attached.sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) phy_info->attached.device_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) phy_info->attached.slot, enclosure_info.enclosure_logical_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * mptsas_del_device_component_by_os - Once a device has been removed, we mark the entry in the list as being cached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) * @channel: os mapped id's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) * @id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) mptsas_del_device_component_by_os(MPT_ADAPTER *ioc, u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) struct mptsas_device_info *sas_info, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) * Set is_cached flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) if (sas_info->os.channel == channel && sas_info->os.id == id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) sas_info->is_cached = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * mptsas_del_device_components - Cleaning the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) mptsas_del_device_components(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) struct mptsas_device_info *sas_info, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) list_del(&sas_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) kfree(sas_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^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) * mptsas_setup_wide_ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) * Updates for new and existing narrow/wide port configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) * in the sas_topology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) struct mptsas_portinfo_details * port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) struct mptsas_phyinfo *phy_info, *phy_info_cmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) phy_info = port_info->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) if (phy_info->attached.handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) port_details = phy_info->port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) if (!port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) if (port_details->num_phys < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) * Removing a phy from a port, letting the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) * phy be removed by firmware events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) "%s: [%p]: deleting phy = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) ioc->name, __func__, port_details, i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) port_details->num_phys--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) port_details->phy_bitmask &= ~ (1 << phy_info->phy_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) if (phy_info->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) devtprintk(ioc, dev_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) &phy_info->phy->dev, MYIOC_s_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) "delete phy %d, phy-obj (0x%p)\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) phy_info->phy_id, phy_info->phy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) sas_port_delete_phy(port_details->port, phy_info->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) phy_info->port_details = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) * Populate and refresh the tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) phy_info = port_info->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) sas_address = phy_info->attached.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "phy_id=%d sas_address=0x%018llX\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) ioc->name, i, (unsigned long long)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) if (!sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) port_details = phy_info->port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * Forming a port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) if (!port_details) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) port_details = kzalloc(sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) mptsas_portinfo_details), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) if (!port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) port_details->num_phys = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) port_details->port_info = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) if (phy_info->phy_id < 64 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) port_details->phy_bitmask |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) (1 << phy_info->phy_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) phy_info->sas_port_add_phy=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tForming port\n\t\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) "phy_id=%d sas_address=0x%018llX\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) ioc->name, i, (unsigned long long)sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) phy_info->port_details = port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) if (i == port_info->num_phys - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) phy_info_cmp = &port_info->phy_info[i + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) for (j = i + 1 ; j < port_info->num_phys ; j++,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) phy_info_cmp++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if (!phy_info_cmp->attached.sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) if (sas_address != phy_info_cmp->attached.sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) if (phy_info_cmp->port_details == port_details )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) "\t\tphy_id=%d sas_address=0x%018llX\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) ioc->name, j, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) phy_info_cmp->attached.sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) if (phy_info_cmp->port_details) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) port_details->rphy =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) mptsas_get_rphy(phy_info_cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) port_details->port =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) mptsas_get_port(phy_info_cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) port_details->starget =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) mptsas_get_starget(phy_info_cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) port_details->num_phys =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) phy_info_cmp->port_details->num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) if (!phy_info_cmp->port_details->num_phys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) kfree(phy_info_cmp->port_details);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) phy_info_cmp->sas_port_add_phy=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) * Adding a phy to a port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) phy_info_cmp->port_details = port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) if (phy_info_cmp->phy_id < 64 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) port_details->phy_bitmask |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) (1 << phy_info_cmp->phy_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) port_details->num_phys++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) port_details = port_info->phy_info[i].port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) if (!port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) "%s: [%p]: phy_id=%02d num_phys=%02d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) "bitmask=0x%016llX\n", ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) port_details, i, port_details->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) (unsigned long long)port_details->phy_bitmask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) ioc->name, port_details->port, port_details->rphy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) dsaswideprintk(ioc, printk("\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) mutex_unlock(&ioc->sas_topology_mutex);
^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) * csmisas_find_vtarget
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) * @ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * @volume_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) * @volume_bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) static VirtTarget *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) VirtDevice *vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) VirtTarget *vtarget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) shost_for_each_device(sdev, ioc->sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) vdevice = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) if ((vdevice == NULL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) (vdevice->vtarget == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) if ((vdevice->vtarget->tflags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) MPT_TARGET_FLAGS_RAID_COMPONENT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) vdevice->vtarget->raidVolume))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) if (vdevice->vtarget->id == id &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) vdevice->vtarget->channel == channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) vtarget = vdevice->vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) return vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) mptsas_queue_device_delete(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) MpiEventDataSasDeviceStatusChange_t *sas_event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) fw_event = kzalloc(sizeof(*fw_event) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) sizeof(MpiEventDataSasDeviceStatusChange_t),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) if (!fw_event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) ioc->name, __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) memcpy(fw_event->event_data, sas_event_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) sizeof(MpiEventDataSasDeviceStatusChange_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) fw_event->event = MPI_EVENT_SAS_DEVICE_STATUS_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) mptsas_add_fw_event(ioc, fw_event, msecs_to_jiffies(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) mptsas_queue_rescan(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) fw_event = kzalloc(sizeof(*fw_event), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) if (!fw_event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) ioc->name, __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) fw_event->event = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) mptsas_add_fw_event(ioc, fw_event, msecs_to_jiffies(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^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) * mptsas_target_reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) * Issues TARGET_RESET to end device using handshaking method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) * @ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) * @channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) * @id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) * Returns (1) success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) * (0) failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) SCSITaskMgmt_t *pScsiTm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) if (mf == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) "%s, no msg frames @%d!!\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request (mf=%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) ioc->name, mf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) /* Format the Request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) pScsiTm = (SCSITaskMgmt_t *) mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) memset (pScsiTm, 0, sizeof(SCSITaskMgmt_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) pScsiTm->TargetID = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) pScsiTm->Bus = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) "TaskMgmt type=%d (sas device delete) fw_channel = %d fw_id = %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) ioc->name, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, channel, id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) out_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) mpt_clear_taskmgmt_in_progress_flag(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) mptsas_block_io_sdev(struct scsi_device *sdev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) scsi_device_set_state(sdev, SDEV_BLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) mptsas_block_io_starget(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) if (starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) starget_for_each_device(starget, NULL, mptsas_block_io_sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) * mptsas_target_reset_queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) * Receive request for TARGET_RESET after receiving an firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) * event NOT_RESPONDING_EVENT, then put command in link list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) * and queue if task_queue already in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) * @ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) * @sas_event_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) mptsas_target_reset_queue(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) VirtTarget *vtarget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) struct mptsas_target_reset_event *target_reset_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) u8 id, channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) id = sas_event_data->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) channel = sas_event_data->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) vtarget = mptsas_find_vtarget(ioc, channel, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) if (vtarget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) mptsas_block_io_starget(vtarget->starget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) vtarget->deleted = 1; /* block IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) target_reset_list = kzalloc(sizeof(struct mptsas_target_reset_event),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) if (!target_reset_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) "%s, failed to allocate mem @%d..!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) ioc->name, __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) memcpy(&target_reset_list->sas_event_data, sas_event_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) sizeof(*sas_event_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) list_add_tail(&target_reset_list->list, &hd->target_reset_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) target_reset_list->time_count = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) if (mptsas_target_reset(ioc, channel, id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) target_reset_list->target_reset_issued = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) * mptsas_schedule_target_reset- send pending target reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) * @iocp: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) * This function will delete scheduled target reset from the list and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) * try to send next target reset. This will be called from completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) * context of any Task management command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) mptsas_schedule_target_reset(void *iocp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) MPT_ADAPTER *ioc = (MPT_ADAPTER *)(iocp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) struct list_head *head = &hd->target_reset_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) struct mptsas_target_reset_event *target_reset_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) u8 id, channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) * issue target reset to next device in the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) if (list_empty(head))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) target_reset_list = list_entry(head->next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) struct mptsas_target_reset_event, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) id = target_reset_list->sas_event_data.TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) channel = target_reset_list->sas_event_data.Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) target_reset_list->time_count = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) if (mptsas_target_reset(ioc, channel, id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) target_reset_list->target_reset_issued = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) * mptsas_taskmgmt_complete - complete SAS task management function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) * Completion for TARGET_RESET after NOT_RESPONDING_EVENT, enable work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) * queue to finish off removing device from upper layers. then send next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) * TARGET_RESET in the queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) struct list_head *head = &hd->target_reset_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) u8 id, channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) struct mptsas_target_reset_event *target_reset_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) SCSITaskMgmtReply_t *pScsiTmReply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt completed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) "(mf = %p, mr = %p)\n", ioc->name, mf, mr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) pScsiTmReply = (SCSITaskMgmtReply_t *)mr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) if (!pScsiTmReply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) "\tTaskMgmt completed: fw_channel = %d, fw_id = %d,\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) "\ttask_type = 0x%02X, iocstatus = 0x%04X "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) "loginfo = 0x%08X,\n\tresponse_code = 0x%02X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) "term_cmnds = %d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) pScsiTmReply->Bus, pScsiTmReply->TargetID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) pScsiTmReply->TaskType,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) le16_to_cpu(pScsiTmReply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) le32_to_cpu(pScsiTmReply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) pScsiTmReply->ResponseCode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) le32_to_cpu(pScsiTmReply->TerminationCount)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) if (pScsiTmReply->ResponseCode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) mptscsih_taskmgmt_response_code(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) pScsiTmReply->ResponseCode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) if (pScsiTmReply->TaskType ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK || pScsiTmReply->TaskType ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_RF_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) memcpy(ioc->taskmgmt_cmds.reply, mr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) min(MPT_DEFAULT_FRAME_SIZE, 4 * mr->u.reply.MsgLength));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) ioc->taskmgmt_cmds.status &= ~MPT_MGMT_STATUS_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) complete(&ioc->taskmgmt_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) mpt_clear_taskmgmt_in_progress_flag(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) if (list_empty(head))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) target_reset_list = list_entry(head->next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) struct mptsas_target_reset_event, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) "TaskMgmt: completed (%d seconds)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) ioc->name, jiffies_to_msecs(jiffies -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) target_reset_list->time_count)/1000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) id = pScsiTmReply->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) channel = pScsiTmReply->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) target_reset_list->time_count = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) * retry target reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) if (!target_reset_list->target_reset_issued) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) if (mptsas_target_reset(ioc, channel, id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) target_reset_list->target_reset_issued = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) * enable work queue to remove device from upper layers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) list_del(&target_reset_list->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) if (!ioc->fw_events_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) mptsas_queue_device_delete(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) &target_reset_list->sas_event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) ioc->schedule_target_reset(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) * mptscsih_ioc_reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) * @ioc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) * @reset_phase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) MPT_SCSI_HOST *hd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) rc = mptscsih_ioc_reset(ioc, reset_phase);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) if ((ioc->bus_type != SAS) || (!rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) hd = shost_priv(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) if (!hd->ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) switch (reset_phase) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) case MPT_IOC_SETUP_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) mptsas_fw_event_off(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) case MPT_IOC_PRE_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) case MPT_IOC_POST_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) ioc->sas_mgmt.status |= MPT_MGMT_STATUS_DID_IOCRESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) complete(&ioc->sas_mgmt.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) mptsas_cleanup_fw_event_q(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) mptsas_queue_rescan(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) * enum device_state -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) * @DEVICE_RETRY: need to retry the TUR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) * @DEVICE_ERROR: TUR return error, don't add device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) * @DEVICE_READY: device can be added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) enum device_state{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) DEVICE_RETRY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) DEVICE_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) DEVICE_READY,
^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) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) u32 form, u32 form_specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) SasEnclosurePage0_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) __le64 le_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) memset(&hdr, 0, sizeof(hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) hdr.PageVersion = MPI_SASENCLOSURE0_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) hdr.PageNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_ENCLOSURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) cfg.pageAddr = form + form_specific;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) /* save config data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) memcpy(&le_identifier, &buffer->EnclosureLogicalID, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) enclosure->enclosure_logical_id = le64_to_cpu(le_identifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) enclosure->enclosure_handle = le16_to_cpu(buffer->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) enclosure->flags = le16_to_cpu(buffer->Flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) enclosure->num_slot = le16_to_cpu(buffer->NumSlots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) enclosure->start_slot = le16_to_cpu(buffer->StartSlot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) enclosure->start_id = buffer->StartTargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) enclosure->start_channel = buffer->StartBus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) enclosure->sep_id = buffer->SEPTargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) enclosure->sep_channel = buffer->SEPBus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) return error;
^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) * mptsas_add_end_device - report a new end device to sas transport layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) * @phy_info: describes attached device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) * return (0) success (1) failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) mptsas_add_end_device(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) struct sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) struct sas_identify identify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) char *ds = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) u8 fw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) if (!phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) fw_id = phy_info->attached.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) if (mptsas_get_rphy(phy_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) port = mptsas_get_port(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) if (!port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) return 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) MPI_SAS_DEVICE_INFO_SSP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) ds = "ssp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) MPI_SAS_DEVICE_INFO_STP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) ds = "stp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) MPI_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) ds = "sata";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) printk(MYIOC_s_INFO_FMT "attaching %s device: fw_channel %d, fw_id %d,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) " phy %d, sas_addr 0x%llx\n", ioc->name, ds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) phy_info->attached.channel, phy_info->attached.id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) phy_info->attached.phy_id, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) phy_info->attached.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) mptsas_parse_device_info(&identify, &phy_info->attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) rphy = sas_end_device_alloc(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) if (!rphy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) return 5; /* non-fatal: an rphy can be added later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) rphy->identify = identify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) if (sas_rphy_add(rphy)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) sas_rphy_free(rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) return 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) mptsas_set_rphy(ioc, phy_info, rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) * mptsas_del_end_device - report a deleted end device to sas transport layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) * @phy_info: describes attached device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) mptsas_del_end_device(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) struct sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) struct mptsas_phyinfo *phy_info_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) char *ds = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) u8 fw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) if (!phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) fw_id = phy_info->attached.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) sas_address = phy_info->attached.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) if (!phy_info->port_details) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) rphy = mptsas_get_rphy(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) if (!rphy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_INITIATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) || phy_info->attached.device_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) & MPI_SAS_DEVICE_INFO_SMP_INITIATOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) || phy_info->attached.device_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) & MPI_SAS_DEVICE_INFO_STP_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) ds = "initiator";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) MPI_SAS_DEVICE_INFO_SSP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) ds = "ssp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) MPI_SAS_DEVICE_INFO_STP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) ds = "stp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) if (phy_info->attached.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) MPI_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) ds = "sata";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) dev_printk(KERN_DEBUG, &rphy->dev, MYIOC_s_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) "removing %s device: fw_channel %d, fw_id %d, phy %d,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) "sas_addr 0x%llx\n", ioc->name, ds, phy_info->attached.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) phy_info->attached.id, phy_info->attached.phy_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) (unsigned long long) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) port = mptsas_get_port(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) if (!port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) __func__, fw_id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) port_info = phy_info->portinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) phy_info_parent = port_info->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) for (i = 0; i < port_info->num_phys; i++, phy_info_parent++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) if (!phy_info_parent->phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) if (phy_info_parent->attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) dev_printk(KERN_DEBUG, &phy_info_parent->phy->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) MYIOC_s_FMT "delete phy %d, phy-obj (0x%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) ioc->name, phy_info_parent->phy_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) phy_info_parent->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) sas_port_delete_phy(port, phy_info_parent->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) dev_printk(KERN_DEBUG, &port->dev, MYIOC_s_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) "delete port %d, sas_addr (0x%llx)\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) port->port_identifier, (unsigned long long)sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) sas_port_delete(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) mptsas_set_port(ioc, phy_info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) mptsas_port_delete(ioc, phy_info->port_details);
^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) static struct mptsas_phyinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) mptsas_refreshing_device_handles(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) struct mptsas_devinfo *sas_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) sas_device->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) if (!phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) port_info = phy_info->portinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) if (!port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) if (port_info->phy_info[i].attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) sas_device->sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) port_info->phy_info[i].attached.channel = sas_device->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) port_info->phy_info[i].attached.id = sas_device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) port_info->phy_info[i].attached.sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) sas_device->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) port_info->phy_info[i].attached.handle = sas_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) port_info->phy_info[i].attached.handle_parent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) sas_device->handle_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) port_info->phy_info[i].attached.handle_enclosure =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) sas_device->handle_enclosure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) return phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) * mptsas_firmware_event_work - work thread for processing fw events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) * @work: work queue payload containing info describing the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) * Context: user
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) mptsas_firmware_event_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) struct fw_event_work *fw_event =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) container_of(work, struct fw_event_work, work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) MPT_ADAPTER *ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) /* special rescan topology handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) if (fw_event->event == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) if (ioc->in_rescan) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) "%s: rescan ignored as it is in progress\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: rescan after "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) "reset\n", ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) ioc->in_rescan = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) mptsas_not_responding_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) mptsas_scan_sas_topology(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) ioc->in_rescan = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) mptsas_fw_event_on(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) /* events handling turned off during host reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) if (ioc->fw_events_off) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: fw_event=(0x%p), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) "event = (0x%02x)\n", ioc->name, __func__, fw_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) (fw_event->event & 0xFF)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) switch (fw_event->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) mptsas_send_sas_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) case MPI_EVENT_INTEGRATED_RAID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) mptsas_send_raid_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) case MPI_EVENT_IR2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) mptsas_send_ir2_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) case MPI_EVENT_PERSISTENT_TABLE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) mptbase_sas_persist_operation(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) MPI_SAS_OP_CLEAR_NOT_PRESENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) case MPI_EVENT_SAS_BROADCAST_PRIMITIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) mptsas_broadcast_primitive_work(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) case MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) mptsas_send_expander_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) case MPI_EVENT_SAS_PHY_LINK_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) mptsas_send_link_status_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) case MPI_EVENT_QUEUE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) mptsas_handle_queue_full_event(fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) mptsas_slave_configure(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) struct Scsi_Host *host = sdev->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) MPT_SCSI_HOST *hd = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) MPT_ADAPTER *ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) VirtDevice *vdevice = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) if (vdevice->vtarget->deleted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) sdev_printk(KERN_INFO, sdev, "clearing deleted flag\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) vdevice->vtarget->deleted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) * RAID volumes placed beyond the last expected port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) * Ignore sending sas mode pages in that case..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) if (sdev->channel == MPTSAS_RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) mptsas_add_device_component_starget_ir(ioc, scsi_target(sdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) sas_read_port_mode_page(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) mptsas_add_device_component_starget(ioc, scsi_target(sdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) return mptscsih_slave_configure(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) mptsas_target_alloc(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) struct Scsi_Host *host = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) MPT_SCSI_HOST *hd = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) VirtTarget *vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) u8 id, channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) struct mptsas_portinfo *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) MPT_ADAPTER *ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) if (!vtarget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) vtarget->starget = starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) vtarget->ioc_id = ioc->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) id = starget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) channel = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) * RAID volumes placed beyond the last expected port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) if (starget->channel == MPTSAS_RAID_CHANNEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) if (!ioc->raid_data.pIocPg2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) kfree(vtarget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) if (id == ioc->raid_data.pIocPg2->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) RaidVolume[i].VolumeID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) channel = ioc->raid_data.pIocPg2->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) RaidVolume[i].VolumeBus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) vtarget->raidVolume = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) rphy = dev_to_rphy(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) list_for_each_entry(p, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) for (i = 0; i < p->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) if (p->phy_info[i].attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) rphy->identify.sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) id = p->phy_info[i].attached.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) channel = p->phy_info[i].attached.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) mptsas_set_starget(&p->phy_info[i], starget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) * Exposing hidden raid components
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) if (mptscsih_is_phys_disk(ioc, channel, id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) id = mptscsih_raid_id_to_num(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) channel, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) vtarget->tflags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) p->phy_info[i].attached.phys_disk_num = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) kfree(vtarget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) vtarget->id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) vtarget->channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) starget->hostdata = vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) mptsas_target_destroy(struct scsi_target *starget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) struct Scsi_Host *host = dev_to_shost(&starget->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) MPT_SCSI_HOST *hd = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) struct mptsas_portinfo *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) MPT_ADAPTER *ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) VirtTarget *vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) if (!starget->hostdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) vtarget = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) mptsas_del_device_component_by_os(ioc, starget->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) starget->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) if (starget->channel == MPTSAS_RAID_CHANNEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) rphy = dev_to_rphy(starget->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) list_for_each_entry(p, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) for (i = 0; i < p->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) if (p->phy_info[i].attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) rphy->identify.sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) starget_printk(KERN_INFO, starget, MYIOC_s_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) "delete device: fw_channel %d, fw_id %d, phy %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) "sas_addr 0x%llx\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) p->phy_info[i].attached.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) p->phy_info[i].attached.id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) p->phy_info[i].attached.phy_id, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) p->phy_info[i].attached.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) mptsas_set_starget(&p->phy_info[i], NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) vtarget->starget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) kfree(starget->hostdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) starget->hostdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) mptsas_slave_alloc(struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) struct Scsi_Host *host = sdev->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) MPT_SCSI_HOST *hd = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) struct mptsas_portinfo *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) VirtDevice *vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) MPT_ADAPTER *ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) if (!vdevice) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) ioc->name, sizeof(VirtDevice));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) starget = scsi_target(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) vdevice->vtarget = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) if (sdev->channel == MPTSAS_RAID_CHANNEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) list_for_each_entry(p, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) for (i = 0; i < p->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) if (p->phy_info[i].attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) rphy->identify.sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) vdevice->lun = sdev->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) * Exposing hidden raid components
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) if (mptscsih_is_phys_disk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) p->phy_info[i].attached.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) p->phy_info[i].attached.id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) sdev->no_uld_attach = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) kfree(vdevice);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) vdevice->vtarget->num_luns++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) sdev->hostdata = vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) mptsas_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) MPT_SCSI_HOST *hd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) VirtDevice *vdevice = SCpnt->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) SCpnt->result = DID_NO_CONNECT << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) SCpnt->scsi_done(SCpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) hd = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) if (ioc->sas_discovery_quiesce_io)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) return SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) if (ioc->debug_level & MPT_DEBUG_SCSI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) scsi_print_command(SCpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) return mptscsih_qcmd(SCpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) * mptsas_mptsas_eh_timed_out - resets the scsi_cmnd timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) * if the device under question is currently in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) * device removal delay.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) * @sc: scsi command that the midlayer is about to time out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) MPT_SCSI_HOST *hd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) VirtDevice *vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) enum blk_eh_timer_return rc = BLK_EH_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) hd = shost_priv(sc->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) if (hd == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) printk(KERN_ERR MYNAM ": %s: Can't locate host! (sc=%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) __func__, sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) ioc = hd->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) if (ioc->bus_type != SAS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) printk(KERN_ERR MYNAM ": %s: Wrong bus type (sc=%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) __func__, sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) /* In case if IOC is in reset from internal context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) * Do not execute EEH for the same IOC. SML should to reset timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) if (ioc->ioc_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: ioc is in reset,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) "SML need to reset the timer (sc=%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) ioc->name, __func__, sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) rc = BLK_EH_RESET_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) vdevice = sc->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) if (vdevice && vdevice->vtarget && (vdevice->vtarget->inDMD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) || vdevice->vtarget->deleted)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: target removed "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) "or in device removal delay (sc=%p)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) ioc->name, __func__, sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) rc = BLK_EH_RESET_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) static struct scsi_host_template mptsas_driver_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) .proc_name = "mptsas",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) .show_info = mptscsih_show_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) .name = "MPT SAS Host",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) .info = mptscsih_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) .queuecommand = mptsas_qcmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) .target_alloc = mptsas_target_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) .slave_alloc = mptsas_slave_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) .slave_configure = mptsas_slave_configure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) .target_destroy = mptsas_target_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) .slave_destroy = mptscsih_slave_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) .change_queue_depth = mptscsih_change_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) .eh_timed_out = mptsas_eh_timed_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) .eh_abort_handler = mptscsih_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) .eh_device_reset_handler = mptscsih_dev_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) .eh_host_reset_handler = mptscsih_host_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) .bios_param = mptscsih_bios_param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) .can_queue = MPT_SAS_CAN_QUEUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) .this_id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) .sg_tablesize = MPT_SCSI_SG_DEPTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) .max_sectors = 8192,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) .cmd_per_lun = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) .shost_attrs = mptscsih_host_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) .no_write_same = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) static int mptsas_get_linkerrors(struct sas_phy *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) MPT_ADAPTER *ioc = phy_to_ioc(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) SasPhyPage1_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) /* FIXME: only have link errors on local phys */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) if (!scsi_is_sas_phy_local(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) hdr.PageNumber = 1 /* page number 1*/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_PHY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) cfg.pageAddr = phy->identify.phy_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) if (!hdr.ExtPageLength)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) mptsas_print_phy_pg1(ioc, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) phy->invalid_dword_count = le32_to_cpu(buffer->InvalidDwordCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) phy->running_disparity_error_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) le32_to_cpu(buffer->RunningDisparityErrorCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) phy->loss_of_dword_sync_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) le32_to_cpu(buffer->LossDwordSynchCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) phy->phy_reset_problem_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) le32_to_cpu(buffer->PhyResetProblemCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) static int mptsas_mgmt_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) MPT_FRAME_HDR *reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) ioc->sas_mgmt.status |= MPT_MGMT_STATUS_COMMAND_GOOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) if (reply != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) ioc->sas_mgmt.status |= MPT_MGMT_STATUS_RF_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) memcpy(ioc->sas_mgmt.reply, reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) min(ioc->reply_sz, 4 * reply->u.reply.MsgLength));
^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) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) ioc->sas_mgmt.status &= ~MPT_MGMT_STATUS_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) complete(&ioc->sas_mgmt.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) MPT_ADAPTER *ioc = phy_to_ioc(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) SasIoUnitControlRequest_t *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) SasIoUnitControlReply_t *reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) MPIHeader_t *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) unsigned long timeleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) int error = -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) /* FIXME: fusion doesn't allow non-local phy reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) if (!scsi_is_sas_phy_local(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) /* not implemented for expanders */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) if (mutex_lock_interruptible(&ioc->sas_mgmt.mutex))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) if (!mf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) hdr = (MPIHeader_t *) mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) req = (SasIoUnitControlRequest_t *)mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) memset(req, 0, sizeof(SasIoUnitControlRequest_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) req->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) req->MsgContext = hdr->MsgContext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) req->Operation = hard_reset ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) MPI_SAS_OP_PHY_HARD_RESET : MPI_SAS_OP_PHY_LINK_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) req->PhyNum = phy->identify.phy_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) 10 * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) error = -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) if (!timeleft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) /* a reply frame is expected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) if ((ioc->sas_mgmt.status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) MPT_MGMT_STATUS_RF_VALID) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) /* process the completed Reply Message Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) printk(MYIOC_s_INFO_FMT "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) ioc->name, __func__, reply->IOCStatus, reply->IOCLogInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) mutex_unlock(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) mptsas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) int i, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) struct mptsas_portinfo *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) struct mptsas_enclosure enclosure_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) u64 enclosure_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) list_for_each_entry(p, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) for (i = 0; i < p->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) if (p->phy_info[i].attached.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) rphy->identify.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) enclosure_handle = p->phy_info[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) attached.handle_enclosure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) goto found_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) found_info:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) memset(&enclosure_info, 0, sizeof(struct mptsas_enclosure));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) error = mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) (MPI_SAS_ENCLOS_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) MPI_SAS_ENCLOS_PGAD_FORM_SHIFT), enclosure_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) *identifier = enclosure_info.enclosure_logical_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) mptsas_get_bay_identifier(struct sas_rphy *rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) struct mptsas_portinfo *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) int i, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) list_for_each_entry(p, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) for (i = 0; i < p->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) if (p->phy_info[i].attached.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) rphy->identify.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) rc = p->phy_info[i].attached.slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) rc = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) static void mptsas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) struct sas_rphy *rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) MPT_ADAPTER *ioc = ((MPT_SCSI_HOST *) shost->hostdata)->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) SmpPassthroughRequest_t *smpreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) int flagsLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) unsigned long timeleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) char *psge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) u64 sas_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) unsigned int reslen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) /* do we need to support multiple segments? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) if (job->request_payload.sg_cnt > 1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) job->reply_payload.sg_cnt > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u, rsp %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) ioc->name, __func__, job->request_payload.payload_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) job->reply_payload.payload_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) if (!mf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) smpreq = (SmpPassthroughRequest_t *)mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) memset(smpreq, 0, sizeof(*smpreq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) smpreq->RequestDataLength =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) cpu_to_le16(job->request_payload.payload_len - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) if (rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) sas_address = rphy->identify.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) port_info = ioc->hba_port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) if (port_info && port_info->phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) port_info->phy_info[0].phy->identify.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) *((u64 *)&smpreq->SASAddress) = cpu_to_le64(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) psge = (char *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) (((int *) mf) + (offsetof(SmpPassthroughRequest_t, SGL) / 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) /* request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) flagsLength = (MPI_SGE_FLAGS_SIMPLE_ELEMENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) MPI_SGE_FLAGS_END_OF_BUFFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) MPI_SGE_FLAGS_DIRECTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) << MPI_SGE_FLAGS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) if (!dma_map_sg(&ioc->pcidev->dev, job->request_payload.sg_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) 1, PCI_DMA_BIDIRECTIONAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) goto put_mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) flagsLength |= (sg_dma_len(job->request_payload.sg_list) - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) ioc->add_sge(psge, flagsLength,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) sg_dma_address(job->request_payload.sg_list));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) psge += ioc->SGE_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) /* response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) flagsLength = MPI_SGE_FLAGS_SIMPLE_ELEMENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) MPI_SGE_FLAGS_SYSTEM_ADDRESS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) MPI_SGE_FLAGS_IOC_TO_HOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) MPI_SGE_FLAGS_END_OF_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) flagsLength = flagsLength << MPI_SGE_FLAGS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) if (!dma_map_sg(&ioc->pcidev->dev, job->reply_payload.sg_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 1, PCI_DMA_BIDIRECTIONAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) goto unmap_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) flagsLength |= sg_dma_len(job->reply_payload.sg_list) + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) ioc->add_sge(psge, flagsLength,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) sg_dma_address(job->reply_payload.sg_list));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) ret = -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) mf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) goto unmap_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) if (!timeleft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) goto unmap_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) mf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) SmpPassthroughReply_t *smprep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) memcpy(job->reply, smprep, sizeof(*smprep));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) job->reply_len = sizeof(*smprep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) reslen = smprep->ResponseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) "%s: smp passthru reply failed to be returned\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) ioc->name, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) unmap_in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) dma_unmap_sg(&ioc->pcidev->dev, job->reply_payload.sg_list, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) PCI_DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) unmap_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) dma_unmap_sg(&ioc->pcidev->dev, job->request_payload.sg_list, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) PCI_DMA_BIDIRECTIONAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) put_mf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) if (mf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) mutex_unlock(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) bsg_job_done(job, ret, reslen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) static struct sas_function_template mptsas_transport_functions = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) .get_linkerrors = mptsas_get_linkerrors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) .get_enclosure_identifier = mptsas_get_enclosure_identifier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) .get_bay_identifier = mptsas_get_bay_identifier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) .phy_reset = mptsas_phy_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) .smp_handler = mptsas_smp_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) static struct scsi_transport_template *mptsas_transport_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) SasIOUnitPage0_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) int error, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) hdr.PageVersion = MPI_SASIOUNITPAGE0_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) hdr.PageNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) cfg.pageAddr = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) port_info->num_phys = buffer->NumPhys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) port_info->phy_info = kcalloc(port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) sizeof(struct mptsas_phyinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) if (!port_info->phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) ioc->nvdata_version_persistent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) le16_to_cpu(buffer->NvdataVersionPersistent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) ioc->nvdata_version_default =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) le16_to_cpu(buffer->NvdataVersionDefault);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) mptsas_print_phy_data(ioc, &buffer->PhyData[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) port_info->phy_info[i].phy_id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) port_info->phy_info[i].port_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) buffer->PhyData[i].Port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) port_info->phy_info[i].negotiated_link_rate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) buffer->PhyData[i].NegotiatedLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) port_info->phy_info[i].handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) le16_to_cpu(buffer->PhyData[i].ControllerDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) mptsas_sas_io_unit_pg1(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) SasIOUnitPage1_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) u8 device_missing_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) memset(&hdr, 0, sizeof(ConfigExtendedPageHeader_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) memset(&cfg, 0, sizeof(CONFIGPARMS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) cfg.cfghdr.ehdr->PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) cfg.cfghdr.ehdr->ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) cfg.cfghdr.ehdr->PageVersion = MPI_SASIOUNITPAGE1_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) cfg.cfghdr.ehdr->PageNumber = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) ioc->io_missing_delay =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) le16_to_cpu(buffer->IODeviceMissingDelay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) device_missing_delay = buffer->ReportDeviceMissingDelay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) ioc->device_missing_delay = (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK) * 16 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) u32 form, u32 form_specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) SasPhyPage0_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) hdr.PageVersion = MPI_SASPHY0_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) hdr.PageNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_PHY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) /* Get Phy Pg 0 for each Phy. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) cfg.pageAddr = form + form_specific;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) mptsas_print_phy_pg0(ioc, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) phy_info->hw_link_rate = buffer->HwLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) phy_info->programmed_link_rate = buffer->ProgrammedLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) u32 form, u32 form_specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) SasDevicePage0_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) int error=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) hdr.PageNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) cfg.pageAddr = form + form_specific;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) memset(device_info, 0, sizeof(struct mptsas_devinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) if (error == MPI_IOCSTATUS_CONFIG_INVALID_PAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) mptsas_print_device_pg0(ioc, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) memset(device_info, 0, sizeof(struct mptsas_devinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) device_info->handle = le16_to_cpu(buffer->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) device_info->handle_enclosure =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) le16_to_cpu(buffer->EnclosureHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) device_info->slot = le16_to_cpu(buffer->Slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) device_info->phy_id = buffer->PhyNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) device_info->port_id = buffer->PhysicalPort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) device_info->id = buffer->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) device_info->phys_disk_num = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) device_info->channel = buffer->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) device_info->sas_address = le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) device_info->device_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) le32_to_cpu(buffer->DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) device_info->flags = le16_to_cpu(buffer->Flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) u32 form, u32 form_specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) SasExpanderPage0_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) int i, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) memset(port_info, 0, sizeof(struct mptsas_portinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) hdr.PageNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) cfg.pageAddr = form + form_specific;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) memset(port_info, 0, sizeof(struct mptsas_portinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) if (error == MPI_IOCSTATUS_CONFIG_INVALID_PAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) /* save config data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) port_info->num_phys = (buffer->NumPhys) ? buffer->NumPhys : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) port_info->phy_info = kcalloc(port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) sizeof(struct mptsas_phyinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) if (!port_info->phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) port_info->phy_info[i].handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) le16_to_cpu(buffer->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) port_info->phy_info[i].identify.sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) port_info->phy_info[i].identify.handle_parent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) le16_to_cpu(buffer->ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) u32 form, u32 form_specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) ConfigExtendedPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) SasExpanderPage1_t *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) int error=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) hdr.PageVersion = MPI_SASEXPANDER1_PAGEVERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) hdr.ExtPageLength = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) hdr.PageNumber = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) hdr.Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) hdr.Reserved2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) cfg.cfghdr.ehdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) cfg.physAddr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) cfg.pageAddr = form + form_specific;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) cfg.dir = 0; /* read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) if (!hdr.ExtPageLength) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) error = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) if (!buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) error = mpt_config(ioc, &cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) if (error == MPI_IOCSTATUS_CONFIG_INVALID_PAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) goto out_free_consistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) mptsas_print_expander_pg1(ioc, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) /* save config data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) phy_info->phy_id = buffer->PhyIdentifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) phy_info->port_id = buffer->PhysicalPort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) phy_info->negotiated_link_rate = buffer->NegotiatedLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) phy_info->programmed_link_rate = buffer->ProgrammedLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) phy_info->hw_link_rate = buffer->HwLinkRate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) out_free_consistent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) buffer, dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) struct rep_manu_request{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) u8 smp_frame_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) u8 function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) u8 request_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) struct rep_manu_reply{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) u8 smp_frame_type; /* 0x41 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) u8 function; /* 0x01 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) u8 function_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) u8 response_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) u16 expander_change_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) u8 reserved0[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) u8 sas_format:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) u8 reserved1:7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) u8 reserved2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) u8 vendor_id[SAS_EXPANDER_VENDOR_ID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) u8 product_id[SAS_EXPANDER_PRODUCT_ID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) u8 product_rev[SAS_EXPANDER_PRODUCT_REV_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) u8 component_vendor_id[SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) u16 component_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) u8 component_revision_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) u8 reserved3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) u8 vendor_specific[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) * mptsas_exp_repmanufacture_info -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) * @sas_address: expander sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) * @edev: the sas_expander_device object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) * Fills in the sas_expander_device object when SMP port is created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) * Returns 0 for success, non-zero for failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) mptsas_exp_repmanufacture_info(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) u64 sas_address, struct sas_expander_device *edev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) SmpPassthroughRequest_t *smpreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) SmpPassthroughReply_t *smprep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) struct rep_manu_reply *manufacture_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) struct rep_manu_request *manufacture_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) int flagsLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) unsigned long timeleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) char *psge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) void *data_out = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) dma_addr_t data_out_dma = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) u32 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) if (ioc->ioc_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) printk(MYIOC_s_INFO_FMT "%s: host reset in progress!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) __func__, ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) if (!mf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) smpreq = (SmpPassthroughRequest_t *)mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) memset(smpreq, 0, sizeof(*smpreq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) sz = sizeof(struct rep_manu_request) + sizeof(struct rep_manu_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) data_out = pci_alloc_consistent(ioc->pcidev, sz, &data_out_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) if (!data_out) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) printk(KERN_ERR "Memory allocation failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) goto put_mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) manufacture_request = data_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) manufacture_request->smp_frame_type = 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) manufacture_request->function = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) manufacture_request->reserved = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) manufacture_request->request_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) smpreq->PhysicalPort = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) *((u64 *)&smpreq->SASAddress) = cpu_to_le64(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) smpreq->RequestDataLength = sizeof(struct rep_manu_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) psge = (char *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) (((int *) mf) + (offsetof(SmpPassthroughRequest_t, SGL) / 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) flagsLength = MPI_SGE_FLAGS_SIMPLE_ELEMENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) MPI_SGE_FLAGS_SYSTEM_ADDRESS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) MPI_SGE_FLAGS_HOST_TO_IOC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) MPI_SGE_FLAGS_END_OF_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) flagsLength = flagsLength << MPI_SGE_FLAGS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) flagsLength |= sizeof(struct rep_manu_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) ioc->add_sge(psge, flagsLength, data_out_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) psge += ioc->SGE_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) flagsLength = MPI_SGE_FLAGS_SIMPLE_ELEMENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) MPI_SGE_FLAGS_SYSTEM_ADDRESS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) MPI_SGE_FLAGS_IOC_TO_HOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) MPI_SGE_FLAGS_END_OF_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) flagsLength = flagsLength << MPI_SGE_FLAGS_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) flagsLength |= sizeof(struct rep_manu_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) ioc->add_sge(psge, flagsLength, data_out_dma +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) sizeof(struct rep_manu_request));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) ret = -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) mf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) if (!timeleft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) goto out_free;
^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) mf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) u8 *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) if (le16_to_cpu(smprep->ResponseDataLength) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) sizeof(struct rep_manu_reply))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) manufacture_reply = data_out + sizeof(struct rep_manu_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) strncpy(edev->vendor_id, manufacture_reply->vendor_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) SAS_EXPANDER_VENDOR_ID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) strncpy(edev->product_id, manufacture_reply->product_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) SAS_EXPANDER_PRODUCT_ID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) strncpy(edev->product_rev, manufacture_reply->product_rev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) SAS_EXPANDER_PRODUCT_REV_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) edev->level = manufacture_reply->sas_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) if (manufacture_reply->sas_format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) strncpy(edev->component_vendor_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) manufacture_reply->component_vendor_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) tmp = (u8 *)&manufacture_reply->component_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) edev->component_id = tmp[0] << 8 | tmp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) edev->component_revision_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) manufacture_reply->component_revision_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) "%s: smp passthru reply failed to be returned\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) ioc->name, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) ret = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) if (data_out_dma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) pci_free_consistent(ioc->pcidev, sz, data_out, data_out_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) put_mf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) if (mf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) mutex_unlock(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) mptsas_parse_device_info(struct sas_identify *identify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) struct mptsas_devinfo *device_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) u16 protocols;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) identify->sas_address = device_info->sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) identify->phy_identifier = device_info->phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) * Fill in Phy Initiator Port Protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) * Bits 6:3, more than one bit can be set, fall through cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) protocols = device_info->device_info & 0x78;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) identify->initiator_port_protocols = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) if (protocols & MPI_SAS_DEVICE_INFO_SSP_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) identify->initiator_port_protocols |= SAS_PROTOCOL_SSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) if (protocols & MPI_SAS_DEVICE_INFO_STP_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) identify->initiator_port_protocols |= SAS_PROTOCOL_STP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) if (protocols & MPI_SAS_DEVICE_INFO_SMP_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) identify->initiator_port_protocols |= SAS_PROTOCOL_SMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) if (protocols & MPI_SAS_DEVICE_INFO_SATA_HOST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) identify->initiator_port_protocols |= SAS_PROTOCOL_SATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) * Fill in Phy Target Port Protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) * Bits 10:7, more than one bit can be set, fall through cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) protocols = device_info->device_info & 0x780;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) identify->target_port_protocols = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) if (protocols & MPI_SAS_DEVICE_INFO_SSP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) identify->target_port_protocols |= SAS_PROTOCOL_SSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) if (protocols & MPI_SAS_DEVICE_INFO_STP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) identify->target_port_protocols |= SAS_PROTOCOL_STP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) if (protocols & MPI_SAS_DEVICE_INFO_SMP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) identify->target_port_protocols |= SAS_PROTOCOL_SMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) if (protocols & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) identify->target_port_protocols |= SAS_PROTOCOL_SATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) * Fill in Attached device type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) switch (device_info->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) MPI_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) case MPI_SAS_DEVICE_INFO_NO_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) identify->device_type = SAS_PHY_UNUSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) case MPI_SAS_DEVICE_INFO_END_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) identify->device_type = SAS_END_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) case MPI_SAS_DEVICE_INFO_EDGE_EXPANDER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) identify->device_type = SAS_EDGE_EXPANDER_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) case MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) identify->device_type = SAS_FANOUT_EXPANDER_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) static int mptsas_probe_one_phy(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) struct mptsas_phyinfo *phy_info, int index, int local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) struct sas_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) struct sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) VirtTarget *vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) if (!dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) if (!phy_info->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) phy = sas_phy_alloc(dev, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) if (!phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) phy = phy_info->phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) mptsas_parse_device_info(&phy->identify, &phy_info->identify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) * Set Negotiated link rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) switch (phy_info->negotiated_link_rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) phy->negotiated_linkrate = SAS_PHY_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) phy->negotiated_linkrate = SAS_LINK_RATE_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) case MPI_SAS_IOUNIT0_RATE_1_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) case MPI_SAS_IOUNIT0_RATE_3_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) case MPI_SAS_IOUNIT0_RATE_6_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) case MPI_SAS_IOUNIT0_RATE_SATA_OOB_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) case MPI_SAS_IOUNIT0_RATE_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) * Set Max hardware link rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) phy->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) * Set Max programmed link rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) switch (phy_info->programmed_link_rate &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) phy->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) phy->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) * Set Min hardware link rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) phy->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) * Set Min programmed link rate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) switch (phy_info->programmed_link_rate &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) phy->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) if (!phy_info->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) error = sas_phy_add(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) sas_phy_free(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) phy_info->phy = phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) if (!phy_info->attached.handle ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) !phy_info->port_details)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) port = mptsas_get_port(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) ioc = phy_to_ioc(phy_info->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) if (phy_info->sas_port_add_phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) if (!port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) port = sas_port_alloc_num(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) if (!port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) error = sas_port_add(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) mptsas_set_port(ioc, phy_info, port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) devtprintk(ioc, dev_printk(KERN_DEBUG, &port->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) MYIOC_s_FMT "add port %d, sas_addr (0x%llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) ioc->name, port->port_identifier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) (unsigned long long)phy_info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) attached.sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) "sas_port_add_phy: phy_id=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) ioc->name, phy_info->phy_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) sas_port_add_phy(port, phy_info->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) phy_info->sas_port_add_phy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) devtprintk(ioc, dev_printk(KERN_DEBUG, &phy_info->phy->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) MYIOC_s_FMT "add phy %d, phy-obj (0x%p)\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) phy_info->phy_id, phy_info->phy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) if (!mptsas_get_rphy(phy_info) && port && !port->rphy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) struct device *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) struct sas_identify identify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) parent = dev->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) * Let the hotplug_work thread handle processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) * the adding/removing of devices that occur
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) * after start of day.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) if (mptsas_is_end_device(&phy_info->attached) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) phy_info->attached.handle_parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) mptsas_parse_device_info(&identify, &phy_info->attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) if (scsi_is_host_device(parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) port_info = ioc->hba_port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) for (i = 0; i < port_info->num_phys; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) if (port_info->phy_info[i].identify.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) identify.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) sas_port_mark_backlink(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) } else if (scsi_is_sas_rphy(parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) struct sas_rphy *parent_rphy = dev_to_rphy(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) if (identify.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) parent_rphy->identify.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) sas_port_mark_backlink(port);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) switch (identify.device_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) case SAS_END_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) rphy = sas_end_device_alloc(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) case SAS_EDGE_EXPANDER_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) case SAS_FANOUT_EXPANDER_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) rphy = sas_expander_alloc(port, identify.device_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) rphy = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) if (!rphy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) rphy->identify = identify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) error = sas_rphy_add(rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) sas_rphy_free(rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) mptsas_set_rphy(ioc, phy_info, rphy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) if (identify.device_type == SAS_EDGE_EXPANDER_DEVICE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) identify.device_type == SAS_FANOUT_EXPANDER_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) mptsas_exp_repmanufacture_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) identify.sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) rphy_to_expander_device(rphy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) /* If the device exists,verify it wasn't previously flagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) as a missing device. If so, clear it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) vtarget = mptsas_find_vtarget(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) phy_info->attached.channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) phy_info->attached.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) if (vtarget && vtarget->inDMD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) printk(KERN_INFO "Device returned, unsetting inDMD\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) vtarget->inDMD = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) }
^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) mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) struct mptsas_portinfo *port_info, *hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) int error = -ENOMEM, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) hba = kzalloc(sizeof(struct mptsas_portinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) if (! hba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) error = mptsas_sas_io_unit_pg0(ioc, hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) goto out_free_port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) mptsas_sas_io_unit_pg1(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) port_info = ioc->hba_port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) if (!port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) ioc->hba_port_info = port_info = hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) ioc->hba_port_num_phy = port_info->num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) list_add_tail(&port_info->list, &ioc->sas_topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) for (i = 0; i < hba->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) port_info->phy_info[i].negotiated_link_rate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) hba->phy_info[i].negotiated_link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) port_info->phy_info[i].handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) hba->phy_info[i].handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) port_info->phy_info[i].port_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) hba->phy_info[i].port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) kfree(hba->phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) kfree(hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) hba = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) #if defined(CPQ_CIM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) ioc->num_ports = port_info->num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) MPI_SAS_PHY_PGAD_FORM_SHIFT), i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) port_info->phy_info[i].identify.handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) port_info->phy_info[i].handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) mptsas_sas_device_pg0(ioc, &port_info->phy_info[i].identify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) port_info->phy_info[i].identify.handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) if (!ioc->hba_port_sas_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) ioc->hba_port_sas_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) port_info->phy_info[i].identify.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) port_info->phy_info[i].identify.phy_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) port_info->phy_info[i].phy_id = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) if (port_info->phy_info[i].attached.handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) mptsas_sas_device_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) &port_info->phy_info[i].attached,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) port_info->phy_info[i].attached.handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) mptsas_setup_wide_ports(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) mptsas_probe_one_phy(&ioc->sh->shost_gendev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) &port_info->phy_info[i], ioc->sas_index, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) out_free_port_info:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) kfree(hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) mptsas_expander_refresh(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) struct mptsas_portinfo *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) struct device *parent_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) u64 sas_address; /* expander sas address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) u32 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) handle = port_info->phy_info[0].handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) sas_address = port_info->phy_info[0].identify.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) mptsas_sas_device_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) &port_info->phy_info[i].identify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) port_info->phy_info[i].identify.handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) port_info->phy_info[i].identify.phy_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) port_info->phy_info[i].phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) if (port_info->phy_info[i].attached.handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) mptsas_sas_device_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) &port_info->phy_info[i].attached,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) port_info->phy_info[i].attached.handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) port_info->phy_info[i].attached.phy_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) port_info->phy_info[i].phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) parent = mptsas_find_portinfo_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) port_info->phy_info[0].identify.handle_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) if (!parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) for (i = 0, parent_dev = NULL; i < parent->num_phys && !parent_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) if (parent->phy_info[i].attached.sas_address == sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) rphy = mptsas_get_rphy(&parent->phy_info[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) parent_dev = &rphy->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) mptsas_setup_wide_ports(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) mptsas_probe_one_phy(parent_dev, &port_info->phy_info[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) ioc->sas_index, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) mptsas_expander_event_add(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) MpiEventDataSasExpanderStatusChange_t *expander_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) port_info = kzalloc(sizeof(struct mptsas_portinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) if (!port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) port_info->num_phys = (expander_data->NumPhys) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) expander_data->NumPhys : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) port_info->phy_info = kcalloc(port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) sizeof(struct mptsas_phyinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) if (!port_info->phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) memcpy(&sas_address, &expander_data->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) port_info->phy_info[i].handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) le16_to_cpu(expander_data->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) port_info->phy_info[i].identify.sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) port_info->phy_info[i].identify.handle_parent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) le16_to_cpu(expander_data->ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) list_add_tail(&port_info->list, &ioc->sas_topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) (unsigned long long)sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) * mptsas_delete_expander_siblings - remove siblings attached to expander
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) * @parent: the parent port_info object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) * @expander: the expander port_info object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) mptsas_delete_expander_siblings(MPT_ADAPTER *ioc, struct mptsas_portinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) *parent, struct mptsas_portinfo *expander)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) struct sas_rphy *rphy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) phy_info = expander->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) for (i = 0; i < expander->num_phys; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) rphy = mptsas_get_rphy(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) if (!rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) if (rphy->identify.device_type == SAS_END_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) mptsas_del_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) phy_info = expander->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) for (i = 0; i < expander->num_phys; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) rphy = mptsas_get_rphy(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) if (!rphy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) if (rphy->identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) MPI_SAS_DEVICE_INFO_EDGE_EXPANDER ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) rphy->identify.device_type ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) port_info = mptsas_find_portinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) rphy->identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) if (!port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) if (port_info == parent) /* backlink rphy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) Delete this expander even if the expdevpage is exists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) because the parent expander is already deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) mptsas_expander_delete(ioc, port_info, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) * mptsas_expander_delete - remove this expander
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) * @port_info: expander port_info struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) * @force: Flag to forcefully delete the expander
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) static void mptsas_expander_delete(MPT_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) struct mptsas_portinfo *port_info, u8 force)
^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) struct mptsas_portinfo *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) u64 expander_sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) struct mptsas_portinfo buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) struct mptsas_portinfo_details *port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) struct sas_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) if (!port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) /* see if expander is still there before deleting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) mptsas_sas_expander_pg0(ioc, &buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) (MPI_SAS_EXPAND_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) MPI_SAS_EXPAND_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) port_info->phy_info[0].identify.handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) if (buffer.num_phys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) kfree(buffer.phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) if (!force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) * Obtain the port_info instance to the parent port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) port_details = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) expander_sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) port_info->phy_info[0].identify.sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) parent = mptsas_find_portinfo_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) port_info->phy_info[0].identify.handle_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) mptsas_delete_expander_siblings(ioc, parent, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) if (!parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) * Delete rphys in the parent that point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) * to this expander.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) phy_info = parent->phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) port = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) for (i = 0; i < parent->num_phys; i++, phy_info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) if (!phy_info->phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) if (phy_info->attached.sas_address !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) expander_sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) if (!port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) port = mptsas_get_port(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) port_details = phy_info->port_details;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) dev_printk(KERN_DEBUG, &phy_info->phy->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) MYIOC_s_FMT "delete phy %d, phy-obj (0x%p)\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) phy_info->phy_id, phy_info->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) sas_port_delete_phy(port, phy_info->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) if (port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) dev_printk(KERN_DEBUG, &port->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) MYIOC_s_FMT "delete port %d, sas_addr (0x%llx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) ioc->name, port->port_identifier,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) (unsigned long long)expander_sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) sas_port_delete(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) mptsas_port_delete(ioc, port_details);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) printk(MYIOC_s_INFO_FMT "delete expander: num_phys %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) (unsigned long long)expander_sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) * free link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) list_del(&port_info->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) kfree(port_info->phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) kfree(port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589)
^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) * mptsas_send_expander_event - expanders events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) * @expander_data: event data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) * This function handles adding, removing, and refreshing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) * device handles within the expander objects.
^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) mptsas_send_expander_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) MpiEventDataSasExpanderStatusChange_t *expander_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) expander_data = (MpiEventDataSasExpanderStatusChange_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) memcpy(&sas_address, &expander_data->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) sas_address = le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) port_info = mptsas_find_portinfo_by_sas_address(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) if (expander_data->ReasonCode == MPI_EVENT_SAS_EXP_RC_ADDED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) if (port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) port_info->phy_info[i].handle =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) le16_to_cpu(expander_data->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) port_info->phy_info[i].identify.sas_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) port_info->phy_info[i].identify.handle_parent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) le16_to_cpu(expander_data->ParentDevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) } else if (!port_info && expander_data->NumPhys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) mptsas_expander_event_add(ioc, expander_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) } else if (expander_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) MPI_EVENT_SAS_EXP_RC_NOT_RESPONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) mptsas_expander_delete(ioc, port_info, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) mptsas_free_fw_event(ioc, fw_event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) * mptsas_expander_add -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) * @handle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) static struct mptsas_portinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) mptsas_expander_add(MPT_ADAPTER *ioc, u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) struct mptsas_portinfo buffer, *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) if ((mptsas_sas_expander_pg0(ioc, &buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) (MPI_SAS_EXPAND_PGAD_FORM_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) MPI_SAS_EXPAND_PGAD_FORM_SHIFT), handle)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) port_info = kzalloc(sizeof(struct mptsas_portinfo), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) if (!port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) port_info->num_phys = buffer.num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) port_info->phy_info = buffer.phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) for (i = 0; i < port_info->num_phys; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) list_add_tail(&port_info->list, &ioc->sas_topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) (unsigned long long)buffer.phy_info[0].identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) return port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) mptsas_send_link_status_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) MpiEventDataSasPhyLinkStatus_t *link_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) struct mptsas_phyinfo *phy_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) __le64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) u8 phy_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) u8 link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) link_data = (MpiEventDataSasPhyLinkStatus_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) memcpy(&sas_address, &link_data->SASAddress, sizeof(__le64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) sas_address = le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) link_rate = link_data->LinkRates >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) phy_num = link_data->PhyNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) port_info = mptsas_find_portinfo_by_sas_address(ioc, sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) if (port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) phy_info = &port_info->phy_info[phy_num];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) if (phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) phy_info->negotiated_link_rate = link_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) if (link_rate == MPI_SAS_IOUNIT0_RATE_1_5 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) link_rate == MPI_SAS_IOUNIT0_RATE_3_0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) link_rate == MPI_SAS_IOUNIT0_RATE_6_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) if (!port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) if (ioc->old_sas_discovery_protocal) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) port_info = mptsas_expander_add(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) le16_to_cpu(link_data->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) if (port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) goto out;
^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) if (port_info == ioc->hba_port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) mptsas_probe_hba_phys(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) } else if (phy_info && phy_info->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) if (link_rate == MPI_SAS_IOUNIT0_RATE_PHY_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) phy_info->phy->negotiated_linkrate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) SAS_PHY_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) else if (link_rate ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) phy_info->phy->negotiated_linkrate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) SAS_LINK_RATE_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) phy_info->phy->negotiated_linkrate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) SAS_LINK_RATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) if (ioc->device_missing_delay &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) mptsas_is_end_device(&phy_info->attached)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) VirtDevice *vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) u8 channel, id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) id = phy_info->attached.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) channel = phy_info->attached.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) "Link down for fw_id %d:fw_channel %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) ioc->name, phy_info->attached.id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) phy_info->attached.channel));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) shost_for_each_device(sdev, ioc->sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) vdevice = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) if ((vdevice == NULL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) (vdevice->vtarget == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) if ((vdevice->vtarget->tflags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) MPT_TARGET_FLAGS_RAID_COMPONENT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) vdevice->vtarget->raidVolume))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) if (vdevice->vtarget->id == id &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) vdevice->vtarget->channel ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) devtprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) "SDEV OUTSTANDING CMDS"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) "%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) atomic_read(&sdev->device_busy)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) mptsas_not_responding_devices(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) struct mptsas_portinfo buffer, *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) struct mptsas_device_info *sas_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) struct mptsas_devinfo sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) u32 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) VirtTarget *vtarget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) u8 found_expander;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) int retval, retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) if (ioc->ioc_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) "%s: exiting due to a parallel reset \n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) /* devices, logical volumes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) redo_device_scan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) list_for_each_entry(sas_info, &ioc->sas_device_info_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) if (sas_info->is_cached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) if (!sas_info->is_logical_volume) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) sas_device.handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) retry_page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) retval = mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) << MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) (sas_info->fw.channel << 8) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) sas_info->fw.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) if (sas_device.handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) if (retval == -EBUSY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) if (ioc->ioc_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) dfailprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) "%s: exiting due to reset\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) spin_unlock_irqrestore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) (&ioc->taskmgmt_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) mutex_unlock(&ioc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) spin_unlock_irqrestore(&ioc->taskmgmt_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) if (retval && (retval != -ENODEV)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) if (retry_count < 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) retry_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) goto retry_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) "%s: Config page retry exceeded retry "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) "count deleting device 0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) sas_info->sas_address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) /* delete device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) vtarget = mptsas_find_vtarget(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) sas_info->fw.channel, sas_info->fw.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) if (vtarget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) vtarget->deleted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) sas_info->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) mptsas_del_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) goto redo_device_scan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) mptsas_volume_delete(ioc, sas_info->fw.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) /* expanders */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) redo_expander_scan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) list_for_each_entry(port_info, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) if (!(port_info->phy_info[0].identify.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) MPI_SAS_DEVICE_INFO_SMP_TARGET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) found_expander = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) while (!mptsas_sas_expander_pg0(ioc, &buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) MPI_SAS_EXPAND_PGAD_FORM_SHIFT), handle) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) !found_expander) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) handle = buffer.phy_info[0].handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) if (buffer.phy_info[0].identify.sas_address ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) port_info->phy_info[0].identify.sas_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) found_expander = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) kfree(buffer.phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) if (!found_expander) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) mptsas_expander_delete(ioc, port_info, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) goto redo_expander_scan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) * mptsas_probe_expanders - adding expanders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) mptsas_probe_expanders(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) struct mptsas_portinfo buffer, *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) u32 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) while (!mptsas_sas_expander_pg0(ioc, &buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) MPI_SAS_EXPAND_PGAD_FORM_SHIFT), handle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) handle = buffer.phy_info[0].handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) port_info = mptsas_find_portinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) buffer.phy_info[0].identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) if (port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) /* refreshing handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) for (i = 0; i < buffer.num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) port_info->phy_info[i].handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) port_info->phy_info[i].identify.handle_parent =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) buffer.phy_info[0].identify.handle_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) kfree(buffer.phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) port_info = kzalloc(sizeof(struct mptsas_portinfo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) if (!port_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) "%s: exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) port_info->num_phys = buffer.num_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) port_info->phy_info = buffer.phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) for (i = 0; i < port_info->num_phys; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) port_info->phy_info[i].portinfo = port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) list_add_tail(&port_info->list, &ioc->sas_topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) (unsigned long long)buffer.phy_info[0].identify.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) mptsas_probe_devices(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) struct mptsas_devinfo sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) handle = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) while (!(mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) MPI_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) handle = sas_device.handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) if ((sas_device.device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) (MPI_SAS_DEVICE_INFO_SSP_TARGET |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) MPI_SAS_DEVICE_INFO_STP_TARGET |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) MPI_SAS_DEVICE_INFO_SATA_DEVICE)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) /* If there is no FW B_T mapping for this device then continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) if (!(sas_device.flags & MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) || !(sas_device.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) phy_info = mptsas_refreshing_device_handles(ioc, &sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) if (!phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) if (mptsas_get_rphy(phy_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) mptsas_add_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) * mptsas_scan_sas_topology -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) * @sas_address:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) mptsas_probe_hba_phys(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) mptsas_probe_expanders(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) mptsas_probe_devices(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) Reporting RAID volumes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) if (!ioc->ir_firmware || !ioc->raid_data.pIocPg2 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) !ioc->raid_data.pIocPg2->NumActiveVolumes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) if (sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) scsi_device_put(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) printk(MYIOC_s_INFO_FMT "attaching raid volume, channel %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) mptsas_handle_queue_full_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) EventDataQueueFull_t *qfull_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) struct mptsas_device_info *sas_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) int depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) int id = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) int channel = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) int fw_id, fw_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) u16 current_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) qfull_data = (EventDataQueueFull_t *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) fw_id = qfull_data->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) fw_channel = qfull_data->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) current_depth = le16_to_cpu(qfull_data->CurrentDepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) /* if hidden raid component, look for the volume id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) mutex_lock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) if (mptscsih_is_phys_disk(ioc, fw_channel, fw_id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) list_for_each_entry(sas_info, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) if (sas_info->is_cached ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) sas_info->is_logical_volume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) if (sas_info->is_hidden_raid_component &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) (sas_info->fw.channel == fw_channel &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) sas_info->fw.id == fw_id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) id = sas_info->volume_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) channel = MPTSAS_RAID_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) list_for_each_entry(sas_info, &ioc->sas_device_info_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) if (sas_info->is_cached ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) sas_info->is_hidden_raid_component ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) sas_info->is_logical_volume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) if (sas_info->fw.channel == fw_channel &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) sas_info->fw.id == fw_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) id = sas_info->os.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) channel = sas_info->os.channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) mutex_unlock(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) if (id != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) shost_for_each_device(sdev, ioc->sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) if (sdev->id == id && sdev->channel == channel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) if (current_depth > sdev->queue_depth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) "strange observation, the queue "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) "depth is (%d) meanwhile fw queue "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) "depth (%d)\n", sdev->queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) current_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) depth = scsi_track_queue_full(sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) sdev->queue_depth - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) if (depth > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) "Queue depth reduced to (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) else if (depth < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) sdev_printk(KERN_INFO, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) "Tagged Command Queueing is being "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) "disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) else if (depth == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) sdev_printk(KERN_DEBUG, sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) "Queue depth not changed yet\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) mptsas_free_fw_event(ioc, fw_event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) static struct mptsas_phyinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) mptsas_find_phyinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) struct mptsas_phyinfo *phy_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) list_for_each_entry(port_info, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) for (i = 0; i < port_info->num_phys; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) if (!mptsas_is_end_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) &port_info->phy_info[i].attached))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) if (port_info->phy_info[i].attached.sas_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) != sas_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) phy_info = &port_info->phy_info[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) break;
^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) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) return phy_info;
^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) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) * mptsas_find_phyinfo_by_phys_disk_num -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) * @phys_disk_num:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) * @channel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) * @id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) static struct mptsas_phyinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) mptsas_find_phyinfo_by_phys_disk_num(MPT_ADAPTER *ioc, u8 phys_disk_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) struct mptsas_phyinfo *phy_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) RaidPhysDiskPage1_t *phys_disk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) int num_paths;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) u64 sas_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) phy_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) if (!ioc->raid_data.pIocPg3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) /* dual port support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) num_paths = mpt_raid_phys_disk_get_num_paths(ioc, phys_disk_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) if (!num_paths)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) phys_disk = kzalloc(offsetof(RaidPhysDiskPage1_t, Path) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) (num_paths * sizeof(RAID_PHYS_DISK1_PATH)), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) if (!phys_disk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) mpt_raid_phys_disk_pg1(ioc, phys_disk_num, phys_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) for (i = 0; i < num_paths; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) if ((phys_disk->Path[i].Flags & 1) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) /* entry no longer valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) if ((id == phys_disk->Path[i].PhysDiskID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) (channel == phys_disk->Path[i].PhysDiskBus)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) memcpy(&sas_address, &phys_disk->Path[i].WWID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) kfree(phys_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) if (phy_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) return phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) * Extra code to handle RAID0 case, where the sas_address is not updated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) * in phys_disk_page_1 when hotswapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) list_for_each_entry(port_info, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) for (i = 0; i < port_info->num_phys && !phy_info; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) if (!mptsas_is_end_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) &port_info->phy_info[i].attached))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) if (port_info->phy_info[i].attached.phys_disk_num == ~0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) if ((port_info->phy_info[i].attached.phys_disk_num ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) phys_disk_num) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) (port_info->phy_info[i].attached.id == id) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) (port_info->phy_info[i].attached.channel ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) channel))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) phy_info = &port_info->phy_info[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) return phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) mptsas_reprobe_lun(struct scsi_device *sdev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) sdev->no_uld_attach = data ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) rc = scsi_device_reprobe(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) starget_for_each_device(starget, uld_attach ? (void *)1 : NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) mptsas_reprobe_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) mptsas_adding_inactive_raid_components(MPT_ADAPTER *ioc, u8 channel, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) CONFIGPARMS cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) ConfigPageHeader_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) dma_addr_t dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) pRaidVolumePage0_t buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) RaidPhysDiskPage0_t phys_disk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) struct mptsas_devinfo sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) memset(&cfg, 0 , sizeof(CONFIGPARMS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) memset(&hdr, 0 , sizeof(ConfigPageHeader_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) hdr.PageType = MPI_CONFIG_PAGETYPE_RAID_VOLUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) cfg.pageAddr = (channel << 8) + id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) cfg.cfghdr.hdr = &hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) cfg.timeout = SAS_CONFIG_PAGE_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) if (mpt_config(ioc, &cfg) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) if (!hdr.PageLength)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) &dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) cfg.physAddr = dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) if (mpt_config(ioc, &cfg) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) if (!(buffer->VolumeStatus.Flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) if (!buffer->NumPhysDisks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) for (i = 0; i < buffer->NumPhysDisks; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) if (mpt_raid_phys_disk_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) if (mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) (phys_disk.PhysDiskBus << 8) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) phys_disk.PhysDiskID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) /* If there is no FW B_T mapping for this device then continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) if (!(sas_device.flags & MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) || !(sas_device.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) sas_device.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) mptsas_add_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) if (buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) * Work queue thread to handle SAS hotplug events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) mptsas_hotplug_work(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) struct mptsas_hotplug_event *hot_plug_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) struct mptsas_phyinfo *phy_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) struct scsi_target * starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) struct mptsas_devinfo sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) VirtTarget *vtarget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) struct mptsas_portinfo *port_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) switch (hot_plug_info->event_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) case MPTSAS_ADD_PHYSDISK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) if (!ioc->raid_data.pIocPg2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) hot_plug_info->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) printk(MYIOC_s_WARN_FMT "firmware bug: unable "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) "to add hidden disk - target_id matches "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) "volume_id\n", ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) case MPTSAS_ADD_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) memset(&sas_device, 0, sizeof(struct mptsas_devinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) (hot_plug_info->channel << 8) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) /* If there is no FW B_T mapping for this device then break
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) if (!(sas_device.flags & MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) || !(sas_device.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) if (!sas_device.handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) phy_info = mptsas_refreshing_device_handles(ioc, &sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) /* Device hot plug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) if (!phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) "%s %d HOT PLUG: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) "parent handle of device %x\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) __func__, __LINE__, sas_device.handle_parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) port_info = mptsas_find_portinfo_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) sas_device.handle_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) if (port_info == ioc->hba_port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) mptsas_probe_hba_phys(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) else if (port_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) mptsas_expander_refresh(ioc, port_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) "%s %d port info is NULL\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) ioc->name, __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) phy_info = mptsas_refreshing_device_handles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) (ioc, &sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) if (!phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) "%s %d phy info is NULL\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) ioc->name, __func__, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) if (mptsas_get_rphy(phy_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) mptsas_add_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) case MPTSAS_DEL_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) hot_plug_info->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) mptsas_del_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) case MPTSAS_DEL_PHYSDISK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) phy_info = mptsas_find_phyinfo_by_phys_disk_num(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) ioc, hot_plug_info->phys_disk_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) hot_plug_info->channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) mptsas_del_end_device(ioc, phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) case MPTSAS_ADD_PHYSDISK_REPROBE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) if (mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) (hot_plug_info->channel << 8) + hot_plug_info->id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) /* If there is no FW B_T mapping for this device then break
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) if (!(sas_device.flags & MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) || !(sas_device.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) phy_info = mptsas_find_phyinfo_by_sas_address(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) ioc, sas_device.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) if (!phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) starget = mptsas_get_starget(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) if (!starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) vtarget = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) if (!vtarget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) starget_printk(KERN_INFO, starget, MYIOC_s_FMT "RAID Hidding: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) "fw_channel=%d, fw_id=%d, physdsk %d, sas_addr 0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) ioc->name, hot_plug_info->channel, hot_plug_info->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) hot_plug_info->phys_disk_num, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) sas_device.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) vtarget->id = hot_plug_info->phys_disk_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) phy_info->attached.phys_disk_num = hot_plug_info->phys_disk_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) mptsas_reprobe_target(starget, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) case MPTSAS_DEL_PHYSDISK_REPROBE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) if (mptsas_sas_device_pg0(ioc, &sas_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) (hot_plug_info->channel << 8) + hot_plug_info->id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) "%s: fw_id=%d exit at line=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) /* If there is no FW B_T mapping for this device then break
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) if (!(sas_device.flags & MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) || !(sas_device.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) sas_device.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) if (!phy_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) starget = mptsas_get_starget(phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) if (!starget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) vtarget = starget->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) if (!vtarget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) if (!(vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) "%s: fw_id=%d exit at line=%d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) __func__, hot_plug_info->id, __LINE__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) starget_printk(KERN_INFO, starget, MYIOC_s_FMT "RAID Exposing:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) " fw_channel=%d, fw_id=%d, physdsk %d, sas_addr 0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) ioc->name, hot_plug_info->channel, hot_plug_info->id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) hot_plug_info->phys_disk_num, (unsigned long long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) sas_device.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) vtarget->id = hot_plug_info->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) phy_info->attached.phys_disk_num = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) mptsas_reprobe_target(starget, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) mptsas_add_device_component_by_fw(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) hot_plug_info->channel, hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) case MPTSAS_ADD_RAID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) printk(MYIOC_s_INFO_FMT "attaching raid volume, channel %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) hot_plug_info->id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) case MPTSAS_DEL_RAID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) printk(MYIOC_s_INFO_FMT "removing raid volume, channel %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) scsi_remove_device(hot_plug_info->sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) scsi_device_put(hot_plug_info->sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) case MPTSAS_ADD_INACTIVE_VOLUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) mptsas_adding_inactive_raid_components(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) hot_plug_info->channel, hot_plug_info->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) mptsas_send_sas_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) struct mptsas_hotplug_event hot_plug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) u32 device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) u64 sas_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) sas_event_data = (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) device_info = le32_to_cpu(sas_event_data->DeviceInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) if ((device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) (MPI_SAS_DEVICE_INFO_SSP_TARGET |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) MPI_SAS_DEVICE_INFO_STP_TARGET |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) MPI_SAS_DEVICE_INFO_SATA_DEVICE)) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) if (sas_event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) mptbase_sas_persist_operation(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) MPI_SAS_OP_CLEAR_NOT_PRESENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) return;
^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) switch (sas_event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) case MPI_EVENT_SAS_DEV_STAT_RC_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) memset(&hot_plug_info, 0, sizeof(struct mptsas_hotplug_event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) hot_plug_info.handle = le16_to_cpu(sas_event_data->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) hot_plug_info.channel = sas_event_data->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) hot_plug_info.id = sas_event_data->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) hot_plug_info.phy_id = sas_event_data->PhyNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) memcpy(&sas_address, &sas_event_data->SASAddress,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) hot_plug_info.sas_address = le64_to_cpu(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) hot_plug_info.device_info = device_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) if (sas_event_data->ReasonCode &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) MPI_EVENT_SAS_DEV_STAT_RC_ADDED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) hot_plug_info.event_type = MPTSAS_ADD_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) hot_plug_info.event_type = MPTSAS_DEL_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) mptbase_sas_persist_operation(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) MPI_SAS_OP_CLEAR_NOT_PRESENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) case MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) mptsas_send_raid_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) EVENT_DATA_RAID *raid_event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) struct mptsas_hotplug_event hot_plug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) int state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) struct scsi_device *sdev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) VirtDevice *vdevice = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) RaidPhysDiskPage0_t phys_disk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) raid_event_data = (EVENT_DATA_RAID *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) status = le32_to_cpu(raid_event_data->SettingsStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) state = (status >> 8) & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) memset(&hot_plug_info, 0, sizeof(struct mptsas_hotplug_event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) hot_plug_info.id = raid_event_data->VolumeID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) hot_plug_info.channel = raid_event_data->VolumeBus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) hot_plug_info.phys_disk_num = raid_event_data->PhysDiskNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) if (raid_event_data->ReasonCode == MPI_EVENT_RAID_RC_VOLUME_DELETED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) raid_event_data->ReasonCode == MPI_EVENT_RAID_RC_VOLUME_CREATED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) raid_event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) hot_plug_info.id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) hot_plug_info.sdev = sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) if (sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) vdevice = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Entering %s: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) "ReasonCode=%02x\n", ioc->name, __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) raid_event_data->ReasonCode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) switch (raid_event_data->ReasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) case MPI_EVENT_RAID_RC_PHYSDISK_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) hot_plug_info.event_type = MPTSAS_DEL_PHYSDISK_REPROBE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) case MPI_EVENT_RAID_RC_PHYSDISK_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) hot_plug_info.event_type = MPTSAS_ADD_PHYSDISK_REPROBE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) case MPI_PD_STATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) case MPI_PD_STATE_NOT_COMPATIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) mpt_raid_phys_disk_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) raid_event_data->PhysDiskNum, &phys_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) hot_plug_info.id = phys_disk.PhysDiskID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) hot_plug_info.channel = phys_disk.PhysDiskBus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) hot_plug_info.event_type = MPTSAS_ADD_PHYSDISK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) case MPI_PD_STATE_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) case MPI_PD_STATE_MISSING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) case MPI_PD_STATE_OFFLINE_AT_HOST_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) case MPI_PD_STATE_FAILED_AT_HOST_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) case MPI_PD_STATE_OFFLINE_FOR_ANOTHER_REASON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) hot_plug_info.event_type = MPTSAS_DEL_PHYSDISK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) case MPI_EVENT_RAID_RC_VOLUME_DELETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) if (!sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) vdevice->vtarget->deleted = 1; /* block IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) hot_plug_info.event_type = MPTSAS_DEL_RAID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) case MPI_EVENT_RAID_RC_VOLUME_CREATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) if (sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) scsi_device_put(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) hot_plug_info.event_type = MPTSAS_ADD_RAID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) if (!(status & MPI_RAIDVOL0_STATUS_FLAG_ENABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) if (!sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) vdevice->vtarget->deleted = 1; /* block IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) hot_plug_info.event_type = MPTSAS_DEL_RAID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) case MPI_RAIDVOL0_STATUS_STATE_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) case MPI_RAIDVOL0_STATUS_STATE_MISSING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) if (!sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) vdevice->vtarget->deleted = 1; /* block IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) hot_plug_info.event_type = MPTSAS_DEL_RAID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) case MPI_RAIDVOL0_STATUS_STATE_OPTIMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) case MPI_RAIDVOL0_STATUS_STATE_DEGRADED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) if (sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) scsi_device_put(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) hot_plug_info.event_type = MPTSAS_ADD_RAID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) if (hot_plug_info.event_type != MPTSAS_IGNORE_EVENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) * mptsas_issue_tm - send mptsas internal tm request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) * @type: Task Management type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) * @channel: channel number for task management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) * @id: Logical Target ID for reset (if appropriate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) * @lun: Logical unit for reset (if appropriate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) * @task_context: Context for the task to be aborted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) * @timeout: timeout for task management control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) * return 0 on success and -1 on failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) mptsas_issue_tm(MPT_ADAPTER *ioc, u8 type, u8 channel, u8 id, u64 lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) int task_context, ulong timeout, u8 *issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) SCSITaskMgmt_t *pScsiTm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) unsigned long timeleft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) *issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) if (mf == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) retval = -1; /* return failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) dtmprintk(ioc, printk(MYIOC_s_WARN_FMT "TaskMgmt request: no "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) "msg frames!!\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request: mr = %p, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) "task_type = 0x%02X,\n\t timeout = %ld, fw_channel = %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) "fw_id = %d, lun = %lld,\n\t task_context = 0x%x\n", ioc->name, mf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) type, timeout, channel, id, (unsigned long long)lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) task_context));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) pScsiTm = (SCSITaskMgmt_t *) mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) memset(pScsiTm, 0, sizeof(SCSITaskMgmt_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) pScsiTm->TaskType = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) pScsiTm->MsgFlags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) pScsiTm->TargetID = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) pScsiTm->Bus = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) pScsiTm->ChainOffset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) pScsiTm->Reserved = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) pScsiTm->Reserved1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) pScsiTm->TaskMsgContext = task_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) int_to_scsilun(lun, (struct scsi_lun *)pScsiTm->LUN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) CLEAR_MGMT_STATUS(ioc->internal_cmds.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) /* Now wait for the command to complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) timeleft = wait_for_completion_timeout(&ioc->taskmgmt_cmds.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) timeout*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) retval = -1; /* return failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) dtmprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) "TaskMgmt request: TIMED OUT!(mr=%p)\n", ioc->name, mf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) mpt_free_msg_frame(ioc, mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) *issue_reset = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_RF_VALID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) retval = -1; /* return failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) "TaskMgmt request: failed with no reply\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) CLEAR_MGMT_STATUS(ioc->taskmgmt_cmds.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) * mptsas_broadcast_primitive_work - Handle broadcast primitives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) * @work: work queue payload containing info describing the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) * this will be handled in workqueue context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) mptsas_broadcast_primitive_work(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) MPT_ADAPTER *ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) MPT_FRAME_HDR *mf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) VirtDevice *vdevice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) int ii;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) struct scsi_cmnd *sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) SCSITaskMgmtReply_t *pScsiTmReply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) u8 issue_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) int task_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) u8 channel, id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) int lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) u32 termination_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) u32 query_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) "%s - enter\n", ioc->name, __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) mutex_lock(&ioc->taskmgmt_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) mutex_unlock(&ioc->taskmgmt_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) mptsas_requeue_fw_event(ioc, fw_event, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) termination_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) query_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) mpt_findImVolumes(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) pScsiTmReply = (SCSITaskMgmtReply_t *) ioc->taskmgmt_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) for (ii = 0; ii < ioc->req_depth; ii++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) if (ioc->fw_events_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) sc = mptscsih_get_scsi_lookup(ioc, ii);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) if (!sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) mf = MPT_INDEX_2_MFPTR(ioc, ii);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) if (!mf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) task_context = mf->u.frame.hwhdr.msgctxu.MsgContext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) vdevice = sc->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) if (!vdevice || !vdevice->vtarget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) continue; /* skip hidden raid components */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) if (vdevice->vtarget->raidVolume)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) continue; /* skip hidden raid components */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) channel = vdevice->vtarget->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) id = vdevice->vtarget->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) lun = vdevice->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) if (mptsas_issue_tm(ioc, MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) channel, id, (u64)lun, task_context, 30, &issue_reset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) query_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) termination_count +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) le32_to_cpu(pScsiTmReply->TerminationCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) if ((pScsiTmReply->IOCStatus == MPI_IOCSTATUS_SUCCESS) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) (pScsiTmReply->ResponseCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) MPI_SCSITASKMGMT_RSP_TM_SUCCEEDED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) pScsiTmReply->ResponseCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) MPI_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) if (mptsas_issue_tm(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) channel, id, (u64)lun, 0, 30, &issue_reset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) termination_count +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) le32_to_cpu(pScsiTmReply->TerminationCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) "%s - exit, query_count = %d termination_count = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) ioc->name, __func__, query_count, termination_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) ioc->broadcast_aen_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) mpt_clear_taskmgmt_in_progress_flag(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) mutex_unlock(&ioc->taskmgmt_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) if (issue_reset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) "Issuing Reset from %s!! doorbell=0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) ioc->name, __func__, mpt_GetIocState(ioc, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) * mptsas_send_ir2_event - handle exposing hidden disk when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) * an inactive raid volume is added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) * @ioc: Pointer to MPT_ADAPTER structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) * @ir2_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) mptsas_send_ir2_event(struct fw_event_work *fw_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) struct mptsas_hotplug_event hot_plug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) MPI_EVENT_DATA_IR2 *ir2_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) u8 reasonCode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) RaidPhysDiskPage0_t phys_disk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) ioc = fw_event->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) ir2_data = (MPI_EVENT_DATA_IR2 *)fw_event->event_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) reasonCode = ir2_data->ReasonCode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Entering %s: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) "ReasonCode=%02x\n", ioc->name, __func__, reasonCode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) memset(&hot_plug_info, 0, sizeof(struct mptsas_hotplug_event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) hot_plug_info.id = ir2_data->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) hot_plug_info.channel = ir2_data->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) switch (reasonCode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) case MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) hot_plug_info.event_type = MPTSAS_ADD_INACTIVE_VOLUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) case MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) hot_plug_info.phys_disk_num = ir2_data->PhysDiskNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) hot_plug_info.event_type = MPTSAS_DEL_PHYSDISK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) case MPI_EVENT_IR2_RC_DUAL_PORT_ADDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) hot_plug_info.phys_disk_num = ir2_data->PhysDiskNum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) mpt_raid_phys_disk_pg0(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) ir2_data->PhysDiskNum, &phys_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) hot_plug_info.id = phys_disk.PhysDiskID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) hot_plug_info.event_type = MPTSAS_ADD_PHYSDISK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) mptsas_free_fw_event(ioc, fw_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) u32 event = le32_to_cpu(reply->Event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) int event_data_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) struct fw_event_work *fw_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) unsigned long delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) if (ioc->bus_type != SAS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) /* events turned off due to host reset or driver unloading */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) if (ioc->fw_events_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) delay = msecs_to_jiffies(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) case MPI_EVENT_SAS_BROADCAST_PRIMITIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) EVENT_DATA_SAS_BROADCAST_PRIMITIVE *broadcast_event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) (EVENT_DATA_SAS_BROADCAST_PRIMITIVE *)reply->Data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) if (broadcast_event_data->Primitive !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) MPI_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) if (ioc->broadcast_aen_busy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) ioc->broadcast_aen_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) u16 ioc_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) ioc_stat = le16_to_cpu(reply->IOCStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) if (sas_event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) mptsas_target_reset_queue(ioc, sas_event_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) if (sas_event_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) ioc->device_missing_delay &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) VirtTarget *vtarget = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) u8 id, channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) id = sas_event_data->TargetID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) channel = sas_event_data->Bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) vtarget = mptsas_find_vtarget(ioc, channel, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) if (vtarget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) "LogInfo (0x%x) available for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) "INTERNAL_DEVICE_RESET"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) "fw_id %d fw_channel %d\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) le32_to_cpu(reply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) id, channel));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) if (vtarget->raidVolume) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) "Skipping Raid Volume for inDMD\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) "Setting device flag inDMD\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) vtarget->inDMD = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) case MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) MpiEventDataSasExpanderStatusChange_t *expander_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) (MpiEventDataSasExpanderStatusChange_t *)reply->Data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) if (ioc->old_sas_discovery_protocal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) if (expander_data->ReasonCode ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) MPI_EVENT_SAS_EXP_RC_NOT_RESPONDING &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) ioc->device_missing_delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) delay = HZ * ioc->device_missing_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) case MPI_EVENT_SAS_DISCOVERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) u32 discovery_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) EventDataSasDiscovery_t *discovery_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) (EventDataSasDiscovery_t *)reply->Data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) discovery_status = le32_to_cpu(discovery_data->DiscoveryStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) ioc->sas_discovery_quiesce_io = discovery_status ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) if (ioc->old_sas_discovery_protocal && !discovery_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) mptsas_queue_rescan(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) case MPI_EVENT_INTEGRATED_RAID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) case MPI_EVENT_PERSISTENT_TABLE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) case MPI_EVENT_IR2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) case MPI_EVENT_SAS_PHY_LINK_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) case MPI_EVENT_QUEUE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) event_data_sz = ((reply->MsgLength * 4) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) offsetof(EventNotificationReply_t, Data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) fw_event = kzalloc(sizeof(*fw_event) + event_data_sz, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) if (!fw_event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) __func__, __LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) memcpy(fw_event->event_data, reply->Data, event_data_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) fw_event->event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) fw_event->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) mptsas_add_fw_event(ioc, fw_event, delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) /* Delete a volume when no longer listed in ioc pg2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) static void mptsas_volume_delete(MPT_ADAPTER *ioc, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) if (!sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) if (!ioc->raid_data.pIocPg2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) goto release_sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) printk(MYIOC_s_INFO_FMT "removing raid volume, channel %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) scsi_remove_device(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) release_sdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) scsi_device_put(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) struct Scsi_Host *sh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) MPT_SCSI_HOST *hd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) MPT_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) int ii;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) int numSGE = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) int scale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) int ioc_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) int error=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) r = mpt_attach(pdev,id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) ioc = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) mptsas_fw_event_off(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) ioc->DoneCtx = mptsasDoneCtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) ioc->TaskCtx = mptsasTaskCtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) ioc->InternalCtx = mptsasInternalCtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) ioc->schedule_target_reset = &mptsas_schedule_target_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) ioc->schedule_dead_ioc_flush_running_cmds =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) &mptscsih_flush_running_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) /* Added sanity check on readiness of the MPT adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) "Skipping because it's not operational!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) goto out_mptsas_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) if (!ioc->active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) goto out_mptsas_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) /* Sanity check - ensure at least 1 port is INITIATOR capable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) ioc_cap = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) for (ii = 0; ii < ioc->facts.NumberOfPorts; ii++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) if (ioc->pfacts[ii].ProtocolFlags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) MPI_PORTFACTS_PROTOCOL_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) ioc_cap++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) if (!ioc_cap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) "Skipping ioc=%p because SCSI Initiator mode "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) "is NOT enabled!\n", ioc->name, ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) sh = scsi_host_alloc(&mptsas_driver_template, sizeof(MPT_SCSI_HOST));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) if (!sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) printk(MYIOC_s_WARN_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) "Unable to register controller with SCSI subsystem\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) error = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) goto out_mptsas_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) spin_lock_irqsave(&ioc->FreeQlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) /* Attach the SCSI Host to the IOC structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) ioc->sh = sh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) sh->io_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) sh->n_io_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) sh->irq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) /* set 16 byte cdb's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) sh->max_cmd_len = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) sh->can_queue = min_t(int, ioc->req_depth - 10, sh->can_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) sh->max_id = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) sh->max_lun = max_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) sh->transportt = mptsas_transport_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) /* Required entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) sh->unique_id = ioc->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) INIT_LIST_HEAD(&ioc->sas_topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) mutex_init(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) mutex_init(&ioc->sas_discovery_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) mutex_init(&ioc->sas_mgmt.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) init_completion(&ioc->sas_mgmt.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) /* Verify that we won't exceed the maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) * number of chain buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) * We can optimize: ZZ = req_sz/sizeof(SGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) * For 32bit SGE's:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) * + (req_sz - 64)/sizeof(SGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) * A slightly different algorithm is required for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) * 64bit SGEs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) scale = ioc->req_sz/ioc->SGE_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) if (ioc->sg_addr_size == sizeof(u64)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) numSGE = (scale - 1) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) (ioc->facts.MaxChainDepth-1) + scale +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) (ioc->req_sz - 60) / ioc->SGE_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) numSGE = 1 + (scale - 1) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) (ioc->facts.MaxChainDepth-1) + scale +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) (ioc->req_sz - 64) / ioc->SGE_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) if (numSGE < sh->sg_tablesize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) /* Reset this value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) "Resetting sg_tablesize to %d from %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) ioc->name, numSGE, sh->sg_tablesize));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) sh->sg_tablesize = numSGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) if (mpt_loadtime_max_sectors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) if (mpt_loadtime_max_sectors < 64 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) mpt_loadtime_max_sectors > 8192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) printk(MYIOC_s_INFO_FMT "Invalid value passed for"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) "mpt_loadtime_max_sectors %d."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) "Range from 64 to 8192\n", ioc->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) mpt_loadtime_max_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) mpt_loadtime_max_sectors &= 0xFFFFFFFE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) "Resetting max sector to %d from %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) ioc->name, mpt_loadtime_max_sectors, sh->max_sectors));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) sh->max_sectors = mpt_loadtime_max_sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) hd = shost_priv(sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) hd->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) /* SCSI needs scsi_cmnd lookup table!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) * (with size equal to req_depth*PtrSz!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) if (!ioc->ScsiLookup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) spin_unlock_irqrestore(&ioc->FreeQlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) goto out_mptsas_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) spin_lock_init(&ioc->scsi_lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) ioc->name, ioc->ScsiLookup));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) ioc->sas_data.ptClear = mpt_pt_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) hd->last_queue_full = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) INIT_LIST_HEAD(&hd->target_reset_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) INIT_LIST_HEAD(&ioc->sas_device_info_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) mutex_init(&ioc->sas_device_info_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) spin_unlock_irqrestore(&ioc->FreeQlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) if (ioc->sas_data.ptClear==1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) mptbase_sas_persist_operation(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) error = scsi_add_host(sh, &ioc->pcidev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) dprintk(ioc, printk(MYIOC_s_ERR_FMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) "scsi_add_host failed\n", ioc->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) goto out_mptsas_probe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) /* older firmware doesn't support expander events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) if ((ioc->facts.HeaderVersion >> 8) < 0xE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) ioc->old_sas_discovery_protocal = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) mptsas_scan_sas_topology(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) mptsas_fw_event_on(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) out_mptsas_probe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) mptscsih_remove(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) mptsas_shutdown(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) mptsas_fw_event_off(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) mptsas_cleanup_fw_event_q(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) static void mptsas_remove(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) struct mptsas_portinfo *p, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) if (!ioc->sh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) printk(MYIOC_s_INFO_FMT "IOC is in Target mode\n", ioc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) mpt_detach(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) mptsas_shutdown(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) mptsas_del_device_components(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) ioc->sas_discovery_ignore_events = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) sas_remove_host(ioc->sh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) mutex_lock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) list_del(&p->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) for (i = 0 ; i < p->num_phys ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) mptsas_port_delete(ioc, p->phy_info[i].port_details);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) kfree(p->phy_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) kfree(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) mutex_unlock(&ioc->sas_topology_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) ioc->hba_port_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) mptscsih_remove(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) static struct pci_device_id mptsas_pci_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064E,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068E,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1078,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068_820XELP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) PCI_ANY_ID, PCI_ANY_ID },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) {0} /* Terminating entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) MODULE_DEVICE_TABLE(pci, mptsas_pci_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) static struct pci_driver mptsas_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) .name = "mptsas",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) .id_table = mptsas_pci_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) .probe = mptsas_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) .remove = mptsas_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) .shutdown = mptsas_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) .suspend = mptscsih_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) .resume = mptscsih_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) mptsas_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) show_mptmod_ver(my_NAME, my_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) mptsas_transport_template =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) sas_attach_transport(&mptsas_transport_functions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) if (!mptsas_transport_template)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) mptsasDoneCtx = mpt_register(mptscsih_io_done, MPTSAS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) "mptscsih_io_done");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) mptsasTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSAS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) "mptscsih_taskmgmt_complete");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) mptsasInternalCtx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) "mptscsih_scandv_complete");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) mptsasMgmtCtx = mpt_register(mptsas_mgmt_done, MPTSAS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) "mptsas_mgmt_done");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) mptsasDeviceResetCtx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) mpt_register(mptsas_taskmgmt_complete, MPTSAS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) "mptsas_taskmgmt_complete");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) mpt_event_register(mptsasDoneCtx, mptsas_event_process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) mpt_reset_register(mptsasDoneCtx, mptsas_ioc_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) error = pci_register_driver(&mptsas_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) sas_release_transport(mptsas_transport_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) static void __exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) mptsas_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) pci_unregister_driver(&mptsas_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) sas_release_transport(mptsas_transport_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) mpt_reset_deregister(mptsasDoneCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) mpt_event_deregister(mptsasDoneCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) mpt_deregister(mptsasMgmtCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) mpt_deregister(mptsasInternalCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) mpt_deregister(mptsasTaskCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) mpt_deregister(mptsasDoneCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) mpt_deregister(mptsasDeviceResetCtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) module_init(mptsas_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) module_exit(mptsas_exit);