Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2009938imm; Thu, 24 May 2018 04:28:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIM0IFuCabtrp9vL7q9BiNTcK9a/qFmt1Awjiy+xo3gysJhYB65pNl6JvO44xN1zUG4fqo X-Received: by 2002:a65:6250:: with SMTP id q16-v6mr5619883pgv.113.1527161296458; Thu, 24 May 2018 04:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161296; cv=none; d=google.com; s=arc-20160816; b=Yise0znWaipBrx1CEb2cGb8pXIcwjFvmFVVoChI3CejYiORLv0xTO1X2GIwmpP90G6 zLCuFSFVbP/ShgGg9wgxLalz1vowHhDXZRw8MSiLALpcXX7fVeDVWRzD4T4IQaBs1j00 WPFAvhOBOs2hlQiRUFa9AYnsNi8pwdXVUMLwQQxi1YP9lkGJ7RwtGRe5/vOPhUb5DCCK W61+CFwDBugNEHSae2ZsMzaAQJ4LjPN2vEyCstI8mogLm7QolDypZyEP2odkcbt/Dj6D NAQmSRSnaIRHhlL2hBv+Pm4fwo8MEYUYL3tCQeGTPS6GKu0EZ+ia4jWb8K7sYPbGLIfQ jNtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=VCqOD/5WT0VbKmwhTUb2MU0kQSGLRHkDJsMjPNAxx7M=; b=C6BYjr8afpLdcAKZEGhmvvVf6IDdakWEamGLAxny8Q8UgzURobS1tvye8Ur9MuNCGK GiqCkJiKE03yd0TdshK2ar6eOjzzfNp6IXvL0LtRWBvfCjNWrWAV9jTgXoam87P9cz3W 43g6mKS8ut+vuyCcMpcZe8MvYgGCGl1TFAXlD3RJx5MPa94Z8dm/HgXHD3UUnY8jwzpY enY3h69JYqDS3X+/PyheFiP1Vh+UuY6OkxXIJDcybZ5gZETHFvl3ks0Mdfnn+VpJgnX1 NUoYQhWNdH8OKVz06qHGPMp1Tow4ZrbDZJeFVYLhd33/dBm79a1GSeuDu1ZSiS3CmBsf K28Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdD6dLkV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k91-v6si3855284pld.27.2018.05.24.04.28.01; Thu, 24 May 2018 04:28:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdD6dLkV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967744AbeEXJvj (ORCPT + 99 others); Thu, 24 May 2018 05:51:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:47044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967719AbeEXJva (ORCPT ); Thu, 24 May 2018 05:51:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B784208A0; Thu, 24 May 2018 09:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155489; bh=myhGPWTSz6u05td+WJNW8yEPlqzH3nc56ja+MT5zxZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdD6dLkV9KGvOwKU0SmLpoxSQ63+ayqTYR68moM9ykLZPWHWfDusP7ENx5vAw6oIb vkmePzJu179g9XB1PRHIMxLZnELws9NeImsT7CyQxY6rkF8P37s8HqPemfsa3uK66B 7GnDh+hhJ4hKrjUEUE+BEvM8g+UepN1PXhtKfM+I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manish Rangankar , "Ewan D. Milne" , Tomas Henzl , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 59/96] scsi: qla4xxx: skip error recovery in case of register disconnect. Date: Thu, 24 May 2018 11:38:42 +0200 Message-Id: <20180524093608.857625124@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manish Rangankar [ Upstream commit 1bc5ad3a6acdcf56f83272f2de1cd2389ea9e9e2 ] A system crashes when continuously removing/re-adding the storage controller. Signed-off-by: Manish Rangankar Reviewed-by: Ewan D. Milne Reviewed-by: Tomas Henzl Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla4xxx/ql4_def.h | 2 + drivers/scsi/qla4xxx/ql4_os.c | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) --- a/drivers/scsi/qla4xxx/ql4_def.h +++ b/drivers/scsi/qla4xxx/ql4_def.h @@ -168,6 +168,8 @@ #define DEV_DB_NON_PERSISTENT 0 #define DEV_DB_PERSISTENT 1 +#define QL4_ISP_REG_DISCONNECT 0xffffffffU + #define COPY_ISID(dst_isid, src_isid) { \ int i, j; \ for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \ --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -262,6 +262,24 @@ static struct iscsi_transport qla4xxx_is static struct scsi_transport_template *qla4xxx_scsi_transport; +static int qla4xxx_isp_check_reg(struct scsi_qla_host *ha) +{ + u32 reg_val = 0; + int rval = QLA_SUCCESS; + + if (is_qla8022(ha)) + reg_val = readl(&ha->qla4_82xx_reg->host_status); + else if (is_qla8032(ha) || is_qla8042(ha)) + reg_val = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_ALIVE_COUNTER); + else + reg_val = readw(&ha->reg->ctrl_status); + + if (reg_val == QL4_ISP_REG_DISCONNECT) + rval = QLA_ERROR; + + return rval; +} + static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num, uint32_t iface_type, uint32_t payload_size, uint32_t pid, struct sockaddr *dst_addr) @@ -9196,10 +9214,17 @@ static int qla4xxx_eh_abort(struct scsi_ struct srb *srb = NULL; int ret = SUCCESS; int wait = 0; + int rval; ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", ha->host_no, id, lun, cmd, cmd->cmnd[0]); + rval = qla4xxx_isp_check_reg(ha); + if (rval != QLA_SUCCESS) { + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); + return FAILED; + } + spin_lock_irqsave(&ha->hardware_lock, flags); srb = (struct srb *) CMD_SP(cmd); if (!srb) { @@ -9251,6 +9276,7 @@ static int qla4xxx_eh_device_reset(struc struct scsi_qla_host *ha = to_qla_host(cmd->device->host); struct ddb_entry *ddb_entry = cmd->device->hostdata; int ret = FAILED, stat; + int rval; if (!ddb_entry) return ret; @@ -9270,6 +9296,12 @@ static int qla4xxx_eh_device_reset(struc cmd, jiffies, cmd->request->timeout / HZ, ha->dpc_flags, cmd->result, cmd->allowed)); + rval = qla4xxx_isp_check_reg(ha); + if (rval != QLA_SUCCESS) { + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); + return FAILED; + } + /* FIXME: wait for hba to go online */ stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); if (stat != QLA_SUCCESS) { @@ -9313,6 +9345,7 @@ static int qla4xxx_eh_target_reset(struc struct scsi_qla_host *ha = to_qla_host(cmd->device->host); struct ddb_entry *ddb_entry = cmd->device->hostdata; int stat, ret; + int rval; if (!ddb_entry) return FAILED; @@ -9330,6 +9363,12 @@ static int qla4xxx_eh_target_reset(struc ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, ha->dpc_flags, cmd->result, cmd->allowed)); + rval = qla4xxx_isp_check_reg(ha); + if (rval != QLA_SUCCESS) { + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); + return FAILED; + } + stat = qla4xxx_reset_target(ha, ddb_entry); if (stat != QLA_SUCCESS) { starget_printk(KERN_INFO, scsi_target(cmd->device), @@ -9384,9 +9423,16 @@ static int qla4xxx_eh_host_reset(struct { int return_status = FAILED; struct scsi_qla_host *ha; + int rval; ha = to_qla_host(cmd->device->host); + rval = qla4xxx_isp_check_reg(ha); + if (rval != QLA_SUCCESS) { + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); + return FAILED; + } + if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) qla4_83xx_set_idc_dontreset(ha);