]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
scsi: ufs: core: Add missing post notify for power mode change
authorPeter Wang <peter.wang@mediatek.com>
Fri, 22 Nov 2024 02:49:43 +0000 (10:49 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 4 Dec 2024 18:22:59 +0000 (13:22 -0500)
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: 7eb584db73be ("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>
drivers/ufs/core/ufshcd.c
include/ufs/ufshcd.h

index 25c8b3f5717178bdf9f7011b11bddad8351beea5..b7ec5797d5baa65e73d7f158093529f2da626ad8 100644 (file)
@@ -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));
        }
@@ -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);
index d7aca9e61684f9208f58126ff5c85b2934028361..d650ae6b58d3906c9aafa071bed5a62c7e528f27 100644 (file)
@@ -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
@@ -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);