Skip to content

Commit 1e30b52

Browse files
ptr324gregkh
authored andcommitted
scsi: ufs: core: Add missing post notify for power mode change
commit 7f45ed5 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0069928 commit 1e30b52

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,9 +4555,6 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
45554555
dev_err(hba->dev,
45564556
"%s: power mode change failed %d\n", __func__, ret);
45574557
} else {
4558-
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4559-
pwr_mode);
4560-
45614558
memcpy(&hba->pwr_info, pwr_mode,
45624559
sizeof(struct ufs_pa_layer_attr));
45634560
}
@@ -4586,6 +4583,10 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba,
45864583

45874584
ret = ufshcd_change_power_mode(hba, &final_params);
45884585

4586+
if (!ret)
4587+
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4588+
&final_params);
4589+
45894590
return ret;
45904591
}
45914592
EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);

include/ufs/ufshcd.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ struct ufs_pwr_mode_info {
304304
* to allow variant specific Uni-Pro initialization.
305305
* @pwr_change_notify: called before and after a power mode change
306306
* is carried out to allow vendor spesific capabilities
307-
* to be set.
307+
* to be set. PRE_CHANGE can modify final_params based
308+
* on desired_pwr_mode, but POST_CHANGE must not alter
309+
* the final_params parameter
308310
* @setup_xfer_req: called before any transfer request is issued
309311
* to set some things
310312
* @setup_task_mgmt: called before any task management request is issued
@@ -341,9 +343,9 @@ struct ufs_hba_variant_ops {
341343
int (*link_startup_notify)(struct ufs_hba *,
342344
enum ufs_notify_change_status);
343345
int (*pwr_change_notify)(struct ufs_hba *,
344-
enum ufs_notify_change_status status,
345-
struct ufs_pa_layer_attr *,
346-
struct ufs_pa_layer_attr *);
346+
enum ufs_notify_change_status status,
347+
struct ufs_pa_layer_attr *desired_pwr_mode,
348+
struct ufs_pa_layer_attr *final_params);
347349
void (*setup_xfer_req)(struct ufs_hba *hba, int tag,
348350
bool is_scsi_cmd);
349351
void (*setup_task_mgmt)(struct ufs_hba *, int, u8);

0 commit comments

Comments
 (0)