Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp987356ybh; Wed, 22 Jul 2020 19:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc6Z69IO4RTnwj5NJLFekKZT9UDn8996KsVAf2jzXorwvhLqVyomP033d2PMQG8YV1NjZG X-Received: by 2002:a05:6402:cb9:: with SMTP id cn25mr2201912edb.247.1595471694248; Wed, 22 Jul 2020 19:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595471694; cv=none; d=google.com; s=arc-20160816; b=k2glU1rvgsztITIFV30ypPIQCycG+yrXgM/KNAUVek0tEzzfpme3UOjeHhqxB/BrIN jZt1OREFMeoOuhOJwg0Mz+4Zrunt4rp5nwLm0YhMwZTkQiuvXe78iBj1Hz4oZLIuLlC1 uWyMK36Fhc8hukO9VFZ8ffvMFBSA6zCCzcxt1t5awP/oL/rFBE8CNHQBgDcmLL410C/j rdbbREjO0A0ouPtoAqOYqpYy+n6o4zFl8XB/dpoFiDMpyPcw6CZo7nhSpndYuAtEF2RC Au6B2URK2V9CzOFxceDtnMVoY94xEqEAkTzxJuEPWr+uckNp1CdRjIJTw05zOb+80+Pa UveA== 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=g8di4bvdxWzqn6tMDU77sfoeo/iTIdp+i7QD4G1EKiE=; b=V2Rq7rO0i450XkWR19DOpsTgKVdNUoUe8fZU9JB1ujv63b08oSvGVoy4CYYLOEK5LH oy5rM2FujoRO0OBpFmsHBXsiUxXrv8PIs4eIjaHcyFKPPIpfZd3HcVZnOaMGpE/hvzC0 4Drv6+31cOBA3DWyConfZm3GOHcYhIeH+GmvJs4StJ9769iJzfs6qb6zUJfzlQmk9n0A VOMHwQaohGhBZY+SqHKhvk26m7BUNGM77ZQdJmK5YaBRcgtSn2X2VmPPyaBShTe4TDKB SsXwxgjRVS24lNsJtwsGZp4KMduFfn42clp0Xg/2gd7Qk4MQJZlC11qfUrWcXlEINKx2 Tlsw== 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 s24si1108818ejd.704.2020.07.22.19.34.31; Wed, 22 Jul 2020 19:34:54 -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 S2387427AbgGWCeT (ORCPT + 99 others); Wed, 22 Jul 2020 22:34:19 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:30244 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728914AbgGWCeS (ORCPT ); Wed, 22 Jul 2020 22:34:18 -0400 IronPort-SDR: qqjSYGIrY03x/nQGQRrWNlzYExV6CSP62+sFb33/m42pf09y+IaRBD/s7CK4ZtTg6kTADtRmGF D05meV1T/2X/vM8xJoP8gDs0ZMgCL6TYo91ChAUcSDj2OarDFKvhZ32BhZjLUUDW129nbUNOCD C5WWZQwcZbwiedctnQgW8UqeUWcjLh2HJHmLXSoTP97t62ie4RcOeA5S2kdyYY1GmlEY/Y54iy /+Exu+p6iJ7jq7Ldu6pRsR3QSPG4HJpM4efsVJMfdOgVmT0phcP9bkGWW5DCgNWjEjpKAk6D7E mZ4= X-IronPort-AV: E=Sophos;i="5.75,385,1589266800"; d="scan'208";a="47229202" Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by labrats.qualcomm.com with ESMTP; 22 Jul 2020 19:34:17 -0700 Received: from pacamara-linux.qualcomm.com ([192.168.140.135]) by ironmsg03-sd.qualcomm.com with ESMTP; 22 Jul 2020 19:34:16 -0700 Received: by pacamara-linux.qualcomm.com (Postfix, from userid 359480) id 7326B22A4D; Wed, 22 Jul 2020 19:34:16 -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 v5 1/9] scsi: ufs: Add checks before setting clk-gating states Date: Wed, 22 Jul 2020 19:34:00 -0700 Message-Id: <1595471649-25675-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595471649-25675-1-git-send-email-cang@codeaurora.org> References: <1595471649-25675-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 --- 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.