From patchwork Mon Dec 4 22:45:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10091731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B713600C5 for ; Mon, 4 Dec 2017 22:46:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F14A029387 for ; Mon, 4 Dec 2017 22:46:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E62DA29446; Mon, 4 Dec 2017 22:46:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C4ED29387 for ; Mon, 4 Dec 2017 22:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751598AbdLDWqV (ORCPT ); Mon, 4 Dec 2017 17:46:21 -0500 Received: from mail-bl2nam02on0040.outbound.protection.outlook.com ([104.47.38.40]:41602 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752149AbdLDWqH (ORCPT ); Mon, 4 Dec 2017 17:46:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=97m+xro9Xo/nLgOkvy7zk6oOGI5HJ9Po8ArkB52Jpnc=; b=Mev7hCvsgQxYR30NgAeF+1Kv7pHsMT7PrSMhft7q5xlPyWS4fFEwcuXPTCCnaCYjb4wqfYyNZ3xuoak0ZwI+DmLFOKenWbuzBzPWzTqOusGAQ838vsFI8s5VqFHhmw/AZRgty6puMYUTscc5mFCsG5RLnkazrzGeABZTiGHvs6k= Received: from CY1PR07CA0027.namprd07.prod.outlook.com (10.166.202.37) by BY2PR0701MB1943.namprd07.prod.outlook.com (10.163.155.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Mon, 4 Dec 2017 22:46:05 +0000 Received: from BL2FFO11FD028.protection.gbl (2a01:111:f400:7c09::116) by CY1PR07CA0027.outlook.office365.com (2a01:111:e400:c60a::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.282.5 via Frontend Transport; Mon, 4 Dec 2017 22:46:05 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BL2FFO11FD028.mail.protection.outlook.com (10.173.161.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.239.4 via Frontend Transport; Mon, 4 Dec 2017 22:46:04 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Mon, 4 Dec 2017 14:45:22 -0800 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 vB4MjM5L003529; Mon, 4 Dec 2017 14:45:22 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vB4MjMZn003528; Mon, 4 Dec 2017 14:45:22 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 21/22] qla2xxx: Fix memory leak in dual/target mode Date: Mon, 4 Dec 2017 14:45:16 -0800 Message-ID: <20171204224517.3409-22-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171204224517.3409-1-himanshu.madhani@cavium.com> References: <20171204224517.3409-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(2980300002)(428002)(199003)(189002)(36756003)(6666003)(87636003)(4326008)(316002)(105586002)(33646002)(106466001)(189998001)(54906003)(478600001)(42186006)(101416001)(1076002)(47776003)(16586007)(2906002)(110136005)(72206003)(5660300001)(69596002)(356003)(81166006)(80596001)(50226002)(8676002)(81156014)(51416003)(305945005)(2950100002)(48376002)(50466002)(86362001)(8936002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB1943; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD028; 1:zqTpSkr8m84z+qlbxj161ZtxrzaeVx7ZkxGxeEowEOXc4yC6Neccvsd+nIrJyeVDLvN92lpI7r3gE6uWSGJcDuBVJn7aln5xv2pMLNw/fnCMEcWwIIR4ximRG0/gsHwK X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d8d0721-a900-4837-c7f6-08d53b68cd53 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603286); SRVR:BY2PR0701MB1943; X-Microsoft-Exchange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n+VMWd4pzv3uDiCWTeYq3aSv6koLWFTdci/3maPkLYne3sbi8U8D8ImHPFaEpLGZyL/YnpeCWYQ1JD6KcSyk6dkluGMZyGY8QxYnrXBYVqyt9FtlSWrX/zPT2M4MdUc/cdtNaXHjpS9rAF8sPZBx95H4jD1/6+CfJEAHbVpC0ijWi5XbBdu2BYaYeiGo3fSnaftRfmRGoicEIDLyT/y62R/eCXNCkwGFBWO9k2arbp2JUDdJfctqqAhKZdxsuh0h3QrAxjaOnVE8yWER5T7GW/jXyveoBN/1yMAeQIEIUcAs3UVDkbipKnoRGDYrfEQFu19IEG0bYAhh/CtZTKuIeH6XR2kRy1oM1HeOj7FpGFR6caWcvnogPnUPvo3SY16duES9Khy1JG/7cnoLa2fXZIAXSV2kid0olezN0rVjpDVk+fUF7t9t29j/1szZZ4sHdvC4ywY9RpllmTE+pRR0OMzGqsdl2Q9tNexcohVv8iD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(3231022)(93006095)(93001095)(3002001)(6041248)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(6072148)(201708071742011); SRVR:BY2PR0701MB1943; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BY2PR0701MB1943; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1943; 4:kH4fdBCRht8mNl6WvVZU2vdJnuslkAIUttEqk8+llH609XUBHyXuMvTX7IenAxqlWRFM8qKw8RVvTBO6IvvVnuO7gOAAGzQz8LS3FO1BIo3ctep17+ZIZBEBMnrsQNnUxuzYwLliv6tTJe6ZDC+543BdQdVydLBs6Cnfi8aVKgeCHC05i9oTqsAxSa3Q6u02tNb9FmHs+w5JdiYalNA5+nEMc9xyIfj/C2Y3kl9qXNHzs8Clt456Cw4XVuNb7EX1p4NzceONDewJOCVP3GA4IIK3ob2QESiePQgDh08H0zVtjYoJhxsc5y289qXepV5L X-Forefront-PRVS: 051158ECBB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0701MB1943; 23:qUWVAjgiZPWkj2izO0hSdtVk5WOHiBPKxPKLsMA?= =?us-ascii?Q?dkUr3I0d/CbXAxJFEaaBp98zhzhfKGqbYXA6FKvGBXgiq0NFLy6szF9n+CV5?= =?us-ascii?Q?Ofxm/JlRSyODbH5CYFAtUVebRlBZg80HmHeyE4jr+LVjpUb2UuU0llXtjsMj?= =?us-ascii?Q?uToM72QJEM3Q4zSmX+FIcRcZFp1+5YBH8OJMS659RqmcZPSgQI/UkKhnJ4T7?= =?us-ascii?Q?p4tGRoBhFTLR7VZMDXyYv/DKxq3r4Ct3PUjEYuXpZRG+LJeZ2KBaOdf+kpMZ?= =?us-ascii?Q?JXMlWQh/Pj8wPH2Z0tOz7Ah/OAItTShi/jshcE1MxyIo6gngpcEDU+BP5R3E?= =?us-ascii?Q?rEKfbb9Gg2ShsnTYtfUmfwr3BPDIc/oezGZdUl7DmY4Fwb+9fiENigvF7s2x?= =?us-ascii?Q?vowanfshbbI/jgjoiBMT68xf980KPrAKZgtej46uwSlmHeTSIU1I2M+pk1RG?= =?us-ascii?Q?dBDGmM/8WzwiinAyb58FDrKhwYmW13INwEVeqmF2JttNV4z5YnPlA7f6UTKE?= =?us-ascii?Q?CEpiLGTDCbDBUOnrjbqP/2nylTJ51QgvJs91Tb+bM2JoQldl5MssGRN6ipRf?= =?us-ascii?Q?BZHMtrMXM3mOYIS6k3CTKperzhqITI/R964TMJoWI2LKVlgKNiDnD9bykMFL?= =?us-ascii?Q?fV7ZfXsuIwUTXZipcCBQoW5zcP/LUSL2iPYmWRat8MMujnG3hv1SiF0Vw3w+?= =?us-ascii?Q?IECSqSpOgYHcvvTTutRnEk7B2p3H8GthFTFxjJLdgnfABfy84jSmVCJY7sA1?= =?us-ascii?Q?9RrvWDIV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0lHyB7f2R1xfNb0oSMDr1NuaVqxs/lvwRGbmQyCA5bRpMVn9Oi9K1M3qgB2/5vZVa4CeLALhu1pYDqj8zmre0owij/vpjp+O2Ig2BfUIoYoJDd9p9nSrDgMl1G0oE0UHwGm0QUE/ekIs79Y5AkkfxhPn34rO2IhjqnYorECymy8df4O2M5hgxnIYkXF7c SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2017 22:46:04.6818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d8d0721-a900-4837-c7f6-08d53b68cd53 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB1943 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When driver is loaded in Target/Dual mode, it creates QPair to support MQ and allocates resources for each QPair. This Qpair initialization is delayed until the FW personality is changed to Dual/Target mode by issuing chip reset. At the time of chip reset firmware is re-initilized in correct personality all the QPairs are initialized by sending MBC_INITIALIZE_MULTIQ (001Fh). This patch fixes memory leak by adding check to issue MBC_INITIALIZE_MULTIQ command only while deleting rsp/req queue when the flag is set for initiator mode, and clean up QPair resources correctly during the driver unload. This MBX does not need to be issued for Target/Dual mode because chip reset will reset ISP. Fixes: d65237c7f0860 ("scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs") Cc: # 4.10+ Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke --- drivers/scsi/qla2xxx/qla_init.c | 4 +--- drivers/scsi/qla2xxx/qla_mid.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 57b8f43c5980..58663df38627 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8220,9 +8220,6 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) int ret = QLA_FUNCTION_FAILED; struct qla_hw_data *ha = qpair->hw; - if (!vha->flags.qpairs_req_created && !vha->flags.qpairs_rsp_created) - goto fail; - qpair->delete_in_progress = 1; while (atomic_read(&qpair->ref_count)) msleep(500); @@ -8230,6 +8227,7 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) ret = qla25xx_delete_req_que(vha, qpair->req); if (ret != QLA_SUCCESS) goto fail; + ret = qla25xx_delete_rsp_que(vha, qpair->rsp); if (ret != QLA_SUCCESS) goto fail; diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 618ca272d01a..e538e6308885 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -575,14 +575,15 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) int qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) { - int ret = -1; + int ret = QLA_SUCCESS; - if (req) { + if (req && vha->flags.qpairs_req_created) { req->options |= BIT_0; ret = qla25xx_init_req_que(vha, req); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_req_que(vha, req); + qla25xx_free_req_que(vha, req); return ret; } @@ -590,14 +591,15 @@ qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) int qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) { - int ret = -1; + int ret = QLA_SUCCESS; - if (rsp) { + if (rsp && vha->flags.qpairs_rsp_created) { rsp->options |= BIT_0; ret = qla25xx_init_rsp_que(vha, rsp); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_rsp_que(vha, rsp); + qla25xx_free_rsp_que(vha, rsp); return ret; }