Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4823083ybl; Wed, 22 Jan 2020 05:25:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxZob3UzzsCK6GMuJwPfyWxkRH/5S2nTrYYAxJavSqQA0y0m9RasBGKHlOCaKItPOVOCih3 X-Received: by 2002:aca:1713:: with SMTP id j19mr6717194oii.160.1579699524615; Wed, 22 Jan 2020 05:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699524; cv=none; d=google.com; s=arc-20160816; b=P2C1ASpv8YTbZ5Cmz319zyLDCOVN4rbYSt5QdzqhAPaBhDlbNN2Fer6cpfoUVKFb+q UJ7j9QJ0nrY1AczyJ5r3dz/JfjQ9e/Ud99FMg9CNhPDRa3fKUF+rgLN3b5o1j2P2N30w soEfdY2rwr5IUdX6dCUpO171PU0OqnrWlx3tXpwKzNrs0ywWntfmqvxQw3Dx7HIjrF+f 0jCx2H9/0cU6fSQVbKMVTIcGKHZVyAJxjUL51g1IcreVudOuayhWZkroOBGIfrw76NX2 SpnpuQKXP0cTLEpb2b7p/pcQ7tKvSxiDkuDWcvq6JZmR2eGSc0731WtvXLuU7KBmXj4O OdXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BdnMK7ILmf1PPJYqPZiaqVo5aymH41mSjL8oYJ97848=; b=FCnMqh8XEKKt8zRZtS3BrZy2RGCDqOk2zEs+hdDfhtNqTIFuNlNE7Ge9eOPhucfRVZ R/VizrcUPSAxBe7WqZ+vAO3Ksln9g4k4AK2Qj3ausYPVEw6zd2zpO8BCXAq/6lLYasEv xXSfISwhd5vfr6fScpKxCRD/1fAaj05d0D636uOhwowcfYvuedZ3PdgwZvrk+slbHdzH GTQlZnrTVcyhQj6ZGgYQmSqwswNL55auNlPo4YPOH2zEdbT1XMtJAP28QsttHXKGsZWv GOhiD0ytVie24B0syAMvBRqMUcLjO8UgPUq4TKVqtOs9Lomn9Ks2G9C4dDzSflpHQB9i g8oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ivs2CYIf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89si17703895otf.231.2020.01.22.05.25.13; Wed, 22 Jan 2020 05:25:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ivs2CYIf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730990AbgAVNYY (ORCPT + 99 others); Wed, 22 Jan 2020 08:24:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:43288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730677AbgAVNYW (ORCPT ); Wed, 22 Jan 2020 08:24:22 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 673902468A; Wed, 22 Jan 2020 13:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699462; bh=4EbajuRZsUnZKJ3OzlpYEySvgEwAm9G1z/wFKtlybhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivs2CYIfoU4z3YZBw5sksuR4UcZP85t5Kt++cSbB2dIVzuQwUGE/ds9vsIFtX7MuX 6syzafveyIp//96I9YIFdYujV3LwC5pBrPDGhRVqB+v8ee2p1vtrl3OqY2kG2lHN9Z /2X/n1ICYutKGNauJYhjp6FxNJoQw4v68+r1M4Og= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Dmitry Osipenko , Wolfram Sang Subject: [PATCH 5.4 117/222] i2c: tegra: Properly disable runtime PM on drivers probe error Date: Wed, 22 Jan 2020 10:28:23 +0100 Message-Id: <20200122092842.109113952@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko commit 24a49678f5e20f18006e71b90ac1531876b27eb1 upstream. One of the recent Tegra I2C commits made a change that resumes runtime PM during driver's probe, but it missed to put the RPM in a case of error. Note that it's not correct to use pm_runtime_status_suspended because it breaks RPM refcounting. Fixes: 8ebf15e9c869 ("i2c: tegra: Move suspend handling to NOIRQ phase") Cc: # v5.4+ Tested-by: Thierry Reding Signed-off-by: Dmitry Osipenko Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-tegra.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1608,14 +1608,18 @@ static int tegra_i2c_probe(struct platfo } pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) + if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra_i2c_runtime_resume(&pdev->dev); - else + if (ret < 0) { + dev_err(&pdev->dev, "runtime resume failed\n"); + goto unprepare_div_clk; + } + } else { ret = pm_runtime_get_sync(i2c_dev->dev); - - if (ret < 0) { - dev_err(&pdev->dev, "runtime resume failed\n"); - goto unprepare_div_clk; + if (ret < 0) { + dev_err(&pdev->dev, "runtime resume failed\n"); + goto disable_rpm; + } } if (i2c_dev->is_multimaster_mode) { @@ -1623,7 +1627,7 @@ static int tegra_i2c_probe(struct platfo if (ret < 0) { dev_err(i2c_dev->dev, "div_clk enable failed %d\n", ret); - goto disable_rpm; + goto put_rpm; } } @@ -1671,11 +1675,16 @@ disable_div_clk: if (i2c_dev->is_multimaster_mode) clk_disable(i2c_dev->div_clk); -disable_rpm: - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) +put_rpm: + if (pm_runtime_enabled(&pdev->dev)) + pm_runtime_put_sync(&pdev->dev); + else tegra_i2c_runtime_suspend(&pdev->dev); +disable_rpm: + if (pm_runtime_enabled(&pdev->dev)) + pm_runtime_disable(&pdev->dev); + unprepare_div_clk: clk_unprepare(i2c_dev->div_clk);