Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4639958ybl; Mon, 13 Jan 2020 17:38:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwvO6dJwghSakG7qxsqBaDx6xeO+4i7SOCFfi4YTEVpgarmqbvwPfQtoG80Ayas0wSczkD9 X-Received: by 2002:a05:6808:4c7:: with SMTP id a7mr14983990oie.83.1578965896765; Mon, 13 Jan 2020 17:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578965896; cv=none; d=google.com; s=arc-20160816; b=eh/DRswg92Z5JCyyLnWUOWSu0XTaTxxYtXGRRxCbTIiYBQcKqOdfxvdVvl+YA4YnRi bJsqU+w4LQp1+fP+xP30bPfJ0QZf7o55aQWtVonHfJdVxDfyDJ+kGF5p+fv7G1qnhnpX 3bgzgDbkxZLn9piVj/sTun/B3NZw8jP0q330yOeBr3lgDQiLDNnc0tpflsHPn1J2dG50 X3vRmK/fZZrqFkYvfwzY0tQkbfQMGTcGebcwWN3KLsKT+Q43cQJDuSYwop6hgb+2YxKF xC4KYMmDELKRIJur3RCXDUgrZ9Z6RZt+a/id4DdsbhaKh5IXyIdtabIMqFfj8eUbWrlG TY6Q== 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=1OzVTCuCrH223Q6o6Mny/CNmcyfK60qlLZIddv7A7e0=; b=bM8bCXLIKzLQzlhrMKZG1VTVMcB86FlwMbrC24Ee1yoYItGgvJnkzRB/J0dA6Qyqhz Qtu3S3wOmXnhlKq+d5j2sYdGev9xNFPyfn/Hx/DklIZozurwOTn2Z4avSPyIRY78422e 0STghGgwEFsqNl0Lsph1CY0dnvudszmqqyXx4F1EDSX2CprJuNg5ry80mi6X39xrevqn dC4M1AgZSdhlbXEUPmLJFbWaB7L+C/BrYrKZXvacBePox6OAgnMG6oxqWQCxLTvMTP+5 9pZer2hQkladid3jQSE8tscbq1fplZ/xDQ4EpjKsU2pNnKHQrjo4PuRDPKLaoVbIs6YN impg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DbQx6W54; 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 r6si7640380otn.216.2020.01.13.17.38.04; Mon, 13 Jan 2020 17:38:16 -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=DbQx6W54; 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 S1729192AbgANBhA (ORCPT + 99 others); Mon, 13 Jan 2020 20:37:00 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34005 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729061AbgANBg6 (ORCPT ); Mon, 13 Jan 2020 20:36:58 -0500 Received: by mail-lj1-f196.google.com with SMTP id z22so12409144ljg.1; Mon, 13 Jan 2020 17:36:56 -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=1OzVTCuCrH223Q6o6Mny/CNmcyfK60qlLZIddv7A7e0=; b=DbQx6W54hhTZMUfciGI8Fow5LTBQdhkLFWMwm0oV+me9gGmHIZajj8B7X6vrrUo8Cr GYnazSXues/YIkaUXdMEws4qfAYO7UFhMR2ZK/yX6xYWPtpBR5vKRNeVCDnWdK9KEBvn E17f0AEdcQCQ8EVDNlr52yYG4RbAdZGbSWzvLIBWN1jcJDpnIiMF9Hqfih9foFLGZkC+ LNdxU6Tc3ntAwalzd/vjdrxA3RIs2MqG9I14hzf8yWWupBBmIPn6slT57k/NxLwUFTUN y6TPv8hdILQPYttiSeNVe2fYVq2Cuz8WeafrlJfizReJnmFtS5fACBzxEs3He4AQqyir yEnQ== 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=1OzVTCuCrH223Q6o6Mny/CNmcyfK60qlLZIddv7A7e0=; b=lLa75qFeG01kfFtg/fR3uo5iunHnaUEMd8twIxB6jIRiGZggRIxPTTAPBuI1jE48tC R3BPTUy/3oiXkZ++7Lb27ydCof2kkD6CFT/8LPjwrnacNrxSE5Mo4/AfmcjqoUB3FTrs tlZhU+VVEz9D4lPm7nXns2+KxqmJMubG2deI+SryLuayn+TFNru6ftMYXrcpN48zOCZx 1UJd+ySZujarlQejx73PEz46RIKkZMf5GAvgPr9m8vD7ffp0KVWvXFYMuYMioawhxXQA 8d2a+0GavwWZyOTzQ6rjKlo6+wkFuYDJQehZue5gHJe5CUwAmaliq8SnmmJtwH/5tYNM usBg== X-Gm-Message-State: APjAAAXbWHCgN4lxq5oOpmy7seAPrg7wfKep7+8Br0XYBolh1+Gw2JRa aNQWJtsa+SF/hV6rgCyweUc= X-Received: by 2002:a2e:818e:: with SMTP id e14mr1660522ljg.2.1578965815401; Mon, 13 Jan 2020 17:36:55 -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 m189sm6427627lfd.92.2020.01.13.17.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 17:36:54 -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 v5 2/8] i2c: tegra: Properly disable runtime PM on driver's probe error Date: Tue, 14 Jan 2020 04:34:36 +0300 Message-Id: <20200114013442.28448-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200114013442.28448-1-digetx@gmail.com> References: <20200114013442.28448-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") Cc: # v5.4+ 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