From 70e0b8e2147e53529095e6e32ed335b940301d8a Mon Sep 17 00:00:00 2001 From: Yifeng Zhao Date: Wed, 30 Oct 2024 11:00:51 +0800 Subject: [PATCH] scsi: ufs: rockchip: fix dme-reset failed issue Resetting the device without resetting the controller during exception handling will result in a dme command error. log: ufshcd-rockchip 2a2d0000.ufs: uic cmd 0x14 with arg3 0x0 completion timeout ufshcd-rockchip 2a2d0000.ufs: dme-reset: error code -110 ufshcd-rockchip 2a2d0000.ufs: DME_RESET failed ufshcd-rockchip 2a2d0000.ufs: ufshcd_host_reset_and_restore: Host init failed -110 Change-Id: Ia83e80aea0f6b916bf7131d0b2240023f32a1a21 Signed-off-by: Yifeng Zhao --- drivers/ufs/host/ufs-rockchip.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/host/ufs-rockchip.c b/drivers/ufs/host/ufs-rockchip.c index 53104cceb299..e7a3191cb4b2 100644 --- a/drivers/ufs/host/ufs-rockchip.c +++ b/drivers/ufs/host/ufs-rockchip.c @@ -182,14 +182,25 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba) return ret; } +static void ufs_rockchip_controller_reset(struct ufs_rockchip_host *host) +{ + reset_control_assert(host->rst); + udelay(1); + reset_control_deassert(host->rst); +} + static int ufs_rockchip_hce_enable_notify(struct ufs_hba *hba, enum ufs_notify_change_status status) { + struct ufs_rockchip_host *host = ufshcd_get_variant(hba); int err = 0; if (status == PRE_CHANGE) { int retry_outer = 3; int retry_inner; + + ufs_rockchip_controller_reset(host); + start: if (ufshcd_is_hba_active(hba)) /* change controller state to "reset state" */ @@ -374,9 +385,7 @@ static int ufs_rockchip_common_init(struct ufs_hba *hba) return PTR_ERR(host->rst); } - reset_control_assert(host->rst); - udelay(1); - reset_control_deassert(host->rst); + ufs_rockchip_controller_reset(host); host->ref_out_clk = devm_clk_get(dev, "ref_out"); if (IS_ERR(host->ref_out_clk)) {