Hi,
This series simply do some refactoring and cleanups in UFS drivers.
Stanley Chu (9):
scsi: ufs-mediatek: Refactor performance scaling functions
scsi: ufs: Introduce device parameter initialization function
scsi: ufs-mediatek: Use device parameter initialization function
scsi: ufs-qcom: Use device parameter initialization function
scsi: ufs-exynos: Use device parameter initialization function
scsi: ufs-hisi: Use device parameter initialization function
scsi: ufs: Refactor ADAPT configuration function
scsi: ufs-mediatek: Use common ADAPT configuration function
scsi: ufs-qcom: Use common ADAPT configuration function
drivers/scsi/ufs/ufs-exynos.c | 15 +---------
drivers/scsi/ufs/ufs-exynos.h | 13 --------
drivers/scsi/ufs/ufs-hisi.c | 13 +-------
drivers/scsi/ufs/ufs-hisi.h | 13 --------
drivers/scsi/ufs/ufs-mediatek.c | 51 ++++++++++++++------------------
drivers/scsi/ufs/ufs-mediatek.h | 16 ----------
drivers/scsi/ufs/ufs-qcom.c | 27 +++--------------
drivers/scsi/ufs/ufs-qcom.h | 11 -------
drivers/scsi/ufs/ufshcd-pltfrm.c | 17 +++++++++++
drivers/scsi/ufs/ufshcd-pltfrm.h | 1 +
drivers/scsi/ufs/ufshcd.c | 16 ++++++++++
drivers/scsi/ufs/ufshcd.h | 3 ++
12 files changed, 65 insertions(+), 131 deletions(-)
--
2.18.0
Use common device parameter initialization function instead of
initialziing those parameters by vendor driver itself.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-hisi.c | 13 +------------
drivers/scsi/ufs/ufs-hisi.h | 13 -------------
2 files changed, 1 insertion(+), 25 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
index 074a6a055a4c..0aa58131e791 100644
--- a/drivers/scsi/ufs/ufs-hisi.c
+++ b/drivers/scsi/ufs/ufs-hisi.c
@@ -293,18 +293,7 @@ static int ufs_hisi_link_startup_notify(struct ufs_hba *hba,
static void ufs_hisi_set_dev_cap(struct ufs_dev_params *hisi_param)
{
- hisi_param->rx_lanes = UFS_HISI_LIMIT_NUM_LANES_RX;
- hisi_param->tx_lanes = UFS_HISI_LIMIT_NUM_LANES_TX;
- hisi_param->hs_rx_gear = UFS_HISI_LIMIT_HSGEAR_RX;
- hisi_param->hs_tx_gear = UFS_HISI_LIMIT_HSGEAR_TX;
- hisi_param->pwm_rx_gear = UFS_HISI_LIMIT_PWMGEAR_RX;
- hisi_param->pwm_tx_gear = UFS_HISI_LIMIT_PWMGEAR_TX;
- hisi_param->rx_pwr_pwm = UFS_HISI_LIMIT_RX_PWR_PWM;
- hisi_param->tx_pwr_pwm = UFS_HISI_LIMIT_TX_PWR_PWM;
- hisi_param->rx_pwr_hs = UFS_HISI_LIMIT_RX_PWR_HS;
- hisi_param->tx_pwr_hs = UFS_HISI_LIMIT_TX_PWR_HS;
- hisi_param->hs_rate = UFS_HISI_LIMIT_HS_RATE;
- hisi_param->desired_working_mode = UFS_HISI_LIMIT_DESIRED_MODE;
+ ufshcd_init_pwr_dev_param(hisi_param);
}
static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)
diff --git a/drivers/scsi/ufs/ufs-hisi.h b/drivers/scsi/ufs/ufs-hisi.h
index 3231d3d81c98..5a90c0f4e90c 100644
--- a/drivers/scsi/ufs/ufs-hisi.h
+++ b/drivers/scsi/ufs/ufs-hisi.h
@@ -76,19 +76,6 @@ enum {
#define SLOW 1
#define FAST 2
-#define UFS_HISI_LIMIT_NUM_LANES_RX 2
-#define UFS_HISI_LIMIT_NUM_LANES_TX 2
-#define UFS_HISI_LIMIT_HSGEAR_RX UFS_HS_G3
-#define UFS_HISI_LIMIT_HSGEAR_TX UFS_HS_G3
-#define UFS_HISI_LIMIT_PWMGEAR_RX UFS_PWM_G4
-#define UFS_HISI_LIMIT_PWMGEAR_TX UFS_PWM_G4
-#define UFS_HISI_LIMIT_RX_PWR_PWM SLOW_MODE
-#define UFS_HISI_LIMIT_TX_PWR_PWM SLOW_MODE
-#define UFS_HISI_LIMIT_RX_PWR_HS FAST_MODE
-#define UFS_HISI_LIMIT_TX_PWR_HS FAST_MODE
-#define UFS_HISI_LIMIT_HS_RATE PA_HS_MODE_B
-#define UFS_HISI_LIMIT_DESIRED_MODE FAST
-
#define UFS_HISI_CAP_RESERVED BIT(0)
#define UFS_HISI_CAP_PHY10nm BIT(1)
--
2.18.0
Use common device parameter initialization function instead of
initialziing those parameters by vendor driver itself.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-qcom.c | 13 +------------
drivers/scsi/ufs/ufs-qcom.h | 11 -----------
2 files changed, 1 insertion(+), 23 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 357c3b49321d..04adfbd10753 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -691,19 +691,8 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
switch (status) {
case PRE_CHANGE:
- ufs_qcom_cap.tx_lanes = UFS_QCOM_LIMIT_NUM_LANES_TX;
- ufs_qcom_cap.rx_lanes = UFS_QCOM_LIMIT_NUM_LANES_RX;
- ufs_qcom_cap.hs_rx_gear = UFS_QCOM_LIMIT_HSGEAR_RX;
- ufs_qcom_cap.hs_tx_gear = UFS_QCOM_LIMIT_HSGEAR_TX;
- ufs_qcom_cap.pwm_rx_gear = UFS_QCOM_LIMIT_PWMGEAR_RX;
- ufs_qcom_cap.pwm_tx_gear = UFS_QCOM_LIMIT_PWMGEAR_TX;
- ufs_qcom_cap.rx_pwr_pwm = UFS_QCOM_LIMIT_RX_PWR_PWM;
- ufs_qcom_cap.tx_pwr_pwm = UFS_QCOM_LIMIT_TX_PWR_PWM;
- ufs_qcom_cap.rx_pwr_hs = UFS_QCOM_LIMIT_RX_PWR_HS;
- ufs_qcom_cap.tx_pwr_hs = UFS_QCOM_LIMIT_TX_PWR_HS;
+ ufshcd_init_pwr_dev_param(&ufs_qcom_cap);
ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE;
- ufs_qcom_cap.desired_working_mode =
- UFS_QCOM_LIMIT_DESIRED_MODE;
if (host->hw_ver.major == 0x1) {
/*
diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h
index 3f4922743b3e..8208e3a3ef59 100644
--- a/drivers/scsi/ufs/ufs-qcom.h
+++ b/drivers/scsi/ufs/ufs-qcom.h
@@ -27,18 +27,7 @@
#define SLOW 1
#define FAST 2
-#define UFS_QCOM_LIMIT_NUM_LANES_RX 2
-#define UFS_QCOM_LIMIT_NUM_LANES_TX 2
-#define UFS_QCOM_LIMIT_HSGEAR_RX UFS_HS_G3
-#define UFS_QCOM_LIMIT_HSGEAR_TX UFS_HS_G3
-#define UFS_QCOM_LIMIT_PWMGEAR_RX UFS_PWM_G4
-#define UFS_QCOM_LIMIT_PWMGEAR_TX UFS_PWM_G4
-#define UFS_QCOM_LIMIT_RX_PWR_PWM SLOW_MODE
-#define UFS_QCOM_LIMIT_TX_PWR_PWM SLOW_MODE
-#define UFS_QCOM_LIMIT_RX_PWR_HS FAST_MODE
-#define UFS_QCOM_LIMIT_TX_PWR_HS FAST_MODE
#define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B
-#define UFS_QCOM_LIMIT_DESIRED_MODE FAST
/* QCOM UFS host controller vendor specific registers */
enum {
--
2.18.0
Use common device parameter initialization function instead of
initialziing those parameters by vendor driver itself.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-exynos.c | 15 +--------------
drivers/scsi/ufs/ufs-exynos.h | 13 -------------
2 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index 5e6b95dbb578..a8770ff14588 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -617,20 +617,7 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
goto out;
}
-
- ufs_exynos_cap.tx_lanes = UFS_EXYNOS_LIMIT_NUM_LANES_TX;
- ufs_exynos_cap.rx_lanes = UFS_EXYNOS_LIMIT_NUM_LANES_RX;
- ufs_exynos_cap.hs_rx_gear = UFS_EXYNOS_LIMIT_HSGEAR_RX;
- ufs_exynos_cap.hs_tx_gear = UFS_EXYNOS_LIMIT_HSGEAR_TX;
- ufs_exynos_cap.pwm_rx_gear = UFS_EXYNOS_LIMIT_PWMGEAR_RX;
- ufs_exynos_cap.pwm_tx_gear = UFS_EXYNOS_LIMIT_PWMGEAR_TX;
- ufs_exynos_cap.rx_pwr_pwm = UFS_EXYNOS_LIMIT_RX_PWR_PWM;
- ufs_exynos_cap.tx_pwr_pwm = UFS_EXYNOS_LIMIT_TX_PWR_PWM;
- ufs_exynos_cap.rx_pwr_hs = UFS_EXYNOS_LIMIT_RX_PWR_HS;
- ufs_exynos_cap.tx_pwr_hs = UFS_EXYNOS_LIMIT_TX_PWR_HS;
- ufs_exynos_cap.hs_rate = UFS_EXYNOS_LIMIT_HS_RATE;
- ufs_exynos_cap.desired_working_mode =
- UFS_EXYNOS_LIMIT_DESIRED_MODE;
+ ufshcd_init_pwr_dev_param(&ufs_exynos_cap);
ret = ufshcd_get_pwr_dev_param(&ufs_exynos_cap,
dev_max_params, dev_req_params);
diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h
index 76d6e39efb2f..06ee565f7eb0 100644
--- a/drivers/scsi/ufs/ufs-exynos.h
+++ b/drivers/scsi/ufs/ufs-exynos.h
@@ -90,19 +90,6 @@ struct exynos_ufs;
#define SLOW 1
#define FAST 2
-#define UFS_EXYNOS_LIMIT_NUM_LANES_RX 2
-#define UFS_EXYNOS_LIMIT_NUM_LANES_TX 2
-#define UFS_EXYNOS_LIMIT_HSGEAR_RX UFS_HS_G3
-#define UFS_EXYNOS_LIMIT_HSGEAR_TX UFS_HS_G3
-#define UFS_EXYNOS_LIMIT_PWMGEAR_RX UFS_PWM_G4
-#define UFS_EXYNOS_LIMIT_PWMGEAR_TX UFS_PWM_G4
-#define UFS_EXYNOS_LIMIT_RX_PWR_PWM SLOW_MODE
-#define UFS_EXYNOS_LIMIT_TX_PWR_PWM SLOW_MODE
-#define UFS_EXYNOS_LIMIT_RX_PWR_HS FAST_MODE
-#define UFS_EXYNOS_LIMIT_TX_PWR_HS FAST_MODE
-#define UFS_EXYNOS_LIMIT_HS_RATE PA_HS_MODE_B
-#define UFS_EXYNOS_LIMIT_DESIRED_MODE FAST
-
#define RX_ADV_FINE_GRAN_SUP_EN 0x1
#define RX_ADV_FINE_GRAN_STEP_VAL 0x3
#define RX_ADV_MIN_ACTV_TIME_CAP 0x9
--
2.18.0
Refactor preformance scaling related functions in MediaTek
UFS driver.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-mediatek.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 7fed7630d36c..b9b423752ee1 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -514,6 +514,19 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
dev_info(hba->dev, "caps: 0x%x", host->caps);
}
+static void ufs_mtk_scale_perf(struct ufs_hba *hba, bool up)
+{
+ struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+ ufs_mtk_boost_crypt(hba, up);
+ ufs_mtk_setup_ref_clk(hba, up);
+
+ if (up)
+ phy_power_on(host->mphy);
+ else
+ phy_power_off(host->mphy);
+}
+
/**
* ufs_mtk_setup_clocks - enables/disable clocks
* @hba: host controller instance
@@ -555,15 +568,10 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
clk_pwr_off = true;
}
- if (clk_pwr_off) {
- ufs_mtk_boost_crypt(hba, on);
- ufs_mtk_setup_ref_clk(hba, on);
- phy_power_off(host->mphy);
- }
+ if (clk_pwr_off)
+ ufs_mtk_scale_perf(hba, false);
} else if (on && status == POST_CHANGE) {
- phy_power_on(host->mphy);
- ufs_mtk_setup_ref_clk(hba, on);
- ufs_mtk_boost_crypt(hba, on);
+ ufs_mtk_scale_perf(hba, true);
}
return ret;
--
2.18.0
Use common ADAPT configuration function to reduce duplicated
code in UFS drivers.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-mediatek.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 87b4bf125e23..1d3c5cd4592e 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -677,7 +677,6 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct ufs_dev_params host_cap;
- u32 adapt_val;
int ret;
ufshcd_init_pwr_dev_param(&host_cap);
@@ -693,13 +692,9 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
}
if (host->hw_ver.major >= 3) {
- if (dev_req_params->gear_tx == UFS_HS_G4)
- adapt_val = PA_INITIAL_ADAPT;
- else
- adapt_val = PA_NO_ADAPT;
- ufshcd_dme_set(hba,
- UIC_ARG_MIB(PA_TXHSADAPTTYPE),
- adapt_val);
+ ret = ufshcd_dme_configure_adapt(hba,
+ dev_req_params->gear_tx,
+ PA_INITIAL_ADAPT);
}
return ret;
--
2.18.0
Use common device parameter initialization function instead of
initialziing those parameters by vendor driver itself.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-mediatek.c | 16 +++-------------
drivers/scsi/ufs/ufs-mediatek.h | 16 ----------------
2 files changed, 3 insertions(+), 29 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index b9b423752ee1..87b4bf125e23 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -680,19 +680,9 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
u32 adapt_val;
int ret;
- host_cap.tx_lanes = UFS_MTK_LIMIT_NUM_LANES_TX;
- host_cap.rx_lanes = UFS_MTK_LIMIT_NUM_LANES_RX;
- host_cap.hs_rx_gear = UFS_MTK_LIMIT_HSGEAR_RX;
- host_cap.hs_tx_gear = UFS_MTK_LIMIT_HSGEAR_TX;
- host_cap.pwm_rx_gear = UFS_MTK_LIMIT_PWMGEAR_RX;
- host_cap.pwm_tx_gear = UFS_MTK_LIMIT_PWMGEAR_TX;
- host_cap.rx_pwr_pwm = UFS_MTK_LIMIT_RX_PWR_PWM;
- host_cap.tx_pwr_pwm = UFS_MTK_LIMIT_TX_PWR_PWM;
- host_cap.rx_pwr_hs = UFS_MTK_LIMIT_RX_PWR_HS;
- host_cap.tx_pwr_hs = UFS_MTK_LIMIT_TX_PWR_HS;
- host_cap.hs_rate = UFS_MTK_LIMIT_HS_RATE;
- host_cap.desired_working_mode =
- UFS_MTK_LIMIT_DESIRED_MODE;
+ ufshcd_init_pwr_dev_param(&host_cap);
+ host_cap.hs_rx_gear = UFS_HS_G4;
+ host_cap.hs_tx_gear = UFS_HS_G4;
ret = ufshcd_get_pwr_dev_param(&host_cap,
dev_max_params,
diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs/ufs-mediatek.h
index ac37b11803fb..93d35097dfb0 100644
--- a/drivers/scsi/ufs/ufs-mediatek.h
+++ b/drivers/scsi/ufs/ufs-mediatek.h
@@ -30,22 +30,6 @@
#define REFCLK_REQ_TIMEOUT_US 3000
-/*
- * Vendor specific pre-defined parameters
- */
-#define UFS_MTK_LIMIT_NUM_LANES_RX 2
-#define UFS_MTK_LIMIT_NUM_LANES_TX 2
-#define UFS_MTK_LIMIT_HSGEAR_RX UFS_HS_G4
-#define UFS_MTK_LIMIT_HSGEAR_TX UFS_HS_G4
-#define UFS_MTK_LIMIT_PWMGEAR_RX UFS_PWM_G4
-#define UFS_MTK_LIMIT_PWMGEAR_TX UFS_PWM_G4
-#define UFS_MTK_LIMIT_RX_PWR_PWM SLOW_MODE
-#define UFS_MTK_LIMIT_TX_PWR_PWM SLOW_MODE
-#define UFS_MTK_LIMIT_RX_PWR_HS FAST_MODE
-#define UFS_MTK_LIMIT_TX_PWR_HS FAST_MODE
-#define UFS_MTK_LIMIT_HS_RATE PA_HS_MODE_B
-#define UFS_MTK_LIMIT_DESIRED_MODE UFS_HS_MODE
-
/*
* Other attributes
*/
--
2.18.0
Nowadays many vendors initialize their device parameters in
their own vendor drivers. The initialization code is almost
the same as well as the pre-defined definitions. Introduce
a common device parameter initialization function which assign
the most common initial values. With this function, we
could remove those duplicated codes in vendor drivers.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufshcd-pltfrm.c | 17 +++++++++++++++++
drivers/scsi/ufs/ufshcd-pltfrm.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 3db0af66c71c..a6f76399b3ae 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -354,6 +354,23 @@ int ufshcd_get_pwr_dev_param(struct ufs_dev_params *pltfrm_param,
}
EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
+void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
+{
+ dev_param->tx_lanes = 2;
+ dev_param->rx_lanes = 2;
+ dev_param->hs_rx_gear = UFS_HS_G3;
+ dev_param->hs_tx_gear = UFS_HS_G3;
+ dev_param->pwm_rx_gear = UFS_PWM_G4;
+ dev_param->pwm_tx_gear = UFS_PWM_G4;
+ dev_param->rx_pwr_pwm = SLOW_MODE;
+ dev_param->tx_pwr_pwm = SLOW_MODE;
+ dev_param->rx_pwr_hs = FAST_MODE;
+ dev_param->tx_pwr_hs = FAST_MODE;
+ dev_param->hs_rate = PA_HS_MODE_B;
+ dev_param->desired_working_mode = UFS_HS_MODE;
+}
+EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
+
/**
* ufshcd_pltfrm_init - probe routine of the driver
* @pdev: pointer to Platform device handle
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.h b/drivers/scsi/ufs/ufshcd-pltfrm.h
index b79cdf9129a0..772a8e848098 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.h
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.h
@@ -28,6 +28,7 @@ struct ufs_dev_params {
int ufshcd_get_pwr_dev_param(struct ufs_dev_params *dev_param,
struct ufs_pa_layer_attr *dev_max,
struct ufs_pa_layer_attr *agreed_pwr);
+void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param);
int ufshcd_pltfrm_init(struct platform_device *pdev,
const struct ufs_hba_variant_ops *vops);
void ufshcd_pltfrm_shutdown(struct platform_device *pdev);
--
2.18.0
Several vendors are using same code to configure ADAPT
settings for HS-G4. Simply refactor it as common function.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufshcd.c | 16 ++++++++++++++++
drivers/scsi/ufs/ufshcd.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 9186ee01379a..80cbce414678 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3587,6 +3587,22 @@ static int ufshcd_dme_reset(struct ufs_hba *hba)
return ret;
}
+int ufshcd_dme_configure_adapt(struct ufs_hba *hba,
+ int agreed_gear,
+ int adapt_val)
+{
+ int ret;
+
+ if (agreed_gear != UFS_HS_G4)
+ adapt_val = PA_INITIAL_ADAPT;
+
+ ret = ufshcd_dme_set(hba,
+ UIC_ARG_MIB(PA_TXHSADAPTTYPE),
+ adapt_val);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(ufshcd_dme_configure_adapt);
+
/**
* ufshcd_dme_enable - UIC command for DME_ENABLE
* @hba: per adapter instance
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 5191d87f6263..d0b68df07eef 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -956,6 +956,9 @@ extern int ufshcd_runtime_idle(struct ufs_hba *hba);
extern int ufshcd_system_suspend(struct ufs_hba *hba);
extern int ufshcd_system_resume(struct ufs_hba *hba);
extern int ufshcd_shutdown(struct ufs_hba *hba);
+extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba,
+ int agreed_gear,
+ int adapt_val);
extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
u8 attr_set, u32 mib_val, u8 peer);
extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
--
2.18.0
Use common ADAPT configuration function to reduce duplicated
code in UFS drivers.
Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-qcom.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 04adfbd10753..1e434cce0f79 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -723,17 +723,9 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
ufs_qcom_dev_ref_clk_ctrl(host, true);
if (host->hw_ver.major >= 0x4) {
- if (dev_req_params->gear_tx == UFS_HS_G4) {
- /* INITIAL ADAPT */
- ufshcd_dme_set(hba,
- UIC_ARG_MIB(PA_TXHSADAPTTYPE),
- PA_INITIAL_ADAPT);
- } else {
- /* NO ADAPT */
- ufshcd_dme_set(hba,
- UIC_ARG_MIB(PA_TXHSADAPTTYPE),
- PA_NO_ADAPT);
- }
+ ufshcd_dme_configure_adapt(hba,
+ dev_req_params->gear_tx,
+ PA_INITIAL_ADAPT);
}
break;
case POST_CHANGE:
--
2.18.0
On Mon, 2020-11-16 at 14:50 +0800, Stanley Chu wrote:
> Hi,
> This series simply do some refactoring and cleanups in UFS drivers.
>
> Stanley Chu (9):
> scsi: ufs-mediatek: Refactor performance scaling functions
> scsi: ufs: Introduce device parameter initialization function
> scsi: ufs-mediatek: Use device parameter initialization function
> scsi: ufs-qcom: Use device parameter initialization function
> scsi: ufs-exynos: Use device parameter initialization function
> scsi: ufs-hisi: Use device parameter initialization function
> scsi: ufs: Refactor ADAPT configuration function
> scsi: ufs-mediatek: Use common ADAPT configuration function
> scsi: ufs-qcom: Use common ADAPT configuration function
>
> drivers/scsi/ufs/ufs-exynos.c | 15 +---------
> drivers/scsi/ufs/ufs-exynos.h | 13 --------
> drivers/scsi/ufs/ufs-hisi.c | 13 +-------
> drivers/scsi/ufs/ufs-hisi.h | 13 --------
> drivers/scsi/ufs/ufs-mediatek.c | 51 ++++++++++++++--------------
> ----
> drivers/scsi/ufs/ufs-mediatek.h | 16 ----------
> drivers/scsi/ufs/ufs-qcom.c | 27 +++--------------
> drivers/scsi/ufs/ufs-qcom.h | 11 -------
> drivers/scsi/ufs/ufshcd-pltfrm.c | 17 +++++++++++
> drivers/scsi/ufs/ufshcd-pltfrm.h | 1 +
> drivers/scsi/ufs/ufshcd.c | 16 ++++++++++
> drivers/scsi/ufs/ufshcd.h | 3 ++
> 12 files changed, 65 insertions(+), 131 deletions(-)
>
This series looks good to me, thanks.
Reviewed-by: Bean Huo <[email protected]>
Stanley,
> This series simply do some refactoring and cleanups in UFS drivers.
Applied to 5.11/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
On Mon, 16 Nov 2020 14:50:45 +0800, Stanley Chu wrote:
> This series simply do some refactoring and cleanups in UFS drivers.
>
> Stanley Chu (9):
> scsi: ufs-mediatek: Refactor performance scaling functions
> scsi: ufs: Introduce device parameter initialization function
> scsi: ufs-mediatek: Use device parameter initialization function
> scsi: ufs-qcom: Use device parameter initialization function
> scsi: ufs-exynos: Use device parameter initialization function
> scsi: ufs-hisi: Use device parameter initialization function
> scsi: ufs: Refactor ADAPT configuration function
> scsi: ufs-mediatek: Use common ADAPT configuration function
> scsi: ufs-qcom: Use common ADAPT configuration function
>
> [...]
Applied to 5.11/scsi-queue, thanks!
[1/9] scsi: ufs: ufs-mediatek: Refactor performance scaling functions
https://git.kernel.org/mkp/scsi/c/54770cbebe2c
[2/9] scsi: ufs: Introduce device parameter initialization function
https://git.kernel.org/mkp/scsi/c/65858014ee20
[3/9] scsi: ufs: ufs-mediatek: Use device parameter initialization function
https://git.kernel.org/mkp/scsi/c/a4b537ea656e
[4/9] scsi: ufs: ufs-qcom: Use device parameter initialization function
https://git.kernel.org/mkp/scsi/c/8beef54716e6
[5/9] scsi: ufs: ufs-exynos: Use device parameter initialization function
https://git.kernel.org/mkp/scsi/c/5b3573d68d9a
[6/9] scsi: ufs: ufs-hisi: Use device parameter initialization function
https://git.kernel.org/mkp/scsi/c/85d6d3c18953
[7/9] scsi: ufs: Refactor ADAPT configuration function
https://git.kernel.org/mkp/scsi/c/fc85a74e28fe
[8/9] scsi: ufs: ufs-mediatek: Use common ADAPT configuration function
https://git.kernel.org/mkp/scsi/c/e1e25d1b8996
[9/9] scsi: ufs: ufs-qcom: Use common ADAPT configuration function
https://git.kernel.org/mkp/scsi/c/d9fa1e731e24
--
Martin K. Petersen Oracle Linux Engineering