linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Asutosh Das (asd)" <asutoshd@codeaurora.org>
To: Can Guo <cang@codeaurora.org>
Cc: 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,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Bean Huo <beanhuo@micron.com>,
	Stanley Chu <stanley.chu@mediatek.com>,
	Tomas Winkler <tomas.winkler@intel.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Satya Tangirala <satyat@google.com>,
	open list <linux-kernel@vger.kernel.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-arm-kernel@lists.infradead.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v3 1/2] scsi: ufs: Refactor ufshcd_setup_clocks() to remove skip_ref_clk
Date: Tue, 1 Dec 2020 08:47:09 -0800	[thread overview]
Message-ID: <2e27f15a-988a-fb08-9c51-913a542b7399@codeaurora.org> (raw)
In-Reply-To: <81ac4e5b5974cd7a21f18bf4e74213e9@codeaurora.org>

On 11/30/2020 7:11 PM, Can Guo wrote:
> On 2020-12-01 07:01, Asutosh Das (asd) wrote:
>> On 11/25/2020 6:01 PM, Can Guo wrote:
>>> 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.
>>>
>>> Reviewed-by: Hongwu Su<hongwus@codeaurora.org>
>>> Reviewed-by: Bean Huo <beanhuo@micron.com>
>>> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
>>> Signed-off-by: Can Guo <cang@codeaurora.org>
>>> ---
>>>   drivers/scsi/ufs/ufshcd-pltfrm.c |  2 ++
>>>   drivers/scsi/ufs/ufshcd.c        | 29 +++++++++--------------------
>>>   drivers/scsi/ufs/ufshcd.h        |  3 +++
>>>   3 files changed, 14 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c 
>>> b/drivers/scsi/ufs/ufshcd-pltfrm.c
>>> index 3db0af6..873ef14 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->keep_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..44254c9 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,12 @@ 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"))
>>> +            /*
>>> +             * Don't disable clocks which are needed
>>> +             * to keep the link active.
>>> +             */
>>> +            if (ufshcd_is_link_active(hba) &&
>>> +                clki->keep_link_active)
>>>                   continue;
>>>                 clk_state_changed = on ^ clki->enabled;
>>> @@ -8054,11 +8052,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 +8570,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..6f0f2d4 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
>>> + * @keep_link_active: indicates that the clk should not be disabled if
>>> +              link is 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 keep_link_active;
>>
>> Nitpick - How about 'always-on' instead of 'keep_link_active'?
> 
> Hi Asutosh,
> 
> But it is not always-on, during suspend, it is on when rpm/spm-lvl is 1
> and 2, off when rpm/spm-lvl is 3, 4 and 5, depending on the link state.
> 

Understood & agree.


> Thanks,
> 
> Can Guo.
> 
>>>       bool enabled;
>>>   };
>>>


-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
Linux Foundation Collaborative Project

  reply	other threads:[~2020-12-01 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1606356063-38380-1-git-send-email-cang@codeaurora.org>
2020-11-26  2:01 ` [PATCH v3 1/2] scsi: ufs: Refactor ufshcd_setup_clocks() to remove skip_ref_clk Can Guo
2020-11-30 23:01   ` Asutosh Das (asd)
2020-12-01  3:11     ` Can Guo
2020-12-01 16:47       ` Asutosh Das (asd) [this message]
2020-11-26  2:01 ` [PATCH v3 2/2] scsi: ufs-qcom: Keep core_clk_unipro ON while link is active Can Guo
2020-12-01  2:36   ` Asutosh Das (asd)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e27f15a-988a-fb08-9c51-913a542b7399@codeaurora.org \
    --to=asutoshd@codeaurora.org \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=hongwus@codeaurora.org \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-team@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthias.bgg@gmail.com \
    --cc=nguyenb@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=salyzyn@google.com \
    --cc=saravanak@google.com \
    --cc=satyat@google.com \
    --cc=stanley.chu@mediatek.com \
    --cc=tomas.winkler@intel.com \
    --cc=ziqichen@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).