Message ID | 20220419183044.789065-2-huobean@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Several changes for UFSHPB | expand |
Hi Bean, >From: Bean Huo <beanhuo@micron.com> > >There is no functional change in this patch, just merge ufshpb_reset() and >ufshpb_reset_host() into one function ufshpb_toggle() > >Signed-off-by: Bean Huo <beanhuo@micron.com> >--- > drivers/scsi/ufs/ufshcd.c | 4 ++-- > drivers/scsi/ufs/ufshpb.c | 36 +++++++++++++----------------------- > drivers/scsi/ufs/ufshpb.h | 6 ++---- > 3 files changed, 17 insertions(+), 29 deletions(-) > >diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >index 0899d5b8cdad..de0bc53e3ac6 100644 >--- a/drivers/scsi/ufs/ufshcd.c >+++ b/drivers/scsi/ufs/ufshcd.c >@@ -7223,7 +7223,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) > * Stop the host controller and complete the requests > * cleared by h/w > */ >- ufshpb_reset_host(hba); >+ ufshpb_toggle(hba, HPB_PRESENT, HPB_RESET); > ufshcd_hba_stop(hba); > hba->silence_err_logs = true; > ufshcd_complete_requests(hba); >@@ -8184,7 +8184,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) > /* Enable Auto-Hibernate if configured */ > ufshcd_auto_hibern8_enable(hba); > >- ufshpb_reset(hba); >+ ufshpb_toggle(hba, HPB_RESET, HPB_PRESENT); > out: > spin_lock_irqsave(hba->host->host_lock, flags); > if (ret) >diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c >index 3ca745ad616c..9df032e82ec3 100644 >--- a/drivers/scsi/ufs/ufshpb.c >+++ b/drivers/scsi/ufs/ufshpb.c >@@ -2278,38 +2278,28 @@ static bool ufshpb_check_hpb_reset_query(struct ufs_hba *hba) > return flag_res; > } > >-void ufshpb_reset(struct ufs_hba *hba) >+/** >+ * ufshpb_toggle - switch HPB state of all LUs >+ * @hba: per-adapter instance >+ * @src: expected current HPB state >+ * @dest: target HPB state to switch to >+ */ >+void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) How about changing it to something like ufshpb_state_toggle()? Best Regards, Keoseong Park > { > struct ufshpb_lu *hpb; > struct scsi_device *sdev; > > shost_for_each_device(sdev, hba->host) { > hpb = ufshpb_get_hpb_data(sdev); >- if (!hpb) >- continue; >- >- if (ufshpb_get_state(hpb) != HPB_RESET) >- continue; >- >- ufshpb_set_state(hpb, HPB_PRESENT); >- } >-} >- >-void ufshpb_reset_host(struct ufs_hba *hba) >-{ >- struct ufshpb_lu *hpb; >- struct scsi_device *sdev; > >- shost_for_each_device(sdev, hba->host) { >- hpb = ufshpb_get_hpb_data(sdev); >- if (!hpb) >+ if (!hpb || ufshpb_get_state(hpb) != src) > continue; >+ ufshpb_set_state(hpb, dest); > >- if (ufshpb_get_state(hpb) != HPB_PRESENT) >- continue; >- ufshpb_set_state(hpb, HPB_RESET); >- ufshpb_cancel_jobs(hpb); >- ufshpb_discard_rsp_lists(hpb); >+ if (dest == HPB_RESET) { >+ ufshpb_cancel_jobs(hpb); >+ ufshpb_discard_rsp_lists(hpb); >+ } > } > } > >diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h >index b475dbd78988..2825ec69a6a6 100644 >--- a/drivers/scsi/ufs/ufshpb.h >+++ b/drivers/scsi/ufs/ufshpb.h >@@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; > static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {} > static void ufshpb_resume(struct ufs_hba *hba) {} > static void ufshpb_suspend(struct ufs_hba *hba) {} >-static void ufshpb_reset(struct ufs_hba *hba) {} >-static void ufshpb_reset_host(struct ufs_hba *hba) {} >+static void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {} > static void ufshpb_init(struct ufs_hba *hba) {} > static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} > static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} >@@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); > void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); > void ufshpb_resume(struct ufs_hba *hba); > void ufshpb_suspend(struct ufs_hba *hba); >-void ufshpb_reset(struct ufs_hba *hba); >-void ufshpb_reset_host(struct ufs_hba *hba); >+void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest); > void ufshpb_init(struct ufs_hba *hba); > void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev); > void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev); >-- >2.34.1 > >
On Wed, 2022-04-20 at 11:47 +0900, Keoseong Park wrote: > > +void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, > > enum UFSHPB_STATE dest) > How about changing it to something like ufshpb_state_toggle()? > > Best Regards, > Keoseong Park ufshpb_state_toggle() is much better, I will change it in the next version. Thanks. Kind regards, Bean
On 4/20/22 05:48, Bean Huo wrote: > On Wed, 2022-04-20 at 11:47 +0900, Keoseong Park wrote: >>> +void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, >>> enum UFSHPB_STATE dest) >> How about changing it to something like ufshpb_state_toggle()? >> >> Best Regards, >> Keoseong Park > > ufshpb_state_toggle() is much better, I will change it in the next > version. Thanks. How about ufshbp_toggle_state() such that the word order is correct? Thanks, Bart.
On Wed, 2022-04-20 at 20:48 -0700, Bart Van Assche wrote: > > > How about changing it to something like ufshpb_state_toggle()? > > > > > > Best Regards, > > > Keoseong Park > > > > ufshpb_state_toggle() is much better, I will change it in the next > > version. Thanks. > > How about ufshbp_toggle_state() such that the word order is correct? > > Thanks, > > Bart. Sound good, I will change to this one. thanks. Bean
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 0899d5b8cdad..de0bc53e3ac6 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7223,7 +7223,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) * Stop the host controller and complete the requests * cleared by h/w */ - ufshpb_reset_host(hba); + ufshpb_toggle(hba, HPB_PRESENT, HPB_RESET); ufshcd_hba_stop(hba); hba->silence_err_logs = true; ufshcd_complete_requests(hba); @@ -8184,7 +8184,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) /* Enable Auto-Hibernate if configured */ ufshcd_auto_hibern8_enable(hba); - ufshpb_reset(hba); + ufshpb_toggle(hba, HPB_RESET, HPB_PRESENT); out: spin_lock_irqsave(hba->host->host_lock, flags); if (ret) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 3ca745ad616c..9df032e82ec3 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -2278,38 +2278,28 @@ static bool ufshpb_check_hpb_reset_query(struct ufs_hba *hba) return flag_res; } -void ufshpb_reset(struct ufs_hba *hba) +/** + * ufshpb_toggle - switch HPB state of all LUs + * @hba: per-adapter instance + * @src: expected current HPB state + * @dest: target HPB state to switch to + */ +void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) { struct ufshpb_lu *hpb; struct scsi_device *sdev; shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) - continue; - - if (ufshpb_get_state(hpb) != HPB_RESET) - continue; - - ufshpb_set_state(hpb, HPB_PRESENT); - } -} - -void ufshpb_reset_host(struct ufs_hba *hba) -{ - struct ufshpb_lu *hpb; - struct scsi_device *sdev; - shost_for_each_device(sdev, hba->host) { - hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + if (!hpb || ufshpb_get_state(hpb) != src) continue; + ufshpb_set_state(hpb, dest); - if (ufshpb_get_state(hpb) != HPB_PRESENT) - continue; - ufshpb_set_state(hpb, HPB_RESET); - ufshpb_cancel_jobs(hpb); - ufshpb_discard_rsp_lists(hpb); + if (dest == HPB_RESET) { + ufshpb_cancel_jobs(hpb); + ufshpb_discard_rsp_lists(hpb); + } } } diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index b475dbd78988..2825ec69a6a6 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {} static void ufshpb_resume(struct ufs_hba *hba) {} static void ufshpb_suspend(struct ufs_hba *hba) {} -static void ufshpb_reset(struct ufs_hba *hba) {} -static void ufshpb_reset_host(struct ufs_hba *hba) {} +static void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {} static void ufshpb_init(struct ufs_hba *hba) {} static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} @@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); void ufshpb_resume(struct ufs_hba *hba); void ufshpb_suspend(struct ufs_hba *hba); -void ufshpb_reset(struct ufs_hba *hba); -void ufshpb_reset_host(struct ufs_hba *hba); +void ufshpb_toggle(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest); void ufshpb_init(struct ufs_hba *hba); void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev); void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);