From: Naresh Maramaina <quic_mnaresh@quicinc.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Peter Wang <peter.wang@mediatek.com>,
"Andy Gross" <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
"Konrad Dybcio" <konrad.dybcio@linaro.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
<chu.stanley@gmail.com>, Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
Bart Van Assche <bvanassche@acm.org>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>,
<linux-arm-msm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <quic_cang@quicinc.com>,
<quic_nguyenb@quicinc.com>,
Nitin Rawat <quic_nitirawa@quicinc.com>
Subject: Re: [PATCH V2 1/3] ufs: core: Add CPU latency QoS support for ufs driver
Date: Thu, 7 Dec 2023 16:56:44 +0530 [thread overview]
Message-ID: <090f3c8c-bbd8-4036-aaa1-d18c7a854ee9@quicinc.com> (raw)
In-Reply-To: <20231206152646.GH12802@thinkpad>
On 12/6/2023 8:56 PM, Manivannan Sadhasivam wrote:
> On Mon, Dec 04, 2023 at 08:00:59PM +0530, Maramaina Naresh wrote:
>> Register ufs driver to CPU latency PM QoS framework can improves
>> ufs device random io performance.
>>
>> PM QoS initialization will insert new QoS request into the CPU
>> latency QoS list with the maximum latency PM_QOS_DEFAULT_VALUE
>> value.
>>
>> UFS driver will vote for performance mode on scale up and power
>> save mode for scale down.
>>
>> If clock scaling feature is not enabled then voting will be based
>> on clock on or off condition.
>>
>> tiotest benchmark tool io performance results on sm8550 platform:
>>
>> 1. Without PM QoS support
>> Type (Speed in) | Average of 18 iterations
>> Random Write(IPOS) | 41065.13
>> Random Read(IPOS) | 37101.3
>>
>> 2. With PM QoS support
>> Type (Speed in) | Average of 18 iterations
>> Random Write(IPOS) | 46784.9
>> Random Read(IPOS) | 42943.4
>> (Improvement % with PM QoS = ~15%).
>>
>> Co-developed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
>> Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
>> Signed-off-by: Naveen Kumar Goud Arepalli <quic_narepall@quicinc.com>
>> Signed-off-by: Maramaina Naresh <quic_mnaresh@quicinc.com>
>> ---
>> drivers/ufs/core/ufshcd-priv.h | 8 +++++
>> drivers/ufs/core/ufshcd.c | 62 ++++++++++++++++++++++++++++++++++
>> include/ufs/ufshcd.h | 16 +++++++++
>> 3 files changed, 86 insertions(+)
>>
>> diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
>> index f42d99ce5bf1..536805f6c4e1 100644
>> --- a/drivers/ufs/core/ufshcd-priv.h
>> +++ b/drivers/ufs/core/ufshcd-priv.h
>> @@ -241,6 +241,14 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
>> hba->vops->config_scaling_param(hba, p, data);
>> }
>>
>> +static inline u32 ufshcd_vops_config_qos_vote(struct ufs_hba *hba)
>> +{
>> + if (hba->vops && hba->vops->config_qos_vote)
>> + return hba->vops->config_qos_vote(hba);
>
> Please remove this callback as Bart noted.
>
Sure Mani, will takecare of this comment.
>> +
>> + return UFSHCD_QOS_DEFAULT_VOTE;
>> +}
>> +
>> static inline void ufshcd_vops_reinit_notify(struct ufs_hba *hba)
>> {
>> if (hba->vops && hba->vops->reinit_notify)
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index ae9936fc6ffb..13370febd2b5 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -1001,6 +1001,20 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba)
>> return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
>> }
>>
>> +/**
>> + * ufshcd_pm_qos_perf - vote for PM QoS performance or power save mode
>
> ufshcd_pm_qos_update() - Update PM QoS request
>
Sure Mani, will takecare of this comment.
>> + * @hba: per adapter instance
>> + * @on: If True, vote for perf PM QoS mode otherwise power save mode
>> + */
>> +static void ufshcd_pm_qos_perf(struct ufs_hba *hba, bool on)
>> +{
>> + if (!hba->pm_qos_init)
>> + return;
>> +
>> + cpu_latency_qos_update_request(&hba->pm_qos_req, on ? hba->qos_vote
>> + : PM_QOS_DEFAULT_VALUE);
>> +}
>> +
>> /**
>> * ufshcd_set_clk_freq - set UFS controller clock frequencies
>> * @hba: per adapter instance
>> @@ -1153,6 +1167,10 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq,
>> trace_ufshcd_profile_clk_scaling(dev_name(hba->dev),
>> (scale_up ? "up" : "down"),
>> ktime_to_us(ktime_sub(ktime_get(), start)), ret);
>> +
>> + if (!ret)
>> + ufshcd_pm_qos_perf(hba, scale_up);
>
> Can't you just move this before trace_ufshcd_profile_clk_scaling()? This also
> avoids checking for !ret.
>
In this case, we need to use goto out; inside if(ret) of
ufshcd_vops_clk_scale_notify.
will do the above change, to enable ufshcd_pm_qos_perf before the out flag.
>> +
>> return ret;
>> }
>>
>> @@ -9204,6 +9222,8 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on)
>> if (ret)
>> return ret;
>>
>> + if (!ufshcd_is_clkscaling_supported(hba))
>> + ufshcd_pm_qos_perf(hba, on);
>> out:
>> if (ret) {
>> list_for_each_entry(clki, head, list) {
>> @@ -9296,6 +9316,45 @@ static int ufshcd_init_clocks(struct ufs_hba *hba)
>> return ret;
>> }
>>
>> +/**
>> + * ufshcd_pm_qos_init - initialize PM QoS instance
>
> "Initialize PM QoS request"
>
Sure Mani, will takecare of this comment.
>> + * @hba: per adapter instance
>> + */
>> +static void ufshcd_pm_qos_init(struct ufs_hba *hba)
>> +{
>> + if (!(hba->caps & UFSHCD_CAP_PM_QOS))
>> + return;
>> +
>> + /*
>> + * called to configure PM QoS vote value for UFS host,
>> + * expecting qos vote return value from caller else
>> + * default vote value will be return.
>> + */
>> + hba->qos_vote = ufshcd_vops_config_qos_vote(hba);
>
> No need of this variable too if you get rid of the callback.
>
>> + cpu_latency_qos_add_request(&hba->pm_qos_req,
>> + PM_QOS_DEFAULT_VALUE);
>> +
>> + if (cpu_latency_qos_request_active(&hba->pm_qos_req))
>> + hba->pm_qos_init = true;
>
> Why do you need this flag?
this flag ensure UFS qos request got added into the Global PM QoS list.
>
>> +
>> + dev_dbg(hba->dev, "%s: QoS %s, qos_vote: %u\n", __func__,
>> + hba->pm_qos_init ? "initialized" : "uninitialized",
>> + hba->qos_vote);
>> +}
>> +
>> +/**
>> + * ufshcd_pm_qos_exit - remove instance from PM QoS
>> + * @hba: per adapter instance
>> + */
>> +static void ufshcd_pm_qos_exit(struct ufs_hba *hba)
>> +{
>> + if (!hba->pm_qos_init)
>> + return;
>> +
>> + cpu_latency_qos_remove_request(&hba->pm_qos_req);
>> + hba->pm_qos_init = false;
>> +}
>> +
>
> [...]
>
>> /**
>> * struct ufs_hba - per adapter private structure
>> * @mmio_base: UFSHCI base register address
>> @@ -912,6 +923,8 @@ enum ufshcd_mcq_opr {
>> * @mcq_base: Multi circular queue registers base address
>> * @uhq: array of supported hardware queues
>> * @dev_cmd_queue: Queue for issuing device management commands
>> + * @pm_qos_req: PM QoS request handle
>> + * @pm_qos_init: flag to check if pm qos init completed
>> */
>> struct ufs_hba {
>> void __iomem *mmio_base;
>> @@ -1076,6 +1089,9 @@ struct ufs_hba {
>> struct ufs_hw_queue *uhq;
>> struct ufs_hw_queue *dev_cmd_queue;
>> struct ufshcd_mcq_opr_info_t mcq_opr[OPR_MAX];
>> + struct pm_qos_request pm_qos_req;
>> + bool pm_qos_init;
>> + u32 qos_vote;
>
> Order doesn't match Kdoc.
>
we are removing qos_vote variable in next patch series.
> - Mani
>
Thanks,
Naresh.
next prev parent reply other threads:[~2023-12-07 11:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 14:30 [PATCH V2 0/3] Add CPU latency QoS support for ufs driver Maramaina Naresh
2023-12-04 14:30 ` [PATCH V2 1/3] ufs: core: " Maramaina Naresh
2023-12-04 19:00 ` Bart Van Assche
2023-12-05 5:58 ` Naresh Maramaina
2023-12-05 17:11 ` Bart Van Assche
2023-12-06 14:02 ` Naresh Maramaina
2023-12-06 15:32 ` Manivannan Sadhasivam
2023-12-07 1:02 ` Bart Van Assche
2023-12-07 9:43 ` Manivannan Sadhasivam
2023-12-07 10:26 ` Nitin Rawat
2023-12-07 11:21 ` Manivannan Sadhasivam
2023-12-11 10:00 ` Pavan Kondeti
2023-12-06 15:26 ` Manivannan Sadhasivam
2023-12-07 11:26 ` Naresh Maramaina [this message]
2023-12-11 9:56 ` Naresh Maramaina
2023-12-04 14:31 ` [PATCH V2 2/3] ufs: ufs-mediatek: Enable CPU latency PM QoS support for MEDIATEK SoC Maramaina Naresh
2023-12-04 14:31 ` [PATCH V2 3/3] ufs: ufs-qcom: Enable CPU latency QoS support for QCOM SoC Maramaina Naresh
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=090f3c8c-bbd8-4036-aaa1-d18c7a854ee9@quicinc.com \
--to=quic_mnaresh@quicinc.com \
--cc=agross@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=chu.stanley@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=peter.wang@mediatek.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
/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