]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/scsi-ufs-avoid-runtime-suspend-possibly-being-blocked-forever.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.9 / scsi-ufs-avoid-runtime-suspend-possibly-being-blocked-forever.patch
1 From 24e2e7a19f7e4b83d0d5189040d997bce3596473 Mon Sep 17 00:00:00 2001
2 From: Stanley Chu <stanley.chu@mediatek.com>
3 Date: Wed, 12 Jun 2019 23:19:05 +0800
4 Subject: scsi: ufs: Avoid runtime suspend possibly being blocked forever
5
6 From: Stanley Chu <stanley.chu@mediatek.com>
7
8 commit 24e2e7a19f7e4b83d0d5189040d997bce3596473 upstream.
9
10 UFS runtime suspend can be triggered after pm_runtime_enable() is invoked
11 in ufshcd_pltfrm_init(). However if the first runtime suspend is triggered
12 before binding ufs_hba structure to ufs device structure via
13 platform_set_drvdata(), then UFS runtime suspend will be no longer
14 triggered in the future because its dev->power.runtime_error was set in the
15 first triggering and does not have any chance to be cleared.
16
17 To be more clear, dev->power.runtime_error is set if hba is NULL in
18 ufshcd_runtime_suspend() which returns -EINVAL to rpm_callback() where
19 dev->power.runtime_error is set as -EINVAL. In this case, any future
20 rpm_suspend() for UFS device fails because rpm_check_suspend_allowed()
21 fails due to non-zero
22 dev->power.runtime_error.
23
24 To resolve this issue, make sure the first UFS runtime suspend get valid
25 "hba" in ufshcd_runtime_suspend(): Enable UFS runtime PM only after hba is
26 successfully bound to UFS device structure.
27
28 Fixes: 62694735ca95 ([SCSI] ufs: Add runtime PM support for UFS host controller driver)
29 Cc: stable@vger.kernel.org
30 Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
31 Reviewed-by: Avri Altman <avri.altman@wdc.com>
32 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35 ---
36 drivers/scsi/ufs/ufshcd-pltfrm.c | 11 ++++-------
37 1 file changed, 4 insertions(+), 7 deletions(-)
38
39 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
40 +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
41 @@ -342,24 +342,21 @@ int ufshcd_pltfrm_init(struct platform_d
42 goto dealloc_host;
43 }
44
45 - pm_runtime_set_active(&pdev->dev);
46 - pm_runtime_enable(&pdev->dev);
47 -
48 ufshcd_init_lanes_per_dir(hba);
49
50 err = ufshcd_init(hba, mmio_base, irq);
51 if (err) {
52 dev_err(dev, "Initialization failed\n");
53 - goto out_disable_rpm;
54 + goto dealloc_host;
55 }
56
57 platform_set_drvdata(pdev, hba);
58
59 + pm_runtime_set_active(&pdev->dev);
60 + pm_runtime_enable(&pdev->dev);
61 +
62 return 0;
63
64 -out_disable_rpm:
65 - pm_runtime_disable(&pdev->dev);
66 - pm_runtime_set_suspended(&pdev->dev);
67 dealloc_host:
68 ufshcd_dealloc_host(hba);
69 out: