Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3088117ybl; Sun, 12 Jan 2020 09:27:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyO4nNVuMxoBIHeORqmbKDGxasPAXY/PvTIVnxPfGIAQSNexwcIiD/yBtkoj/n+3xtQKs6L X-Received: by 2002:a9d:6b17:: with SMTP id g23mr9936644otp.265.1578850044473; Sun, 12 Jan 2020 09:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578850044; cv=none; d=google.com; s=arc-20160816; b=oVFLhsxQ3UA4u+FKAiYznxz1gzrgNTXIVYodKokR1SQbENgR81z3W4LWVSAPK6P4KA sMvK3HGgKgJrMAOMS/Jnb+Lvfbl+GfgOHpOSCqLf7TwYJ4WoapbcT9qBGkUGab+ktsiC b2ZEj2PM4r5ntOhbNt+l515H8HPg1wMPQPH6Ax7mbaKY9YSo5VKrP4rUns+dAOX8fWHN nk9/FA47EWtovgySw/YlO0ExFf1FEC3ti9HNz+J3dBscfG3yGJ60iH2n16z/XrkKeH5Y xdw4Mju/54KLW+n6dNX3AKPpA9/N5qYWA2y+cfPxd6MhPFQdPMh1nZbiBA8FG3gPV+7b d9CA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=boftLlCVTiCXcZl17ggg/i9GnkxPrBq2/azgLeosNdc=; b=e6MRfk3t5+ZFLuUN4vho1VCR5D/z5+y3Px5kjATqu2zvJv2lPkBVyjEblULxddPNJj TXSlbaFWttHzkOibTRfCwzqlZGRHNtNvqJCU/qi7TRGwZGxmI2o7winZ2oV2jclVEyTP wPc5G3Ts5iR9DFIzG1IOKjQ6csMAjPQyxm+WdxGZeJW69PvAFt3YQOtK4i8AIPSlzUlB KxrXk+NwakBi94WNJgzfK6qo2wSp1Jn2CUpDPVScNE3YSb4bKsR/Rh2gGrqkYezktZ3Y HcZ45h2+fOojaogY0cKplhRrkJsTbif7Sa04zQW+7lQhRTsiQhibATK/WznHBltQBm9Z pqbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ss1uB9Iq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si5080099ota.300.2020.01.12.09.27.12; Sun, 12 Jan 2020 09:27: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=@gmail.com header.s=20161025 header.b=Ss1uB9Iq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733160AbgALRRr (ORCPT + 99 others); Sun, 12 Jan 2020 12:17:47 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39812 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728734AbgALRRn (ORCPT ); Sun, 12 Jan 2020 12:17:43 -0500 Received: by mail-lf1-f67.google.com with SMTP id y1so5134161lfb.6; Sun, 12 Jan 2020 09:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=boftLlCVTiCXcZl17ggg/i9GnkxPrBq2/azgLeosNdc=; b=Ss1uB9IqTcBQuWmvl8XgQHGygt9/V59mKPWQMYzSzAdsmG5PYHBhb3Lv/BWvPg6LDh MKgtCzJgOayubGM4Z8PsghsmMLLj+rEiSSLtCOcftzD1XoJBeP0wzQOirab4EFYFbyGb Fm8GEt1kxJ/TPiMbSEuIN/qfgkg+B2l+gLipIQ21L81OxIUYpqi9fRJIhiPl8QfACqOu E1z/dh/wNU800lELQt7Fl9ntLr/5BRyoI/yClrQd6dIk4CJ2EvWXwpXQCmCAG3TdBEbJ WxvzObFsOhbhkzMpVZStswd2m5Qb7X6UJZIHBh2fiJGlIlHH4bKM8BIw1yBb0xsm713k SJaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=boftLlCVTiCXcZl17ggg/i9GnkxPrBq2/azgLeosNdc=; b=Claen69xzbFxnvhrVa6JSPcuoM2OxM0DBHTrEUae14TgH+gM+u3XlZM+pmOKJe3/2T RGTIEPd96vAkoAtntNHTm0ftTyW8jnpA6etvbeoAWYJ6D/GPQLFDS1rht6lAsyYJf21c 7LMvRJMsYQ+aoYTCB1je/FtBcT2CaLs9Q545APuJS1/IjwjfYWtQStABKye81IXjj2sc Idw/6jwrt/0QbkMEAc2pmi53KgSNLp+TaLI6GCtAmlL5kVb8LqumvX98EA1rUH3N7nPW XloTV5ZhT/o4K7C3lANBiKt9/byOebvc6GDibxdVTTAnRdgEcFL0Oy9d7On5N/5sBqeJ I9gg== X-Gm-Message-State: APjAAAVJUxGbknZBONqcnFxFkMyQDyfE1pyS0PRAHr1MImQnX5R+LTiW Ckkm/Veq5PAqpown6C+9mnNg+1W9 X-Received: by 2002:a19:2d0d:: with SMTP id k13mr7455372lfj.12.1578849461233; Sun, 12 Jan 2020 09:17:41 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id i13sm4506628ljg.89.2020.01.12.09.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:17:40 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Mikko Perttunen , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/8] i2c: tegra: Properly disable runtime PM on driver's probe error Date: Sun, 12 Jan 2020 20:14:24 +0300 Message-Id: <20200112171430.27219-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112171430.27219-1-digetx@gmail.com> References: <20200112171430.27219-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Tested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 79d19f6ce94e..61339c665ebd 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1608,14 +1608,18 @@ static int tegra_i2c_probe(struct platform_device *pdev) } 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 platform_device *pdev) 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 @@ static int tegra_i2c_probe(struct platform_device *pdev) 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); -- 2.24.0