Commit facc239c authored by Bean Huo's avatar Bean Huo Committed by Martin K. Petersen

scsi: ufs: ufshpb: Merge ufshpb_reset() and ufshpb_reset_host()

There is no functional change in this patch, just merge ufshpb_reset() and
ufshpb_reset_host() into one function ufshpb_toggle_state().

Link: https://lore.kernel.org/r/20220505134707.35929-2-huobean@gmail.comReviewed-by: default avatarKeoseong Park <keosung.park@samsung.com>
Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6f21d927
...@@ -7226,7 +7226,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) ...@@ -7226,7 +7226,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
* Stop the host controller and complete the requests * Stop the host controller and complete the requests
* cleared by h/w * cleared by h/w
*/ */
ufshpb_reset_host(hba); ufshpb_toggle_state(hba, HPB_PRESENT, HPB_RESET);
ufshcd_hba_stop(hba); ufshcd_hba_stop(hba);
hba->silence_err_logs = true; hba->silence_err_logs = true;
ufshcd_complete_requests(hba); ufshcd_complete_requests(hba);
...@@ -8193,7 +8193,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) ...@@ -8193,7 +8193,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
/* Enable Auto-Hibernate if configured */ /* Enable Auto-Hibernate if configured */
ufshcd_auto_hibern8_enable(hba); ufshcd_auto_hibern8_enable(hba);
ufshpb_reset(hba); ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT);
out: out:
spin_lock_irqsave(hba->host->host_lock, flags); spin_lock_irqsave(hba->host->host_lock, flags);
if (ret) if (ret)
......
...@@ -2272,38 +2272,28 @@ static bool ufshpb_check_hpb_reset_query(struct ufs_hba *hba) ...@@ -2272,38 +2272,28 @@ static bool ufshpb_check_hpb_reset_query(struct ufs_hba *hba)
return flag_res; return flag_res;
} }
void ufshpb_reset(struct ufs_hba *hba) /**
* ufshpb_toggle_state - 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_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest)
{ {
struct ufshpb_lu *hpb; struct ufshpb_lu *hpb;
struct scsi_device *sdev; struct scsi_device *sdev;
shost_for_each_device(sdev, hba->host) { shost_for_each_device(sdev, hba->host) {
hpb = ufshpb_get_hpb_data(sdev); 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) { if (!hpb || ufshpb_get_state(hpb) != src)
hpb = ufshpb_get_hpb_data(sdev);
if (!hpb)
continue; continue;
ufshpb_set_state(hpb, dest);
if (ufshpb_get_state(hpb) != HPB_PRESENT) if (dest == HPB_RESET) {
continue; ufshpb_cancel_jobs(hpb);
ufshpb_set_state(hpb, HPB_RESET); ufshpb_discard_rsp_lists(hpb);
ufshpb_cancel_jobs(hpb); }
ufshpb_discard_rsp_lists(hpb);
} }
} }
......
...@@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; ...@@ -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_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {}
static void ufshpb_resume(struct ufs_hba *hba) {} static void ufshpb_resume(struct ufs_hba *hba) {}
static void ufshpb_suspend(struct ufs_hba *hba) {} static void ufshpb_suspend(struct ufs_hba *hba) {}
static void ufshpb_reset(struct ufs_hba *hba) {} static void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {}
static void ufshpb_reset_host(struct ufs_hba *hba) {}
static void ufshpb_init(struct ufs_hba *hba) {} 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_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}
static void ufshpb_destroy_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); ...@@ -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_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
void ufshpb_resume(struct ufs_hba *hba); void ufshpb_resume(struct ufs_hba *hba);
void ufshpb_suspend(struct ufs_hba *hba); void ufshpb_suspend(struct ufs_hba *hba);
void ufshpb_reset(struct ufs_hba *hba); void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest);
void ufshpb_reset_host(struct ufs_hba *hba);
void ufshpb_init(struct ufs_hba *hba); void ufshpb_init(struct ufs_hba *hba);
void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev); 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); void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);
......
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