Skip to content

Commit

Permalink
scsi: ufs: core: Add missing post notify for power mode change
Browse files Browse the repository at this point in the history
When the power mode change is successful but the power mode hasn't
actually changed, the post notification was missed.  Similar to the
approach with hibernate/clock scale/hce enable, having pre/post
notifications in the same function will make it easier to maintain.

Additionally, supplement the description of power parameters for the
pwr_change_notify callback.

Fixes: 7eb584d ("ufs: refactor configuring power mode")
Cc: [email protected] #6.11.x
Signed-off-by: Peter Wang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
ptr324 authored and martinkpetersen committed Dec 4, 2024
1 parent f10593a commit 7f45ed5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions drivers/ufs/core/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4671,9 +4671,6 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
dev_err(hba->dev,
"%s: power mode change failed %d\n", __func__, ret);
} else {
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
pwr_mode);

memcpy(&hba->pwr_info, pwr_mode,
sizeof(struct ufs_pa_layer_attr));
}
Expand Down Expand Up @@ -4702,6 +4699,10 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba,

ret = ufshcd_change_power_mode(hba, &final_params);

if (!ret)
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
&final_params);

return ret;
}
EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);
Expand Down
10 changes: 6 additions & 4 deletions include/ufs/ufshcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ struct ufs_pwr_mode_info {
* to allow variant specific Uni-Pro initialization.
* @pwr_change_notify: called before and after a power mode change
* is carried out to allow vendor spesific capabilities
* to be set.
* to be set. PRE_CHANGE can modify final_params based
* on desired_pwr_mode, but POST_CHANGE must not alter
* the final_params parameter
* @setup_xfer_req: called before any transfer request is issued
* to set some things
* @setup_task_mgmt: called before any task management request is issued
Expand Down Expand Up @@ -353,9 +355,9 @@ struct ufs_hba_variant_ops {
int (*link_startup_notify)(struct ufs_hba *,
enum ufs_notify_change_status);
int (*pwr_change_notify)(struct ufs_hba *,
enum ufs_notify_change_status status,
struct ufs_pa_layer_attr *,
struct ufs_pa_layer_attr *);
enum ufs_notify_change_status status,
struct ufs_pa_layer_attr *desired_pwr_mode,
struct ufs_pa_layer_attr *final_params);
void (*setup_xfer_req)(struct ufs_hba *hba, int tag,
bool is_scsi_cmd);
void (*setup_task_mgmt)(struct ufs_hba *, int, u8);
Expand Down

0 comments on commit 7f45ed5

Please sign in to comment.