From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbdIKL3y (ORCPT ); Mon, 11 Sep 2017 07:29:54 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:45824 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbdIKL3w (ORCPT ); Mon, 11 Sep 2017 07:29:52 -0400 Subject: Re: [PATCH v3 1/2] i2c: davinci: Add PM Runtime Support To: Franklin S Cooper Jr , , , , , , , , , References: <20170908175448.3367-1-fcooper@ti.com> <20170908175448.3367-2-fcooper@ti.com> From: Sekhar Nori Message-ID: <57153767-6dee-a5b5-548c-f7b0dc104b46@ti.com> Date: Mon, 11 Sep 2017 16:59:10 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170908175448.3367-2-fcooper@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 08 September 2017 11:24 PM, Franklin S Cooper Jr wrote: > 66AK2G has I2C instances that are not apart of the ALWAYS_ON power domain > like other Keystone 2 SoCs and OMAPL138. Therefore, pm_runtime unlike ? > is required to insure the power domain used by the specific I2C instance is > properly turned on along with its functional clock. > > Signed-off-by: Franklin S Cooper Jr > --- > Version 3 changes: > Remove several statements that set clk to NULL > Fix error path > > drivers/i2c/busses/i2c-davinci.c | 64 +++++++++++++++++++++++++++++++++------- > 1 file changed, 53 insertions(+), 11 deletions(-) > @@ -802,12 +821,22 @@ static int davinci_i2c_probe(struct platform_device *pdev) > dev->clk = devm_clk_get(&pdev->dev, NULL); > if (IS_ERR(dev->clk)) > return PTR_ERR(dev->clk); > - clk_prepare_enable(dev->clk); > > mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > dev->base = devm_ioremap_resource(&pdev->dev, mem); > if (IS_ERR(dev->base)) { > - r = PTR_ERR(dev->base); > + return PTR_ERR(dev->base); > + } > + > + pm_runtime_set_autosuspend_delay(dev->dev, > + DAVINCI_I2C_PM_TIMEOUT); > + pm_runtime_use_autosuspend(dev->dev); > + > + pm_runtime_enable(dev->dev); > + > + r = pm_runtime_get_sync(dev->dev); > + if (r < 0) { > + dev_err(dev->dev, "failed to runtime_get device: %d\n", r); > goto err_unuse_clocks; You end up doing a pm_runtime_put_sync() on failure here, instead of pm_runtime_put_noidle() like rest of the patch. May be handle this failure here instead of relying on the goto path. > } > > @@ -849,27 +878,40 @@ static int davinci_i2c_probe(struct platform_device *pdev) > if (r) > goto err_unuse_clocks; > > + pm_runtime_mark_last_busy(dev->dev); > + pm_runtime_put_autosuspend(dev->dev); > + > return 0; > > err_unuse_clocks: > - clk_disable_unprepare(dev->clk); > - dev->clk = NULL; > + pm_runtime_dont_use_autosuspend(dev->dev); > + pm_runtime_put_sync(dev->dev); > + pm_runtime_disable(dev->dev); > + > return r; > } Thanks, Sekhar