linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Gao Pan <b54642@freescale.com>
Cc: wsa@the-dreams.de, linux-i2c@vger.kernel.org,
	B20596@freescale.com, b38611@freescale.com,
	kernel@pengutronix.de, hkallweit1@gmail.com
Subject: Re: [Patch V8] i2c: imx: add runtime pm support to improve the performance
Date: Tue, 13 Oct 2015 09:07:11 +0200	[thread overview]
Message-ID: <20151013070711.GA3982@pengutronix.de> (raw)
In-Reply-To: <1442569869-10584-1-git-send-email-b54642@freescale.com>

Hello,

On Fri, Sep 18, 2015 at 05:51:09PM +0800, Gao Pan wrote:
> In our former i2c driver, i2c clk is enabled and disabled in
> xfer function, which contributes to power saving. However,
> the clk enable process brings a busy wait delay until the core
> is stable. As a result, the performance is sacrificed.
> 
> To weigh the power consumption and i2c bus performance, runtime
> pm is the good solution for it. The clk is enabled when a i2c
> transfer starts, and disabled after a specifically defined delay.
> 
> Without the patch the test case (many eeprom reads) executes with approx:
> real 1m7.735s
> user 0m0.488s
> sys 0m20.040s
> 
> With the patch the same test case (many eeprom reads) executes with approx:
> real 0m54.241s
> user 0m0.440s
> sys 0m5.920s
> 
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> Signed-off-by: Gao Pan <b54642@freescale.com>

If runtime-pm is disabled the net result of this patch is that the clock
is never disabled, right? I think this is ok, but I would have pointed
that out in the commit log.

> @@ -1037,6 +1045,18 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	/* Set up adapter data */
>  	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
>  
> +	/* Set up platform driver data */
> +	platform_set_drvdata(pdev, i2c_imx);
> +
> +	pm_runtime_set_autosuspend_delay(&pdev->dev, I2C_PM_TIMEOUT);
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_active(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
> +	ret = pm_runtime_get_sync(&pdev->dev);
> +	if (ret < 0)
> +		goto rpm_disable;
> +
>  	/* Set up clock divider */
>  	i2c_imx->bitrate = IMX_I2C_BIT_RATE;
>  	ret = of_property_read_u32(pdev->dev.of_node,
> @@ -1053,12 +1073,11 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	ret = i2c_add_numbered_adapter(&i2c_imx->adapter);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "registration failed\n");
> -		goto clk_disable;
> +		goto rpm_disable;

Is it right, that here the same error path is taken as when
pm_runtime_get_sync fails above? Even if it works now, not having the
error cleanup path undo all things in reverse order is a danger to get
it wrong in the next change. So if this is fixable, it would be nice to
implement.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  parent reply	other threads:[~2015-10-13  7:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  9:51 [Patch V8] i2c: imx: add runtime pm support to improve the performance Gao Pan
2015-09-25  9:36 ` Gao Pandy
2015-10-10  7:30 ` Wolfram Sang
2015-10-13  7:07 ` Uwe Kleine-König [this message]
2015-10-13  9:08   ` Gao Pandy
2015-10-15 17:03     ` Shubhrajyoti Datta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151013070711.GA3982@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=B20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=b54642@freescale.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).