Commit 29b87e92 authored by Can Guo's avatar Can Guo Committed by Martin K. Petersen

scsi: ufs: Stop hardcoding the scale down gear

Instead of hardcoding the scale down gear, make it a member of
the ufs_clk_scaling struct.

Link: https://lore.kernel.org/r/1606442334-22641-1-git-send-email-cang@codeaurora.orgReviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 96f08cc5
...@@ -1114,7 +1114,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, ...@@ -1114,7 +1114,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
*/ */
static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up)
{ {
#define UFS_MIN_GEAR_TO_SCALE_DOWN UFS_HS_G1
int ret = 0; int ret = 0;
struct ufs_pa_layer_attr new_pwr_info; struct ufs_pa_layer_attr new_pwr_info;
...@@ -1125,16 +1124,16 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) ...@@ -1125,16 +1124,16 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up)
memcpy(&new_pwr_info, &hba->pwr_info, memcpy(&new_pwr_info, &hba->pwr_info,
sizeof(struct ufs_pa_layer_attr)); sizeof(struct ufs_pa_layer_attr));
if (hba->pwr_info.gear_tx > UFS_MIN_GEAR_TO_SCALE_DOWN if (hba->pwr_info.gear_tx > hba->clk_scaling.min_gear ||
|| hba->pwr_info.gear_rx > UFS_MIN_GEAR_TO_SCALE_DOWN) { hba->pwr_info.gear_rx > hba->clk_scaling.min_gear) {
/* save the current power mode */ /* save the current power mode */
memcpy(&hba->clk_scaling.saved_pwr_info.info, memcpy(&hba->clk_scaling.saved_pwr_info.info,
&hba->pwr_info, &hba->pwr_info,
sizeof(struct ufs_pa_layer_attr)); sizeof(struct ufs_pa_layer_attr));
/* scale down gear */ /* scale down gear */
new_pwr_info.gear_tx = UFS_MIN_GEAR_TO_SCALE_DOWN; new_pwr_info.gear_tx = hba->clk_scaling.min_gear;
new_pwr_info.gear_rx = UFS_MIN_GEAR_TO_SCALE_DOWN; new_pwr_info.gear_rx = hba->clk_scaling.min_gear;
} }
} }
...@@ -1842,6 +1841,9 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba) ...@@ -1842,6 +1841,9 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba)
if (!ufshcd_is_clkscaling_supported(hba)) if (!ufshcd_is_clkscaling_supported(hba))
return; return;
if (!hba->clk_scaling.min_gear)
hba->clk_scaling.min_gear = UFS_HS_G1;
INIT_WORK(&hba->clk_scaling.suspend_work, INIT_WORK(&hba->clk_scaling.suspend_work,
ufshcd_clk_scaling_suspend_work); ufshcd_clk_scaling_suspend_work);
INIT_WORK(&hba->clk_scaling.resume_work, INIT_WORK(&hba->clk_scaling.resume_work,
......
...@@ -390,6 +390,7 @@ struct ufs_saved_pwr_info { ...@@ -390,6 +390,7 @@ struct ufs_saved_pwr_info {
* @workq: workqueue to schedule devfreq suspend/resume work * @workq: workqueue to schedule devfreq suspend/resume work
* @suspend_work: worker to suspend devfreq * @suspend_work: worker to suspend devfreq
* @resume_work: worker to resume devfreq * @resume_work: worker to resume devfreq
* @min_gear: lowest HS gear to scale down to
* @is_allowed: tracks if scaling is currently allowed or not * @is_allowed: tracks if scaling is currently allowed or not
* @is_busy_started: tracks if busy period has started or not * @is_busy_started: tracks if busy period has started or not
* @is_suspended: tracks if devfreq is suspended or not * @is_suspended: tracks if devfreq is suspended or not
...@@ -404,6 +405,7 @@ struct ufs_clk_scaling { ...@@ -404,6 +405,7 @@ struct ufs_clk_scaling {
struct workqueue_struct *workq; struct workqueue_struct *workq;
struct work_struct suspend_work; struct work_struct suspend_work;
struct work_struct resume_work; struct work_struct resume_work;
u32 min_gear;
bool is_allowed; bool is_allowed;
bool is_busy_started; bool is_busy_started;
bool is_suspended; bool is_suspended;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment