Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755431AbcDNM6E (ORCPT ); Thu, 14 Apr 2016 08:58:04 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:59102 "EHLO mx0a-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008AbcDNM5x (ORCPT ); Thu, 14 Apr 2016 08:57:53 -0400 From: Jisheng Zhang To: , , , CC: , , , Jisheng Zhang Subject: [PATCH 1/4] i2c: designware-platdrv: Fix runtime PM initialization Date: Thu, 14 Apr 2016 20:53:31 +0800 Message-ID: <1460638414-5987-2-git-send-email-jszhang@marvell.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1460638414-5987-1-git-send-email-jszhang@marvell.com> References: <1460638414-5987-1-git-send-email-jszhang@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-14_07:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603180000 definitions=main-1604140186 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1450 Lines: 46 When pm_runtime_enable() was being called, the device's usage counter was 0, causing the PM layer to runtime-suspend the device. We then went on to call i2c_dw_probe() on a suspended device, which could hung. Fix this by incrementing the usage counter before pm_runtime_enable(). Signed-off-by: Jisheng Zhang --- drivers/i2c/busses/i2c-designware-platdrv.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index d656657..00f9e99 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -246,6 +246,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (dev->pm_runtime_disabled) { pm_runtime_forbid(&pdev->dev); } else { + pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_active(&pdev->dev); @@ -253,8 +254,19 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) } r = i2c_dw_probe(dev); - if (r && !dev->pm_runtime_disabled) + if (r) + goto rpm_disable; + + if (!dev->pm_runtime_disabled) + pm_runtime_put_autosuspend(&pdev->dev); + + return 0; + +rpm_disable: + if (!dev->pm_runtime_disabled) { pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + } return r; } -- 2.8.0.rc3