* [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear [not found] <1581485910-8307-1-git-send-email-cang@codeaurora.org> @ 2020-02-12 5:38 ` Can Guo 2020-02-12 12:21 ` Avri Altman 2020-02-13 7:54 ` Stanley Chu 2020-02-12 5:38 ` [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 Can Guo 1 sibling, 2 replies; 9+ messages in thread From: Can Guo @ 2020-02-12 5:38 UTC (permalink / raw) To: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, cang Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley, Martin K. Petersen, Bean Huo, Stanley Chu, Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list When scale gear, use ufshcd_config_pwr_mode() instead of ufshcd_change_power_mode() so that vops_pwr_change_notify(PRE_CHANGE) can be utilized to allow vendors use customized settings before change the power mode. Signed-off-by: Can Guo <cang@codeaurora.org> --- drivers/scsi/ufs/ufshcd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index adcce41..67bd4f2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1059,8 +1059,7 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) } /* check if the power mode needs to be changed or not? */ - ret = ufshcd_change_power_mode(hba, &new_pwr_info); - + ret = ufshcd_config_pwr_mode(hba, &new_pwr_info); if (ret) dev_err(hba->dev, "%s: failed err %d, old gear: (tx %d rx %d), new gear: (tx %d rx %d)", __func__, ret, @@ -4126,8 +4125,6 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba, memcpy(&final_params, desired_pwr_mode, sizeof(final_params)); ret = ufshcd_change_power_mode(hba, &final_params); - if (!ret) - ufshcd_print_pwr_info(hba); return ret; } @@ -7157,6 +7154,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async) __func__, ret); goto out; } + ufshcd_print_pwr_info(hba); } /* set the state as operational after switching to desired gear */ -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear 2020-02-12 5:38 ` [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear Can Guo @ 2020-02-12 12:21 ` Avri Altman 2020-02-13 2:53 ` Can Guo 2020-02-13 7:54 ` Stanley Chu 1 sibling, 1 reply; 9+ messages in thread From: Avri Altman @ 2020-02-12 12:21 UTC (permalink / raw) To: Can Guo, asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn Cc: Alim Akhtar, James E.J. Bottomley, Martin K. Petersen, Bean Huo, Stanley Chu, Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list Hi, > > When scale gear, use ufshcd_config_pwr_mode() instead of > ufshcd_change_power_mode() so that > vops_pwr_change_notify(PRE_CHANGE) > can be utilized to allow vendors use customized settings before change > the power mode. > > Signed-off-by: Can Guo <cang@codeaurora.org> > --- > drivers/scsi/ufs/ufshcd.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index adcce41..67bd4f2 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1059,8 +1059,7 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, > bool scale_up) > } > > /* check if the power mode needs to be changed or not? */ > - ret = ufshcd_change_power_mode(hba, &new_pwr_info); > - > + ret = ufshcd_config_pwr_mode(hba, &new_pwr_info); You might want to inform ufshcd_config_pwr_mode() of the caller, As now it will be called much more frequently, and you want/don't want To call your vops on probe but not on scale_gear? Also, Alim exported ufshcd_config_pwr_mode a while ago, In commit 0d846e703dc8 "scsi: ufs: make ufshcd_config_pwr_mode of non-static func"), But nobody uses it outside ufshcd - so maybe revert this commit as part of this series? > if (ret) > dev_err(hba->dev, "%s: failed err %d, old gear: (tx %d rx %d), new > gear: (tx %d rx %d)", > __func__, ret, > @@ -4126,8 +4125,6 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba, > memcpy(&final_params, desired_pwr_mode, sizeof(final_params)); > > ret = ufshcd_change_power_mode(hba, &final_params); > - if (!ret) > - ufshcd_print_pwr_info(hba); > > return ret; > } > @@ -7157,6 +7154,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, > bool async) > __func__, ret); > goto out; > } > + ufshcd_print_pwr_info(hba); > } > > /* set the state as operational after switching to desired gear */ > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora > Forum, > a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear 2020-02-12 12:21 ` Avri Altman @ 2020-02-13 2:53 ` Can Guo 2020-02-13 7:20 ` Avri Altman 0 siblings, 1 reply; 9+ messages in thread From: Can Guo @ 2020-02-13 2:53 UTC (permalink / raw) To: Avri Altman Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, Alim Akhtar, James E.J. Bottomley, Martin K. Petersen, Bean Huo, Stanley Chu, Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list On 2020-02-12 20:21, Avri Altman wrote: > Hi, > >> >> When scale gear, use ufshcd_config_pwr_mode() instead of >> ufshcd_change_power_mode() so that >> vops_pwr_change_notify(PRE_CHANGE) >> can be utilized to allow vendors use customized settings before change >> the power mode. >> >> Signed-off-by: Can Guo <cang@codeaurora.org> >> --- >> drivers/scsi/ufs/ufshcd.c | 6 ++---- >> 1 file changed, 2 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index adcce41..67bd4f2 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -1059,8 +1059,7 @@ static int ufshcd_scale_gear(struct ufs_hba >> *hba, >> bool scale_up) >> } >> >> /* check if the power mode needs to be changed or not? */ >> - ret = ufshcd_change_power_mode(hba, &new_pwr_info); >> - >> + ret = ufshcd_config_pwr_mode(hba, &new_pwr_info); > > You might want to inform ufshcd_config_pwr_mode() of the caller, > As now it will be called much more frequently, and you want/don't want > To call your vops on probe but not on scale_gear? > > Also, Alim exported ufshcd_config_pwr_mode a while ago, > In commit 0d846e703dc8 "scsi: ufs: make ufshcd_config_pwr_mode of > non-static func"), > But nobody uses it outside ufshcd - so maybe revert this commit as > part of this series? > > > Hi Avri, Thanks for your review and suggestion. What I get from your suggestion is that add one more parameter to ufshcd_config_pwr_mode(say: bool from_probe), and pass the param to ufshcd_vops_pwr_change_notify() so that vendor drivers know where is the call comes from? If I get it correctly, then yes, we can do that. However, in ufs-qcom.c, ufs_qcom_pwr_change_notify(PRE_CHANGE) is fine being called every time whenever there is a power mode change, we have no problem with that. And as we are the only user of clock scaling in the latest code base, so this change does not impact any other vendors. If later other vendors need to use clock scaling, they can do this change as you suggested above. As for the commit from Alim, I think I should leave it to Alim's call on it, maybe he has changes that use this func outside ufshcd.c but not uploaded yet. Thanks, Can Guo. >> if (ret) >> dev_err(hba->dev, "%s: failed err %d, old gear: (tx %d >> rx %d), new >> gear: (tx %d rx %d)", >> __func__, ret, >> @@ -4126,8 +4125,6 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba, >> memcpy(&final_params, desired_pwr_mode, >> sizeof(final_params)); >> >> ret = ufshcd_change_power_mode(hba, &final_params); >> - if (!ret) >> - ufshcd_print_pwr_info(hba); >> >> return ret; >> } >> @@ -7157,6 +7154,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, >> bool async) >> __func__, ret); >> goto out; >> } >> + ufshcd_print_pwr_info(hba); >> } >> >> /* set the state as operational after switching to desired >> gear */ >> -- >> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora >> Forum, >> a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear 2020-02-13 2:53 ` Can Guo @ 2020-02-13 7:20 ` Avri Altman 0 siblings, 0 replies; 9+ messages in thread From: Avri Altman @ 2020-02-13 7:20 UTC (permalink / raw) To: Can Guo Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, Alim Akhtar, James E.J. Bottomley, Martin K. Petersen, Bean Huo, Stanley Chu, Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list > > On 2020-02-12 20:21, Avri Altman wrote: > > Hi, > > > >> > >> When scale gear, use ufshcd_config_pwr_mode() instead of > >> ufshcd_change_power_mode() so that > >> vops_pwr_change_notify(PRE_CHANGE) > >> can be utilized to allow vendors use customized settings before change > >> the power mode. > >> > >> Signed-off-by: Can Guo <cang@codeaurora.org> Reviewed-by: Avri Altman <avri.altman@wdc.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear 2020-02-12 5:38 ` [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear Can Guo 2020-02-12 12:21 ` Avri Altman @ 2020-02-13 7:54 ` Stanley Chu 1 sibling, 0 replies; 9+ messages in thread From: Stanley Chu @ 2020-02-13 7:54 UTC (permalink / raw) To: Can Guo Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, Alim Akhtar, Avri Altman, James E.J. Bottomley, Martin K. Petersen, Bean Huo, Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list On Tue, 2020-02-11 at 21:38 -0800, Can Guo wrote: > When scale gear, use ufshcd_config_pwr_mode() instead of > ufshcd_change_power_mode() so that vops_pwr_change_notify(PRE_CHANGE) > can be utilized to allow vendors use customized settings before change > the power mode. > > Signed-off-by: Can Guo <cang@codeaurora.org> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 [not found] <1581485910-8307-1-git-send-email-cang@codeaurora.org> 2020-02-12 5:38 ` [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear Can Guo @ 2020-02-12 5:38 ` Can Guo 2020-02-12 12:26 ` Avri Altman ` (2 more replies) 1 sibling, 3 replies; 9+ messages in thread From: Can Guo @ 2020-02-12 5:38 UTC (permalink / raw) To: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, cang Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, Avri Altman, James E.J. Bottomley, Martin K. Petersen, Greg Kroah-Hartman, Pedro Sousa, Thomas Gleixner, open list:ARM/QUALCOMM SUPPORT, open list ADAPT is added specifically for HS Gear4 mode only, select INITIAL ADAPT before do power mode change to G4 and select NO ADAPT before switch to non-G4 modes. Signed-off-by: Can Guo <cang@codeaurora.org> --- drivers/scsi/ufs/ufs-qcom.c | 14 ++++++++++++++ drivers/scsi/ufs/unipro.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index d593523..6a905bb 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -942,6 +942,20 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, if (!ufshcd_is_hs_mode(&hba->pwr_info) && ufshcd_is_hs_mode(dev_req_params)) 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); + } + } break; case POST_CHANGE: if (ufs_qcom_cfg_timers(hba, dev_req_params->gear_rx, diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 3dc4d8b..766d551 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -146,6 +146,12 @@ #define PA_SLEEPNOCONFIGTIME 0x15A2 #define PA_STALLNOCONFIGTIME 0x15A3 #define PA_SAVECONFIGTIME 0x15A4 +#define PA_TXHSADAPTTYPE 0x15D4 + +/* Adpat type for PA_TXHSADAPTTYPE attribute */ +#define PA_REFRESH_ADAPT 0x00 +#define PA_INITIAL_ADAPT 0x01 +#define PA_NO_ADAPT 0x03 #define PA_TACTIVATE_TIME_UNIT_US 10 #define PA_HIBERN8_TIME_UNIT_US 100 @@ -203,6 +209,7 @@ enum ufs_hs_gear_tag { UFS_HS_G1, /* HS Gear 1 (default for reset) */ UFS_HS_G2, /* HS Gear 2 */ UFS_HS_G3, /* HS Gear 3 */ + UFS_HS_G4, /* HS Gear 4 */ }; enum ufs_unipro_ver { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 2020-02-12 5:38 ` [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 Can Guo @ 2020-02-12 12:26 ` Avri Altman 2020-02-12 17:04 ` asutoshd 2020-02-13 0:36 ` Martin K. Petersen 2 siblings, 0 replies; 9+ messages in thread From: Avri Altman @ 2020-02-12 12:26 UTC (permalink / raw) To: Can Guo, asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, James E.J. Bottomley, Martin K. Petersen, Greg Kroah-Hartman, Pedro Sousa, Thomas Gleixner, open list:ARM/QUALCOMM SUPPORT, open list > > ADAPT is added specifically for HS Gear4 mode only, select INITIAL ADAPT > before do power mode change to G4 and select NO ADAPT before switch to > non-G4 modes. > > Signed-off-by: Can Guo <cang@codeaurora.org> Reviewed-by: Avri Altman <avri.altman@wdc.com> Thanks, Avri ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 2020-02-12 5:38 ` [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 Can Guo 2020-02-12 12:26 ` Avri Altman @ 2020-02-12 17:04 ` asutoshd 2020-02-13 0:36 ` Martin K. Petersen 2 siblings, 0 replies; 9+ messages in thread From: asutoshd @ 2020-02-12 17:04 UTC (permalink / raw) To: Can Guo Cc: nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, Andy Gross, Bjorn Andersson, Alim Akhtar, Avri Altman, James E.J. Bottomley, Martin K. Petersen, Greg Kroah-Hartman, Pedro Sousa, Thomas Gleixner, linux-arm-msm, linux-kernel, linux-scsi-owner On 2020-02-11 21:38, Can Guo wrote: > ADAPT is added specifically for HS Gear4 mode only, select INITIAL > ADAPT > before do power mode change to G4 and select NO ADAPT before switch to > non-G4 modes. > > Signed-off-by: Can Guo <cang@codeaurora.org> > --- Reviewed-by: Asutosh Das <asutoshd@codeaurora.org> > drivers/scsi/ufs/ufs-qcom.c | 14 ++++++++++++++ > drivers/scsi/ufs/unipro.h | 7 +++++++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c > index d593523..6a905bb 100644 > --- a/drivers/scsi/ufs/ufs-qcom.c > +++ b/drivers/scsi/ufs/ufs-qcom.c > @@ -942,6 +942,20 @@ static int ufs_qcom_pwr_change_notify(struct > ufs_hba *hba, > if (!ufshcd_is_hs_mode(&hba->pwr_info) && > ufshcd_is_hs_mode(dev_req_params)) > 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); > + } > + } > break; > case POST_CHANGE: > if (ufs_qcom_cfg_timers(hba, dev_req_params->gear_rx, > diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h > index 3dc4d8b..766d551 100644 > --- a/drivers/scsi/ufs/unipro.h > +++ b/drivers/scsi/ufs/unipro.h > @@ -146,6 +146,12 @@ > #define PA_SLEEPNOCONFIGTIME 0x15A2 > #define PA_STALLNOCONFIGTIME 0x15A3 > #define PA_SAVECONFIGTIME 0x15A4 > +#define PA_TXHSADAPTTYPE 0x15D4 > + > +/* Adpat type for PA_TXHSADAPTTYPE attribute */ > +#define PA_REFRESH_ADAPT 0x00 > +#define PA_INITIAL_ADAPT 0x01 > +#define PA_NO_ADAPT 0x03 > > #define PA_TACTIVATE_TIME_UNIT_US 10 > #define PA_HIBERN8_TIME_UNIT_US 100 > @@ -203,6 +209,7 @@ enum ufs_hs_gear_tag { > UFS_HS_G1, /* HS Gear 1 (default for reset) */ > UFS_HS_G2, /* HS Gear 2 */ > UFS_HS_G3, /* HS Gear 3 */ > + UFS_HS_G4, /* HS Gear 4 */ > }; > > enum ufs_unipro_ver { ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 2020-02-12 5:38 ` [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 Can Guo 2020-02-12 12:26 ` Avri Altman 2020-02-12 17:04 ` asutoshd @ 2020-02-13 0:36 ` Martin K. Petersen 2 siblings, 0 replies; 9+ messages in thread From: Martin K. Petersen @ 2020-02-13 0:36 UTC (permalink / raw) To: Can Guo Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team, saravanak, salyzyn, Andy Gross, Bjorn Andersson, Alim Akhtar, Avri Altman, James E.J. Bottomley, Martin K. Petersen, Greg Kroah-Hartman, Pedro Sousa, Thomas Gleixner, open list:ARM/QUALCOMM SUPPORT, open list Can, > ADAPT is added specifically for HS Gear4 mode only, select INITIAL > ADAPT before do power mode change to G4 and select NO ADAPT before > switch to non-G4 modes. Applied to 5.7/scsi-queue, thanks! -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-02-13 7:54 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1581485910-8307-1-git-send-email-cang@codeaurora.org> 2020-02-12 5:38 ` [PATCH v1 1/2] scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear Can Guo 2020-02-12 12:21 ` Avri Altman 2020-02-13 2:53 ` Can Guo 2020-02-13 7:20 ` Avri Altman 2020-02-13 7:54 ` Stanley Chu 2020-02-12 5:38 ` [PATCH v1 2/2] scsi: ufs: Select INITIAL ADAPT type for HS Gear4 Can Guo 2020-02-12 12:26 ` Avri Altman 2020-02-12 17:04 ` asutoshd 2020-02-13 0:36 ` Martin K. Petersen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).