From patchwork Fri Feb 3 22:40:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9555235 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 49478602B7 for ; Fri, 3 Feb 2017 22:42:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3239F27F9F for ; Fri, 3 Feb 2017 22:42:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 273032816B; Fri, 3 Feb 2017 22:42:12 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 B03F127F9F for ; Fri, 3 Feb 2017 22:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbdBCWmH (ORCPT ); Fri, 3 Feb 2017 17:42:07 -0500 Received: from mail-bn3nam01on0070.outbound.protection.outlook.com ([104.47.33.70]:58147 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753048AbdBCWmD (ORCPT ); Fri, 3 Feb 2017 17:42:03 -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=StAWna6nyIXhr5OkL1unMVH5oMVFbbwr/HBj5Ky4HN0=; b=ABW5p58YeLZuDw6DL5b7PhYrmY8Dest857STzZsIykF/TheSPD4VThNEeWyP1qO6rg3ddQEYWmNiPKeTivOZUc/XtJi2uJZuELb0BwB7uY6I1D6IxH5s3o2dYXvmQHpwBVr4izFEr/7/lPfjIYICqKnGg5jUoOhlbeLiU4H0zWA= Received: from DM2PR07CA0012.namprd07.prod.outlook.com (10.141.52.140) by CY1PR0701MB2090.namprd07.prod.outlook.com (10.163.142.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Fri, 3 Feb 2017 22:41:57 +0000 Received: from BN1BFFO11OLC001.protection.gbl (2a01:111:f400:7c10::1:180) by DM2PR07CA0012.outlook.office365.com (2a01:111:e400:2414::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Fri, 3 Feb 2017 22:41:57 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; linux-iscsi.org; dkim=none (message not signed) header.d=none; linux-iscsi.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 BN1BFFO11OLC001.mail.protection.outlook.com (10.58.145.12) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.888.7 via Frontend Transport; Fri, 3 Feb 2017 22:41:55 +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.309.2; Fri, 3 Feb 2017 14:41:25 -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 v13MfCZF002388; Fri, 3 Feb 2017 14:41:12 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v13MfC6M002387; Fri, 3 Feb 2017 14:41:12 -0800 From: Himanshu Madhani To: , , , CC: , , Subject: [PATCH v2 13/14] qla2xxx: Fix sess_lock & hardware_lock lock order problem. Date: Fri, 3 Feb 2017 14:40:54 -0800 Message-ID: <1486161655-2307-14-git-send-email-himanshu.madhani@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1486161655-2307-1-git-send-email-himanshu.madhani@cavium.com> References: <1486161655-2307-1-git-send-email-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)(7916002)(39450400003)(2980300002)(428002)(189002)(199003)(4001430100002)(8656002)(8936002)(92566002)(5660300001)(106466001)(5003940100001)(8676002)(81166006)(42186005)(626004)(50226002)(81156014)(33646002)(105586002)(54906002)(107886002)(47776003)(1691005)(50466002)(356003)(305945005)(2201001)(36756003)(6666003)(4326007)(38730400001)(50986999)(4720700003)(48376002)(76176999)(2950100002)(189998001)(86362001)(5001770100001)(2906002)(69596002)(80596001)(101416001)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB2090; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11OLC001; 1:v5gV8bjKn7lWnu8C8J148HrMb9cTqr3jlP+RXodaewUR7TJqesnTUD5Jrj/yTe9pMZ9majPtEUykrQ2r0E+sC4ZgY3wduMyBGxLMRgDvhF0h5lnjCN8JM5B3RiZhPi9/3Lf4ixgbiV5d6o2sPbC1GK7svMoRBcwG/6zbQrxrAQ4jml4C5OM6etpbeXW3D/n8SZAYqYTMgFNtFqwd6UM13xDrw+Gw6qUgmuOCeztKUBrWbYjmsF0vkSWahYCnwzM3MGK1YiI/seNzQY7zk/SU78/krOJpLzfVo6UBGQ1brMbJZ887B9JJldmFdcYxIMOPSA1zMsXOvOXbJcn74yb8NknzW9UyeHTVZwQyjF0LVwq94rWfRySgB6ojUhFL457MNl/SZfIpmqmwrPyGEBuVB47DPl14CbaDxvCvCJEBLOVU7GjCESE64bFZTsk/OkaIXovwT/9uCWl+7gSMvwYQsivVH4ittasDVtBTio7Acd04sNRkEu4YAp4K7pz6/s5VSKa1UFuJE3/Chfj7Y70ZCcSj8lwBxp0B7sKpOJxaR00= X-MS-Office365-Filtering-Correlation-Id: bc6b7a8e-1f7f-4096-389d-08d44c85dbf6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0701MB2090; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB2090; 3:DGgtl0MxMtMnV38LSSCxddvXshrNtJj01sYU5dvBxfRGcKpkQ9kP89RL8SS2LP8y95HhtmwELdZt6lvD1I2yV+JGApH8iRGwi8MD5zAocuk49Awgyhw7k7bCjreHmtMfAhpD7EvFg3E+pezB0FVD6/A3cW5YwSQWjspByBOtQ0BHby4tyIEoP8hWzbpv6Hr7hflAh2RgM4k0Z0ofopnakUPMSU15Rh07O32+wiOmmtMMLLeaGgAztFSKP5GnblMYforc3SqU7Lvtycj4+KOaDt6FLFck2xoromXwhuVtvwKYaCG0OESIrf8laua8mXuYu/IkIdqHZwvzDqt2S0ekEiMb3xlJs1vifX5Fs7TzfZKqoEJQKsgp/KCIq5kh3qD2; 25:l7WMO1pHEfzLREvP8bzAhFxBkFNlUJGPBXUmCZsf9uAHtV8WUqjlW1bCKW7wP9bUbFSdDQsQlQJXb6xdopgyssEuCvGo+wvURP+aEPwmAAIsCd1SeVAYOnreWpvpVxcEx9ux1/gxq9mwloXfIuNEWSyUjk6MVrF0lTERyF8CgqAIxlV3J4LRiUjCBIXNp74Nf87YZ5oiqxH/Rx+t7KLqEoD6WaMka0o4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IjK6z4XhLAVbebM8Stfvb9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13023025)(13018025)(13015025)(8121501046)(5005006)(13024025)(13017025)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123558025)(20161123555025)(20161123560025)(6072148); SRVR:CY1PR0701MB2090; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB2090; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB2090; 4:G0tyLuS0qb5YsEuWFIzOoPuFvMhtaZ6X1pUZJTzVwefrfCITOIpBzLplXIkPWDHwipPUiSAcyBjyIArr+RCyVaZaGuVYSg42XqmEf0U6fci5UPpSfhlJDOGPgudByRh7w0iODKlbIsg41HSm2KRoM2XmEIFeGlHtlGGJwIcbOuwwr+PalePYTsVrntozLQV/Z2Mhj1QmoY2J0r08uoQhT0V3jZWrGrJ4kHhR3S8zx3ggosUJ/aWhZsEgz6limz4dnKWVbigytBh2nUw77csDClab3c2h4duX0NCVrB2HVug9iZV5z06fKUO//SOEXRoIa/dIKNDjTuBiR+3S4iJDXd0IQF0oht87Kp45M+bG/J+P8VjIPX/tNM1B5oSaHXDjuTCilLs8akL6kYkcawPLPDsY4hdrjr4RWEpEhxUl1WNZ7DsdHLhgMq4Vi1LYBc1FdvfILzrhjxhEZ3l2cpr7v0ENmQ9RuzrgNMxiTJUospn3CF8UIPzOY5w76G1ubUKZKL9O0FuNGkb3qByIFe3ZhdaE0oYlqeVYmDgb/ecqQWyH9L2q9VhJtFBDiJh69+LG2M5Cr2NECc3+Wx0e4LSLvb+Kz+dBYCQZBN06OwwFqwXBo8Ce6pkXZTT+am/ffZnmftRaD+agdUxb5AoeNcGrnSVr9j9AVvTwceIKL1svBsgJu3D9/7v1d3OLlG8bK1xX2lIZcgAvqa5FPtzoejxqOguYbMoT1OgsUwIQ6gE+kH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9QJr0D5qLqhdMNuskrAjMRrmgcpcS9eJZJLZ0+WFqsH7bBHwETR8c2s9a4=; 24:E+tGYayV+KvlfpR5G2eL8hZawgKAr5KxsWbJdvoxgxDSNpiAv4F3cibj70cXhywbd5OYxTKbUdWGPIyoe1/+as6YnpSN7UEcoHiF7w6BGoo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB2090; 7:rp/KvlGFWjdOJMi3Tn76NeUi6c9gid2DdBEOVdwhs86StE5u1Xbwg3/dUrg5ESKpgdiMioAThB0ALLpRM3J+lgvFqqBOwVJIu7cOw6UUkjwigmytS2XuV+FupB0V1+8kyrIl/hYJEkQmybbdyT3AYadibTFn55gC/hOLykZX7h6s2l7uESJzsTegRK2dCftXYCgia+CSykPB2nU2jfQ5OdxYK0fLRR+XXwsVX7JnD2oZYOZu/lXzhxN+G6yHg6ZLj4Zg6a8xKYpTXfNC/aPyQub8QI8tf4c15aAzRUCirkSK0BS4GMTcgOQjgCX67dEZfmPGsI3TjEpUxj75HImnOKMb0l4iUQovcDW/wXn8gLAYzGTiy+KWQHwTsAth5JXvGM8QRH3J8YnqYKh+OIcfh2dbNhQ1m0HVFk9RTwo5ff1xVkkFeSP3FVB+djPXZtne0W/Owi+20mC0jZaSDIPPHaVwa9lzYnpkwPxKCmPWLJSuC+Wip7mT2Mou72H3hbjvxArdAjVjQtny0t+Gx3icOQ== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2017 22:41:55.2226 (UTC) 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: CY1PR0701MB2090 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran The main lock that needs to be held for CMD or TMR submission to upper layer is the sess_lock. The sess_lock is used to serialize cmd submission and session deletion. The addition of hardware_lock being held is not necessary. This patch removes hardware_lock dependency from CMD/TMR submission. Use hardware_lock only for error response in this case. Path1 CPU0 CPU1 ---- ---- lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&ha->hardware_lock)->rlock); lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&ha->hardware_lock)->rlock); Path2/deadlock *** DEADLOCK *** Call Trace: dump_stack+0x85/0xc2 print_circular_bug+0x1e3/0x250 __lock_acquire+0x1425/0x1620 lock_acquire+0xbf/0x210 _raw_spin_lock_irqsave+0x53/0x70 qlt_sess_work_fn+0x21d/0x480 [qla2xxx] process_one_work+0x1f4/0x6e0 Cc: Cc: Bart Van Assche Reported-by: Bart Van Assche Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_target.c | 41 +++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 2909b7b..fb7156c 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -5818,30 +5818,23 @@ static void qlt_abort_work(struct qla_tgt *tgt, } } - spin_lock_irqsave(&ha->hardware_lock, flags); - - if (tgt->tgt_stop) - goto out_term; - rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess); + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); + if (rc != 0) goto out_term; - spin_unlock_irqrestore(&ha->hardware_lock, flags); - if (sess) - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); return; out_term2: - spin_lock_irqsave(&ha->hardware_lock, flags); + if (sess) + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); out_term: + spin_lock_irqsave(&ha->hardware_lock, flags); qlt_24xx_send_abts_resp(vha, &prm->abts, FCP_TMF_REJECTED, false); spin_unlock_irqrestore(&ha->hardware_lock, flags); - - if (sess) - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); } static void qlt_tmr_work(struct qla_tgt *tgt, @@ -5861,7 +5854,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt, spin_lock_irqsave(&ha->tgt.sess_lock, flags); if (tgt->tgt_stop) - goto out_term; + goto out_term2; s_id = prm->tm_iocb2.u.isp24.fcp_hdr.s_id; sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); @@ -5873,11 +5866,11 @@ static void qlt_tmr_work(struct qla_tgt *tgt, spin_lock_irqsave(&ha->tgt.sess_lock, flags); if (!sess) - goto out_term; + goto out_term2; } else { if (sess->deleted) { sess = NULL; - goto out_term; + goto out_term2; } if (!kref_get_unless_zero(&sess->sess_kref)) { @@ -5885,7 +5878,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt, "%s: kref_get fail %8phC\n", __func__, sess->port_name); sess = NULL; - goto out_term; + goto out_term2; } } @@ -5895,17 +5888,19 @@ static void qlt_tmr_work(struct qla_tgt *tgt, unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun); rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0); - if (rc != 0) - goto out_term; - ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + + if (rc != 0) + goto out_term; return; +out_term2: + if (sess) + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); out_term: qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 1, 0); - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); } static void qlt_sess_work_fn(struct work_struct *work)