From patchwork Fri Jan 5 13:27:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10146581 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 CC05E601A1 for ; Fri, 5 Jan 2018 13:29:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9DD1287CD for ; Fri, 5 Jan 2018 13:29:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEF76287D3; Fri, 5 Jan 2018 13:29:31 +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 2576C287CD for ; Fri, 5 Jan 2018 13:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbeAEN3a (ORCPT ); Fri, 5 Jan 2018 08:29:30 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:38317 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751815AbeAEN33 (ORCPT ); Fri, 5 Jan 2018 08:29:29 -0500 Received: by mail-pf0-f194.google.com with SMTP id u25so2181005pfg.5 for ; Fri, 05 Jan 2018 05:29:29 -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=YuHd2EBuum1f1Q1Dx9Hq7rszv1MsxF53DoVqri/IQFk=; b=G2rEzYzAfdn0fkbv3dHciR387ixWP4xmOUuGuyiIpIf5hZnWTf/EmGae0ONRG8CVk+ JZOscC7nTpC/N3/R0EQfdCwe6lNOt5maz02SoqwpeREJhAITBo2p5A9iAUsk3LuSR/sI zJX4PDzttzy9kTWHSFaLhrGFD158lvnNohAPw= 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=YuHd2EBuum1f1Q1Dx9Hq7rszv1MsxF53DoVqri/IQFk=; b=d+Hd49EW6BDZ2fm+sgKZAMj82Lkzjx3hzjnboF3tI+6e/4nLf6Wu+/eM8Uc+jfrf1k tWGpvSiDR9HML6V9qRbVF71nLzgZF1n5Vf04S4bn8vov2cSOH32Ymfht24yGsUDoXozm bGEHq1c1vWW2+niEXmjXb+n3PdThln6jPFpRm5ojrIZsQs+7YWKuXDgQZYMfyZJEwZlh G2eJ3y0iVRDGevM+gvDOPPmsAqqH5RKrGNuMSeBDoGGKOO6EfiYQ6YxVfRvW4dys8fig 6w6a3d6hJPo/uyxFOYhzDBeMXZEhyR+sR7+ILXfXQP1BJ8JGT/pzTmPsU0EAUsacIu/j dGog== X-Gm-Message-State: AKGB3mJMdVAMvrHUAh/RVHvxsa/K/2SOyWOKnWoOmLzBAalCNXukSKb4 Dtu7/9yyOQNd7NsjC38Bh6ZdZYKC X-Google-Smtp-Source: ACJfBotvHYyHpMSHHoPrZguRNLYRVY4/r/KUhPMfzjYeNeJEvTofOb8YqeuyI5E9QwDBOc6HW13o3g== X-Received: by 10.99.96.131 with SMTP id u125mr1488817pgb.380.1515158969008; Fri, 05 Jan 2018 05:29:29 -0800 (PST) Received: from dhcp-135-24-192-142.localdomain ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id 68sm12588733pfx.186.2018.01.05.05.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 05:29:27 -0800 (PST) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Shivasharan S Subject: [PATCH 08/14] megaraid_sas: Use megasas_wait_for_adapter_operational to detect controller state in IOCTL path Date: Fri, 5 Jan 2018 05:27:43 -0800 Message-Id: <1515158869-26693-9-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1515158869-26693-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1515158869-26693-1-git-send-email-shivasharan.srikanteshwara@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 In IOCTL path, re-use megasas_wait_for_adapter_operational API to detect controller state. This will make driver to use this API uniformly in all cases where we need to wait for adapter to become operational. Signed-off-by: Sumit Saxena Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas_base.c | 60 ++----------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 5ab343d386f9..34d1fb75285a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7305,9 +7305,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) struct megasas_iocpacket *ioc; struct megasas_instance *instance; int error; - int i; - unsigned long flags; - u32 wait_time = MEGASAS_RESET_WAIT_TIME; ioc = memdup_user(user_ioc, sizeof(*ioc)); if (IS_ERR(ioc)) @@ -7319,10 +7316,6 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) goto out_kfree_ioc; } - /* Adjust ioctl wait time for VF mode */ - if (instance->requestorId) - wait_time = MEGASAS_ROUTINE_WAIT_TIME_VF; - /* Block ioctls in VF mode */ if (instance->requestorId && !allow_vf_ioctls) { error = -ENODEV; @@ -7345,32 +7338,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) goto out_kfree_ioc; } - for (i = 0; i < wait_time; i++) { - - spin_lock_irqsave(&instance->hba_lock, flags); - if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { - spin_unlock_irqrestore(&instance->hba_lock, flags); - break; - } - spin_unlock_irqrestore(&instance->hba_lock, flags); - - if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { - dev_notice(&instance->pdev->dev, "waiting" - "for controller reset to finish\n"); - } - - msleep(1000); - } - - spin_lock_irqsave(&instance->hba_lock, flags); - if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { - spin_unlock_irqrestore(&instance->hba_lock, flags); - - dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n"); + if (megasas_wait_for_adapter_operational(instance)) { error = -ENODEV; goto out_up; } - spin_unlock_irqrestore(&instance->hba_lock, flags); error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); out_up: @@ -7386,9 +7357,6 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) struct megasas_instance *instance; struct megasas_aen aen; int error; - int i; - unsigned long flags; - u32 wait_time = MEGASAS_RESET_WAIT_TIME; if (file->private_data != file) { printk(KERN_DEBUG "megasas: fasync_helper was not " @@ -7412,32 +7380,8 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) return -ENODEV; } - for (i = 0; i < wait_time; i++) { - - spin_lock_irqsave(&instance->hba_lock, flags); - if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { - spin_unlock_irqrestore(&instance->hba_lock, - flags); - break; - } - - spin_unlock_irqrestore(&instance->hba_lock, flags); - - if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { - dev_notice(&instance->pdev->dev, "waiting for" - "controller reset to finish\n"); - } - - msleep(1000); - } - - spin_lock_irqsave(&instance->hba_lock, flags); - if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { - spin_unlock_irqrestore(&instance->hba_lock, flags); - dev_err(&instance->pdev->dev, "timed out while waiting for HBA to recover\n"); + if (megasas_wait_for_adapter_operational(instance)) return -ENODEV; - } - spin_unlock_irqrestore(&instance->hba_lock, flags); mutex_lock(&instance->reset_mutex); error = megasas_register_aen(instance, aen.seq_num,