diff --git a/drivers/crypto/msm/ice.c b/drivers/crypto/msm/ice.c index ab9f7f6dec84..fd34c0bc39f5 100644 --- a/drivers/crypto/msm/ice.c +++ b/drivers/crypto/msm/ice.c @@ -846,18 +846,27 @@ static int qcom_ice_remove(struct platform_device *pdev) static int qcom_ice_suspend(struct platform_device *pdev) { struct ice_device *ice_dev; + int ret = 0; ice_dev = (struct ice_device *)platform_get_drvdata(pdev); if (!ice_dev) return -EINVAL; - if (atomic_read(&ice_dev->is_ice_busy) != 0) - wait_event_interruptible_timeout( + if (atomic_read(&ice_dev->is_ice_busy) != 0) { + ret = wait_event_interruptible_timeout( ice_dev->block_suspend_ice_queue, - atomic_read(&ice_dev->is_ice_busy) != 0, + atomic_read(&ice_dev->is_ice_busy) == 0, msecs_to_jiffies(1000)); + if (!ret) { + pr_err("%s: Suspend ICE during an ongoing operation\n", + __func__); + atomic_set(&ice_dev->is_ice_suspended, 0); + return -ETIME; + } + } + atomic_set(&ice_dev->is_ice_suspended, 1); return 0;