Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1441784pxu; Mon, 23 Nov 2020 23:31:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbn/sAIp2qjZBgTzHfYxF3vIuAaIttAi3VgD3KnPGTAOAQhfp8Q8r9Vpau2AU+Hb4vrrFs X-Received: by 2002:a50:e00f:: with SMTP id e15mr2805716edl.210.1606203101141; Mon, 23 Nov 2020 23:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606203101; cv=none; d=google.com; s=arc-20160816; b=ScVyDeTksrw67ZRVgT7wTMgH0m9UgCYtlPfSUaqezycMUDRgbf+puUvg/xP9TqikpO MNTxScOC20Wrxq2FJBERMKe4PMWuwLv7PL2+9+5MTZk4RrnNDhJHDLzmklGkXloJ8vbw 7UmRQzs+0H9c/Wb5ylcMqF57ysEmXFiQhrnP55UDF5qncoUlOBi7btqY8uiHNz9H1THs jpjWxrmxIOyLlNIK/c26JnCBJmqfetMfquYHZLbyvtNhuTcHq5caADdk1XvAMSQ2HDAv 53vAKNsbC9NtJqLva9S97EC02BMPscfH5Kj9tiNOGK58+z9ent4G4k4SAt3T/0M4wNWb s1MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr; bh=6ypG3rW6X8DeFe0msPJfOEk1hzcdQmipHMkHJBES0vo=; b=qYHtjzQHg/fN+/O0nCCAcFEJeWRYd/SVpGzYxSjiEkFGRnCSsFRvsjISisiDAB3Nns iRRrzX7OrTZsEehX33GJZfLIi5bkavrLtW+46fiPVIgUmrCwfQrQtwkDn2pWczNjK5M9 RzNFpvRjCjCmFybDkWfP/vnazy+dpB4P3pFvR2u73a0JuxGkFNBSxGWbaL+bh2Y4sdSV QqxC6Ft8NeCGUlfJT8+swsIF39NdcueAQTdK2DNM/rmy6KcRqTE1r3VB8eHzquVAS1Qa f/mvBKWEHp6G8A48h02t8dNUdVaRBDDp5rWUfCuaSb8jsduHwCJwgMi8yN1K/hT+KT8G 7wdw== 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 a13si8376337edb.92.2020.11.23.23.31.18; Mon, 23 Nov 2020 23:31:41 -0800 (PST) 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 S1730083AbgKXH2l (ORCPT + 99 others); Tue, 24 Nov 2020 02:28:41 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:1905 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729915AbgKXH2k (ORCPT ); Tue, 24 Nov 2020 02:28:40 -0500 IronPort-SDR: 6OY8T7vt2+VeFjyrZfPs5CtGPxel/V9/om+gizMrETkT9taxkGk6NMmV+gGSIFQToKDxwAOL8t Li2e4HXX5o6QMwh31fi1auHNBLL+ZooUHBjlARCE9nCcBsFGCLmL1/bxR15Y15B7oiqZ6IIfdk +959n42WNMnvYG7JGncw0k6W0PNuVCytEG6DZ5gtw0ktUvarlFZINsDwcwvn53NKUwsPoM/0cy x8XjGC5Vp3XoviLH8UO1HdJH0Hrk6yGlmBOIG8/jKoAF7gqS8PCUO96oRf11W4tZHJF7Jv3yqL N8I= X-IronPort-AV: E=Sophos;i="5.78,365,1599548400"; d="scan'208";a="47507389" Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by labrats.qualcomm.com with ESMTP; 23 Nov 2020 23:28:40 -0800 X-QCInternal: smtphost Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg04-sd.qualcomm.com with ESMTP; 23 Nov 2020 23:28:37 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 6F6AE2185E; Mon, 23 Nov 2020 23:28:37 -0800 (PST) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@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" , Tomas Winkler , Bean Huo , Stanley Chu , Bart Van Assche , Satya Tangirala , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/2] scsi: ufs: Refector ufshcd_setup_clocks() to remove skip_ref_clk Date: Mon, 23 Nov 2020 23:28:25 -0800 Message-Id: <1606202906-14485-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606202906-14485-1-git-send-email-cang@codeaurora.org> References: <1606202906-14485-1-git-send-email-cang@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the param skip_ref_clk from __ufshcd_setup_clocks(), but keep a flag in struct ufs_clk_info to tell whether a clock can be disabled or not while the link is active. Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd-pltfrm.c | 2 ++ drivers/scsi/ufs/ufshcd.c | 25 +++++-------------------- drivers/scsi/ufs/ufshcd.h | 3 +++ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index 3db0af6..39b1f9b 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -92,6 +92,8 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) clki->min_freq = clkfreq[i]; clki->max_freq = clkfreq[i+1]; clki->name = kstrdup(name, GFP_KERNEL); + if (!strcmp(name, "ref_clk")) + clki->always_on_while_link_active = true; dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz", clki->min_freq, clki->max_freq, clki->name); list_add_tail(&clki->list, &hba->clk_list_head); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a7857f6..0802c10 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -221,8 +221,6 @@ static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); static int ufshcd_probe_hba(struct ufs_hba *hba, bool async); -static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, - bool skip_ref_clk); static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba); static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba); @@ -1707,11 +1705,7 @@ static void ufshcd_gate_work(struct work_struct *work) ufshcd_disable_irq(hba); - if (!ufshcd_is_link_active(hba)) - ufshcd_setup_clocks(hba, false); - else - /* If link is active, device ref_clk can't be switched off */ - __ufshcd_setup_clocks(hba, false, true); + ufshcd_setup_clocks(hba, false); /* * In case you are here to cancel this work the gating state @@ -7990,8 +7984,7 @@ static int ufshcd_init_hba_vreg(struct ufs_hba *hba) return 0; } -static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, - bool skip_ref_clk) +static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on) { int ret = 0; struct ufs_clk_info *clki; @@ -8009,7 +8002,8 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, list_for_each_entry(clki, head, list) { if (!IS_ERR_OR_NULL(clki->clk)) { - if (skip_ref_clk && !strcmp(clki->name, "ref_clk")) + if (ufshcd_is_link_active(hba) && + clki->always_on_while_link_active) continue; clk_state_changed = on ^ clki->enabled; @@ -8054,11 +8048,6 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, return ret; } -static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on) -{ - return __ufshcd_setup_clocks(hba, on, false); -} - static int ufshcd_init_clocks(struct ufs_hba *hba) { int ret = 0; @@ -8577,11 +8566,7 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) */ ufshcd_disable_irq(hba); - if (!ufshcd_is_link_active(hba)) - ufshcd_setup_clocks(hba, false); - else - /* If link is active, device ref_clk can't be switched off */ - __ufshcd_setup_clocks(hba, false, true); + ufshcd_setup_clocks(hba, false); if (ufshcd_is_clkgating_allowed(hba)) { hba->clk_gating.state = CLKS_OFF; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 66e5338..a06bdfb 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -229,6 +229,8 @@ struct ufs_dev_cmd { * @max_freq: maximum frequency supported by the clock * @min_freq: min frequency that can be used for clock scaling * @curr_freq: indicates the current frequency that it is set to + * @always_on_while_link_active: indicate that the clk should not be disabled if + link is still active * @enabled: variable to check against multiple enable/disable */ struct ufs_clk_info { @@ -238,6 +240,7 @@ struct ufs_clk_info { u32 max_freq; u32 min_freq; u32 curr_freq; + bool always_on_while_link_active; bool enabled; }; -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.