From patchwork Tue Sep 8 09:56:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97D87618 for ; Tue, 8 Sep 2020 09:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A7A421D7F for ; Tue, 8 Sep 2020 09:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="i3QG/1Nf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729095AbgIHJ5y (ORCPT ); Tue, 8 Sep 2020 05:57:54 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:44820 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbgIHJ5x (ORCPT ); Tue, 8 Sep 2020 05:57:53 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889p2mQ008211; Tue, 8 Sep 2020 02:57:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=FkhiKUErK7yQSMGTzeorgJ2U9rEJ7JaxU0gwXMkv+Jo=; b=i3QG/1NfzSa43T7Y/uGZTW1zlYJcHcx8Wvo4PGH9s1HxZI1F6A/yEvnxtQ1Q65K5QGkX 8GUJzRMOYAS+p7Bskg/AQ3XJk+zY7rJSRy822RXQSc8Xs4X5NvgG0pN2wXEOAyypaNbz muiib2BSQ3gcbpgOoPOJgXWSHIXEtLkKXb3wPIp5+7T/gfJSlQPRGNxsV9YusUEP9nQ2 BTsEuBY8hNyN9HJUqublmi61xiMIJvfBVkqLmlXerUnbHNe1YqWlHQ96cZGEkFdePzBc 4oVo6DISF26aJdCJHKLr53Kuhc94Ql/xx3u1llljYX/OFfPNWmddvYXlIOu30r16RmiI UA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 33ccvr1ts5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:57:48 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:57:47 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:57:46 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:57:46 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 013563F703F; Tue, 8 Sep 2020 02:57:45 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889vjqo026868; Tue, 8 Sep 2020 02:57:45 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889vjwD026867; Tue, 8 Sep 2020 02:57:45 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 1/8] qedi: Use qed count from set_fp_int in msix allocation. Date: Tue, 8 Sep 2020 02:56:50 -0700 Message-ID: <20200908095657.26821-2-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To avoid unnecessary vector allocation when number of fast-path queues are less then available msix vectors, use return count from module qed->set_fp_int. Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi.h | 1 + drivers/scsi/qedi/qedi_main.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index 9498279ae80d..9c19ec9dc682 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h @@ -305,6 +305,7 @@ struct qedi_ctx { u32 max_sqes; u8 num_queues; u32 max_active_conns; + s32 msix_count; struct iscsi_cid_queue cid_que; struct qedi_endpoint **ep_tbl; diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 6f038ae5efca..e1ec22d7d699 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -1357,7 +1357,7 @@ static int qedi_request_msix_irq(struct qedi_ctx *qedi) u16 idx; cpu = cpumask_first(cpu_online_mask); - for (i = 0; i < qedi->int_info.msix_cnt; i++) { + for (i = 0; i < qedi->msix_count; i++) { idx = i * qedi->dev_info.common.num_hwfns + qedi_ops->common->get_affin_hwfn_idx(qedi->cdev); @@ -1387,7 +1387,12 @@ static int qedi_setup_int(struct qedi_ctx *qedi) { int rc = 0; - rc = qedi_ops->common->set_fp_int(qedi->cdev, num_online_cpus()); + rc = qedi_ops->common->set_fp_int(qedi->cdev, qedi->num_queues); + if (rc < 0) + goto exit_setup_int; + + qedi->msix_count = rc; + rc = qedi_ops->common->get_fp_int(qedi->cdev, &qedi->int_info); if (rc) goto exit_setup_int; From patchwork Tue Sep 8 09:56:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01081138E for ; Tue, 8 Sep 2020 09:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9A7921D7D for ; Tue, 8 Sep 2020 09:58:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="X1Ljs9YI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729104AbgIHJ6S (ORCPT ); Tue, 8 Sep 2020 05:58:18 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:11382 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbgIHJ6R (ORCPT ); Tue, 8 Sep 2020 05:58:17 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889pkPU008557; Tue, 8 Sep 2020 02:58:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=1FIfgwwoNtRaRjziQSLwLNXfEdybeX9/ml/J471buis=; b=X1Ljs9YIDd3Df+FO38d6T96Qv+6hCbRbN1tTm7i3dO+iLuQ9VJsI5/Sy1r5iYNYGL2/y uTXks/TuIFCZaFQtZXmQQDkH3TcdPmS342/z3sIVf/9bkKDua3F21gJwwvNpClKrDg4k OFSlXMsIr4Lmz1bPT3NbGksjpHRxfRd8YUexx798I2UWQ4vKekH7EqlNZ3TNbej4pOgq aj4o4awwIMqzoRixbJFQYMFMQfKFRNQDFxJ/2IHPYFidQCun9mUkax4T7KB39YaWuSQ/ CfgqWCIeipb2vXR6MHMZUfDRBoFfUxTm4WcjZHi4VXlr+uQkiYmW3v8hzTtlGmC/khou uw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 33ccvr1tt0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:58:12 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:58:11 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:58:10 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:58:10 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 208FA3F703F; Tue, 8 Sep 2020 02:58:10 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889w9Dm026880; Tue, 8 Sep 2020 02:58:09 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889w91j026871; Tue, 8 Sep 2020 02:58:09 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 2/8] qedi: Skip f/w connection termination for pci shutdown handler. Date: Tue, 8 Sep 2020 02:56:51 -0700 Message-ID: <20200908095657.26821-3-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In boot from san scenario when qedi pci shutdown handler is called with active iSCSI sessions, sometimes target takes too long time to respond to f/w connection termination request. Instead skip sending termination ramrod and progress with unload path. Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index c14ac7882afa..f815845fc568 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -1069,6 +1069,10 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep) wait_delay += qedi->pf_params.iscsi_pf_params.two_msl_timer; qedi_ep->state = EP_STATE_DISCONN_START; + + if (test_bit(QEDI_IN_SHUTDOWN, &qedi->flags)) + goto ep_release_conn; + ret = qedi_ops->destroy_conn(qedi->cdev, qedi_ep->handle, abrt_conn); if (ret) { QEDI_WARN(&qedi->dbg_ctx, From patchwork Tue Sep 8 09:56:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F185C618 for ; Tue, 8 Sep 2020 09:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D789A21D7D for ; Tue, 8 Sep 2020 09:58:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Vo9bsoyy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbgIHJ6o (ORCPT ); Tue, 8 Sep 2020 05:58:44 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:12940 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728828AbgIHJ6l (ORCPT ); Tue, 8 Sep 2020 05:58:41 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889pNUG002614; Tue, 8 Sep 2020 02:58:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=YEpPZMPUwjCQEOiS7LdbJoPf6GPTRDhC0REuNSK83IE=; b=Vo9bsoyy3aJWflUeOPr/7OS/muweETYDHusFtlak+3LqcFNxG19wR0FZtoiWFApsCzQ4 L0G05mmYUncSch2G8Hk93bjNW6cBH/ybWzRJuNnIVvw3lSiRFzGkwEAs8S0EvPf/3Jp7 iGLUElLoTXzq/hIF2xy9qmBF6gHqpna0bmIHeqrDCd4JInHeXYlfzuSU8dRkIEg3WTLx EMB9Joretj3poBZDIJk+A8ewRQKr9Vb24fFZjMf1YeEOh92xFe7RLGUswW1M/uTQ2RFk Yby9yxkp/wlQeOeoNqdF3kqaOQQ2lAua5nP7DEALXhpc8olUNxdNWY1AUVTgG+p6rEFX BA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 33c81pu0sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:58:36 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:58:35 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:58:34 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:58:34 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 40F173F703F; Tue, 8 Sep 2020 02:58:34 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889wYKF026884; Tue, 8 Sep 2020 02:58:34 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889wYKK026883; Tue, 8 Sep 2020 02:58:34 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 3/8] qedi: Fix list_del corruption while removing active IO Date: Tue, 8 Sep 2020 02:56:52 -0700 Message-ID: <20200908095657.26821-4-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Nilesh Javali While aborting the IO, the FW cleanup task timed out and driver deleted the IO from active command list. Some time later, the FW sends the cleanup task response and driver again deletes the IO from active command list causing FW to send IO completion for non-existent IO and list_del corruption of active command list. Add fix to check if IO is present before deleting the i/o from active command list ensuring FW sends valid i/o completion and protect the list_del corruption. Signed-off-by: Nilesh Javali Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_fw.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 6ed74583b1b9..34c477bda8a4 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -816,8 +816,11 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, qedi_clear_task_idx(qedi_conn->qedi, rtid); spin_lock(&qedi_conn->list_lock); - list_del_init(&dbg_cmd->io_cmd); - qedi_conn->active_cmd_count--; + if (likely(dbg_cmd->io_cmd_in_list)) { + dbg_cmd->io_cmd_in_list = false; + list_del_init(&dbg_cmd->io_cmd); + qedi_conn->active_cmd_count--; + } spin_unlock(&qedi_conn->list_lock); qedi_cmd->state = CLEANUP_RECV; wake_up_interruptible(&qedi_conn->wait_queue); @@ -1235,6 +1238,7 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, qedi_conn->cmd_cleanup_req++; qedi_iscsi_cleanup_task(ctask, true); + cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; QEDI_WARN(&qedi->dbg_ctx, @@ -1446,8 +1450,11 @@ static void qedi_tmf_work(struct work_struct *work) spin_unlock_bh(&qedi_conn->tmf_work_lock); spin_lock(&qedi_conn->list_lock); - list_del_init(&cmd->io_cmd); - qedi_conn->active_cmd_count--; + if (likely(cmd->io_cmd_in_list)) { + cmd->io_cmd_in_list = false; + list_del_init(&cmd->io_cmd); + qedi_conn->active_cmd_count--; + } spin_unlock(&qedi_conn->list_lock); clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); From patchwork Tue Sep 8 09:56:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED096138E for ; Tue, 8 Sep 2020 09:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0B4021D7D for ; Tue, 8 Sep 2020 09:59:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="g2YP1S8s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbgIHJ7E (ORCPT ); Tue, 8 Sep 2020 05:59:04 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:52324 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728828AbgIHJ7E (ORCPT ); Tue, 8 Sep 2020 05:59:04 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889p6Rl002554; Tue, 8 Sep 2020 02:58:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=g7EJ0ES+qzVmtE56onOJLs0Go+C/M6IL3HMq7BqnnlM=; b=g2YP1S8sw7deX+woONcvAumfj2REZP7FKZr+LJqbJn6UQs0B4xdnAKRTYDthroSHFyAt ZuqVOw515FRlOpVSnW8FA24fmUAz5JBKU11kncB+4UqUTaHul1+5vqgGfbyRXUh7hOIm lc1Eir8Es+rixRhV7gVduF6HaDZ8Sa1R7XWFwthCJqW4nJE0wnqiJHemBfZb2+Oj1h/k OzmWE1SJXYCeYej/BWFqvM3TyHndeiAtKZfiNAjarmAUYQmQYdKjpbzhmAFc27aw8Lr3 2uvsj+vRyzwz06f7xiBiXPRsMnE/c9IMHEPfGEnkYJDyyjfhEEJqLNfh2WQAJJvxL/bk kQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 33c81pu0tf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:58:59 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:58:58 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:58:58 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 666EF3F703F; Tue, 8 Sep 2020 02:58:58 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889wwip026888; Tue, 8 Sep 2020 02:58:58 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889wweR026887; Tue, 8 Sep 2020 02:58:58 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 4/8] qedi: Protect active command list to avoid list corruption Date: Tue, 8 Sep 2020 02:56:53 -0700 Message-ID: <20200908095657.26821-5-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Nilesh Javali Protect active command list for non i/o commands like, login response, logout response, text response and recovery cleanup of active list to avoid list corruption. Signed-off-by: Nilesh Javali Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_fw.c | 8 ++++++++ drivers/scsi/qedi/qedi_iscsi.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 34c477bda8a4..f158fde0a43c 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -59,6 +59,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -69,6 +70,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } + spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); @@ -122,6 +124,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -132,6 +135,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } + spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); @@ -222,11 +226,13 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, tmf_hdr = (struct iscsi_tm *)qedi_cmd->task->hdr; + spin_lock(&qedi_conn->list_lock); if (likely(qedi_cmd->io_cmd_in_list)) { qedi_cmd->io_cmd_in_list = false; list_del_init(&qedi_cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || @@ -288,11 +294,13 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK; qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len; + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); memset(task_ctx, '\0', sizeof(*task_ctx)); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index f815845fc568..ae86a40ca040 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -975,11 +975,13 @@ static void qedi_cleanup_active_cmd_list(struct qedi_conn *qedi_conn) { struct qedi_cmd *cmd, *cmd_tmp; + spin_lock(&qedi_conn->list_lock); list_for_each_entry_safe(cmd, cmd_tmp, &qedi_conn->active_cmd_list, io_cmd) { list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); } static void qedi_ep_disconnect(struct iscsi_endpoint *ep) From patchwork Tue Sep 8 09:56:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32B4E618 for ; Tue, 8 Sep 2020 09:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 107BE21D7D for ; Tue, 8 Sep 2020 09:59:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="CJXG3RQl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728966AbgIHJ7b (ORCPT ); Tue, 8 Sep 2020 05:59:31 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:28466 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728828AbgIHJ73 (ORCPT ); Tue, 8 Sep 2020 05:59:29 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889p33v008228; Tue, 8 Sep 2020 02:59:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=bmDvC3ZNx55Y+wPxvBwkaE98rDbLuoSaGr6pb30JTdU=; b=CJXG3RQltdDlCvcRv58ETZIrDpRtWbtIcQg6GmKg3GtjwcmcQPbMnL8b52E52nEfpouP VpRPCG/ZRaVg2CEHGo37gIg4uLJBUCXzKBqhZEd2QgTvkM9ubOfuNtT/GnLb7axXmNFE jRaxjXIoQYVfdQUC8uC2W5Rk5L3k16+TqrTggqkguX7+Vsq2t1QFdyKqRJQsd2SeWGly 36Ne7ySGZSRRxzMFNRNlaQ9EgkQ7ZAP32ffRa3lJAE/jM94ly/4bZ2fGmM0UkWCYHSRP +cPvfCogRiEqs8fvS7BWkkbXDmc65UhE9Qiuj1msZ2vpRZVNCLBRqAtPi8bnu+4m17EI 5Q== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 33ccvr1tw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:59:24 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:59:23 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:59:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:59:22 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 83ED63F703F; Tue, 8 Sep 2020 02:59:22 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889xM4o026900; Tue, 8 Sep 2020 02:59:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889xMPg026891; Tue, 8 Sep 2020 02:59:22 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 5/8] qedi: Use snprintf instead of sprintf Date: Tue, 8 Sep 2020 02:56:54 -0700 Message-ID: <20200908095657.26821-6-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use snprintf to limit max number of bytes to the buffer. Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index e1ec22d7d699..2db99613b8a9 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -2538,7 +2538,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_DISC, "MAC address is %pM.\n", qedi->mac); - sprintf(host_buf, "host_%d", qedi->shost->host_no); + snprintf(host_buf, sizeof(host_buf), "host_%d", qedi->shost->host_no); qedi_ops->common->set_name(qedi->cdev, host_buf); qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi); From patchwork Tue Sep 8 09:56:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4A92618 for ; Tue, 8 Sep 2020 09:59:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9ECF21D7A for ; Tue, 8 Sep 2020 09:59:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="EiCqmxJu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgIHJ7z (ORCPT ); Tue, 8 Sep 2020 05:59:55 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:39692 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728886AbgIHJ7x (ORCPT ); Tue, 8 Sep 2020 05:59:53 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889ptTt002766; Tue, 8 Sep 2020 02:59:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=zDviW05fqJeHHUhQzDHiw0QT8l1FpHJPqkIHBDOEOZk=; b=EiCqmxJux436EsEVNo3s8j9f+h1QkInl5P6qNVWgyFEVHr0lfVOYCGKWLrwflENqPThp cPUj62oc+mUXyD+AStDiltMB0MM56awlGB4LB/97MhDx1WPssktKU8G6UwLJmtlUkLMh UowLrVrmAMYKPiQUXEjYILSTTRzh5hcuhyXUezw1yEfI0uY7yuuJ13Msbi5pp+PK88N2 RNPn7Fp0K4IboO4e7kEykkQulTP51IygO6+esNKelr/VEwlzjD+bRZZaxJV13TvduYA4 4EvuqSqHHVXamz9Rq1Y4voWujew+8xcGKsVZdXWsjYH8dDhhjNmHsRrr4AbIYHzJBKdh fQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 33c81pu0w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 02:59:48 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:59:48 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 02:59:46 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 02:59:46 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id A93E73F703F; Tue, 8 Sep 2020 02:59:46 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 0889xk61026904; Tue, 8 Sep 2020 02:59:46 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 0889xksP026903; Tue, 8 Sep 2020 02:59:46 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 6/8] qedi: Mark all connections for recovery on link down event Date: Tue, 8 Sep 2020 02:56:55 -0700 Message-ID: <20200908095657.26821-7-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Nilesh Javali For short time cable pulls, the in-flight i/o to the FW, is never cleaned up, resulting in the behaviour of stale i/o completion causing list_del corruption and soft lockup of the system. So, on link down event, mark all the connections for recovery, causing cleanup of all the in-flight i/o immediately. Signed-off-by: Nilesh Javali Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 2db99613b8a9..4f43e2a24b50 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -1127,6 +1127,15 @@ static void qedi_schedule_recovery_handler(void *dev) schedule_delayed_work(&qedi->recovery_work, 0); } +static void qedi_set_conn_recovery(struct iscsi_cls_session *cls_session) +{ + struct iscsi_session *session = cls_session->dd_data; + struct iscsi_conn *conn = session->leadconn; + struct qedi_conn *qedi_conn = conn->dd_data; + + qedi_start_conn_recovery(qedi_conn->qedi, qedi_conn); +} + static void qedi_link_update(void *dev, struct qed_link_output *link) { struct qedi_ctx *qedi = (struct qedi_ctx *)dev; @@ -1138,6 +1147,7 @@ static void qedi_link_update(void *dev, struct qed_link_output *link) QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, "Link Down event.\n"); atomic_set(&qedi->link_state, QEDI_LINK_DOWN); + iscsi_host_for_each_session(qedi->shost, qedi_set_conn_recovery); } } From patchwork Tue Sep 8 09:56:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F1A5112E for ; Tue, 8 Sep 2020 10:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0255421D7D for ; Tue, 8 Sep 2020 10:00:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="DyGqOI3V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728886AbgIHKAS (ORCPT ); Tue, 8 Sep 2020 06:00:18 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:53674 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbgIHKAR (ORCPT ); Tue, 8 Sep 2020 06:00:17 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889p2mU008211; Tue, 8 Sep 2020 03:00:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=KoE1uDJ48/5weSi6HQ8Fdmdj+4q04HfDtqgF71ZB+/M=; b=DyGqOI3VbAWpjK90t3/r2c5VbTZ/mcYsBQEopLfg5V22SxlNUAP7eJ4fw3BuXCD6LaG4 EVd0nuCRTwY9QyjMSxKdzAnObbDKL4r/jSAxGEXIQlMtrmX6P5+DnXQS9+NsS/G+08m0 lePX6hVIz/WunyVAOEw6DuqZsav1W8Nu/8xQ96DWoT6ECPajue5gil4nBfq3wVk7oX9h ZKPGx1SEAJy6a7iHBr5bUNlvvoF8Yubsmb08+/P+IxDyG82Qq69bypcI5xPUnxlFG0Ac K+yK5cG8OPxu3RYzHRROezJeV3hLMu6TR0rqy5y5D5b0m+ulh4W4rA3iRoc7525L14V6 4A== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 33ccvr1txx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 03:00:12 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 03:00:10 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 03:00:10 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id D4F7D3F704A; Tue, 8 Sep 2020 03:00:10 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 088A0AgE026970; Tue, 8 Sep 2020 03:00:10 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 088A0AgJ026907; Tue, 8 Sep 2020 03:00:10 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 7/8] qedi: Add firmware error recovery invocation support. Date: Tue, 8 Sep 2020 02:56:56 -0700 Message-ID: <20200908095657.26821-8-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add support to initiate MFW process recovery for all the devices if storage function receive the event first. Also added fix for kernel test robot warning, >> drivers/scsi/qedi/qedi_main.c:1119:6: warning: no previous prototype >> for 'qedi_schedule_hw_err_handler' [-Wmissing-prototypes] Reported-by: kernel test robot Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi.h | 4 +++ drivers/scsi/qedi/qedi_fw.c | 7 ++-- drivers/scsi/qedi/qedi_iscsi.c | 3 +- drivers/scsi/qedi/qedi_main.c | 63 +++++++++++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index 9c19ec9dc682..7e59d50f2fab 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h @@ -274,6 +274,10 @@ struct qedi_ctx { spinlock_t ll2_lock; /* Light L2 lock */ spinlock_t hba_lock; /* per port lock */ struct task_struct *ll2_recv_thread; + unsigned long qedi_err_flags; +#define QEDI_ERR_ATTN_CLR_EN 0 +#define QEDI_ERR_IS_RECOVERABLE 2 +#define QEDI_ERR_OVERRIDE_EN 31 unsigned long flags; #define UIO_DEV_OPENED 1 #define QEDI_IOTHREAD_WAKE 2 diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index f158fde0a43c..440ddd2309f1 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -1267,7 +1267,8 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, rval = wait_event_interruptible_timeout(qedi_conn->wait_queue, ((qedi_conn->cmd_cleanup_req == qedi_conn->cmd_cleanup_cmpl) || - qedi_conn->ep), + test_bit(QEDI_IN_RECOVERY, + &qedi->flags)), 5 * HZ); if (rval) { QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, @@ -1292,7 +1293,9 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, /* Enable IOs for all other sessions except current.*/ if (!wait_event_interruptible_timeout(qedi_conn->wait_queue, (qedi_conn->cmd_cleanup_req == - qedi_conn->cmd_cleanup_cmpl), + qedi_conn->cmd_cleanup_cmpl) || + test_bit(QEDI_IN_RECOVERY, + &qedi->flags), 5 * HZ)) { iscsi_host_for_each_session(qedi->shost, qedi_mark_device_available); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index ae86a40ca040..08c05403cd72 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -1072,7 +1072,8 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep) qedi_ep->state = EP_STATE_DISCONN_START; - if (test_bit(QEDI_IN_SHUTDOWN, &qedi->flags)) + if (test_bit(QEDI_IN_SHUTDOWN, &qedi->flags) || + test_bit(QEDI_IN_RECOVERY, &qedi->flags)) goto ep_release_conn; ret = qedi_ops->destroy_conn(qedi->cdev, qedi_ep->handle, abrt_conn); diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 4f43e2a24b50..1d8c78c41405 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -50,6 +50,10 @@ module_param(qedi_ll2_buf_size, uint, 0644); MODULE_PARM_DESC(qedi_ll2_buf_size, "parameter to set ping packet size, default - 0x400, Jumbo packets - 0x2400."); +static uint qedi_flags_override; +module_param(qedi_flags_override, uint, 0644); +MODULE_PARM_DESC(qedi_flags_override, "Disable/Enable MFW error flags bits action."); + const struct qed_iscsi_ops *qedi_ops; static struct scsi_transport_template *qedi_scsi_transport; static struct pci_driver qedi_pci_driver; @@ -63,6 +67,8 @@ static void qedi_reset_uio_rings(struct qedi_uio_dev *udev); static void qedi_ll2_free_skbs(struct qedi_ctx *qedi); static struct nvm_iscsi_block *qedi_get_nvram_block(struct qedi_ctx *qedi); static void qedi_recovery_handler(struct work_struct *work); +static void qedi_schedule_hw_err_handler(void *dev, + enum qed_hw_err_type err_type); static int qedi_iscsi_event_cb(void *context, u8 fw_event_code, void *fw_handle) { @@ -1113,6 +1119,39 @@ static void qedi_get_protocol_tlv_data(void *dev, void *data) return; } +void qedi_schedule_hw_err_handler(void *dev, + enum qed_hw_err_type err_type) +{ + struct qedi_ctx *qedi = (struct qedi_ctx *)dev; + unsigned long override_flags = qedi_flags_override; + + if (override_flags && test_bit(QEDI_ERR_OVERRIDE_EN, &override_flags)) + qedi->qedi_err_flags = qedi_flags_override; + + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, + "HW error handler scheduled, err=%d err_flags=0x%x\n", + err_type, qedi->qedi_err_flags); + + switch (err_type) { + case QED_HW_ERR_MFW_RESP_FAIL: + case QED_HW_ERR_HW_ATTN: + case QED_HW_ERR_DMAE_FAIL: + case QED_HW_ERR_RAMROD_FAIL: + case QED_HW_ERR_FW_ASSERT: + /* Prevent HW attentions from being reasserted */ + if (test_bit(QEDI_ERR_ATTN_CLR_EN, &qedi->qedi_err_flags)) + qedi_ops->common->attn_clr_enable(qedi->cdev, true); + + if (err_type == QED_HW_ERR_RAMROD_FAIL && + test_bit(QEDI_ERR_IS_RECOVERABLE, &qedi->qedi_err_flags)) + qedi_ops->common->recovery_process(qedi->cdev); + + break; + default: + break; + } +} + static void qedi_schedule_recovery_handler(void *dev) { struct qedi_ctx *qedi = dev; @@ -1155,6 +1194,7 @@ static struct qed_iscsi_cb_ops qedi_cb_ops = { { .link_update = qedi_link_update, .schedule_recovery_handler = qedi_schedule_recovery_handler, + .schedule_hw_err_handler = qedi_schedule_hw_err_handler, .get_protocol_tlv_data = qedi_get_protocol_tlv_data, .get_generic_tlv_data = qedi_get_generic_tlv_data, } @@ -2355,6 +2395,7 @@ static void __qedi_remove(struct pci_dev *pdev, int mode) { struct qedi_ctx *qedi = pci_get_drvdata(pdev); int rval; + u16 retry = 10; if (mode == QEDI_MODE_SHUTDOWN) iscsi_host_for_each_session(qedi->shost, @@ -2383,7 +2424,13 @@ static void __qedi_remove(struct pci_dev *pdev, int mode) qedi_sync_free_irqs(qedi); if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) { - qedi_ops->stop(qedi->cdev); + while (retry--) { + rval = qedi_ops->stop(qedi->cdev); + if (rval < 0) + msleep(1000); + else + break; + } qedi_ops->ll2->stop(qedi->cdev); } @@ -2442,6 +2489,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) struct qed_probe_params qed_params; void *task_start, *task_end; int rc; + u16 retry = 10; if (mode != QEDI_MODE_RECOVERY) { qedi = qedi_host_alloc(pdev); @@ -2453,6 +2501,10 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) qedi = pci_get_drvdata(pdev); } +retry_probe: + if (mode == QEDI_MODE_RECOVERY) + msleep(2000); + memset(&qed_params, 0, sizeof(qed_params)); qed_params.protocol = QED_PROTOCOL_ISCSI; qed_params.dp_module = qedi_qed_debug; @@ -2460,11 +2512,20 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) qed_params.is_vf = is_vf; qedi->cdev = qedi_ops->common->probe(pdev, &qed_params); if (!qedi->cdev) { + if (mode == QEDI_MODE_RECOVERY && retry) { + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, + "Retry %d initialize hardware\n", retry); + retry--; + goto retry_probe; + } + rc = -ENODEV; QEDI_ERR(&qedi->dbg_ctx, "Cannot initialize hardware\n"); goto free_host; } + set_bit(QEDI_ERR_ATTN_CLR_EN, &qedi->qedi_err_flags); + set_bit(QEDI_ERR_IS_RECOVERABLE, &qedi->qedi_err_flags); atomic_set(&qedi->link_state, QEDI_LINK_DOWN); rc = qedi_ops->fill_dev_info(qedi->cdev, &qedi->dev_info); From patchwork Tue Sep 8 09:56:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Rangankar X-Patchwork-Id: 11763089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F46D112E for ; Tue, 8 Sep 2020 10:00:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0344E2078B for ; Tue, 8 Sep 2020 10:00:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="hANdLF3v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729062AbgIHKAm (ORCPT ); Tue, 8 Sep 2020 06:00:42 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:10202 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728886AbgIHKAl (ORCPT ); Tue, 8 Sep 2020 06:00:41 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0889p34B008228; Tue, 8 Sep 2020 03:00:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=aEijHRsmmwJsAZsrWG4VjzlKbgsCu7a85H3abWX+6ZU=; b=hANdLF3vX9wLbTi4rWHrKKYxY4bD/xcQbQzp/e4+hrSCq1K5YI62hBmAczsFxRA35ing QTLwocCzMX3zFH00In6eOMaKNt8OjqxXZmfEMcg5CXxiu8KI+H7RV8dhQfY8FFEkzlvT 9uu1THmkRCvxd7VOv5sqsaKSYxavdjBG5juNkIymwxaRJIvbV15WM2bSSwPFNtihxDGg Fxjic4uqh2T2a8OySFsrI8rccsIptAPnV2lE4UK/2jJAi4LZSr6qnCJgphi0XQzl5mKp xXgz0+NiPUy42+KgwgLX+SubbXdKrcAdM8+bbmUsbtZAgVtlBHKSjmocJ3ztWODAc105 WQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 33ccvr1u0f-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 08 Sep 2020 03:00:35 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 03:00:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 03:00:35 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id F3FA63F7044; Tue, 8 Sep 2020 03:00:34 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 088A0YJG026974; Tue, 8 Sep 2020 03:00:34 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 088A0YUV026973; Tue, 8 Sep 2020 03:00:34 -0700 From: Manish Rangankar To: , , CC: , Subject: [PATCH v2 8/8] qedi: Add support for handling the pcie errors. Date: Tue, 8 Sep 2020 02:56:57 -0700 Message-ID: <20200908095657.26821-9-mrangankar@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200908095657.26821-1-mrangankar@marvell.com> References: <20200908095657.26821-1-mrangankar@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-08_05:2020-09-08,2020-09-08 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The error recovery is handled by management firmware (MFW) with the help of qed/qedi drivers. Upon detecting the errors, driver informs MFW about this event which in turn starts a recovery process. MFW sends ERROR_RECOVERY notification to the driver which performs the required cleanup/recovery from the driver side. Signed-off-by: Manish Rangankar --- drivers/scsi/qedi/qedi_main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 1d8c78c41405..10a7ee055552 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -2391,6 +2391,25 @@ static int qedi_setup_boot_info(struct qedi_ctx *qedi) return -ENOMEM; } +static pci_ers_result_t qedi_io_error_detected(struct pci_dev *pdev, + pci_channel_state_t state) +{ + struct qedi_ctx *qedi = pci_get_drvdata(pdev); + + QEDI_ERR(&qedi->dbg_ctx, "%s: PCI error detected [%d]\n", + __func__, state); + + if (test_and_set_bit(QEDI_IN_RECOVERY, &qedi->flags)) { + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, + "Recovery already in progress.\n"); + return PCI_ERS_RESULT_NONE; + } + + qedi_ops->common->recovery_process(qedi->cdev); + + return PCI_ERS_RESULT_CAN_RECOVER; +} + static void __qedi_remove(struct pci_dev *pdev, int mode) { struct qedi_ctx *qedi = pci_get_drvdata(pdev); @@ -2820,12 +2839,17 @@ MODULE_DEVICE_TABLE(pci, qedi_pci_tbl); static enum cpuhp_state qedi_cpuhp_state; +static struct pci_error_handlers qedi_err_handler = { + .error_detected = qedi_io_error_detected, +}; + static struct pci_driver qedi_pci_driver = { .name = QEDI_MODULE_NAME, .id_table = qedi_pci_tbl, .probe = qedi_probe, .remove = qedi_remove, .shutdown = qedi_shutdown, + .err_handler = &qedi_err_handler, }; static int __init qedi_init(void)