From 14dd90ab373968d35234c2654251d8f37a24c580 Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Fri, 25 Jun 2021 16:55:47 +0530 Subject: [PATCH] ANDROID: scsi: ufs: Add hook to influence the UFS clock scaling policy Add a vendor hook in ufshcd_devfreq_target() to allow vendor modules to influence the UFS clock scaling policy. Bug: 192050146 Change-Id: Ice3e629e132460d240e07c2eba01307317d5aeca Signed-off-by: Nitin Rawat Signed-off-by: Sahitya Tummala --- drivers/android/vendor_hooks.c | 1 + drivers/scsi/ufs/ufshcd.c | 7 ++++++- include/trace/hooks/ufshcd.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index fd57c2ed2fb0..0abcc76269c3 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -207,6 +207,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_uic_command); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_tm_command); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_check_int_errors); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_update_sdev); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_clock_scaling); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_wake_up_sync); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_wake_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_eff_get); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a39aa555b0c2..9c444cb50e58 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1288,6 +1288,8 @@ static int ufshcd_devfreq_target(struct device *dev, struct list_head *clk_list = &hba->clk_list_head; struct ufs_clk_info *clki; unsigned long irq_flags; + bool force_out = false; + bool force_scaling = false; if (!ufshcd_is_clkscaling_supported(hba)) return -EINVAL; @@ -1313,8 +1315,11 @@ static int ufshcd_devfreq_target(struct device *dev, scale_up = (*freq == clki->max_freq) ? true : false; if (!scale_up) *freq = clki->min_freq; + + trace_android_vh_ufs_clock_scaling(hba, &force_out, &force_scaling, &scale_up); + /* Update the frequency */ - if (!ufshcd_is_devfreq_scaling_required(hba, scale_up)) { + if (force_out || (!force_scaling && !ufshcd_is_devfreq_scaling_required(hba, scale_up))) { spin_unlock_irqrestore(hba->host->host_lock, irq_flags); ret = 0; goto out; /* no state change required */ diff --git a/include/trace/hooks/ufshcd.h b/include/trace/hooks/ufshcd.h index 6e37044eb264..362723ff50f2 100644 --- a/include/trace/hooks/ufshcd.h +++ b/include/trace/hooks/ufshcd.h @@ -55,6 +55,9 @@ DECLARE_HOOK(android_vh_ufs_update_sdev, TP_PROTO(struct scsi_device *sdev), TP_ARGS(sdev)); +DECLARE_HOOK(android_vh_ufs_clock_scaling, + TP_PROTO(struct ufs_hba *hba, bool *force_out, bool *force_scaling, bool *scale_up), + TP_ARGS(hba, force_out, force_scaling, scale_up)); #endif /* _TRACE_HOOK_UFSHCD_H */ /* This part must be outside protection */ #include