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

scsi: ufs: ufs-mediatek: Support performance boosting

Add pm-qos request to support performance boosting in MediaTek UFS
platforms.

At the same time, adjust the order of function calls to be symmetric during
the low-power control flow.

Link: https://lore.kernel.org/r/20220623035052.18802-8-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
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
c64c487d 2cf5cb2b

+29 -8
+26 -8
drivers/ufs/host/ufs-mediatek.c
··· 16 16 #include <linux/of_device.h> 17 17 #include <linux/phy/phy.h> 18 18 #include <linux/platform_device.h> 19 + #include <linux/pm_qos.h> 19 20 #include <linux/regulator/consumer.h> 20 21 #include <linux/reset.h> 21 22 #include <linux/sched/clock.h> ··· 587 586 dev_info(hba->dev, "caps: 0x%x", host->caps); 588 587 } 589 588 590 - static void ufs_mtk_scale_perf(struct ufs_hba *hba, bool up) 589 + static void ufs_mtk_boost_pm_qos(struct ufs_hba *hba, bool boost) 591 590 { 592 591 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 593 592 594 - ufs_mtk_boost_crypt(hba, up); 595 - ufs_mtk_setup_ref_clk(hba, up); 593 + if (!host || !host->pm_qos_init) 594 + return; 596 595 597 - if (up) 596 + cpu_latency_qos_update_request(&host->pm_qos_req, 597 + boost ? 0 : PM_QOS_DEFAULT_VALUE); 598 + } 599 + 600 + static void ufs_mtk_pwr_ctrl(struct ufs_hba *hba, bool on) 601 + { 602 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 603 + 604 + if (on) { 598 605 phy_power_on(host->mphy); 599 - else 606 + ufs_mtk_setup_ref_clk(hba, on); 607 + ufs_mtk_boost_crypt(hba, on); 608 + ufs_mtk_boost_pm_qos(hba, on); 609 + } else { 610 + ufs_mtk_boost_pm_qos(hba, on); 611 + ufs_mtk_boost_crypt(hba, on); 612 + ufs_mtk_setup_ref_clk(hba, on); 600 613 phy_power_off(host->mphy); 614 + } 601 615 } 602 616 603 617 /** ··· 657 641 } 658 642 659 643 if (clk_pwr_off) 660 - ufs_mtk_scale_perf(hba, false); 644 + ufs_mtk_pwr_ctrl(hba, false); 661 645 } else if (on && status == POST_CHANGE) { 662 - ufs_mtk_scale_perf(hba, true); 646 + ufs_mtk_pwr_ctrl(hba, true); 663 647 } 664 648 665 649 return ret; ··· 1264 1248 struct ufs_dev_info *dev_info = &hba->dev_info; 1265 1249 u16 mid = dev_info->wmanufacturerid; 1266 1250 1267 - if (mid == UFS_VENDOR_SAMSUNG) 1251 + if (mid == UFS_VENDOR_SAMSUNG) { 1268 1252 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6); 1253 + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), 10); 1254 + } 1269 1255 1270 1256 /* 1271 1257 * Decide waiting time before gating reference clock and
+3
drivers/ufs/host/ufs-mediatek.h
··· 7 7 #define _UFS_MEDIATEK_H 8 8 9 9 #include <linux/bitops.h> 10 + #include <linux/pm_qos.h> 10 11 #include <linux/soc/mediatek/mtk_sip_svc.h> 11 12 12 13 /* ··· 132 131 133 132 struct ufs_mtk_host { 134 133 struct phy *mphy; 134 + struct pm_qos_request pm_qos_req; 135 135 struct regulator *reg_va09; 136 136 struct reset_control *hci_reset; 137 137 struct reset_control *unipro_reset; ··· 142 140 struct ufs_mtk_hw_ver hw_ver; 143 141 enum ufs_mtk_host_caps caps; 144 142 bool mphy_powered_on; 143 + bool pm_qos_init; 145 144 bool unipro_lpm; 146 145 bool ref_clk_enabled; 147 146 u16 ref_clk_ungating_wait_us;