From patchwork Thu Jan 4 12:57:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10144713 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 EF65A6034B for ; Thu, 4 Jan 2018 12:58:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD44E2817F for ; Thu, 4 Jan 2018 12:58:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D218B28635; Thu, 4 Jan 2018 12:58:11 +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 7F1842817F for ; Thu, 4 Jan 2018 12:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752515AbeADM6J (ORCPT ); Thu, 4 Jan 2018 07:58:09 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:44900 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbeADM6I (ORCPT ); Thu, 4 Jan 2018 07:58:08 -0500 Received: by mail-qt0-f193.google.com with SMTP id m59so1718132qte.11 for ; Thu, 04 Jan 2018 04:58:08 -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=IXkSV3qxOgWnjc4ySPRRFbGuSa8YTOLiyVC/UaasXhE=; b=ZzKyveZzXbNWVBPYN4iBnzoRRmXPLH8qebsGvhpFjwbDeC4tTpgzEpOEctnufmH/wq Ii6i8B5UF3SuUjeO95SfJqu9usW1pzoOj29Xn3fMLF1DJZxdj/n9R25a5tOQMUjY6POg d0PopAkfv4KEd5xNbwB5CjRToroLiWwTFrqCk= 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=IXkSV3qxOgWnjc4ySPRRFbGuSa8YTOLiyVC/UaasXhE=; b=AdnWffGHrwneYg+y3jFdwbJkV3fatSDQJGJ18akp+8Ry8oRASc3NuXv2iRt6SExgQY Ue6GllFst+buAsEHuLzLBvjzGTvxA5e6GJnVWhARh5Vf/T33gN5NTU84ttgbruSxeo+Q p/tR79ufqoPYs8ggBRZxXPS8E2i5e7xqpGLO+yhiWErmVgBkjNLFKfHiiGf6Jpbydx+7 xkKGEm3v1SRNgcz5jlnRv8p/OOtZvfnPG63mcwvQAPbDvVTsg68WCey8E6+xKkVa7OFV pNICisiIvJkqoX/lUzo16x8VXqTd7vmdYdFhEWZ1WWEY7+xpYllpdEB57MqGnu1KcXND 2GOg== X-Gm-Message-State: AKGB3mLBIKzjEjPUu0ND3XAJu+McY4K/3J2pXTegQs7PgrnS1qyVdLY1 Do5V6X02hwmXIuCk1QyphnmsjPNl X-Google-Smtp-Source: ACJfBovWsf7QOrBYKPNgbFk5uUnilVOFpweEfoPJV3PSQJ85oSg0C0S42xCUTlQnMuECjdbRAwLqNA== X-Received: by 10.200.53.139 with SMTP id k11mr6065335qtb.77.1515070687677; Thu, 04 Jan 2018 04:58:07 -0800 (PST) Received: from dhcp-135-24-192-103.dhcp.broadcom.net ([192.19.239.250]) by smtp.googlemail.com with ESMTPSA id v58sm2064328qtk.18.2018.01.04.04.58.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 04:58:07 -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, chaitra.basappa@broadcom.com, Hannes Reinecke , Hannes Reinecke , Suganath Prabu S Subject: [Resend 10/11] mpt3sas: simplify _wait_for_commands_to_complete() Date: Thu, 4 Jan 2018 04:57:10 -0800 Message-Id: <1515070631-14740-11-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1515070631-14740-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1515070631-14740-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: Hannes Reinecke Signed-off-by: Suganath Prabu S --- 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 d4b32af..2314949 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;