Commit b334456e authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Martin K. Petersen

scsi: ufs: ufshcd: fix possible unclocked register access

Vendor specific setup_clocks ops may depend on clocks managed by ufshcd
driver so if the vendor specific setup_clocks callback is called when
the required clocks are turned off, it results into unclocked register
access.

This change make sure that required clocks are enabled before vendor
specific setup_clocks callback is called.
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarVenkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 2e3611e9
...@@ -6912,9 +6912,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, ...@@ -6912,9 +6912,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
if (list_empty(head)) if (list_empty(head))
goto out; goto out;
/*
* vendor specific setup_clocks ops may depend on clocks managed by
* this standard driver hence call the vendor specific setup_clocks
* before disabling the clocks managed here.
*/
if (!on) {
ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE); ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
if (ret) if (ret)
return ret; return ret;
}
list_for_each_entry(clki, head, list) { list_for_each_entry(clki, head, list) {
if (!IS_ERR_OR_NULL(clki->clk)) { if (!IS_ERR_OR_NULL(clki->clk)) {
...@@ -6938,9 +6945,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, ...@@ -6938,9 +6945,16 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
} }
} }
/*
* vendor specific setup_clocks ops may depend on clocks managed by
* this standard driver hence call the vendor specific setup_clocks
* after enabling the clocks managed here.
*/
if (on) {
ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE); ret = ufshcd_vops_setup_clocks(hba, on, POST_CHANGE);
if (ret) if (ret)
return ret; return ret;
}
out: out:
if (ret) { if (ret) {
......
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