Commit 49615ba1 authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: override auto suspend tunables for ufs

Rework from previous work by:
Sujit Reddy Thumma <sthumma@codeaurora.org>

Override auto suspend tunables for UFS device LUNs during initialization so
as to efficiently manage background operations and the power consumption.

Link: https://lore.kernel.org/r/1568649411-5127-3-git-send-email-stanley.chu@mediatek.comReviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c74f8056
...@@ -88,6 +88,9 @@ ...@@ -88,6 +88,9 @@
/* Interrupt aggregation default timeout, unit: 40us */ /* Interrupt aggregation default timeout, unit: 40us */
#define INT_AGGR_DEF_TO 0x02 #define INT_AGGR_DEF_TO 0x02
/* default delay of autosuspend: 2000 ms */
#define RPM_AUTOSUSPEND_DELAY_MS 2000
#define ufshcd_toggle_vreg(_dev, _vreg, _on) \ #define ufshcd_toggle_vreg(_dev, _vreg, _on) \
({ \ ({ \
int _ret; \ int _ret; \
...@@ -4631,9 +4634,14 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) ...@@ -4631,9 +4634,14 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth)
*/ */
static int ufshcd_slave_configure(struct scsi_device *sdev) static int ufshcd_slave_configure(struct scsi_device *sdev)
{ {
struct ufs_hba *hba = shost_priv(sdev->host);
struct request_queue *q = sdev->request_queue; struct request_queue *q = sdev->request_queue;
blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1); blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
if (ufshcd_is_rpm_autosuspend_allowed(hba))
sdev->rpm_autosuspend = 1;
return 0; return 0;
} }
...@@ -7069,6 +7077,7 @@ static struct scsi_host_template ufshcd_driver_template = { ...@@ -7069,6 +7077,7 @@ static struct scsi_host_template ufshcd_driver_template = {
.track_queue_depth = 1, .track_queue_depth = 1,
.sdev_groups = ufshcd_driver_groups, .sdev_groups = ufshcd_driver_groups,
.dma_boundary = PAGE_SIZE - 1, .dma_boundary = PAGE_SIZE - 1,
.rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS,
}; };
static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
......
...@@ -716,6 +716,12 @@ struct ufs_hba { ...@@ -716,6 +716,12 @@ struct ufs_hba {
* the performance of ongoing read/write operations. * the performance of ongoing read/write operations.
*/ */
#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5) #define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
/*
* This capability allows host controller driver to automatically
* enable runtime power management by itself instead of waiting
* for userspace to control the power management.
*/
#define UFSHCD_CAP_RPM_AUTOSUSPEND (1 << 6)
struct devfreq *devfreq; struct devfreq *devfreq;
struct ufs_clk_scaling clk_scaling; struct ufs_clk_scaling clk_scaling;
...@@ -749,6 +755,10 @@ static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba) ...@@ -749,6 +755,10 @@ static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba)
{ {
return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND; return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND;
} }
static inline bool ufshcd_is_rpm_autosuspend_allowed(struct ufs_hba *hba)
{
return hba->caps & UFSHCD_CAP_RPM_AUTOSUSPEND;
}
static inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba) static inline bool ufshcd_is_intr_aggr_allowed(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