Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1903647pxa; Mon, 3 Aug 2020 02:05:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVa/U8YZ/eZMtOd5kvv7TbyvJsqAv1C3tbQVVJ2dwIHuqCAiNVAFjC41C3oV9mELexGlIk X-Received: by 2002:a50:bf07:: with SMTP id f7mr15135426edk.356.1596445537800; Mon, 03 Aug 2020 02:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596445537; cv=none; d=google.com; s=arc-20160816; b=pydj/r1AHEae56KjNfcW4n3y2huCvkcqVYkK9wnYH0FDzYfRujS6+reyvrqDuEdP/H 93jsEprAoJQN4XvHTE6sDhP6pcjz+25kIdFV12V0b8hgzo07AB5HvxG2A1hiThAmHHSp 79mDWnKp6pwYSO83k5TlFA1WzycnfB3jFBfPdkLpPBzCi2HPzvwAtBp4EEKo0vb/+RzH BZ90spdpxhVK1JO6NYs3x0gCyYCke0vzu5mDNeTZoz8fyGykA70kx+AiUNtnEe8/uX4h XMRzpuFjsxjreTWa40L+AWS+1HApqE4sJbqK8BmOZC8zDYmkxb0q7NCIS/qhzqbifnEG 26Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr; bh=0tHwnYibInW/wl73dvnhFdj7bYspAOWNK+Zxqvtt+2k=; b=dDIWhIX9tfDi17iqHa3NzLmGJX7sXy71mBy3S16hZ7jmexBgZc7hLYbSuY0KawmTsB mlaebwc/CxQyqAOhr3Ktqz1HFBtB+uRR+AaQ++ohGGhGgts1nYOfN/f8tq9LTtLxGDdf QbTtHIv73ZKofFcVV25Q7i85qzkdY5c80YdCRvZqE9eGbRq/+mJhLcDjAjuehbNxMxhG wMoN1z1Lb99u8edw7EFhNLUvorx51mfXXPCAMNxl59ttelo6l4Mdu56zBEeoABSub/J4 uZ74hwqVn6mrDh3KzIGxW5ldmYBjC7ViyB8WXLNWs0mAcJxjIqooEp5ePXwxZOdjeJrl NUKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si5515497ejx.85.2020.08.03.02.05.15; Mon, 03 Aug 2020 02:05:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbgHCJEv (ORCPT + 99 others); Mon, 3 Aug 2020 05:04:51 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:8658 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgHCJEv (ORCPT ); Mon, 3 Aug 2020 05:04:51 -0400 IronPort-SDR: dajFYW/VqHUFnplPAQ6+aKrMR0HZvwvm685X8F5DC/fWctPM/9JsX8kq3BWkU8uY90lAO0mPQx nX/XlFF4TI9zd5l8fnJ6LlyY4Z6e1Lbf253DcqQFplP3OHX3TeNC0f5OTOyIbNUEFboLr+YbV0 bE8ODrWu7SgUzjBLKyJ6qqAGMZ3j/GGTFvNUwSeGzecsW1Vj4Y1zO/4ECpD46yva7VG+NpXc2D Q1DjEEg4Zyo20+TFkx2lXuBekaH7NHFL0VHBETRpfK0CY004TdcvRwC3JGY+BDvpM77Sp4ohp4 9w4= X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="47240952" Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by labrats.qualcomm.com with ESMTP; 03 Aug 2020 02:04:50 -0700 Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg05-sd.qualcomm.com with ESMTP; 03 Aug 2020 02:04:49 -0700 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 71C3D214E4; Mon, 3 Aug 2020 02:04:49 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH v9 1/9] scsi: ufs: Add checks before setting clk-gating states Date: Mon, 3 Aug 2020 02:04:36 -0700 Message-Id: <1596445485-19834-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596445485-19834-1-git-send-email-cang@codeaurora.org> References: <1596445485-19834-1-git-send-email-cang@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clock gating features can be turned on/off selectively which means its state information is only important if it is enabled. This change makes sure that we only look at state of clk-gating if it is enabled. Signed-off-by: Can Guo Reviewed-by: Avri Altman Reviewed-by: Hongwu Su Reviewed-by: Stanley Chu Reviewed-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 3076222..5acb38c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1839,6 +1839,8 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) if (!ufshcd_is_clkgating_allowed(hba)) return; + hba->clk_gating.state = CLKS_ON; + hba->clk_gating.delay_ms = 150; INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work); INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work); @@ -2541,7 +2543,8 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) err = SCSI_MLQUEUE_HOST_BUSY; goto out; } - WARN_ON(hba->clk_gating.state != CLKS_ON); + WARN_ON(ufshcd_is_clkgating_allowed(hba) && + (hba->clk_gating.state != CLKS_ON)); lrbp = &hba->lrb[tag]; @@ -8326,8 +8329,11 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) /* If link is active, device ref_clk can't be switched off */ __ufshcd_setup_clocks(hba, false, true); - hba->clk_gating.state = CLKS_OFF; - trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state); + if (ufshcd_is_clkgating_allowed(hba)) { + hba->clk_gating.state = CLKS_OFF; + trace_ufshcd_clk_gating(dev_name(hba->dev), + hba->clk_gating.state); + } /* Put the host controller in low power mode if possible */ ufshcd_hba_vreg_set_lpm(hba); @@ -8467,6 +8473,11 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) if (hba->clk_scaling.is_allowed) ufshcd_suspend_clkscaling(hba); ufshcd_setup_clocks(hba, false); + if (ufshcd_is_clkgating_allowed(hba)) { + hba->clk_gating.state = CLKS_OFF; + trace_ufshcd_clk_gating(dev_name(hba->dev), + hba->clk_gating.state); + } out: hba->pm_op_in_progress = 0; if (ret) -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.