From patchwork Fri Dec 22 07:31:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10128915 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 1523F60318 for ; Fri, 22 Dec 2017 07:32:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 081E029EE0 for ; Fri, 22 Dec 2017 07:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F124329FCE; Fri, 22 Dec 2017 07:32:57 +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 7E2C329EE0 for ; Fri, 22 Dec 2017 07:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753704AbdLVHc5 (ORCPT ); Fri, 22 Dec 2017 02:32:57 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33477 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbdLVHc4 (ORCPT ); Fri, 22 Dec 2017 02:32:56 -0500 Received: by mail-wm0-f66.google.com with SMTP id g130so23272791wme.0 for ; Thu, 21 Dec 2017 23:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jL91NU2e9m8rg/97I1jdXPmZl55wvDURbZsk1p855lA=; b=Rk/BIlyruz8uG9bUcWI5sTl+jt/QAm5SBtgsD2VYAqBU1UqIepVIqCF48H9EwWV8Z3 N+SkLvUkV9NiiLlgmWvH6R7FRLyHTct/+0C/dTDzL3Uoq20RknVEKCkEDZEBTfDoAXkL x8nwK35lpx8y8lqY2uUE9G+qTBBgzjoB9VKww= 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:in-reply-to :references; bh=jL91NU2e9m8rg/97I1jdXPmZl55wvDURbZsk1p855lA=; b=aWbm7yXjuVN6r9PzbuFkPKYtE0qS/B+k+kpc2l/c43WBmSJxlpce4lu83kLeoNIm0M IqCOFBbP8zic2KgA8mbKoyZG3B8U3kINh+XmjhOPWu2j6XB5Av2yNt0sKPZVeBUGf0IV BXMl5CfAIxJcc/l6pDQbgwkzwtyZqQQIq1Ny/T/p2bNYcbxgIq0pm7d3gi9YqGDArFU1 n4Qlm04d/w8PUiJ9rFXdRzBu65wqBR4MhX5LVaAz3+79W8rLD+ZknQR96M/diEYc7WOP HzSM3k2BNwflUqV5nLyTaTSWJSm6//YqICNJW2i0ZRxmzm6Ez6T4u0n8SoNmXxxEfeCH KBkg== X-Gm-Message-State: AKGB3mLq/QJJHFhfuVVyaPWjnaLdYU8NS+m8anu7WbvjjjYvVMJ/sEwf bxvs3gZgCjoNQpHDW4W0DkjvsUBh X-Google-Smtp-Source: ACJfBosJYjuClnkffA81pT8Pz3TTFX/orHf3SjG06kA8IgD8cTeMAoIz++AMLjvJa7GN0DTeuNCBbw== X-Received: by 10.28.198.75 with SMTP id w72mr12548151wmf.2.1513927975002; Thu, 21 Dec 2017 23:32:55 -0800 (PST) Received: from dhcp-135-24-192-103.dhcp.broadcom.net ([192.19.239.250]) by smtp.googlemail.com with ESMTPSA id b7sm10379462wrd.69.2017.12.21.23.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:32:54 -0800 (PST) From: Suganath Prabu S To: linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Hannes Reinecke , Suganath Prabu S , Chaitra P B Subject: [PATCH 10/11] mpt3sas: simplify _wait_for_commands_to_complete() Date: Thu, 21 Dec 2017 23:31:46 -0800 Message-Id: <1513927907-19735-11-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1513927907-19735-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1513927907-19735-1-git-send-email-suganath-prabu.subramani@broadcom.com> 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: Hannes Reinecke Use 'host_busy' instead of counting outstanding commands by hand. Signed-off-by: Suganath Prabu S Signed-off-by: Chaitra P B --- drivers/scsi/mpt3sas/mpt3sas_base.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index a49040e..eb4cc20 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -2898,9 +2898,9 @@ _base_recovery_check(struct MPT3SAS_ADAPTER *ioc) * See _wait_for_commands_to_complete() call with regards to this code. */ if (ioc->shost_recovery && ioc->pending_io_count) { - if (ioc->pending_io_count == 1) + ioc->pending_io_count = atomic_read(&ioc->shost->host_busy); + if (ioc->pending_io_count == 0) wake_up(&ioc->reset_wq); - ioc->pending_io_count--; } } @@ -6310,15 +6310,13 @@ _base_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase) * _wait_for_commands_to_complete - reset controller * @ioc: Pointer to MPT_ADAPTER structure * - * This function waiting(3s) for all pending commands to complete + * This function is waiting 10s for all pending commands to complete * prior to putting controller in reset. */ static void _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) { u32 ioc_state; - unsigned long flags; - u16 i; ioc->pending_io_count = 0; @@ -6327,11 +6325,7 @@ _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) return; /* pending command count */ - spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); - for (i = 0; i < ioc->scsiio_depth; i++) - if (ioc->scsi_lookup[i].cb_idx != 0xFF) - ioc->pending_io_count++; - spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); + ioc->pending_io_count = atomic_read(&ioc->shost->host_busy); if (!ioc->pending_io_count) return;