Commit 4e768e76 authored by subhashj@codeaurora.org's avatar subhashj@codeaurora.org Committed by Martin K. Petersen

scsi: ufs: add capability to keep auto bkops always enabled

UFS device requires to perform bkops (back ground operations) periodically
but host can control (via auto-bkops parameter of device) when device can
perform bkops based on its performance requirements. In general, host
would like to enable the device's auto-bkops only when it's not doing any
regular data transfer but sometimes device may not behave properly if host
keeps the auto-bkops disabled. This change adds the capability to let the
device auto-bkops always enabled except suspend.
Reviewed-by: default avatarSahitya Tummala <stummala@codeaurora.org>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 0c8f7586
...@@ -4134,18 +4134,25 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) ...@@ -4134,18 +4134,25 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba)
} }
/** /**
* ufshcd_force_reset_auto_bkops - force enable of auto bkops * ufshcd_force_reset_auto_bkops - force reset auto bkops state
* @hba: per adapter instance * @hba: per adapter instance
* *
* After a device reset the device may toggle the BKOPS_EN flag * After a device reset the device may toggle the BKOPS_EN flag
* to default value. The s/w tracking variables should be updated * to default value. The s/w tracking variables should be updated
* as well. Do this by forcing enable of auto bkops. * as well. This function would change the auto-bkops state based on
* UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND.
*/ */
static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba) static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
{ {
hba->auto_bkops_enabled = false; if (ufshcd_keep_autobkops_enabled_except_suspend(hba)) {
hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS; hba->auto_bkops_enabled = false;
ufshcd_enable_auto_bkops(hba); hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
ufshcd_enable_auto_bkops(hba);
} else {
hba->auto_bkops_enabled = true;
hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS;
ufshcd_disable_auto_bkops(hba);
}
} }
static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status) static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status)
...@@ -6564,11 +6571,15 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) ...@@ -6564,11 +6571,15 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
goto set_old_link_state; goto set_old_link_state;
} }
/* if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
* If BKOPs operations are urgently needed at this moment then ufshcd_enable_auto_bkops(hba);
* keep auto-bkops enabled or else disable it. else
*/ /*
ufshcd_urgent_bkops(hba); * If BKOPs operations are urgently needed at this moment then
* keep auto-bkops enabled or else disable it.
*/
ufshcd_urgent_bkops(hba);
hba->clk_gating.is_suspended = false; hba->clk_gating.is_suspended = false;
if (hba->clk_scaling.is_allowed) if (hba->clk_scaling.is_allowed)
......
...@@ -566,6 +566,14 @@ struct ufs_hba { ...@@ -566,6 +566,14 @@ struct ufs_hba {
* CAUTION: Enabling this might reduce overall UFS throughput. * CAUTION: Enabling this might reduce overall UFS throughput.
*/ */
#define UFSHCD_CAP_INTR_AGGR (1 << 4) #define UFSHCD_CAP_INTR_AGGR (1 << 4)
/*
* This capability allows the device auto-bkops to be always enabled
* except during suspend (both runtime and suspend).
* Enabling this capability means that device will always be allowed
* to do background operation when it's active but it might degrade
* the performance of ongoing read/write operations.
*/
#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
struct devfreq *devfreq; struct devfreq *devfreq;
struct ufs_clk_scaling clk_scaling; struct ufs_clk_scaling clk_scaling;
...@@ -663,6 +671,11 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba) ...@@ -663,6 +671,11 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)
BUG_ON(!hba); BUG_ON(!hba);
return hba->priv; return hba->priv;
} }
static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
struct ufs_hba *hba)
{
return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
}
extern int ufshcd_runtime_suspend(struct ufs_hba *hba); extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
extern int ufshcd_runtime_resume(struct ufs_hba *hba); extern int ufshcd_runtime_resume(struct ufs_hba *hba);
......
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