From patchwork Tue Apr 2 21:24:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10882345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13F94922 for ; Tue, 2 Apr 2019 21:25:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF4A0288BA for ; Tue, 2 Apr 2019 21:25:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E06E1288D2; Tue, 2 Apr 2019 21:25:45 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 6BB97288BA for ; Tue, 2 Apr 2019 21:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfDBVZp (ORCPT ); Tue, 2 Apr 2019 17:25:45 -0400 Received: from mail-eopbgr730047.outbound.protection.outlook.com ([40.107.73.47]:14528 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726637AbfDBVZo (ORCPT ); Tue, 2 Apr 2019 17:25:44 -0400 Received: from BN8PR07CA0012.namprd07.prod.outlook.com (2603:10b6:408:ac::25) by SN6PR07MB5375.namprd07.prod.outlook.com (2603:10b6:805:74::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15; Tue, 2 Apr 2019 21:25:42 +0000 Received: from CO1NAM05FT044.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::208) by BN8PR07CA0012.outlook.office365.com (2603:10b6:408:ac::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15 via Frontend Transport; Tue, 2 Apr 2019 21:25:41 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by CO1NAM05FT044.mail.protection.outlook.com (10.152.96.158) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1771.6 via Frontend Transport; Tue, 2 Apr 2019 21:25:41 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 2 Apr 2019 14:24:38 -0700 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 x32LOc3i028508; Tue, 2 Apr 2019 14:24:38 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x32LOcu9028507; Tue, 2 Apr 2019 14:24:38 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 01/15] qla2xxx: Set the SCSI command result before calling the command done Date: Tue, 2 Apr 2019 14:24:20 -0700 Message-ID: <20190402212434.28469-2-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190402212434.28469-1-hmadhani@marvell.com> References: <20190402212434.28469-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131987139417418409;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(106466001)(42186006)(51416003)(47776003)(8676002)(53936002)(50466002)(85426001)(2616005)(36756003)(80596001)(126002)(1076003)(81166006)(4326008)(69596002)(97736004)(476003)(486006)(48376002)(11346002)(446003)(81156014)(336012)(68736007)(54906003)(36906005)(110136005)(8936002)(498600001)(76176011)(50226002)(86362001)(305945005)(2906002)(6666004)(87636003)(316002)(356004)(5660300002)(26005)(26826003)(16586007)(105606002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR07MB5375;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6103fc50-407d-44ad-064f-08d6b7b1c246 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600139)(711020)(4605104)(2017052603328);SRVR:SN6PR07MB5375; X-MS-TrafficTypeDiagnostic: SN6PR07MB5375: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0995196AA2 X-Microsoft-Antispam-Message-Info: AUoVFBkvrQ583H7XmcFa5a/iGTxJ5pguaJtY2WNHUyqkkx2bl5VgB/m42tLE1C1BcigXpyjkPTnR+8PkZ5NQZ1JSaxEqdMmmRZiFw21SjsMObpS+su6ki+fi4TgpG68t0MHYFVmywVpbEweOhQqG+iBB9k670C/iT3yi9Q9cLyQ6awFUmSlrg2N1YxwBQogUGiBRpoUCn3+MSLMRmL8NIKLRcVxVzLqbHkLPiGZG6Fcu+3h7NIZ7j9YVg5tyFvZTMFgYT81Atdi4E4pLhKRBVs31An4g2rhTKsgQ9ldzvjlIYOMb6/gBk6Y/JSz1W7Gs8m5GCGZi47bWsfU2litJPKsnzinlrDgUl9lS6y+qRsTM66JicdrjZzDEXE5qIeN90b270Ff7Op5Ez4Aesu76MFLLyzljWwxbhFz7V0YvdRo= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2019 21:25:41.2934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6103fc50-407d-44ad-064f-08d6b7b1c246 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB5375 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 From: Giridhar Malavali This patch tries to address race condition between abort handler and completion handler. When scsi command result is set by both abort and completion handler, scsi_done() is only called after refcount on SRB structure goes to zero. The abort handler sets this result prematurely even when the refcount is non-zero value. Fix this by setting SCSI cmd->result before scsi_done() is called. Signed-off-by: Giridhar Malavali Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index cad93c34409b..dde13036b06a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -765,8 +765,6 @@ qla2x00_sp_compl(void *ptr, int res) srb_t *sp = ptr; struct scsi_cmnd *cmd = GET_CMD_SP(sp); - cmd->result = res; - if (atomic_read(&sp->ref_count) == 0) { ql_dbg(ql_dbg_io, sp->vha, 0x3015, "SP reference-count to ZERO -- sp=%p cmd=%p.\n", @@ -779,6 +777,7 @@ qla2x00_sp_compl(void *ptr, int res) return; sp->free(sp); + cmd->result = res; cmd->scsi_done(cmd); }