Received: by 10.223.185.116 with SMTP id b49csp3027002wrg; Sun, 25 Feb 2018 12:00:02 -0800 (PST) X-Google-Smtp-Source: AH8x225s5rTsOBTC4sG9hQGyOVW0hZ1x5FCUN8cLwiG30exol7xdXBYp4kjqxH+LPEo9LUlsysLI X-Received: by 10.98.25.10 with SMTP id 10mr8153294pfz.136.1519588802066; Sun, 25 Feb 2018 12:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519588802; cv=none; d=google.com; s=arc-20160816; b=X5rbHPmla87Q21RhypG8FDTzWfhp1MozZeMA+TC7W6gSclXsUL/A3V0jk8UETY2MHD t2ix0YbqvrHqs/LMmMEbE6X2KL7TwkblYDF5/IB9C/dnlk5mUrqFTblKX5+9qkkSg3bV Wthad+/wjE8XTO++N0VdXhyAEDBe3ALnwpUrXdSg/Hd86INWmukIKlUauzzgDChspuVa OzP30Ei5JvNN9d1JTNZzUJZb7gj8X7aa260F5rUYYEYO6OnTGgFD+fCbKDAGq9j18Uxl kHMI4DTS07CUQ6XQAyny+U9TiDiT0sIZhZAK4gmg+iwGMxLUOkWoZkbJzljwhKg4fzze R1vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=W/qVSN3w7ZCEe4dludJALOf4233pDaQAzHoCNyF+HNw=; b=h+YBQfLj6GjBsb6scjQoCnXYJUYt5Z9PKWdoGPFCKtXNEujjhrC3GYZHh8G4P21gUb 8mckgJOO3BmTZ4emsRPIf1ApNFJhXsvR3ky82YF1y7Ul/35ZpOgxfmZeD+ymNxc5/dzA cx/mIMy2GHk7qPINDKeWEtgeMUpkhKkN+fyUoK/rBMaiMk+1LcQHLkyONUyJydIgfBdd y9OR3hS9qS57imbLjhcoDMrLajlCL1JDQ1chvGJ9joBme7ezFLQuQHm5B3sIFa53EYGr JKsDgDuYwohWzRgfPpSq/Hvb3IF1MPGz5AZ9c+ywQxjYf2DB7F1XpFv5QAFtrwT18377 ZvuA== ARC-Authentication-Results: i=1; mx.google.com; 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 p125si4538409pga.97.2018.02.25.11.59.46; Sun, 25 Feb 2018 12:00:02 -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; 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 S1751964AbeBYT5x (ORCPT + 99 others); Sun, 25 Feb 2018 14:57:53 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34049 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751762AbeBYT5v (ORCPT ); Sun, 25 Feb 2018 14:57:51 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eq2Qf-0000Or-4B; Sun, 25 Feb 2018 20:57:49 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1eq2Qe-0002V5-Am; Sun, 25 Feb 2018 20:57:48 +0100 Date: Sun, 25 Feb 2018 20:57:48 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Tobias Jordan Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfram Sang , "Rafael J. Wysocki" Subject: Re: [PATCH] i2c: imx: Fix PM device usage count Message-ID: <20180225195748.5itrchj36wz5mquu@pengutronix.de> References: <20180224224328.2pfki7rqcxqetmlz@agrajag.zerfleddert.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180224224328.2pfki7rqcxqetmlz@agrajag.zerfleddert.de> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 24, 2018 at 11:43:28PM +0100, Tobias Jordan wrote: > pm_runtime_get_sync() increases the device's usage count even when > reporting an error, so add a call to pm_runtime_put_noidle() in the > related error branches. > > Fixes: 588eb93ea49f ("i2c: imx: add runtime pm support to improve the > performance") > Signed-off-by: Tobias Jordan > --- > In i2c_imx_xfer(), one could also move the "out" label up (in front of > the call to pm_runtime_put_autosuspend()), but I'm not sure what the > underlying error scenario is; calling _put_noidle() seems to be the > safer bet. > > This is one of a number of patches for problems found using coccinelle > scripting in the SIL2LinuxMP project. The patch has been compile-tested; > it's based on linux-next-20180223. > > For a discussion of the corresponding issue, see > https://marc.info/?l=linux-pm&m=151904483924999&w=2 I don't get the original mail, so reply here. In reply to the question I would have asked here, too: > Why isn't ...get_sync() directly calling ...put_noidle() but relies on > the driver implementation to do it? It seems unintuitive for a _get_ > function to increase the usage count although returning an error. Rafael replied: > Because ...get_sync() returns an error when runtime PM is disabled and > we wanted that case to be transparent for the users of it. > > In the majority of cases (if not always) errors returned by > ...get_sync() > mean disabled runtime PM or flaky hardware and the latter is much less > common (and generally there's not much to do about them in the kernel > anyway). If pm_runtime_get_sync() should be transparent for the users if PM is disable, why not simply return success then? Or introduce a return value convention like: <0 (i.e. -ESOMETHIN) is error 0 success 1 PM is disabled (Taking a quick glimpse there seem to be already some cases where 1 or -ESOMETHING is returned, but I didn't find documentation explaining the return values.) Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |