* Re: [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3)
2025-10-12 17:38 [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3) Nitin Rawat
@ 2025-10-22 22:22 ` Nitin Rawat
2025-10-23 5:08 ` Manivannan Sadhasivam
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Nitin Rawat @ 2025-10-22 22:22 UTC (permalink / raw)
To: Nitin Rawat, mani, James.Bottomley, martin.petersen, bvanassche,
konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi
On 10/12/2025 11:08 PM, Nitin Rawat wrote:
> According to UFS specifications, the power-off sequence for a UFS
> device includes:
>
> - Sending an SSU command with Power_Condition=3 and await a
> response.
> - Asserting RST_N low.
> - Turning off REF_CLK.
> - Turning off VCC.
> - Turning off VCCQ/VCCQ2.
>
> As part of ufs shutdown , after the SSU command completion, asserting
> hardware reset (HWRST) triggers the device firmware to wake up and
> execute its reset routine. This routine initializes hardware blocks
> and takes a few milliseconds to complete. During this time, the
> ICCQ draws a large current.
>
> This large ICCQ current may cause issues for the regulator which
> is supplying power to UFS, because the turn off request from UFS
> driver to the regulator framework will be immediately followed by
> low power mode(LPM) request by regulator framework. This is done
> by framework because UFS which is the only client is requesting
> for disable. So if the rail is still in the process of shutting down
> while ICCQ exceeds LPM current thresholds, and LPM mode is activated
> in hardware during this state, it may trigger an overcurrent
> protection (OCP) fault in the regulator.
>
> To prevent this, a 10ms delay is added after asserting HWRST. This
> allows the reset operation to complete while power rails remain active
> and in high-power mode.
>
> Currently there is no way for Host to query whether the reset is
> completed or not and hence this the delay is based on experiments
> with Qualcomm UFS controllers across multiple UFS vendors.
>
> Signed-off-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 89a3328a7a75..cb54628be466 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -744,8 +744,21 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
>
>
> /* reset the connected UFS device during power down */
> - if (ufs_qcom_is_link_off(hba) && host->device_reset)
> + if (ufs_qcom_is_link_off(hba) && host->device_reset) {
> ufs_qcom_device_reset_ctrl(hba, true);
> + /*
> + * After sending the SSU command, asserting the rst_n
> + * line causes the device firmware to wake up and
> + * execute its reset routine.
> + *
> + * During this process, the device may draw current
> + * beyond the permissible limit for low-power mode (LPM).
> + * A 10ms delay, based on experimental observations,
> + * allows the UFS device to complete its hardware reset
> + * before transitioning the power rail to LPM.
> + */
> + usleep_range(10000, 11000);
> + }
>
> return ufs_qcom_ice_suspend(host);
> }
> --
> 2.50.1
>
>
Gentle reminder for review!!
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3)
2025-10-12 17:38 [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3) Nitin Rawat
2025-10-22 22:22 ` Nitin Rawat
@ 2025-10-23 5:08 ` Manivannan Sadhasivam
2025-10-24 2:08 ` Martin K. Petersen
2025-10-24 3:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2025-10-23 5:08 UTC (permalink / raw)
To: Nitin Rawat
Cc: James.Bottomley, martin.petersen, bvanassche, konrad.dybcio,
linux-arm-msm, linux-kernel, linux-scsi
On Sun, Oct 12, 2025 at 11:08:28PM +0530, Nitin Rawat wrote:
> According to UFS specifications, the power-off sequence for a UFS
> device includes:
>
> - Sending an SSU command with Power_Condition=3 and await a
> response.
> - Asserting RST_N low.
> - Turning off REF_CLK.
> - Turning off VCC.
> - Turning off VCCQ/VCCQ2.
>
> As part of ufs shutdown , after the SSU command completion, asserting
> hardware reset (HWRST) triggers the device firmware to wake up and
> execute its reset routine. This routine initializes hardware blocks
> and takes a few milliseconds to complete. During this time, the
> ICCQ draws a large current.
>
> This large ICCQ current may cause issues for the regulator which
> is supplying power to UFS, because the turn off request from UFS
> driver to the regulator framework will be immediately followed by
> low power mode(LPM) request by regulator framework. This is done
> by framework because UFS which is the only client is requesting
> for disable. So if the rail is still in the process of shutting down
> while ICCQ exceeds LPM current thresholds, and LPM mode is activated
> in hardware during this state, it may trigger an overcurrent
> protection (OCP) fault in the regulator.
>
> To prevent this, a 10ms delay is added after asserting HWRST. This
> allows the reset operation to complete while power rails remain active
> and in high-power mode.
>
> Currently there is no way for Host to query whether the reset is
> completed or not and hence this the delay is based on experiments
> with Qualcomm UFS controllers across multiple UFS vendors.
>
> Signed-off-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
- Mani
> ---
> drivers/ufs/host/ufs-qcom.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 89a3328a7a75..cb54628be466 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -744,8 +744,21 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
>
>
> /* reset the connected UFS device during power down */
> - if (ufs_qcom_is_link_off(hba) && host->device_reset)
> + if (ufs_qcom_is_link_off(hba) && host->device_reset) {
> ufs_qcom_device_reset_ctrl(hba, true);
> + /*
> + * After sending the SSU command, asserting the rst_n
> + * line causes the device firmware to wake up and
> + * execute its reset routine.
> + *
> + * During this process, the device may draw current
> + * beyond the permissible limit for low-power mode (LPM).
> + * A 10ms delay, based on experimental observations,
> + * allows the UFS device to complete its hardware reset
> + * before transitioning the power rail to LPM.
> + */
> + usleep_range(10000, 11000);
> + }
>
> return ufs_qcom_ice_suspend(host);
> }
> --
> 2.50.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3)
2025-10-12 17:38 [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3) Nitin Rawat
2025-10-22 22:22 ` Nitin Rawat
2025-10-23 5:08 ` Manivannan Sadhasivam
@ 2025-10-24 2:08 ` Martin K. Petersen
2025-10-24 3:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2025-10-24 2:08 UTC (permalink / raw)
To: Nitin Rawat
Cc: mani, James.Bottomley, martin.petersen, bvanassche, konrad.dybcio,
linux-arm-msm, linux-kernel, linux-scsi
Nitin,
> To prevent this, a 10ms delay is added after asserting HWRST. This
> allows the reset operation to complete while power rails remain active
> and in high-power mode.
>
> Currently there is no way for Host to query whether the reset is
> completed or not and hence this the delay is based on experiments
> with Qualcomm UFS controllers across multiple UFS vendors.
Applied to 6.18/scsi-fixes, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3)
2025-10-12 17:38 [PATCH V1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3) Nitin Rawat
` (2 preceding siblings ...)
2025-10-24 2:08 ` Martin K. Petersen
@ 2025-10-24 3:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2025-10-24 3:09 UTC (permalink / raw)
To: mani, James.Bottomley, bvanassche, konrad.dybcio, Nitin Rawat
Cc: Martin K . Petersen, linux-arm-msm, linux-kernel, linux-scsi
On Sun, 12 Oct 2025 23:08:28 +0530, Nitin Rawat wrote:
> According to UFS specifications, the power-off sequence for a UFS
> device includes:
>
> - Sending an SSU command with Power_Condition=3 and await a
> response.
> - Asserting RST_N low.
> - Turning off REF_CLK.
> - Turning off VCC.
> - Turning off VCCQ/VCCQ2.
>
> [...]
Applied to 6.18/scsi-fixes, thanks!
[1/1] ufs: ufs-qcom: Fix UFS OCP issue during UFS power down(PC=3)
https://git.kernel.org/mkp/scsi/c/5127be409c6c
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 5+ messages in thread