Skip to content

Commit 7f45ed5

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: core: Add missing post notify for power mode change
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]>
1 parent f10593a commit 7f45ed5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/ufs/core/ufshcd.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -4671,9 +4671,6 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
46714671
dev_err(hba->dev,
46724672
"%s: power mode change failed %d\n", __func__, ret);
46734673
} else {
4674-
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4675-
pwr_mode);
4676-
46774674
memcpy(&hba->pwr_info, pwr_mode,
46784675
sizeof(struct ufs_pa_layer_attr));
46794676
}
@@ -4702,6 +4699,10 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba,
47024699

47034700
ret = ufshcd_change_power_mode(hba, &final_params);
47044701

4702+
if (!ret)
4703+
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4704+
&final_params);
4705+
47054706
return ret;
47064707
}
47074708
EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);

include/ufs/ufshcd.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ struct ufs_pwr_mode_info {
310310
* to allow variant specific Uni-Pro initialization.
311311
* @pwr_change_notify: called before and after a power mode change
312312
* is carried out to allow vendor spesific capabilities
313-
* to be set.
313+
* to be set. PRE_CHANGE can modify final_params based
314+
* on desired_pwr_mode, but POST_CHANGE must not alter
315+
* the final_params parameter
314316
* @setup_xfer_req: called before any transfer request is issued
315317
* to set some things
316318
* @setup_task_mgmt: called before any task management request is issued
@@ -353,9 +355,9 @@ struct ufs_hba_variant_ops {
353355
int (*link_startup_notify)(struct ufs_hba *,
354356
enum ufs_notify_change_status);
355357
int (*pwr_change_notify)(struct ufs_hba *,
356-
enum ufs_notify_change_status status,
357-
struct ufs_pa_layer_attr *,
358-
struct ufs_pa_layer_attr *);
358+
enum ufs_notify_change_status status,
359+
struct ufs_pa_layer_attr *desired_pwr_mode,
360+
struct ufs_pa_layer_attr *final_params);
359361
void (*setup_xfer_req)(struct ufs_hba *hba, int tag,
360362
bool is_scsi_cmd);
361363
void (*setup_task_mgmt)(struct ufs_hba *, int, u8);

0 commit comments

Comments
 (0)