Skip to content

Commit 87bd050

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: core: Allow host driver to disable wb toggling during clock scaling
Mediatek UFS does not want to toggle write booster during clock scaling. Permit host driver to disable wb toggling during clock scaling. Introduce a flag UFSHCD_CAP_WB_WITH_CLK_SCALING to decouple WB and clock scaling. UFSHCD_CAP_WB_WITH_CLK_SCALING is only valid when UFSHCD_CAP_CLK_SCALING is set. Just like UFSHCD_CAP_HIBERN8_WITH_CLK_GATING is valid only when UFSHCD_CAP_CLK_GATING set. Set UFSHCD_CAP_WB_WITH_CLK_SCALING for qcom to compatible legacy design at the same time. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Peter Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0f85e74 commit 87bd050

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

drivers/ufs/core/ufs-sysfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr,
225225
unsigned int wb_enable;
226226
ssize_t res;
227227

228-
if (!ufshcd_is_wb_allowed(hba) || ufshcd_is_clkscaling_supported(hba)) {
228+
if (!ufshcd_is_wb_allowed(hba) || (ufshcd_is_clkscaling_supported(hba)
229+
&& ufshcd_enable_wb_if_scaling_up(hba))) {
229230
/*
230231
* If the platform supports UFSHCD_CAP_CLK_SCALING, turn WB
231232
* on/off will be done while clock scaling up/down.

drivers/ufs/core/ufshcd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,11 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
12991299
}
13001300

13011301
/* Enable Write Booster if we have scaled up else disable it */
1302-
downgrade_write(&hba->clk_scaling_lock);
1303-
is_writelock = false;
1304-
ufshcd_wb_toggle(hba, scale_up);
1302+
if (ufshcd_enable_wb_if_scaling_up(hba)) {
1303+
downgrade_write(&hba->clk_scaling_lock);
1304+
is_writelock = false;
1305+
ufshcd_wb_toggle(hba, scale_up);
1306+
}
13051307

13061308
out_unprepare:
13071309
ufshcd_clock_scaling_unprepare(hba, is_writelock);

drivers/ufs/host/ufs-qcom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba)
846846
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
847847

848848
hba->caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING;
849-
hba->caps |= UFSHCD_CAP_CLK_SCALING;
849+
hba->caps |= UFSHCD_CAP_CLK_SCALING | UFSHCD_CAP_WB_WITH_CLK_SCALING;
850850
hba->caps |= UFSHCD_CAP_AUTO_BKOPS_SUSPEND;
851851
hba->caps |= UFSHCD_CAP_WB_EN;
852852
hba->caps |= UFSHCD_CAP_CRYPTO;

include/ufs/ufshcd.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,12 @@ enum ufshcd_caps {
664664
* notification if it is supported by the UFS device.
665665
*/
666666
UFSHCD_CAP_TEMP_NOTIF = 1 << 11,
667+
668+
/*
669+
* Enable WriteBooster when scaling up the clock and disable
670+
* WriteBooster when scaling the clock down.
671+
*/
672+
UFSHCD_CAP_WB_WITH_CLK_SCALING = 1 << 12,
667673
};
668674

669675
struct ufs_hba_variant_params {
@@ -1021,6 +1027,11 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
10211027
return hba->caps & UFSHCD_CAP_WB_EN;
10221028
}
10231029

1030+
static inline bool ufshcd_enable_wb_if_scaling_up(struct ufs_hba *hba)
1031+
{
1032+
return hba->caps & UFSHCD_CAP_WB_WITH_CLK_SCALING;
1033+
}
1034+
10241035
#define ufshcd_writel(hba, val, reg) \
10251036
writel((val), (hba)->mmio_base + (reg))
10261037
#define ufshcd_readl(hba, reg) \

0 commit comments

Comments
 (0)