From 6d6afa9d3f8fada34bfa4725d5b3079bccf4cf0b Mon Sep 17 00:00:00 2001 From: Manish Pandey Date: Mon, 15 Jul 2024 13:50:22 +0530 Subject: [PATCH] FROMGIT: scsi: ufs: core: Suspend clk scaling on no request Currently UFS clk scaling is getting suspended only when the clks are scaled down. When high load is generated, a huge amount of latency is added due to scaling up the clk and completing the request post that. Suspending the scaling in its existing state when high load is generated improves the random performance KPI by 28%. So suspending the scaling when there are no requests. And the clk would be put in low scaled state when the actual request load is low. Make this change optional by having the check enabled using vops since for some devices suspending without bringing the clk in low scaled state might have impact on power consumption of the SoC. The change takes advantage of the hole in 'struct ufs_clk_scaling' before ANDROID_KABI_RESERVE and does not change the size of the struct. Use __GENKSYMS__ marker to preserve the abi correctly. Signed-off-by: Ram Prakash Gupta Link: https://lore.kernel.org/r/20240627083756.25340-2-quic_rampraka@quicinc.com Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Bug: 351099319 (cherry picked from commit 50183ac2cfb54e027dd36fb22ea1bd1e91e3a08b https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git 6.11/scsi-staging) Change-Id: I6e11beab7bc56746e7e1ae1ea25f9ab205394ef7 Signed-off-by: Manish Pandey (cherry picked from commit 78931ac60273825b4141796eb8631424b3690712) --- android/abi_gki_aarch64.stg | 7 +++++++ drivers/ufs/core/ufshcd.c | 3 ++- include/ufs/ufshcd.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/android/abi_gki_aarch64.stg b/android/abi_gki_aarch64.stg index 53f70fca4b5a..bd632daa5065 100644 --- a/android/abi_gki_aarch64.stg +++ b/android/abi_gki_aarch64.stg @@ -189224,6 +189224,12 @@ member { type_id: 0x351ca0f0 offset: 64 } +member { + id: 0x0489a9d9 + name: "suspend_on_no_request" + type_id: 0x6d7f5ff6 + offset: 1672 +} member { id: 0x0b4c6d3f name: "suspend_opp" @@ -266594,6 +266600,7 @@ struct_union { member_id: 0xbbefba04 member_id: 0xb768ef54 member_id: 0x2061f6ba + member_id: 0x0489a9d9 member_id: 0x2d081217 } } diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index f91088fd2480..aabea7aaf048 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1503,7 +1503,8 @@ static int ufshcd_devfreq_target(struct device *dev, ktime_to_us(ktime_sub(ktime_get(), start)), ret); out: - if (sched_clk_scaling_suspend_work && !scale_up) + if (sched_clk_scaling_suspend_work && + (!scale_up || hba->clk_scaling.suspend_on_no_request)) queue_work(hba->clk_scaling.workq, &hba->clk_scaling.suspend_work); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 12965946d194..b817bd525a69 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -425,6 +425,7 @@ struct ufs_saved_pwr_info { * @is_initialized: Indicates whether clock scaling is initialized or not * @is_busy_started: tracks if busy period has started or not * @is_suspended: tracks if devfreq is suspended or not + * @suspend_on_no_request: Flag to suspend clk scaling when there is no request */ struct ufs_clk_scaling { int active_reqs; @@ -442,6 +443,10 @@ struct ufs_clk_scaling { bool is_initialized; bool is_busy_started; bool is_suspended; + /* using hole here would not alter the overall size of the structure. */ +#ifndef __GENKSYMS__ + bool suspend_on_no_request; +#endif ANDROID_KABI_RESERVE(1); };