From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BF312C3745; Mon, 25 Aug 2025 11:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756123058; cv=none; b=gbmYv8b4ICpXZTd/N+4AkbmGUJNcHgghInieBaZoAjZGPag+FXQm7K7X3O2U5VJehO9lx+ymG2IzCRWZHmxYw4Sx5CRuRHstQDhb25LsqNuwCl06MSWjT23fQJwtxzX5y+X44c8wTZy7nIHbX5csimqJVu0tbfB5jWLO/XFSgfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756123058; c=relaxed/simple; bh=u2aZrMHjp5VNoFtmPYT/Q13ILrdcSo4FSZG4TtJl/mU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dRJAk7bb8xYpgUzBGpov6r6bsyMaF/BBIsBDALdeZqh/iJbdgUoaKC0daXAOFkNBkqlmKId5TF3iD/QHART/3hngbHnavM4XWOcCtSdtypOZF7PFmqbDOhbOkcEbT0/qr7QnMlBdScpdt7z1PrJ0RWaPJoFl4f9hAuzLDuQ4fp8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GCuoi/2x; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GCuoi/2x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756123057; x=1787659057; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=u2aZrMHjp5VNoFtmPYT/Q13ILrdcSo4FSZG4TtJl/mU=; b=GCuoi/2xqcWJNHEWuT365QuUw1DYy8VlxyTdgrhea24GfHgILpwlYt9s 4IKqI5PHbkwxL4ZRdPbfsVtfbmsyYoCiIcACr/vFfMY+OIjPolwZocOw+ qa5jx4y9s2sYlAqJ1SGYkWybMN2E+EuCBaJP+SSrUdLpt/V9B7+nV3uWk Irs+FushW+V4f/Zh0wFdK+8folHlPqVgMsrhAcik5oAyekevS6tRmLMhf Hu7DXQmVqbySG6rto/dTtFT947Zt73IMOC50gZp5TiL3v9albIvjfiqKa gUi9gHHR4fGtaMnTz2D41U041YwKb2Qc8xroaIw26LsJRTC9+Ug8+Eix3 A==; X-CSE-ConnectionGUID: Z6YNC1pGQJysy12M745u6w== X-CSE-MsgGUID: T/DQk7HJSJCdSYcI+fDOOQ== X-IronPort-AV: E=McAfee;i="6800,10657,11532"; a="58479712" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="58479712" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 04:57:36 -0700 X-CSE-ConnectionGUID: hdTgoxMQSJ63eWNqPKthrA== X-CSE-MsgGUID: +r8EtaYQTHi9Cnk+LVEvvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="169178170" Received: from vpanait-mobl.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.7]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 04:57:27 -0700 Received: from kekkonen.localdomain (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with SMTP id F1E361203CE; Mon, 25 Aug 2025 14:57:23 +0300 (EEST) Date: Mon, 25 Aug 2025 14:57:23 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: Jonathan Cameron Cc: Linus Walleij , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Cai Huoqing , Haibo Chen , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Marek Vasut , Geert Uytterhoeven , Magnus Damm , Lad Prabhakar , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Francesco Dolcini , =?iso-8859-1?Q?Jo=E3o_Paulo_Gon=E7alves?= , "Jiri Slaby (SUSE)" , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Thomas Gleixner , Fabrice Gasnier , "Rob Herring (Arm)" , Christophe JAILLET , Julien Stephan , linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls Message-ID: References: <20250708231144.971170-1-sakari.ailus@linux.intel.com> <20250708231152.971398-1-sakari.ailus@linux.intel.com> <20250709163756.32b0e1d1@jic23-huawei> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250709163756.32b0e1d1@jic23-huawei> Hi Jonathan, Thanks for the review. On Wed, Jul 09, 2025 at 04:37:56PM +0100, Jonathan Cameron wrote: > On Wed, 9 Jul 2025 02:11:52 +0300 > Sakari Ailus wrote: > > > pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(), > > pm_runtime_autosuspend() and pm_request_autosuspend() now include a call > > to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to > > pm_runtime_mark_last_busy(). > > > > Signed-off-by: Sakari Ailus > > Reviewed-by: Linus Walleij > > Some comments for the future as more about what can be improved on the back > of this than what you have here. > > > > > diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c > > index cc326f21d398..3a17b3898bf6 100644 > > --- a/drivers/iio/adc/rcar-gyroadc.c > > +++ b/drivers/iio/adc/rcar-gyroadc.c > > @@ -163,12 +163,10 @@ static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on) > > { > > struct device *dev = priv->dev; > > > This is a very clear example of where the *_set_power() pattern is a bad idea. > There are two calls of this function, one with it hard coded as on and one with it > hard coded as off. We can just push the pm_runtime_resume_and_get() > to the on case etc. > > I don't mind that much if we do so as a follow up patch so this one can > be the mechanical change and then we follow up with the enabled simplification. Ack. I presume this pattern is due to one driver having used it first and then other drivers copying that. I haven't seen it elsewhere, or at least not being used as widely. > > > - if (on) { > > + if (on) > > return pm_runtime_resume_and_get(dev); > > - } else { > > - pm_runtime_mark_last_busy(dev); > > - return pm_runtime_put_autosuspend(dev); > > - } > > + > > + return pm_runtime_put_autosuspend(dev); > > } > > > > static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev, > >> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c > > index 48549d617e5f..f2a93c63ca14 100644 > > --- a/drivers/iio/adc/ti-ads1015.c > > +++ b/drivers/iio/adc/ti-ads1015.c > > @@ -374,12 +374,10 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on) > > int ret; > > struct device *dev = regmap_get_device(data->regmap); > > > > - if (on) { > > + if (on) > > ret = pm_runtime_resume_and_get(dev); > > - } else { > > - pm_runtime_mark_last_busy(dev); > > + else > > ret = pm_runtime_put_autosuspend(dev); > > - } > > > > return ret < 0 ? ret : 0; > So this one has a stub version which only brings benefits because > we have checks on the pm_runtime_put_autosuspend() path failing > (which it does if we have !CONFIG_PM). > > I think the right option there is check the return value is < 0 > for the resume_and_get() and don't check the _put_autosuspend() > return value at all. Then we can just push this down to the > call sites as all of them hard code the bool value. Ack. -- Regards, Sakari Ailus