From: "Asutosh Das (asd)" <asutoshd@codeaurora.org>
To: Avri Altman <Avri.Altman@wdc.com>,
"cang@codeaurora.org" <cang@codeaurora.org>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: "linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Bean Huo <beanhuo@micron.com>,
Bart Van Assche <bvanassche@acm.org>,
Venkat Gopalakrishnan <venkatg@codeaurora.org>,
Tomas Winkler <tomas.winkler@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 1/3] scsi: ufshcd: Update the set frequency to devfreq
Date: Wed, 25 Mar 2020 09:32:24 -0700 [thread overview]
Message-ID: <3ea137ea-aade-31d8-a374-70c6f0d2dacc@codeaurora.org> (raw)
In-Reply-To: <SN6PR04MB4640BC23D0827886927D302AFCCE0@SN6PR04MB4640.namprd04.prod.outlook.com>
On 3/25/2020 6:11 AM, Avri Altman wrote:
>>
>> Currently, the frequency that devfreq provides the
>> driver to set always leads the clocks to be scaled up.
>> Hence, round the clock-rate to the nearest frequency
>> before deciding to scale.
>>
>> Also update the devfreq statistics of current frequency.
>>
>> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
>> ---
>> drivers/scsi/ufs/ufshcd.c | 14 +++++++++++++-
>> 1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>> index 2a2a63b..4607bc6 100644
>> --- a/drivers/scsi/ufs/ufshcd.c
>> +++ b/drivers/scsi/ufs/ufshcd.c
>> @@ -1187,6 +1187,9 @@ static int ufshcd_devfreq_target(struct device
>> *dev,
>> if (!ufshcd_is_clkscaling_supported(hba))
>> return -EINVAL;
>>
>> + clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, list);
>> + /* Override with the closest supported frequency */
>> + *freq = (unsigned long) clk_round_rate(clki->clk, *freq);
>> spin_lock_irqsave(hba->host->host_lock, irq_flags);
> Please remind me what the spin lock is protecting here?
Hmmm ... Nothing comes to my mind. I blamed it but it's a part of a
bigger change.
>
>> if (ufshcd_eh_in_progress(hba)) {
>> spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
>> @@ -1201,8 +1204,13 @@ static int ufshcd_devfreq_target(struct device
>> *dev,
>> goto out;
>> }
>>
>> - clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, list);
>> + /* Decide based on the rounded-off frequency and update */
>> scale_up = (*freq == clki->max_freq) ? true : false;
>> + if (scale_up)
>> + *freq = clki->max_freq;
> This was already established 2 lines above ?
Good point - I'll change it.
>
>> + else
>> + *freq = clki->min_freq;
>> + /* Update the frequency */
>> if (!ufshcd_is_devfreq_scaling_required(hba, scale_up)) {
>> spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
>> ret = 0;
>> @@ -1250,6 +1258,8 @@ static int ufshcd_devfreq_get_dev_status(struct
>> device *dev,
>> struct ufs_hba *hba = dev_get_drvdata(dev);
>> struct ufs_clk_scaling *scaling = &hba->clk_scaling;
>> unsigned long flags;
>> + struct list_head *clk_list = &hba->clk_list_head;
>> + struct ufs_clk_info *clki;
>>
>> if (!ufshcd_is_clkscaling_supported(hba))
>> return -EINVAL;
>> @@ -1260,6 +1270,8 @@ static int ufshcd_devfreq_get_dev_status(struct
>> device *dev,
>> if (!scaling->window_start_t)
>> goto start_window;
>>
>> + clki = list_first_entry(clk_list, struct ufs_clk_info, list);
>> + stat->current_frequency = clki->curr_freq;
> Is this a bug fix? > devfreq_simple_ondemand_func is trying to establish the busy period,
> but also uses the frequency in its calculation - which I wasn't able to understand how.
> Can you add a short comment why updating current_frequency is needed?
>
Sure - I'll add a comment. If stat->current_frequency is not updated,
the governor would always ask to set the max freq because the initial
frequency was unknown to it. Reference - devfreq_simple_ondemand_func(...)
>
> Thanks,
> Avri
>
Thanks,
-asd
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
Linux Foundation Collaborative Project
prev parent reply other threads:[~2020-03-25 16:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 0:07 Asutosh Das
2020-03-25 0:07 ` [PATCH v1 2/3] scsi: ufshcd: Let vendor override devfreq parameters Asutosh Das
2020-03-25 13:11 ` Avri Altman
2020-03-25 0:07 ` [PATCH v1 3/3] scsi: ufs-qcom: Override " Asutosh Das
2020-03-25 13:11 ` Avri Altman
2020-03-25 13:11 ` [PATCH v1 1/3] scsi: ufshcd: Update the set frequency to devfreq Avri Altman
2020-03-25 16:32 ` Asutosh Das (asd) [this message]
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=3ea137ea-aade-31d8-a374-70c6f0d2dacc@codeaurora.org \
--to=asutoshd@codeaurora.org \
--cc=Avri.Altman@wdc.com \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=cang@codeaurora.org \
--cc=jejb@linux.ibm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stanley.chu@mediatek.com \
--cc=tomas.winkler@intel.com \
--cc=venkatg@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
Powered by JetHome