From patchwork Wed Dec 13 01:51:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanyuan Zhong X-Patchwork-Id: 10108577 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 BB6C6602CA for ; Wed, 13 Dec 2017 01:52:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD4161FE82 for ; Wed, 13 Dec 2017 01:52:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1CFC2860A; Wed, 13 Dec 2017 01:52:34 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 814E01FE82 for ; Wed, 13 Dec 2017 01:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752066AbdLMBwR (ORCPT ); Tue, 12 Dec 2017 20:52:17 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:44752 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbdLMBwQ (ORCPT ); Tue, 12 Dec 2017 20:52:16 -0500 Received: by mail-pl0-f65.google.com with SMTP id n13so89010plp.11 for ; Tue, 12 Dec 2017 17:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=from:to:cc:subject:date:message-id; bh=peSZiuH9MZLzHjZovUat0+CQo8/6kVzK1DS7ImxKmic=; b=NLeuMl1OmvvUhLiQ1n35f48JmuqMzaWvDiKLWLKzkDRrZiAOb46hfXXDiV4itj4T+v cdM4wx6BvrJfvmJFdFoNphZwRUmx+pIeLHKkHlSVfrOJecsReQ7HnsVX5x/8sEbnhO2V FhD+MqUlCXgEqODYEaiFOFumAowDm/AKQVw9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=peSZiuH9MZLzHjZovUat0+CQo8/6kVzK1DS7ImxKmic=; b=BP/Fihl7dsHsJm0fFzXXqRA/+B5Wgwd5iSsKLxM2sEbG+HQX5fdurei6QKn0YpyEwy 9Ac8HirHxR6el09sJeAZgtrsdMZi4GQELzE1nmxPo/+31PYBKrogWeFscGz60OSgdeIy oW5oXC2tQqNMn/HaKMfcyhECXAB9W3ebYhVVDPNGLPzM7EQUfJ5A0Ly9rm72cXs16xIx S539BTsSvAWs8VxkgdawTrt6J2XgdmNhSqPStiGlNbI9VsBKBc2o9JteF5G/vqG2PDSP j48Coqjg2yMeoglu7I+N2KJQox6suM9hKoav/38TPJY91BUKVFpLBI1s6jEnJTP3EfmS cATg== X-Gm-Message-State: AKGB3mLMgB/KdtqKVWneSh8eSE9dhM1AuCgnPEQ64LkfgOsi+lxR68MJ 6pNef1s6LcvbhZ+UYisGbYIutA== X-Google-Smtp-Source: ACJfBov5pcd1oNnCdbJyXv0/PSwkC8UqZcMaVwEtzmOVbkXHi8NOkFS6hEDty60ZUd1N7p93v7Jbfw== X-Received: by 10.84.168.193 with SMTP id f59mr4184847plb.251.1513129936212; Tue, 12 Dec 2017 17:52:16 -0800 (PST) Received: from dev-yzhong.dev.purestorage.com ([192.30.188.252]) by smtp.googlemail.com with ESMTPSA id c11sm456315pgv.22.2017.12.12.17.52.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 17:52:14 -0800 (PST) From: Yuanyuan Zhong To: sathya.prakash@broadcom.com Cc: chaitra.basappa@broadcom.com, suganath-prabu.subramani@broadcom.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, Yuanyuan Zhong Subject: [PATCH] scsi: mpt3sas: validate device handle before ata pending flag Date: Tue, 12 Dec 2017 18:51:49 -0700 Message-Id: <1513129909-25243-1-git-send-email-yzhong@purestorage.com> X-Mailer: git-send-email 1.9.1 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 Commit ffb584565894 ("scsi: mpt3sas: fix hang on ata passthrough commands") introduced ata_command_pending bit-flag to ensure sending only one outstanding pass through ATA command to target device. However if target device become irresponsive with ata_command_pending, we won't be able to remove it timely, since we try to dispatch a SYNCHRONIZE_CACHE command and bail out with SAM_STAT_BUSY repeatedly. Move the invalid device handle checking a bit earlier than the ata_command_pending. Signed-off-by: Yuanyuan Zhong --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index b258f21..32fc0d8 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -4758,6 +4758,16 @@ static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending) return 0; } + sas_target_priv_data = sas_device_priv_data->sas_target; + + /* invalid device handle */ + handle = sas_target_priv_data->handle; + if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) { + scmd->result = DID_NO_CONNECT << 16; + scmd->scsi_done(scmd); + return 0; + } + /* * Bug work around for firmware SATL handling. The loop * is based on atomic operations and ensures consistency @@ -4771,17 +4781,6 @@ static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending) } } while (_scsih_set_satl_pending(scmd, true)); - sas_target_priv_data = sas_device_priv_data->sas_target; - - /* invalid device handle */ - handle = sas_target_priv_data->handle; - if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) { - scmd->result = DID_NO_CONNECT << 16; - scmd->scsi_done(scmd); - return 0; - } - - /* host recovery or link resets sent via IOCTLs */ if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress) return SCSI_MLQUEUE_HOST_BUSY;