mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-26 14:43:27 -04:00
scsi: ufs-qcom: Adjust the order of bus bandwidth voting and unvoting
The bus bandwidth voting is required to be done before the bus clocks are enabled, and the unvoting is required to be done only after the bus clocks are disabled. Change-Id: Ie231d9c373c0d8c8f3dd90b8322ff24fabdfae26 Signed-off-by: Can Guo <cang@codeaurora.org>
This commit is contained in:
parent
3595f45491
commit
55af5bb593
1 changed files with 53 additions and 29 deletions
|
|
@ -64,7 +64,6 @@ struct ufs_qcom_dev_params {
|
|||
|
||||
static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
|
||||
|
||||
static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote);
|
||||
static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
|
||||
static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba,
|
||||
u32 clk_1us_cycles,
|
||||
|
|
@ -1053,7 +1052,7 @@ static int ufs_qcom_get_ib_ab(struct ufs_qcom_host *host, int index,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote)
|
||||
static int __ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote)
|
||||
{
|
||||
int err = 0;
|
||||
struct qcom_bus_scale_data *d = host->qbsd;
|
||||
|
|
@ -1100,7 +1099,7 @@ static int ufs_qcom_update_bus_bw_vote(struct ufs_qcom_host *host)
|
|||
|
||||
vote = ufs_qcom_get_bus_vote(host, mode);
|
||||
if (vote >= 0)
|
||||
err = ufs_qcom_set_bus_vote(host, vote);
|
||||
err = __ufs_qcom_set_bus_vote(host, vote);
|
||||
else
|
||||
err = vote;
|
||||
|
||||
|
|
@ -1111,6 +1110,35 @@ static int ufs_qcom_update_bus_bw_vote(struct ufs_qcom_host *host)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int ufs_qcom_set_bus_vote(struct ufs_hba *hba, bool on)
|
||||
{
|
||||
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
|
||||
int vote, err;
|
||||
|
||||
/*
|
||||
* In case ufs_qcom_init() is not yet done, simply ignore.
|
||||
* This ufs_qcom_set_bus_vote() shall be called from
|
||||
* ufs_qcom_init() after init is done.
|
||||
*/
|
||||
if (!host)
|
||||
return 0;
|
||||
|
||||
if (on) {
|
||||
vote = host->bus_vote.saved_vote;
|
||||
if (vote == host->bus_vote.min_bw_vote)
|
||||
ufs_qcom_update_bus_bw_vote(host);
|
||||
} else {
|
||||
vote = host->bus_vote.min_bw_vote;
|
||||
}
|
||||
|
||||
err = __ufs_qcom_set_bus_vote(host, vote);
|
||||
if (err)
|
||||
dev_err(hba->dev, "%s: set bus vote failed %d\n",
|
||||
__func__, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
show_ufs_to_mem_max_bus_bw(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
|
|
@ -1271,7 +1299,7 @@ static int ufs_qcom_bus_register(struct ufs_qcom_host *host)
|
|||
err);
|
||||
|
||||
/* Full throttle */
|
||||
err = ufs_qcom_set_bus_vote(host, host->bus_vote.max_bw_vote);
|
||||
err = __ufs_qcom_set_bus_vote(host, host->bus_vote.max_bw_vote);
|
||||
if (err)
|
||||
dev_err(dev, "Error: (%d) Failed to set max bus vote\n", err);
|
||||
|
||||
|
|
@ -1550,8 +1578,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
|
|||
enum ufs_notify_change_status status)
|
||||
{
|
||||
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
|
||||
int err;
|
||||
int vote = 0;
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
* In case ufs_qcom_init() is not yet done, simply ignore.
|
||||
|
|
@ -1561,32 +1588,28 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
|
|||
if (!host)
|
||||
return 0;
|
||||
|
||||
if (on && (status == POST_CHANGE)) {
|
||||
/* enable the device ref clock for HS mode*/
|
||||
if (ufshcd_is_hs_mode(&hba->pwr_info))
|
||||
ufs_qcom_dev_ref_clk_ctrl(host, true);
|
||||
vote = host->bus_vote.saved_vote;
|
||||
if (vote == host->bus_vote.min_bw_vote)
|
||||
ufs_qcom_update_bus_bw_vote(host);
|
||||
|
||||
} else if (!on && (status == PRE_CHANGE)) {
|
||||
if ((ufshcd_is_auto_hibern8_supported(hba) &&
|
||||
!!hba->ahit) ||
|
||||
!ufs_qcom_is_link_active(hba)) {
|
||||
/* disable device ref_clk */
|
||||
ufs_qcom_dev_ref_clk_ctrl(host, false);
|
||||
/* powering off PHY during aggressive clk gating */
|
||||
switch (status) {
|
||||
case PRE_CHANGE:
|
||||
if (on) {
|
||||
err = ufs_qcom_set_bus_vote(hba, true);
|
||||
} else {
|
||||
if (!ufs_qcom_is_link_active(hba)) {
|
||||
/* disable device ref_clk */
|
||||
ufs_qcom_dev_ref_clk_ctrl(host, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vote = host->bus_vote.min_bw_vote;
|
||||
break;
|
||||
case POST_CHANGE:
|
||||
if (on) {
|
||||
/* enable the device ref clock for HS mode*/
|
||||
if (ufshcd_is_hs_mode(&hba->pwr_info))
|
||||
ufs_qcom_dev_ref_clk_ctrl(host, true);
|
||||
} else {
|
||||
err = ufs_qcom_set_bus_vote(hba, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
err = ufs_qcom_set_bus_vote(host, vote);
|
||||
if (err)
|
||||
dev_err(hba->dev, "%s: set bus vote failed %d\n",
|
||||
__func__, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -2156,6 +2179,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
|
|||
ufs_qcom_set_caps(hba);
|
||||
ufs_qcom_advertise_quirks(hba);
|
||||
|
||||
ufs_qcom_set_bus_vote(hba, true);
|
||||
ufs_qcom_setup_clocks(hba, true, POST_CHANGE);
|
||||
|
||||
if (hba->dev->id < MAX_UFS_QCOM_HOSTS)
|
||||
|
|
|
|||
Loading…
Reference in a new issue