Skip to content

Commit 195118a

Browse files
ptr324smb49
authored andcommitted
scsi: ufs: core: Add missing post notify for power mode change
BugLink: https://bugs.launchpad.net/bugs/2102118 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: stable@vger.kernel.org #6.11.x Signed-off-by: Peter Wang <peter.wang@mediatek.com> Link: https://lore.kernel.org/r/20241122024943.30589-1-peter.wang@mediatek.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 9c45db9 commit 195118a

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
@@ -4655,9 +4655,6 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
46554655
dev_err(hba->dev,
46564656
"%s: power mode change failed %d\n", __func__, ret);
46574657
} else {
4658-
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4659-
pwr_mode);
4660-
46614658
memcpy(&hba->pwr_info, pwr_mode,
46624659
sizeof(struct ufs_pa_layer_attr));
46634660
}
@@ -4686,6 +4683,10 @@ int ufshcd_config_pwr_mode(struct ufs_hba *hba,
46864683

46874684
ret = ufshcd_change_power_mode(hba, &final_params);
46884685

4686+
if (!ret)
4687+
ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
4688+
&final_params);
4689+
46894690
return ret;
46904691
}
46914692
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
@@ -306,7 +306,9 @@ struct ufs_pwr_mode_info {
306306
* to allow variant specific Uni-Pro initialization.
307307
* @pwr_change_notify: called before and after a power mode change
308308
* is carried out to allow vendor spesific capabilities
309-
* to be set.
309+
* to be set. PRE_CHANGE can modify final_params based
310+
* on desired_pwr_mode, but POST_CHANGE must not alter
311+
* the final_params parameter
310312
* @setup_xfer_req: called before any transfer request is issued
311313
* to set some things
312314
* @setup_task_mgmt: called before any task management request is issued
@@ -343,9 +345,9 @@ struct ufs_hba_variant_ops {
343345
int (*link_startup_notify)(struct ufs_hba *,
344346
enum ufs_notify_change_status);
345347
int (*pwr_change_notify)(struct ufs_hba *,
346-
enum ufs_notify_change_status status,
347-
struct ufs_pa_layer_attr *,
348-
struct ufs_pa_layer_attr *);
348+
enum ufs_notify_change_status status,
349+
struct ufs_pa_layer_attr *desired_pwr_mode,
350+
struct ufs_pa_layer_attr *final_params);
349351
void (*setup_xfer_req)(struct ufs_hba *hba, int tag,
350352
bool is_scsi_cmd);
351353
void (*setup_task_mgmt)(struct ufs_hba *, int, u8);

0 commit comments

Comments
 (0)