Skip to content

Commit 0c09815

Browse files
subhashj@codeaurora.orggregkh
authored andcommitted
scsi: ufs: add capability to keep auto bkops always enabled
[ Upstream commit 4e768e7645ec4ffa92ee163643777b261ae97142 ] 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: Sahitya Tummala <stummala@codeaurora.org> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 469e75d commit 0c09815

2 files changed

Lines changed: 35 additions & 11 deletions

File tree

drivers/scsi/ufs/ufshcd.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,18 +3340,25 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba)
33403340
}
33413341

33423342
/**
3343-
* ufshcd_force_reset_auto_bkops - force enable of auto bkops
3343+
* ufshcd_force_reset_auto_bkops - force reset auto bkops state
33443344
* @hba: per adapter instance
33453345
*
33463346
* After a device reset the device may toggle the BKOPS_EN flag
33473347
* to default value. The s/w tracking variables should be updated
3348-
* as well. Do this by forcing enable of auto bkops.
3348+
* as well. This function would change the auto-bkops state based on
3349+
* UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND.
33493350
*/
3350-
static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
3351+
static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
33513352
{
3352-
hba->auto_bkops_enabled = false;
3353-
hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
3354-
ufshcd_enable_auto_bkops(hba);
3353+
if (ufshcd_keep_autobkops_enabled_except_suspend(hba)) {
3354+
hba->auto_bkops_enabled = false;
3355+
hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
3356+
ufshcd_enable_auto_bkops(hba);
3357+
} else {
3358+
hba->auto_bkops_enabled = true;
3359+
hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS;
3360+
ufshcd_disable_auto_bkops(hba);
3361+
}
33553362
}
33563363

33573364
static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status)
@@ -5149,11 +5156,15 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
51495156
goto set_old_link_state;
51505157
}
51515158

5152-
/*
5153-
* If BKOPs operations are urgently needed at this moment then
5154-
* keep auto-bkops enabled or else disable it.
5155-
*/
5156-
ufshcd_urgent_bkops(hba);
5159+
if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
5160+
ufshcd_enable_auto_bkops(hba);
5161+
else
5162+
/*
5163+
* If BKOPs operations are urgently needed at this moment then
5164+
* keep auto-bkops enabled or else disable it.
5165+
*/
5166+
ufshcd_urgent_bkops(hba);
5167+
51575168
hba->clk_gating.is_suspended = false;
51585169

51595170
if (ufshcd_is_clkscaling_enabled(hba))

drivers/scsi/ufs/ufshcd.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,14 @@ struct ufs_hba {
528528
* CAUTION: Enabling this might reduce overall UFS throughput.
529529
*/
530530
#define UFSHCD_CAP_INTR_AGGR (1 << 4)
531+
/*
532+
* This capability allows the device auto-bkops to be always enabled
533+
* except during suspend (both runtime and suspend).
534+
* Enabling this capability means that device will always be allowed
535+
* to do background operation when it's active but it might degrade
536+
* the performance of ongoing read/write operations.
537+
*/
538+
#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
531539

532540
struct devfreq *devfreq;
533541
struct ufs_clk_scaling clk_scaling;
@@ -623,6 +631,11 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)
623631
BUG_ON(!hba);
624632
return hba->priv;
625633
}
634+
static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
635+
struct ufs_hba *hba)
636+
{
637+
return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
638+
}
626639

627640
extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
628641
extern int ufshcd_runtime_resume(struct ufs_hba *hba);

0 commit comments

Comments
 (0)