From patchwork Fri Feb 24 21:37:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9591219 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 F33CB601AE for ; Fri, 24 Feb 2017 21:38:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2EB02894F for ; Fri, 24 Feb 2017 21:38:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D73C728965; Fri, 24 Feb 2017 21:38:00 +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=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 5CDB42894F for ; Fri, 24 Feb 2017 21:38:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751219AbdBXVh7 (ORCPT ); Fri, 24 Feb 2017 16:37:59 -0500 Received: from mail-co1nam03on0076.outbound.protection.outlook.com ([104.47.40.76]:42236 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751298AbdBXVhz (ORCPT ); Fri, 24 Feb 2017 16:37:55 -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=RrVSxt6ifuItlJPsMVbLBwvObDuYw8fBPWl2JOxnizo=; b=UbbwQgtajbgKvNed9GzccFAuG9cyaDA/YN+h6ld7i3PyAJyRDcpN0vYqDmlVvIuMVlol6Phl0D86537BCui/eSy9aExudejk2yiJKybRMGYiwNVTpc7RI5SnVU5uzqNaVi1WwlfvkE+b/CuhTt8v1k5xPJNvNO4Gt7IgitUCEcI= Received: from BY2PR07CA0088.namprd07.prod.outlook.com (10.166.107.41) by CO2PR07MB634.namprd07.prod.outlook.com (10.141.228.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Fri, 24 Feb 2017 21:37:52 +0000 Received: from BY2FFO11OLC016.protection.gbl (2a01:111:f400:7c0c::111) by BY2PR07CA0088.outlook.office365.com (2a01:111:e400:7bff::41) 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, 24 Feb 2017 21:37:52 +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 BY2FFO11OLC016.mail.protection.outlook.com (10.1.15.61) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.919.10 via Frontend Transport; Fri, 24 Feb 2017 21:37:51 +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, 24 Feb 2017 13:37:44 -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 v1OLbifL003836; Fri, 24 Feb 2017 13:37:44 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v1OLbiIj003835; Fri, 24 Feb 2017 13:37:44 -0800 From: Himanshu Madhani To: , , CC: , , Subject: [PATCH v3 03/14] qla2xxx: Allow vref count to timeout on vport delete. Date: Fri, 24 Feb 2017 13:37:32 -0800 Message-ID: <1487972263-3795-4-git-send-email-himanshu.madhani@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487972263-3795-1-git-send-email-himanshu.madhani@cavium.com> References: <1487972263-3795-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)(42186005)(5003940100001)(2906002)(8936002)(50226002)(105586002)(8656002)(69596002)(8676002)(81156014)(81166006)(54906002)(4326007)(106466001)(48376002)(6666003)(356003)(33646002)(189998001)(86362001)(575784001)(2201001)(50466002)(76176999)(38730400002)(305945005)(5660300001)(1691005)(36756003)(2950100002)(107886003)(101416001)(50986999)(80596001)(92566002)(626004)(4720700003)(47776003)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB634; 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; BY2FFO11OLC016; 1:GjJ7WL4GAjR7n778fjflypRYseFiQXpB2rjXJqbeQBzZLdOLEBIuFDPn3Vea/VciRxeRPJOegIHfiqc24GGzM2TyVl76QqwbbLkicwlPpf66A4W3/nVJQk/iK0DG+3G7vRQXU1PMUyw0GBAy6bsomPGFBreea6xBH6skMFSOHwKWTVcVlQIq8EsXb2WloZ9DJcRrGwvshDCxV5QE03HA8ZnwXjGcXZKb5bwyFep8KPSNmw0BTJnJBJwqOjN5pE48L44qAYEYmpEEchpTlckkwmQybKQUt36nDlq3YDot86YHeugTadQpO238oiGFhN4M+qvO203EmI3cgV2SeL9BF1kywiVQQ6U93Wua0KIdqIiejlA3H6S52nnCM+VrDpraYt8hp8t/0Svxh0lBC56tasRIxL6zWhaYvTPctM8buzETEOLH7FJTMnwWc56uRq2d0qyAjJQL+sjCL5LFdlUJWtIAtMSGJNYi+w/nVqGN+T2Iv1N2rR3TfHtikIpG/QpSypNbQCZyeoW5F4MYAPQK/KK2xDQhLMdq/7qAh+4YvXM= X-MS-Office365-Filtering-Correlation-Id: 817ca535-dee7-4fe0-ebb6-08d45cfd62fd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR07MB634; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB634; 3:69VI9IQZMCRSLSQcPLUFH4Ly8hM7gmpfqyLaUBp+QUpnMpMo5LF/cdoRZ1EVLACB1mDnOXhOu1NilxnPF+zia4bzqQYwbOlYQbUTmgtW8YjspGSTyrRV7kzr/ixhzNJrdwWD/mNWsCRtuaAXsH7yR3aDmjoyLnMQFd4OP2vD4APyQGsjEabY1nlZasq+KOMCCNfFmSPblHk7gYP6D7bBFZXft7opyHj+fTQ+Bs2hK++QXUiT+wr/XPpfR8xCCO7zUuJcgDBj+GWtY21ztXs2guFOtl5AZFdmT53ITXUWw472T1J+CyWCbLFX8AzchhS+F7Nju5QS+pqDHIyFXQDv+2sMFRP4q59qS1POpWFBrAHL1d3R++LhN49BNzn0On79; 25:6EXbfUckdNKFYJBVBoccX1akZHw1PLEFKaintg6h/l2MnKA2x0OxnX4e6Sx+eCcKlqtUwfug+gT2YiNo8CYl5a9pv81MfyieESsO/l4A35IxFJMaUHmQDRzsdJnxg3nSy81VuOkbHg1NS6rCLMYtZpfG0FR3plVMShLip2dBsqOTjn4SOa5Vo1ZcPpDDPFQqvNW7adDQGY990BLNa+5UN4c/BMEkNuIxwt1ivtGzFVqqZAbNlzCG64E5+QKOrutDLfftVkrJ175qOA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antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13015025)(8121501046)(5005006)(13017025)(13023025)(13024025)(13018025)(10201501046)(3002001)(6041248)(20161123558025)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CO2PR07MB634; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB634; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB634; 4:FaT0ZNMzuFIe8oy/ATPPJEbNu7kAQyngrTyF59eDo6R87yL6M10UzdwZnIoWQAKIXLunfjZKJ44bYRcNhIUBytzgQCpRB+1kmF3oaWowJSe4iYavxI3c3i8IcNj1sZv/4Dit9cdzrIRy+NRfZQleFtuu77r8q9rPz7K8D3j5vsbFCQI9uwVzJyg9Go2XtTL9lTfANNF05whkdAGcZdhDR6H/KQznC3KxSkNztQoDyDNZodZRr5Esb2TsEa8TZh7R4PajY64DNpy4HUyIYhHQhj+x6Za81CKtNz4bI1j2oFsmrhRNFJezl/Mpvq18wFdmNxOsQHri4ZlmS8geqloL92OolG+sf7ODCmaU+zDVgtsGdzju3fAKfdSfb3E8ZVDN4ys+3LzcSOQ8DyBt4df+numNK9KTSbSnymmyL/4G7+Vo8uzkhMUyZhq7zqNmWw9kaS1WjwtyO2lvIzCPGT+L7xeYg8DA9/jobv3DPdbEmTh5werAxiquG3khylm6m79uTkG1nj3CvkuzQOe+QMsNsS3QbebkoN9nppdC6lw4BOWDp7mnWR6XLgAl6Lwf5liN8nHe0nBx4zGGE3wj/gCvAwyVfQbu4BeO267fvcawtY7pPttDpN9bFBC7ff7Zeq6yOo+ZNxpJsQtUCTSs8Vxv2S2QBj/vQ2NOdKpiMgVPf5gPxptKOkS4klPLZ0+gKxynrNcQwSjJjz8q1/PdiKW2ODYcA3B1QJZmfQaqONt5ZUeRXtMqbqM7/ck1f984FneF X-Forefront-PRVS: 0228DDDDD7 X-Microsoft-Exchange-Diagnostics: =?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F1d58kXH53LhsVtRe0?= =?us-ascii?Q?02DBFr8ihojbuHQhhGNUvnyGszFKNwFdbgaoYmpo5BT1M1xkO26CNFwJlH3e?= =?us-ascii?Q?yHb3BiG8600+A8MQsmip4zapyGsqeFm5De7XVGxeHFJ6GRcrg1uW4vKniaDX?= =?us-ascii?Q?EvP+5JLi6wXbx2LCiKNI0AAsxZpvI/lOF0YF0yWs0ic7gngbYUho0siUVDml?= =?us-ascii?Q?A5b40PjjpNv8kAF4nkCkpIxMpjiKwhNNhgifSBo8F8mWwMqhqlbQYkDeqnwf?= =?us-ascii?Q?SyK6Lf5Xk=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB634; 6:j+9HH///GZRHNUNESi/zonTyoTvF3bIeNlcxFpdT7XIuxmmnkMF3BVCuGX2qqOqXyxF41a7123eUH4CwM2PRltC7mxBCdOiQz1QgaOdgAYyVKYDB+Hp15ogiA7X/6X/MILglzNm5KKKNcuLjN8AcJqagrBX/e7PXEOw59qnhA+cB4rbRsm1te/mLrT813qwyQmy0hCIBpdpPlWeXHFvTjdDU04+rU98bFLiozgda5z09AbkTVgzKaNwPjg9/eMBRU+pGOj7FZb1EMhcCnGxVcVDOVpo1ngcIAa6kWqbnltum67gW8gpqIgXZvZ6HPzXSC3isFTNGtmwKbseqXQbFT30fjQsttBlNE0CGNlJwR0H5qllADBXYPis3QYGMORsw/zskRoyOWAR09dnfO/jtNg==; 5:YjO1sJvJkAHgKwAz336ni64PIkxdmlqUVzyneqqE3qvQJDm21i6fW0l62MJHTL54mV6ECTHWRawNQu7vjIcUVN3L9+0qRIZpqkGG6q7p71jD39YPU/JanQ6Hqzasd//54HXzY5Cqy9sUjYJ+P4QnIXHSASx7vBQ9xHOEAN7YEf4=; 24:D9InPmN24CaNeEdBnP5zzsyvw4YIbOWdRnLN3egYaGTF1dP824jJLVIzKyrU3sT8CWB7wWcypHvoJ9wBx0rhxKG56sqZzyqXxeZtqng5byk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB634; 7:nUooBUMj5enZCxpxZzWcbOQXsxMyo1anue6fEc+esaj/N8ak/vkg328YK7PUWsInDMvw3PCwbVwL+TtDU3YPG5ghRPHrSP8iwxPMixlipuZSP0VRch2iK4P3SJ0RLOe+IvYURooJ+rta5DBGKtYVA0im0D2trHLsR0Ydn35ej+NDNoN4Vw1sdYxrb0WzmAgdf3w8sbItV/KCqbN4ZGdE5EcsR1McVujkGCUfwu8CQi20vBUAgSGChBDnkDuYFA4iCRbjJzr831+eBjZsmqT4DqZCtx5+8SMJ8xjuj81vPw6KleAfzW06owNQMaf+G6BXIWbZQzQ7K1Ks1PJxrCNyWg== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2017 21:37:51.7912 (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: CO2PR07MB634 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: Joe Carnuccio Cc: Signed-off-by: Joe Carnuccio Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 4 +--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 14 ++++++++------ drivers/scsi/qla2xxx/qla_os.c | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index f610103..435ff7f 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -2154,8 +2154,6 @@ struct device_attribute *qla2x00_host_attrs[] = { "Timer for the VP[%d] has stopped\n", vha->vp_idx); } - BUG_ON(atomic_read(&vha->vref_count)); - qla2x00_free_fcports(vha); mutex_lock(&ha->vport_lock); @@ -2166,7 +2164,7 @@ struct device_attribute *qla2x00_host_attrs[] = { dma_free_coherent(&ha->pdev->dev, vha->gnl.size, vha->gnl.l, vha->gnl.ldma); - if (vha->qpair->vp_idx == vha->vp_idx) { + if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) { if (qla2xxx_delete_qpair(vha, vha->qpair) != QLA_SUCCESS) ql_log(ql_log_warn, vha, 0x7087, "Queue Pair delete failed.\n"); diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index fea4b79..e337020 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -4086,6 +4086,7 @@ struct qla_tgt_counters { /* Count of active session/fcport */ int fcport_count; wait_queue_head_t fcport_waitQ; + wait_queue_head_t vref_waitq; } scsi_qla_host_t; struct qla27xx_image_status { @@ -4141,14 +4142,17 @@ struct qla2_sgx { mb(); \ if (__vha->flags.delete_progress) { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ __bail = 1; \ } else { \ __bail = 0; \ } \ } while (0) -#define QLA_VHA_MARK_NOT_BUSY(__vha) \ +#define QLA_VHA_MARK_NOT_BUSY(__vha) do { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ +} while (0) \ #define QLA_QPAIR_MARK_BUSY(__qpair, __bail) do { \ atomic_inc(&__qpair->ref_count); \ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 08f8536..1f94003 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5158,6 +5158,7 @@ int qla2x00_perform_loop_resync(scsi_qla_host_t *ha) } } atomic_dec(&vha->vref_count); + wake_up(&vha->vref_waitq); } spin_unlock_irqrestore(&ha->vport_slock, flags); } diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index c6d6f0d..09a490c 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -74,13 +74,14 @@ * ensures no active vp_list traversal while the vport is removed * from the queue) */ - spin_lock_irqsave(&ha->vport_slock, flags); - while (atomic_read(&vha->vref_count)) { - spin_unlock_irqrestore(&ha->vport_slock, flags); - - msleep(500); + wait_event_timeout(vha->vref_waitq, atomic_read(&vha->vref_count), + 10*HZ); - spin_lock_irqsave(&ha->vport_slock, flags); + spin_lock_irqsave(&ha->vport_slock, flags); + if (atomic_read(&vha->vref_count)) { + ql_dbg(ql_dbg_vport, vha, 0xfffa, + "vha->vref_count=%u timeout\n", vha->vref_count.counter); + vha->vref_count = (atomic_t)ATOMIC_INIT(0); } list_del(&vha->list); qlt_update_vp_map(vha, RESET_VP_IDX); @@ -269,6 +270,7 @@ spin_lock_irqsave(&ha->vport_slock, flags); atomic_dec(&vha->vref_count); + wake_up(&vha->vref_waitq); } i++; } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 312972b..4867589 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4288,6 +4288,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, spin_lock_init(&vha->work_lock); spin_lock_init(&vha->cmd_list_lock); init_waitqueue_head(&vha->fcport_waitQ); + init_waitqueue_head(&vha->vref_waitq); vha->gnl.size = sizeof(struct get_name_list_extended) * (ha->max_loop_id + 1);