Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp718338ybh; Sun, 12 Jul 2020 22:04:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTN/m5uHN4HR2BczgtpB78E/+E8R10uGP/sWT8kP9iN5GJON3j4jUpB/JyUTf9+KFsJaYL X-Received: by 2002:a17:906:2c18:: with SMTP id e24mr76187250ejh.335.1594616641731; Sun, 12 Jul 2020 22:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594616641; cv=none; d=google.com; s=arc-20160816; b=IVCAQ8L1cJpDvsiQBIPHEV0ZpOt9E6+ztooNsMDYNWARrnmZP0KGf2WPSEULNVKKF+ aOF/4dOJyeVIldN/dZb7YpezvjZsxarbsXqtGEa+SRduSYgp+OcoPQT8ikoSGOkfNjQD NyKzag7qHPTfso162sTWmzjHTvni7glP+/ksd0dB+CfqcXlHCugQY7R/9umrDAA3C/KD 1vJ16C9Ue4BeqgWm4EX+kPLAGBMUPiW0wp2etk0vW0M7qW8JhFTZPrl0+iJFeERI7LkH 7RoJLd7tp/mddMaEU3q8oh+EqR2zO3efzJq4Qo0iseHiUdRE99P9+692zG8RVP+t7bm0 qoSg== 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=Tsu0rA7gzEUl9lnA6GVnT31xV4a1fYQmfgPKkgV/K7k=; b=dfc7OWNkt91lK3ZfZ+t1QWbHuQybKyWfQzMWbBrJRZT20gL2GeTNEhxMCdiXF11nIh XLH6Io+1KPEUSTSen1O14NhU6HwC5Uu+ywAuHFcr7JT8syJ6Mh26QGfisM5pXcwkgaQo Lo+tB5/HYRih8XmHxdcmt9qSYUdejUL1Jycw4PzjXmsStKsJWHqWdfcdCuW7Ixbux9+S R2oQItXSm1wn+H7TwZyIfLUocUx5rmzpBtelLNLRZ0UN6xj9D4EADV9xnId3kwwSDfrH 8ZbeO8L/E/+UAhGIimNpG4STgUQkpyS9Xgnd2/OfFEZAHo+KfzDxAu7MFn9rK2Van8UN Pdug== 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 l17si8959270ejc.174.2020.07.12.22.03.38; Sun, 12 Jul 2020 22:04:01 -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 S1727788AbgGMFD1 (ORCPT + 99 others); Mon, 13 Jul 2020 01:03:27 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:31904 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMFD0 (ORCPT ); Mon, 13 Jul 2020 01:03:26 -0400 X-Greylist: delayed 364 seconds by postgrey-1.27 at vger.kernel.org; Mon, 13 Jul 2020 01:03:26 EDT IronPort-SDR: H/gVbe3f5uszX/6TDQbNxfjTdKBxPVp4GXX0QzIsna5hSBXGFaA845Oa+OBr7cyZCtfn4pA0YH v27R7A1hC8R5esbU+VtgoM08i6nyE2CY7NCBuOgjTnKlHGqk0q2FePPq5RZatJ7kIb0g7s20dg DkVUIp+q/uQF+wWmDbVPgpIqG10Lwki0LDNeww0tsSoY7CRI7qPSDFVhxnStcgJ7g7Usb5c7t4 jboT4lhkv0LIQ1rU9qp4AlXyqWf34IO0EVJ8LTGhiZ46OeGBI8SLS3Tbla5HIlrMSBSR2oZjwM bdI= X-IronPort-AV: E=Sophos;i="5.75,346,1589266800"; d="scan'208";a="47215536" Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by labrats.qualcomm.com with ESMTP; 12 Jul 2020 21:57:22 -0700 Received: from pacamara-linux.qualcomm.com ([192.168.140.135]) by ironmsg04-sd.qualcomm.com with ESMTP; 12 Jul 2020 21:57:20 -0700 Received: by pacamara-linux.qualcomm.com (Postfix, from userid 359480) id C08D522DAF; Sun, 12 Jul 2020 21:57:20 -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" , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 1/4] scsi: ufs: Add checks before setting clk-gating states Date: Sun, 12 Jul 2020 21:57:09 -0700 Message-Id: <1594616232-25080-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594616232-25080-1-git-send-email-cang@codeaurora.org> References: <1594616232-25080-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 --- 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 efc0a6c..ebf7a95 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); @@ -2538,7 +2540,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); + if (ufshcd_is_clkgating_allowed(hba)) + WARN_ON(hba->clk_gating.state != CLKS_ON); lrbp = &hba->lrb[tag]; @@ -8315,8 +8318,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); @@ -8456,6 +8462,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.