Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1266800ybh; Thu, 23 Jul 2020 04:47:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1PijomdYmMN0w4yUIrAMrYP8z6HMqFVwvxHSdtW35CBC7vL+/ALK5HkNq7WWPb6YDOyIV X-Received: by 2002:a17:906:6606:: with SMTP id b6mr4172723ejp.102.1595504850450; Thu, 23 Jul 2020 04:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595504850; cv=none; d=google.com; s=arc-20160816; b=t7mJkRSJPkSboY9GZP9KeHMMomhXu2qM/r/iKIVvhVntUWJnaM/ZNuLTun2gzGpsPH pLkF5zNl5brXVYXfY2JVOaWS47X6vMorJfzJ6fl8WuyUAU/aba5iKELxh84CuRp2VpQ6 vAryRgIbsxC6iiDyxeaOUtVm+SAN91ZnrHc+sz8ByHD3ml27xuI5hy8j4+1MKumyiHfN 5UzLwMKXsm256M0TJIpDzua5vcY/0CCm7UN7zSUijT0E7GvavseWmg19vTBK9/vERGqx iGh6RFLzEYutNjkuSNqjpEPjnygn8VZZ7OTR3HVQU35b0M0GyqPpU3NRziIvHduw7X9m kUhg== 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=rungzZMHtUGTBk3PE2Ved1AHlxskvVbxWRfwaMawuBY=; b=A4+BikKxMyKmrLmQMLlEUfTHSwIxZsoGnPzyAnUJUCtCwFQemWKW5SlEDVeogBpmgV tg14DaH5cWnzTBcOuwxaFYKcdg2aZxXmaf0geZhZFAxTlB1rwjwYoSJNphqJzx9pO7PU lCdTTk1Y8VFQLuX1KL04WxxsBOzTn16U811RAjgV96LCtcaqWy5lBN93Xvwf5bxBxPVy TMgwXkcTa8i72tqglh33FKxgoOUCSE2tBK2CRyZxlkGucyrDWkuSf7gOwz8YOgz5O0wp 3F9tCI82YQMyW/zts+JuXROCQaTwfaDywaui7FhMGuqunqSxycNgeiYhX7opUXHmbkYE NR2Q== 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 r25si1864439edo.46.2020.07.23.04.47.08; Thu, 23 Jul 2020 04:47:30 -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 S1728617AbgGWLqe (ORCPT + 99 others); Thu, 23 Jul 2020 07:46:34 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:3550 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWLqd (ORCPT ); Thu, 23 Jul 2020 07:46:33 -0400 IronPort-SDR: RJG1xERsJG8YQ1Y/d6EGWuKKoxg6brdsgOlmzVu5LeYDgm53YL3XWVSE0H93f88cFq9OGpiUQi 4hCIWwK6fa14hDOMBc5X15NC/E5SmbA5YIw0wnWcrGo7Z523v+M7Hmt3a4Bu5OBuFeavt//MnE GdVgui8pbAC1vQKApRTxl0jfjCEmTCStMiAzi0aoHT8peCQj2yVcIJfxKQ4nsEZRAAH3ht9SiQ +zNJwhdEUw4Zjdzn9alEaqIoJSsvZKsgjpbqrMmRfVqlaCk4LwTW8QZmLm6m01wAkmlLQPQw4A 5+E= X-IronPort-AV: E=Sophos;i="5.75,386,1589266800"; d="scan'208";a="29048251" Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by labrats.qualcomm.com with ESMTP; 23 Jul 2020 04:46:34 -0700 Received: from pacamara-linux.qualcomm.com ([192.168.140.135]) by ironmsg05-sd.qualcomm.com with ESMTP; 23 Jul 2020 04:46:32 -0700 Received: by pacamara-linux.qualcomm.com (Postfix, from userid 359480) id ACA0622E23; Thu, 23 Jul 2020 04:46:32 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, sh425.lee@samsung.com, 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 v6 1/8] scsi: ufs: Add checks before setting clk-gating states Date: Thu, 23 Jul 2020 04:46:19 -0700 Message-Id: <1595504787-19429-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595504787-19429-1-git-send-email-cang@codeaurora.org> References: <1595504787-19429-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 --- 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 cdff7e5..99bd3e4 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]; @@ -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.