Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: ufs-mediatek: Fix performance scaling

If clk-scaling is enabled, performance scaling can be bound to the decision
of clk-scaling to avoid unnecessary boosting.

In addition, fix missing initialization of pm-qos request.

Link: https://lore.kernel.org/r/20220802235437.4547-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Peter Wang and committed by
Martin K. Petersen
2873e045 36489357

+14 -4
+14 -4
drivers/ufs/host/ufs-mediatek.c
··· 635 635 boost ? 0 : PM_QOS_DEFAULT_VALUE); 636 636 } 637 637 638 + static void ufs_mtk_scale_perf(struct ufs_hba *hba, bool scale_up) 639 + { 640 + ufs_mtk_boost_crypt(hba, scale_up); 641 + ufs_mtk_boost_pm_qos(hba, scale_up); 642 + } 643 + 638 644 static void ufs_mtk_pwr_ctrl(struct ufs_hba *hba, bool on) 639 645 { 640 646 struct ufs_mtk_host *host = ufshcd_get_variant(hba); ··· 648 642 if (on) { 649 643 phy_power_on(host->mphy); 650 644 ufs_mtk_setup_ref_clk(hba, on); 651 - ufs_mtk_boost_crypt(hba, on); 652 - ufs_mtk_boost_pm_qos(hba, on); 645 + if (!ufshcd_is_clkscaling_supported(hba)) 646 + ufs_mtk_scale_perf(hba, on); 653 647 } else { 654 - ufs_mtk_boost_pm_qos(hba, on); 655 - ufs_mtk_boost_crypt(hba, on); 648 + if (!ufshcd_is_clkscaling_supported(hba)) 649 + ufs_mtk_scale_perf(hba, on); 656 650 ufs_mtk_setup_ref_clk(hba, on); 657 651 phy_power_off(host->mphy); 658 652 } ··· 875 869 ufs_mtk_setup_clocks(hba, true, POST_CHANGE); 876 870 877 871 host->ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER); 872 + 873 + /* Initialize pm-qos request */ 874 + cpu_latency_qos_add_request(&host->pm_qos_req, PM_QOS_DEFAULT_VALUE); 875 + host->pm_qos_init = true; 878 876 879 877 goto out; 880 878